@archon-inc/sdk
Version:
Integrate easily to our government platform using this SDK. More info on https://archon.inc/sdk
18 lines (15 loc) • 756 B
text/typescript
import { ResourceIntent, ResourceType } from "../types/policy.js";
/**
* Retrieves the intent with the specified name from the given resource type.
* @param {ResourceType} resourceType - The resource type containing the intents.
* @param {string} intentName - The name of the intent to retrieve.
* @returns {ResourceIntent} The intent with the specified name.
* @throws {Error} If the intent is not found on the resource type.
*/
export default function getIntent(resourceType: ResourceType, intentName: string): ResourceIntent {
const intent = resourceType.intents?.find(i => i.name === intentName);
if (!intent) {
throw new Error(`Intent ${intentName} not found on resource type ${resourceType.name}`);
}
return intent;
}