common-types
Advanced tools
Comparing version 1.21.8 to 1.21.9
@@ -31,2 +31,16 @@ /** | ||
} | ||
/** | ||
* Strong typing of all valid AWS regions. | ||
* | ||
* > Note: if you need a more generalized form you can try `AwsRegionPattern` | ||
*/ | ||
export declare type AwsRegion = keyof typeof AwsRegionName; | ||
declare type Region = "us" | "us" | "ca" | "af" | "ap" | "eu" | "me" | "sa"; | ||
declare type SubRegion = "east" | "west" | "south" | "north" | "southeast" | "northeast" | "central"; | ||
/** | ||
* Reasonable typing of AWS regions based on known patterns. | ||
* | ||
* > Note: for explicit regions available use `AwsRegion` instead | ||
*/ | ||
export declare type AwsRegionPattern = `${Region}-${SubRegion}-${"1" | "2" | "3"}`; | ||
export {}; |
import { IAwsLambdaProxyIntegrationRequestV2, IAwsLambdaProxyIntegrationRequest } from "./aws"; | ||
import { AwsLambdaArn } from "./aws-arn"; | ||
import { AwsRegion } from "./aws-regions"; | ||
/** | ||
@@ -12,1 +13,5 @@ * Distinguishes between a V1 and V2 Proxy Integration Request | ||
export declare function isLambdaArn(arn: string): arn is AwsLambdaArn; | ||
/** | ||
* Type guard to ensure that a given string is a `AwsRegion` | ||
*/ | ||
export declare function isAwsRegion(region: string): region is AwsRegion; |
@@ -27,4 +27,5 @@ 'use strict'; | ||
AwsRegionName["us-west-2"] = "Oregon"; | ||
// Africa | ||
AwsRegionName["af-south-1"] = "Cape Town"; | ||
// AP | ||
AwsRegionName["af-south-1"] = "Cape Town"; | ||
AwsRegionName["ap-east-1"] = "Hong Kong"; | ||
@@ -37,2 +38,3 @@ AwsRegionName["ap-south-1"] = "Mumbai"; | ||
AwsRegionName["ap-southeast-2"] = "Sydney"; | ||
// Canada | ||
AwsRegionName["ca-central-1"] = "Canada (central)"; | ||
@@ -65,2 +67,8 @@ // EU | ||
} | ||
/** | ||
* Type guard to ensure that a given string is a `AwsRegion` | ||
*/ | ||
function isAwsRegion(region) { | ||
return /^(us|eu|af|ap|me|sa|ca)\-(\w+)\-[0-9]$/.test(region); | ||
} | ||
@@ -513,2 +521,3 @@ /** | ||
exports.getBodyFromPossibleLambdaProxyRequest = getBodyFromPossibleLambdaProxyRequest; | ||
exports.isAwsRegion = isAwsRegion; | ||
exports.isLambdaArn = isLambdaArn; | ||
@@ -515,0 +524,0 @@ exports.isLambdaProxyRequest = isLambdaProxyRequest; |
@@ -31,2 +31,16 @@ /** | ||
} | ||
/** | ||
* Strong typing of all valid AWS regions. | ||
* | ||
* > Note: if you need a more generalized form you can try `AwsRegionPattern` | ||
*/ | ||
export declare type AwsRegion = keyof typeof AwsRegionName; | ||
declare type Region = "us" | "us" | "ca" | "af" | "ap" | "eu" | "me" | "sa"; | ||
declare type SubRegion = "east" | "west" | "south" | "north" | "southeast" | "northeast" | "central"; | ||
/** | ||
* Reasonable typing of AWS regions based on known patterns. | ||
* | ||
* > Note: for explicit regions available use `AwsRegion` instead | ||
*/ | ||
export declare type AwsRegionPattern = `${Region}-${SubRegion}-${"1" | "2" | "3"}`; | ||
export {}; |
import { IAwsLambdaProxyIntegrationRequestV2, IAwsLambdaProxyIntegrationRequest } from "./aws"; | ||
import { AwsLambdaArn } from "./aws-arn"; | ||
import { AwsRegion } from "./aws-regions"; | ||
/** | ||
@@ -12,1 +13,5 @@ * Distinguishes between a V1 and V2 Proxy Integration Request | ||
export declare function isLambdaArn(arn: string): arn is AwsLambdaArn; | ||
/** | ||
* Type guard to ensure that a given string is a `AwsRegion` | ||
*/ | ||
export declare function isAwsRegion(region: string): region is AwsRegion; |
@@ -23,4 +23,5 @@ /** | ||
AwsRegionName["us-west-2"] = "Oregon"; | ||
// Africa | ||
AwsRegionName["af-south-1"] = "Cape Town"; | ||
// AP | ||
AwsRegionName["af-south-1"] = "Cape Town"; | ||
AwsRegionName["ap-east-1"] = "Hong Kong"; | ||
@@ -33,2 +34,3 @@ AwsRegionName["ap-south-1"] = "Mumbai"; | ||
AwsRegionName["ap-southeast-2"] = "Sydney"; | ||
// Canada | ||
AwsRegionName["ca-central-1"] = "Canada (central)"; | ||
@@ -61,2 +63,8 @@ // EU | ||
} | ||
/** | ||
* Type guard to ensure that a given string is a `AwsRegion` | ||
*/ | ||
function isAwsRegion(region) { | ||
return /^(us|eu|af|ap|me|sa|ca)\-(\w+)\-[0-9]$/.test(region); | ||
} | ||
@@ -505,3 +513,3 @@ /** | ||
export { AWS_REGIONS, AwsRegionName, HttpStatusCodes, LambdaEventParser, StepFunctionMissingDataTreatment, createBindDeploymentConfig, getBodyFromPossibleLambdaProxyRequest, isLambdaArn, isLambdaProxyRequest, isProxyRequestContextV2, isServerlessFunctionHandler, isServerlessFunctionImage, isTypeSubtype, parseStack, wait }; | ||
export { AWS_REGIONS, AwsRegionName, HttpStatusCodes, LambdaEventParser, StepFunctionMissingDataTreatment, createBindDeploymentConfig, getBodyFromPossibleLambdaProxyRequest, isAwsRegion, isLambdaArn, isLambdaProxyRequest, isProxyRequestContextV2, isServerlessFunctionHandler, isServerlessFunctionImage, isTypeSubtype, parseStack, wait }; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "common-types", | ||
"version": "1.21.8", | ||
"version": "1.21.9", | ||
"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
339328
8075