UNPKG

@cloud-copilot/iam-data

Version:
47 lines 1.81 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.iamActionsForService = iamActionsForService; exports.iamActionExists = iamActionExists; exports.iamActionDetails = iamActionDetails; const data_js_1 = require("./data.js"); /** * Get all actions for a service * * @param serviceKey the service key to get actions for, is case insensitive * @returns the actions for the service */ async function iamActionsForService(serviceKey) { const data = await (0, data_js_1.readActionData)(serviceKey.toLowerCase()); return Object.values(data).map((action) => action.name); } /** * Check if an action exists * * @param serviceKey the service key to check for the action, is case insensitive * @param actionKey the action key to check for, is case insensitive * @returns true if the action exists, false otherwise */ async function iamActionExists(serviceKey, actionKey) { const data = await (0, data_js_1.readActionData)(serviceKey.toLowerCase()); return !!data[actionKey.toLowerCase()]; } /** * Get the details for an action * * @param serviceKey the service key to get the action for, is case insensitive * @param actionKey the action key to get the details for, is case insensitive * @throws error if the service or action does not exist * @returns the details for the action */ async function iamActionDetails(serviceKey, actionKey) { const data = await (0, data_js_1.readActionData)(serviceKey.toLowerCase()); if (!data[actionKey.toLowerCase()]) { throw new Error(`Action ${actionKey} does not exist for service ${serviceKey}`); } const actionData = data[actionKey.toLowerCase()]; return { ...actionData, isWildcardOnly: actionData.resourceTypes.length === 0 }; } //# sourceMappingURL=actions.js.map