Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ember-arcgis-portal-services

Package Overview
Dependencies
Maintainers
7
Versions
119
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-arcgis-portal-services

A set of promise-based Ember Services for working with the ArcGIS Portal API.

  • 2.2.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10
increased by11.11%
Maintainers
7
Weekly downloads
 
Created
Source

ember-arcgis-portal-services

npm version build status apache licensed

Ember Services for working with ArcGIS Portal/Online. Essentially a wrapper around the functions from arcgis-rest-js for working with items, groups, and users that integrates with torii authentication.

Getting Started

Installation

To consume this library in any ember application:

  • ember install ember-arcgis-portal-services

Dependencies

This project uses ember-fetch, and a few packages from arcgis-rest-js, which will be installed as dependencies.

If you're using torii for oauth management, please also npm install torii-provider-arcgis. More information here.

Otherwise, you can use the portalOpts parameter described below, but you need a service named session in your app or addon. You can generate a dummy service using ember generate service session. TODO: there's probably a better way to do this...

ArcGIS Portal Services

After adding this to your project, you will have a number of services available for injection into your routes/controllers/services.

Shared Methods

All the services expose a set of shared helper properties and methods:

PropertyReturnsDescription
geocodeUrlstringReturn the geocode base url

NOTE: Most public methods take an optional portalOpts parameter. This takes the form:

{
  portalHostname: 'some.portal.com',
  token: 'BZSOMETOKENQJ'
}
// it might also look like this
{
  portalHostname: 'https://some.portal.com',
  token: 'BZSOMETOKENQJ'
}
MethodReturnsDescription
encodeFormstringThis is used internally. Formats an object into a html form. In most cases, not necessary to call this.
request (url, options, portalOpts)promiseThis is used internally. Promisified xhr that does basic handling of Portal's 400-in-a-200 errors
getPortalUrl()stringGet the portal url i.e. https://org.maps.arcgis.com
getPortalRestUrl()stringGet the portal rest url i.e. https://org.maps.arcgis.com/sharing/rest

Items Service

MethodReturnsDescription
search(form)promiseExecutes via /sharing/rest/search. The form is an object properties matching the search params
getById(id, portalOpts)promiseReturns the Item.
getDataById(id, portalOpts)promiseReturns the Item-Data (/data).
update(item, portalOpts)promiseUpdates an existing item. The .owner property must be set.
create(item, portalOpts)promiseCreates an item. The .owner property must be set.
remove(itemId, owner, portalOpts)promiseDelete the item.
protect(itemId, owner, portalOpts)promiseProtect the item (to avoid accidental deletion).
unprotect(itemId, owner, portalOpts)promiseUnprotect the item.
getRelatedItems(itemId, relationshipType, direction, portalOpts)promiseRelated Items
addRelationship (username, itemId, destItemId, relType, portalOpts)promiseAdd a relationship between items
removeRelationship (username, itemId, destItemId, relType, portalOpts)promiseDelete a relationship between items
addImageResourceFromUrl (itemId, owner, filename, url)promiseAdd an image at the specified url to the item as a resource

Groups Service

MethodReturnsDescription
search(form, portalOpts)promiseExecutes via /sharing/rest/community/groups. The form is an object properties matching the search params
getById(id, portalOpts)promiseReturns the Group.
getBulk(ids, portalOpts)promiseReturns an array of Groups.
getItemsById(id, portalOpts)promiseReturns Items in the group. Note: Does not currently support paging.
save(group, portalOpts)promiseCreates or Updates a group.
rename(group, newTitle, portalOpts)promiseRenames an existing group.
update(group, portalOpts)promiseUpdates an existing group.
create(group, portalOpts)promiseCreates an item. The .owner property must be set.
remove(id, portalOpts)promiseDelete the Group.
protect(id, portalOpts)promiseProtect the Group from deletion.
unprotect(id, portalOpts)promiseUnprotect the Group from deletion.
users(id, portalOpts)promiseReturn array of users that are members of the Group. Documentation
addUsers(id, users, portalOpts)promiseAdds users to the Group. Expects an array of usernames.
addAdmins(id, admins, portalOpts)promiseAdds admins to the Group. Expects an array of usernames.
reassign(id, username, portalOpts)promiseReassign ownership of the group
remove(id, portalOpts)promiseDeletes a group from AGO
join(id, portalOpts)promiseRequest for current user to join a group
leave (id, portalOpts)promiseRequest for current user to leave a group
isUserGroupAdmin (id, username, portalOpts)booleanUser's group admin status
getUserMembership (id, username, portalOpts)promiseReturn the type of group membership of a user
updateUserMemberships (id, users, type, portalOpts)promiseUpdates membership(s) from user to admin or admin to user
ensureUniqueGroupName (title, step, portalOpts)promiseReturn a group name guaranteed to be unique in the org
doesGroupExist (title, portalOpts)promiseReturn a boolean indicating whether the group exists in the org
sendGroupMessage (groupId, subject, message, users, notificationChannelType, portalOpts) (deprecated)promiseSends a notification to the group. See: http://mediawikidev.esri.com/index.php/ArcGIS.com/User_Notifications
sendEmailNotification (groupId, subject, message, users = [], portalOpts)promiseSends an email notification to the specified group members
sendBuiltinNotification (groupId, subject, message, users = [], portalOpts)promiseSends a "builtin" notification to the specified group members
sendPushNotificaiton (groupId, data, users = [], portalOpts)promiseSends a push notification to the specified group members

Sharing Service

The sharing service separates setting Access (private/shared/org/everyone) from sharing with a group. This allows the methods to be more deterministic.

MethodReturnsDescription
setAccess(owner, itemId, access, portalOpts)promisewhere access is null
shareWithGroup(owner, itemId, groupId, confirmItemControl, portalOpts)promiseShares an item with a group. confirmItemControl defaults to false. If set to true then itemControl (aka edit permission) is conferred via group membership
unShareWithGroup(owner, itemId, groupId, portalOpts)promiseUn-Share an item with a group.
changeGroupSharing(action, owner, itemId, groupId, portalOpts)promiseActual implementation of the sharing. Action can be 'share' or 'unshare'
isItemSharedWithGroup(itemId, groupId, portalOpts)promiseChecks to see if an item has already been shared with a group

User Service

MethodReturnsDescription
search(form, portalOpts) (deprecated)promiseDelegates to allUsers if user is authenticated or portalOpts is provided, otherwise delegates to searchUsers
searchCommunityUsers(form, portalOpts)promiseExecutes via /sharing/rest/community/users. The form is an object properties matching the search params
searchPortalUsers(form, portalOpts)promiseExecutes via /sharing/rest/portals/self/users. The form is an object properties matching the search params
getByName(username, portalOpts)promiseGet a user object by name.
update(user, portalOpts)promiseUpdate a user
signup (user, portalOpts)promiseSigns the user up to the organization
getNotifications (portalOpts)'promise'Gets the user's "builtin" notifications
removeNotification (id, portalOpts)'promise'Removes the notification
'getInvitations (portalOpts)''promise'Gets the user's invitations
'getInvitationById (id, portalOpts)''promise'Gets the specified invitation for the user
'acceptInvitation (id, portalOpts)''promise'Accepts the invitation
'declineInvitation (id, portalOpts)''promise'Declines the invitation

OAuth Service

Note: This is not used for authentication - rather its purpose is to allow Application Items to be programatically manipulated.

MethodReturnsDescription
registerApp (itemId, redirectUris, appType = 'browser', portalOpts)promiseRegisters an App item. Returning clientId, client secret etc
updateApp(clientId, redirectUris, portalOpts)promiseCurrently just supports changing the set of valid redirect uris. PR's accepted to expand this

Geocode Service

MethodReturnsDescription
findLocationAddress(inputString)promiseReturns a location address based on an input string that moves through a specified or default geocode url

Portal Service

MethodReturnsDescription
getById (id, portalOpts)promiseGet portal info by Id
self (portalOpts)promisePerform a portals/self call
update(portal, portalOpts)promiseUpdate a portal. Lots of rules apply to what can be changed
uploadResource (file)promiseUpload a file as a portal resource
addImageResourceFromUrl (url, filename)promiseUpload a file as a portal resource, from a url
addResource (name, content, portalOpts)promiseAdd a resource to a portal
getResources () promiseGet list of portal resources
removeResource (resourceName, portalOpts)promiseRemove a resource from a porta
users(portalId, start = 1, num = 100, portalOpts)promiseGet a portal users.
configureSocialProviders (opts, portalOpts)promiseConfigure social logins.
checkUsername (username, portalOpts)promiseChecks whether the specified username is available
checkUrlKey (urlKey, portalOpts)promiseChecks whether the specified urlKey is available
activate (opts, portalOpts)promiseActivates the organization
addApprovedApp (itemId, properties, portalOpts)promiseAdds an approved app to the portal. Used to create App Launcher entries
getApprovedApps (portalOpts)promiseGets all approved apps to the portal.
sendMessage (subject, message, users, notificationChannelType, portalOpts) (deprecated)promiseSends a notification to the specified users. See: http://mediawikidev.esri.com/index.php/ArcGIS.com/User_Notifications
sendEmailNotification (subject, message, users = [], portalOpts)promiseSends an email notification to the specified users
sendBuiltinNotification (subject, message, users = [], portalOpts)promiseSends a builtin notification to the specified users
sendPushNotification (data, users = [], portalOpts)promiseSends a push notification to the specified users
setUserDefaultSettings (opts, portalOpts)promisesets default user settings
getUserDefaultSettings (opts, portalOpts)promisegets default user settings
setSigninSettings (opts, portalOpts)promisesets organization signin settings
getSigninSettings (opts, portalOpts)promisegets organization signin settings

Folders Service

MethodReturnsDescription
getUserFolders (username, portalOpts)promiseResolves with an array of folders
folderExists (folderTitle, username, portalOpts)promiseResolves with bool
create (folderTitle, username, portalOpts)promiseCreates a folder
remove (folderId, username, portalOpts)promiseRemoves a folder

Hosted Service

Used to create/manage hosted feature services. Use the feature-service in ember-arcgis-server-services to work with features/records in the service.

MethodReturnsDescription
serviceExists (serviceName, orgId, portalOpts)promiseCheck if a service exists
create (svcParams, username, folderId, portalOpts)promiseCreate a Service + Item
addToDefinition (fsUrl, definition, layerId, portalOpts)promiseAdd/Edit a layer or table to the service
updateDefinition (fsUrl, definition, layerId, portalOpts)promiseUpdate a service/layer's definition
deleteFromDefinition (fsUrl, definition, layerId, portalOpts)promiseDelete from a service/layer's definition

environment.js

Configuration for how to connect to the portal is managed in the torii section. If you are using ArcGIS Online, the portalUrl property is not needed.

// environment.js
...
torii: {
  sessionServiceName: 'session',
  providers: {
    'arcgis-oauth-bearer': {
      apiKey: 'SECRET-KEY-FOR-YOUR-APP',
      portalUrl: 'https://yourawesomeportal.com'
    }
  }
}
...

Running

Running Tests

Note: Currently there are no automated tests for this addon. PR's welcomed :)

  • npm test (Runs ember try:testall to test your addon against multiple Ember versions)
  • ember test
  • ember test --server

Building

For more information on using ember-cli, visit http://ember-cli.com/" target="_blank" class="rg-linkified-code">http://ember-cli.com/.

Resources

Issues

Find a bug or want to request a new feature? Please let us know by submitting an issue.

Contributing

Esri welcomes contributions from anyone and everyone. Please see our guidelines for contributing.

License

Copyright © 2016-2018 Esri

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

A copy of the license is available in the repository's LICENSE file.

Keywords

FAQs

Package last updated on 26 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc