@algolia/transporter
Advanced tools
Comparing version 4.0.0-beta.10 to 4.0.0-beta.11
@@ -8,3 +8,3 @@ 'use strict'; | ||
// eslint-disable-next-line functional/prefer-readonly-type | ||
const data = {}; | ||
const data = options.data || {}; | ||
Object.keys(options).forEach(key => { | ||
@@ -16,3 +16,3 @@ if (['timeout', 'headers', 'queryParameters', 'data', 'cacheable'].indexOf(key) === -1) { | ||
return { | ||
data, | ||
data: Object.entries(data).length > 0 ? data : undefined, | ||
timeout: options.timeout || timeout, | ||
@@ -87,3 +87,3 @@ headers: options.headers || {}, | ||
* | ||
* 6 (timeouted) > 7 (timeouted) > 8 ... | ||
* 5 (timeouted) > 6 (timeouted) > 7 ... | ||
* | ||
@@ -393,8 +393,8 @@ * This strategy may need to be reviewed, but is the strategy on the our | ||
function serializeData(request, requestOptions) { | ||
if (request.data === undefined && requestOptions.data === undefined) { | ||
return undefined; | ||
} | ||
const data = Array.isArray(request.data) | ||
? request.data | ||
: { ...request.data, ...requestOptions.data }; | ||
if (data.constructor === Object && Object.entries(data).length === 0) { | ||
return ''; | ||
} | ||
return JSON.stringify(data); | ||
@@ -401,0 +401,0 @@ } |
@@ -65,5 +65,2 @@ import { Cache } from '@algolia/cache-common'; | ||
readonly timeout: number | undefined; | ||
readonly data: { | ||
[key: string]: string; | ||
}; | ||
readonly headers: { | ||
@@ -75,2 +72,5 @@ [key: string]: string; | ||
}; | ||
readonly data?: { | ||
[key: string]: string; | ||
}; | ||
}; | ||
@@ -109,3 +109,3 @@ | ||
/** | ||
* Custom query paramters for the request. This query parameters are | ||
* Custom query parameters for the request. This query parameters are | ||
* going to be merged the transporter query parameters. | ||
@@ -117,2 +117,9 @@ */ | ||
/** | ||
* Custom data for the request. This data are | ||
* going to be merged the transporter data. | ||
*/ | ||
readonly data?: { | ||
[key: string]: any; | ||
}; | ||
/** | ||
* Additional request body values. It's only taken in | ||
@@ -132,3 +139,3 @@ * consideration in `POST` and `PUT` requests. | ||
export declare function serializeData(request: Request, requestOptions: RequestOptions): string; | ||
export declare function serializeData(request: Request, requestOptions: RequestOptions): string | undefined; | ||
@@ -135,0 +142,0 @@ export declare function serializeQueryParameters(parameters: { |
function createMappedRequestOptions(requestOptions, timeout) { | ||
const options = requestOptions || {}; | ||
// eslint-disable-next-line functional/prefer-readonly-type | ||
const data = {}; | ||
const data = options.data || {}; | ||
Object.keys(options).forEach(key => { | ||
@@ -11,3 +11,3 @@ if (['timeout', 'headers', 'queryParameters', 'data', 'cacheable'].indexOf(key) === -1) { | ||
return { | ||
data, | ||
data: Object.entries(data).length > 0 ? data : undefined, | ||
timeout: options.timeout || timeout, | ||
@@ -82,3 +82,3 @@ headers: options.headers || {}, | ||
* | ||
* 6 (timeouted) > 7 (timeouted) > 8 ... | ||
* 5 (timeouted) > 6 (timeouted) > 7 ... | ||
* | ||
@@ -388,8 +388,8 @@ * This strategy may need to be reviewed, but is the strategy on the our | ||
function serializeData(request, requestOptions) { | ||
if (request.data === undefined && requestOptions.data === undefined) { | ||
return undefined; | ||
} | ||
const data = Array.isArray(request.data) | ||
? request.data | ||
: { ...request.data, ...requestOptions.data }; | ||
if (data.constructor === Object && Object.entries(data).length === 0) { | ||
return ''; | ||
} | ||
return JSON.stringify(data); | ||
@@ -396,0 +396,0 @@ } |
{ | ||
"name": "@algolia/transporter", | ||
"version": "4.0.0-beta.10", | ||
"version": "4.0.0-beta.11", | ||
"private": false, | ||
@@ -16,6 +16,6 @@ "description": "Promise-based transporter layer with embedded retry strategy.", | ||
"dependencies": { | ||
"@algolia/cache-common": "4.0.0-beta.10", | ||
"@algolia/logger-common": "4.0.0-beta.10", | ||
"@algolia/requester-common": "4.0.0-beta.10" | ||
"@algolia/cache-common": "4.0.0-beta.11", | ||
"@algolia/logger-common": "4.0.0-beta.11", | ||
"@algolia/requester-common": "4.0.0-beta.11" | ||
} | ||
} |
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
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
42198
996
+ Added@algolia/cache-common@4.0.0-beta.11(transitive)
+ Added@algolia/logger-common@4.0.0-beta.11(transitive)
+ Added@algolia/requester-common@4.0.0-beta.11(transitive)
- Removed@algolia/cache-common@4.0.0-beta.10(transitive)
- Removed@algolia/logger-common@4.0.0-beta.10(transitive)
- Removed@algolia/requester-common@4.0.0-beta.10(transitive)