UNPKG

1.87 kBTypeScriptView Raw
1import { IRequestClient } from "@pnp/common";
2import { IQueryableData } from "./queryable.js";
3/**
4 * Defines the context for a given request to be processed in the pipeline
5 */
6export interface IRequestContext<ReturnType> extends IQueryableData<ReturnType> {
7 result?: ReturnType;
8 clientFactory: () => IRequestClient;
9 hasResult: boolean;
10 isBatched: boolean;
11 requestId: string;
12 method: string;
13}
14export declare type PipelineMethod<ReturnType> = (c: IRequestContext<ReturnType>) => Promise<IRequestContext<ReturnType>>;
15/**
16 * Sets the result on the context
17 */
18export declare function setResult<T = any>(context: IRequestContext<T>, value: any): Promise<IRequestContext<T>>;
19/**
20 * Executes the current request context's pipeline
21 *
22 * @param context Current context
23 */
24export declare function pipe<T = any>(context: IRequestContext<T>): Promise<T>;
25/**
26 * decorator factory applied to methods in the pipeline to control behavior
27 */
28export declare function requestPipelineMethod(alwaysRun?: boolean): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
29/**
30 * Contains the methods used within the request pipeline
31 */
32export declare class PipelineMethods {
33 /**
34 * Logs the start of the request
35 */
36 static logStart<T = any>(context: IRequestContext<T>): Promise<IRequestContext<T>>;
37 /**
38 * Handles caching of the request
39 */
40 static caching<T = any>(context: IRequestContext<T>): Promise<IRequestContext<T>>;
41 /**
42 * Sends the request
43 */
44 static send<T = any>(context: IRequestContext<T>): Promise<IRequestContext<T>>;
45 /**
46 * Logs the end of the request
47 */
48 static logEnd<T = any>(context: IRequestContext<T>): Promise<IRequestContext<T>>;
49}
50export declare function getDefaultPipeline(): (typeof PipelineMethods.logStart)[];
51//# sourceMappingURL=pipeline.d.ts.map
\No newline at end of file