1 | import { Queryable, IInvokable } from "@pnp/queryable";
|
2 | export type SPInit = string | ISPQueryable | [ISPQueryable, string];
|
3 | export interface ISPConstructor<T extends ISPQueryable = ISPQueryable> {
|
4 | new (base: SPInit, path?: string): T;
|
5 | }
|
6 | export type ISPInvokableFactory<R extends ISPQueryable> = (base: SPInit, path?: string) => R & IInvokable;
|
7 | export declare const spInvokableFactory: <R extends ISPQueryable<any>>(f: any) => ISPInvokableFactory<R>;
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | export declare class _SPQueryable<GetType = any> extends Queryable<GetType> {
|
13 | protected parentUrl: string;
|
14 | |
15 |
|
16 |
|
17 |
|
18 |
|
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 | }
|
45 | export interface ISPQueryable<GetType = any> extends _SPQueryable<GetType> {
|
46 | }
|
47 | export declare const SPQueryable: ISPInvokableFactory<ISPQueryable<any>>;
|
48 |
|
49 |
|
50 |
|
51 |
|
52 | export declare class _SPCollection<GetType = any[]> extends _SPQueryable<GetType> {
|
53 | |
54 |
|
55 |
|
56 |
|
57 |
|
58 | filter<T = UnwrapArray<GetType>>(filter: string | ComparisonResult<T> | ((f: InitialFieldQuery<T>) => ComparisonResult<T>)): 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 | }
|
79 | export interface ISPCollection<GetType = any[]> extends _SPCollection<GetType> {
|
80 | }
|
81 | export declare const SPCollection: ISPInvokableFactory<ISPCollection<any[]>>;
|
82 | /**
|
83 | * Represents an instance that can be selected
|
84 | *
|
85 | */
|
86 | export declare class _SPInstance<GetType = any> extends _SPQueryable<GetType> {
|
87 | }
|
88 | export interface ISPInstance<GetType = any> extends _SPInstance<GetType> {
|
89 | }
|
90 | export declare const SPInstance: ISPInvokableFactory<ISPInstance<any>>;
|
91 | /**
|
92 | * Adds the a delete method to the tagged class taking no parameters and calling spPostDelete
|
93 | */
|
94 | export declare function deleteable(): (this: ISPQueryable) => Promise<void>;
|
95 | export interface IDeleteable {
|
96 | |
97 |
|
98 |
|
99 | delete(): Promise<void>;
|
100 | }
|
101 | export declare function deleteableWithETag(): (this: ISPQueryable, eTag?: string) => Promise<void>;
|
102 | export interface IDeleteableWithETag {
|
103 | |
104 |
|
105 |
|
106 |
|
107 |
|
108 | delete(eTag?: string): Promise<void>;
|
109 | }
|
110 | export declare const spGet: <T = any>(o: ISPQueryable<any>, init?: RequestInit) => Promise<T>;
|
111 | export declare const spPost: <T = any>(o: ISPQueryable<any>, init?: RequestInit) => Promise<T>;
|
112 | export declare const spPostMerge: <T = any>(o: ISPQueryable<any>, init?: RequestInit) => Promise<T>;
|
113 | export declare const spPostDelete: <T = any>(o: ISPQueryable<any>, init?: RequestInit) => Promise<T>;
|
114 | export declare const spPostDeleteETag: <T = any>(o: ISPQueryable<any>, init?: RequestInit, eTag?: string) => Promise<T>;
|
115 | export declare const spDelete: <T = any>(o: ISPQueryable<any>, init?: RequestInit) => Promise<T>;
|
116 | export declare const spPatch: <T = any>(o: ISPQueryable<any>, init?: RequestInit) => Promise<T>;
|
117 | type KeysMatching<T, V> = {
|
118 | [K in keyof T]: T[K] extends V ? K : never;
|
119 | }[keyof T];
|
120 | type KeysMatchingObjects<T> = {
|
121 | [K in keyof T]: T[K] extends object ? (T[K] extends Date ? never : K) : never;
|
122 | }[keyof T];
|
123 | type UnwrapArray<T> = T extends (infer U)[] ? U : T;
|
124 | declare class BaseQuery {
|
125 | protected query: string[];
|
126 | constructor(query: string[]);
|
127 | }
|
128 | declare class QueryableFields<T> extends BaseQuery {
|
129 | constructor(q: string[]);
|
130 | text(internalName: KeysMatching<T, string>): TextField<T>;
|
131 | choice(internalName: KeysMatching<T, string>): TextField<T>;
|
132 | multiChoice(internalName: KeysMatching<T, string[]>): TextField<T>;
|
133 | number(internalName: KeysMatching<T, number>): NumberField<T>;
|
134 | date(internalName: KeysMatching<T, Date>): DateField<T>;
|
135 | boolean(internalName: KeysMatching<T, boolean>): BooleanField<T>;
|
136 | lookup<TKey extends KeysMatchingObjects<T>>(internalName: TKey): LookupQueryableFields<T, T[TKey]>;
|
137 | lookupId<TKey extends KeysMatching<T, number>>(internalName: TKey): NumberField<T>;
|
138 | }
|
139 | declare class QueryableAndResult<T> extends QueryableFields<T> {
|
140 | or(...queries: (ComparisonResult<T> | ((f: QueryableFields<T>) => ComparisonResult<T>))[]): ComparisonResult<T>;
|
141 | }
|
142 | declare class QueryableOrResult<T> extends QueryableFields<T> {
|
143 | and(...queries: (ComparisonResult<T> | ((f: QueryableFields<T>) => ComparisonResult<T>))[]): ComparisonResult<T>;
|
144 | }
|
145 | declare class InitialFieldQuery<T> extends QueryableFields<T> {
|
146 | or(): QueryableFields<T>;
|
147 | or(...queries: (ComparisonResult<T> | ((f: QueryableFields<T>) => ComparisonResult<T>))[]): ComparisonResult<T>;
|
148 | and(): QueryableFields<T>;
|
149 | and(...queries: (ComparisonResult<T> | ((f: QueryableFields<T>) => ComparisonResult<T>))[]): ComparisonResult<T>;
|
150 | }
|
151 | declare class LookupQueryableFields<TBaseInterface, TExpandedType> extends BaseQuery {
|
152 | private LookupField;
|
153 | constructor(q: string[], LookupField: string);
|
154 | Id(id: number): ComparisonResult<TBaseInterface>;
|
155 | text(internalName: KeysMatching<TExpandedType, string>): TextField<TBaseInterface>;
|
156 | number(internalName: KeysMatching<TExpandedType, number>): NumberField<TBaseInterface>;
|
157 | }
|
158 | declare class NullableField<TBaseInterface, TInputValueType> extends BaseQuery {
|
159 | protected LastIndex: number;
|
160 | protected InternalName: string;
|
161 | constructor(q: string[]);
|
162 | protected toODataValue(value: TInputValueType): string;
|
163 | isNull(): ComparisonResult<TBaseInterface>;
|
164 | isNotNull(): ComparisonResult<TBaseInterface>;
|
165 | }
|
166 | declare class ComparableField<T, TInputValueType> extends NullableField<T, TInputValueType> {
|
167 | equals(value: TInputValueType): ComparisonResult<T>;
|
168 | notEquals(value: TInputValueType): ComparisonResult<T>;
|
169 | in(...values: TInputValueType[]): ComparisonResult<T>;
|
170 | notIn(...values: TInputValueType[]): ComparisonResult<T>;
|
171 | }
|
172 | declare class TextField<TBaseInterface> extends ComparableField<TBaseInterface, string> {
|
173 | startsWith(value: string): ComparisonResult<TBaseInterface>;
|
174 | contains(value: string): ComparisonResult<TBaseInterface>;
|
175 | }
|
176 | declare class BooleanField<TBaseInterface> extends NullableField<TBaseInterface, boolean> {
|
177 | protected toODataValue(value: boolean | null): string;
|
178 | isTrue(): ComparisonResult<TBaseInterface>;
|
179 | isFalse(): ComparisonResult<TBaseInterface>;
|
180 | isFalseOrNull(): ComparisonResult<TBaseInterface>;
|
181 | }
|
182 | declare class NumericField<T, TInputValueType> extends ComparableField<T, TInputValueType> {
|
183 | greaterThan(value: TInputValueType): ComparisonResult<T>;
|
184 | greaterThanOrEquals(value: TInputValueType): ComparisonResult<T>;
|
185 | lessThan(value: TInputValueType): ComparisonResult<T>;
|
186 | lessThanOrEquals(value: TInputValueType): ComparisonResult<T>;
|
187 | }
|
188 | declare class NumberField<T> extends NumericField<T, number> {
|
189 | protected toODataValue(value: number): string;
|
190 | }
|
191 | declare class DateField<TBaseInterface> extends NumericField<TBaseInterface, Date> {
|
192 | protected toODataValue(value: Date): string;
|
193 | isBetween(startDate: Date, endDate: Date): ComparisonResult<TBaseInterface>;
|
194 | isToday(): ComparisonResult<TBaseInterface>;
|
195 | }
|
196 | declare class ComparisonResult<T> extends BaseQuery {
|
197 | and(): QueryableAndResult<T>;
|
198 | and(...queries: (ComparisonResult<T> | ((f: QueryableFields<T>) => ComparisonResult<T>))[]): ComparisonResult<T>;
|
199 | or(): QueryableOrResult<T>;
|
200 | or(...queries: (ComparisonResult<T> | ((f: QueryableFields<T>) => ComparisonResult<T>))[]): ComparisonResult<T>;
|
201 | toString(): string;
|
202 | }
|
203 | export {};
|
204 | //# sourceMappingURL=spqueryable.d.ts.map |
\ | No newline at end of file |