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

@twilio/flex-plugins-library-utils

Package Overview
Dependencies
Maintainers
0
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@twilio/flex-plugins-library-utils - npm Package Compare versions

Comparing version 1.1.6 to 1.1.7

9

CHANGELOG.md

@@ -93,1 +93,10 @@ # Changelog

- Removed the default limit of 1000 imposed on the `listPhoneNumbers` method of `PhoneNumberUtils` as the library automatically fetches all pages without specifying a limit.
## 1.1.7
**v1.1.7** of **`@twilio/flex-plugins-library-utils`**! is released
### Fixed
- Updated the retry logic and added default values for rety configuration

2

dist/common/retryHandler.d.ts

@@ -6,3 +6,3 @@ import { Parameters, PluginsUtilsMetaData, TwilioError, RetryCallbackFunction } from '../types';

* @param {object} parameters the parameters to call the callback with
* @param {number} parameters.attempts the number of retry attempts performed
* @param {function} callback the callback function to retry

@@ -9,0 +9,0 @@ * @returns {any}

@@ -20,3 +20,3 @@ "use strict";

* @param {object} parameters the parameters to call the callback with
* @param {number} parameters.attempts the number of retry attempts performed
* @param {function} callback the callback function to retry

@@ -52,4 +52,3 @@ * @returns {any}

console.warn(`retrying ${callback.name}() after ${logWarning}, status code: ${status}`);
if (status === statusCodes_1.HttpErrorCode.TooManyRequests || status === statusCodes_1.HttpErrorCode.ServiceUnavailable)
yield (0, utils_1.snooze)((0, lodash_1.random)(minBackoff, maxBackoff));
yield (0, utils_1.snooze)((0, lodash_1.random)(minBackoff, maxBackoff));
const updatedAttempts = attempts + 1;

@@ -56,0 +55,0 @@ const updatedParameters = Object.assign(Object.assign({}, parameters), { attempts: updatedAttempts });

@@ -11,1 +11,6 @@ export declare const TwilioApis: {

}
export declare const enum RETRY_STRATEGY {
MIN_BACKOFF = 100,
MAX_BACKOFF = 300,
RETRY_LIMIT = 3
}

@@ -26,3 +26,3 @@ import { Twilio } from 'twilio';

* @param {boolean} parameters.coaching the coaching status
* @param {number} parameters.attempts the number of retry attempts performed
* @returns {any}

@@ -39,3 +39,3 @@ * @description the following method is used to modify a participant

* @param {boolean} parameters.muted the muted status
* @param {number} parameters.attempts the number of retry attempts performed
* @returns {any}

@@ -49,3 +49,3 @@ * @description the following method is used to modify a participant

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.taskSid the unique task SID to modify

@@ -61,3 +61,3 @@ * @param {string} parameters.to the phone number to add to the conference

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.conference the unique conference SID with the participant

@@ -73,3 +73,3 @@ * @param {string} parameters.participant the unique participant SID to modify

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.conferenceSid the unique conference SID with the participant

@@ -84,3 +84,3 @@ * @param {string} parameters.participantSid the unique participant SID to remove

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.conferenceSid the unique conference SID with the participant

@@ -95,3 +95,3 @@ * @param {string} parameters.participantSid the unique participant SID to remove

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.conferenceSid the unique conference SID with the participant

@@ -109,3 +109,3 @@ * @param {string} parameters.participantSid the unique participant SID to modify

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.taskSid the task SID to fetch conferences for

@@ -121,3 +121,3 @@ * @param {string} parameters.status the status of conference(s) to fetch

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.conference the unique conference SID with the participant

@@ -124,0 +124,0 @@ * @param {object} parameters.updateParams parameters to update on the participant

@@ -29,3 +29,3 @@ "use strict";

super(client);
this.config = config;
this.config = Object.assign(Object.assign({}, config), { maxBackoff: config.maxBackoff || 300 /* RETRY_STRATEGY.MAX_BACKOFF */, minBackoff: config.minBackoff || 100 /* RETRY_STRATEGY.MIN_BACKOFF */, retryLimit: config.retryLimit || 3 /* RETRY_STRATEGY.RETRY_LIMIT */ });
}

@@ -38,3 +38,3 @@ /**

* @param {boolean} parameters.coaching the coaching status
* @param {number} parameters.attempts the number of retry attempts performed
* @returns {any}

@@ -46,4 +46,4 @@ * @description the following method is used to modify a participant

return __awaiter(this, void 0, void 0, function* () {
const { conferenceSid, participantSid, agentSid, muted, coaching, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
participantSid: 'string',

@@ -56,3 +56,2 @@ conferenceSid: 'string',

try {
const { conferenceSid, participantSid, agentSid, muted, coaching } = parameters;
const inputError = PluginUtilsErrorManager_1.PluginUtilsErrorManager.checkInvalidParameters(parameters, parameterChecks);

@@ -77,3 +76,3 @@ if (inputError) {

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.coachToggle);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !attempts ? 0 : attempts }), this.coachToggle);
}

@@ -86,3 +85,3 @@ });

* @param {boolean} parameters.muted the muted status
* @param {number} parameters.attempts the number of retry attempts performed
* @returns {any}

@@ -94,4 +93,4 @@ * @description the following method is used to modify a participant

return __awaiter(this, void 0, void 0, function* () {
const { conferenceSid, participantSid, muted, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
conferenceSid: 'string',

@@ -102,3 +101,2 @@ participantSid: 'string',

try {
const { conferenceSid, participantSid, muted } = parameters;
const inputError = PluginUtilsErrorManager_1.PluginUtilsErrorManager.checkInvalidParameters(parameters, parameterChecks);

@@ -121,3 +119,3 @@ if (inputError) {

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.bargeToggle);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !attempts ? 0 : attempts }), this.bargeToggle);
}

@@ -127,3 +125,3 @@ });

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.taskSid the unique task SID to modify

@@ -137,4 +135,4 @@ * @param {string} parameters.to the phone number to add to the conference

return __awaiter(this, void 0, void 0, function* () {
const { taskSid, to, from, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
taskSid: 'string',

@@ -145,3 +143,2 @@ to: 'string',

try {
const { taskSid, to, from } = parameters;
const inputError = PluginUtilsErrorManager_1.PluginUtilsErrorManager.checkInvalidParameters(parameters, parameterChecks);

@@ -167,3 +164,3 @@ if (inputError) {

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.addParticipant);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !attempts ? 0 : attempts }), this.addParticipant);
}

@@ -173,3 +170,3 @@ });

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.conference the unique conference SID with the participant

@@ -183,4 +180,4 @@ * @param {string} parameters.participant the unique participant SID to modify

return __awaiter(this, void 0, void 0, function* () {
const { conferenceSid, participantSid, hold, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
conferenceSid: 'string',

@@ -191,3 +188,2 @@ participantSid: 'string',

try {
const { conferenceSid, participantSid, hold } = parameters;
const inputError = PluginUtilsErrorManager_1.PluginUtilsErrorManager.checkInvalidParameters(parameters, parameterChecks);

@@ -210,3 +206,3 @@ if (inputError) {

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.holdParticipant);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !attempts ? 0 : attempts }), this.holdParticipant);
}

@@ -216,3 +212,3 @@ });

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.conferenceSid the unique conference SID with the participant

@@ -225,4 +221,4 @@ * @param {string} parameters.participantSid the unique participant SID to remove

return __awaiter(this, void 0, void 0, function* () {
const { conferenceSid, participantSid, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
conferenceSid: 'string',

@@ -232,3 +228,2 @@ participantSid: 'string',

try {
const { conferenceSid, participantSid } = parameters;
const inputError = PluginUtilsErrorManager_1.PluginUtilsErrorManager.checkInvalidParameters(parameters, parameterChecks);

@@ -249,3 +244,3 @@ if (inputError) {

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.removeParticipant);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !attempts ? 0 : attempts }), this.removeParticipant);
}

@@ -255,3 +250,3 @@ });

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.conferenceSid the unique conference SID with the participant

@@ -264,4 +259,4 @@ * @param {string} parameters.participantSid the unique participant SID to remove

return __awaiter(this, void 0, void 0, function* () {
const { conferenceSid, participantSid, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
conferenceSid: 'string',

@@ -271,3 +266,2 @@ participantSid: 'string',

try {
const { conferenceSid, participantSid } = parameters;
const inputError = PluginUtilsErrorManager_1.PluginUtilsErrorManager.checkInvalidParameters(parameters, parameterChecks);

@@ -288,3 +282,3 @@ if (inputError) {

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.fetchParticipant);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !attempts ? 0 : attempts }), this.fetchParticipant);
}

@@ -294,3 +288,3 @@ });

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.conferenceSid the unique conference SID with the participant

@@ -304,4 +298,4 @@ * @param {string} parameters.participantSid the unique participant SID to modify

return __awaiter(this, void 0, void 0, function* () {
const { conferenceSid, participantSid, endConferenceOnExit, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
conferenceSid: 'string',

@@ -312,3 +306,2 @@ participantSid: 'string',

try {
const { conferenceSid, participantSid, endConferenceOnExit } = parameters;
const inputError = PluginUtilsErrorManager_1.PluginUtilsErrorManager.checkInvalidParameters(parameters, parameterChecks);

@@ -331,3 +324,3 @@ if (inputError) {

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.updateParticipant);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !attempts ? 0 : attempts }), this.updateParticipant);
}

@@ -337,3 +330,3 @@ });

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.taskSid the task SID to fetch conferences for

@@ -347,8 +340,7 @@ * @param {string} parameters.status the status of conference(s) to fetch

return __awaiter(this, void 0, void 0, function* () {
const { taskSid, status, limit, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
taskSid: 'string'
};
try {
const { taskSid, status, limit } = parameters;
const inputError = PluginUtilsErrorManager_1.PluginUtilsErrorManager.checkInvalidParameters(parameters, parameterChecks);

@@ -375,3 +367,3 @@ if (inputError) {

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.fetchConferencesByTask);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !attempts ? 0 : attempts }), this.fetchConferencesByTask);
}

@@ -381,3 +373,3 @@ });

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.conference the unique conference SID with the participant

@@ -390,4 +382,4 @@ * @param {object} parameters.updateParams parameters to update on the participant

return __awaiter(this, void 0, void 0, function* () {
const { conferenceSid, updateParams, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
conferenceSid: 'string',

@@ -397,3 +389,2 @@ updateParams: 'object',

try {
const { conferenceSid, updateParams } = parameters;
const inputError = PluginUtilsErrorManager_1.PluginUtilsErrorManager.checkInvalidParameters(parameters, parameterChecks);

@@ -414,3 +405,3 @@ if (inputError) {

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.updateConference);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !attempts ? 0 : attempts }), this.updateConference);
}

@@ -417,0 +408,0 @@ });

@@ -22,3 +22,3 @@ import { Twilio } from 'twilio';

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.conversationSid the conversation to be fetched

@@ -32,3 +32,3 @@ * @returns {object} An object containing the conversation

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.conversationSid the sid for this conversation

@@ -43,3 +43,3 @@ * @param {number} parameters.limit max number of participants to list

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.conversationSid the conversation to be updated

@@ -55,3 +55,3 @@ * @param {object} parameters.attributes the attributes to apply to the channel

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.conversationSid the conversation to be updated

@@ -70,3 +70,3 @@ * @param {object} parameters.method webhook method

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.conversationSid the conversation to be updated

@@ -73,0 +73,0 @@ * @param {object} parameters.webhookSid webhook sid

@@ -28,6 +28,6 @@ "use strict";

super(client);
this.config = config;
this.config = Object.assign(Object.assign({}, config), { maxBackoff: config.maxBackoff || 300 /* RETRY_STRATEGY.MAX_BACKOFF */, minBackoff: config.minBackoff || 100 /* RETRY_STRATEGY.MIN_BACKOFF */, retryLimit: config.retryLimit || 3 /* RETRY_STRATEGY.RETRY_LIMIT */ });
}
/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.conversationSid the conversation to be fetched

@@ -39,8 +39,7 @@ * @returns {object} An object containing the conversation

return __awaiter(this, void 0, void 0, function* () {
const { conversationSid, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
conversationSid: 'string',
};
try {
const { conversationSid } = parameters;
const inputError = PluginUtilsErrorManager_1.PluginUtilsErrorManager.checkInvalidParameters(parameters, parameterChecks);

@@ -61,3 +60,3 @@ if (inputError) {

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.getConversation);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !attempts ? 0 : attempts }), this.getConversation);
}

@@ -67,3 +66,3 @@ });

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.conversationSid the sid for this conversation

@@ -76,8 +75,7 @@ * @param {number} parameters.limit max number of participants to list

return __awaiter(this, void 0, void 0, function* () {
const { conversationSid, limit, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
conversationSid: 'string'
};
try {
const { conversationSid, limit } = parameters;
const inputError = PluginUtilsErrorManager_1.PluginUtilsErrorManager.checkInvalidParameters(parameters, parameterChecks);

@@ -100,3 +98,3 @@ if (inputError) {

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.getConversationParticipantList);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !attempts ? 0 : attempts }), this.getConversationParticipantList);
}

@@ -106,3 +104,3 @@ });

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.conversationSid the conversation to be updated

@@ -116,4 +114,4 @@ * @param {object} parameters.attributes the attributes to apply to the channel

return __awaiter(this, void 0, void 0, function* () {
const { conversationSid, attributes, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
conversationSid: 'string',

@@ -123,3 +121,2 @@ attributes: 'string',

try {
const { conversationSid, attributes } = parameters;
const inputError = PluginUtilsErrorManager_1.PluginUtilsErrorManager.checkInvalidParameters(parameters, parameterChecks);

@@ -140,3 +137,3 @@ if (inputError) {

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.updateConversationAttributes);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !attempts ? 0 : attempts }), this.updateConversationAttributes);
}

@@ -146,3 +143,3 @@ });

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.conversationSid the conversation to be updated

@@ -159,4 +156,4 @@ * @param {object} parameters.method webhook method

return __awaiter(this, void 0, void 0, function* () {
const { conversationSid, method, filters, url, target, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
conversationSid: 'string',

@@ -169,3 +166,2 @@ method: 'string',

try {
const { conversationSid, method, filters, url, target } = parameters;
const inputError = PluginUtilsErrorManager_1.PluginUtilsErrorManager.checkInvalidParameters(parameters, parameterChecks);

@@ -191,3 +187,3 @@ if (inputError) {

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.addWebhook);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !attempts ? 0 : attempts }), this.addWebhook);
}

@@ -197,3 +193,3 @@ });

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.conversationSid the conversation to be updated

@@ -207,4 +203,4 @@ * @param {object} parameters.webhookSid webhook sid

return __awaiter(this, void 0, void 0, function* () {
const { conversationSid, webhookSid, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
conversationSid: 'string',

@@ -214,3 +210,2 @@ webhookSid: 'string',

try {
const { conversationSid, webhookSid } = parameters;
const inputError = PluginUtilsErrorManager_1.PluginUtilsErrorManager.checkInvalidParameters(parameters, parameterChecks);

@@ -231,3 +226,3 @@ if (inputError) {

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.addWebhook);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !attempts ? 0 : attempts }), this.addWebhook);
}

@@ -234,0 +229,0 @@ });

@@ -22,3 +22,3 @@ import { Twilio } from 'twilio';

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.interactionSid the Interaction Sid for this channel

@@ -34,3 +34,3 @@ * @param {string} parameters.channelSid the sid of the channel

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.interactionSid the Interaction Sid for this channel

@@ -47,3 +47,3 @@ * @param {string} parameters.channelSid The Channel Sid for this Participant

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.interactionSid the Interaction Sid for this channel

@@ -50,0 +50,0 @@ * @param {string} parameters.channelSid The Channel Sid for this Participant

@@ -29,6 +29,6 @@ "use strict";

super(client);
this.config = config;
this.config = Object.assign(Object.assign({}, config), { maxBackoff: config.maxBackoff || 300 /* RETRY_STRATEGY.MAX_BACKOFF */, minBackoff: config.minBackoff || 100 /* RETRY_STRATEGY.MIN_BACKOFF */, retryLimit: config.retryLimit || 3 /* RETRY_STRATEGY.RETRY_LIMIT */ });
}
/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.interactionSid the Interaction Sid for this channel

@@ -42,4 +42,4 @@ * @param {string} parameters.channelSid the sid of the channel

return __awaiter(this, void 0, void 0, function* () {
const { interactionSid, channelSid, routing, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
interactionSid: 'string',

@@ -50,3 +50,2 @@ channelSid: 'string',

try {
const { interactionSid, channelSid, routing } = parameters;
const inputError = PluginUtilsErrorManager_1.PluginUtilsErrorManager.checkInvalidParameters(parameters, parameterChecks);

@@ -72,3 +71,3 @@ if (inputError) {

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.participantCreateInvite);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !attempts ? 0 : attempts }), this.participantCreateInvite);
}

@@ -78,3 +77,3 @@ });

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.interactionSid the Interaction Sid for this channel

@@ -89,4 +88,4 @@ * @param {string} parameters.channelSid The Channel Sid for this Participant

return __awaiter(this, void 0, void 0, function* () {
const { interactionSid, channelSid, participantSid, status, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
interactionSid: 'string',

@@ -98,3 +97,2 @@ channelSid: 'string',

try {
const { interactionSid, channelSid, participantSid, status } = parameters;
const inputError = PluginUtilsErrorManager_1.PluginUtilsErrorManager.checkInvalidParameters(parameters, parameterChecks);

@@ -121,3 +119,3 @@ if (inputError) {

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.participantUpdate);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !attempts ? 0 : attempts }), this.participantUpdate);
}

@@ -127,3 +125,3 @@ });

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.interactionSid the Interaction Sid for this channel

@@ -137,4 +135,4 @@ * @param {string} parameters.channelSid The Channel Sid for this Participant

return __awaiter(this, void 0, void 0, function* () {
const { interactionSid, channelSid, status, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
interactionSid: 'string',

@@ -145,3 +143,2 @@ channelSid: 'string',

try {
const { interactionSid, channelSid, status } = parameters;
const inputError = PluginUtilsErrorManager_1.PluginUtilsErrorManager.checkInvalidParameters(parameters, parameterChecks);

@@ -167,3 +164,3 @@ if (inputError) {

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.channelUpdate);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !attempts ? 0 : attempts }), this.channelUpdate);
}

@@ -170,0 +167,0 @@ });

@@ -21,3 +21,3 @@ import { Twilio } from 'twilio';

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @returns {Array<PhoneNumber>} An array of phone numbers for the account

@@ -31,3 +31,3 @@ * @description the following method is used to robustly retrieve

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @returns {Array<PhoneNumber>} An array of outbound caller ids for the account

@@ -41,3 +41,3 @@ * @description the following method is used to robustly retrieve

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.phoneNumber the phone number to validate

@@ -44,0 +44,0 @@ * @returns {object} https://www.twilio.com/docs/lookup/v2-api#making-a-request

@@ -28,6 +28,6 @@ "use strict";

super(client);
this.config = config;
this.config = Object.assign(Object.assign({}, config), { maxBackoff: config.maxBackoff || 300 /* RETRY_STRATEGY.MAX_BACKOFF */, minBackoff: config.minBackoff || 100 /* RETRY_STRATEGY.MIN_BACKOFF */, retryLimit: config.retryLimit || 3 /* RETRY_STRATEGY.RETRY_LIMIT */ });
}
/**
* @param {number} parameters.attempts the number of retry attempts performed
* @returns {Array<PhoneNumber>} An array of phone numbers for the account

@@ -39,10 +39,3 @@ * @description the following method is used to robustly retrieve

return __awaiter(this, void 0, void 0, function* () {
const parameterChecks = {
attempts: 'number',
};
try {
const inputError = PluginUtilsErrorManager_1.PluginUtilsErrorManager.checkInvalidParameters(parameters, parameterChecks);
if (inputError) {
throw new PluginUtilsErrorManager_1.PluginUtilsErrorManager(inputError, statusCodes_1.HttpErrorCode.BadRequest);
}
const phoneNumbers = yield this.client.incomingPhoneNumbers.list(Object.assign({}, (parameters.limit && { limit: parameters.limit })));

@@ -52,10 +45,3 @@ return { success: true, phoneNumbers, status: statusCodes_1.HttpErrorCode.OK };

catch (error) {
if (error.code === statusCodes_1.HttpErrorCode.BadRequest) {
return {
success: false,
status: statusCodes_1.HttpErrorCode.BadRequest,
message: error.message,
};
}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.listPhoneNumbers);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !parameters.attempts ? 0 : parameters.attempts }), this.listPhoneNumbers);
}

@@ -65,3 +51,3 @@ });

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @returns {Array<PhoneNumber>} An array of outbound caller ids for the account

@@ -73,10 +59,3 @@ * @description the following method is used to robustly retrieve

return __awaiter(this, void 0, void 0, function* () {
const parameterChecks = {
attempts: 'number',
};
try {
const inputError = PluginUtilsErrorManager_1.PluginUtilsErrorManager.checkInvalidParameters(parameters, parameterChecks);
if (inputError) {
throw new PluginUtilsErrorManager_1.PluginUtilsErrorManager(inputError, statusCodes_1.HttpErrorCode.BadRequest);
}
const callerIds = yield this.client.outgoingCallerIds.list(Object.assign({}, (parameters.limit && { limit: parameters.limit })));

@@ -86,10 +65,3 @@ return { success: true, callerIds, status: statusCodes_1.HttpErrorCode.OK };

catch (error) {
if (error.code === statusCodes_1.HttpErrorCode.BadRequest) {
return {
success: false,
status: statusCodes_1.HttpErrorCode.BadRequest,
message: error.message,
};
}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.listOutgoingCallerIds);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !parameters.attempts ? 0 : parameters.attempts }), this.listOutgoingCallerIds);
}

@@ -99,3 +71,3 @@ });

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.phoneNumber the phone number to validate

@@ -108,3 +80,2 @@ * @returns {object} https://www.twilio.com/docs/lookup/v2-api#making-a-request

const parameterChecks = {
attempts: 'number',
phoneNumber: 'string',

@@ -128,3 +99,3 @@ };

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.validatePhoneNumber);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !parameters.attempts ? 0 : parameters.attempts }), this.validatePhoneNumber);
}

@@ -131,0 +102,0 @@ });

@@ -26,3 +26,3 @@ import { Twilio } from 'twilio';

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.callSid the unique call SID to fetch

@@ -38,3 +38,3 @@ * @returns {Map} The given call's properties

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.callSid the unique call SID to fetch

@@ -50,3 +50,3 @@ * @param {string} parameters.twiml the response of twiml based on to and from arguments of event

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.callSid the unique call SID to fetch

@@ -64,3 +64,3 @@ * @param {object} parameters.params recording creation parameters

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.callSid the unique call SID to update recording

@@ -76,3 +76,3 @@ * @param {string} parameters.recordingSid the unique recording SID to update

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.conferenceSid the unique conference SID to update recording

@@ -88,3 +88,3 @@ * @param {string} parameters.recordingSid the unique recording SID to update

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.callSid the unique call SID to update

@@ -99,3 +99,3 @@ * @param {object} parameters.params recording update parameters

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.queueSid the unique queue SID to fetch

@@ -110,3 +110,3 @@ * @param {object} parameters.params recording update parameters

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.recordingSid the unique recording SID to fetch

@@ -121,3 +121,3 @@ * @param {object} parameters.params recording update parameters

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.recordingSid the unique recording SID to fetch

@@ -133,3 +133,3 @@ * @param {object} parameters.params recording update parameters

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @returns {Array<PhoneNumber>} An array of outbound caller ids for the account

@@ -136,0 +136,0 @@ * @description the following method is used to robustly retrieve

@@ -32,3 +32,3 @@ "use strict";

super(client);
this.config = config;
this.config = Object.assign(Object.assign({}, config), { maxBackoff: config.maxBackoff || 300 /* RETRY_STRATEGY.MAX_BACKOFF */, minBackoff: config.minBackoff || 100 /* RETRY_STRATEGY.MIN_BACKOFF */, retryLimit: config.retryLimit || 3 /* RETRY_STRATEGY.RETRY_LIMIT */ });
const { accountSid, authToken, region } = config;

@@ -38,3 +38,3 @@ this.api = new Api_1.default(accountSid, authToken, region);

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.callSid the unique call SID to fetch

@@ -46,5 +46,4 @@ * @returns {Map} The given call's properties

return __awaiter(this, void 0, void 0, function* () {
const { callSid } = parameters;
const { callSid, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
callSid: 'string',

@@ -68,3 +67,3 @@ };

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.fetchProperties);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !attempts ? 0 : attempts }), this.fetchProperties);
}

@@ -74,3 +73,3 @@ });

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.callSid the unique call SID to fetch

@@ -85,3 +84,2 @@ * @param {string} parameters.twiml the response of twiml based on to and from arguments of event

const parameterChecks = {
attempts: 'number',
callSid: 'string',

@@ -108,3 +106,3 @@ twiml: 'string',

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.coldTransfer);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !attempts ? 0 : attempts }), this.coldTransfer);
}

@@ -114,3 +112,3 @@ });

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.callSid the unique call SID to fetch

@@ -123,5 +121,4 @@ * @param {object} parameters.params recording creation parameters

return __awaiter(this, void 0, void 0, function* () {
const { callSid, params } = parameters;
const { callSid, params, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
callSid: 'string',

@@ -146,3 +143,3 @@ params: 'object',

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.createRecording);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !attempts ? 0 : attempts }), this.createRecording);
}

@@ -152,3 +149,3 @@ });

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.callSid the unique call SID to update recording

@@ -162,5 +159,4 @@ * @param {string} parameters.recordingSid the unique recording SID to update

return __awaiter(this, void 0, void 0, function* () {
const { callSid, recordingSid, params } = parameters;
const { callSid, recordingSid, params, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
callSid: 'string',

@@ -186,3 +182,3 @@ recordingSid: 'string',

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.updateCallRecording);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !attempts ? 0 : attempts }), this.updateCallRecording);
}

@@ -192,3 +188,3 @@ });

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.conferenceSid the unique conference SID to update recording

@@ -202,5 +198,4 @@ * @param {string} parameters.recordingSid the unique recording SID to update

return __awaiter(this, void 0, void 0, function* () {
const { conferenceSid, recordingSid, params } = parameters;
const { conferenceSid, recordingSid, params, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
conferenceSid: 'string',

@@ -226,3 +221,3 @@ recordingSid: 'string',

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.updateConferenceRecording);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !attempts ? 0 : attempts }), this.updateConferenceRecording);
}

@@ -232,3 +227,3 @@ });

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.callSid the unique call SID to update

@@ -241,5 +236,4 @@ * @param {object} parameters.params recording update parameters

return __awaiter(this, void 0, void 0, function* () {
const { callSid, params } = parameters;
const { callSid, params, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
callSid: 'string',

@@ -264,3 +258,3 @@ params: 'object',

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.updateCall);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !attempts ? 0 : attempts }), this.updateCall);
}

@@ -270,3 +264,3 @@ });

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.queueSid the unique queue SID to fetch

@@ -279,5 +273,4 @@ * @param {object} parameters.params recording update parameters

return __awaiter(this, void 0, void 0, function* () {
const { queueSid } = parameters;
const { queueSid, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
queueSid: 'string',

@@ -301,3 +294,3 @@ };

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.fetchVoiceQueue);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !attempts ? 0 : attempts }), this.fetchVoiceQueue);
}

@@ -307,3 +300,3 @@ });

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.recordingSid the unique recording SID to fetch

@@ -316,5 +309,4 @@ * @param {object} parameters.params recording update parameters

return __awaiter(this, void 0, void 0, function* () {
const { recordingSid } = parameters;
const { recordingSid, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
recordingSid: 'string',

@@ -338,3 +330,3 @@ };

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.fetchRecording);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !attempts ? 0 : attempts }), this.fetchRecording);
}

@@ -344,3 +336,3 @@ });

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.recordingSid the unique recording SID to fetch

@@ -353,5 +345,4 @@ * @param {object} parameters.params recording update parameters

return __awaiter(this, void 0, void 0, function* () {
const { recordingSid } = parameters;
const { recordingSid, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
recordingSid: 'string',

@@ -377,3 +368,3 @@ };

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.fetchRecordingMedia);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !attempts ? 0 : attempts }), this.fetchRecordingMedia);
}

@@ -383,3 +374,3 @@ });

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @returns {Array<PhoneNumber>} An array of outbound caller ids for the account

@@ -391,11 +382,4 @@ * @description the following method is used to robustly retrieve

return __awaiter(this, void 0, void 0, function* () {
const parameterChecks = {
attempts: 'number',
};
try {
const inputError = PluginUtilsErrorManager_1.PluginUtilsErrorManager.checkInvalidParameters(parameters, parameterChecks);
if (inputError) {
throw new PluginUtilsErrorManager_1.PluginUtilsErrorManager(inputError, statusCodes_1.HttpErrorCode.BadRequest);
}
const callerIds = yield this.client.outgoingCallerIds.list({});
const callerIds = yield this.client.outgoingCallerIds.list();
return { success: true, callerIds, status: statusCodes_1.HttpErrorCode.OK };

@@ -411,3 +395,3 @@ }

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.fetchRecording);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !parameters.attempts ? 0 : parameters.attempts }), this.fetchRecording);
}

@@ -414,0 +398,0 @@ });

@@ -29,3 +29,3 @@ import { Twilio } from 'twilio';

* @param {number} parameters.attempts the number of retry attempts performed
* @param {number} parameters.limit limit for the queues to be reterived

@@ -41,3 +41,3 @@ * @return { Promise<Array<WorkerInstance>> } - list of all workers from specific workspace

* @param {number} parameters.attempts the number of retry attempts performed
* @param {number} parameters.limit limit for the queues to be reterived

@@ -59,3 +59,3 @@ * @param {string} parameters.workflowSid (optional) the workflow SID to filter by

* @param {number} parameters.attempts the number of retry attempts performed
* @param {number} parameters.limit limit for the queues to be reterived

@@ -71,3 +71,3 @@ * @returns {object} An object containing an array of queues for the account

* @param {number} parameters.attempts the number of retry attempts performed
* @param {number} parameters.limit limit for the queues to be reterived

@@ -82,3 +82,3 @@ * @returns {object} An object containing an array of workflows for the account

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.workerSid the worker sid to fetch channels for

@@ -96,3 +96,3 @@ * @returns {object} worker channel object

* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.workerSid the worker sid to fetch channels for

@@ -110,3 +110,3 @@ * @param {string} parameters.workerChannelSid the worker channel sid to fetch channels for

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.taskSid the task to update

@@ -121,3 +121,3 @@ * @param {object} parameters.updateParams parameters to update on the task

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.taskSid the task to fetch

@@ -134,3 +134,3 @@ * @returns {object} an object containing the task if successful

* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.workflowSid the workflow to submit the task

@@ -149,3 +149,3 @@ * @param {string} parameters.taskChannel the task channel to submit the task on

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.taskSid the task to update

@@ -160,3 +160,3 @@ * @param {string} parameters.reason a JSON object to merge with the task

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.taskSid the task to update

@@ -172,3 +172,3 @@ * @param {string} parameters.reservationSid the reservation to update

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.taskSid the task to update

@@ -175,0 +175,0 @@ * @param {string} parameters.attributesUpdate a string JSON object to merge with the task

@@ -38,3 +38,3 @@ "use strict";

const { accountSid, authToken, flexWorkSpaceSid, region } = config;
this.config = config;
this.config = Object.assign(Object.assign({}, config), { maxBackoff: config.maxBackoff || 300 /* RETRY_STRATEGY.MAX_BACKOFF */, minBackoff: config.minBackoff || 100 /* RETRY_STRATEGY.MIN_BACKOFF */, retryLimit: config.retryLimit || 3 /* RETRY_STRATEGY.RETRY_LIMIT */ });
this.api = new Api_1.default(accountSid, authToken, flexWorkSpaceSid, region);

@@ -45,3 +45,3 @@ }

* @param {number} parameters.attempts the number of retry attempts performed
* @param {number} parameters.limit limit for the queues to be reterived

@@ -65,3 +65,3 @@ * @return { Promise<Array<WorkerInstance>> } - list of all workers from specific workspace

catch (error) {
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.getAllWorkersFromWorkspace);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !parameters.attempts ? 0 : parameters.attempts }), this.getAllWorkersFromWorkspace);
}

@@ -73,3 +73,3 @@ });

* @param {number} parameters.attempts the number of retry attempts performed
* @param {number} parameters.limit limit for the queues to be reterived

@@ -97,3 +97,3 @@ * @param {string} parameters.workflowSid (optional) the workflow SID to filter by

catch (error) {
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.getAllTasksFromWorkspace);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !parameters.attempts ? 0 : parameters.attempts }), this.getAllTasksFromWorkspace);
}

@@ -104,3 +104,3 @@ });

* @param {number} parameters.attempts the number of retry attempts performed
* @param {number} parameters.limit limit for the queues to be reterived

@@ -125,3 +125,3 @@ * @returns {object} An object containing an array of queues for the account

catch (error) {
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.getAllQueues);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !parameters.attempts ? 0 : parameters.attempts }), this.getAllQueues);
}

@@ -132,3 +132,3 @@ });

* @param {number} parameters.attempts the number of retry attempts performed
* @param {number} parameters.limit limit for the queues to be reterived

@@ -153,3 +153,3 @@ * @returns {object} An object containing an array of workflows for the account

catch (error) {
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.getAllWorkflows);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !parameters.attempts ? 0 : parameters.attempts }), this.getAllWorkflows);
}

@@ -159,3 +159,3 @@ });

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.workerSid the worker sid to fetch channels for

@@ -168,5 +168,4 @@ * @returns {object} worker channel object

return __awaiter(this, void 0, void 0, function* () {
const { attempts, workerSid } = parameters;
const { workerSid, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
workerSid: 'string',

@@ -197,3 +196,3 @@ };

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.getWorkerChannels);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !attempts ? 0 : attempts }), this.getWorkerChannels);
}

@@ -204,3 +203,3 @@ });

* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.workerSid the worker sid to fetch channels for

@@ -216,5 +215,4 @@ * @param {string} parameters.workerChannelSid the worker channel sid to fetch channels for

return __awaiter(this, void 0, void 0, function* () {
const { workerSid, workerChannelSid, capacity, available } = parameters;
const { workerSid, workerChannelSid, capacity, available, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
workerSid: 'string',

@@ -249,3 +247,3 @@ workerChannelSid: 'string',

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.updateWorkerChannel);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !attempts ? 0 : attempts }), this.updateWorkerChannel);
}

@@ -255,3 +253,3 @@ });

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.taskSid the task to update

@@ -265,5 +263,4 @@ * @param {object} parameters.updateParams parameters to update on the task

return __awaiter(this, void 0, void 0, function* () {
const { taskSid, updateParams } = parameters;
const { taskSid, updateParams, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
taskSid: 'string',

@@ -303,3 +300,3 @@ updateParams: 'object',

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.updateTask);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !attempts ? 0 : attempts }), this.updateTask);
}

@@ -309,3 +306,3 @@ });

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.taskSid the task to fetch

@@ -318,5 +315,4 @@ * @returns {object} an object containing the task if successful

return __awaiter(this, void 0, void 0, function* () {
const { taskSid } = parameters;
const { taskSid, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
taskSid: 'string',

@@ -352,3 +348,3 @@ };

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.fetchTask);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !attempts ? 0 : attempts }), this.fetchTask);
}

@@ -359,3 +355,3 @@ });

* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.workflowSid the workflow to submit the task

@@ -371,7 +367,6 @@ * @param {string} parameters.taskChannel the task channel to submit the task on

return __awaiter(this, void 0, void 0, function* () {
const { workflowSid, taskChannel, attributes, priority: overriddenPriority, timeout: overriddenTimeout, } = parameters;
const { workflowSid, taskChannel, attributes, attempts, priority: overriddenPriority, timeout: overriddenTimeout, } = parameters;
const timeout = overriddenTimeout || defaultTimeout;
const priority = overriddenPriority || defaultTaskPriority;
const parameterChecks = {
attempts: 'number',
workflowSid: 'string',

@@ -408,3 +403,3 @@ attributes: 'string',

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.createTask);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !attempts ? 0 : attempts }), this.createTask);
}

@@ -414,3 +409,3 @@ });

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.taskSid the task to update

@@ -424,5 +419,4 @@ * @param {string} parameters.reason a JSON object to merge with the task

return __awaiter(this, void 0, void 0, function* () {
const { taskSid, reason } = parameters;
const { taskSid, reason, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
taskSid: 'string',

@@ -462,3 +456,3 @@ reason: 'string',

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.completeTask);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !attempts ? 0 : attempts }), this.completeTask);
}

@@ -468,3 +462,3 @@ });

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.taskSid the task to update

@@ -479,5 +473,4 @@ * @param {string} parameters.reservationSid the reservation to update

return __awaiter(this, void 0, void 0, function* () {
const { taskSid, reservationSid, status } = parameters;
const { taskSid, reservationSid, status, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
taskSid: 'string',

@@ -520,3 +513,3 @@ reservationSid: 'string',

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.updateReservation);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !attempts ? 0 : attempts }), this.updateReservation);
}

@@ -526,3 +519,3 @@ });

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.taskSid the task to update

@@ -538,5 +531,4 @@ * @param {string} parameters.attributesUpdate a string JSON object to merge with the task

return __awaiter(this, void 0, void 0, function* () {
const { taskSid, attributesUpdate } = parameters;
const { taskSid, attributesUpdate, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
taskSid: 'string',

@@ -579,3 +571,3 @@ attributesUpdate: 'string',

}
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.updateTaskAttributes);
return (0, retryHandler_1.retryHandler)(this.config, error, Object.assign(Object.assign({}, parameters), { attempts: !attempts ? 0 : attempts }), this.updateTaskAttributes);
}

@@ -582,0 +574,0 @@ });

@@ -11,3 +11,3 @@ import { AxiosResponse } from 'axios';

export interface Parameters {
attempts: number;
attempts?: number;
limit?: number;

@@ -14,0 +14,0 @@ }

{
"name": "@twilio/flex-plugins-library-utils",
"version": "1.1.6",
"version": "1.1.7",
"description": "Flex Plugins Library Utils",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -10,3 +10,3 @@ import { Parameters, PluginsUtilsMetaData, TwilioError, RetryCallbackFunction } from '../types';

* @param {object} parameters the parameters to call the callback with
* @param {number} parameters.attempts the number of retry attempts performed
* @param {function} callback the callback function to retry

@@ -50,4 +50,3 @@ * @returns {any}

console.warn(`retrying ${callback.name}() after ${logWarning}, status code: ${status}`);
if (status === HttpErrorCode.TooManyRequests || status === HttpErrorCode.ServiceUnavailable)
await snooze(random(minBackoff, maxBackoff));
await snooze(random(minBackoff, maxBackoff));

@@ -54,0 +53,0 @@ const updatedAttempts = attempts + 1;

@@ -13,1 +13,7 @@ // add new APIs here

}
export const enum RETRY_STRATEGY {
MIN_BACKOFF = 100,
MAX_BACKOFF = 300,
RETRY_LIMIT = 3,
}

@@ -20,2 +20,3 @@ import { Twilio } from 'twilio';

import { ConferenceInstance } from 'twilio/lib/rest/api/v2010/account/conference';
import { RETRY_STRATEGY } from 'src/constants/api';

@@ -37,3 +38,8 @@ export default class ConferenceUtils extends PluginUtils {

this.config = config;
this.config = {
...config,
maxBackoff: config.maxBackoff || RETRY_STRATEGY.MAX_BACKOFF,
minBackoff: config.minBackoff || RETRY_STRATEGY.MIN_BACKOFF,
retryLimit: config.retryLimit || RETRY_STRATEGY.RETRY_LIMIT,
};
}

@@ -47,3 +53,3 @@

* @param {boolean} parameters.coaching the coaching status
* @param {number} parameters.attempts the number of retry attempts performed
* @returns {any}

@@ -56,4 +62,5 @@ * @description the following method is used to modify a participant

): Promise<ApiReturnType & { updatedConference?: ParticipantInstance }> {
const { conferenceSid, participantSid, agentSid, muted, coaching, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
participantSid: 'string',

@@ -67,4 +74,2 @@ conferenceSid: 'string',

try {
const { conferenceSid, participantSid, agentSid, muted, coaching } = parameters;
const inputError = PluginUtilsErrorManager.checkInvalidParameters<CoachToggleParams>(parameters, parameterChecks);

@@ -90,3 +95,3 @@ if (inputError) {

}
return retryHandler(this.config, error, parameters, this.coachToggle);
return retryHandler(this.config, error,{ ...parameters , attempts: !attempts ? 0 : attempts},this.coachToggle);
}

@@ -99,3 +104,3 @@ }

* @param {boolean} parameters.muted the muted status
* @param {number} parameters.attempts the number of retry attempts performed
* @returns {any}

@@ -108,4 +113,4 @@ * @description the following method is used to modify a participant

): Promise<ApiReturnType & { updatedParticipant?: ParticipantInstance }> {
const { conferenceSid, participantSid, muted, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
conferenceSid: 'string',

@@ -117,3 +122,2 @@ participantSid: 'string',

try {
const { conferenceSid, participantSid, muted } = parameters;

@@ -139,3 +143,3 @@ const inputError = PluginUtilsErrorManager.checkInvalidParameters<BargeToggleParams>(parameters, parameterChecks);

}
return retryHandler(this.config, error, parameters, this.bargeToggle);
return retryHandler(this.config, error,{ ...parameters , attempts: !attempts ? 0 : attempts},this.bargeToggle);
}

@@ -145,3 +149,3 @@ }

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.taskSid the unique task SID to modify

@@ -156,4 +160,4 @@ * @param {string} parameters.to the phone number to add to the conference

): Promise<ApiReturnType & { participantsResponse?: ParticipantInstance }> {
const { taskSid, to, from, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
taskSid: 'string',

@@ -165,3 +169,2 @@ to: 'string',

try {
const { taskSid, to, from } = parameters;

@@ -193,3 +196,3 @@ const inputError = PluginUtilsErrorManager.checkInvalidParameters<ConferenceAddParticipantParams>(

}
return retryHandler(this.config, error, parameters, this.addParticipant);
return retryHandler(this.config, error,{ ...parameters , attempts: !attempts ? 0 : attempts},this.addParticipant);
}

@@ -199,3 +202,3 @@ }

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.conference the unique conference SID with the participant

@@ -210,4 +213,4 @@ * @param {string} parameters.participant the unique participant SID to modify

): Promise<ApiReturnType & { participantsResponse?: ParticipantInstance }> {
const { conferenceSid, participantSid, hold, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
conferenceSid: 'string',

@@ -219,3 +222,2 @@ participantSid: 'string',

try {
const { conferenceSid, participantSid, hold } = parameters;

@@ -244,3 +246,3 @@ const inputError = PluginUtilsErrorManager.checkInvalidParameters<ConferenceHoldParticipantParams>(

}
return retryHandler(this.config, error, parameters, this.holdParticipant);
return retryHandler(this.config, error,{ ...parameters , attempts: !attempts ? 0 : attempts},this.holdParticipant);
}

@@ -250,3 +252,3 @@ }

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.conferenceSid the unique conference SID with the participant

@@ -260,4 +262,4 @@ * @param {string} parameters.participantSid the unique participant SID to remove

): Promise<ApiReturnType & { participantsResponse?: boolean }> {
const { conferenceSid, participantSid, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
conferenceSid: 'string',

@@ -268,3 +270,2 @@ participantSid: 'string',

try {
const { conferenceSid, participantSid } = parameters;

@@ -291,3 +292,3 @@ const inputError = PluginUtilsErrorManager.checkInvalidParameters<ConferenceParticipantParams>(

}
return retryHandler(this.config, error, parameters, this.removeParticipant);
return retryHandler(this.config, error,{ ...parameters , attempts: !attempts ? 0 : attempts},this.removeParticipant);
}

@@ -297,3 +298,3 @@ }

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.conferenceSid the unique conference SID with the participant

@@ -307,4 +308,4 @@ * @param {string} parameters.participantSid the unique participant SID to remove

): Promise<ApiReturnType & { participantsResponse?: ParticipantInstance }> {
const { conferenceSid, participantSid, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
conferenceSid: 'string',

@@ -315,3 +316,2 @@ participantSid: 'string',

try {
const { conferenceSid, participantSid } = parameters;

@@ -338,3 +338,3 @@ const inputError = PluginUtilsErrorManager.checkInvalidParameters<ConferenceParticipantParams>(

}
return retryHandler(this.config, error, parameters, this.fetchParticipant);
return retryHandler(this.config, error,{ ...parameters , attempts: !attempts ? 0 : attempts},this.fetchParticipant);
}

@@ -344,3 +344,3 @@ }

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.conferenceSid the unique conference SID with the participant

@@ -355,4 +355,4 @@ * @param {string} parameters.participantSid the unique participant SID to modify

): Promise<ApiReturnType & { participantsResponse?: ParticipantInstance }> {
const { conferenceSid, participantSid, endConferenceOnExit, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
conferenceSid: 'string',

@@ -364,3 +364,2 @@ participantSid: 'string',

try {
const { conferenceSid, participantSid, endConferenceOnExit } = parameters;

@@ -388,3 +387,3 @@ const inputError = PluginUtilsErrorManager.checkInvalidParameters<

}
return retryHandler(this.config, error, parameters, this.updateParticipant);
return retryHandler(this.config, error,{ ...parameters , attempts: !attempts ? 0 : attempts},this.updateParticipant);
}

@@ -394,3 +393,3 @@ }

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.taskSid the task SID to fetch conferences for

@@ -405,4 +404,4 @@ * @param {string} parameters.status the status of conference(s) to fetch

): Promise<ApiReturnType & { conferences?: ConferenceInstance[] }> {
const parameterChecks = {
attempts: 'number',
const { taskSid, status, limit, attempts } = parameters;
const parameterChecks = {
taskSid: 'string'

@@ -412,3 +411,2 @@ };

try {
const { taskSid, status, limit } = parameters;

@@ -444,3 +442,3 @@ const inputError = PluginUtilsErrorManager.checkInvalidParameters<FetchConferencesByTaskParams>(

}
return retryHandler(this.config, error, parameters, this.fetchConferencesByTask);
return retryHandler(this.config, error,{ ...parameters , attempts: !attempts ? 0 : attempts},this.fetchConferencesByTask);
}

@@ -450,3 +448,3 @@ }

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.conference the unique conference SID with the participant

@@ -460,4 +458,4 @@ * @param {object} parameters.updateParams parameters to update on the participant

): Promise<ApiReturnType & { conferencesResponse?: ConferenceInstance }> {
const { conferenceSid, updateParams, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
conferenceSid: 'string',

@@ -468,3 +466,2 @@ updateParams: 'object',

try {
const { conferenceSid, updateParams } = parameters;

@@ -491,5 +488,5 @@ const inputError = PluginUtilsErrorManager.checkInvalidParameters<UpdateConferenceParams>(

}
return retryHandler(this.config, error, parameters, this.updateConference);
return retryHandler(this.config, error,{ ...parameters , attempts: !attempts ? 0 : attempts},this.updateConference);
}
}
}

@@ -12,2 +12,3 @@ import { Twilio } from 'twilio';

import { WebhookInstance, WebhookMethod } from 'twilio/lib/rest/conversations/v1/conversation/webhook';
import { RETRY_STRATEGY } from 'src/constants/api';

@@ -28,7 +29,12 @@ export default class ConversationsUtils extends PluginUtils {

super(client);
this.config = config;
this.config = {
...config,
maxBackoff: config.maxBackoff || RETRY_STRATEGY.MAX_BACKOFF,
minBackoff: config.minBackoff || RETRY_STRATEGY.MIN_BACKOFF,
retryLimit: config.retryLimit || RETRY_STRATEGY.RETRY_LIMIT,
};
}
/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.conversationSid the conversation to be fetched

@@ -41,4 +47,4 @@ * @returns {object} An object containing the conversation

): Promise<ApiReturnType & { conversation?: ConversationInstance }> {
const { conversationSid, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
conversationSid: 'string',

@@ -48,3 +54,2 @@ };

try {
const { conversationSid } = parameters;

@@ -71,3 +76,3 @@ const inputError = PluginUtilsErrorManager.checkInvalidParameters<ConversationParams>(

}
return retryHandler(this.config, error, parameters, this.getConversation);
return retryHandler(this.config, error,{ ...parameters , attempts: !attempts ? 0 : attempts},this.getConversation);
}

@@ -77,3 +82,3 @@ }

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.conversationSid the sid for this conversation

@@ -87,4 +92,4 @@ * @param {number} parameters.limit max number of participants to list

): Promise<ApiReturnType & { participants?: ParticipantInstance[] }> {
const { conversationSid, limit, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
conversationSid: 'string'

@@ -94,3 +99,2 @@ };

try {
const { conversationSid, limit } = parameters;

@@ -119,3 +123,3 @@ const inputError = PluginUtilsErrorManager.checkInvalidParameters<ConversationParams>(

}
return retryHandler(this.config, error, parameters, this.getConversationParticipantList);
return retryHandler(this.config, error,{ ...parameters , attempts: !attempts ? 0 : attempts},this.getConversationParticipantList);
}

@@ -125,3 +129,3 @@ }

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.conversationSid the conversation to be updated

@@ -136,4 +140,5 @@ * @param {object} parameters.attributes the attributes to apply to the channel

): Promise<ApiReturnType & { conversation?: ConversationInstance }> {
const { conversationSid, attributes, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
conversationSid: 'string',

@@ -144,4 +149,2 @@ attributes: 'string',

try {
const { conversationSid, attributes } = parameters;
const inputError = PluginUtilsErrorManager.checkInvalidParameters<ConversationParams>(

@@ -167,3 +170,3 @@ parameters,

}
return retryHandler(this.config, error, parameters, this.updateConversationAttributes);
return retryHandler(this.config, error,{ ...parameters , attempts: !attempts ? 0 : attempts},this.updateConversationAttributes);
}

@@ -173,3 +176,3 @@ }

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.conversationSid the conversation to be updated

@@ -187,4 +190,4 @@ * @param {object} parameters.method webhook method

): Promise<ApiReturnType & { webhook?: WebhookInstance }> {
const parameterChecks = {
attempts: 'number',
const { conversationSid, method, filters, url, target, attempts } = parameters;
const parameterChecks = {
conversationSid: 'string',

@@ -198,3 +201,2 @@ method: 'string',

try {
const { conversationSid, method, filters, url, target } = parameters;

@@ -226,3 +228,3 @@ const inputError = PluginUtilsErrorManager.checkInvalidParameters<ConversationAddWebhookParams>(

}
return retryHandler(this.config, error, parameters, this.addWebhook);
return retryHandler(this.config, error,{ ...parameters , attempts: !attempts ? 0 : attempts},this.addWebhook);
}

@@ -232,3 +234,3 @@ }

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.conversationSid the conversation to be updated

@@ -243,4 +245,4 @@ * @param {object} parameters.webhookSid webhook sid

): Promise<ApiReturnType & { webhook?: boolean }> {
const { conversationSid, webhookSid, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
conversationSid: 'string',

@@ -251,3 +253,2 @@ webhookSid: 'string',

try {
const { conversationSid, webhookSid } = parameters;

@@ -274,5 +275,5 @@ const inputError = PluginUtilsErrorManager.checkInvalidParameters<ConversationRemoveWebhookParams>(

}
return retryHandler(this.config, error, parameters, this.addWebhook);
return retryHandler(this.config, error,{ ...parameters , attempts: !attempts ? 0 : attempts},this.addWebhook);
}
}
}

@@ -14,2 +14,3 @@ import { Twilio } from 'twilio';

import { InteractionChannelInstance } from 'twilio/lib/rest/flexApi/v1/interaction/interactionChannel';
import { RETRY_STRATEGY } from 'src/constants/api';

@@ -30,7 +31,12 @@ export default class InteractionUtils extends PluginUtils {

super(client);
this.config = config;
this.config = {
...config,
maxBackoff: config.maxBackoff || RETRY_STRATEGY.MAX_BACKOFF,
minBackoff: config.minBackoff || RETRY_STRATEGY.MIN_BACKOFF,
retryLimit: config.retryLimit || RETRY_STRATEGY.RETRY_LIMIT,
};
}
/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.interactionSid the Interaction Sid for this channel

@@ -45,4 +51,4 @@ * @param {string} parameters.channelSid the sid of the channel

): Promise<ApiReturnType & { participantInvite?: InteractionChannelInviteInstance }> {
const { interactionSid, channelSid, routing, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
interactionSid: 'string',

@@ -54,3 +60,2 @@ channelSid: 'string',

try {
const { interactionSid, channelSid, routing } = parameters;

@@ -82,3 +87,3 @@ const inputError = PluginUtilsErrorManager.checkInvalidParameters<ParticipantCreateInviteParams>(

}
return retryHandler(this.config, error, parameters, this.participantCreateInvite);
return retryHandler(this.config, error,{ ...parameters , attempts: !attempts ? 0 : attempts},this.participantCreateInvite);
}

@@ -88,3 +93,3 @@ }

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.interactionSid the Interaction Sid for this channel

@@ -100,4 +105,5 @@ * @param {string} parameters.channelSid The Channel Sid for this Participant

): Promise<ApiReturnType & { updatedParticipant?: InteractionChannelParticipantInstance }> {
const { interactionSid, channelSid, participantSid, status, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
interactionSid: 'string',

@@ -110,3 +116,2 @@ channelSid: 'string',

try {
const { interactionSid, channelSid, participantSid, status } = parameters;

@@ -142,3 +147,3 @@ const inputError = PluginUtilsErrorManager.checkInvalidParameters<ParticipantUpdateParams>(

}
return retryHandler(this.config, error, parameters, this.participantUpdate);
return retryHandler(this.config, error,{ ...parameters , attempts: !attempts ? 0 : attempts},this.participantUpdate);
}

@@ -148,3 +153,3 @@ }

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.interactionSid the Interaction Sid for this channel

@@ -159,4 +164,4 @@ * @param {string} parameters.channelSid The Channel Sid for this Participant

): Promise<ApiReturnType & { updatedChannel?: InteractionChannelInstance }> {
const { interactionSid, channelSid, status, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
interactionSid: 'string',

@@ -168,3 +173,2 @@ channelSid: 'string',

try {
const { interactionSid, channelSid, status } = parameters;

@@ -199,5 +203,5 @@ const inputError = PluginUtilsErrorManager.checkInvalidParameters<ChannelUpdateParams>(

}
return retryHandler(this.config, error, parameters, this.channelUpdate);
return retryHandler(this.config, error,{ ...parameters , attempts: !attempts ? 0 : attempts}, this.channelUpdate);
}
}
}

@@ -13,2 +13,3 @@ import { Twilio } from 'twilio';

import { PhoneNumberInstance } from 'twilio/lib/rest/lookups/v2/phoneNumber';
import { RETRY_STRATEGY } from 'src/constants/api';

@@ -29,7 +30,12 @@ export default class PhoneNumbersUtils extends PluginUtils {

super(client);
this.config = config;
this.config = {
...config,
maxBackoff: config.maxBackoff || RETRY_STRATEGY.MAX_BACKOFF,
minBackoff: config.minBackoff || RETRY_STRATEGY.MIN_BACKOFF,
retryLimit: config.retryLimit || RETRY_STRATEGY.RETRY_LIMIT,
};
}
/**
* @param {number} parameters.attempts the number of retry attempts performed
* @returns {Array<PhoneNumber>} An array of phone numbers for the account

@@ -42,12 +48,4 @@ * @description the following method is used to robustly retrieve

): Promise<ApiReturnType & { phoneNumbers?: Array<IncomingPhoneNumberInstance> }> {
const parameterChecks = {
attempts: 'number',
};
try {
const inputError = PluginUtilsErrorManager.checkInvalidParameters<Parameters>(parameters, parameterChecks);
if (inputError) {
throw new PluginUtilsErrorManager(inputError, HttpErrorCode.BadRequest);
}
const phoneNumbers = await this.client.incomingPhoneNumbers.list({

@@ -59,10 +57,3 @@ ...(parameters.limit && { limit: parameters.limit }),

} catch (error) {
if (error.code === HttpErrorCode.BadRequest) {
return {
success: false,
status: HttpErrorCode.BadRequest,
message: error.message,
};
}
return retryHandler(this.config, error, parameters, this.listPhoneNumbers);
return retryHandler(this.config, error,{ ...parameters , attempts: !parameters.attempts ? 0 : parameters.attempts},this.listPhoneNumbers);
}

@@ -72,3 +63,3 @@ }

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @returns {Array<PhoneNumber>} An array of outbound caller ids for the account

@@ -81,12 +72,4 @@ * @description the following method is used to robustly retrieve

): Promise<ApiReturnType & { callerIds?: Array<OutgoingCallerIdInstance> }> {
const parameterChecks = {
attempts: 'number',
};
try {
const inputError = PluginUtilsErrorManager.checkInvalidParameters<Parameters>(parameters, parameterChecks);
if (inputError) {
throw new PluginUtilsErrorManager(inputError, HttpErrorCode.BadRequest);
}
const callerIds = await this.client.outgoingCallerIds.list({

@@ -98,10 +81,3 @@ ...(parameters.limit && { limit: parameters.limit }),

} catch (error) {
if (error.code === HttpErrorCode.BadRequest) {
return {
success: false,
status: HttpErrorCode.BadRequest,
message: error.message,
};
}
return retryHandler(this.config, error, parameters, this.listOutgoingCallerIds);
return retryHandler(this.config, error,{ ...parameters , attempts: !parameters.attempts ? 0 : parameters.attempts},this.listOutgoingCallerIds);
}

@@ -111,3 +87,3 @@ }

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.phoneNumber the phone number to validate

@@ -121,3 +97,2 @@ * @returns {object} https://www.twilio.com/docs/lookup/v2-api#making-a-request

const parameterChecks = {
attempts: 'number',
phoneNumber: 'string',

@@ -143,5 +118,5 @@ };

}
return retryHandler(this.config, error, parameters, this.validatePhoneNumber);
return retryHandler(this.config, error,{ ...parameters , attempts: !parameters.attempts ? 0 : parameters.attempts},this.validatePhoneNumber);
}
}
}

@@ -23,2 +23,3 @@ import { Twilio } from 'twilio';

import TwilioRecordingAPI from './Api';
import { RETRY_STRATEGY } from 'src/constants/api';

@@ -40,3 +41,8 @@ export default class ProgrammableVoiceUtils extends PluginUtils {

super(client);
this.config = config;
this.config = {
...config,
maxBackoff: config.maxBackoff || RETRY_STRATEGY.MAX_BACKOFF,
minBackoff: config.minBackoff || RETRY_STRATEGY.MIN_BACKOFF,
retryLimit: config.retryLimit || RETRY_STRATEGY.RETRY_LIMIT,
};
const { accountSid, authToken, region } = config;

@@ -47,3 +53,3 @@ this.api = new TwilioRecordingAPI(accountSid, authToken, region);

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.callSid the unique call SID to fetch

@@ -56,6 +62,6 @@ * @returns {Map} The given call's properties

): Promise<ApiReturnType & { callProperties?: CallInstance }> {
const { callSid } = parameters;
const { callSid, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
callSid: 'string',

@@ -84,3 +90,3 @@ };

}
return retryHandler<Parameters & { callSid: string }>(this.config, error, parameters, this.fetchProperties);
return retryHandler<Parameters & { callSid: string }>(this.config, error,{ ...parameters , attempts: !attempts ? 0 : attempts},this.fetchProperties);
}

@@ -90,3 +96,3 @@ }

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.callSid the unique call SID to fetch

@@ -100,3 +106,3 @@ * @param {string} parameters.twiml the response of twiml based on to and from arguments of event

const parameterChecks = {
attempts: 'number',
callSid: 'string',

@@ -128,6 +134,6 @@ twiml: 'string',

}
return retryHandler<Parameters & { callSid: string; twiml: string;}>(
return retryHandler<Parameters & { callSid: string; twiml: string }>(
this.config,
error,
parameters,
{ ...parameters, attempts: !attempts ? 0 : attempts },
this.coldTransfer,

@@ -139,3 +145,3 @@ );

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.callSid the unique call SID to fetch

@@ -149,5 +155,5 @@ * @param {object} parameters.params recording creation parameters

): Promise<ApiReturnType & { recording?: CallRecordingInstance }> {
const { callSid, params } = parameters;
const { callSid, params, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
callSid: 'string',

@@ -180,3 +186,3 @@ params: 'object',

error,
parameters,
{ ...parameters , attempts: !attempts ? 0 : attempts},
this.createRecording,

@@ -188,3 +194,3 @@ );

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.callSid the unique call SID to update recording

@@ -199,6 +205,6 @@ * @param {string} parameters.recordingSid the unique recording SID to update

): Promise<ApiReturnType & { recording?: CallRecordingInstance }> {
const { callSid, recordingSid, params } = parameters;
const { callSid, recordingSid, params, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
callSid: 'string',

@@ -229,3 +235,3 @@ recordingSid: 'string',

}
return retryHandler<updateCallRecordingParams>(this.config, error, parameters, this.updateCallRecording);
return retryHandler<updateCallRecordingParams>(this.config, error,{ ...parameters , attempts: !attempts ? 0 : attempts},this.updateCallRecording);
}

@@ -235,3 +241,3 @@ }

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.conferenceSid the unique conference SID to update recording

@@ -246,6 +252,6 @@ * @param {string} parameters.recordingSid the unique recording SID to update

): Promise<ApiReturnType & { recording?: ConferenceRecordingInstance }> {
const { conferenceSid, recordingSid, params } = parameters;
const { conferenceSid, recordingSid, params, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
conferenceSid: 'string',

@@ -276,3 +282,3 @@ recordingSid: 'string',

}
return retryHandler<updateConferenceRecording>(this.config, error, parameters, this.updateConferenceRecording);
return retryHandler<updateConferenceRecording>(this.config, error,{ ...parameters , attempts: !attempts ? 0 : attempts},this.updateConferenceRecording);
}

@@ -282,3 +288,3 @@ }

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.callSid the unique call SID to update

@@ -292,6 +298,6 @@ * @param {object} parameters.params recording update parameters

): Promise<ApiReturnType & { call?: CallInstance }> {
const { callSid, params } = parameters;
const { callSid, params, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
callSid: 'string',

@@ -321,3 +327,3 @@ params: 'object',

}
return retryHandler<updateCall>(this.config, error, parameters, this.updateCall);
return retryHandler<updateCall>(this.config, error,{ ...parameters , attempts: !attempts ? 0 : attempts},this.updateCall);
}

@@ -327,3 +333,3 @@ }

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.queueSid the unique queue SID to fetch

@@ -337,6 +343,6 @@ * @param {object} parameters.params recording update parameters

): Promise<ApiReturnType & { queueProperties?: QueueInstance }> {
const { queueSid } = parameters;
const { queueSid, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
queueSid: 'string',

@@ -365,3 +371,3 @@ };

}
return retryHandler<fetchVoiceQueue>(this.config, error, parameters, this.fetchVoiceQueue);
return retryHandler<fetchVoiceQueue>(this.config, error,{ ...parameters , attempts: !attempts ? 0 : attempts},this.fetchVoiceQueue);
}

@@ -371,3 +377,3 @@ }

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.recordingSid the unique recording SID to fetch

@@ -381,6 +387,6 @@ * @param {object} parameters.params recording update parameters

): Promise<ApiReturnType & { recordingProperties?: RecordingInstance }> {
const { recordingSid } = parameters;
const { recordingSid,attempts } = parameters;
const parameterChecks = {
attempts: 'number',
recordingSid: 'string',

@@ -409,3 +415,3 @@ };

}
return retryHandler<fetchRecording>(this.config, error, parameters, this.fetchRecording);
return retryHandler<fetchRecording>(this.config, error,{ ...parameters , attempts: !attempts ? 0 : attempts},this.fetchRecording);
}

@@ -415,3 +421,3 @@ }

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.recordingSid the unique recording SID to fetch

@@ -425,6 +431,6 @@ * @param {object} parameters.params recording update parameters

): Promise<ApiReturnType & { recording?: any , type?: string}> {
const { recordingSid } = parameters;
const { recordingSid, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
recordingSid: 'string',

@@ -457,3 +463,3 @@ };

}
return retryHandler<fetchRecording>(this.config, error, parameters, this.fetchRecordingMedia);
return retryHandler<fetchRecording>(this.config, error,{ ...parameters , attempts: !attempts ? 0 : attempts},this.fetchRecordingMedia);
}

@@ -463,3 +469,3 @@ }

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @returns {Array<PhoneNumber>} An array of outbound caller ids for the account

@@ -472,16 +478,6 @@ * @description the following method is used to robustly retrieve

): Promise<ApiReturnType & { callerIds?: Array<OutgoingCallerIdInstance> }> {
const parameterChecks = {
attempts: 'number',
};
try {
const inputError = PluginUtilsErrorManager.checkInvalidParameters<Parameters>(parameters, parameterChecks);
const callerIds = await this.client.outgoingCallerIds.list();
if (inputError) {
throw new PluginUtilsErrorManager(inputError, HttpErrorCode.BadRequest);
}
const callerIds = await this.client.outgoingCallerIds.list({
});
return { success: true, callerIds, status: HttpErrorCode.OK };

@@ -496,5 +492,10 @@ } catch (error) {

}
return retryHandler(this.config, error, parameters, this.fetchRecording);
return retryHandler(
this.config,
error,
{ ...parameters, attempts: !parameters.attempts ? 0 : parameters.attempts },
this.fetchRecording,
);
}
}
}
import { Twilio } from 'twilio';
import { isBoolean, isNil, isNumber, isObject, isString, merge, omitBy } from 'lodash';
import { attempt, isBoolean, isNil, isNumber, isObject, isString, merge, omitBy } from 'lodash';
import { TaskInstance, TaskListInstanceCreateOptions } from 'twilio/lib/rest/taskrouter/v1/workspace/task';

@@ -22,2 +22,3 @@ import { TaskQueueInstance } from 'twilio/lib/rest/taskrouter/v1/workspace/taskQueue';

import { HttpErrorCode, TwilioErrorCode } from '../../constants/statusCodes';
import { RETRY_STRATEGY } from '../../constants/api';

@@ -48,3 +49,8 @@ import { PluginUtilsErrorManager } from '../../common/PluginUtilsErrorManager';

const { accountSid, authToken, flexWorkSpaceSid, region } = config;
this.config = config;
this.config = {
...config,
maxBackoff: config.maxBackoff || RETRY_STRATEGY.MAX_BACKOFF,
minBackoff: config.minBackoff || RETRY_STRATEGY.MIN_BACKOFF,
retryLimit: config.retryLimit || RETRY_STRATEGY.RETRY_LIMIT,
};
this.api = new TwilioTaskRouterAPI(accountSid, authToken, flexWorkSpaceSid, region);

@@ -56,3 +62,3 @@ }

* @param {number} parameters.attempts the number of retry attempts performed
* @param {number} parameters.limit limit for the queues to be reterived

@@ -77,3 +83,8 @@ * @return { Promise<Array<WorkerInstance>> } - list of all workers from specific workspace

} catch (error) {
return retryHandler(this.config, error, parameters, this.getAllWorkersFromWorkspace);
return retryHandler(
this.config,
error,
{ ...parameters, attempts: !parameters.attempts ? 0 : parameters.attempts },
this.getAllWorkersFromWorkspace,
);
}

@@ -85,3 +96,3 @@ }

* @param {number} parameters.attempts the number of retry attempts performed
* @param {number} parameters.limit limit for the queues to be reterived

@@ -110,3 +121,8 @@ * @param {string} parameters.workflowSid (optional) the workflow SID to filter by

} catch (error) {
return retryHandler(this.config, error, parameters, this.getAllTasksFromWorkspace);
return retryHandler(
this.config,
error,
{ ...parameters, attempts: !parameters.attempts ? 0 : parameters.attempts },
this.getAllTasksFromWorkspace,
);
}

@@ -117,3 +133,3 @@ }

* @param {number} parameters.attempts the number of retry attempts performed
* @param {number} parameters.limit limit for the queues to be reterived

@@ -140,3 +156,8 @@ * @returns {object} An object containing an array of queues for the account

} catch (error) {
return retryHandler(this.config, error, parameters, this.getAllQueues);
return retryHandler(
this.config,
error,
{ ...parameters, attempts: !parameters.attempts ? 0 : parameters.attempts },
this.getAllQueues,
);
}

@@ -147,3 +168,3 @@ }

* @param {number} parameters.attempts the number of retry attempts performed
* @param {number} parameters.limit limit for the queues to be reterived

@@ -170,3 +191,8 @@ * @returns {object} An object containing an array of workflows for the account

} catch (error) {
return retryHandler(this.config, error, parameters, this.getAllWorkflows);
return retryHandler(
this.config,
error,
{ ...parameters, attempts: !parameters.attempts ? 0 : parameters.attempts },
this.getAllWorkflows,
);
}

@@ -176,3 +202,3 @@ }

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.workerSid the worker sid to fetch channels for

@@ -186,6 +212,5 @@ * @returns {object} worker channel object

): Promise<ApiReturnType & { workerChannels?: Array<WorkerChannelInstance> }> {
const { attempts, workerSid } = parameters;
const { workerSid, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
workerSid: 'string',

@@ -221,3 +246,3 @@ };

}
return retryHandler<Parameters & { workerSid: string }>(this.config, error, parameters, this.getWorkerChannels);
return retryHandler<Parameters & { workerSid: string }>(this.config, error,{ ...parameters , attempts: !attempts ? 0 : attempts},this.getWorkerChannels);
}

@@ -228,3 +253,3 @@ }

* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.workerSid the worker sid to fetch channels for

@@ -241,6 +266,5 @@ * @param {string} parameters.workerChannelSid the worker channel sid to fetch channels for

): Promise<ApiReturnType & { workerChannelCapacity?: WorkerChannelInstance }> {
const { workerSid, workerChannelSid, capacity, available } = parameters;
const { workerSid, workerChannelSid, capacity, available, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
workerSid: 'string',

@@ -280,3 +304,3 @@ workerChannelSid: 'string',

}
return retryHandler<WorkerChannelParams>(this.config, error, parameters, this.updateWorkerChannel);
return retryHandler<WorkerChannelParams>(this.config, error,{ ...parameters , attempts: !attempts ? 0 : attempts},this.updateWorkerChannel);
}

@@ -286,3 +310,3 @@ }

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.taskSid the task to update

@@ -294,6 +318,5 @@ * @param {object} parameters.updateParams parameters to update on the task

public async updateTask(parameters: UpdateTaskParams): Promise<ApiReturnType & { task?: TaskInstance }> {
const { taskSid, updateParams } = parameters;
const { taskSid, updateParams, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
taskSid: 'string',

@@ -338,3 +361,3 @@ updateParams: 'object',

}
return retryHandler<UpdateTaskParams>(this.config, error, parameters, this.updateTask);
return retryHandler<UpdateTaskParams>(this.config, error,{ ...parameters , attempts: !attempts ? 0 : attempts},this.updateTask);
}

@@ -344,3 +367,3 @@ }

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.taskSid the task to fetch

@@ -353,6 +376,5 @@ * @returns {object} an object containing the task if successful

): Promise<ApiReturnType & { task?: TaskInstance }> {
const { taskSid } = parameters;
const { taskSid, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
taskSid: 'string',

@@ -394,3 +416,3 @@ };

}
return retryHandler<Parameters & { taskSid: string }>(this.config, error, parameters, this.fetchTask);
return retryHandler<Parameters & { taskSid: string }>(this.config, error,{ ...parameters , attempts: !attempts ? 0 : attempts},this.fetchTask);
}

@@ -401,3 +423,3 @@ }

* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.workflowSid the workflow to submit the task

@@ -418,2 +440,3 @@ * @param {string} parameters.taskChannel the task channel to submit the task on

attributes,
attempts,
priority: overriddenPriority,

@@ -427,3 +450,2 @@ timeout: overriddenTimeout,

const parameterChecks = {
attempts: 'number',
workflowSid: 'string',

@@ -464,3 +486,3 @@ attributes: 'string',

}
return retryHandler<Parameters & TaskListInstanceCreateOptions>(this.config, error, parameters, this.createTask);
return retryHandler<Parameters & TaskListInstanceCreateOptions>(this.config, error,{ ...parameters , attempts: !attempts ? 0 : attempts},this.createTask);
}

@@ -470,3 +492,3 @@ }

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.taskSid the task to update

@@ -478,6 +500,5 @@ * @param {string} parameters.reason a JSON object to merge with the task

public async completeTask(parameters: CompleteTaskParams): Promise<ApiReturnType & { task?: TaskInstance }> {
const { taskSid, reason } = parameters;
const { taskSid, reason, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
taskSid: 'string',

@@ -522,3 +543,3 @@ reason: 'string',

}
return retryHandler<CompleteTaskParams>(this.config, error, parameters, this.completeTask);
return retryHandler<CompleteTaskParams>(this.config, error,{ ...parameters , attempts: !attempts ? 0 : attempts},this.completeTask);
}

@@ -528,3 +549,3 @@ }

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.taskSid the task to update

@@ -539,6 +560,5 @@ * @param {string} parameters.reservationSid the reservation to update

): Promise<ApiReturnType & { reservation?: ReservationInstance }> {
const { taskSid, reservationSid, status } = parameters;
const { taskSid, reservationSid, status, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
taskSid: 'string',

@@ -591,3 +611,3 @@ reservationSid: 'string',

}
return retryHandler<UpdateReservationParams>(this.config, error, parameters, this.updateReservation);
return retryHandler<UpdateReservationParams>(this.config, error,{ ...parameters , attempts: !attempts ? 0 : attempts},this.updateReservation);
}

@@ -597,3 +617,3 @@ }

/**
* @param {number} parameters.attempts the number of retry attempts performed
* @param {string} parameters.taskSid the task to update

@@ -608,5 +628,4 @@ * @param {string} parameters.attributesUpdate a string JSON object to merge with the task

public async updateTaskAttributes(parameters: UpdateTaskAttributesParams) {
const { taskSid, attributesUpdate } = parameters;
const { taskSid, attributesUpdate, attempts } = parameters;
const parameterChecks = {
attempts: 'number',
taskSid: 'string',

@@ -661,5 +680,10 @@ attributesUpdate: 'string',

}
return retryHandler<UpdateTaskAttributesParams>(this.config, error, parameters, this.updateTaskAttributes);
return retryHandler<UpdateTaskAttributesParams>(
this.config,
error,
{ ...parameters, attempts: !attempts ? 0 : attempts},
this.updateTaskAttributes,
);
}
}
}

@@ -13,3 +13,3 @@ import { AxiosResponse } from 'axios';

export interface Parameters {
attempts: number;
attempts?: number;
limit?: number;

@@ -16,0 +16,0 @@ }

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

Sorry, the diff of this file is not supported yet

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