jmapserver-ng-core 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkjmapserver_ng_core=self.webpackChunkjmapserver_ng_core||[]).push([[195],{53195:function(e,t,r){r.r(t),r.d(t,{mapSaasRPO:function(){return u}});var n=r(30926),s=r(98506),a=r(9103),c=r(77860),i=r(73868),o=r(48883),p=r(23240);const u={getMaplibreStyles:function(){var e=this;return new Promise(function(t,r){var u=this;(0,n.Z)(this,e);try{if(!JMap.Project.hasProjectActivated())return r(c.jX);const e=i.n.getId(),l=JMap.User.getOrganizationId(),h=`${(0,p.xv)(o.Hc.MAP_CONFIGURATION)}/rest/v1/organizations/${l}/projects/${e}`;s.x.get({url:`${h}/mapbox-styles?locale=${a.c.getLocale()}`}).then(function(e){return(0,n.Z)(this,u),t(e)}.bind(this))}catch(e){console.error("mapRPO.getMaplibreStyles : unexpected error",e),r("Unexpected error while getting map styles")}}.bind(this))}};t.default=u}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkjmapserver_ng_core=self.webpackChunkjmapserver_ng_core||[]).push([[276],{93276:function(e,r,n){n.r(r);var t=n(30926),s=(n(70560),n(98506)),o=n(95117),i=n(37901),a=n(48883),c=n(23240),h=n(72272),u=n(46848);const l={loginIntoOrganization:function(e,r){var n=this;return new Promise(function(o,i){var h=this;(0,t.Z)(this,n);try{s.x.post({url:`${(0,c.xv)(a.Hc.SECURITY)}/rest/v1/refresh-token`,params:{refreshToken:r,organizationId:e}}).then(function({result:r}){var n=this;(0,t.Z)(this,h);const l=r;s.x.get({url:`${(0,c.xv)(a.Hc.SECURITY)}${(0,u.Wx)(e)}`,accessToken:l.accessToken}).then(function(r){var s=this;(0,t.Z)(this,n),this.getOrganization(e,l.accessToken).then(function(e){return(0,t.Z)(this,s),o(getSessionDataFromLoginResponses(l,r,e))}.bind(this)).catch(function(e){(0,t.Z)(this,s),console.error("Error while fetching user's organization",e),i("user.validation.error.invalid")}.bind(this))}.bind(this)).catch(function(e){return(0,t.Z)(this,n),i(getErrorMessageFromResponse(e))}.bind(this))}.bind(this)).catch(function(e){(0,t.Z)(this,h),console.error("Error while login",e),i(getErrorMessageFromResponse(e))}.bind(this))}catch(e){console.error("Error while login",e),i("user.login.error.unexpected")}}.bind(this))},login:function(e,r,n){var o=this;return new Promise(function(i,l){var g=this;(0,t.Z)(this,o);try{s.x.post({url:`${(0,c.xv)(a.Hc.SECURITY)}/rest/v1/authenticate`,params:{username:e,password:r}}).then(function({result:e}){var r=this;(0,t.Z)(this,g);const o=e;if(n)return i(this.loginIntoOrganization(n,o.refreshToken));s.x.get({url:`${(0,c.xv)(a.Hc.SECURITY)}${(0,u.Wx)(n??"")}`,accessToken:o.accessToken}).then(function(e){if((0,t.Z)(this,r),!Array.isArray(e.result?.organizations)||0===e.result.organizations.length)return(0,u.XG)((0,u.fk)()),l(h.e5);const n=e.result.organizations;if(1===n.length){const e=n[0].id;i(this.loginIntoOrganization(e,o.refreshToken))}else i(getSessionDataFromLoginResponses(o,e,(0,u.NZ)()))}.bind(this)).catch(function(e){return(0,t.Z)(this,r),l(getErrorMessageFromResponse(e))}.bind(this))}.bind(this)).catch(function(e){(0,t.Z)(this,g),console.error("Error while login",e),l(getErrorMessageFromResponse(e))}.bind(this))}catch(e){console.error("Error while login",e),l("user.login.error.unexpected")}}.bind(this))},logout:function(){var e=this;return new Promise(function(r,n){var i=this;(0,t.Z)(this,e);const l=o.h.getState().user.refreshToken;if(l===h.z1)return r((0,u.fk)());try{s.x.post({url:`${(0,c.xv)(a.Hc.SECURITY)}/rest/v1/revoke-token`,params:{refreshToken:l}}).then(function(){return(0,t.Z)(this,i),r((0,u.fk)())}.bind(this)).catch(function(e){(0,t.Z)(this,i),console.error("Error while logout",e),n(getErrorMessageFromResponse(e))}.bind(this))}catch(e){console.error("Error while logout",e),n("user.logout.error.unexpected")}}.bind(this))},validateToken:function(e,r,n){var o=this;return new Promise(async function(i,l){var g=this;(0,t.Z)(this,o);try{const o=await this.refreshToken(e,n);s.x.get({url:`${(0,c.xv)(a.Hc.SECURITY)}${(0,u.Wx)(n)}`,accessToken:o.accessToken}).then(function(e){var s=this;if((0,t.Z)(this,g),!n)return(0,u.XG)((0,u.fk)()),l(h.e5);const a={username:e.result?.email,fullName:e.result?.name,email:e.result?.email,changePasswordAllowed:!0,organizationInfos:e.result.organizations,tokenInfo:o};r?this.getOrganization(n,o.accessToken).then(function(e){return(0,t.Z)(this,s),i({...a,organization:e})}.bind(this)).catch(function(e){(0,t.Z)(this,s),console.error("Error while fetching user's organization",e),l("user.validation.error.invalid")}.bind(this)):i(a)}.bind(this)).catch(function(e){(0,t.Z)(this,g),e&&e.response&&401===e.response.status?l("user.token.invalid"):(console.error("Error while checking token validity",e),l("user.validation.error.invalid"))}.bind(this))}catch(e){console.error("Error while checking token validity",e),l("user.validation.error.unexpected")}}.bind(this))},refreshToken:function(e,r){var n=this;return new Promise(async function(o,i){(0,t.Z)(this,n);try{const{result:n}=await s.x.post({url:`${(0,c.xv)(a.Hc.SECURITY)}/rest/v1/refresh-token`,params:{refreshToken:e,organizationId:r===h.EM?void 0:r}});o({...n,accessTokenExpiration:n.accessTokenExpiration-60>60?n.accessTokenExpiration-60:n.accessTokenExpiration})}catch(e){console.error("Error while refreshing token",e),i("user.refresh.token.error.unexpected")}}.bind(this))},changeFullName:function(e){var r=this;return new Promise(function(n,i){var h=this;(0,t.Z)(this,r),s.x.patch({url:`${(0,c.xv)(a.Hc.SECURITY)}/rest/v1/users/${o.h.getState().user.identity.email}`,params:{name:e}}).then(function(){return(0,t.Z)(this,h),n()}.bind(this)).catch(function(e){(0,t.Z)(this,h),console.error("Error while changing user's full name",e),i(getErrorMessageFromResponse(e))}.bind(this))}.bind(this))},changePassword:function(e,r){var n=this;return new Promise(function(i,h){var u=this;(0,t.Z)(this,n),s.x.patch({url:`${(0,c.xv)(a.Hc.SECURITY)}/rest/v1/users/${o.h.getState().user.identity.email}`,params:{newPassword:e,currentPassword:r}}).then(function(){return(0,t.Z)(this,u),i()}.bind(this)).catch(function(e){(0,t.Z)(this,u),console.error("Error while changing user's password",e),h(getErrorMessageFromResponse(e))}.bind(this))}.bind(this))},getOrganization:async function(e,r){try{const n=(await s.x.get({url:`${(0,c.xv)(a.Hc.SECURITY)}/rest/v1/organizations/${e}`,accessToken:r})).result,o=await async function getOrganizationFromRaw(e,r){var n=this;const o=(await s.x.get({url:`${(0,c.xv)(a.Hc.EXTENSION)}/rest/v1/organizations/${e.id}/extensions`,accessToken:r})).result.map(function(e){return(0,t.Z)(this,n),e.extensionId}.bind(this)),h=[];for(const e of o){const n=(await s.x.get({url:`${(0,c.xv)(a.Hc.EXTENSION)}/rest/v1/extensions/${e}`,accessToken:r})).result;n.enabled&&("string"==typeof n.urn&&n.urn.match(i.d)?h.push({id:n.id,urn:n.urn,jsUrl:n.downloadUrl,name:n.name,version:n.version,data:null}):console.error(`Invalid URN found for extension "${n.name}" (urn="${n.urn}"). The extension will not be loaded. Please contact the publisher (${n.editor})`))}return{active:Boolean(e.active),id:e.id,name:e.name,externalApiKeys:getExternalApiKeysFromRaw(e.externalApiKeys),enabledExtensions:h,auth0Id:e.auth0Id,backgroundColor:e.backgroundColor,primaryColor:e.primaryColor,logoUrl:e.logoUrl}}(n,r);return o}catch(e){throw console.error("Error while getting organization",e),new Error("Error while getting organization")}}};function getExternalApiKeysFromRaw(e){if(!Array.isArray(e))throw new Error("externalApiKeys is not an array");const r=[];for(const n of e)"MAPBOX_ACCESS_TOKEN"===n.type?r.push({apiKey:n.apiKey,id:n.id,title:n.title,type:n.type}):console.warn(`unknown External API key type: "${n.type}", will skip`);return r}function getErrorMessageFromResponse(e){return e&&e.response&&(403===e.response.status||401===e.response.status)?h.WJ:e.message===h.e5?h.e5:h.gl}function getSessionDataFromLoginResponses(e,r,n){return{...e,accessTokenExpiration:e.accessTokenExpiration-60>60?e.accessTokenExpiration-60:h.fV,changePasswordAllowed:!0,user:{fullName:r.result?.name,username:r.result?.email,email:r.result?.email},currentOrganization:n,organizationInfos:r.result?.organizations??[]}}r.default=l}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkjmapserver_ng_core=self.webpackChunkjmapserver_ng_core||[]).push([[283],{84283:function(e,r,s){s.r(r);var n=s(30926),o=s(98506),t=s(9103),i=s(21774),a=s(46848),u=s(72272);const c={loginIntoOrganization:function(e){return Promise.reject("For JMap Cloud only")},login:function(e,r){var s=this;return new Promise(function(t,c){var l=this;(0,n.Z)(this,s);try{o.x.post({url:`${i.H.getRestUrl()}/session`,params:{username:e,password:r,type:"NG"}}).then(function(e){(0,n.Z)(this,l);const r={accessToken:e.result.sessionId,refreshToken:u.z1,accessTokenExpiration:u.fV,changePasswordAllowed:e.result.changePasswordAllowed,user:{fullName:e.result.userFullName,username:e.result.username,email:e.result.userEmailAddress},organizationInfos:[],currentOrganization:(0,a.NZ)()};t(r)}.bind(this)).catch(function(e){(0,n.Z)(this,l);const r=e&&e.response&&403===e.response.status?e.response.data?.message?.includes("no JMap Ng session available")?u.mD:e.response.data?.message?.includes("License expired. Contact your system administrator")?u.K8:u.WJ:u.gl;console.error("Error while login",e),c(r)}.bind(this))}catch(e){console.error("Error while login",e),c("user.login.error.unexpected")}}.bind(this))},logout:function(){var e=this;return new Promise(function(r,s){var t=this;(0,n.Z)(this,e);try{if(!JMap.User.isLoggedIn())return s(u.TC);const e=JMap.User.getToken();o.x.del({url:`${i.H.getRestUrl()}/session?sessionId=${e}`}).then(function(e){(0,n.Z)(this,t),r(e.result)}.bind(this)).catch(function(e){(0,n.Z)(this,t),console.error("Error while logout",e),s("user.logout.error.server")}.bind(this))}catch(e){console.error("Error while logout",e),s("user.logout.error.unexpected")}}.bind(this))},validateToken:function(e,r,s){var t=this;return new Promise(function(r,s){var u=this;(0,n.Z)(this,t);try{o.x.get({url:`${i.H.getRestUrl()}/session?sessionId=${e}`}).then(function(e){(0,n.Z)(this,u);const s={username:e.result.username,fullName:e.result.userFullName,email:e.result.userEmailAddress,changePasswordAllowed:e.result.changePasswordAllowed,organizationInfos:[],organization:(0,a.NZ)()};r(s)}.bind(this)).catch(function(e){(0,n.Z)(this,u),e&&e.response&&401===e.response.status?s("user.token.invalid"):(console.error("Error while checking token validity",e),s("user.validation.error.invalid"))}.bind(this))}catch(e){console.error("Error while checking token validity",e),s("user.validation.error.unexpected")}}.bind(this))},refreshToken:function(e,r){return Promise.reject("Refresh token will never been implemented for legacy server")},changeFullName:function(e){return Promise.reject("For JMap Cloud only.")},changePassword:function(e,r){var s=this;return new Promise(function(a,c){var l=this;(0,n.Z)(this,s);try{if(!JMap.User.isLoggedIn())return c(u.TC);const s=JMap.User.getToken();o.x.put({url:`${i.H.getRestUrl()}/users?sessionId=${s}`,params:{newPassword:e,oldPassword:r}}).then(function(){return(0,n.Z)(this,l),a()}.bind(this)).catch(function(e){(0,n.Z)(this,l),console.error(e.response.data.message),c("Former password param does not match"===e.response.data.message?"user.password.change.error.credential":"user.password.change.error.unexpected")}.bind(this))}catch(e){console.error((0,t.I)("user.password.change.error.unexpected"),e),c("user.password.change.error.unexpected")}}.bind(this))},getOrganization:function(e,r){return Promise.resolve((0,a.NZ)())}};r.default=c}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkjmapserver_ng_core=self.webpackChunkjmapserver_ng_core||[]).push([[531],{62531:function(e,t,r){r.r(t),r.d(t,{mapLegacyRPO:function(){return u}});var n=r(30926),s=r(98506),i=r(21774),c=r(77860),o=r(73868),a=r(3960);const u={getMaplibreStyles:function(){var e=this;return new Promise(function(t,r){var u=this;(0,n.Z)(this,e);try{if(!JMap.Project.hasProjectActivated())return r(c.jX);const e=o.n.getId(),l=a.a.getToken();s.x.get({url:`${i.H.getRestUrl()}/projects/${e}/mvt/styles?styleVersion=V2&sessionId=${l}`}).then(function(e){return(0,n.Z)(this,u),t(e)}.bind(this))}catch(e){console.error("mapRPO.getMaplibreStyles : unexpected error",e),r("Unexpected error while getting map styles")}}.bind(this))}};t.default=u}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkjmapserver_ng_core=self.webpackChunkjmapserver_ng_core||[]).push([[60],{34060:function(e,r,t){t.r(r);var i=t(30926),n=t(98506),o=t(9103),s=t(21774),c=t(61368),a=t(46205),u=t(72272),d=t(3960),l=t(77860),h=t(14681);const m={getProject:function(e){var r=this;return new Promise(function(t,c){var a=this;(0,i.Z)(this,r);try{if(!JMap.User.isLoggedIn())return c(u.TC);const r=JMap.User.getToken();n.x.get({url:`${s.H.getRestUrl()}/projects/${e}?sessionId=${r}&locale=${o.c.getLocale()}`}).then(function(e){(0,i.Z)(this,a),t(checkAndGetProject(e.result))}.bind(this)).catch(function(e){(0,i.Z)(this,a),console.error("Error while getting project description",e),c("project.get.error.server")}.bind(this))}catch(e){console.error("Error while getting project description",e),c("project.get.error.unexpected")}}.bind(this))},getAllProjects:function(){var e=this;return new Promise(function(r,t){var c=this;(0,i.Z)(this,e);try{if(!JMap.User.isLoggedIn())return t(u.TC);const e=JMap.User.getToken();n.x.get({url:`${s.H.getRestUrl()}/projects?sessionId=${e}&locale=${o.c.getLocale()}`}).then(function(e){var t=this;(0,i.Z)(this,c),r(e.result.map(function(e){return(0,i.Z)(this,t),checkAndGetProject(e)}.bind(this)))}.bind(this)).catch(function(e){(0,i.Z)(this,c),console.error("Error while getting all project descriptors",e),t("project.get.all.error.server")}.bind(this))}catch(e){console.error("Error while getting all project description",e),t("project.get.all.error.unexpected")}}.bind(this))},existImageEndpoint:function(e){var r=this;return new Promise(function(t,o){var c=this;if((0,i.Z)(this,r),!JMap.User.isLoggedIn())return o(u.TC);const a=JMap.User.getToken();n.x.get({url:`${s.H.getRestUrl()}/projects/${e}/preview?width=200&height=200&sessionId=${a}`}).then(function(){(0,i.Z)(this,c),t(!0)}.bind(this)).catch(function(e){(0,i.Z)(this,c),console.error(e),t(!1)}.bind(this))}.bind(this))},getProjectBase64Image:function(e,r,t){var n=this;return new Promise(function(o,c){var a=this;(0,i.Z)(this,n);try{if(!JMap.User.isLoggedIn())return c(u.TC);const n=JMap.User.getToken(),l=`${s.H.getRestUrl()}/projects/${e}/preview?format=PNG&width=${r}&height=${t}&sessionId=${n}`,h=new XMLHttpRequest;h.addEventListener("load",function(){var r=this;if((0,i.Z)(this,a),4===h.readyState)if(200===h.status){const e=new FileReader;e.onloadend=function(){(0,i.Z)(this,r),e.result&&"data:"!==e.result?o(e.result):c("Cannot convert image as a base64 string")}.bind(this),e.readAsDataURL(h.response)}else 401===h.status&&d.a.logout(),c(`Error loading project ${e} preview`)}.bind(this)),h.addEventListener("error",function(){(0,i.Z)(this,a),c(`Error loading project ${e} preview (network error)`)}.bind(this)),h.responseType="blob",h.open("GET",l,!0),h.send()}catch(e){console.error(e),c(e)}}.bind(this))}};function checkAndGetProject(e){if(!e)throw console.error("checkAndGetProject : missing data"),Error(l.So);if(e.id<0)throw console.error("checkAndGetProject : missing id"),Error(l.So);if(!e.name)throw console.error("checkAndGetProject : missing name"),Error(l.So);if(!e.projection)throw console.error("checkAndGetProject : missing projection"),Error(l.So);if(void 0===e.maximumScale)throw console.error("checkAndGetProject : missing maximumScale"),Error(l.So);if(void 0===e.minimumScale)throw console.error("checkAndGetProject : missing minimumScale"),Error(l.So);void 0===e.initialRotation&&(e.initialRotation=0),e.backgroundColor||(e.backgroundColor="#ffffff"),e.selectionColor||(e.selectionColor="bisque"),e.apiKey||(e.apiKey={google:null,bing:null,mapBox:null}),e.description||(e.description=""),e.distanceUnit||(e.distanceUnit=c.yn),"boolean"!=typeof e.usageStatisticsActive&&(e.usageStatisticsActive=!1);return{id:e.id,name:e.name,description:"",projection:checkAndGetProjection(e.projection),initialRotation:e.initialRotation,colorSelection:e.selectionColor,colorBackground:e.backgroundColor,initialExtent:checkAndGetBounds(e.initialExtent),minimumVisibleZoom:(0,a.Rt)(e.minimumVisibleMapboxZoom,c.SD),maximumVisibleZoom:(0,a.Rt)(e.maximumVisibleMapboxZoom,c.NS),mapUnit:getMapUnitFrowRaw(e.mapUnit),apiKey:{google:e.apiKey.google,bing:e.apiKey.bing,mapBox:e.apiKey.mapBox},queryGroups:checkAndGetQueryGroups(e),defaultDistanceUnit:e.distanceUnit,base64ImageThumbnail:"",extensions:checkAndGetExtensions(e.extensions),usageStatisticsActive:e.usageStatisticsActive}}function getMapUnitFrowRaw(e){switch(e){case"m":default:return"meters";case"mm":return"millimeters";case"cm":return"centimeters";case"km":return"kilometers";case"in":return"inches";case"ft":return"feet";case"yd":return"yards";case"mi":return"miles";case"nmi":return"nauticalmiles"}}function checkAndGetExtensions(e){var r=this;if(!e)return[];const t=(0,h.M)();return e.map(function(e){return(0,i.Z)(this,r),{id:e.id,urn:e.id,name:e.name,jsUrl:t[e.id]||e.jsUrl,data:e.params||null,version:e.version}}.bind(this))}function checkAndGetQueryGroups(e){var r=this;const t=e.attributeQueryGroups;return Array.isArray(t)?t.filter(function(e){return(0,i.Z)(this,r),"number"==typeof e.id&&"string"==typeof e.name}.bind(this)).map(function(e){return(0,i.Z)(this,r),{id:e.id,name:e.name,queries:[]}}.bind(this)):(console.error("Missing or invalid attributeQueryGroups in project descriptor"),[])}function checkAndGetProjection(e){if(!e)throw console.error("getProjection : missing projectionCode"),Error(l.MF);return{code:e,name:e}}function checkAndGetBounds(e){if(null===e)return null;if(!e)throw console.error("checkAndGetBounds : missing data"),Error(l.PZ);if(!e.x1)throw console.error("checkAndGetBounds : missing x1"),Error(l.PZ);if(!e.x2)throw console.error("checkAndGetBounds : missing x2"),Error(l.PZ);if(!e.y1)throw console.error("checkAndGetBounds : missing y1"),Error(l.PZ);if(!e.y2)throw console.error("checkAndGetBounds : missing y2"),Error(l.PZ);return e}r.default=m},14681:function(e,r,t){function getExtensionOverrides(){const e={};if(window.JMAP_OPTIONS){const r=window.JMAP_OPTIONS.extensionsUrlOverride;if(Array.isArray(r)&&r.length>0)for(const t of r)e[t.extensionUniqueIdentifier]=t.jsUrl}return e}t.d(r,{M:function(){return getExtensionOverrides}})}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkjmapserver_ng_core=self.webpackChunkjmapserver_ng_core||[]).push([[640],{60640:function(e,t,r){r.r(t),r.d(t,{layerSaasRPO:function(){return f}});var i=r(30926),n=(r(70560),r(98506)),o=r(9103),a=r(9841),s=r(61368),l=r(46205),c=r(10084),u=r(77860),m=r(73868),d=r(48883),y=r(23240),h=r(14674),p=r(86720);const f={getLayersConfiguration:function(e){var t=this;return new Promise(function(r,a){var s=this;(0,i.Z)(this,t);try{const t=JMap.User.getOrganizationId();let l,c,u,m=0;const p=2,f=function onRequestEnd(){if((0,i.Z)(this,s),p===++m)return void 0===l||void 0===u||void 0===c?a("Missing allLayers, or rawTree, or allStyleSamples"):void r({metadataSchema:[],layerTree:checkAndGetLayerTree(l,u),styleSamples:c})}.bind(this);n.x.post({url:`${(0,y.xv)(d.Hc.MAP_CONFIGURATION)}/graphql`,params:{query:`{\n getLayers(organizationId: "${t}", projectId: "${e}", locale: "${o.c.getLocale()}") {\n id\n spatialDataSourceId\n name\n type\n elementType\n visible\n listed\n selectable\n includeInMvt\n minimumVisibleMapboxZoom\n maximumVisibleMapboxZoom\n defaultStyleId\n selectionStyleId\n tags\n mouseOverConfiguration {\n text\n preventDuplication\n backgroundColor\n minimumVisibleMapboxZoom\n maximumVisibleMapboxZoom\n }\n attributes {\n id\n name\n type\n title\n }\n }\n\n getStyleSamples(organizationId: "${t}", projectId: "${e}", sampleWidth: 20, sampleHeight: 20) {\n styleId\n base64Image\n }\n\n getStyleRules(organizationId: "${t}", projectId: "${e}", locale: "${o.c.getLocale()}") {\n id\n layerId\n name\n active\n defaultRule\n conditions{\n id\n name\n styleMapScales{\n id\n styleId\n minimumVisibleMapboxZoom\n maximumVisibleMapboxZoom\n }\n }\n }\n }`,variables:{}},headers:{organizationId:t}}).then(function(e){(0,i.Z)(this,s),l=function checkAndGetLayersFromRaw(e){var t=this;const r=e.getLayers,n=e.getStyleRules;if(!r||!Array.isArray(r))throw console.error("checkAndGetLayersFromRaw : missing data: 'getLayers'"),Error(h.Nz);if(!n||!Array.isArray(n))throw console.error("checkAndGetLayersFromRaw : missing data: 'getStyleRules'"),Error(h.Nz);const o=[];for(const e of r){if("object"!=typeof e){console.error("checkAndGetLayerTree : an element is not an object!");continue}const r=n.filter(function(r){return(0,i.Z)(this,t),r.layerId===e.id}.bind(this));o.push(checkAndGetLayer(e,r))}return o}(e.data),c=function checkAndGetStyleSamplesFromRaw(e){const t=e.getStyleSamples;if(!t||!Array.isArray(t))throw console.error("checkAndGetLayersFromRaw : missing data: 'getStyleSamples'"),Error(h.Nz);const r={};for(const e of t)r[e.styleId]=e.base64Image;return r}(e.data),f()}.bind(this)).catch(function(e){return(0,i.Z)(this,s),console.error("Error while getting layers configuration from server",e),a("layers.get.configuration.error.server")}.bind(this)),n.x.get({url:`${(0,y.xv)(d.Hc.MAP_CONFIGURATION)}/rest/v1/organizations/${t}/projects/${e}/layers-groups?locale=${o.c.getLocale()}`}).then(function(e){(0,i.Z)(this,s),u=e.result,f()}.bind(this)).catch(function(e){return(0,i.Z)(this,s),console.error("Error while getting layers from server",e),a("layers.get.layer-groups.error.server")}.bind(this))}catch(e){return console.error("Error while getting layers from server",e),a("layers.get.error.unexpected")}}.bind(this))},searchFeaturesByAttribute:function(e){var t=this;return new Promise(function(r,a){var s=this;(0,i.Z)(this,t);try{const t=JMap.User.getOrganizationId();let l=e.attributeValue;Array.isArray(l)||(l=[l]);const c=(0,p.tS)(e.layerId),u=`${e.attributeName} IN ('${l.join("','")}')`;n.x.get({url:`${(0,y.xv)(d.Hc.MAP_CONFIGURATION)}/rest/v1/organizations/${t}/collections/${c.spatialDataSourceId}/items?filter=filterCQL${encodeURIComponent(u)}&locale=${o.c.getLocale()}`}).then(function(e){if((0,i.Z)(this,s),!e.result||!e.result.features)return console.error("JLayerRepository.filterFeaturesByAttribute : missing result or features"),a("Server response is incorrect : missing result or features");r(e.result.features)}.bind(this)).catch(function(e){(0,i.Z)(this,s),console.error("JLayerRepository.filterFeaturesByAttribute : unexpected error (POST)"),a(e)}.bind(this))}catch(e){console.error("JLayerRepository.filterFeaturesByAttribute : unexpected error"),a(e)}}.bind(this))},getReportUrl:function(e,t){var r=this;return new Promise(async function(e,t){(0,i.Z)(this,r),t("Layer reports not supported in JMap Cloud")}.bind(this))},getExtent:function(e){var t=this;return new Promise(async function(r,a){var s=this;(0,i.Z)(this,t);const l=JMap.User.getOrganizationId();if(!JMap.Project.hasProjectActivated())return a(u.jX);const c=m.n.getId();n.x.get({url:`${(0,y.xv)(d.Hc.MAP_CONFIGURATION)}/rest/v1/organizations/${l}/projects/${c}/layers/${e}/extent?crs=EPSG:4326&locale=${o.c.getLocale()}`}).then(function(e){(0,i.Z)(this,s);const t=e.result;if("object"!=typeof t||"number"!=typeof t.x1||"number"!=typeof t.x2||"number"!=typeof t.y1||"number"!=typeof t.y2||0===t.x1&&0===t.x2&&0===t.y1&&0===t.y2)return console.debug("Invalid extent returned from server",t),r(null);r({sw:{x:t.x1,y:t.y1},ne:{x:t.x2,y:t.y2}})}.bind(this)).catch(function(e){return(0,i.Z)(this,s),console.error("Error while getting layers configuration from server",e),a("layers.get.extent.error.server")}.bind(this))}.bind(this))}};function checkAndGetLayerTree(e,t){var r=this;const n=[],a={};for(const t of e)a[t.id]=t;const s={children:[],description:"",id:h.dX,initialVisibility:!0,isGroup:!0,image:null,name:(0,o.I)(h.Lo),open:!0,path:`/${h.dX}`,visible:!0};let l=t.filter(function(e){return(0,i.Z)(this,r),"GROUP"===e.nodeType}.bind(this)).length;l!==t.length&&l++;const c=l<h.aJ;for(const e of t)"LAYER"===e.nodeType?s.children.push(checkAndGetLayerTreeElement(s.path,a,e,c)):n.push(checkAndGetLayerTreeElement("",a,e,c));return s.children.length>0&&(0===n.length&&(s.name=(0,o.I)(h.l7)),n.push(s)),n}function checkAndGetLayerTreeElement(e,t,r,n){var o=this;if("GROUP"===r.nodeType){let a=""===e;void 0!==n&&(a=a&&n);const s=`${e}/${r.id}`;return{id:r.id,name:r.name,description:r.description||"",initialVisibility:r.visible,visible:r.visible,isGroup:!0,open:a,image:r.iconData||"",path:s,children:r.children.map(function(e){return(0,i.Z)(this,o),checkAndGetLayerTreeElement(s,t,e)}.bind(this))}}{const n=t[r.id];if(!n)throw Error(`Layer tree endpoint returned a layer id="${r.id}" that is not found in the graphQL layers request`);return n.thematics=function getLayerThematicsFromStyleRules(e){var t=this;const r=[];for(const n of e.styleRules){if(n.defaultRule)continue;const e={id:n.id,description:"",title:n.name,name:n.name,dynamicLegend:!1,enabled:n.active,isVisible:n.active,type:"STYLE_RULE",subTitle:"",conditions:n.conditions.map(function(e){var r=this;return(0,i.Z)(this,t),{id:e.id,title:e.name,scaledStyles:e.styleMapScales.map(function(e){return(0,i.Z)(this,r),{minZoom:e.minimumVisibleZoom,maxZoom:e.maximumVisibleZoom,styleId:e.styleId}}.bind(this))}}.bind(this)),hiddenConditionIds:[]};r.push(e)}return r}(n),n.path=`${e}/${n.id}`,n}}function checkAndGetLayer(e,t){var r=this;if(!e)throw console.error("checkAndGetLayer : missing data"),Error(h.PX);if(e.id<0)throw console.error("checkAndGetLayer : missing id"),Error(h.PX);if(!e.name)throw console.error("checkAndGetLayer : missing name"),Error(h.PX);const n=!1,o=function getLayerAttributesFromRaw(e){const t=[];if(!e||!Array.isArray(e))return t;for(const r of e){const e=r.type;let i;i=e===h.MI.BOOLEAN?"boolean":(0,a.SH)(e)?"number":(0,a.cV)(e)?"datetime":e===h.MI.DATE?"date":"string",t.push({id:r.id,name:r.name,label:r.title||r.name||"",type:i})}return t}(e.attributes),[c,u]=function getStyleRulesData(e){var t=this;const r=[];let n;for(const o of e){const e={id:o.id,layerId:o.layerId,name:o.name,active:o.active,defaultRule:o.defaultRule,conditions:o.conditions.map(function(e){return(0,i.Z)(this,t),getStylesRuleCondition(e)}.bind(this))};r.push(e),o.defaultRule&&(n=e)}return[n||r[0],r]}(t);return{id:e.id,name:e.name||"",layerType:e.type,useClientCache:!0,elementType:e.elementType,defaultMetadatas:[],metadataSections:[],description:e.description||"",initialVisibility:Boolean(e.visible),visible:Boolean(e.visible),listedInTree:void 0===e.listed||Boolean(e.listed),path:"",isGroup:!1,attributes:o,lowercasedAttributeNames:o.map(function(e){return(0,i.Z)(this,r),e.name.toLowerCase()}.bind(this)),geometry:{type:(0,p.q9)(e.elementType),editable:!1},mouseOver:getMouseOverFromRawData(e.mouseOverConfiguration),minimumVisibleZoom:(0,l.Rt)(e.minimumVisibleMapboxZoom,s.SD),maximumVisibleZoom:(0,l.Rt)(e.maximumVisibleMapboxZoom,s.NS),defaultStyleRule:c,styleRules:u,thematics:[],extent:null,queries:[],permissions:{ADD:n,DELETE:n,DUPLICATE:n,EDIT_ATTRIBUTE_VALUES:n,EDIT_GEOMETRY:n,EDIT_ONLY_OWN:n},canEditGeometry:n,hasAttributeForm:!1,hasExternalForms:!1,selectable:"boolean"==typeof e.selectable&&e.selectable,authorPropertyName:e.authorColumnName||"",forms:[],hasInformationReport:!1,informationReports:[],spatialDataSourceId:e.spatialDataSourceId,dynamicFilter:{layerId:e.id,isAvailable:!1,isActive:!1,intervalOperatorDisabled:!0,conditions:[]}}}function getStylesRuleCondition(e){const t=e.styleMapScales,r=[];for(const e of t)r.push({id:e.id,minimumVisibleZoom:e.minimumVisibleMapboxZoom,maximumVisibleZoom:e.maximumVisibleMapboxZoom,styleId:e.styleId});return{id:e.id,name:e.name,styleMapScales:r}}function getMouseOverFromRawData(e){e||(e={});return{backgroundColor:"string"!=typeof e.backgroundColor||""===e.backgroundColor?c.f:e.backgroundColor,maximumVisibleZoom:(0,l.Rt)(e.maximumVisibleMapboxZoom,s.NS),minimumVisibleZoom:(0,l.Rt)(e.minimumVisibleMapboxZoom,s.SD),preventTextDuplication:"boolean"==typeof e.preventDuplication&&e.preventDuplication,text:"string"!=typeof e.text?"":e.text}}t.default=f}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkjmapserver_ng_core=self.webpackChunkjmapserver_ng_core||[]).push([[698],{13698:function(e,t,n){n.r(t);var r,i=n(30926),o=(n(70560),n(98506)),c=n(9103),s=n(71195),a=n(21045),u=n(61368),l=n(46205),d=n(48883),g=n(23240),m=n(72272),f=n(46848),h=n(77860),p=n(14681);!function(e){e.METER="METER"}(r||(r={}));const E={getProject:function(e){var t=this;return new Promise(function(n,r){var s=this;(0,i.Z)(this,t);try{const t=JMap.User.getOrganizationId();o.x.get({url:`${(0,g.xv)(d.Hc.MAP_CONFIGURATION)}/rest/v1/organizations/${t}/projects/${e}?locale=${c.c.getLocale()}`}).then(function(e){(0,i.Z)(this,s),n(checkAndGetProject(e.result))}.bind(this)).catch(function(e){(0,i.Z)(this,s),console.error("Error while getting project description",e),r("project.get.error.server")}.bind(this))}catch(e){console.error("Error while getting project description",e),r("project.get.error.unexpected")}}.bind(this))},getAllProjects:async function(){if(!JMap.User.isLoggedIn())throw new Error(m.TC);try{const e=JMap.User.getOrganizationId(),t=[],n=(await o.x.get({url:`${(0,g.xv)(d.Hc.MAP_CONFIGURATION)}/rest/v1/organizations/${e}/projects?locale=${c.c.getLocale()}`})).result;for(const e of n)t.push(await checkAndGetProject(e));return t}catch(e){throw console.error("Error while getting all project description",e),new Error("project.get.all.error.unexpected")}},existImageEndpoint:function(e){var t=this;return new Promise(function(e,n){if((0,i.Z)(this,t),!JMap.User.isLoggedIn())return n(m.TC);e(!1)}.bind(this))},getProjectBase64Image:function(e,t,n){var r=this;return new Promise(function(e,t){(0,i.Z)(this,r),t("Project preview thumbnails are not available on JMap Cloud server")}.bind(this))}};async function checkAndGetProject(e){if(!e)throw console.error("checkAndGetProject : missing data"),Error(h.So);if(!(0,s.w8)(e.id))throw console.error("checkAndGetProject : missing id"),Error(h.So);if(!e.name)throw console.error("checkAndGetProject : missing name"),Error(h.So);if(!e.mapCrs)throw console.error("checkAndGetProject : missing CRS"),Error(h.So);void 0===e.maximumScale&&(e.maximumScale=1),void 0===e.minimumScale&&(e.minimumScale=Number.MAX_VALUE),void 0===e.rotation&&(e.rotation=0),e.backgroundColor||(e.backgroundColor="#ffffff"),e.defaultSelectionColor||(e.defaultSelectionColor="bisque"),e.apiKey||(e.apiKey={google:null,bing:null,mapBox:null}),"string"!=typeof e.description&&(e.description=""),e.distanceUnit||(e.distanceUnit=u.yn),e.initialExtent||(e.initialExtent=null),"boolean"!=typeof e.usageStatisticsActive&&(e.usageStatisticsActive=!1);return{id:e.id,name:e.name,description:e.description,projection:checkAndGetProjection(e.mapCrs),initialRotation:e.rotation,colorSelection:e.defaultSelectionColor,colorBackground:e.backgroundColor,initialExtent:checkAndGetBounds(e.initialExtent),minimumVisibleZoom:(0,l.Rt)(e.minimumVisibleMapboxZoom,u.SD),maximumVisibleZoom:(0,l.Rt)(e.maximumVisibleMapboxZoom,u.NS),mapUnit:getMapUnitFrowRaw(e.mapUnit),apiKey:{google:e.apiKey.google,bing:e.apiKey.bing,mapBox:e.apiKey.mapBox},queryGroups:[],defaultDistanceUnit:checkAndGetDistanceUnit(e.distanceUnit),base64ImageThumbnail:"",extensions:await checkAndGetExtensions(e.id),usageStatisticsActive:e.usageStatisticsActive}}function getMapUnitFrowRaw(e){switch(e){case"METER":default:return"meters";case"MILLIMETER":return"millimeters";case"CENTIMETER":return"centimeters";case"KILOMETER":return"kilometers";case"INCH":return"inches";case"FEET":return"feet";case"YARD":return"yards";case"MILE":return"miles";case"NAUTICAL_MILE":return"nauticalmiles"}}function checkAndGetDistanceUnit(e){return Object.values(r).includes(e)&&e===r.METER||console.error(`Unrecognized raw distance unit "${e}", default to meters`),"meters"}async function checkAndGetExtensions(e){const t=(0,f.BN)().enabledExtensions,n=(0,f.BN)().id,r=[],i=(0,p.M)();for(const c of t)try{const t=(await o.x.get({url:`${(0,g.xv)(d.Hc.EXTENSION)}/rest/v1/configuration/organizations/${n}/extensions/${c.id}/projects/${e}`})).result;t.enabled&&r.push({...c,jsUrl:i[c.urn]??c.jsUrl,data:t.config??null})}catch(e){if(404===e.response.status)continue;console.error("Error while getting project extension config",e)}return r}function checkAndGetProjection(e){if(!e)throw console.error("getProjection : missing projectionCode"),Error(h.MF);return{code:e,name:e}}function checkAndGetBounds(e){if(null===e)return null;const t=a.h.getBboxFromFeature(a.h.getFeatureFromWkt(e));return{x1:t.sw.x,y1:t.sw.y,x2:t.ne.x,y2:t.ne.y}}t.default=E},14681:function(e,t,n){function getExtensionOverrides(){const e={};if(window.JMAP_OPTIONS){const t=window.JMAP_OPTIONS.extensionsUrlOverride;if(Array.isArray(t)&&t.length>0)for(const n of t)e[n.extensionUniqueIdentifier]=n.jsUrl}return e}n.d(t,{M:function(){return getExtensionOverrides}})}}]);