@altostra/core
Version:
Core library for shared types and logic
1 lines • 1.36 kB
JavaScript
;var __rest=this&&this.__rest||function(e,o){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&o.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)o.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(t[n[r]]=e[n[r]])}return t};Object.defineProperty(exports,"__esModule",{value:!0}),exports.getApiEndpointUtils=void 0;const Errors_1=require("../../../../../common/Errors"),some_1=require("../../../../../common/Iterable/Operators/some"),map_1=require("@reactivex/ix-es2015-cjs/iterable/operators/map"),common_1=require("../common");function getApiEndpointUtils(e,o){return Object.assign(Object.assign({},(0,common_1.getWebApiEndpointUtils)(e,o,"resource.api")),{convertToProxyEndpoint(t,n){if("throw-if-connected"===n&&(0,some_1.some)(o.outgoingConnections))throw Errors_1.AltoError.create("An API endpoint cannot be converted to a proxy if the endpoint has connection",{data:{connections:[...o.outgoingConnections.pipe((0,map_1.map)(e=>e.connection))]}});for(const t of o.outgoingConnections)e.connections.delete(t);return o.mapResource("resource.api.proxy-endpoint",e=>{var{type:o}=e,n=__rest(e,["type"]);return Object.assign(Object.assign({},n),{targetUrl:t})})}})}exports.getApiEndpointUtils=getApiEndpointUtils;