@elastic/transport
Advanced tools
Comparing version 8.0.0-beta.2 to 8.0.0
@@ -41,3 +41,5 @@ /* | ||
ConnectionRequestOptions, | ||
ConnectionRequestResponse | ||
ConnectionRequestOptionsAsStream, | ||
ConnectionRequestResponse, | ||
ConnectionRequestResponseAsStream | ||
} from './lib/connection' | ||
@@ -51,2 +53,3 @@ | ||
export type { | ||
TransportOptions, | ||
TransportRequestParams, | ||
@@ -53,0 +56,0 @@ TransportRequestOptions, |
@@ -36,6 +36,8 @@ /// <reference types="node" /> | ||
maxCompressedResponseSize?: number; | ||
asStream?: boolean; | ||
signal?: AbortSignal; | ||
timeout?: number; | ||
} | ||
export interface ConnectionRequestOptionsAsStream extends ConnectionRequestOptions { | ||
asStream: true; | ||
} | ||
export interface ConnectionRequestResponse { | ||
@@ -46,2 +48,7 @@ body: string | Buffer; | ||
} | ||
export interface ConnectionRequestResponseAsStream { | ||
body: ReadableStream; | ||
headers: http.IncomingHttpHeaders; | ||
statusCode: number; | ||
} | ||
export default class BaseConnection { | ||
@@ -69,2 +76,3 @@ url: URL; | ||
request(params: ConnectionRequestParams, options: ConnectionRequestOptions): Promise<ConnectionRequestResponse>; | ||
request(params: ConnectionRequestParams, options: ConnectionRequestOptionsAsStream): Promise<ConnectionRequestResponseAsStream>; | ||
close(): Promise<void>; | ||
@@ -71,0 +79,0 @@ [inspect.custom](depth: number, options: Record<string, any>): Record<string, any>; |
@@ -131,3 +131,2 @@ "use strict"; | ||
} | ||
/* istanbul ignore next */ | ||
async request(params, options) { | ||
@@ -134,0 +133,0 @@ throw new errors_1.ConfigurationError('The request method should be implemented by extended classes'); |
@@ -5,3 +5,3 @@ /// <reference types="node" /> | ||
import https from 'https'; | ||
import BaseConnection, { ConnectionOptions, ConnectionRequestParams, ConnectionRequestOptions, ConnectionRequestResponse } from './BaseConnection'; | ||
import BaseConnection, { ConnectionOptions, ConnectionRequestParams, ConnectionRequestOptions, ConnectionRequestOptionsAsStream, ConnectionRequestResponse, ConnectionRequestResponseAsStream } from './BaseConnection'; | ||
export default class HttpConnection extends BaseConnection { | ||
@@ -12,4 +12,5 @@ agent?: http.Agent | https.Agent | hpagent.HttpProxyAgent | hpagent.HttpsProxyAgent; | ||
request(params: ConnectionRequestParams, options: ConnectionRequestOptions): Promise<ConnectionRequestResponse>; | ||
request(params: ConnectionRequestParams, options: ConnectionRequestOptionsAsStream): Promise<ConnectionRequestResponseAsStream>; | ||
close(): Promise<void>; | ||
buildRequestObject(params: ConnectionRequestParams, options: ConnectionRequestOptions): http.ClientRequestArgs; | ||
} |
@@ -22,2 +22,3 @@ "use strict"; | ||
const tslib_1 = require("tslib"); | ||
/* eslint-disable @typescript-eslint/restrict-template-expressions */ | ||
const hpagent_1 = (0, tslib_1.__importDefault)(require("hpagent")); | ||
@@ -108,3 +109,2 @@ const http_1 = (0, tslib_1.__importDefault)(require("http")); | ||
if (options.signal != null) { | ||
// @ts-expect-error | ||
options.signal.addEventListener('abort', () => request.abort(), { once: true }); | ||
@@ -116,2 +116,9 @@ } | ||
this._openRequests--; | ||
if (options.asStream === true) { | ||
return resolve({ | ||
body: response, | ||
statusCode: response.statusCode, | ||
headers: response.headers | ||
}); | ||
} | ||
const contentEncoding = ((_a = response.headers['content-encoding']) !== null && _a !== void 0 ? _a : '').toLowerCase(); | ||
@@ -118,0 +125,0 @@ const isCompressed = contentEncoding.includes('gzip') || contentEncoding.includes('deflate'); |
@@ -5,3 +5,3 @@ import BaseConnection from './BaseConnection'; | ||
export declare type Connection = BaseConnection | HttpConnection | UndiciConnection; | ||
export type { ConnectionOptions, ConnectionRequestParams, ConnectionRequestOptions, ConnectionRequestResponse } from './BaseConnection'; | ||
export type { ConnectionOptions, ConnectionRequestParams, ConnectionRequestOptions, ConnectionRequestOptionsAsStream, ConnectionRequestResponse, ConnectionRequestResponseAsStream } from './BaseConnection'; | ||
export { BaseConnection, HttpConnection, UndiciConnection }; |
/// <reference types="node" /> | ||
import { EventEmitter } from 'events'; | ||
import BaseConnection, { ConnectionOptions, ConnectionRequestParams, ConnectionRequestOptions, ConnectionRequestResponse } from './BaseConnection'; | ||
import BaseConnection, { ConnectionOptions, ConnectionRequestParams, ConnectionRequestOptions, ConnectionRequestOptionsAsStream, ConnectionRequestResponse, ConnectionRequestResponseAsStream } from './BaseConnection'; | ||
import { Pool } from 'undici'; | ||
@@ -11,3 +11,4 @@ import { kEmitter } from '../symbols'; | ||
request(params: ConnectionRequestParams, options: ConnectionRequestOptions): Promise<ConnectionRequestResponse>; | ||
request(params: ConnectionRequestParams, options: ConnectionRequestOptionsAsStream): Promise<ConnectionRequestResponseAsStream>; | ||
close(): Promise<void>; | ||
} |
@@ -23,2 +23,3 @@ "use strict"; | ||
const tslib_1 = require("tslib"); | ||
/* eslint-disable @typescript-eslint/restrict-template-expressions */ | ||
const events_1 = require("events"); | ||
@@ -128,3 +129,2 @@ const debug_1 = (0, tslib_1.__importDefault)(require("debug")); | ||
if (options.signal != null) { | ||
// @ts-expect-error | ||
options.signal.dispatchEvent('abort'); | ||
@@ -163,2 +163,9 @@ } | ||
} | ||
if (options.asStream === true) { | ||
return { | ||
statusCode: response.statusCode, | ||
headers: response.headers, | ||
body: response.body | ||
}; | ||
} | ||
const contentEncoding = ((_o = response.headers['content-encoding']) !== null && _o !== void 0 ? _o : '').toLowerCase(); | ||
@@ -165,0 +172,0 @@ const isCompressed = contentEncoding.includes('gzip') || contentEncoding.includes('deflate'); // eslint-disable-line |
@@ -27,1 +27,4 @@ export declare const kSniffEnabled: unique symbol; | ||
export declare const kMaxCompressedResponseSize: unique symbol; | ||
export declare const kJsonContentType: unique symbol; | ||
export declare const kNdjsonContentType: unique symbol; | ||
export declare const kAcceptHeader: unique symbol; |
@@ -21,3 +21,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.kMaxCompressedResponseSize = exports.kMaxResponseSize = exports.kCaFingerprint = exports.kProductCheck = exports.kEmitter = exports.kStatus = exports.kJsonOptions = exports.kNodeSelector = exports.kNodeFilter = exports.kHeaders = exports.kDiagnostic = exports.kSerializer = exports.kConnectionPool = exports.kContext = exports.kGenerateRequestId = exports.kOpaqueIdPrefix = exports.kName = exports.kMaxRetries = exports.kCompression = exports.kRequestTimeout = exports.kSniffEndpoint = exports.kSniffOnConnectionFault = exports.kSniffInterval = exports.kIsSniffing = exports.kNextSniff = exports.kSniffEnabled = void 0; | ||
exports.kAcceptHeader = exports.kNdjsonContentType = exports.kJsonContentType = exports.kMaxCompressedResponseSize = exports.kMaxResponseSize = exports.kCaFingerprint = exports.kProductCheck = exports.kEmitter = exports.kStatus = exports.kJsonOptions = exports.kNodeSelector = exports.kNodeFilter = exports.kHeaders = exports.kDiagnostic = exports.kSerializer = exports.kConnectionPool = exports.kContext = exports.kGenerateRequestId = exports.kOpaqueIdPrefix = exports.kName = exports.kMaxRetries = exports.kCompression = exports.kRequestTimeout = exports.kSniffEndpoint = exports.kSniffOnConnectionFault = exports.kSniffInterval = exports.kIsSniffing = exports.kNextSniff = exports.kSniffEnabled = void 0; | ||
exports.kSniffEnabled = Symbol('sniff enabled'); | ||
@@ -49,2 +49,5 @@ exports.kNextSniff = Symbol('next sniff'); | ||
exports.kMaxCompressedResponseSize = Symbol('max compressed response size'); | ||
exports.kJsonContentType = Symbol('json content type'); | ||
exports.kNdjsonContentType = Symbol('ndjson content type'); | ||
exports.kAcceptHeader = Symbol('accept header'); | ||
//# sourceMappingURL=symbols.js.map |
@@ -8,3 +8,3 @@ /// <reference types="node" /> | ||
import { nodeFilterFn, nodeSelectorFn, generateRequestIdFn, RequestBody, RequestNDBody, TransportResult, Context } from './types'; | ||
import { kSniffEnabled, kNextSniff, kIsSniffing, kSniffInterval, kSniffOnConnectionFault, kSniffEndpoint, kRequestTimeout, kCompression, kMaxRetries, kName, kOpaqueIdPrefix, kGenerateRequestId, kContext, kConnectionPool, kSerializer, kDiagnostic, kHeaders, kNodeFilter, kNodeSelector, kProductCheck, kMaxResponseSize, kMaxCompressedResponseSize } from './symbols'; | ||
import { kSniffEnabled, kNextSniff, kIsSniffing, kSniffInterval, kSniffOnConnectionFault, kSniffEndpoint, kRequestTimeout, kCompression, kMaxRetries, kName, kOpaqueIdPrefix, kGenerateRequestId, kContext, kConnectionPool, kSerializer, kDiagnostic, kHeaders, kNodeFilter, kNodeSelector, kProductCheck, kMaxResponseSize, kMaxCompressedResponseSize, kJsonContentType, kNdjsonContentType, kAcceptHeader } from './symbols'; | ||
export interface TransportOptions { | ||
@@ -31,2 +31,7 @@ diagnostic?: Diagnostic; | ||
maxCompressedResponseSize?: number; | ||
vendoredHeaders?: { | ||
jsonContentType?: string; | ||
ndjsonContentType?: string; | ||
accept?: string; | ||
}; | ||
} | ||
@@ -115,2 +120,5 @@ export interface TransportRequestParams { | ||
[kMaxCompressedResponseSize]: number; | ||
[kJsonContentType]: string; | ||
[kNdjsonContentType]: string; | ||
[kAcceptHeader]: string; | ||
static sniffReasons: { | ||
@@ -117,0 +125,0 @@ SNIFF_ON_START: string; |
@@ -20,3 +20,3 @@ "use strict"; | ||
*/ | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x; | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -43,3 +43,3 @@ exports.lowerCaseHeaders = exports.generateRequestId = void 0; | ||
constructor(opts) { | ||
var _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11; | ||
var _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20; | ||
Object.defineProperty(this, _a, { | ||
@@ -177,2 +177,20 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(this, _y, { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, _z, { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, _0, { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
if (opts.connectionPool == null) { | ||
@@ -194,24 +212,27 @@ throw new errors_1.ConfigurationError('The Connection Pool option is not defined'); | ||
} | ||
this[symbols_1.kNodeFilter] = (_y = opts.nodeFilter) !== null && _y !== void 0 ? _y : defaultNodeFilter; | ||
this[symbols_1.kNodeSelector] = (_z = opts.nodeSelector) !== null && _z !== void 0 ? _z : roundRobinSelector(); | ||
this[symbols_1.kNodeFilter] = (_1 = opts.nodeFilter) !== null && _1 !== void 0 ? _1 : defaultNodeFilter; | ||
this[symbols_1.kNodeSelector] = (_2 = opts.nodeSelector) !== null && _2 !== void 0 ? _2 : roundRobinSelector(); | ||
this[symbols_1.kHeaders] = Object.assign({}, { 'user-agent': userAgent }, opts.compression === true ? { 'accept-encoding': 'gzip,deflate' } : null, lowerCaseHeaders(opts.headers)); | ||
this[symbols_1.kDiagnostic] = (_0 = opts.diagnostic) !== null && _0 !== void 0 ? _0 : new Diagnostic_1.default(); | ||
this[symbols_1.kDiagnostic] = (_3 = opts.diagnostic) !== null && _3 !== void 0 ? _3 : new Diagnostic_1.default(); | ||
this[symbols_1.kConnectionPool] = opts.connectionPool; | ||
this[symbols_1.kSerializer] = (_1 = opts.serializer) !== null && _1 !== void 0 ? _1 : new Serializer_1.default(); | ||
this[symbols_1.kContext] = (_2 = opts.context) !== null && _2 !== void 0 ? _2 : null; | ||
this[symbols_1.kGenerateRequestId] = (_3 = opts.generateRequestId) !== null && _3 !== void 0 ? _3 : generateRequestId(); | ||
this[symbols_1.kOpaqueIdPrefix] = (_4 = opts.opaqueIdPrefix) !== null && _4 !== void 0 ? _4 : null; | ||
this[symbols_1.kName] = (_5 = opts.name) !== null && _5 !== void 0 ? _5 : 'elastic-transport-js'; | ||
this[symbols_1.kSerializer] = (_4 = opts.serializer) !== null && _4 !== void 0 ? _4 : new Serializer_1.default(); | ||
this[symbols_1.kContext] = (_5 = opts.context) !== null && _5 !== void 0 ? _5 : null; | ||
this[symbols_1.kGenerateRequestId] = (_6 = opts.generateRequestId) !== null && _6 !== void 0 ? _6 : generateRequestId(); | ||
this[symbols_1.kOpaqueIdPrefix] = (_7 = opts.opaqueIdPrefix) !== null && _7 !== void 0 ? _7 : null; | ||
this[symbols_1.kName] = (_8 = opts.name) !== null && _8 !== void 0 ? _8 : 'elastic-transport-js'; | ||
this[symbols_1.kMaxRetries] = typeof opts.maxRetries === 'number' ? opts.maxRetries : 3; | ||
this[symbols_1.kCompression] = opts.compression === true; | ||
this[symbols_1.kRequestTimeout] = opts.requestTimeout != null ? toMs(opts.requestTimeout) : 30000; | ||
this[symbols_1.kSniffInterval] = (_6 = opts.sniffInterval) !== null && _6 !== void 0 ? _6 : false; | ||
this[symbols_1.kSniffInterval] = (_9 = opts.sniffInterval) !== null && _9 !== void 0 ? _9 : false; | ||
this[symbols_1.kSniffEnabled] = typeof this[symbols_1.kSniffInterval] === 'number'; | ||
this[symbols_1.kNextSniff] = this[symbols_1.kSniffEnabled] ? (Date.now() + this[symbols_1.kSniffInterval]) : 0; | ||
this[symbols_1.kIsSniffing] = false; | ||
this[symbols_1.kSniffOnConnectionFault] = (_7 = opts.sniffOnConnectionFault) !== null && _7 !== void 0 ? _7 : false; | ||
this[symbols_1.kSniffEndpoint] = (_8 = opts.sniffEndpoint) !== null && _8 !== void 0 ? _8 : null; | ||
this[symbols_1.kProductCheck] = (_9 = opts.productCheck) !== null && _9 !== void 0 ? _9 : null; | ||
this[symbols_1.kMaxResponseSize] = (_10 = opts.maxResponseSize) !== null && _10 !== void 0 ? _10 : buffer_1.default.constants.MAX_STRING_LENGTH; | ||
this[symbols_1.kMaxCompressedResponseSize] = (_11 = opts.maxCompressedResponseSize) !== null && _11 !== void 0 ? _11 : buffer_1.default.constants.MAX_LENGTH; | ||
this[symbols_1.kSniffOnConnectionFault] = (_10 = opts.sniffOnConnectionFault) !== null && _10 !== void 0 ? _10 : false; | ||
this[symbols_1.kSniffEndpoint] = (_11 = opts.sniffEndpoint) !== null && _11 !== void 0 ? _11 : null; | ||
this[symbols_1.kProductCheck] = (_12 = opts.productCheck) !== null && _12 !== void 0 ? _12 : null; | ||
this[symbols_1.kMaxResponseSize] = (_13 = opts.maxResponseSize) !== null && _13 !== void 0 ? _13 : buffer_1.default.constants.MAX_STRING_LENGTH; | ||
this[symbols_1.kMaxCompressedResponseSize] = (_14 = opts.maxCompressedResponseSize) !== null && _14 !== void 0 ? _14 : buffer_1.default.constants.MAX_LENGTH; | ||
this[symbols_1.kJsonContentType] = (_16 = (_15 = opts.vendoredHeaders) === null || _15 === void 0 ? void 0 : _15.jsonContentType) !== null && _16 !== void 0 ? _16 : 'application/json'; | ||
this[symbols_1.kNdjsonContentType] = (_18 = (_17 = opts.vendoredHeaders) === null || _17 === void 0 ? void 0 : _17.ndjsonContentType) !== null && _18 !== void 0 ? _18 : 'application/x-ndjson'; | ||
this[symbols_1.kAcceptHeader] = (_20 = (_19 = opts.vendoredHeaders) === null || _19 === void 0 ? void 0 : _19.accept) !== null && _20 !== void 0 ? _20 : 'application/json, text/plain'; | ||
if (opts.sniffOnStart === true) { | ||
@@ -250,3 +271,3 @@ this.sniff({ | ||
async request(params, options = {}) { | ||
var _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11; | ||
var _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13; | ||
const connectionParams = { | ||
@@ -261,3 +282,3 @@ method: params.method, | ||
options: options, | ||
id: (_y = options.id) !== null && _y !== void 0 ? _y : this[symbols_1.kGenerateRequestId](params, options) | ||
id: (_1 = options.id) !== null && _1 !== void 0 ? _1 : this[symbols_1.kGenerateRequestId](params, options) | ||
}, | ||
@@ -269,3 +290,3 @@ name: this[symbols_1.kName], | ||
}; | ||
const returnMeta = (_z = options.meta) !== null && _z !== void 0 ? _z : false; | ||
const returnMeta = (_2 = options.meta) !== null && _2 !== void 0 ? _2 : false; | ||
if (this[symbols_1.kContext] != null && options.context != null) { | ||
@@ -288,4 +309,4 @@ meta.context = Object.assign({}, this[symbols_1.kContext], options.context); | ||
get warnings() { | ||
var _y; | ||
return ((_y = this.headers) === null || _y === void 0 ? void 0 : _y.warning) != null | ||
var _1; | ||
return ((_1 = this.headers) === null || _1 === void 0 ? void 0 : _1.warning) != null | ||
? this.headers.warning.split(/(?!\B"[^"]*),(?![^"]*"\B)/) | ||
@@ -299,7 +320,7 @@ : null; | ||
// Furthermore, copying everytime the stream is very a expensive operation. | ||
const maxRetries = isStream((_0 = params.body) !== null && _0 !== void 0 ? _0 : params.bulkBody) ? 0 : (typeof options.maxRetries === 'number' ? options.maxRetries : this[symbols_1.kMaxRetries]); | ||
const maxRetries = isStream((_3 = params.body) !== null && _3 !== void 0 ? _3 : params.bulkBody) ? 0 : (typeof options.maxRetries === 'number' ? options.maxRetries : this[symbols_1.kMaxRetries]); | ||
const compression = typeof options.compression === 'boolean' ? options.compression : this[symbols_1.kCompression]; | ||
const signal = options.signal; | ||
const maxResponseSize = (_1 = options.maxResponseSize) !== null && _1 !== void 0 ? _1 : this[symbols_1.kMaxResponseSize]; | ||
const maxCompressedResponseSize = (_2 = options.maxCompressedResponseSize) !== null && _2 !== void 0 ? _2 : this[symbols_1.kMaxCompressedResponseSize]; | ||
const maxResponseSize = (_4 = options.maxResponseSize) !== null && _4 !== void 0 ? _4 : this[symbols_1.kMaxResponseSize]; | ||
const maxCompressedResponseSize = (_5 = options.maxCompressedResponseSize) !== null && _5 !== void 0 ? _5 : this[symbols_1.kMaxCompressedResponseSize]; | ||
this[symbols_1.kDiagnostic].emit('serialization', null, result); | ||
@@ -322,10 +343,10 @@ const headers = Object.assign({}, this[symbols_1.kHeaders], lowerCaseHeaders(options.headers)); | ||
} | ||
headers['content-type'] = (_6 = headers['content-type']) !== null && _6 !== void 0 ? _6 : this[symbols_1.kJsonContentType]; | ||
} | ||
else { | ||
if (params.body !== '') { | ||
headers['content-type'] = (_7 = headers['content-type']) !== null && _7 !== void 0 ? _7 : 'text/plain'; | ||
} | ||
connectionParams.body = params.body; | ||
} | ||
if (params.body !== '') { | ||
headers['content-type'] = (_3 = headers['content-type']) !== null && _3 !== void 0 ? _3 : 'application/vnd.elasticsearch+json; compatible-with=8'; | ||
headers.accept = (_4 = headers.accept) !== null && _4 !== void 0 ? _4 : 'application/vnd.elasticsearch+json; compatible-with=8'; | ||
} | ||
// handle ndjson body | ||
@@ -347,4 +368,3 @@ } | ||
if (connectionParams.body !== '') { | ||
headers['content-type'] = (_5 = headers['content-type']) !== null && _5 !== void 0 ? _5 : 'application/vnd.elasticsearch+x-ndjson; compatible-with=8'; | ||
headers.accept = (_6 = headers.accept) !== null && _6 !== void 0 ? _6 : 'application/vnd.elasticsearch+json; compatible-with=8'; | ||
headers['content-type'] = (_8 = headers['content-type']) !== null && _8 !== void 0 ? _8 : this[symbols_1.kNdjsonContentType]; | ||
} | ||
@@ -359,4 +379,2 @@ } | ||
} | ||
// TODO: fixme | ||
// if (options.asStream === true) params.asStream = true | ||
// handle compression | ||
@@ -387,3 +405,3 @@ if (connectionParams.body !== '' && connectionParams.body != null) { | ||
} | ||
headers.accept = (_7 = headers.accept) !== null && _7 !== void 0 ? _7 : 'application/vnd.elasticsearch+json; compatible-with=8,text/plain'; | ||
headers.accept = (_9 = headers.accept) !== null && _9 !== void 0 ? _9 : this[symbols_1.kAcceptHeader]; | ||
connectionParams.headers = headers; | ||
@@ -411,3 +429,4 @@ while (meta.attempts <= maxRetries) { | ||
signal, | ||
timeout: toMs(options.requestTimeout != null ? options.requestTimeout : this[symbols_1.kRequestTimeout]) | ||
timeout: toMs(options.requestTimeout != null ? options.requestTimeout : this[symbols_1.kRequestTimeout]), | ||
...(options.asStream === true ? { asStream: true } : null) | ||
}); | ||
@@ -419,16 +438,15 @@ result.statusCode = statusCode; | ||
} | ||
const contentEncoding = ((_8 = headers['content-encoding']) !== null && _8 !== void 0 ? _8 : '').toLowerCase(); | ||
if (options.asStream === true) { | ||
result.body = body; | ||
this[symbols_1.kDiagnostic].emit('response', null, result); | ||
return returnMeta ? result : body; | ||
} | ||
const contentEncoding = ((_10 = headers['content-encoding']) !== null && _10 !== void 0 ? _10 : '').toLowerCase(); | ||
if (contentEncoding.includes('gzip') || contentEncoding.includes('deflate')) { | ||
body = await unzip(body); | ||
} | ||
const isVectorTile = ((_9 = headers['content-type']) !== null && _9 !== void 0 ? _9 : '').includes('application/vnd.mapbox-vector-tile'); | ||
const isVectorTile = ((_11 = headers['content-type']) !== null && _11 !== void 0 ? _11 : '').includes('application/vnd.mapbox-vector-tile'); | ||
if (Buffer.isBuffer(body) && !isVectorTile) { | ||
body = body.toString(); | ||
} | ||
// TODO: fixme | ||
// if (options.asStream === true) { | ||
// result.body = response | ||
// this[kDiagnostic].emit('response', null, result) | ||
// return result | ||
// } | ||
const isHead = params.method === 'HEAD'; | ||
@@ -440,4 +458,4 @@ // we should attempt the payload deserialization only if: | ||
if (headers['content-type'] !== undefined && | ||
(((_10 = headers['content-type']) === null || _10 === void 0 ? void 0 : _10.includes('application/json')) || | ||
((_11 = headers['content-type']) === null || _11 === void 0 ? void 0 : _11.includes('application/vnd.elasticsearch+json'))) && | ||
(((_12 = headers['content-type']) === null || _12 === void 0 ? void 0 : _12.includes('application/json')) || | ||
((_13 = headers['content-type']) === null || _13 === void 0 ? void 0 : _13.includes('application/vnd.elasticsearch+json'))) && | ||
!isHead && body !== '') { // eslint-disable-line | ||
@@ -556,3 +574,3 @@ result.body = this[symbols_1.kSerializer].deserialize(body); | ||
exports.default = Transport; | ||
_a = symbols_1.kNodeFilter, _b = symbols_1.kNodeSelector, _c = symbols_1.kHeaders, _d = symbols_1.kDiagnostic, _e = symbols_1.kConnectionPool, _f = symbols_1.kSerializer, _g = symbols_1.kContext, _h = symbols_1.kGenerateRequestId, _j = symbols_1.kOpaqueIdPrefix, _k = symbols_1.kName, _l = symbols_1.kMaxRetries, _m = symbols_1.kCompression, _o = symbols_1.kRequestTimeout, _p = symbols_1.kSniffEnabled, _q = symbols_1.kNextSniff, _r = symbols_1.kIsSniffing, _s = symbols_1.kSniffInterval, _t = symbols_1.kSniffOnConnectionFault, _u = symbols_1.kSniffEndpoint, _v = symbols_1.kProductCheck, _w = symbols_1.kMaxResponseSize, _x = symbols_1.kMaxCompressedResponseSize; | ||
_a = symbols_1.kNodeFilter, _b = symbols_1.kNodeSelector, _c = symbols_1.kHeaders, _d = symbols_1.kDiagnostic, _e = symbols_1.kConnectionPool, _f = symbols_1.kSerializer, _g = symbols_1.kContext, _h = symbols_1.kGenerateRequestId, _j = symbols_1.kOpaqueIdPrefix, _k = symbols_1.kName, _l = symbols_1.kMaxRetries, _m = symbols_1.kCompression, _o = symbols_1.kRequestTimeout, _p = symbols_1.kSniffEnabled, _q = symbols_1.kNextSniff, _r = symbols_1.kIsSniffing, _s = symbols_1.kSniffInterval, _t = symbols_1.kSniffOnConnectionFault, _u = symbols_1.kSniffEndpoint, _v = symbols_1.kProductCheck, _w = symbols_1.kMaxResponseSize, _x = symbols_1.kMaxCompressedResponseSize, _y = symbols_1.kJsonContentType, _z = symbols_1.kNdjsonContentType, _0 = symbols_1.kAcceptHeader; | ||
Object.defineProperty(Transport, "sniffReasons", { | ||
@@ -559,0 +577,0 @@ enumerable: true, |
{ | ||
"name": "@elastic/transport", | ||
"version": "8.0.0-beta.2", | ||
"version": "8.0.0", | ||
"description": "Transport classes and utilities shared among Node.js Elastic client libraries", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
226787
3542
0