UNPKG

@cloud-copilot/iam-policy

Version:
56 lines 1.84 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ResourceImpl = void 0; const utils_js_1 = require("../utils.js"); class ResourceImpl { rawValue; otherProps; constructor(rawValue, otherProps) { this.rawValue = rawValue; this.otherProps = otherProps; } path() { return this.otherProps.path; } partition() { if (!this.isArnResource()) { throw new Error('Called partition on a resource without an ARN, use isArnResource before calling partition'); } return this.value().split(':').at(1); } service() { if (!this.isArnResource()) { throw new Error('Called service on a resource without an ARN, use isArnResource before calling service'); } return this.value().split(':').at(2); } region() { if (!this.isArnResource()) { throw new Error('Called region on a resource without an ARN, use isArnResource before calling region'); } return this.value().split(':').at(3); } account() { if (!this.isArnResource()) { throw new Error('Called account on a resource without an ARN, use isArnResource before calling account'); } return this.value().split(':').at(4); } resource() { if (!this.isArnResource()) { throw new Error('Called resource on a resource without an ARN, use isArnResource before calling resource'); } return this.value().split(':').slice(5).join(':'); } value() { return this.rawValue; } isAllResources() { return (0, utils_js_1.isAllWildcards)(this.rawValue); } isArnResource() { return !this.isAllResources(); } } exports.ResourceImpl = ResourceImpl; //# sourceMappingURL=resource.js.map