Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@algolia/transporter

Package Overview
Dependencies
Maintainers
61
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@algolia/transporter - npm Package Compare versions

Comparing version 4.0.0-beta.14 to 4.0.0-beta.15

84

dist/transporter.cjs.js

@@ -158,3 +158,3 @@ 'use strict';

if (host === undefined) {
throw createRetryError(stackTrace);
throw createRetryError(stackTraceWithoutCredentials(stackTrace));
}

@@ -169,18 +169,23 @@ const payload = {

};
/**
* The stackFrame is pushed to the stackTrace so we
* can have information about onRetry and onFailure
* decisions.
*/
const pushToStackTrace = (response) => {
const stackFrame = {
request: payload,
response,
host,
triesLeft: hosts.length,
};
// eslint-disable-next-line functional/immutable-data
stackTrace.push(stackFrame);
return stackFrame;
};
const decisions = {
onSucess: response => deserializeSuccess(response),
onRetry(response) {
const stackFrame = {
request: payload,
response,
host,
triesLeft: hosts.length,
};
const stackFrame = pushToStackTrace(response);
/**
* The stackFrace is pushed to the stackTrace so we
* can have information about the failures once a
* retry error is thrown.
*/
stackTrace.push(stackFrame); // eslint-disable-line functional/immutable-data
/**
* If response is a timeout, we increaset the number of

@@ -198,3 +203,3 @@ * timeouts so we can increase the timeout later.

*/
transporter.logger.debug('Retryable failure', stackFrame),
transporter.logger.info('Retryable failure', stackFrameWithoutCredentials(stackFrame)),
/**

@@ -209,3 +214,4 @@ * We also store the state of the host in failure cases. If the host, is

onFail(response) {
throw deserializeFailure(response);
pushToStackTrace(response);
throw deserializeFailure(response, stackTraceWithoutCredentials(stackTrace));
},

@@ -341,10 +347,2 @@ };

function createDeserializationError(message, response) {
return {
name: 'DeserializationError',
message,
response,
};
}
function deserializeSuccess(response) {

@@ -359,3 +357,3 @@ // eslint-disable-next-line functional/no-try-statement

}
function deserializeFailure({ content, status }) {
function deserializeFailure({ content, status }, stackFrame) {
// eslint-disable-next-line functional/no-let

@@ -370,3 +368,3 @@ let message = content;

}
return createApiError(message, status);
return createApiError(message, status, stackFrame);
}

@@ -422,15 +420,43 @@

function createApiError(message, status) {
function stackTraceWithoutCredentials(stackTrace) {
return stackTrace.map(stackFrame => stackFrameWithoutCredentials(stackFrame));
}
function stackFrameWithoutCredentials(stackFrame) {
const modifiedHeaders = stackFrame.request.headers['x-algolia-api-key']
? { 'x-algolia-api-key': '*****' }
: {};
return {
...stackFrame,
request: {
...stackFrame.request,
headers: {
...stackFrame.request.headers,
...modifiedHeaders,
},
},
};
}
function createApiError(message, status, transporterStackTrace) {
return {
name: 'ApiError',
message,
status,
transporterStackTrace,
};
}
function createRetryError(stackTrace) {
function createDeserializationError(message, response) {
return {
name: 'DeserializationError',
message,
response,
};
}
function createRetryError(transporterStackTrace) {
return {
name: 'RetryError',
message: 'Unreachable hosts - your application id may be incorrect. If the error persists, contact support@algolia.com.',
stackTrace,
transporterStackTrace,
};

@@ -457,1 +483,3 @@ }

exports.serializeUrl = serializeUrl;
exports.stackFrameWithoutCredentials = stackFrameWithoutCredentials;
exports.stackTraceWithoutCredentials = stackTraceWithoutCredentials;

@@ -13,2 +13,7 @@ import { Cache } from '@algolia/cache-common';

readonly status: number;
/**
* Contains report of stack frames of the
* execution of a certain request.
*/
readonly transporterStackTrace: readonly StackFrame[];
};

@@ -20,3 +25,3 @@

export declare function createApiError(message: string, status: number): ApiError;
export declare function createApiError(message: string, status: number, transporterStackTrace: readonly StackFrame[]): ApiError;

@@ -27,3 +32,3 @@ export declare function createDeserializationError(message: string, response: Response): DeserializationError;

export declare function createRetryError(stackTrace: readonly StackFrame[]): RetryError;
export declare function createRetryError(transporterStackTrace: readonly StackFrame[]): RetryError;

@@ -45,3 +50,3 @@ export declare function createStatefulHost(host: StatelessHost, status?: HostStatusType): StatefulHost;

export declare function deserializeFailure({ content, status }: Response): Error;
export declare function deserializeFailure({ content, status }: Response, stackFrame: readonly StackFrame[]): Error;

@@ -158,3 +163,3 @@ export declare function deserializeSuccess<TObject>(response: Response): TObject;

*/
readonly stackTrace: readonly StackFrame[];
readonly transporterStackTrace: readonly StackFrame[];
};

@@ -189,2 +194,6 @@

export declare function stackFrameWithoutCredentials(stackFrame: StackFrame): StackFrame;
export declare function stackTraceWithoutCredentials(stackTrace: readonly StackFrame[]): readonly StackFrame[];
export declare type StatefulHost = StatelessHost & {

@@ -191,0 +200,0 @@ /**

@@ -154,3 +154,3 @@ import { MethodEnum } from '@algolia/requester-common';

if (host === undefined) {
throw createRetryError(stackTrace);
throw createRetryError(stackTraceWithoutCredentials(stackTrace));
}

@@ -165,18 +165,23 @@ const payload = {

};
/**
* The stackFrame is pushed to the stackTrace so we
* can have information about onRetry and onFailure
* decisions.
*/
const pushToStackTrace = (response) => {
const stackFrame = {
request: payload,
response,
host,
triesLeft: hosts.length,
};
// eslint-disable-next-line functional/immutable-data
stackTrace.push(stackFrame);
return stackFrame;
};
const decisions = {
onSucess: response => deserializeSuccess(response),
onRetry(response) {
const stackFrame = {
request: payload,
response,
host,
triesLeft: hosts.length,
};
const stackFrame = pushToStackTrace(response);
/**
* The stackFrace is pushed to the stackTrace so we
* can have information about the failures once a
* retry error is thrown.
*/
stackTrace.push(stackFrame); // eslint-disable-line functional/immutable-data
/**
* If response is a timeout, we increaset the number of

@@ -194,3 +199,3 @@ * timeouts so we can increase the timeout later.

*/
transporter.logger.debug('Retryable failure', stackFrame),
transporter.logger.info('Retryable failure', stackFrameWithoutCredentials(stackFrame)),
/**

@@ -205,3 +210,4 @@ * We also store the state of the host in failure cases. If the host, is

onFail(response) {
throw deserializeFailure(response);
pushToStackTrace(response);
throw deserializeFailure(response, stackTraceWithoutCredentials(stackTrace));
},

@@ -337,10 +343,2 @@ };

function createDeserializationError(message, response) {
return {
name: 'DeserializationError',
message,
response,
};
}
function deserializeSuccess(response) {

@@ -355,3 +353,3 @@ // eslint-disable-next-line functional/no-try-statement

}
function deserializeFailure({ content, status }) {
function deserializeFailure({ content, status }, stackFrame) {
// eslint-disable-next-line functional/no-let

@@ -366,3 +364,3 @@ let message = content;

}
return createApiError(message, status);
return createApiError(message, status, stackFrame);
}

@@ -418,18 +416,46 @@

function createApiError(message, status) {
function stackTraceWithoutCredentials(stackTrace) {
return stackTrace.map(stackFrame => stackFrameWithoutCredentials(stackFrame));
}
function stackFrameWithoutCredentials(stackFrame) {
const modifiedHeaders = stackFrame.request.headers['x-algolia-api-key']
? { 'x-algolia-api-key': '*****' }
: {};
return {
...stackFrame,
request: {
...stackFrame.request,
headers: {
...stackFrame.request.headers,
...modifiedHeaders,
},
},
};
}
function createApiError(message, status, transporterStackTrace) {
return {
name: 'ApiError',
message,
status,
transporterStackTrace,
};
}
function createRetryError(stackTrace) {
function createDeserializationError(message, response) {
return {
name: 'DeserializationError',
message,
response,
};
}
function createRetryError(transporterStackTrace) {
return {
name: 'RetryError',
message: 'Unreachable hosts - your application id may be incorrect. If the error persists, contact support@algolia.com.',
stackTrace,
transporterStackTrace,
};
}
export { CallEnum, HostStatusEnum, createApiError, createDeserializationError, createMappedRequestOptions, createRetryError, createStatefulHost, createStatelessHost, createTransporter, createUserAgent, deserializeFailure, deserializeSuccess, isStatefulHostTimeouted, isStatefulHostUp, serializeData, serializeHeaders, serializeQueryParameters, serializeUrl };
export { CallEnum, HostStatusEnum, createApiError, createDeserializationError, createMappedRequestOptions, createRetryError, createStatefulHost, createStatelessHost, createTransporter, createUserAgent, deserializeFailure, deserializeSuccess, isStatefulHostTimeouted, isStatefulHostUp, serializeData, serializeHeaders, serializeQueryParameters, serializeUrl, stackFrameWithoutCredentials, stackTraceWithoutCredentials };
{
"name": "@algolia/transporter",
"version": "4.0.0-beta.14",
"version": "4.0.0-beta.15",
"private": false,

@@ -16,6 +16,6 @@ "description": "Promise-based transporter layer with embedded retry strategy.",

"dependencies": {
"@algolia/cache-common": "4.0.0-beta.14",
"@algolia/logger-common": "4.0.0-beta.14",
"@algolia/requester-common": "4.0.0-beta.14"
"@algolia/cache-common": "4.0.0-beta.15",
"@algolia/logger-common": "4.0.0-beta.15",
"@algolia/requester-common": "4.0.0-beta.15"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc