Skip to content

Helper functions for communicating with SharePoint REST endpoints.

License

Notifications You must be signed in to change notification settings

JoHoN8/pd-spserverajax

Repository files navigation

pdspserverajax

Requires:

  • babel polyfill - object assign and promise
  • axios - the response of the server is in the data property when a plain axios response is returned
  • pd-sputil - encodeAccountName, getURLOrigin

pdspserverajax - is exposed is a global namespace if added to browser via script tag

Author: "Jered McGlohon"

pdspserverajax.getContext(props) ⇒ promise.<object>

Gets a context object for server requests. the key from response is FormDigestValue

Kind: static method of pdspserverajax

Param Type Description
props object
[props.origin] string
props.url string site relative url

pdspserverajax.getData(url) ⇒ promise.<object>

Get data from server using the REST endpoint

Kind: static method of pdspserverajax

Param Type Description
url string full odata url

pdspserverajax.getAllListResults(props) ⇒ promise.<Array.<object>>

Gets all results for server requests. once the promise resolves you get an array of objects that are the servers response

Kind: static method of pdspserverajax

Param Type Description
props object
[props.origin] string
props.url string site relative url
props.listGUID string use either listGUID or listTitle not both
[props.listTitle] string
[props.select] string
[props.filter] string
[props.expand] string
[props.top] string
[props.orderBy] string

pdspserverajax.getBatchMetered(props) ⇒ promise.<Array.<object>>

Gets all items requested in the getUrls property (batch request)

Kind: static method of pdspserverajax

Param Type Description
props object
[props.origin] string
props.url string relative url of the site that contains the data
props.getUrls Array.<string> full odata urls

pdspserverajax.getBatchProfiles(props) ⇒ promise.<Array.<object>>

Get user profiles from the server (batch request)

Kind: static method of pdspserverajax

Param Type Description
props object
[props.origin] string
props.url string site relative url
props.profileEmails Array.<string> email addresses of the users you want profile data for

pdspserverajax.getListInfo(props) ⇒ promise.<object>

Get list or library properties from server

Kind: static method of pdspserverajax

Param Type Description
props object
[props.origin] string
props.url string a site relative url
props.listGUID string use either listGUID or listTitle not both
[props.listTitle] string

pdspserverajax.peopleSearch(props) ⇒ promise.<Array.<object>>

Get user profile info from the SharePoint search service

Kind: static method of pdspserverajax

Param Type Description
props object
[props.origin] string
props.url string site relative url
props.query string query that is passed to search service, ex "'" + 'Bureau="'+ divisionName + '"''
[props.sourceId] string source id for the search service to use, defaults to the out of the box people source id
props.properties Array.<string> specify which properties you want back from the request

pdspserverajax.ensureUser(props) ⇒ promise.<object>

Checks if user is in the site collection user table

Kind: static method of pdspserverajax

Param Type Description
props object
[props.origin] string
props.url string site relative url
props.email string email address of the user to check

pdspserverajax.getSiteUserInfoByEmail(props) ⇒ promise.<object>

Gets user info from the site collection user table

Kind: static method of pdspserverajax

Param Type Description
props object
[props.origin] string
props.url string site relative url
props.email string email address of the user to retrieve

pdspserverajax.getItemsByCaml(props) ⇒ promise.<object>

Get request that uses CAML to filter results

Kind: static method of pdspserverajax

Param Type Description
props object
[props.origin] string
props.url string site relative url
props.query string CAML query
props.listGUID string use either listGUID or listTitle not both
[props.listTitle] string

pdspserverajax.getUserSitePermissions(props) ⇒ promise.<Array.<string>>

Get a users permissions to a site

Kind: static method of pdspserverajax

Param Type Description
props object
[props.origin] string
props.url string site relative url
props.email string email of the user to get permissions for

pdspserverajax.getUserListPermissions(props) ⇒ promise.<Array.<sting>>

Get a users permissions to a list or library

Kind: static method of pdspserverajax

Param Type Description
props object
[props.origin] string
props.url string site relative url
props.listGUID string use either listGUID or listTitle not both
[props.listTitle] string
props.email string email of the user to check permission of

pdspserverajax.getCurrentUserGroups(props) ⇒ promise.<Array.<sting>>

Gets the SharePoint groups that a user has been added to, identify the user by passing the id number of the user for the site.

Kind: static method of pdspserverajax

Param Type Description
props object
[props.origin] string
props.url string site relative url
props.userId number users site id number

pdspserverajax.createItem(props) ⇒ promise.<object>

Creates a single item in a list

Kind: static method of pdspserverajax

Param Type Description
props object
[props.origin] string
props.url string site relative url
props.listGUID string use either listGUID or listTitle not both
[props.listTitle] string
[props.listName] string server name for the list
props.infoToServer object object whos key is the column name and the value is what you want stored in that column

pdspserverajax.updateItem(props) ⇒ promise.<object>

Updates a single item in a list

Kind: static method of pdspserverajax

Param Type Description
props object
[props.origin] string
props.url string site relative url
props.listGUID string use either listGUID or listTitle not both
[props.listTitle] string
[props.listName] string server name for the list
[props.etag] string etag of the item to update
props.itemId number id of the item to update
props.infoToServer object object whos key is the column name and the value is what you want stored in that column

pdspserverajax.deleteItem(props) ⇒ promise.<object>

Deletes a single item from a list or library be warned if you use this function, the item you delete will be gone and unrecoverable!!!!

Kind: static method of pdspserverajax

Param Type Description
props object
[props.origin] string
props.url string site relative url
props.listGUID string use either listGUID or listTitle not both
[props.listTitle] string
[props.etag] string etag of the item to update
props.itemId number id of the item to delete

pdspserverajax.recycleItem(props) ⇒ promise.<object>

Sends a single item to the recycle bin of the site collection

Kind: static method of pdspserverajax

Param Type Description
props object
[props.origin] string
props.url string site relative url
props.listGUID string use either listGUID or listTitle not both
[props.listTitle] string
props.itemId number id of the item to recycle

pdspserverajax.getUserProfileData(props) ⇒ promise.<Array.<object>>

Gets the profile information from the profile service if email is passed then that will be the profile data you get back if email is not passed you get current user profile data back

Kind: static method of pdspserverajax

Param Type Description
props object
[props.origin] string
[props.email] string email of the user you want profile data for

pdspserverajax.getListColumns(props) ⇒ promise.<object>

Get the columns of a list or library

Kind: static method of pdspserverajax

Param Type Description
props object
[props.origin] string
props.url string site relative url
props.listGUID string use either listGUID or listTitle not both
[props.listTitle] string

pdspserverajax.meteredCreateItems(props) ⇒ promise.<Array.<object>>

Creates multiple items via REST, items array should contain object with a key of column name and property of value you want stored in that column ex. { Title: "something" }

Kind: static method of pdspserverajax

Param Type Description
props object
props.items Array.<object> items to create
[props.origin] string
props.url string site relative url
props.listGUID string use either listGUID or listTitle not both
[props.listTitle] string
[props.listName] string server name for the list
[props.itemCreatedCB] itemPreProcessing this call back is called when an item is added to be processed
[props.itemCompletedCB] itemCompletedProcessing this call back is called when item is completed

pdspserverajax.meteredUpdateItems(props) ⇒ promise.<Array.<object>>

Updates multiple items via REST, items array should contain object with 2 properties itemId and updateInfo and 1 optional property etag ex. { itemId: 3, etag: ""3"" updateInfo: { Title: "example string" } }

Kind: static method of pdspserverajax

Param Type Description
props object
props.items Array.<object> items to update
[props.origin] string
props.url string site relative url
props.listGUID string use either listGUID or listTitle not both
[props.listTitle] string
[props.listName] string server name for the list
[props.itemCreatedCB] itemPreProcessing this call back is called when an item is added to be processed
[props.itemCompletedCB] itemCompletedProcessing this call back is called when item is completed

pdspserverajax.meteredRecycleItems(props) ⇒ promise.<Array.<object>>

Recycles multiple items via REST

Kind: static method of pdspserverajax

Param Type Description
props object
props.items Array.<number> ids of items to recycle
[props.origin] string
props.url string site relative url
props.listGUID string use either listGUID or listTitle not both
[props.listTitle] string
[props.itemCreatedCB] itemPreProcessing this call back is called when an item is added to be processed
[props.itemCompletedCB] itemCompletedProcessing this call back is called when item is completed

pdspserverajax~itemCompletedProcessing : function

The processingCompletedCallback will be passed the order number and the process status (success or fail) to trigger any completed side effects The order number is your id to locate elements (dom or whatever) based on the specific item processing

Kind: inner typedef of pdspserverajax

Param Type
status string
index number

pdspserverajax~itemPreProcessing : function

The index and itemData to process will be passed to this function it MUST return a native promise. the order number is your id to locate elements (dom or whatever) based on the specific item processing

Kind: inner typedef of pdspserverajax

Param Type
itemData any
index number

About

Helper functions for communicating with SharePoint REST endpoints.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published