> For the complete documentation index, see [llms.txt](https://node.spflow.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://node.spflow.com/packages/sp-screwdriver.md).

# sp-screwdriver

![NPM](https://camo.githubusercontent.com/47f8cc586feffcb73033ed904607151607160381/68747470733a2f2f6e6f6465692e636f2f6e706d2f73702d73637265776472697665722e706e673f6d696e693d7472756526646f776e6c6f6164733d7472756526646f776e6c6f616452616e6b3d747275652673746172733d74727565)

[![npm version](https://camo.githubusercontent.com/5fcb328e2d2b0a8007e545aeb7fca63a97ff7921/68747470733a2f2f62616467652e667572792e696f2f6a732f73702d73637265776472697665722e737667)](https://badge.fury.io/js/sp-screwdriver) [![Downloads](https://camo.githubusercontent.com/101e29744cfa1f0f80caeab2728e24ecacd12eb7/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f646d2f73702d73637265776472697665722e737667)](https://www.npmjs.com/package/sp-screwdriver) [![Gitter chat](https://camo.githubusercontent.com/20d7543bc8280bf8134b686c46c7b7e2c0a467fd/68747470733a2f2f6261646765732e6769747465722e696d2f67697474657248512f6769747465722e706e67)](https://gitter.im/sharepoint-node/Lobby)

![logo](https://github.com/koltyakov/sp-screwdriver/raw/master/doc/img/screwdriver-logo.png?raw=true)

> Adds missing and abstracts SharePoint APIs for transparent usage in Node.js applications

SharePoint REST API is cool, but there are cases, then it's limited or even absent (e.g. MMD is not reachable trough REST API).

This library implements (or at least tries) some vital capabilities by wrapping legacy but still working SOAP services and by hacking HTTP requests mimicing JSOM/CSOM.

### New in version 1.0.0

* Code base is completely migrated to TypeScript.
* node-sp-auth-config is integrated to the library.
* Integration tests are added.

### Supported SharePoint versions

* SharePoint Online
* SharePoint On-Prem (2019, 2016, 2013)

### Usage

#### Install

```
npm install sp-screwdriver
```

#### Minimal setup

```typescript
import { Screwdriver, IScrewdriverSettings } from 'sp-screwdriver';

const settings: IScrewdriverSettings = {
  // ...
};

const screw = new Screwdriver(settings);

// Wizard mode asks for credentials
screw.wizard().then(() => {

  screw.ups.getPropertiesFor({
    accountName: 'i:0#.f|membership|username'
  }).then(result => {
    // ...
  }).catch(console.log);

  screw.mmd.getAllTerms({
    serviceName: 'Taxonomy_5KSgChEZ9j15+7UVInQNRQ==',
    termSetId: '8ed8c9ea-7052-4c1d-a4d7-b9c10bffea6f'
  }).then(result => {
    // ...
  }).catch(console.log);

});
```

alternative:

```typescript
import { Screwdriver } from 'sp-screwdriver';

const screw = new Screwdriver(); // Default settings
screw.init(); // private.json already should be on the disk
              // or raw auth parameters should be provided

screw.ups.getUserPropertyByAccountName({
  accountName: 'i:0#.f|membership|username',
  propertyName: 'SPS-Birthday'
}).then(result => {
  done();
}).catch(done);
```

### APIs

#### User Profiles Service

* getUserProfileByName (SOAP, /\_vti\_bin/UserProfileService.asmx)
* modifyUserPropertyByAccountName (SOAP, /\_vti\_bin/UserProfileService.asmx)
* getUserPropertyByAccountName (SOAP, /\_vti\_bin/UserProfileService.asmx)
* getUserProfilePropertyFor (REST, /\_api/sp.userprofiles.peoplemanager/getpropertiesfor)
* getPropertiesFor (REST, /\_api/sp.userprofiles.peoplemanager/getuserprofilepropertyfor)
* setSingleValueProfileProperty (HTTP, /\_vti\_bin/client.svc/ProcessQuery)
* setMultiValuedProfileProperty (HTTP, /\_vti\_bin/client.svc/ProcessQuery)

#### Manage Metadata Service (Taxonomy)

* getTermSets (SOAP, /\_vti\_bin/TaxonomyClientService.asmx)
* getChildTermsInTermSet (SOAP, /\_vti\_bin/TaxonomyClientService.asmx)
* getChildTermsInTerm (SOAP, /\_vti\_bin/TaxonomyClientService.asmx)
* getTermsByLabel (SOAP, /\_vti\_bin/TaxonomyClientService.asmx)
* getKeywordTermsByGuids (SOAP, /\_vti\_bin/TaxonomyClientService.asmx)
* addTerms (SOAP, /\_vti\_bin/TaxonomyClientService.asmx)
* getAllTerms (HTTP, /\_vti\_bin/client.svc/ProcessQuery)
* setTermName (HTTP, /\_vti\_bin/client.svc/ProcessQuery)
* deprecateTerm (HTTP, /\_vti\_bin/client.svc/ProcessQuery)

#### Versions

**Document versions**

* getVersions (SOAP, /\_vti\_bin/versions.asmx)
* restoreVersion (SOAP, /\_vti\_bin/versions.asmx)
* deleteVersion (SOAP, /\_vti\_bin/versions.asmx)
* deleteAllVersions (SOAP, /\_vti\_bin/versions.asmx)

**Item versions**

* getVersionCollection (SOAP, /\_vti\_bin/lists.asmx)

**Item property bags**

* setItemProperties (HTTP, /\_vti\_bin/client.svc/ProcessQuery)

#### Possible SOAP services to implement

* Alerts (/\_vti\_bin/alerts.asmx)
* Authentication Web service (/\_vti\_bin/Authentication.asmx)
* BDC Web Service (/\_vti\_bin/businessdatacatalog.asmx)
* CMS Content Area Toolbox Info Web service (/\_vti\_bin/contentAreaToolboxService.asmx)
* Copy Web service (/\_vti\_bin/Copy.asmx)
* Document Workspace Web service (/\_vti\_bin/DWS.asmx)
* Excel Services Web service (/\_vti\_bin/ExcelService.asmx)
* Meetings Web service (/\_vti\_bin/Meetings.asmx)
* People Web service (/\_vti\_bin/People.asmx)
* Permissions Web service (/\_vti\_bin/Permissions.asmx)
* Published Links Web service (/\_vti\_bin/publishedlinksservice.asmx)
* Publishing Service Web service (/\_vti\_bin/PublishingService.asmx)
* Search Web service (/\_vti\_bin/search.asmx)
* SharePoint Directory Management Web service (/\_vti\_bin/sharepointemailws.asmx)
* Sites Web service (/\_vti\_bin/sites.asmx)
* Search Crawl Web service (/\_vti\_bin/spscrawl.asmx)
* Users and Groups Web service (/\_vti\_bin/UserGroup.asmx)
* User Profile Change Web service (/\_vti\_bin/userprofilechangeservice.asmx)
* User Profile Web service (/\_vti\_bin/userprofileservice.asmx)
* Views Web service (/\_vti\_bin/Views.asmx)
* Web Part Pages Web service (/\_vti\_bin/webpartpages.asmx)
* Webs Web service (/\_vti\_bin/Webs.asmx)
* Workflow Web service (/\_vti\_bin/workflow\.asmx)
