@pnp/sp-commonjs
Advanced tools
Comparing version 3.0.0-v3nightly.20220004 to 3.0.0-v3nightly.20220005
import { TimelinePipe } from "@pnp/core-commonjs"; | ||
import { IQueryableInternal } from "@pnp/queryable-commonjs"; | ||
import { ISPQueryable } from "./spqueryable.js"; | ||
declare module "./fi" { | ||
@@ -9,6 +9,23 @@ interface SPFI { | ||
*/ | ||
batched(): [SPFI, () => Promise<void>]; | ||
batched(props?: ISPBatchProps): [SPFI, () => Promise<void>]; | ||
} | ||
} | ||
export declare function createBatch(base: IQueryableInternal): [TimelinePipe, () => Promise<void>]; | ||
declare module "./webs/types" { | ||
interface _Web { | ||
/** | ||
* Creates a batch behavior and associated execute function | ||
* | ||
*/ | ||
batched(props?: ISPBatchProps): [IWeb, () => Promise<void>]; | ||
} | ||
} | ||
interface ISPBatchProps { | ||
/** | ||
* Controls the headers copied from the original request into the batched request, applied to all items | ||
* default: /Accept|Content-Type|IF-Match/i | ||
*/ | ||
headersCopyPattern?: RegExp; | ||
} | ||
export declare function createBatch(base: ISPQueryable, props?: ISPBatchProps): [TimelinePipe, () => Promise<void>]; | ||
export {}; | ||
//# sourceMappingURL=batching.d.ts.map |
@@ -9,8 +9,15 @@ "use strict"; | ||
const fi_js_1 = require("./fi.js"); | ||
fi_js_1.SPFI.prototype.batched = function () { | ||
const batchedRest = new fi_js_1.SPFI(this._root); | ||
const [behavior, execute] = createBatch(batchedRest._root); | ||
batchedRest._root.using(behavior); | ||
return [batchedRest, execute]; | ||
const types_js_1 = require("./webs/types.js"); | ||
fi_js_1.SPFI.prototype.batched = function (props) { | ||
const batched = (0, fi_js_1.spfi)(this); | ||
const [behavior, execute] = createBatch(batched._root, props); | ||
batched.using(behavior); | ||
return [batched, execute]; | ||
}; | ||
types_js_1._Web.prototype.batched = function (props) { | ||
const batched = (0, types_js_1.Web)(this); | ||
const [behavior, execute] = createBatch(batched, props); | ||
batched.using(behavior); | ||
return [batched, execute]; | ||
}; | ||
const RegistrationCompleteSym = Symbol.for("batch_reg_done"); | ||
@@ -34,3 +41,3 @@ const RequestCompleteSym = Symbol.for("batch_req_done"); | ||
} | ||
function createBatch(base) { | ||
function createBatch(base, props) { | ||
const registrationPromises = []; | ||
@@ -41,2 +48,6 @@ const completePromises = []; | ||
const batchQuery = new BatchQueryable(base); | ||
const propsWithDefaults = { | ||
headersCopyPattern: /Accept|Content-Type|IF-Match/i, | ||
...props, | ||
}; | ||
const execute = async () => { | ||
@@ -95,3 +106,3 @@ await Promise.all(registrationPromises); | ||
headers.forEach((value, name) => { | ||
if (/Accept|Content-Type|IF-Match/i.test(name)) { | ||
if (propsWithDefaults.headersCopyPattern.test(name)) { | ||
batchBody.push(`${name}: ${value}\n`); | ||
@@ -98,0 +109,0 @@ } |
{ | ||
"name": "@pnp/sp-commonjs", | ||
"version": "3.0.0-v3nightly.20220004", | ||
"version": "3.0.0-v3nightly.20220005", | ||
"description": "pnp - provides a fluent api for working with SharePoint REST", | ||
@@ -9,4 +9,4 @@ "main": "./presets/all.js", | ||
"tslib": "2.3.1", | ||
"@pnp/core-commonjs": "3.0.0-v3nightly.20220004", | ||
"@pnp/queryable-commonjs": "3.0.0-v3nightly.20220004" | ||
"@pnp/core-commonjs": "3.0.0-v3nightly.20220005", | ||
"@pnp/queryable-commonjs": "3.0.0-v3nightly.20220005" | ||
}, | ||
@@ -13,0 +13,0 @@ "author": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1086747
17509
567
+ Added@pnp/core-commonjs@3.0.0-v3nightly.20220005(transitive)
+ Added@pnp/queryable-commonjs@3.0.0-v3nightly.20220005(transitive)
- Removed@pnp/core-commonjs@3.0.0-v3nightly.20220004(transitive)
- Removed@pnp/queryable-commonjs@3.0.0-v3nightly.20220004(transitive)