@archon-inc/sdk
Version:
Integrate easily to our government platform using this SDK. More info on https://archon.inc/sdk
18 lines (17 loc) • 740 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = getIntent;
/**
* 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.
*/
function getIntent(resourceType, intentName) {
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;
}