common-types
Advanced tools
Comparing version 1.21.12 to 1.22.0
@@ -6,3 +6,3 @@ import { AwsRegion } from "./aws-regions"; | ||
*/ | ||
export declare type AwsPartition = "aws" | "aws-cn" | "aws-us-gov"; | ||
export declare type ArnPartition = "aws" | "aws-cn" | "aws-us-gov"; | ||
/** | ||
@@ -24,3 +24,3 @@ * A type alias for an AWS account id. Typically these accounts | ||
*/ | ||
export declare type AwsService = "lambda" | "iam" | "logs" | "states" | "sqs" | "sns" | "dynamodb" | "events" | string; | ||
export declare type ArnService = "lambda" | "iam" | "logs" | "states" | "sqs" | "sns" | "dynamodb" | "events"; | ||
/** | ||
@@ -30,15 +30,15 @@ * AWS _resources_ are found in an ARN and tied to the parent _service_ | ||
*/ | ||
export declare type AwsResource = "function" | "logs" | "states" | "user" | "group" | "stateMachine" | "event-bus" | string; | ||
export declare type ArnResource = "function" | "logs" | "states" | "user" | "group" | "role" | "stateMachine" | "table" | "event-bus"; | ||
/** | ||
* Describes the shape of a fully-qualified AWS **ARN** for a _Lambda function_ | ||
*/ | ||
export declare type AwsLambdaArn = `arn:${AwsPartition}:lambda:${AwsRegion}:${AwsAccountId}:function:${string}`; | ||
export declare type AwsLambdaArn = `arn:${ArnPartition}:lambda:${AwsRegion}:${AwsAccountId}:function:${string}`; | ||
/** | ||
* Describes the shape of a fully-qualified AWS **ARN** for a _log group_. | ||
*/ | ||
export declare type AwsLogGroupArn = `arn:${AwsPartition}:logs:${AwsRegion}:${AwsAccountId}:log-group:${string}`; | ||
export declare type AwsLogGroupArn = `arn:${ArnPartition}:logs:${AwsRegion}:${AwsAccountId}:log-group:${string}`; | ||
/** | ||
* Describes the shape of a fully-qualified AWS **ARN** for a _Step Function_. | ||
*/ | ||
export declare type AwsStepFunctionArn = `arn:${AwsPartition}:states:${AwsRegion}:${AwsAccountId}:stateMachine:${string}`; | ||
export declare type AwsStepFunctionArn = `arn:${ArnPartition}:states:${AwsRegion}:${AwsAccountId}:stateMachine:${string}`; | ||
export declare type AwsIamResource = "user" | "group" | string; | ||
@@ -48,8 +48,8 @@ /** | ||
*/ | ||
export declare type AwsIamArn = `arn:${AwsPartition}:iam:${AwsAccountId}:${AwsIamResource}/${string}`; | ||
export declare type AwsEventBridgeResource = "event-bus"; | ||
export declare type AwsIamArn = `arn:${ArnPartition}:iam:${AwsAccountId}:${AwsIamResource}/${string}`; | ||
export declare type ArnEventBridgeResource = "event-bus"; | ||
/** | ||
* Describes the shape of a fully-qualified AWS **ARN** for a _EventBridge event_. | ||
*/ | ||
export declare type AwsEventBridgeArn = `arn:${AwsPartition}:events:${AwsRegion}:${AwsAccountId}:${AwsEventBridgeResource}/${string}`; | ||
export declare type AwsEventBridgeArn = `arn:${ArnPartition}:events:${AwsRegion}:${AwsAccountId}:${ArnEventBridgeResource}/${string}`; | ||
/** | ||
@@ -65,2 +65,2 @@ * A type alias to indicate a AWS ARN. | ||
*/ | ||
export declare type AwsArn = `arn:${AwsPartition}:${AwsService}:${AwsRegion}:${AwsAccountId}:${string}`; | ||
export declare type AwsArn = `arn:${ArnPartition}:${ArnService}:${AwsRegion}:${AwsAccountId}:${string}` | `arn:${ArnPartition}:${ArnService}::${AwsAccountId}:${string}`; |
import { DevelopmentStage } from "../aliases"; | ||
export declare type AwsStage = DevelopmentStage; | ||
/** | ||
* A AWS _stage_ is identified typically by a development stage | ||
* (e.g., "dev", "prod", etc.) but alternatively you can use a | ||
* _developer sandbox_ as the stage name where the convention is | ||
* that the name is a "sb-[name]". | ||
*/ | ||
export declare type AwsStage = DevelopmentStage | `sb-${string}`; |
import { IAwsLambdaProxyIntegrationRequestV2, IAwsLambdaProxyIntegrationRequest } from "./aws"; | ||
import { AwsArn, AwsEventBridgeArn, AwsLambdaArn, AwsStepFunctionArn } from "./aws-arn"; | ||
import { AwsArn, AwsEventBridgeArn, AwsLambdaArn, ArnPartition, ArnResource, ArnService, AwsStepFunctionArn } from "./aws-arn"; | ||
import { AwsRegion } from "./aws-regions"; | ||
@@ -28,5 +28,17 @@ import { AwsStage } from "./aws-stage"; | ||
/** | ||
* A reasonable strength type guard to validate that a string is in fact | ||
* A reasonable strong type guard to validate that a string is in fact | ||
* a fully qualified ARN. | ||
*/ | ||
export declare function isArn(arn: string): arn is AwsArn; | ||
/** | ||
* A type guard that tests whether a string is a valid AWS _partition_ (from the standpoint of a ARN) | ||
*/ | ||
export declare function isArnPartition(partition: string): partition is ArnPartition; | ||
/** | ||
* A type guard that tests whether a string is a valid AWS _resource_ (from the standpoint of a ARN) | ||
*/ | ||
export declare function isArnResource(resource: string): resource is ArnResource; | ||
/** | ||
* A type guard that tests whether a string is a valid AWS _service_ (from the standpoint of a ARN) | ||
*/ | ||
export declare function isArnService(service: string): service is ArnService; |
@@ -69,3 +69,3 @@ 'use strict'; | ||
function isAwsRegion(region) { | ||
return /^(us|eu|af|ap|me|sa|ca)\-(\w+)\-[0-9]$/.test(region); | ||
return /^(us|eu|af|ap|me|sa|ca)\-(north|south|east|west|central|northeast|southeast)\-[1-3]$/.test(region); | ||
} | ||
@@ -88,3 +88,3 @@ /** | ||
/** | ||
* A reasonable strength type guard to validate that a string is in fact | ||
* A reasonable strong type guard to validate that a string is in fact | ||
* a fully qualified ARN. | ||
@@ -95,2 +95,20 @@ */ | ||
} | ||
/** | ||
* A type guard that tests whether a string is a valid AWS _partition_ (from the standpoint of a ARN) | ||
*/ | ||
function isArnPartition(partition) { | ||
return /(aws|aws-cn|aws-us-gov)/.test(partition); | ||
} | ||
/** | ||
* A type guard that tests whether a string is a valid AWS _resource_ (from the standpoint of a ARN) | ||
*/ | ||
function isArnResource(resource) { | ||
return /(function|logs|states|user|group|stateMachine|event-bus|table)/.test(resource); | ||
} | ||
/** | ||
* A type guard that tests whether a string is a valid AWS _service_ (from the standpoint of a ARN) | ||
*/ | ||
function isArnService(service) { | ||
return /(lambda|iam|logs|states|sqs|sns|dynamodb|events)/.test(service); | ||
} | ||
@@ -544,2 +562,5 @@ /** | ||
exports.isArn = isArn; | ||
exports.isArnPartition = isArnPartition; | ||
exports.isArnResource = isArnResource; | ||
exports.isArnService = isArnService; | ||
exports.isAwsRegion = isAwsRegion; | ||
@@ -546,0 +567,0 @@ exports.isAwsStage = isAwsStage; |
@@ -6,3 +6,3 @@ import { AwsRegion } from "./aws-regions"; | ||
*/ | ||
export declare type AwsPartition = "aws" | "aws-cn" | "aws-us-gov"; | ||
export declare type ArnPartition = "aws" | "aws-cn" | "aws-us-gov"; | ||
/** | ||
@@ -24,3 +24,3 @@ * A type alias for an AWS account id. Typically these accounts | ||
*/ | ||
export declare type AwsService = "lambda" | "iam" | "logs" | "states" | "sqs" | "sns" | "dynamodb" | "events" | string; | ||
export declare type ArnService = "lambda" | "iam" | "logs" | "states" | "sqs" | "sns" | "dynamodb" | "events"; | ||
/** | ||
@@ -30,15 +30,15 @@ * AWS _resources_ are found in an ARN and tied to the parent _service_ | ||
*/ | ||
export declare type AwsResource = "function" | "logs" | "states" | "user" | "group" | "stateMachine" | "event-bus" | string; | ||
export declare type ArnResource = "function" | "logs" | "states" | "user" | "group" | "role" | "stateMachine" | "table" | "event-bus"; | ||
/** | ||
* Describes the shape of a fully-qualified AWS **ARN** for a _Lambda function_ | ||
*/ | ||
export declare type AwsLambdaArn = `arn:${AwsPartition}:lambda:${AwsRegion}:${AwsAccountId}:function:${string}`; | ||
export declare type AwsLambdaArn = `arn:${ArnPartition}:lambda:${AwsRegion}:${AwsAccountId}:function:${string}`; | ||
/** | ||
* Describes the shape of a fully-qualified AWS **ARN** for a _log group_. | ||
*/ | ||
export declare type AwsLogGroupArn = `arn:${AwsPartition}:logs:${AwsRegion}:${AwsAccountId}:log-group:${string}`; | ||
export declare type AwsLogGroupArn = `arn:${ArnPartition}:logs:${AwsRegion}:${AwsAccountId}:log-group:${string}`; | ||
/** | ||
* Describes the shape of a fully-qualified AWS **ARN** for a _Step Function_. | ||
*/ | ||
export declare type AwsStepFunctionArn = `arn:${AwsPartition}:states:${AwsRegion}:${AwsAccountId}:stateMachine:${string}`; | ||
export declare type AwsStepFunctionArn = `arn:${ArnPartition}:states:${AwsRegion}:${AwsAccountId}:stateMachine:${string}`; | ||
export declare type AwsIamResource = "user" | "group" | string; | ||
@@ -48,8 +48,8 @@ /** | ||
*/ | ||
export declare type AwsIamArn = `arn:${AwsPartition}:iam:${AwsAccountId}:${AwsIamResource}/${string}`; | ||
export declare type AwsEventBridgeResource = "event-bus"; | ||
export declare type AwsIamArn = `arn:${ArnPartition}:iam:${AwsAccountId}:${AwsIamResource}/${string}`; | ||
export declare type ArnEventBridgeResource = "event-bus"; | ||
/** | ||
* Describes the shape of a fully-qualified AWS **ARN** for a _EventBridge event_. | ||
*/ | ||
export declare type AwsEventBridgeArn = `arn:${AwsPartition}:events:${AwsRegion}:${AwsAccountId}:${AwsEventBridgeResource}/${string}`; | ||
export declare type AwsEventBridgeArn = `arn:${ArnPartition}:events:${AwsRegion}:${AwsAccountId}:${ArnEventBridgeResource}/${string}`; | ||
/** | ||
@@ -65,2 +65,2 @@ * A type alias to indicate a AWS ARN. | ||
*/ | ||
export declare type AwsArn = `arn:${AwsPartition}:${AwsService}:${AwsRegion}:${AwsAccountId}:${string}`; | ||
export declare type AwsArn = `arn:${ArnPartition}:${ArnService}:${AwsRegion}:${AwsAccountId}:${string}` | `arn:${ArnPartition}:${ArnService}::${AwsAccountId}:${string}`; |
import { DevelopmentStage } from "../aliases"; | ||
export declare type AwsStage = DevelopmentStage; | ||
/** | ||
* A AWS _stage_ is identified typically by a development stage | ||
* (e.g., "dev", "prod", etc.) but alternatively you can use a | ||
* _developer sandbox_ as the stage name where the convention is | ||
* that the name is a "sb-[name]". | ||
*/ | ||
export declare type AwsStage = DevelopmentStage | `sb-${string}`; |
import { IAwsLambdaProxyIntegrationRequestV2, IAwsLambdaProxyIntegrationRequest } from "./aws"; | ||
import { AwsArn, AwsEventBridgeArn, AwsLambdaArn, AwsStepFunctionArn } from "./aws-arn"; | ||
import { AwsArn, AwsEventBridgeArn, AwsLambdaArn, ArnPartition, ArnResource, ArnService, AwsStepFunctionArn } from "./aws-arn"; | ||
import { AwsRegion } from "./aws-regions"; | ||
@@ -28,5 +28,17 @@ import { AwsStage } from "./aws-stage"; | ||
/** | ||
* A reasonable strength type guard to validate that a string is in fact | ||
* A reasonable strong type guard to validate that a string is in fact | ||
* a fully qualified ARN. | ||
*/ | ||
export declare function isArn(arn: string): arn is AwsArn; | ||
/** | ||
* A type guard that tests whether a string is a valid AWS _partition_ (from the standpoint of a ARN) | ||
*/ | ||
export declare function isArnPartition(partition: string): partition is ArnPartition; | ||
/** | ||
* A type guard that tests whether a string is a valid AWS _resource_ (from the standpoint of a ARN) | ||
*/ | ||
export declare function isArnResource(resource: string): resource is ArnResource; | ||
/** | ||
* A type guard that tests whether a string is a valid AWS _service_ (from the standpoint of a ARN) | ||
*/ | ||
export declare function isArnService(service: string): service is ArnService; |
@@ -65,3 +65,3 @@ /** | ||
function isAwsRegion(region) { | ||
return /^(us|eu|af|ap|me|sa|ca)\-(\w+)\-[0-9]$/.test(region); | ||
return /^(us|eu|af|ap|me|sa|ca)\-(north|south|east|west|central|northeast|southeast)\-[1-3]$/.test(region); | ||
} | ||
@@ -84,3 +84,3 @@ /** | ||
/** | ||
* A reasonable strength type guard to validate that a string is in fact | ||
* A reasonable strong type guard to validate that a string is in fact | ||
* a fully qualified ARN. | ||
@@ -91,2 +91,20 @@ */ | ||
} | ||
/** | ||
* A type guard that tests whether a string is a valid AWS _partition_ (from the standpoint of a ARN) | ||
*/ | ||
function isArnPartition(partition) { | ||
return /(aws|aws-cn|aws-us-gov)/.test(partition); | ||
} | ||
/** | ||
* A type guard that tests whether a string is a valid AWS _resource_ (from the standpoint of a ARN) | ||
*/ | ||
function isArnResource(resource) { | ||
return /(function|logs|states|user|group|stateMachine|event-bus|table)/.test(resource); | ||
} | ||
/** | ||
* A type guard that tests whether a string is a valid AWS _service_ (from the standpoint of a ARN) | ||
*/ | ||
function isArnService(service) { | ||
return /(lambda|iam|logs|states|sqs|sns|dynamodb|events)/.test(service); | ||
} | ||
@@ -535,3 +553,3 @@ /** | ||
export { AWS_REGIONS, AwsRegionName, HttpStatusCodes, LambdaEventParser, StepFunctionMissingDataTreatment, createBindDeploymentConfig, getBodyFromPossibleLambdaProxyRequest, isArn, isAwsRegion, isAwsStage, isEventBridgeArn, isLambdaArn, isLambdaProxyRequest, isProxyRequestContextV2, isServerlessFunctionHandler, isServerlessFunctionImage, isStepFunctionArn, isTypeSubtype, parseStack, wait }; | ||
export { AWS_REGIONS, AwsRegionName, HttpStatusCodes, LambdaEventParser, StepFunctionMissingDataTreatment, createBindDeploymentConfig, getBodyFromPossibleLambdaProxyRequest, isArn, isArnPartition, isArnResource, isArnService, isAwsRegion, isAwsStage, isEventBridgeArn, isLambdaArn, isLambdaProxyRequest, isProxyRequestContextV2, isServerlessFunctionHandler, isServerlessFunctionImage, isStepFunctionArn, isTypeSubtype, parseStack, wait }; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "common-types", | ||
"version": "1.21.12", | ||
"version": "1.22.0", | ||
"description": "Common types not included in Typescript", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/lifegadget/common-types", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
346749
8248