forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
camljs.d.ts
378 lines (376 loc) · 22.2 KB
/
camljs.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
// Type definitions for camljs
// Project: http://camljs.codeplex.com
// Definitions by: Andrey Markeev <http://markeev.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare class CamlBuilder {
constructor();
/** Generate CAML Query, starting from <Where> tag */
public Where(): CamlBuilder.IFieldExpression;
/** Generate <View> tag for SP.CamlQuery
@param viewFields If omitted, default view fields are requested; otherwise, only values for the fields with the specified internal names are returned.
Specifying view fields is a good practice, as it decreases traffic between server and client. */
public View(viewFields?: string[]): CamlBuilder.IView;
/** Generate <ViewFields> tag for SPServices */
public ViewFields(viewFields: string[]): CamlBuilder.IFinalizableToString;
/** Use for:
1. SPServices CAMLQuery attribute
2. Creating partial expressions
3. In conjunction with Any & All clauses
*/
static Expression(): CamlBuilder.IFieldExpression;
}
declare namespace CamlBuilder {
interface IView extends IJoinable, IFinalizable {
Query(): IQuery;
RowLimit(limit: number, paged?: boolean): IView;
Scope(scope: ViewScope): IView;
}
interface IJoinable {
/** Join the list you're querying with another list.
Joins are only allowed through a lookup field relation.
@param lookupFieldInternalName Internal name of the lookup field, that points to the list you're going to join in.
@alias alias for the joined list */
InnerJoin(lookupFieldInternalName: string, alias: string): IJoin;
/** Join the list you're querying with another list.
Joins are only allowed through a lookup field relation.
@param lookupFieldInternalName Internal name of the lookup field, that points to the list you're going to join in.
@alias alias for the joined list */
LeftJoin(lookupFieldInternalName: string, alias: string): IJoin;
}
interface IJoin extends IJoinable {
/** Select projected field for using in the main Query body
@param remoteFieldAlias By this alias, the field can be used in the main Query body. */
Select(remoteFieldInternalName: string, remoteFieldAlias: string): IProjectableView;
}
interface IProjectableView extends IView {
/** Select projected field for using in the main Query body
@param remoteFieldAlias By this alias, the field can be used in the main Query body. */
Select(remoteFieldInternalName: string, remoteFieldAlias: string): IProjectableView;
}
enum ViewScope {
/** */
Recursive = 0,
/** */
RecursiveAll = 1,
/** */
FilesOnly = 2,
}
interface IQuery {
Where(): IFieldExpression;
}
interface IFinalizableToString {
/** Get the resulting CAML query as string */
ToString(): string;
}
interface IFinalizable extends IFinalizableToString {
/** Get the resulting CAML query as SP.CamlQuery object */
ToCamlQuery(): any;
}
interface ISortable extends IFinalizable {
/** Adds OrderBy clause to the query
@param fieldInternalName Internal field of the first field by that the data will be sorted (ascending)
@param override This is only necessary for large lists. DON'T use it unless you know what it is for!
@param useIndexForOrderBy This is only necessary for large lists. DON'T use it unless you know what it is for!
*/
OrderBy(fieldInternalName: string, override?: boolean, useIndexForOrderBy?: boolean): ISortedQuery;
/** Adds OrderBy clause to the query (using descending order for the first field).
@param fieldInternalName Internal field of the first field by that the data will be sorted (descending)
@param override This is only necessary for large lists. DON'T use it unless you know what it is for!
@param useIndexForOrderBy This is only necessary for large lists. DON'T use it unless you know what it is for!
*/
OrderByDesc(fieldInternalName: string, override?: boolean, useIndexForOrderBy?: boolean): ISortedQuery;
}
interface IGroupable extends ISortable {
/** Adds GroupBy clause to the query.
@param collapse If true, only information about the groups is retrieved, otherwise items are also retrieved. */
GroupBy(fieldInternalName: any): IGroupedQuery;
}
interface IExpression extends IGroupable {
/** Adds And clause to the query. */
And(): IFieldExpression;
/** Adds Or clause to the query. */
Or(): IFieldExpression;
}
interface IGroupedQuery extends ISortable {
}
interface ISortedQuery extends IFinalizable {
/** Specifies next order field (ascending) */
ThenBy(fieldInternalName: string): any;
/** Specifies next order field (descending) */
ThenByDesc(fieldInternalName: string): any;
}
interface IFieldExpression {
/** Adds And clauses to the query. Use for creating bracket-expressions in conjuction with CamlBuilder.Expression(). */
All(...conditions: IExpression[]): IExpression;
/** Adds Or clauses to the query. Use for creating bracket-expressions in conjuction with CamlBuilder.Expression(). */
Any(...conditions: IExpression[]): IExpression;
/** Adds And clauses to the query. Use for creating bracket-expressions in conjuction with CamlBuilder.Expression(). */
All(conditions: IExpression[]): IExpression;
/** Adds Or clauses to the query. Use for creating bracket-expressions in conjuction with CamlBuilder.Expression(). */
Any(conditions: IExpression[]): IExpression;
/** Specifies that a condition will be tested against the field with the specified internal name, and the type of this field is Text */
TextField(internalName: string): ITextFieldExpression;
/** Specifies that a condition will be tested against the field with the specified internal name, and the type of this field is Boolean */
BooleanField(internalName: string): IBooleanFieldExpression;
/** Specifies that a condition will be tested against the field with the specified internal name, and the type of this field is URL */
UrlField(internalName: string): ITextFieldExpression;
/** Specifies that a condition will be tested against the field with the specified internal name, and the type of this field is Number */
NumberField(internalName: string): INumberFieldExpression;
/** Specifies that a condition will be tested against the field with the specified internal name, and the type of this field is Counter (usually ID fields) */
CounterField(internalName: string): INumberFieldExpression;
/** Specifies that a condition will be tested against the field with the specified internal name, and the type of this field is Integer */
IntegerField(internalName: string): INumberFieldExpression;
/** Specifies that a condition will be tested against the field with the specified internal name, and the type of this field is User */
UserField(internalName: string): IUserFieldExpression;
/** Specifies that a condition will be tested against the field with the specified internal name, and the type of this field is Lookup */
LookupField(internalName: string): ILookupFieldExpression;
/** Specifies that a condition will be tested against the field with the specified internal name, and the type of this field is LookupMulti */
LookupMultiField(internalName: string): ILookupMultiFieldExpression;
/** Specifies that a condition will be tested against the field with the specified internal name, and the type of this field is UserMulti */
UserMultiField(internalName: string): IUserMultiFieldExpression;
/** Specifies that a condition will be tested against the field with the specified internal name, and the type of this field is Date */
DateField(internalName: string): IDateTimeFieldExpression;
/** Specifies that a condition will be tested against the field with the specified internal name, and the type of this field is DateTime */
DateTimeField(internalName: string): IDateTimeFieldExpression;
/** Used in queries for retrieving recurring calendar events.
NOTICE: DateRangesOverlap with overlapType other than Now cannot be used with SP.CamlQuery, because it doesn't support
CalendarDate and ExpandRecurrence query options. Lists.asmx, however, supports them, so you can still use DateRangesOverlap
with SPServices.
@param overlapType Defines type of overlap: return all events for a day, for a week, for a month or for a year
@param calendarDate Defines date that will be used for determining events for which exactly day/week/month/year will be returned.
This value is ignored for overlapType=Now, but for the other overlap types it is mandatory.
@param eventDateField Internal name of "Start Time" field (default: "EventDate" - all OOTB Calendar lists use this name)
@param endDateField Internal name of "End Time" field (default: "EndDate" - all OOTB Calendar lists use this name)
@param recurrenceIDField Internal name of "Recurrence ID" field (default: "RecurrenceID" - all OOTB Calendar lists use this name)
*/
DateRangesOverlap(overlapType: DateRangesOverlapType, calendarDate: string, eventDateField?: string, endDateField?: string, recurrenceIDField?: string): IExpression;
}
interface IBooleanFieldExpression {
/** Checks whether the value of the field is True */
IsTrue(): IExpression;
/** Checks whether the value of the field is False */
IsFalse(): IExpression;
/** Checks whether the value of the field is equal to the specified value */
EqualTo(value: boolean): IExpression;
/** Checks whether the value of the field is not equal to the specified value */
NotEqualTo(value: boolean): IExpression;
/** Checks whether the value of the field was specified by user */
IsNull(): IExpression;
/** Checks whether the value of the field was not specified by user */
IsNotNull(): IExpression;
}
interface INumberFieldExpression {
/** Checks whether the value of the field is equal to the specified value */
EqualTo(value: number): IExpression;
/** Checks whether the value of the field is not equal to the specified value */
NotEqualTo(value: number): IExpression;
/** Checks whether the value of the field is greater than the specified value */
GreaterThan(value: number): IExpression;
/** Checks whether the value of the field is less than the specified value */
LessThan(value: number): IExpression;
/** Checks whether the value of the field is greater than or equal to the specified value */
GreaterThanOrEqualTo(value: number): IExpression;
/** Checks whether the value of the field is less than or equal to the specified value */
LessThanOrEqualTo(value: number): IExpression;
/** Checks whether the value of the field was specified by user */
IsNull(): IExpression;
/** Checks whether the value of the field was not specified by user */
IsNotNull(): IExpression;
/** Checks whether the value of the field is equal to one of the specified values */
In(arrayOfValues: number[]): IExpression;
}
interface IDateTimeFieldExpression {
/** Checks whether the value of the field was specified by user */
IsNull(): IExpression;
/** Checks whether the value of the field was not specified by user */
IsNotNull(): IExpression;
/** Checks whether the value of the field is equal to the specified value */
EqualTo(value: Date): IExpression;
/** Checks whether the value of the field is not equal to the specified value */
NotEqualTo(value: Date): IExpression;
/** Checks whether the value of the field is greater than the specified value */
GreaterThan(value: Date): IExpression;
/** Checks whether the value of the field is less than the specified value */
LessThan(value: Date): IExpression;
/** Checks whether the value of the field is greater than or equal to the specified value */
GreaterThanOrEqualTo(value: Date): IExpression;
/** Checks whether the value of the field is less than or equal to the specified value */
LessThanOrEqualTo(value: Date): IExpression;
/** Checks whether the value of the field is equal to one of the specified values */
In(arrayOfValues: Date[]): IExpression;
/** Checks whether the value of the field is equal to the specified value.
The datetime value should be defined in ISO 8601 format! */
EqualTo(value: string): IExpression;
/** Checks whether the value of the field is not equal to the specified value.
The datetime value should be defined in ISO 8601 format! */
NotEqualTo(value: string): IExpression;
/** Checks whether the value of the field is greater than the specified value.
The datetime value should be defined in ISO 8601 format! */
GreaterThan(value: string): IExpression;
/** Checks whether the value of the field is less than the specified value.
The datetime value should be defined in ISO 8601 format! */
LessThan(value: string): IExpression;
/** Checks whether the value of the field is greater than or equal to the specified value.
The datetime value should be defined in ISO 8601 format! */
GreaterThanOrEqualTo(value: string): IExpression;
/** Checks whether the value of the field is less than or equal to the specified value.
The datetime value should be defined in ISO 8601 format! */
LessThanOrEqualTo(value: string): IExpression;
/** Checks whether the value of the field is equal to one of the specified values.
The datetime value should be defined in ISO 8601 format! */
In(arrayOfValues: string[]): IExpression;
}
interface ITextFieldExpression {
/** Checks whether the value of the field is equal to the specified value */
EqualTo(value: string): IExpression;
/** Checks whether the value of the field is not equal to the specified value */
NotEqualTo(value: string): IExpression;
/** Checks whether the value of the field contains the specified substring */
Contains(value: string): IExpression;
/** Checks whether the value of the field begins with the specified substring */
BeginsWith(value: string): IExpression;
/** Checks whether the value of the field was specified by user */
IsNull(): IExpression;
/** Checks whether the value of the field was not specified by user */
IsNotNull(): IExpression;
/** Checks whether the value of the field is equal to one of the specified values */
In(arrayOfValues: string[]): IExpression;
}
interface IUserFieldExpression {
/** DEPRECATED. Please use IsIn* methods instead. This property will be removed in next release(!!) */
Membership: IMembership;
/** Checks whether the value of the User field is equal to id of the current user */
EqualToCurrentUser(): IExpression;
/** Checks whether the group specified by the value of the field includes the current user. */
IsInCurrentUserGroups(): IExpression;
/** Checks whether the user specified by the value of the field is member of the specified SharePoint Group. */
IsInSPGroup(groupId: number): IExpression;
/** Checks whether the user specified by the value of the field is member of current SPWeb groups. */
IsInSPWebGroups(): IExpression;
/** Checks whether the user specified by the value of the field is in current SPWeb users. */
IsInSPWebAllUsers(): IExpression;
/** Checks whether the user specified by the value of the field has received the rights to the site directly (not through a group). */
IsInSPWebUsers(): IExpression;
/** Specifies that id of the user will be used for further comparisons. */
Id(): INumberFieldExpression;
/** Specifies that lookup target field value will be used for further comparisons. */
ValueAsText(): ITextFieldExpression;
}
/** DEPRECATED!! Please use UserField(...).IsIn* methods instead. This interface will be removed in the next release */
interface IMembership {
/** DEPRECATED. Please use UserField(...).IsInCurrentUserGroups() instead */
CurrentUserGroups(): IExpression;
/** DEPRECATED. Please use UserField(...).IsInSPGroup() instead */
SPGroup(groupId: number): IExpression;
/** DEPRECATED. Please use UserField(...).IsInSPWeb* methods instead */
SPWeb: IMembershipSPWeb;
}
/** DEPRECATED!! Please use UserField(...).IsInSPWeb* methods instead. This interface will be removed in the next release */
interface IMembershipSPWeb {
/** DEPRECATED. Please use UserField(...).IsInSPWebAllUsers() instead */
AllUsers(): IExpression;
/** DEPRECATED. Please use UserField(...).IsInSPWebUsers() instead */
Users(): IExpression;
/** DEPRECATED. Please use UserField(...).IsInSPWebGroups() instead */
Groups(): IExpression;
}
interface ILookupFieldExpression {
/** Specifies that lookup id value will be used. */
Id(): INumberFieldExpression;
/** Specifies that lookup value will be used and this value is of type Text */
ValueAsText(): ITextFieldExpression;
/** Specifies that lookup value will be used and this value is of type Number */
ValueAsNumber(): INumberFieldExpression;
/** Specifies that lookup value will be used and this value is of type Date */
ValueAsDate(): IDateTimeFieldExpression;
/** Specifies that lookup value will be used and this value is of type DateTime */
ValueAsDateTime(): IDateTimeFieldExpression;
/** Specifies that lookup value will be used and this value is of type Boolean */
ValueAsBoolean(): IBooleanFieldExpression;
}
interface ILookupMultiFieldExpression {
/** Checks a condition against every item in the multi lookup value */
IncludesSuchItemThat(): ILookupFieldExpression;
/** Checks whether the field values collection is empty */
IsNull(): IExpression;
/** Checks whether the field values collection is not empty */
IsNotNull(): IExpression;
/** DEPRECATED: use "IncludesSuchItemThat().ValueAsText().EqualTo(value)" instead. */
Includes(value: any): IExpression;
/** DEPRECATED: use "IncludesSuchItemThat().ValueAsText().NotEqualTo(value)" instead. */
NotIncludes(value: any): IExpression;
/** DEPRECATED: "Eq" operation in CAML works exactly the same as "Includes". To avoid confusion, please use Includes. */
EqualTo(value: any): IExpression;
/** DEPRECATED: "Neq" operation in CAML works exactly the same as "NotIncludes". To avoid confusion, please use NotIncludes. */
NotEqualTo(value: any): IExpression;
}
interface IUserMultiFieldExpression {
/** Checks a condition against every item in the multi lookup value */
IncludesSuchItemThat(): IUserFieldExpression;
/** Checks whether the field values collection is empty */
IsNull(): IExpression;
/** Checks whether the field values collection is not empty */
IsNotNull(): IExpression;
/** DEPRECATED: use "IncludesSuchItemThat().ValueAsText().EqualTo(value)" instead. */
Includes(value: any): IExpression;
/** DEPRECATED: use "IncludesSuchItemThat().ValueAsText().NotEqualTo(value)" instead. */
NotIncludes(value: any): IExpression;
/** DEPRECATED: "Eq" operation in CAML works exactly the same as "Includes". To avoid confusion, please use Includes. */
EqualTo(value: any): IExpression;
/** DEPRECATED: "Neq" operation in CAML works exactly the same as "NotIncludes". To avoid confusion, please use NotIncludes. */
NotEqualTo(value: any): IExpression;
}
enum DateRangesOverlapType {
/** Returns events for today */
Now = 0,
/** Returns events for one day, specified by CalendarDate in QueryOptions */
Day = 1,
/** Returns events for one week, specified by CalendarDate in QueryOptions */
Week = 2,
/** Returns events for one month, specified by CalendarDate in QueryOptions.
Caution: usually also returns few days from previous and next months */
Month = 3,
/** Returns events for one year, specified by CalendarDate in QueryOptions */
Year = 4,
}
class Internal {
static createView(viewFields?: string[]): IView;
static createViewFields(viewFields: string[]): IFinalizableToString;
static createWhere(): IFieldExpression;
static createExpression(): IFieldExpression;
}
class CamlValues {
/** Dynamic value that represents Id of the current user */
static UserID: string;
/** Dynamic value that represents current date */
static Today: string;
/** Dynamic value that represents current date with specified offset (may be negative) */
static TodayWithOffset(offsetDays: number): string;
static Now: string;
/** Dynamic value that represents a property of the current list */
static ListProperty: {
Created: string;
DefaultViewUrl: string;
Description: string;
EnableSyndication: string;
ItemCount: string;
LinkTitle: string;
MajorVersionLimit: string;
MajorWithMinorVersionsLimit: string;
RelativeFolderPath: string;
Title: string;
ViewSelector: string;
};
/** Dynamic value that represents a property of the current SPWeb */
static ProjectProperty: {
BlogCategoryTitle: string;
BlogPostTitle: string;
Description: string;
RecycleBinEnabled: string;
SiteOwnerName: string;
SiteUrl: string;
Title: string;
Url: string;
};
}
}