@cloud-copilot/iam-policy
Version:
An ORM for AWS IAM policies
34 lines • 994 B
JavaScript
import { StatementImpl } from '../statements/statement.js';
export class PolicyImpl {
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 StatementImpl(this.policyObject.Statement, 1, { path: 'Statement' })];
}
return [this.policyObject.Statement].flat().map((statement, index) => {
return new StatementImpl(statement, index + 1, { path: `Statement[${index}]` });
});
}
statementIsArray() {
return Array.isArray(this.policyObject.Statement);
}
toJSON() {
return this.policyObject;
}
metadata() {
return this.theMetadata;
}
}
//# sourceMappingURL=policy.js.map