The SharePoint Patterns and Practices JavaScript Core Library was created to help developers by simplifying common operations within SharePoint and the SharePoint Framework. This is open source, community driven library with contributions cross different organizations and teams. Currently it contains a fluent API for working with the full SharePoint REST API as well as utility and helper functions. This takes the guess work out of creating REST requests, letting developers focus on the what and less on the how. PnP JS Core library can be used in SharePoint Online or in on-premises. It’s a great library to be used with SharePoint Framework customizations, but it can be also used using classic development models, like with Script Editor Web Part or when you embed JavaScript to SharePoint using User Custom Actions.
The latest release, 2.0.0, of the Patterns and Practices JavaScript Core Library represents an exciting milestone in library evolution and is thanks to all of the great contributions, feedback, and ideas from the community. Thank you all!
Reorganization
If you are a contributor to the library, one of the first things you’ve likely noticed in the dev branch is that we moved things around. We added a debug folder (more on that below) and removed provisioning code. The provisioning code can now be found in a new repository where it can grow and evolve on its own. We also reorganized and simplified the gulp tasks – though all of the expected functionality remains in place.
Debugging
Taking into account feedback and a desire to enhance the development experience we added support for debugging directly in the library. This will help with folks developing new features or fixing bugs as you can directly test, set break points, and step through the internals of the library. The full steps are outlined here.
Wiki Enhancements
Another piece of feedback we heard is a need for better documentation and we have started to enhance the wiki to include deeper details around configuring, using, and extending the library. We have reorganized the menu to help guide you to the information you need to be successful. As always these articles are a work in progress and the community is encouraged to help us create new articles or update existing ones.
Enhancements
- Added a getJSON method to File
- Added support for attachments on list items
- Multipleupdates to UserCustomActions
- Simplified request pipeline
- Added currentUser property to web
- Added custom exceptions
- Added support for use of custom HttpClientImpl instances (docs)
- Gave full control of response handling including errors to parsers (parser docs)
- Exporting additional classes from the library
- Added limited FieldLinks support (as possible with the REST API)
- Added file property to item class
- Added ability to manage features in webs/sites
- Ability to pass ListItemEntityTypeFullName when creating list items (example)
Bug Fixes
- Fix for empty body in SPRequestExecutorClient
- Fix for broken tests
- Fix for empty responses in SPRequestExecutorClient as reported in #256
- Fix for context info when a Site instance is created directly
- Fix for property names in wrong property names in sitegroups and siteusers
- Fixed bug with using a web immediately after it is created using ensure
- Fixed typing errors when using library with SharePoint Framework
This update does represent a breaking change but we’ve tried to minimize the effort required in migration.
Additional resources around PnP JS Core Library
Here are some additional resources around the SharePoint Framework development topics
- PnP-JS-Core GitHub repository
- SharePoint Patterns and Practices JS Core Library Wiki
- SharePoint Patterns and Practices JS Core – Developer Guide
- sp-pnp-js at npmjs.com
- sp-pnp-js API documentation
If you have any questions, comments or feedback around PnP initiative, these tutorials or this blog post, please use the Microsoft Tech Community (SharePoint Developer group) or the issue list in the sp-dev-docs repository.
“Sharing is caring”
Patrick Rodgers, Senior Program Manager, SharePoint, Microsoft – 25th of January 2017