11/**
2- * sp-pnp-js v1.0.5 - A reusable JavaScript library targeting SharePoint client-side development.
2+ * sp-pnp-js v1.0.6 - A reusable JavaScript library targeting SharePoint client-side development.
33 * MIT (https://github.com/OfficeDev/PnP-JS-Core/blob/master/LICENSE)
44 * Copyright (c) 2016 Microsoft
55 * docs: http://officedev.github.io/PnP-JS-Core
6- * source: https://github.com/OfficeDev /PnP-JS-Core
7- * bugs: https://github.com/OfficeDev /PnP-JS-Core/issues
6+ * source: https://github.com/SharePoint /PnP-JS-Core
7+ * bugs: https://github.com/SharePoint /PnP-JS-Core/issues
88 */
99( function ( f ) { if ( typeof exports === "object" && typeof module !== "undefined" ) { module . exports = f ( ) } else if ( typeof define === "function" && define . amd ) { define ( [ ] , f ) } else { var g ; if ( typeof window !== "undefined" ) { g = window } else if ( typeof global !== "undefined" ) { g = global } else if ( typeof self !== "undefined" ) { g = self } else { g = this } ( g . $pnp || ( g . $pnp = { } ) ) . Provisioning = f ( ) } } ) ( function ( ) { var define , module , exports ; return ( function e ( t , n , r ) { function s ( o , u ) { if ( ! n [ o ] ) { if ( ! t [ o ] ) { var a = typeof require == "function" && require ; if ( ! u && a ) return a ( o , ! 0 ) ; if ( i ) return i ( o , ! 0 ) ; var f = new Error ( "Cannot find module '" + o + "'" ) ; throw f . code = "MODULE_NOT_FOUND" , f } var l = n [ o ] = { exports :{ } } ; t [ o ] [ 0 ] . call ( l . exports , function ( e ) { var n = t [ o ] [ 1 ] [ e ] ; return s ( n ?n :e ) } , l , l . exports , e , t , n , r ) } return n [ o ] . exports } var i = typeof require == "function" && require ; for ( var o = 0 ; o < r . length ; o ++ ) s ( r [ o ] ) ; return s } ) ( { 1 :[ function ( require , module , exports ) {
1010"use strict" ;
@@ -269,7 +269,7 @@ var HttpClient = (function () {
269269 headers . append ( "Content-Type" , "application/json;odata=verbose;charset=utf-8" ) ;
270270 }
271271 if ( ! headers . has ( "X-ClientService-ClientTag" ) ) {
272- headers . append ( "X-ClientService-ClientTag" , "PnPCoreJS:1.0.5 " ) ;
272+ headers . append ( "X-ClientService-ClientTag" , "PnPCoreJS:1.0.6 " ) ;
273273 }
274274 opts = util_1 . Util . extend ( opts , { headers : headers } ) ;
275275 if ( opts . method && opts . method . toUpperCase ( ) !== "GET" ) {
@@ -329,6 +329,16 @@ var HttpClient = (function () {
329329 var opts = util_1 . Util . extend ( options , { method : "POST" } ) ;
330330 return this . fetch ( url , opts ) ;
331331 } ;
332+ HttpClient . prototype . patch = function ( url , options ) {
333+ if ( options === void 0 ) { options = { } ; }
334+ var opts = util_1 . Util . extend ( options , { method : "PATCH" } ) ;
335+ return this . fetch ( url , opts ) ;
336+ } ;
337+ HttpClient . prototype . delete = function ( url , options ) {
338+ if ( options === void 0 ) { options = { } ; }
339+ var opts = util_1 . Util . extend ( options , { method : "DELETE" } ) ;
340+ return this . fetch ( url , opts ) ;
341+ } ;
332342 HttpClient . prototype . getFetchImpl = function ( ) {
333343 if ( pnplibconfig_1 . RuntimeConfig . useSPRequestExecutor ) {
334344 return new sprequestexecutorclient_1 . SPRequestExecutorClient ( ) ;
@@ -1794,21 +1804,23 @@ var ODataParserBase = (function () {
17941804 function ODataParserBase ( ) {
17951805 }
17961806 ODataParserBase . prototype . parse = function ( r ) {
1797- return r . json ( ) . then ( function ( json ) {
1798- var result = json ;
1799- if ( json . hasOwnProperty ( "d" ) ) {
1800- if ( json . d . hasOwnProperty ( "results" ) ) {
1801- result = json . d . results ;
1802- }
1803- else {
1804- result = json . d ;
1805- }
1807+ var _this = this ;
1808+ return r . json ( ) . then ( function ( json ) { return _this . parseODataJSON ( json ) ; } ) ;
1809+ } ;
1810+ ODataParserBase . prototype . parseODataJSON = function ( json ) {
1811+ var result = json ;
1812+ if ( json . hasOwnProperty ( "d" ) ) {
1813+ if ( json . d . hasOwnProperty ( "results" ) ) {
1814+ result = json . d . results ;
18061815 }
1807- else if ( json . hasOwnProperty ( "value" ) ) {
1808- result = json . value ;
1816+ else {
1817+ result = json . d ;
18091818 }
1810- return result ;
1811- } ) ;
1819+ }
1820+ else if ( json . hasOwnProperty ( "value" ) ) {
1821+ result = json . value ;
1822+ }
1823+ return result ;
18121824 } ;
18131825 return ODataParserBase ;
18141826} ( ) ) ;
@@ -1898,11 +1910,12 @@ function ODataEntityArray(factory) {
18981910}
18991911exports . ODataEntityArray = ODataEntityArray ;
19001912var ODataBatch = ( function ( ) {
1901- function ODataBatch ( _batchId ) {
1913+ function ODataBatch ( baseUrl , _batchId ) {
19021914 if ( _batchId === void 0 ) { _batchId = util_1 . Util . getGUID ( ) ; }
1915+ this . baseUrl = baseUrl ;
19031916 this . _batchId = _batchId ;
19041917 this . _requests = [ ] ;
1905- this . _batchDepCount = 0 ;
1918+ this . _batchDependencies = Promise . resolve ( ) ;
19061919 }
19071920 ODataBatch . prototype . add = function ( url , method , options , parser ) {
19081921 var info = {
@@ -1920,27 +1933,22 @@ var ODataBatch = (function () {
19201933 this . _requests . push ( info ) ;
19211934 return p ;
19221935 } ;
1923- ODataBatch . prototype . incrementBatchDep = function ( ) {
1924- this . _batchDepCount ++ ;
1925- } ;
1926- ODataBatch . prototype . decrementBatchDep = function ( ) {
1927- this . _batchDepCount -- ;
1936+ ODataBatch . prototype . addBatchDependency = function ( ) {
1937+ var resolver ;
1938+ var promise = new Promise ( function ( resolve ) {
1939+ resolver = resolve ;
1940+ } ) ;
1941+ this . _batchDependencies = this . _batchDependencies . then ( function ( ) { return promise ; } ) ;
1942+ return resolver ;
19281943 } ;
19291944 ODataBatch . prototype . execute = function ( ) {
19301945 var _this = this ;
1931- return new Promise ( function ( resolve , reject ) {
1932- if ( _this . _batchDepCount > 0 ) {
1933- setTimeout ( function ( ) { return _this . execute ( ) ; } , 100 ) ;
1934- }
1935- else {
1936- _this . executeImpl ( ) . then ( function ( ) { return resolve ( ) ; } ) . catch ( reject ) ;
1937- }
1938- } ) ;
1946+ return this . _batchDependencies . then ( function ( ) { return _this . executeImpl ( ) ; } ) ;
19391947 } ;
19401948 ODataBatch . prototype . executeImpl = function ( ) {
19411949 var _this = this ;
19421950 if ( this . _requests . length < 1 ) {
1943- return new Promise ( function ( r ) { return r ( ) ; } ) ;
1951+ return Promise . resolve ( ) ;
19441952 }
19451953 var batchBody = [ ] ;
19461954 var currentChangeSetId = "" ;
@@ -2006,23 +2014,27 @@ var ODataBatch = (function () {
20062014 "headers" : batchHeaders ,
20072015 } ;
20082016 var client = new httpclient_1 . HttpClient ( ) ;
2009- return client . post ( util_1 . Util . makeUrlAbsolute ( "/_api/$batch" ) , batchOptions )
2017+ var requestUrl = util_1 . Util . makeUrlAbsolute ( util_1 . Util . combinePaths ( this . baseUrl , "/_api/$batch" ) ) ;
2018+ return client . post ( requestUrl , batchOptions )
20102019 . then ( function ( r ) { return r . text ( ) ; } )
20112020 . then ( this . _parseResponse )
20122021 . then ( function ( responses ) {
20132022 if ( responses . length !== _this . _requests . length ) {
20142023 throw new Error ( "Could not properly parse responses to match requests in batch." ) ;
20152024 }
2016- var resolutions = [ ] ;
2017- for ( var i = 0 ; i < responses . length ; i ++ ) {
2025+ var chain = Promise . resolve ( ) ;
2026+ var _loop_1 = function ( i ) {
20182027 var request = _this . _requests [ i ] ;
20192028 var response = responses [ i ] ;
20202029 if ( ! response . ok ) {
20212030 request . reject ( new Error ( response . statusText ) ) ;
20222031 }
2023- resolutions . push ( request . parser . parse ( response ) . then ( request . resolve ) . catch ( request . reject ) ) ;
2032+ chain = chain . then ( function ( _ ) { return request . parser . parse ( response ) . then ( request . resolve ) . catch ( request . reject ) ; } ) ;
2033+ } ;
2034+ for ( var i = 0 ; i < responses . length ; i ++ ) {
2035+ _loop_1 ( i ) ;
20242036 }
2025- return Promise . all ( resolutions ) ;
2037+ return chain ;
20262038 } ) ;
20272039 } ;
20282040 ODataBatch . prototype . _parseResponse = function ( body ) {
0 commit comments