@pnp/odata
- Version 2.15.0
- Published
- 105 kB
- 3 dependencies
- MIT license
Install
npm i @pnp/odata
yarn add @pnp/odata
pnpm add @pnp/odata
Overview
pnp - provides shared odata functionality and base classes
Index
Variables
Functions
Classes
Interfaces
Type Aliases
Variables
variable defaultPipelineBinder
const defaultPipelineBinder: IClientFactoryBinder;
Functions
function addProp
addProp: <T, U>( target: { prototype: any }, name: string, factory: (arg: U, p?: string) => T, path?: string) => void;
Adds a property to a target instance
Parameter target
The object to whose prototype we will add a property
Parameter name
Property name
Parameter factory
Factory method used to produce the property value
Parameter path
Any additional path required to produce the value
function body
body: <T = unknown, U = any>(o: U, previous?: T) => T & { body: string };
function clearGlobalExtensions
clearGlobalExtensions: () => void;
Clears all global extensions
function cloneQueryableData
cloneQueryableData: (source: Partial<IQueryableData>) => Partial<IQueryableData>;
function disableExtensions
disableExtensions: () => void;
Disables all extensions
function enableExtensions
enableExtensions: () => void;
Enables all extensions
function extendFactory
extendFactory: <T extends (...args: any[]) => any>( factory: T, extensions: ExtensionType | ExtensionType[]) => void;
Allows applying extensions to all instances created from the supplied factory
Parameter factory
The Invokable Factory method to extend
Parameter extensions
Extensions to apply
function extendGlobal
extendGlobal: (e: ExtensionType | ExtensionType[]) => void;
Creates global extensions across all invokable objects
Parameter e
The global extensions to apply
function extendObj
extendObj: <T extends object>( target: T, extensions: ExtensionType | ExtensionType[]) => T;
Applies the supplied extensions to a single instance
Parameter target
Object to which extensions are applied
Parameter extensions
Extensions to apply
function getDefaultPipeline
getDefaultPipeline: () => typeof PipelineMethods.logStart[];
function headers
headers: <T = unknown, U extends ITypedHash<string> = {}>( o: U, previous?: T) => T & { headers: U };
function invokableFactory
invokableFactory: <R>( constructor: new (...args: any[]) => any) => (...args: any[]) => R & IInvokable<any>;
function pipe
pipe: <T = any>(context: IRequestContext<T>) => Promise<T>;
Executes the current request context's pipeline
Parameter context
Current context
function pipelineBinder
pipelineBinder: (pipes: PipelineMethod<any>[]) => IClientFactoryBinder;
function requestPipelineMethod
requestPipelineMethod: ( alwaysRun?: boolean) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
decorator factory applied to methods in the pipeline to control behavior
function setResult
setResult: <T = any>( context: IRequestContext<T>, value: any) => Promise<IRequestContext<T>>;
Sets the result on the context
Classes
class Batch
abstract class Batch {}
constructor
constructor(_batchId?: string);
property batchId
readonly batchId: string;
property requests
readonly requests: IODataBatchRequestInfo[];
The requests contained in this batch
method add
add: <T = any>(context: IRequestContext<T>) => Promise<T>;
Adds the given request context to the batch for execution
Parameter context
Details of the request to batch
method addDependency
addDependency: () => () => void;
Adds a dependency insuring that some set of actions will occur before a batch is processed. MUST be cleared using the returned resolve delegate to allow batches to run
method addResolveBatchDependency
addResolveBatchDependency: (p: Promise<any>) => void;
The batch's execute method will not resolve util any promises added here resolve
Parameter p
The dependent promise
method execute
execute: () => Promise<void>;
Execute the current batch and resolve the associated promises
Returns
A promise which will be resolved once all of the batch's child promises have resolved
method executeImpl
protected abstract executeImpl: () => Promise<void>;
method track
track: (batchee: IQueryable<any>) => void;
Not meant for use directly
Parameter batchee
The IQueryable for this batch to track in order
class BlobParser
class BlobParser extends ODataParser<Blob> {}
method parseImpl
protected parseImpl: (r: Response, resolve: (value: any) => void) => void;
class BufferParser
class BufferParser extends ODataParser<ArrayBuffer> {}
method parseImpl
protected parseImpl: (r: Response, resolve: (value: any) => void) => void;
class CachingOptions
class CachingOptions implements ICachingOptions {}
constructor
constructor(key: string, storeName?: 'session' | 'local', expiration?: Date);
property expiration
expiration?: Date;
property key
key: string;
property store
readonly store: IPnPClientStore;
property storeName
storeName?: 'session' | 'local';
class CachingParserWrapper
class CachingParserWrapper<T> implements IODataParser<T> {}
constructor
constructor(parser: IODataParser<T>, cacheOptions: CachingOptions);
property cacheOptions
cacheOptions: CachingOptions;
property parser
parser: IODataParser<T>;
method cacheData
protected cacheData: (data: any) => any;
method parse
parse: (response: Response) => Promise<T>;
class HttpRequestError
class HttpRequestError extends Error {}
constructor
constructor( message: string, response: Response, status?: number, statusText?: string);
property isHttpRequestError
isHttpRequestError: boolean;
property response
response: Response;
property status
status: number;
property statusText
statusText: string;
method init
static init: (r: Response) => Promise<HttpRequestError>;
class JSONParser
class JSONParser extends ODataParser<any> {}
method parseImpl
protected parseImpl: (r: Response, resolve: (value: any) => void) => void;
class LambdaParser
class LambdaParser<T = any> extends ODataParser<T> {}
constructor
constructor(parser: (r: Response) => Promise<T>);
method parseImpl
protected parseImpl: (r: Response, resolve: (value: any) => void) => void;
class ODataParser
class ODataParser<T = any> implements IODataParser<T> {}
method handleError
protected handleError: (r: Response, reject: (err?: Error) => void) => boolean;
Handles a response with ok === false by parsing the body and creating a ProcessHttpClientResponseException which is passed to the reject delegate. This method returns true if there is no error, otherwise false
Parameter r
Current response object
Parameter reject
reject delegate for the surrounding promise
method parse
parse: (r: Response) => Promise<T>;
method parseImpl
protected parseImpl: ( r: Response, resolve: (value?: T | PromiseLike<T>) => void, reject: (reason?: Error) => void) => void;
method parseODataJSON
protected parseODataJSON: <U>(json: any) => U;
Normalizes the json response by removing the various nested levels
Parameter json
json object to parse
class PipelineMethods
class PipelineMethods {}
Contains the methods used within the request pipeline
method caching
static caching: <T = any>( context: IRequestContext<T>) => Promise<IRequestContext<T>>;
Handles caching of the request
method logEnd
static logEnd: <T = any>( context: IRequestContext<T>) => Promise<IRequestContext<T>>;
Logs the end of the request
method logStart
static logStart: <T = any>( context: IRequestContext<T>) => Promise<IRequestContext<T>>;
Logs the start of the request
method send
static send: <T = any>( context: IRequestContext<T>) => Promise<IRequestContext<T>>;
Sends the request
class Queryable
abstract class Queryable<DefaultActionType = any> implements IQueryable<DefaultActionType> {}
constructor
constructor(dataSeed?: Partial<IQueryableData<DefaultActionType>>);
property batch
readonly batch: Batch;
The batch currently associated with this query or null
property data
data: Partial<IQueryableData<DefaultActionType>>;
property hasBatch
readonly hasBatch: boolean;
Indicates if the current query has a batch associated
property parentUrl
readonly parentUrl: string;
Gets the parent url used when creating this instance
property query
readonly query: Map<string, string>;
Provides access to the query builder for this url
method addBatchDependency
addBatchDependency: () => () => void;
Blocks a batch call from occuring, MUST be cleared by calling the returned function
method append
append: (pathPart: string) => void;
Appends the given string and normalizes "/" chars
Parameter pathPart
The string to append
method cloneTo
protected cloneTo: <T extends IQueryable<any>>( target: T, settings?: { includeBatch?: boolean; includeQuery?: boolean }) => T;
Clones this instance's data to target
Parameter target
Instance to which data is written
Parameter settings
[Optional] Settings controlling how clone is applied
method concat
concat: (pathPart: string) => this;
Directly concatenates the supplied string to the current url, not normalizing "/" chars
Parameter pathPart
The string to concatenate to the url
method configure
configure: (options: IConfigOptions) => this;
Sets custom options for current object and all derived objects accessible via chaining
Parameter options
custom options
method configureFrom
configureFrom: (o: IQueryable<any>) => this;
Configures this instance from the configure options of the supplied instance
Parameter o
Instance from which options should be taken
method defaultAction
abstract defaultAction: (options?: IFetchOptions) => Promise<DefaultActionType>;
The default action for this
method getRuntime
getRuntime: () => Runtime;
method inBatch
inBatch: (batch: Batch) => this;
Adds this query to the supplied batch
Example 1
let b = pnp.sp.createBatch();pnp.sp.web.inBatch(b).get().then(...);b.execute().then(...)
method setRuntime
setRuntime: { (runtime: Runtime): this; (cloneGlobal: boolean, additionalConfig?: ITypedHash<any>): this;};
method toUrl
toUrl: () => string;
Gets the current url
method toUrlAndQuery
abstract toUrlAndQuery: () => string;
Gets the full url with query information
method usingCaching
usingCaching: (options?: string | ICachingOptions) => this;
Enables caching for this request
Parameter options
Defines the options used when caching this request
method usingParser
usingParser: (parser: IODataParser<any>) => this;
method withPipeline
withPipeline: (pipeline: PipelineMethod<DefaultActionType>[]) => this;
Allows you to set a request specific processing pipeline
Parameter pipeline
The set of methods, in order, to execute a given request
class TextParser
class TextParser extends ODataParser<string> {}
method parseImpl
protected parseImpl: (r: Response, resolve: (value: any) => void) => void;
Interfaces
interface ICachingOptions
interface ICachingOptions {}
property expiration
expiration?: Date;
property key
key: string;
property storeName
storeName?: 'session' | 'local';
interface IClientFactoryBinder
interface IClientFactoryBinder {}
call signature
(clientFactory: () => IRequestClient): IMethodBinder;
interface IInvokable
interface IInvokable<R = any> {}
call signature
<T = R>(options?: Partial<IRequestContext<T>>): Promise<T>;
interface IMethodBinder
interface IMethodBinder {}
call signature
(method: string): IOperation;
interface IODataBatchRequestInfo
interface IODataBatchRequestInfo {}
interface IODataParser
interface IODataParser<T> {}
interface IOperation
interface IOperation {}
call signature
<ReturnType>(o: Partial<IQueryableData<ReturnType>>): Promise<ReturnType>;
interface IPipelineBinder
interface IPipelineBinder {}
call signature
(pipeline: PipelineMethod<any>[]): IClientFactoryBinder;
interface IQueryable
interface IQueryable<DefaultActionType> {}
property data
data: Partial<IQueryableData<DefaultActionType>>;
property query
query: Map<string, string>;
method addBatchDependency
addBatchDependency: () => () => void;
method append
append: (pathPart: string) => void;
method concat
concat: (pathPart: string) => this;
method configure
configure: (options: IConfigOptions) => this;
method configureFrom
configureFrom: (o: IQueryable<DefaultActionType>) => this;
method defaultAction
defaultAction: (options?: IFetchOptions) => Promise<DefaultActionType>;
method getRuntime
getRuntime: () => Runtime;
method inBatch
inBatch: (batch: Batch) => this;
method setRuntime
setRuntime: { (runtime: Runtime): this; (cloneGlobal: boolean, additionalConfig?: ITypedHash<any>): this;};
method toUrl
toUrl: () => string;
method toUrlAndQuery
toUrlAndQuery: () => string;
method usingCaching
usingCaching: (options?: ICachingOptions) => this;
method usingParser
usingParser: (parser: IODataParser<any>) => this;
method withPipeline
withPipeline: (pipeline: PipelineMethod<DefaultActionType>[]) => this;
interface IQueryable
interface IQueryable<DefaultActionType = any> {}
Returns the instance wrapped by the invokable proxy
interface IQueryableData
interface IQueryableData<DefaultActionType = any> {}
property batch
batch: Batch | null;
property batchDependency
batchDependency: () => void | null;
property batchIndex
batchIndex: number;
property cachingOptions
cachingOptions: ICachingOptions | null;
property clientFactory
clientFactory?: () => IRequestClient;
property cloneParentCacheOptions
cloneParentCacheOptions: ICachingOptions | null;
property cloneParentWasCaching
cloneParentWasCaching: boolean;
property method
method?: string;
property options
options: IFetchOptions | null;
property parentUrl
parentUrl: string;
property parser
parser?: IODataParser<DefaultActionType>;
property pipes
pipes?: PipelineMethod<DefaultActionType>[];
property query
query: Map<string, string>;
property url
url: string;
property useCaching
useCaching: boolean;
interface IRequestContext
interface IRequestContext<ReturnType> extends IQueryableData<ReturnType> {}
Defines the context for a given request to be processed in the pipeline
interface IRequestOptions
interface IRequestOptions<T> extends IFetchOptions {}
property parser
parser: IODataParser<T>;
interface Queryable
interface Queryable<DefaultActionType = any> {}
Type Aliases
type ExtensionType
type ExtensionType<T extends Record<string, unknown> = {}> = | Pick<ProxyHandler<T>, ValidProxyMethods> | ExtensionDelegateType<T> | ITypedHash<any>;
type IHybrid
type IHybrid<R = any, T = any> = T & { (this: T, ...args: any[]): Promise<R>;};
type IInvoker
type IInvoker<R> = (this: IQueryable<any>, ...args: any[]) => Promise<R>;
type PipelineMethod
type PipelineMethod<ReturnType> = ( c: IRequestContext<ReturnType>) => Promise<IRequestContext<ReturnType>>;
Package Files (12)
Dependencies (3)
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@pnp/odata
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@pnp/odata)
- HTML<a href="https://www.jsdocs.io/package/@pnp/odata"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 4280 ms. - Missing or incorrect documentation? Open an issue for this package.