aws-core-utils
Advanced tools
Comparing version 8.0.2 to 8.1.0
@@ -9,2 +9,3 @@ 'use strict'; | ||
const merge = merging.merge; | ||
const isInstanceOf = require('core-functions/objects').isInstanceOf; | ||
@@ -15,2 +16,3 @@ | ||
const BadRequest = appErrors.BadRequest; | ||
const strings = require('core-functions/strings'); | ||
@@ -104,15 +106,21 @@ const isString = strings.isString; | ||
if (logLevel && logging.isValidLogLevel(logLevel)) { | ||
context.log(logLevel, 'Request:', JSON.stringify(event)); | ||
log(context, logLevel, 'Request:', stringify(event)); | ||
} | ||
// Execute the given function | ||
return Promises.try(() => fn(event, context)) | ||
// If a `postConfigure` function was configured then execute it now, BEFORE executing the given function | ||
return executePostConfigure(event, context) | ||
.then(c => { | ||
context = c || context; | ||
// Execute the given function | ||
return fn(event, context); | ||
}) | ||
.then(response => { | ||
// Optionally log the response | ||
if (logLevel && logging.isValidLogLevel(logLevel)) { | ||
context.log(logLevel, 'Response:', JSON.stringify(response)); | ||
log(context, logLevel, 'Response:', stringify(response)); | ||
} | ||
// Log the given success message (if any) | ||
if (isNotBlank(opts.successMsg)) context.info(opts.successMsg); | ||
if (isNotBlank(opts.successMsg)) log(context, LogLevel.INFO, opts.successMsg); | ||
@@ -125,7 +133,7 @@ succeedLambdaCallback(callback, response, event, context); | ||
// Log the invalid request | ||
context.warn(isNotBlank(opts.invalidRequestMsg) ? opts.invalidRequestMsg : 'Invalid request', '-', err.message); | ||
log(context, LogLevel.WARN, isNotBlank(opts.invalidRequestMsg) ? opts.invalidRequestMsg : 'Invalid request', '-', err.message); | ||
failLambdaCallback(callback, err, event, context); | ||
} else { | ||
// Log the error encountered | ||
context.error(isNotBlank(opts.failureMsg) ? opts.failureMsg : 'Failed to execute Lambda', err); | ||
log(context, LogLevel.ERROR, isNotBlank(opts.failureMsg) ? opts.failureMsg : 'Failed to execute Lambda', err); | ||
failLambdaCallback(callback, err, event, context); | ||
@@ -207,2 +215,5 @@ } | ||
} | ||
if (from.postConfigure && !to.postConfigure) { | ||
to.postConfigure = from.postConfigure; | ||
} | ||
if (from.preSuccessCallback && !to.preSuccessCallback) { | ||
@@ -219,2 +230,24 @@ to.preSuccessCallback = from.preSuccessCallback; | ||
/** | ||
* Executes the custom configured `postConfigure` function (if any). | ||
* @param {AWSEvent} event - the AWS event passed to your handler | ||
* @param {StandardHandlerContext} context - the context to use | ||
* @param {PostConfigure|undefined} [context.handler.postConfigure] - an optional function to be used by an AWS Lambda | ||
* `handler` to add any additional configuration needed to the context AFTER the primary configuration of the | ||
* context has completed and BEFORE the main function is executed | ||
* @return {Promise.<*>} a promise of anything - any errors are logged and result in rejections | ||
*/ | ||
function executePostConfigure(event, context) { | ||
const handler = context && context.handler; | ||
const postConfigure = handler && handler.postConfigure; | ||
return typeof postConfigure === 'function' ? | ||
Promises.try(() => postConfigure(event, context)) | ||
.then(c => c || context) | ||
.catch(err => { | ||
log(context, LogLevel.ERROR, err); | ||
throw err; | ||
}) : | ||
Promise.resolve(context); | ||
} | ||
/** | ||
* Executes the custom configured `preSuccessCallback` function (if any). | ||
@@ -229,5 +262,7 @@ * @param {Object} response - a normal or Lambda Proxy integration response to be returned | ||
function executePreSuccessCallback(response, event, context) { | ||
const preSuccessCallback = context.handler && context.handler.preSuccessCallback; | ||
const handler = context && context.handler; | ||
const preSuccessCallback = handler && handler.preSuccessCallback; | ||
return typeof preSuccessCallback === 'function' ? | ||
Promises.try(() => preSuccessCallback(response, event, context)).catch(err => context.error(err)) : | ||
Promises.try(() => preSuccessCallback(response, event, context)) | ||
.catch(err => log(context, LogLevel.ERROR, err)) : | ||
Promise.resolve(); | ||
@@ -247,5 +282,7 @@ } | ||
function executePreFailureCallback(error, errorResponse, event, context) { | ||
const preFailureCallback = context.handler && context.handler.preFailureCallback; | ||
const handler = context && context.handler; | ||
const preFailureCallback = handler && handler.preFailureCallback; | ||
return typeof preFailureCallback === 'function' ? | ||
Promises.try(() => preFailureCallback(error, errorResponse, event, context)).catch(err => context.error(err)) : | ||
Promises.try(() => preFailureCallback(error, errorResponse, event, context)) | ||
.catch(err => log(context, LogLevel.ERROR, err)) : | ||
Promise.resolve(); | ||
@@ -263,6 +300,7 @@ } | ||
function succeedLambdaCallback(callback, response, event, context) { | ||
if (context.handler && context.handler.useLambdaProxy) { | ||
const handler = context && context.handler; | ||
if (handler && handler.useLambdaProxy) { | ||
const statusCode = response && isNotBlank(response.statusCode) ? response.statusCode : 200; | ||
const body = (response && response.body) || response || {}; | ||
const proxyResponse = toLambdaProxyResponse(statusCode, response && response.headers, body, context.handler.defaultHeaders); | ||
const proxyResponse = toLambdaProxyResponse(statusCode, response && response.headers, body, handler.defaultHeaders); | ||
executePreSuccessCallback(proxyResponse, event, context) | ||
@@ -294,8 +332,10 @@ .then(() => callback(null, proxyResponse)); | ||
// Convert the error into an "API" error | ||
const allowedHttpStatusCodes = context.handler && context.handler.allowedHttpStatusCodes; | ||
const handler = context && context.handler; | ||
const allowedHttpStatusCodes = handler && handler.allowedHttpStatusCodes; | ||
const apiError = appErrors.toAppErrorForApiGateway(error, undefined, undefined, allowedHttpStatusCodes); | ||
// Resolve the AWS request id (if available) | ||
apiError.awsRequestId = trim(apiError.awsRequestId) || trim(error.awsRequestId) || trim(context.awsRequestId) || | ||
(context.awsContext && trim(context.awsContext.awsRequestId)) || undefined; | ||
apiError.awsRequestId = trim(apiError.awsRequestId) || trim(error.awsRequestId) || | ||
(context && (trim(context.awsRequestId) || (context.awsContext && trim(context.awsContext.awsRequestId)))) || | ||
undefined; | ||
@@ -305,6 +345,6 @@ // Resolve the audit reference (if available) | ||
if (context.handler && context.handler.useLambdaProxy) { | ||
if (handler && handler.useLambdaProxy) { | ||
const statusCode = apiError.httpStatus; | ||
const body = toCustomOrDefaultErrorResponseBody(apiError, event, context); | ||
const defaultHeaders = context.handler && context.handler.defaultHeaders; | ||
const defaultHeaders = handler.defaultHeaders; | ||
const proxyResponse = toLambdaProxyResponse(statusCode, error.headers, body, defaultHeaders); | ||
@@ -354,3 +394,4 @@ executePreFailureCallback(apiError, proxyResponse, event, context) | ||
try { | ||
const toErrorResponse = context.handler && context.handler.toErrorResponse; | ||
const handler = context && context.handler; | ||
const toErrorResponse = handler && handler.toErrorResponse; | ||
return typeof toErrorResponse === 'function' ? | ||
@@ -360,3 +401,3 @@ toErrorResponse(error, event, context) || toDefaultErrorResponseBody(error) : | ||
} catch (err) { | ||
console.error('ERROR', err); | ||
log(context, LogLevel.ERROR, err); | ||
// fallback to default function if given function fails | ||
@@ -379,3 +420,4 @@ return toDefaultErrorResponseBody(error); | ||
try { | ||
const toErrorResponse = context.handler && context.handler.toErrorResponse; | ||
const handler = context && context.handler; | ||
const toErrorResponse = handler && handler.toErrorResponse; | ||
return typeof toErrorResponse === 'function' ? | ||
@@ -385,3 +427,3 @@ toErrorResponse(error, event, context) || toDefaultErrorResponse(error) : | ||
} catch (err) { | ||
console.error('ERROR', err); | ||
log(context, LogLevel.ERROR, err); | ||
// fallback to default function if given function fails | ||
@@ -415,2 +457,11 @@ return toDefaultErrorResponse(error); | ||
return error && error.toJSON(); | ||
} | ||
function stringify(o) { | ||
try { | ||
return JSON.stringify(o); | ||
} catch (err) { | ||
log(context, LogLevel.ERROR, err); | ||
return strings.stringify(o); | ||
} | ||
} |
## Changes | ||
### 8.1.0 | ||
- Changes to `api-lambdas` module: | ||
- Added support for an optional `postConfigure` function, which can be configured onto `context.handler`, that can be | ||
used by an AWS Lambda `handler` to add any additional configuration needed to the context AFTER the primary | ||
configuration of the context has completed and BEFORE the main function is executed | ||
- Added more checks to better handle missing `context` failure cases | ||
- Added `stringify` function to better survive responses with circular dependencies | ||
- Changes to `other-lambdas` module: | ||
- Added support for an optional `postConfigure` function, which can be configured onto `context.handler`, that can be | ||
used by an AWS Lambda `handler` to add any additional configuration needed to the context AFTER the primary | ||
configuration of the context has completed and BEFORE the main function is executed | ||
- Added more checks to better handle missing `context` failure cases | ||
- Added `stringify` function to better survive responses with circular dependencies | ||
- Fixed intermittent unit test issues | ||
- Changes to `stages` module: | ||
- Enabled configuration of logging options via a new `logging` property or the legacy `loggingOptions` property | ||
- Enabled configuration of logging settings via a new `logging` property or the legacy `loggingSettings` property | ||
- Changes to `contexts` module: | ||
- Enabled configuration of staging options via a new `staging` property or the legacy `stagingOptions` property | ||
- Enabled configuration of staging settings via a new `staging` property or the legacy `stagingSettings` property | ||
- Enabled configuration of custom options via a new `custom` property or the legacy `customOptions` property | ||
- Enabled configuration of custom settings via a new `custom` property or the legacy `customSettings` property | ||
- Fixed unit test defect | ||
### 8.0.2 | ||
@@ -4,0 +28,0 @@ - Updated `aws-sdk` dev dependency to match latest used in AWS Lambda |
@@ -63,4 +63,6 @@ 'use strict'; | ||
// Configure the given context with stage handling and its dependencies (i.e. logging) | ||
stages.configureStageHandling(context, settings ? settings.stageHandlingSettings : undefined, | ||
options ? options.stageHandlingOptions : undefined, settings, options, forceConfiguration); | ||
const stageHandlingSettings = settings ? settings.stageHandling || settings.stageHandlingSettings : undefined; | ||
const stageHandlingOptions = options ? options.stageHandling || options.stageHandlingOptions : undefined; | ||
stages.configureStageHandling(context, stageHandlingSettings, stageHandlingOptions, settings, options, | ||
forceConfiguration); | ||
@@ -71,3 +73,5 @@ // Configure the region after configuring logging | ||
// Configure the given context with any custom settings and/or custom options | ||
configureCustomSettings(context, settings ? settings.customSettings : undefined, options ? options.customOptions : undefined); | ||
const customSettings = settings ? settings.custom || settings.customSettings : undefined; | ||
const customOptions = options ? options.custom || options.customOptions : undefined; | ||
configureCustomSettings(context, customSettings, customOptions); | ||
@@ -74,0 +78,0 @@ // Configure a Kinesis instance (if NOT already configured AND kinesisOptions were provided) |
@@ -7,2 +7,3 @@ 'use strict'; | ||
const copy = copying.copy; | ||
const isInstanceOf = require('core-functions/objects').isInstanceOf; | ||
@@ -13,2 +14,3 @@ | ||
const BadRequest = appErrors.BadRequest; | ||
const strings = require('core-functions/strings'); | ||
@@ -85,15 +87,21 @@ const isNotBlank = strings.isNotBlank; | ||
if (logLevel && logging.isValidLogLevel(logLevel)) { | ||
context.log(logLevel, 'Request:', JSON.stringify(event)); | ||
log(context, logLevel, 'Request:', stringify(event)); | ||
} | ||
// Execute the given function | ||
return Promises.try(() => fn(event, context)) | ||
// If a `postConfigure` function was configured then execute it now, BEFORE executing the given function | ||
return executePostConfigure(event, context) | ||
.then(c => { | ||
context = c || context; | ||
// Execute the given function | ||
return fn(event, context); | ||
}) | ||
.then(response => { | ||
// Optionally log the response | ||
if (logLevel && logging.isValidLogLevel(logLevel)) { | ||
context.log(logLevel, 'Response:', JSON.stringify(response)); | ||
log(context, logLevel, 'Response:', stringify(response)); | ||
} | ||
// Log the given success message (if any) | ||
if (isNotBlank(opts.successMsg)) context.info(opts.successMsg); | ||
if (isNotBlank(opts.successMsg)) log(context, LogLevel.INFO, opts.successMsg); | ||
@@ -106,7 +114,7 @@ succeedLambdaCallback(callback, response, event, context); | ||
// Log the invalid request | ||
context.warn(isNotBlank(opts.invalidRequestMsg) ? opts.invalidRequestMsg : 'Invalid request', '-', err.message); | ||
log(context, LogLevel.WARN, isNotBlank(opts.invalidRequestMsg) ? opts.invalidRequestMsg : 'Invalid request', '-', err.message); | ||
failLambdaCallback(callback, err, event, context); | ||
} else { | ||
// Log the error encountered | ||
context.error(isNotBlank(opts.failureMsg) ? opts.failureMsg : 'Failed to execute Lambda', err); | ||
log(context, LogLevel.ERROR, isNotBlank(opts.failureMsg) ? opts.failureMsg : 'Failed to execute Lambda', err); | ||
failLambdaCallback(callback, err, event, context); | ||
@@ -176,2 +184,5 @@ } | ||
} | ||
if (from.postConfigure && !to.postConfigure) { | ||
to.postConfigure = from.postConfigure; | ||
} | ||
if (from.preSuccessCallback && !to.preSuccessCallback) { | ||
@@ -188,2 +199,24 @@ to.preSuccessCallback = from.preSuccessCallback; | ||
/** | ||
* Executes the custom configured `postConfigure` function (if any). | ||
* @param {AWSEvent} event - the AWS event passed to your handler | ||
* @param {StandardHandlerContext} context - the context to use | ||
* @param {PostConfigure|undefined} [context.handler.postConfigure] - an optional function to be used by an AWS Lambda | ||
* `handler` to add any additional configuration needed to the context AFTER the primary configuration of the | ||
* context has completed and BEFORE the main function is executed | ||
* @return {Promise.<*>} a promise of anything - any errors are logged and result in rejections | ||
*/ | ||
function executePostConfigure(event, context) { | ||
const handler = context && context.handler; | ||
const postConfigure = handler && handler.postConfigure; | ||
return typeof postConfigure === 'function' ? | ||
Promises.try(() => postConfigure(event, context)) | ||
.then(c => c || context) | ||
.catch(err => { | ||
log(context, LogLevel.ERROR, err); | ||
throw err; | ||
}) : | ||
Promise.resolve(context); | ||
} | ||
/** | ||
* Executes the custom configured `preSuccessCallback` function (if any). | ||
@@ -198,5 +231,7 @@ * @param {Object} response - a normal or Lambda Proxy integration response to be returned | ||
function executePreSuccessCallback(response, event, context) { | ||
const preSuccessCallback = context.handler && context.handler.preSuccessCallback; | ||
const handler = context && context.handler; | ||
const preSuccessCallback = handler && handler.preSuccessCallback; | ||
return typeof preSuccessCallback === 'function' ? | ||
Promises.try(() => preSuccessCallback(response, event, context)).catch(err => context.error(err)) : | ||
Promises.try(() => preSuccessCallback(response, event, context)) | ||
.catch(err => log(context, LogLevel.ERROR, err)) : | ||
Promise.resolve(); | ||
@@ -216,5 +251,7 @@ } | ||
function executePreFailureCallback(error, errorResponse, event, context) { | ||
const preFailureCallback = context.handler && context.handler.preFailureCallback; | ||
const handler = context && context.handler; | ||
const preFailureCallback = handler && handler.preFailureCallback; | ||
return typeof preFailureCallback === 'function' ? | ||
Promises.try(() => preFailureCallback(error, errorResponse, event, context)).catch(err => context.error(err)) : | ||
Promises.try(() => preFailureCallback(error, errorResponse, event, context)) | ||
.catch(err => log(context, LogLevel.ERROR, err)) : | ||
Promise.resolve(); | ||
@@ -254,4 +291,5 @@ } | ||
// Resolve the AWS request id (if available) | ||
apiError.awsRequestId = trim(apiError.awsRequestId) || trim(error.awsRequestId) || trim(context.awsRequestId) || | ||
(context.awsContext && trim(context.awsContext.awsRequestId)) || undefined; | ||
apiError.awsRequestId = trim(apiError.awsRequestId) || trim(error.awsRequestId) || | ||
(context && (trim(context.awsRequestId) || (context.awsContext && trim(context.awsContext.awsRequestId)))) || | ||
undefined; | ||
@@ -279,3 +317,4 @@ // Resolve the audit reference (if available) | ||
try { | ||
const toErrorResponse = context.handler && context.handler.toErrorResponse; | ||
const handler = context && context.handler; | ||
const toErrorResponse = handler && handler.toErrorResponse; | ||
return typeof toErrorResponse === 'function' ? | ||
@@ -285,3 +324,3 @@ toErrorResponse(error, event, context) || toDefaultErrorResponse(error) : | ||
} catch (err) { | ||
console.error('ERROR', err); | ||
log(context, LogLevel.ERROR, err); | ||
// fallback to default function if given function fails | ||
@@ -300,1 +339,10 @@ return toDefaultErrorResponse(error); | ||
} | ||
function stringify(o) { | ||
try { | ||
return JSON.stringify(o); | ||
} catch (err) { | ||
log(context, LogLevel.ERROR, err); | ||
return strings.stringify(o); | ||
} | ||
} |
{ | ||
"name": "aws-core-utils", | ||
"version": "8.0.2", | ||
"version": "8.1.0", | ||
"description": "Core utilities for working with Amazon Web Services (AWS), including ARNs, regions, stages, Lambdas, AWS errors, stream events, Kinesis, DynamoDB.DocumentClients, etc.", | ||
@@ -5,0 +5,0 @@ "author": "Byron du Preez", |
@@ -1,2 +0,2 @@ | ||
# aws-core-utils v8.0.2 | ||
# aws-core-utils v8.1.0 | ||
@@ -3,0 +3,0 @@ Core utilities for working with Amazon Web Services (AWS), including ARNs, regions, stages, Lambdas, AWS errors, stream events, Kinesis, DynamoDB.DocumentClients, etc. |
@@ -129,5 +129,9 @@ 'use strict'; | ||
* @param {Object|StandardSettings|undefined} [otherSettings] - optional other configuration settings to use | ||
* @param {LoggingSettings|undefined} [otherSettings.loggingSettings] - optional logging settings to use to configure logging | ||
* @param {LoggingSettings|undefined} [otherSettings.logging] - optional logging settings to use to configure logging | ||
* @param {LoggingSettings|undefined} [otherSettings.loggingSettings] - LEGACY optional logging settings to use to | ||
* configure logging (NB: otherSettings.loggingSettings will be ignored if otherSettings.logging is defined) | ||
* @param {Object|StandardOptions|undefined} [otherOptions] - optional other configuration options to use if no corresponding other settings are provided | ||
* @param {LoggingOptions|undefined} [otherOptions.loggingOptions] - optional logging options to use to configure logging | ||
* @param {LoggingOptions|undefined} [otherOptions.logging] - optional logging options to use to configure logging | ||
* @param {LoggingOptions|undefined} [otherOptions.loggingOptions] - LEGACY optional logging options to use to configure | ||
* logging (NB: otherOptions.loggingOptions will be ignored if otherOptions.logging is defined) | ||
* @param {boolean|undefined} [forceConfiguration] - whether or not to force configuration of the given settings, which | ||
@@ -175,5 +179,9 @@ * will override any previously configured stage handling settings on the given context | ||
* @param {Object|StandardSettings|undefined} [otherSettings] - optional other configuration settings to use | ||
* @param {LoggingSettings|undefined} [otherSettings.loggingSettings] - optional logging settings to use to configure logging | ||
* @param {LoggingSettings|undefined} [otherSettings.logging] - optional logging settings to use to configure logging | ||
* @param {LoggingSettings|undefined} [otherSettings.loggingSettings] - LEGACY optional logging settings to use to | ||
* configure logging (NB: otherSettings.loggingSettings will be ignored if otherSettings.logging is defined) | ||
* @param {Object|StandardOptions|undefined} [otherOptions] - optional other configuration options to use if no corresponding other settings are provided | ||
* @param {LoggingOptions|undefined} [otherOptions.loggingOptions] - optional logging options to use to configure logging | ||
* @param {LoggingOptions|undefined} [otherOptions.logging] - optional logging options to use to configure logging | ||
* @param {LoggingOptions|undefined} [otherOptions.loggingOptions] - LEGACY optional logging options to use to configure | ||
* logging (NB: otherOptions.loggingOptions will be ignored if otherOptions.logging is defined) | ||
* @param {boolean|undefined} [forceConfiguration] - whether or not to force configuration of the default settings, which | ||
@@ -276,5 +284,9 @@ * will override any previously configured stage handling settings on the given context | ||
* @param {Object|StandardSettings|undefined} [otherSettings] - optional other settings to use to configure dependencies | ||
* @param {LoggingSettings|undefined} [otherSettings.loggingSettings] - optional logging settings to use to configure logging | ||
* @param {LoggingSettings|undefined} [otherSettings.logging] - optional logging settings to use to configure logging | ||
* @param {LoggingSettings|undefined} [otherSettings.loggingSettings] - LEGACY optional logging settings to use to | ||
* configure logging (NB: otherSettings.loggingSettings will be ignored if otherSettings.logging is defined) | ||
* @param {Object|StandardOptions|undefined} [otherOptions] - optional other options to use to configure dependencies if corresponding settings are not provided | ||
* @param {LoggingOptions|undefined} [otherOptions.loggingOptions] - optional logging options to use to configure logging | ||
* @param {LoggingOptions|undefined} [otherOptions.logging] - optional logging options to use to configure logging | ||
* @param {LoggingOptions|undefined} [otherOptions.loggingOptions] - LEGACY optional logging options to use to configure | ||
* logging (NB: otherOptions.loggingOptions will be ignored if otherOptions.logging is defined) | ||
* @param {boolean|undefined} [forceConfiguration] - whether or not to force configuration of the given settings, which | ||
@@ -312,5 +324,9 @@ * will override any previously configured stage handling settings on the given context | ||
* @param {Object|StandardSettings|undefined} [otherSettings] - optional other configuration settings to use | ||
* @param {LoggingSettings|undefined} [otherSettings.loggingSettings] - optional logging settings to use to configure logging | ||
* @param {LoggingSettings|undefined} [otherSettings.logging] - optional logging settings to use to configure logging | ||
* @param {LoggingSettings|undefined} [otherSettings.loggingSettings] - LEGACY optional logging settings to use to | ||
* configure logging (NB: otherSettings.loggingSettings will be ignored if otherSettings.logging is defined) | ||
* @param {Object|StandardOptions|undefined} [otherOptions] - optional other configuration options to use if no corresponding other settings are provided | ||
* @param {LoggingOptions|undefined} [otherOptions.loggingOptions] - optional logging options to use to configure logging | ||
* @param {LoggingOptions|undefined} [otherOptions.logging] - optional logging options to use to configure logging | ||
* @param {LoggingOptions|undefined} [otherOptions.loggingOptions] - LEGACY optional logging options to use to configure | ||
* logging (NB: otherOptions.loggingOptions will be ignored if otherOptions.logging is defined) | ||
* @param {boolean|undefined} [forceConfiguration] - whether or not to force configuration of the given settings, which | ||
@@ -322,4 +338,4 @@ * will override any previously configured dependencies' settings on the given context | ||
// Configure logging if not configured yet | ||
logging.configureLogging(context, otherSettings ? otherSettings.loggingSettings : undefined, | ||
otherOptions ? otherOptions.loggingOptions : undefined, forceConfiguration); | ||
logging.configureLogging(context, otherSettings ? (otherSettings.logging || otherSettings.loggingSettings) : | ||
undefined, otherOptions ? (otherOptions.logging || otherOptions.loggingOptions) : undefined, forceConfiguration); | ||
} | ||
@@ -326,0 +342,0 @@ |
@@ -46,7 +46,13 @@ 'use strict'; | ||
* @typedef {Object} StandardSettings - settings to be used to configure a standard context (see StandardContext) | ||
* @property {LoggingSettings|undefined} [loggingSettings] - optional logging settings to use to configure logging | ||
* @property {StageHandlingSettings|undefined} [stageHandlingSettings] - optional stage handling settings to use to | ||
* configure stage handling | ||
* @property {CustomSettings|undefined} [customSettings] - custom settings to be merged into an existing or new | ||
* context.custom object | ||
* @property {LoggingSettings|undefined} [logging] - optional logging settings to use to configure logging | ||
* @property {LoggingSettings|undefined} [loggingSettings] - LEGACY optional logging settings to use to configure | ||
* logging (NB: loggingSettings will be ignored if logging is defined) | ||
* @property {StageHandlingSettings|undefined} [stageHandling] - optional stage handling settings to use to configure | ||
* stage handling | ||
* @property {StageHandlingSettings|undefined} [stageHandlingSettings] - LEGACY optional stage handling settings to use | ||
* to configure stage handling (NB: stageHandlingSettings will be ignored if stageHandling is defined) | ||
* @property {CustomSettings|undefined} [custom] - custom settings to be merged into an existing or new context.custom | ||
* object | ||
* @property {CustomSettings|undefined} [customSettings] - LEGACY custom settings to be merged into an existing or new | ||
* context.custom object (NB: customSettings will be ignored if custom is defined) | ||
* @property {Object|undefined} [kinesisOptions] - optional Kinesis constructor options to use to configure an | ||
@@ -60,7 +66,13 @@ * AWS.Kinesis instance | ||
* @typedef {Object} StandardOptions - options to be used to configure a standard context (see StandardContext) | ||
* @property {LoggingOptions|undefined} [loggingOptions] - optional logging options to use to configure logging | ||
* @property {StageHandlingOptions|undefined} [stageHandlingOptions] - optional stage handling options to use to | ||
* configure stage handling | ||
* @property {CustomOptions|undefined} [customOptions] - custom options to be merged into an existing or new | ||
* context.custom object | ||
* @property {LoggingOptions|undefined} [logging] - optional logging options to use to configure logging | ||
* @property {LoggingOptions|undefined} [loggingOptions] - LEGACY optional logging options to use to configure logging | ||
* (NB: loggingOptions will be ignored if logging is defined) | ||
* @property {StageHandlingOptions|undefined} [stageHandling] - optional stage handling options to use to configure | ||
* stage handling | ||
* @property {StageHandlingOptions|undefined} [stageHandlingOptions] - LEGACY optional stage handling options to use to | ||
* configure stage handling (NB: stageHandlingOptions will be ignored if stageHandling is defined) | ||
* @property {CustomOptions|undefined} [custom] - custom options to be merged into an existing or new context.custom | ||
* object | ||
* @property {CustomOptions|undefined} [customOptions] - LEGACY custom options to be merged into an existing or new | ||
* context.custom object (NB: customOptions will be ignored if custom is defined) | ||
* @property {Object|undefined} [kinesisOptions] - optional Kinesis constructor options to use to configure an | ||
@@ -619,2 +631,5 @@ * AWS.Kinesis instance | ||
* function to convert an AppError into an appropriate error response object | ||
* @property {PostConfigure|undefined} [postConfigure] - an optional function to be used by an AWS Lambda `handler` to | ||
* add any additional configuration needed to the context AFTER the primary configuration of the context has | ||
* completed and BEFORE the main function is executed | ||
* @property {PreSuccessCallback|undefined} [preSuccessCallback] - an optional function to be used by an AWS Lambda | ||
@@ -632,2 +647,8 @@ * `handler` to run any needed shutdown logic immediately before succeeding the Lambda callback | ||
/** | ||
* @typedef {function(event: AWSEvent, context: StandardHandlerContext)} PostConfigure - a function to be used to add | ||
* any additional configuration needed to the context AFTER the primary configuration of the context has | ||
* completed and BEFORE the main function is executed | ||
*/ | ||
/** | ||
* @typedef {function(response: Object, event: AWSEvent, context: StandardHandlerContext)} PreSuccessCallback - | ||
@@ -634,0 +655,0 @@ * a function to use to run any needed shutdown logic immediately before succeeding the Lambda callback |
315645
4267