UNPKG

@cloud-copilot/iam-data

Version:
44 lines 1.92 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.iamConditionKeysForService = iamConditionKeysForService; exports.iamConditionKeyExists = iamConditionKeyExists; exports.iamConditionKeyDetails = iamConditionKeyDetails; const data_js_1 = require("./data.js"); /** * Reads the condition keys for a service * * @param serviceKey the service key to read the condition keys for, is case insensitive * @returns the condition keys for the service */ async function iamConditionKeysForService(serviceKey) { const data = await (0, data_js_1.readConditionKeys)(serviceKey.toLowerCase()); return Object.values(data).map((conditionKey) => conditionKey.key); } /** * Check if a condition key exists * * @param serviceKey the service key to check for the condition key, is case insensitive * @param conditionKey the condition key to check for, is case insensitive * @returns true if the condition key exists, false otherwise */ async function iamConditionKeyExists(serviceKey, conditionKey) { const data = await (0, data_js_1.readConditionKeys)(serviceKey.toLowerCase()); return !!data[conditionKey.toLowerCase()]; } /** * Get the details for a condition key * * @param serviceKey the service key to get the condition key for, is case insensitive * @param conditionKey the condition key to get the details for, is case insensitive * @throws error if the service or condition key does not exist * @returns the details for the condition key */ async function iamConditionKeyDetails(serviceKey, conditionKey) { const data = await (0, data_js_1.readConditionKeys)(serviceKey.toLowerCase()); const conditionKeyData = data[conditionKey.toLowerCase()]; if (!conditionKeyData) { throw new Error(`Condition key ${conditionKey} does not exist for service ${serviceKey}`); } return conditionKeyData; } //# sourceMappingURL=conditionKeys.js.map