UNPKG

@speckle/shared

Version:

Shared code between various Speckle JS packages

22 lines 1.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ensureAutomateFunctionCreatorFragment = exports.ensureAutomateEnabledFragment = void 0; const result_1 = require("true-myth/result"); const authErrors_js_1 = require("../domain/authErrors.js"); const ensureAutomateEnabledFragment = (loaders) => async () => { const env = await loaders.getEnv(); if (!env.FF_AUTOMATE_MODULE_ENABLED) return (0, result_1.err)(new authErrors_js_1.AutomateNotEnabledError()); return (0, result_1.ok)(); }; exports.ensureAutomateEnabledFragment = ensureAutomateEnabledFragment; const ensureAutomateFunctionCreatorFragment = (loaders) => async ({ userId, functionId }) => { const automateFunction = await loaders.getAutomateFunction({ functionId }); if (!automateFunction) return (0, result_1.err)(new authErrors_js_1.AutomateFunctionNotFoundError()); if (!userId || automateFunction.functionCreator?.speckleUserId !== userId) return (0, result_1.err)(new authErrors_js_1.AutomateFunctionNotCreatorError()); return (0, result_1.ok)(); }; exports.ensureAutomateFunctionCreatorFragment = ensureAutomateFunctionCreatorFragment; //# sourceMappingURL=automate.js.map