@smj0x/homebridge-shortcuts-buttons
Version:
Run any Apple Shortcut with just the tap of a button, and execute a custom unix command (or another shortcut!) after completion to handle its success/failure, using x-callback-url.
25 lines • 816 B
JavaScript
/**
* @module server
*/
class HSBXCallbackUrlRequestValidator {
condition;
errorCode;
errorMessage;
constructor(condition, errorCode, errorMessage) {
this.condition = condition;
this.errorCode = errorCode;
this.errorMessage = errorMessage;
Object.freeze(this);
}
test() {
try {
return this.condition() === true;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
}
catch (e) {
return false;
}
}
}
export const createRequestValidators = (validatorsDescriptors) => Object.freeze(Object.values(validatorsDescriptors).map(({ condition, errorCode, errorMessage }) => new HSBXCallbackUrlRequestValidator(condition, errorCode, errorMessage)));
//# sourceMappingURL=validators.js.map