UNPKG

3.76 kBTypeScriptView Raw
1import { IInvokable, Queryable } from "@pnp/queryable";
2export declare type SPInit = string | ISPQueryable | [ISPQueryable, string];
3export interface ISPConstructor<T extends ISPQueryable = ISPQueryable> {
4 new (base: SPInit, path?: string): T;
5}
6export declare type ISPInvokableFactory<R extends ISPQueryable> = (base: SPInit, path?: string) => R & IInvokable;
7export declare const spInvokableFactory: <R extends ISPQueryable<any>>(f: any) => ISPInvokableFactory<R>;
8/**
9 * SharePointQueryable Base Class
10 *
11 */
12export declare class _SPQueryable<GetType = any> extends Queryable<GetType> {
13 protected parentUrl: string;
14 /**
15 * Creates a new instance of the SharePointQueryable class
16 *
17 * @constructor
18 * @param base A string or SharePointQueryable that should form the base part of the url
19 *
20 */
21 constructor(base: SPInit, path?: string);
22 /**
23 * Gets the full url with query information
24 */
25 toRequestUrl(): string;
26 /**
27 * Choose which fields to return
28 *
29 * @param selects One or more fields to return
30 */
31 select(...selects: string[]): this;
32 /**
33 * Expands fields such as lookups to get additional data
34 *
35 * @param expands The Fields for which to expand the values
36 */
37 expand(...expands: string[]): this;
38 /**
39 * Gets a parent for this instance as specified
40 *
41 * @param factory The contructor for the class to create
42 */
43 protected getParent<T extends ISPQueryable>(factory: ISPInvokableFactory<any>, path?: string, base?: string): T;
44}
45export interface ISPQueryable<GetType = any> extends _SPQueryable<GetType> {
46}
47export declare const SPQueryable: ISPInvokableFactory<ISPQueryable<any>>;
48/**
49 * Represents a REST collection which can be filtered, paged, and selected
50 *
51 */
52export declare class _SPCollection<GetType = any[]> extends _SPQueryable<GetType> {
53 /**
54 * Filters the returned collection (https://msdn.microsoft.com/en-us/library/office/fp142385.aspx#bk_supported)
55 *
56 * @param filter The string representing the filter query
57 */
58 filter(filter: string): this;
59 /**
60 * Orders based on the supplied fields
61 *
62 * @param orderby The name of the field on which to sort
63 * @param ascending If false DESC is appended, otherwise ASC (default)
64 */
65 orderBy(orderBy: string, ascending?: boolean): this;
66 /**
67 * Skips the specified number of items
68 *
69 * @param skip The number of items to skip
70 */
71 skip(skip: number): this;
72 /**
73 * Limits the query to only return the specified number of items
74 *
75 * @param top The query row limit
76 */
77 top(top: number): this;
78}
79export interface ISPCollection<GetType = any[]> extends _SPCollection<GetType> {
80}
81export declare const SPCollection: ISPInvokableFactory<ISPCollection<any[]>>;
82/**
83 * Represents an instance that can be selected
84 *
85 */
86export declare class _SPInstance<GetType = any> extends _SPQueryable<GetType> {
87}
88export interface ISPInstance<GetType = any> extends _SPInstance<GetType> {
89}
90export declare const SPInstance: ISPInvokableFactory<ISPInstance<any>>;
91/**
92 * Adds the a delete method to the tagged class taking no parameters and calling spPostDelete
93 */
94export declare function deleteable(): (this: ISPQueryable) => Promise<void>;
95export interface IDeleteable {
96 /**
97 * Delete this instance
98 */
99 delete(): Promise<void>;
100}
101export declare function deleteableWithETag(): (this: ISPQueryable, eTag?: string) => Promise<void>;
102export interface IDeleteableWithETag {
103 /**
104 * Delete this instance
105 *
106 * @param eTag Value used in the IF-Match header, by default "*"
107 */
108 delete(eTag?: string): Promise<void>;
109}
110//# sourceMappingURL=spqueryable.d.ts.map
\No newline at end of file