UNPKG

@pnp/odata

Version:

pnp - provides shared odata functionality and base classes

39 lines 1.85 kB
import { ODataParser } from "./parsers.js"; import { getGUID, objectDefinedNotNull } from "@pnp/common"; import { cloneQueryableData } from "./queryable.js"; import { pipe, getDefaultPipeline } from "./pipeline.js"; // first we bind the pipeline we will use for all requests within this closure export function pipelineBinder(pipes) { // then we bind the client factory we'll use (typically done in an implementing library such as sp) return function (clientFactory) { // then we create a binder we can apply for each type of method (GET, POST, etc.) return function (method) { // finally we get a function back to which we can pass an IQueryableData instance and execute the request it defines return function (o) { // send the IQueryableData down the pipeline return pipe(Object.assign({}, { batch: null, batchDependency: null, batchIndex: -1, cachingOptions: null, clientFactory: clientFactory, cloneParentCacheOptions: null, cloneParentWasCaching: false, hasResult: false, isBatched: objectDefinedNotNull(o.batch), method: method, options: null, parentUrl: "", parser: new ODataParser(), pipes: pipes.slice(0), query: new Map(), requestId: getGUID(), url: "", useCaching: /^get$/i.test(o.method) && o.useCaching, }, cloneQueryableData(o))); }; }; }; } export var defaultPipelineBinder = pipelineBinder(getDefaultPipeline()); //# sourceMappingURL=pipeline-binder.js.map