common-types
Advanced tools
Comparing version 1.22.0 to 1.22.1
import { IAwsLambdaProxyIntegrationRequestV2, IAwsLambdaProxyIntegrationRequest } from "./aws"; | ||
import { AwsArn, AwsEventBridgeArn, AwsLambdaArn, ArnPartition, ArnResource, ArnService, AwsStepFunctionArn } from "./aws-arn"; | ||
import { AwsArn, AwsEventBridgeArn, AwsLambdaArn, ArnPartition, ArnResource, ArnService, AwsStepFunctionArn, AwsAccountId } from "./aws-arn"; | ||
import { AwsRegion } from "./aws-regions"; | ||
@@ -15,9 +15,9 @@ import { AwsStage } from "./aws-stage"; | ||
/** | ||
* Type guard to ensure that a given string is a `AwsRegion` | ||
* Type guard to ensure that a given value is a `AwsRegion` | ||
*/ | ||
export declare function isAwsRegion(region: string): region is AwsRegion; | ||
export declare function isAwsRegion(region: unknown): region is AwsRegion; | ||
/** | ||
* Type guard to ensure that a given string is a valid `AwsStage` | ||
* Type guard to ensure that a given value is a valid `AwsStage` | ||
*/ | ||
export declare function isAwsStage(stage: string): stage is AwsStage; | ||
export declare function isAwsStage(stage: unknown): stage is AwsStage; | ||
/** | ||
@@ -45,1 +45,6 @@ * Type guard to ensure a ARN string is EventBridge event | ||
export declare function isArnService(service: string): service is ArnService; | ||
/** | ||
* validates that the provided input could be a valid | ||
* `AwsAccountId` | ||
*/ | ||
export declare function isAwsAccountId(accountId: unknown): accountId is AwsAccountId; |
@@ -66,12 +66,13 @@ 'use strict'; | ||
/** | ||
* Type guard to ensure that a given string is a `AwsRegion` | ||
* Type guard to ensure that a given value is a `AwsRegion` | ||
*/ | ||
function isAwsRegion(region) { | ||
return /^(us|eu|af|ap|me|sa|ca)\-(north|south|east|west|central|northeast|southeast)\-[1-3]$/.test(region); | ||
return (typeof region === "string" && | ||
/^(us|eu|af|ap|me|sa|ca)\-(north|south|east|west|central|northeast|southeast)\-[1-3]$/.test(region)); | ||
} | ||
/** | ||
* Type guard to ensure that a given string is a valid `AwsStage` | ||
* Type guard to ensure that a given value is a valid `AwsStage` | ||
*/ | ||
function isAwsStage(stage) { | ||
return /(dev|test|prod|stage)/.test(stage); | ||
return typeof stage === "string" && /(dev|test|prod|stage)/.test(stage); | ||
} | ||
@@ -112,2 +113,9 @@ /** | ||
} | ||
/** | ||
* validates that the provided input could be a valid | ||
* `AwsAccountId` | ||
*/ | ||
function isAwsAccountId(accountId) { | ||
return typeof accountId === "string" && !isNaN(Number(accountId)); | ||
} | ||
@@ -564,2 +572,3 @@ /** | ||
exports.isArnService = isArnService; | ||
exports.isAwsAccountId = isAwsAccountId; | ||
exports.isAwsRegion = isAwsRegion; | ||
@@ -566,0 +575,0 @@ exports.isAwsStage = isAwsStage; |
import { IAwsLambdaProxyIntegrationRequestV2, IAwsLambdaProxyIntegrationRequest } from "./aws"; | ||
import { AwsArn, AwsEventBridgeArn, AwsLambdaArn, ArnPartition, ArnResource, ArnService, AwsStepFunctionArn } from "./aws-arn"; | ||
import { AwsArn, AwsEventBridgeArn, AwsLambdaArn, ArnPartition, ArnResource, ArnService, AwsStepFunctionArn, AwsAccountId } from "./aws-arn"; | ||
import { AwsRegion } from "./aws-regions"; | ||
@@ -15,9 +15,9 @@ import { AwsStage } from "./aws-stage"; | ||
/** | ||
* Type guard to ensure that a given string is a `AwsRegion` | ||
* Type guard to ensure that a given value is a `AwsRegion` | ||
*/ | ||
export declare function isAwsRegion(region: string): region is AwsRegion; | ||
export declare function isAwsRegion(region: unknown): region is AwsRegion; | ||
/** | ||
* Type guard to ensure that a given string is a valid `AwsStage` | ||
* Type guard to ensure that a given value is a valid `AwsStage` | ||
*/ | ||
export declare function isAwsStage(stage: string): stage is AwsStage; | ||
export declare function isAwsStage(stage: unknown): stage is AwsStage; | ||
/** | ||
@@ -45,1 +45,6 @@ * Type guard to ensure a ARN string is EventBridge event | ||
export declare function isArnService(service: string): service is ArnService; | ||
/** | ||
* validates that the provided input could be a valid | ||
* `AwsAccountId` | ||
*/ | ||
export declare function isAwsAccountId(accountId: unknown): accountId is AwsAccountId; |
@@ -62,12 +62,13 @@ /** | ||
/** | ||
* Type guard to ensure that a given string is a `AwsRegion` | ||
* Type guard to ensure that a given value is a `AwsRegion` | ||
*/ | ||
function isAwsRegion(region) { | ||
return /^(us|eu|af|ap|me|sa|ca)\-(north|south|east|west|central|northeast|southeast)\-[1-3]$/.test(region); | ||
return (typeof region === "string" && | ||
/^(us|eu|af|ap|me|sa|ca)\-(north|south|east|west|central|northeast|southeast)\-[1-3]$/.test(region)); | ||
} | ||
/** | ||
* Type guard to ensure that a given string is a valid `AwsStage` | ||
* Type guard to ensure that a given value is a valid `AwsStage` | ||
*/ | ||
function isAwsStage(stage) { | ||
return /(dev|test|prod|stage)/.test(stage); | ||
return typeof stage === "string" && /(dev|test|prod|stage)/.test(stage); | ||
} | ||
@@ -108,2 +109,9 @@ /** | ||
} | ||
/** | ||
* validates that the provided input could be a valid | ||
* `AwsAccountId` | ||
*/ | ||
function isAwsAccountId(accountId) { | ||
return typeof accountId === "string" && !isNaN(Number(accountId)); | ||
} | ||
@@ -552,3 +560,3 @@ /** | ||
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 }; | ||
export { AWS_REGIONS, AwsRegionName, HttpStatusCodes, LambdaEventParser, StepFunctionMissingDataTreatment, createBindDeploymentConfig, getBodyFromPossibleLambdaProxyRequest, isArn, isArnPartition, isArnResource, isArnService, isAwsAccountId, isAwsRegion, isAwsStage, isEventBridgeArn, isLambdaArn, isLambdaProxyRequest, isProxyRequestContextV2, isServerlessFunctionHandler, isServerlessFunctionImage, isStepFunctionArn, isTypeSubtype, parseStack, wait }; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "common-types", | ||
"version": "1.22.0", | ||
"version": "1.22.1", | ||
"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
347725
8275