UNPKG

@cloud-copilot/iam-data

Version:
38 lines 1.61 kB
import { readConditionKeys } from './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 */ export async function iamConditionKeysForService(serviceKey) { const data = await 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 */ export async function iamConditionKeyExists(serviceKey, conditionKey) { const data = await 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 */ export async function iamConditionKeyDetails(serviceKey, conditionKey) { const data = await readConditionKeys(serviceKey.toLowerCase()); if (!data[conditionKey.toLowerCase()]) { throw new Error(`Condition key ${conditionKey} does not exist for service ${serviceKey}`); } return data[conditionKey.toLowerCase()]; } //# sourceMappingURL=conditionKeys.js.map