@vertigis/arcgis-rest-client
Advanced tools
Comparing version 18.1.2 to 18.1.3
@@ -16,3 +16,3 @@ { | ||
}, | ||
"version": "18.1.2", | ||
"version": "18.1.3", | ||
"files": [ | ||
@@ -19,0 +19,0 @@ "**/*.js", |
@@ -1,1 +0,1 @@ | ||
import{getToken,getUser}from"../auth/index";import{warn}from"../utils/log";export function getThumbnailUrl(item,principal){const url=getThumbnailUrlWithoutToken(item,principal);if(!url)return;const token=getToken(principal);return token?`${url}?token=${token}`:url}export function getThumbnailUrlWithoutToken(item,principal){if(principal&&item?.id&&item.thumbnail)return`${getPortalContentUrl(principal)}/items/${item.id}/info/${item.thumbnail}`}export function getDocumentUrl(document,principal){if(!document)return;const documentId="string"==typeof document?document:document.id;if(!documentId)return;const portal=principal.self;if(!portal)return;return`https://${getHost(portal)}/home/item.html?id=${documentId}`}export function getItemId(itemIdOrUrl){if(itemIdOrUrl){if(/^[0-9a-fA-F]{32}$/.test(itemIdOrUrl))return itemIdOrUrl;{const match=/\/home\/item\.html\?id=([0-9a-fA-F]{32}$)/i.exec(itemIdOrUrl);if(null!=match&&2===match.length)return match[1];warn(`The value '${itemIdOrUrl}' is not a valid item ID or URL.`)}}}export function getPortalUrl(principal){const url=principal?.credentials?.url;return url?`${url}/sharing/rest`:"https://www.arcgis.com/sharing/rest"}export function getPortalContentUrl(principal){return`${getPortalUrl(principal)}/content`}export function getPortalUserContentUrl(principal,username,folderId){const user=getUser(principal);if(!user)throw new Error("Couldn't resolve user from principal");let url=`${getPortalContentUrl(principal)}/users/${username??user.username}`;return folderId&&(url+=`/${folderId}`),url}export function getPortalUserItemUrl(id,principal,username){return`${getPortalUserContentUrl(principal,username)}/items/${id}`}export function getPortalItemUrl(id,principal){return`${getPortalContentUrl(principal)}/items/${id}`}export function getPortalItemResourcesUrl(id,principal){return`${getPortalContentUrl(principal)}/items/${id}/resources`}export function isCurrentUserOwner(document,principal){const self=principal?.self;return!!document&&(!!self?.user?.username&&self.user.username===document.owner)}export function canUserCreateItems(principal){if(principal?.self){if(!principal.self.user.privileges&&!principal.self.user.orgId)return!0;if(principal.self.user.privileges)return principal.self.user.privileges.some((privilege=>"portal:user:createItem"===privilege))}return!1}export function getHomeUrl(principal){return`${getPortalRootUrl(principal.self)}/home`}export function getFolderUrl(principal,folderId){return`${getHomeUrl(principal)}/content.html?folder=${encodeURIComponent(folderId??principal.self.user.username)}`}export function getSearchUrl(principal,searchTerm,area){return`${getHomeUrl(principal)}/content.html?searchTerm=${searchTerm}${area?`#${area}`:""}`}export function getPortalRootUrl(portal){return`https://${getHost(portal)}`}export function getPortalHostAndPath(portal){return getHost(portal)}function getHost(portal){let host=portal.portalHostname;return!portal.isPortal&&portal.customBaseUrl&&portal.customBaseUrl&&portal.urlKey&&(host=`${portal.urlKey.toLowerCase()}.${portal.customBaseUrl}`),host}export function isArcGISOnlineUrl(url){return new URL(url).hostname.endsWith("arcgis.com")} | ||
import{getToken,getUser}from"../auth/index";import{warn}from"../utils/log";export function getThumbnailUrl(item,principal){const url=getThumbnailUrlWithoutToken(item,principal);if(!url)return;const token=getToken(principal);return token?`${url}?token=${token}`:url}export function getThumbnailUrlWithoutToken(item,principal){if(principal&&item?.id&&item.thumbnail)return`${getPortalContentUrl(principal)}/items/${item.id}/info/${item.thumbnail}`}export function getDocumentUrl(document,principal){if(!document)return;const documentId="string"==typeof document?document:document.id;if(!documentId)return;const portal=principal.self;if(!portal)return;return`https://${getHost(portal)}/home/item.html?id=${documentId}`}export function getItemId(itemIdOrUrl){if(itemIdOrUrl){if(/^[0-9a-fA-F]{32}$/.test(itemIdOrUrl))return itemIdOrUrl;{const match=/\/home\/item\.html\?id=([0-9a-fA-F]{32}$)/i.exec(itemIdOrUrl);if(null!=match&&2===match.length)return match[1];warn(`The value '${itemIdOrUrl}' is not a valid item ID or URL.`)}}}export function getPortalUrl(principal){const url=principal?.credentials?.url;return url?`${url}/sharing/rest`:"https://www.arcgis.com/sharing/rest"}export function getPortalContentUrl(principal){return`${getPortalUrl(principal)}/content`}export function getPortalUserContentUrl(principal,username,folderId){const user=getUser(principal);if(!user)throw new Error("Couldn't resolve user from principal");let url=`${getPortalContentUrl(principal)}/users/${username??user.username}`;return folderId&&(url+=`/${folderId}`),url}export function getPortalUserItemUrl(id,principal,username){return`${getPortalUserContentUrl(principal,username)}/items/${id}`}export function getPortalItemUrl(id,principal){return`${getPortalContentUrl(principal)}/items/${id}`}export function getPortalItemResourcesUrl(id,principal){return`${getPortalContentUrl(principal)}/items/${id}/resources`}export function isCurrentUserOwner(document,principal){const self=principal?.self;return!!document&&(!!self?.user?.username&&self.user.username===document.owner)}export function canUserCreateItems(principal){if(principal?.self){if(!principal.self.user.privileges&&!principal.self.user.orgId)return!0;if(principal.self.user.privileges)return principal.self.user.privileges.some((privilege=>"portal:user:createItem"===privilege))}return!1}export function getHomeUrl(principal){return`${getPortalRootUrl(principal.self)}/home`}export function getFolderUrl(principal,folderId){return`${getHomeUrl(principal)}/content.html?folder=${encodeURIComponent(folderId??principal.self.user.username)}`}export function getSearchUrl(principal,searchTerm,area){return`${getHomeUrl(principal)}/content.html?searchTerm=${searchTerm}${area?`#${area}`:""}`}export function getPortalRootUrl(portal){return`https://${getHost(portal)}`}export function getPortalHostAndPath(portal){return getHost(portal)}function getHost(portal){let host=portal.portalHostname;return!portal.isPortal&&portal.customBaseUrl&&portal.customBaseUrl&&portal.urlKey&&(host=`${portal.urlKey.toLowerCase()}.${portal.customBaseUrl}`),host}export function isArcGISOnlineUrl(url){const hostname=new URL(url).hostname;return hostname.endsWith("arcgis.com")||hostname.endsWith("arcgisonline.com")} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
68915