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

aws-core-utils

Package Overview
Dependencies
Maintainers
1
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aws-core-utils - npm Package Compare versions

Comparing version 5.0.6 to 5.0.7

stage-handling-type-defs.js

4

package.json
{
"name": "aws-core-utils",
"version": "5.0.6",
"version": "5.0.7",
"description": "Core utilities for working with Amazon Web Services (AWS), including ARNs, regions, stages, Lambdas, AWS errors, stream events, Kinesis, DynamoDB.DocumentClients, etc.",

@@ -15,3 +15,3 @@ "author": "Byron du Preez",

"core-functions": "^2.0.11",
"logging-utils": "^3.0.6",
"logging-utils": "^3.0.7",
"deep-equal": "^1.0.1"

@@ -18,0 +18,0 @@ },

@@ -294,2 +294,11 @@ # aws-core-utils v5.0.6

### 5.0.7
- Added `stage-handling-type-defs.js` module to hold all of the stage handling related typedefs
- Added `StageHandlingOptions` and `StageHandlingSettings` typedefs from `stages.js`
- Added new `StageHandling` and `StageAware` typedefs
- Changes to `stages.js` module:
- Removed `StageHandlingOptions` and `StageHandlingSettings` typedefs
- Changed the argument and return types on many of the functions to use the existing and new typedefs
- Updated `logging-utils` dependency to version 3.0.7
### 5.0.6

@@ -296,0 +305,0 @@ - Updated `core-functions` dependency to version 2.0.11

@@ -98,67 +98,2 @@ 'use strict';

/**
* Stage handling settings are used for configuring and customising stage handling behaviour. The stage handling
* settings determine how {@linkcode resolveStage}, {@linkcode toStageQualifiedStreamName},
* {@linkcode extractStageFromQualifiedStreamName}, {@linkcode toStageQualifiedResourceName},
* {@linkcode extractStageFromQualifiedStreamName} and other internal functions will behave when invoked.
*
* NB: Add any, new custom settings that you need for any custom implementations of some or all of the stage handling
* functions that you develop and configure via {@linkcode configureStageHandling}.
*
* Notes:
* - If injectInCase is set to 'upper' then extractInCase should typically be set to 'lower'.
* - If injectInCase is set to 'lower' then extractInCase should typically be set to 'upper'.
* - If injectInCase is set to 'as_is' then extractInCase should typically be set to 'as_is'.
*
* - Recommendation: For clarity, use 'as_is' to keep extracted and resolved stages as is (i.e. to NOT convert them to
* either upper or lowercase). Technically any non-blank value will achieve the same result, but the 'as_is' is less
* confusing.
*
* @typedef {Object} StageHandlingSettings
* @property {string|undefined} [envStageName] - the optional name of a process.env environment variable that holds the
* configured stage (if any) (using AWS Lambda's new environment support), defaults to 'STAGE' if not defined
* @property {Function|undefined} [customToStage] - an optional custom function that accepts: an AWS event; an AWS context;
* and a context, and somehow extracts a usable stage from the AWS event and/or AWS context.
* @property {Function|undefined} [convertAliasToStage] - an optional function that accepts: an extracted alias (if any);
* an AWS event; an AWS context; and a context, and converts the alias into a stage
* @property {Function|undefined} [injectStageIntoStreamName] - an optional function that accepts: an unqualified stream
* name; a stage; and a context, and returns a stage-qualified stream name (effectively the reverse function of the
* extractStageFromStreamName function)
* @property {Function|undefined} [extractStageFromStreamName] - an optional function that accepts: a stage-qualified
* stream name; and a context, and extracts a stage from the stream name
* @property {string|undefined} [streamNameStageSeparator] - an optional non-blank separator to use to extract a stage from
* a stage-qualified stream name or inject a stage into an unqualified stream name
* @property {Function|undefined} [injectStageIntoResourceName] - an optional function that accepts: an unqualified
* resource name; a stage; and a context, and returns a stage-qualified resource name (effectively the reverse function
* of the extractStageFromResourceName function)
* @property {Function|undefined} [extractStageFromResourceName] - an optional function that accepts: a stage-qualified
* resource name; and a context, and extracts a stage from the resource name
* @property {string|undefined} [resourceNameStageSeparator] - an optional non-blank separator to use to extract a stage
* from a stage-qualified resource name or inject a stage into an unqualified resource name
* @property {string|undefined} [injectInCase] - optionally specifies whether to convert an injected stage to uppercase (if
* 'upper' or 'uppercase') or to lowercase (if 'lowercase' or 'lower') or keep it as given (if 'as_is' or anything else)
* @property {string|undefined} [extractInCase] - optionally specifies whether to convert an extracted stage to uppercase
* (if 'upper' or 'uppercase') or to lowercase (if 'lowercase' or 'lower') or keep it as extracted (if 'as_is' or
* anything else)
* @property {string|undefined} [defaultStage] - an optional default stage to use as a last resort if all other attempts fail
*/
/**
* Stage handling options are a subset of the full (@linkcode StageHandlingSettings}, which are used to configure ONLY
* the property (i.e. non-function) stage handling settings.
* @typedef {Object} StageHandlingOptions
* @property {string|undefined} [envStageName] - the optional name of a process.env environment variable that holds the
* configured stage (if any) (using AWS Lambda's new environment support), defaults to 'STAGE' if not defined
* @property {string|undefined} [streamNameStageSeparator] - an optional non-blank separator to use to extract a stage from
* a stage-qualified stream name or inject a stage into an unqualified stream name
* @property {string|undefined} [resourceNameStageSeparator] - an optional non-blank separator to use to extract a stage
* from a stage-qualified resource name or inject a stage into an unqualified resource name
* @property {string|undefined} [injectInCase] - optionally specifies whether to convert an injected stage to uppercase (if
* 'upper' or 'uppercase') or to lowercase (if 'lowercase' or 'lower') or keep it as given (if 'as_is' or anything else)
* @property {string|undefined} [extractInCase] - optionally specifies whether to convert an extracted stage to uppercase
* (if 'upper' or 'uppercase') or to lowercase (if 'lowercase' or 'lower') or keep it as extracted (if 'as_is' or
* anything else)
* @property {string|undefined} [defaultStage] - an optional default stage to use as a last resort if all other attempts fail
*/
/**
* Configures the given context with the given stage handling settings, but only if stage handling is not already

@@ -170,3 +105,3 @@ * configured on the given context OR if forceConfiguration is true. The stage handling settings determine how

*
* @param {Object} context the context onto which to configure stage handling settings
* @param {Object} context - the context onto which to configure stage handling settings
* @param {StageHandlingSettings} [context.stageHandling] - previously configured stage handling settings on the context (if any)

@@ -180,3 +115,3 @@ * @param {StageHandlingSettings} settings - the new stage handling settings to use

* will override any previously configured stage handling settings on the given context
* @return {Object} the context object configured with stage handling settings
* @return {StageHandling} the context object configured with stage handling settings and logging functionality
*/

@@ -226,3 +161,4 @@ function configureStageHandlingWithSettings(context, settings, otherSettings, otherOptions, forceConfiguration) {

* will override any previously configured stage handling settings on the given context
* @return {Object} the context object configured with stage handling settings (either existing or defaults or overrides)
* @return {StageHandling} the context object configured with stage handling settings (either existing or defaults or
* overrides) and logging functionality
*/

@@ -285,4 +221,4 @@ function configureDefaultStageHandling(context, options, otherSettings, otherOptions, forceConfiguration) {

* Returns the value of the named stage handling setting (if any) on the given context.
* @param context - the context from which to fetch the named setting's value
* @param settingName - the name of the stage handling setting
* @param {StageHandling} context - the context from which to fetch the named setting's value
* @param {string} settingName - the name of the stage handling setting
* @returns {*|undefined} the value of the named setting (if any); otherwise undefined

@@ -298,4 +234,4 @@ */

* function); otherwise returns undefined.
* @param context - the context from which to fetch the function
* @param settingName - the name of the stage handling setting
* @param {StageHandling} context - the context from which to fetch the function
* @param {string} settingName - the name of the stage handling setting
* @returns {*|undefined} the named function (if it's a function); otherwise undefined

@@ -322,3 +258,3 @@ */

* will override any previously configured stage handling settings on the given context
* @returns {Object} the given context
* @return {StageHandling} the given context object configured with stage handling settings and logging functionality
*/

@@ -362,3 +298,3 @@ function configureStageHandling(context, settings, options, otherSettings, otherOptions, forceConfiguration) {

* will override any previously configured dependencies' settings on the given context
* @returns {Object} the context object configured with stage handling dependencies
* @returns {Logging} the context object configured with stage handling dependencies (i.e. logging functionality)
*/

@@ -416,24 +352,4 @@ function configureDependencies(context, otherSettings, otherOptions, forceConfiguration) {

* @param {Object} awsContext - the AWS context, which was passed to your lambda
* @param {Object} context - the context to use, which will contain any and all of the pre-configured settings
* @param {string|undefined} [context.stage] - an optional stage on the given context, which will short-circuit
* resolution to this stage (if non-blank)
* @param {StageHandlingSettings|undefined} [context.stageHandling] - the configured stage handling settings (if any) on
* the given context, which can be used to pass additional configuration through to any custom functions that you configured
* @param {Function|undefined} [context.stageHandling.customToStage] - an optional custom function that accepts: an
* AWS event; an AWS context; and a context, and somehow extracts and returns a usable stage from the AWS event and/or
* AWS context
* @param {Function|undefined} [context.stageHandling.convertAliasToStage] - an optional function on the given
* context that accepts: an extracted alias (if any); an AWS event; an AWS context; and a context, and converts the
* alias into a stage
* @param {Function|undefined} [context.stageHandling.extractStageFromStreamName] - an optional function on the given
* context that accepts: a stage-qualified stream name; and a context, and extracts a stage from the stream name
* @param {Function|undefined} [context.stageHandling.extractStageFromResourceName] - an optional function on the given
* context that accepts: a stage-qualified resource (e.g. table) name; and a context, and extracts a stage from the resource name
* @param {string|undefined} [context.stageHandling.defaultStage] - an optional default stage on the given context to
* use as a second last resort if all other attempts fail (configure this via configureStageHandling)
* @param {string|undefined} [context.defaultStage] - an optional default stage on the given context to use as the LAST
* resort if all other attempts fail
* @param {string|undefined} [context.stageHandling.extractInCase] - specifies whether to convert the resolved stage to
* uppercase (if 'upper' or 'uppercase') or to lowercase (if 'lower' or 'lowercase') or keep it as resolved (if 'as_is'
* or anything else)
* @param {StageHandling|StageAware|Object} context - the context to use, which should ideally contain any and all of
* the pre-configured stage handling settings
* @returns {string} the resolved stage (if non-blank); otherwise an empty string

@@ -582,3 +498,3 @@ */

* @param {Object} awsContext - the AWS context
* @param {Object} context - the context
* @param {StageHandling|Object} context - the context to use with stage handling settings and logging functionality
* @returns {string} the resolved stage (if non-blank); otherwise an empty string

@@ -603,6 +519,3 @@ */

* @param {string} stage - the stage to inject
* @param {Object} context - the context, which can also be used to pass additional configuration through to a custom
* injectStageIntoStreamName function that you configured
* @param {Function|undefined} [context.stageHandling.injectStageIntoStreamName] - an optional function that accepts:
* an unqualified stream name; a stage; and a context, and returns a stage-qualified stream name
* @param {StageHandling|Object} context - the context to use with stage handling settings and logging functionality
* @returns {string} a stage-qualified stream name (or the given stream name)

@@ -622,6 +535,3 @@ */

* @param {string} qualifiedStreamName - the stage-qualified stream name
* @param {Object} context - the context, which can also be used to pass additional configuration through to a custom
* extractStageFromStreamName function that you configured
* @param {Function|undefined} [context.stageHandling.extractStageFromStreamName] - an optional function that accepts:
* a stage-qualified stream name; and a context, and extracts a stage from the stream name
* @param {StageHandling|Object} context - the context to use with stage handling settings and logging functionality
* @returns {string} the stage extracted from the stage-qualified stream name or an empty string

@@ -644,7 +554,3 @@ */

* @param {string} stage - the stage to append
* @param {Object} context - the context
* @param {string|undefined} [context.stageHandling.streamNameStageSeparator] - an optional non-blank separator to use
* to append a stage suffix to an unsuffixed stream name
* @param {string|undefined} [context.stageHandling.injectInCase] - specifies whether to convert the stage to uppercase
* (if 'upper' or 'uppercase') or to lowercase (if 'lower' or 'lowercase') or keep it as is (if 'as_is' or anything else)
* @param {StageHandling|Object} context - the context to use with stage handling settings and logging functionality
* @returns {string} the stage-suffixed stream name

@@ -663,6 +569,3 @@ */

* @param {string} stageSuffixedStreamName - the stage-suffixed name of the stream
* @param {Object} context - the context
* @param {string|undefined} [context.stageHandling.streamNameStageSeparator] - an optional non-blank separator to use
* @param {string|undefined} [context.stageHandling.extractInCase] - specifies whether to convert the stage to uppercase
* (if 'upper' or 'uppercase') or to lowercase (if 'lower' or 'lowercase') or keep it as is (if anything else);
* @param {StageHandling|Object} context - the context to use with stage handling settings and logging functionality
* @returns {string} the stage (if extracted) or an empty string

@@ -688,6 +591,3 @@ */

* @param {string} stage - the stage to inject
* @param {Object} context - the context, which can also be used to pass additional configuration through to a custom
* injectStageIntoResourceName function that you configured
* @param {Function|undefined} context.stageHandling.injectStageIntoResourceName - an optional function that accepts:
* an unqualified resource name; a stage; and a context, and returns a stage-qualified resource name
* @param {StageHandling|Object} context - the context to use with stage handling settings and logging functionality
* @returns {string} a stage-qualified resource name

@@ -707,6 +607,3 @@ */

* @param {string} qualifiedResourceName - the stage-qualified resource name
* @param {Object} context - the context, which can also be used to pass additional configuration through to a custom
* extractStageFromResourceName function that you configured
* @param {Function|undefined} [context.stageHandling.extractStageFromResourceName] - an optional function that accepts:
* a stage-qualified resource name; and a context, and extracts a stage from the resource name
* @param {StageHandling|Object} context - the context to use with stage handling settings and logging functionality
* @returns {string} the stage extracted from the stage-qualified resource name; or an empty string

@@ -728,7 +625,3 @@ */

* @param {string} stage - the stage to append
* @param {Object} context - the context
* @param {string|undefined} [context.stageHandling.resourceNameStageSeparator] - an optional non-blank separator to use
* to append a stage suffix to an unsuffixed stream name
* @param {string|undefined} [context.stageHandling.injectInCase] - specifies whether to convert the stage to uppercase
* (if 'upper' or 'uppercase') or to lowercase (if 'lower' or 'lowercase') or keep it as is (if 'as_is' or anything else)
* @param {StageHandling|Object} context - the context to use with stage handling settings and logging functionality
* @returns {string} the stage-suffixed resource name

@@ -746,6 +639,3 @@ */

* @param {string} stageSuffixedResourceName the stage-suffixed name of the resource
* @param {Object} context the context
* @param {string|undefined} [context.stageHandling.resourceNameStageSeparator] - an optional non-blank separator to use
* @param {string|undefined} [context.stageHandling.extractInCase] - specifies whether to convert the stage to uppercase
* (if 'upper' or 'uppercase') or to lowercase (if 'lower' or 'lowercase') or keep it as is (if 'as-is' or anything else)
* @param {StageHandling|Object} context - the context to use with stage handling settings and logging functionality
* @returns {string} the stage (if extracted) or an empty string

@@ -861,4 +751,4 @@ */

* (if failFast is explicitly true) or logs a warning.
* @param {Object} context - a context on which to set the stage
* @param {Object} [context.stage] - a context on which to set the stage
* @param {StageHandling|StageAware|Object} context - a context with stage handling settings and logging functionality
* on which to set the stage
* @param {Object} event - the AWS event

@@ -869,3 +759,3 @@ * @param {Object} awsContext - the AWS context, which was passed to your lambda

* @throws {Error} if failFast is explicitly true and a needed resolved stage is blank
* @returns {Object} the context with its existing stage or the resolved stage or an empty string stage.
* @returns {StageAware} the given context with its existing stage or the resolved stage or an empty string stage.
*/

@@ -872,0 +762,0 @@ function configureStage(context, event, awsContext, failFast) {

{
"name": "aws-core-utils-tests",
"description": "Unit tests for aws-core-utils modules",
"version": "5.0.6",
"version": "5.0.7",
"author": "Byron du Preez",

@@ -6,0 +6,0 @@ "license": "Apache-2.0",

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