@cloud-copilot/iam-policy
Version:
An ORM for AWS IAM policies
33 lines • 920 B
JavaScript
const ifExistsSlice = 'IfExists'.length * -1;
export class ConditionOperationImpl {
constructor(op) {
this.op = op;
}
setOperator() {
if (!this.op.includes(':')) {
return undefined;
}
const setOp = this.op.split(':').at(0)?.toLowerCase();
if (setOp === 'forallvalues') {
return 'ForAllValues';
}
else if (setOp === 'foranyvalue') {
return 'ForAnyValue';
}
throw new Error(`Unknown set operator: ${setOp}`);
}
isIfExists() {
return this.op.toLowerCase().endsWith('ifexists');
}
baseOperator() {
const base = this.op.split(':').at(-1);
if (base?.toLowerCase().endsWith('ifexists')) {
return base.slice(0, ifExistsSlice);
}
return base;
}
value() {
return this.op;
}
}
//# sourceMappingURL=conditionOperation.js.map