4
4
// Definitions: https://github.com/borisyankov/DefinitelyTyped
5
5
6
6
7
- declare module Sys {
8
- class StringBuilder {
9
- /** Appends a string to the string builder */
10
- public append ( s : string ) : void ;
11
- /** Appends a line to the string builder */
12
- public appendLine ( s : string ) : void ;
13
- /** Clears the contents of the string builder */
14
- public clear ( ) : void ;
15
- /** Indicates wherever the string builder is empty */
16
- public isEmpty ( ) : boolean ;
17
- /** Gets the contents of the string builder as a string */
18
- public toString ( ) : string ;
19
- }
20
- }
21
- declare module SP {
22
- /** Defines a writer that provides a set of methods to append text in XML format. Use the static SP.XmlWriter.create(sb) Method to create an SP.XmlWriter object with the Sys.StringBuilder object you pass in. */
23
- class XmlWriter {
24
- /** Creates a new instance of the XmlWriter class with the specified string builder. */
25
- static create ( sb : Sys . StringBuilder ) : XmlWriter ;
26
- /** Appends a start element tag with the specified name in XML format to the object?s string builder. */
27
- public writeStartElement ( tagName : string ) : void ;
28
- /** Appends an element with the specified tag name and value in XML format to the string builder. */
29
- public writeElementString ( tagName : string , value : string ) : void ;
30
- /** Appends an end element tag in XML format to the object?s string builder. This method appends the end element tag ?/>? if the start element tag is not closed; otherwise, it appends a full end element tag ?</tagName>? to the string builder. */
31
- public writeEndElement ( ) : void ;
32
- /** Appends an attribute with the specified name and value in XML format to the object?s string builder. */
33
- public writeAttributeString ( localName : string , value : string ) : void ;
34
- /** This method only appends the name of the attribute. You can append the value of the attribute by calling the SP.XmlWriter.writeString(value) Method, and close the attribute by calling the SP.XmlWriter.writeEndAttribute() Method. */
35
- public writeStartAttribute ( localName : string ) : void ;
36
- /** Appends an end of an attribute in XML format to the object?s string builder. */
37
- public writeEndAttribute ( ) : void ;
38
- /** Appends the specified value for an element tag or attribute to the object?s string builder. */
39
- public writeString ( value : string ) : void ;
40
- /** Appends the specified text to the object?s string builder. */
41
- public writeRaw ( xml : string ) : void ;
42
- /** This member is reserved for internal use and is not intended to be used directly from your code. */
43
- public close ( ) : void ;
44
- }
45
- }
46
7
declare class CamlBuilder {
47
8
constructor ( ) ;
9
+ /** Generate CAML Query, starting from <Where> tag */
48
10
public Where ( ) : CamlBuilder . IFieldExpression ;
11
+ /** Generate <View> tag for SP.CamlQuery
12
+ @param viewFields If omitted, default view fields are requested; otherwise, only values for the fields with the specified internal names are returned.
13
+ Specifying view fields is a good practice, as it decreases traffic between server and client. */
14
+ public View ( viewFields ?: string [ ] ) : CamlBuilder . IView ;
49
15
/** Use for:
50
16
1. SPServices CAMLQuery attribute
51
17
2. Creating partial expressions
@@ -54,15 +20,49 @@ declare class CamlBuilder {
54
20
static Expression ( ) : CamlBuilder . IFieldExpression ;
55
21
}
56
22
declare module CamlBuilder {
57
- interface IView {
23
+ interface IView extends IJoinable , IFinalizable {
58
24
Query ( ) : IQuery ;
25
+ RowLimit ( limit : number , paged ?: boolean ) : IView ;
26
+ Scope ( scope : ViewScope ) : IView ;
27
+ }
28
+ interface IJoinable {
29
+ /** Join the list you're querying with another list.
30
+ Joins are only allowed through a lookup field relation.
31
+ @param lookupFieldInternalName Internal name of the lookup field, that points to the list you're going to join in.
32
+ @alias alias for the joined list */
33
+ InnerJoin ( lookupFieldInternalName : string , alias : string ) : IJoin ;
34
+ /** Join the list you're querying with another list.
35
+ Joins are only allowed through a lookup field relation.
36
+ @param lookupFieldInternalName Internal name of the lookup field, that points to the list you're going to join in.
37
+ @alias alias for the joined list */
38
+ LeftJoin ( lookupFieldInternalName : string , alias : string ) : IJoin ;
39
+ }
40
+ interface IJoin extends IJoinable {
41
+ /** Select projected field for using in the main Query body
42
+ @param remoteFieldAlias By this alias, the field can be used in the main Query body. */
43
+ Select ( remoteFieldInternalName : string , remoteFieldAlias : string ) : IProjectableView ;
44
+ }
45
+ interface IProjectableView extends IView {
46
+ /** Select projected field for using in the main Query body
47
+ @param remoteFieldAlias By this alias, the field can be used in the main Query body. */
48
+ Select ( remoteFieldInternalName : string , remoteFieldAlias : string ) : IProjectableView ;
49
+ }
50
+ enum ViewScope {
51
+ /** */
52
+ Recursive = 0 ,
53
+ /** */
54
+ RecursiveAll = 1 ,
55
+ /** */
56
+ FilesOnly = 2 ,
59
57
}
60
58
interface IQuery {
61
59
Where ( ) : IFieldExpression ;
62
60
}
63
61
interface IFinalizable {
64
62
/** Get the resulting CAML query as string */
65
63
ToString ( ) : string ;
64
+ /** Get the resulting CAML query as SP.CamlQuery object */
65
+ ToCamlQuery ( ) : any ;
66
66
}
67
67
interface ISortable extends IFinalizable {
68
68
/** Adds OrderBy clause to the query
@@ -81,7 +81,7 @@ declare module CamlBuilder {
81
81
interface IGroupable extends ISortable {
82
82
/** Adds GroupBy clause to the query.
83
83
@param collapse If true, only information about the groups is retrieved, otherwise items are also retrieved. */
84
- GroupBy ( fieldInternalName ) : IGroupedQuery ;
84
+ GroupBy ( fieldInternalName : any ) : IGroupedQuery ;
85
85
}
86
86
interface IExpression extends IGroupable {
87
87
/** Adds And clause to the query. */
@@ -122,12 +122,10 @@ declare module CamlBuilder {
122
122
UserField ( internalName : string ) : IUserFieldExpression ;
123
123
/** Specifies that a condition will be tested against the field with the specified internal name, and the type of this field is Lookup */
124
124
LookupField ( internalName : string ) : ILookupFieldExpression ;
125
- /** DEPRECATED. Please use LookupField(...).Id() instead */
126
- LookupIdField ( internalName : string ) : INumberFieldExpression ;
127
125
/** Specifies that a condition will be tested against the field with the specified internal name, and the type of this field is LookupMulti */
128
126
LookupMultiField ( internalName : string ) : ILookupMultiFieldExpression ;
129
127
/** Specifies that a condition will be tested against the field with the specified internal name, and the type of this field is UserMulti */
130
- UserMultiField ( internalName : string ) : ILookupMultiFieldExpression ;
128
+ UserMultiField ( internalName : string ) : IUserMultiFieldExpression ;
131
129
/** Specifies that a condition will be tested against the field with the specified internal name, and the type of this field is Date */
132
130
DateField ( internalName : string ) : IDateTimeFieldExpression ;
133
131
/** Specifies that a condition will be tested against the field with the specified internal name, and the type of this field is DateTime */
@@ -289,30 +287,52 @@ declare module CamlBuilder {
289
287
ValueAsBoolean ( ) : IBooleanFieldExpression ;
290
288
}
291
289
interface ILookupMultiFieldExpression {
292
- /** Checks whether the value of the field is equal to the specified value */
293
- EqualTo ( value : string ) : IExpression ;
294
- /** Checks whether the value of the field is not equal to the specified value */
295
- NotEqualTo ( value : string ) : IExpression ;
296
- /** Checks whether the values of the field includes the specified value */
297
- Includes ( value ) : IExpression ;
298
- /** Checks whether the values of the field not includes the specified value */
299
- NotIncludes ( value ) : IExpression ;
290
+ /** Checks a condition against every item in the multi lookup value */
291
+ IncludesSuchItemThat ( ) : ILookupFieldExpression ;
292
+ /** Checks whether the field values collection is empty */
293
+ IsNull ( ) : IExpression ;
294
+ /** Checks whether the field values collection is not empty */
295
+ IsNotNull ( ) : IExpression ;
296
+ /** DEPRECATED: use "IncludesSuchItemThat().ValueAsText().EqualTo(value)" instead. */
297
+ Includes ( value : any ) : IExpression ;
298
+ /** DEPRECATED: use "IncludesSuchItemThat().ValueAsText().NotEqualTo(value)" instead. */
299
+ NotIncludes ( value : any ) : IExpression ;
300
+ /** DEPRECATED: "Eq" operation in CAML works exactly the same as "Includes". To avoid confusion, please use Includes. */
301
+ EqualTo ( value : any ) : IExpression ;
302
+ /** DEPRECATED: "Neq" operation in CAML works exactly the same as "NotIncludes". To avoid confusion, please use NotIncludes. */
303
+ NotEqualTo ( value : any ) : IExpression ;
304
+ }
305
+ interface IUserMultiFieldExpression {
306
+ /** Checks a condition against every item in the multi lookup value */
307
+ IncludesSuchItemThat ( ) : IUserFieldExpression ;
308
+ /** Checks whether the field values collection is empty */
309
+ IsNull ( ) : IExpression ;
310
+ /** Checks whether the field values collection is not empty */
311
+ IsNotNull ( ) : IExpression ;
312
+ /** DEPRECATED: use "IncludesSuchItemThat().ValueAsText().EqualTo(value)" instead. */
313
+ Includes ( value : any ) : IExpression ;
314
+ /** DEPRECATED: use "IncludesSuchItemThat().ValueAsText().NotEqualTo(value)" instead. */
315
+ NotIncludes ( value : any ) : IExpression ;
316
+ /** DEPRECATED: "Eq" operation in CAML works exactly the same as "Includes". To avoid confusion, please use Includes. */
317
+ EqualTo ( value : any ) : IExpression ;
318
+ /** DEPRECATED: "Neq" operation in CAML works exactly the same as "NotIncludes". To avoid confusion, please use NotIncludes. */
319
+ NotEqualTo ( value : any ) : IExpression ;
300
320
}
301
321
enum DateRangesOverlapType {
302
322
/** Returns events for today */
303
- Now ,
323
+ Now = 0 ,
304
324
/** Returns events for one day, specified by CalendarDate in QueryOptions */
305
- Day ,
325
+ Day = 1 ,
306
326
/** Returns events for one week, specified by CalendarDate in QueryOptions */
307
- Week ,
327
+ Week = 2 ,
308
328
/** Returns events for one month, specified by CalendarDate in QueryOptions.
309
329
Caution: usually also returns few days from previous and next months */
310
- Month ,
330
+ Month = 3 ,
311
331
/** Returns events for one year, specified by CalendarDate in QueryOptions */
312
- Year ,
332
+ Year = 4 ,
313
333
}
314
334
class Internal {
315
- static createView ( ) : IView ;
335
+ static createView ( viewFields ?: string [ ] ) : IView ;
316
336
static createWhere ( ) : IFieldExpression ;
317
337
static createExpression ( ) : IFieldExpression ;
318
338
}
0 commit comments