@aws-sdk/util-arn-parser
Advanced tools
Comparing version 3.170.0 to 3.183.0
@@ -6,2 +6,10 @@ # Change Log | ||
# [3.183.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.182.0...v3.183.0) (2022-10-03) | ||
**Note:** Version bump only for package @aws-sdk/util-arn-parser | ||
# [3.170.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.169.0...v3.170.0) (2022-09-13) | ||
@@ -8,0 +16,0 @@ |
@@ -1,24 +0,21 @@ | ||
import { __read } from "tslib"; | ||
export var validate = function (str) { | ||
return typeof str === "string" && str.indexOf("arn:") === 0 && str.split(":").length >= 6; | ||
}; | ||
export var parse = function (arn) { | ||
var segments = arn.split(":"); | ||
export const validate = (str) => typeof str === "string" && str.indexOf("arn:") === 0 && str.split(":").length >= 6; | ||
export const parse = (arn) => { | ||
const segments = arn.split(":"); | ||
if (segments.length < 6 || segments[0] !== "arn") | ||
throw new Error("Malformed ARN"); | ||
var _a = __read(segments), partition = _a[1], service = _a[2], region = _a[3], accountId = _a[4], resource = _a.slice(5); | ||
const [, partition, service, region, accountId, ...resource] = segments; | ||
return { | ||
partition: partition, | ||
service: service, | ||
region: region, | ||
accountId: accountId, | ||
partition, | ||
service, | ||
region, | ||
accountId, | ||
resource: resource.join(":"), | ||
}; | ||
}; | ||
export var build = function (arnObject) { | ||
var _a = arnObject.partition, partition = _a === void 0 ? "aws" : _a, service = arnObject.service, region = arnObject.region, accountId = arnObject.accountId, resource = arnObject.resource; | ||
if ([service, region, accountId, resource].some(function (segment) { return typeof segment !== "string"; })) { | ||
export const build = (arnObject) => { | ||
const { partition = "aws", service, region, accountId, resource } = arnObject; | ||
if ([service, region, accountId, resource].some((segment) => typeof segment !== "string")) { | ||
throw new Error("Input ARN object is invalid"); | ||
} | ||
return "arn:".concat(partition, ":").concat(service, ":").concat(region, ":").concat(accountId, ":").concat(resource); | ||
return `arn:${partition}:${service}:${region}:${accountId}:${resource}`; | ||
}; |
@@ -8,5 +8,3 @@ export interface ARN { | ||
} | ||
export declare const validate: (str: any) => boolean; | ||
export declare const parse: (arn: string) => ARN; | ||
@@ -16,4 +14,3 @@ declare type buildOptions = Pick<ARN, Exclude<keyof ARN, "partition">> & { | ||
}; | ||
export declare const build: (arnObject: buildOptions) => string; | ||
export {}; |
{ | ||
"name": "@aws-sdk/util-arn-parser", | ||
"version": "3.170.0", | ||
"version": "3.183.0", | ||
"description": "A parser to Amazon Resource Names", | ||
@@ -5,0 +5,0 @@ "main": "./dist-cjs/index.js", |
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
24388
85