1 | import { InjectHeaders } from "@pnp/queryable";
|
2 | import { _Items, Items } from "./types.js";
|
3 | _Items.prototype.getAll = async function (requestSize = 2000, acceptHeader = "application/json;odata=nometadata") {
|
4 | // this will be used for the actual query
|
5 | // and we set no metadata here to try and reduce traffic
|
6 | const items = Items(this, "").top(requestSize).using(InjectHeaders({
|
7 | "Accept": acceptHeader,
|
8 | }));
|
9 | // let's copy over the odata query params that can be applied
|
10 | // $top - allow setting the page size this way (override what we did above)
|
11 | // $select - allow picking the return fields (good behavior)
|
12 | // $filter - allow setting a filter, though this may fail for large lists
|
13 | this.query.forEach((v, k) => {
|
14 | if (/^\$select|filter|top|expand$/i.test(k)) {
|
15 | items.query.set(k, v);
|
16 | }
|
17 | });
|
18 | // this will eventually hold the items we return
|
19 | const itemsCollector = [];
|
20 | // action that will gather up our results recursively
|
21 | const gatherer = (last) => {
|
22 | // collect that set of results
|
23 | [].push.apply(itemsCollector, last.results);
|
24 | // if we have more, repeat - otherwise resolve with the collected items
|
25 | return last.hasNext ? last.getNext().then(gatherer) : itemsCollector;
|
26 | };
|
27 | return items.getPaged().then(gatherer);
|
28 | };
|
29 | //# sourceMappingURL=get-all.js.map |
\ | No newline at end of file |