ArcGISContext

Class

Abstraction that holds a UserSession, along with getters to streamline access to various platform urls, and common constructs like IRequestOptions, IUserRequestOptions etc.

Instances are intended to be immutable, but this is not directly enforced.

In most circumstances, this class should be created by the ArcGISContextManager class.

Implements

Constructors

Constructor Parameters

Parameter Type Default Notes
opts Required IArcGISContextOptions

Properties

Property Type Notes
id number

Unique id from the ArcGISContextManager that created this instance. Primarily useful for debugging possible race-conditions that can result in multiple ArcGISContextManager instances being created.

Accessors

Accessor Type Notes
communityOrgHostname string

Returns the Hub Community Org Hostname, if defined

communityOrgId string

Return the Hub Community Org Id, if defined

communityOrgUrl string

Returns the Hub Community Org url

currentUser IUser

Returns the current user as IUser

discussionsServiceUrl string

Returns the discussions API URL

domainServiceUrl string

Returns Hub Domain Service URL

environment HubEnvironment

Return the HubEnvironment of the current context

eventsConfig any

Returns the Events configuration object from portal/self

featureFlags IFeatureFlags

Return hash of feature flags passed into constructor. Default is empty object.

helperServices any

Returns the hash of helper services from portal self

history IHubHistory

Return the user's history

hubEnabled boolean

Returns boolean indicating if the current user belongs to an organization that has licensed ArcGIS Hub

hubHomeUrl string

Returns the current user's hub-home url. If not authenticated, returns the Hub Url. If portal, returns undefined

hubLicense HubLicense

Returns the current user's Hub License

hubRequestOptions IHubRequestOptions

Return a IHubRequestOptions object

hubSearchServiceUrl string

Returns the Hub Search API URL

hubUrl string

Returns the Hub url, based on the portalUrl

isAlphaOrg boolean

Is the users org in the alpha orgs list? Alpha orgs are passed in via properties.alphaOrgs

isAuthenticated boolean

Return boolean indicating if authenticatio is present

isBetaOrg boolean

Is the users org in the beta orgs list? Beta orgs are passed in via properties.betaOrgs

isPortal boolean

Returns boolean indicating if the backing system is ArcGIS Enterprise (formerly ArcGIS Portal) or not

ogcApiUrl string

Returns Hub OGCAPI Service URL

orgThumbnailUrl string
portal IPortal

Returns the portal object as IPortal

portalUrl string

Return the portal url i.e. https://www.arcgis.com

properties Record<stringany>

Return the properties hash that was passed in. Useful for app-specific context such as the active Site for ArcGIS Hub

requestOptions IRequestOptions

Return IRequestOptions, which is used by REST-JS functions which may use authentication information if provided.

serviceStatus HubServiceStatus

Returns the current hub service status information

session UserSession

Return the UserSession if authenticated

sharingApiUrl string

Returns the url to the sharing api composed from portalUrl i.e. https://myorg.maps.arcgis.com/sharing/rest

survey123Url string

Return the survey123 url

trustedOrgIds string[]

Returns the array of Trusted Org Ids

trustedOrgs IHubTrustedOrgsResponse[]

Returns the array of Trusted Orgs

userHubSettings IUserHubSettings

Return the user hub settings. Updates must be done via contextManager.updateUserHubSettings

userRequestOptions IUserRequestOptions

Return IUserRequestOptions, which is used for REST-JS functions which require authentication information.

userResourceTokens IUserResourceToken[]

Return the whole array of user resource tokens

Methods

Method Returns Notes
Promise<void>

Add an entry to the user's history

IPermissionAccessResponse

Check specific permission for the current user, and optionally an entity

Promise<void>

Clear the entire history

Promise<void>

Re-fetch the current user, including their groups

Promise<void>

Remove a specific entry from the user's history

string

Return a token for a specific app

Promise<void>

Update the user's hub settings

Possible issue here is that we're not updating the contextManager so the contextManager will be out of sync with this instance of ArcGISContext. Unclear if this will be an actual problem.

addToHistory

Class Method

Add an entry to the user's history

Parameters

Parameter Type Default Notes
entry Required IHubHistoryEntry

Returns

Promise<void>

checkPermission

Class Method

Check specific permission for the current user, and optionally an entity

Parameters

Parameter Type Default Notes
permission Required Permission
entity Optional HubEntity

Returns

clearHistory

Class Method

Clear the entire history

  • clearHistory() : Promise<void>

Returns

Promise<void>

refreshUser

Class Method

Re-fetch the current user, including their groups

  • refreshUser() : Promise<void>

Returns

Promise<void>

removeFromHistory

Class Method

Remove a specific entry from the user's history

Parameters

Parameter Type Default Notes
entry Required IHubHistoryEntry

Returns

Promise<void>

tokenFor

Class Method

Return a token for a specific app

Parameters

Parameter Type Default Notes
app Required UserResourceApp

Returns

string

updateUserHubSettings

Class Method

Update the user's hub settings

Parameters

Parameter Type Default Notes
settings Required IUserHubSettings

Returns

Promise<void>

Possible issue here is that we're not updating the contextManager so the contextManager will be out of sync with this instance of ArcGISContext. Unclear if this will be an actual problem.


Class defined in common/src/ArcGISContext.ts:388