UNPKG

@altostra/core

Version:

Core library for shared types and logic

1 lines 1.09 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.parameterPath=exports.validateParameterPath=exports.isParameterPath=exports.globalEnvironmentVariablesPathRx=exports.PARAM_PATH_SEPARATOR=exports.validPathPrefixes=void 0;const AltoError_1=require("../../common/Errors/AltoError"),common_1=require("../Blueprint/common");function isParameterPath(r){if("string"!=typeof r)return!1;if(exports.globalEnvironmentVariablesPathRx.test(r))return!0;const e=r.indexOf("/"),t=-1===e?r:r.substring(0,e);return exports.validPathPrefixes.has(t)}function validateParameterPath(r){if(!isParameterPath(r))throw AltoError_1.AltoError.create(`Invalid parameter path: [${String(r)}]`)}function parameterPath(r){return validateParameterPath(r),r}exports.validPathPrefixes=new Set(["resources","connections",common_1.globalEnvironmentVariablesKey]),exports.PARAM_PATH_SEPARATOR="/",exports.globalEnvironmentVariablesPathRx=/^globalEnvironmentVariables\/[^/]+$/,exports.isParameterPath=isParameterPath,exports.validateParameterPath=validateParameterPath,exports.parameterPath=parameterPath;