UNPKG

@cloud-copilot/iam-policy

Version:
40 lines 1.19 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PolicyImpl = void 0; const statement_js_1 = require("../statements/statement.js"); class PolicyImpl { policyObject; theMetadata; constructor(policyObject, theMetadata) { this.policyObject = policyObject; this.theMetadata = theMetadata; } version() { return this.policyObject.Version; } id() { return this.policyObject.Id; } statements() { return this.newStatements(); } newStatements() { if (!this.statementIsArray()) { return [new statement_js_1.StatementImpl(this.policyObject.Statement, 1, { path: 'Statement' })]; } return [this.policyObject.Statement].flat().map((statement, index) => { return new statement_js_1.StatementImpl(statement, index + 1, { path: `Statement[${index}]` }); }); } statementIsArray() { return Array.isArray(this.policyObject.Statement); } toJSON() { return this.policyObject; } metadata() { return this.theMetadata; } } exports.PolicyImpl = PolicyImpl; //# sourceMappingURL=policy.js.map