@progress/sitefinity-webservices-sdk 0.2.72 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +4 -0
- package/.eslintrc.js +19 -0
- package/ci/pipelines/ci.yml +219 -0
- package/config/helpers.js +0 -6
- package/config/webpack.common.js +1 -3
- package/config/webpack.dev.js +2 -9
- package/config/webpack.prod.js +5 -6
- package/dist/docs/.nojekyll +1 -0
- package/dist/docs/assets/highlight.css +57 -0
- package/dist/docs/assets/icons.css +1043 -0
- package/dist/docs/assets/icons.png +0 -0
- package/dist/docs/assets/icons@2x.png +0 -0
- package/dist/docs/assets/main.js +52 -0
- package/dist/docs/assets/search.js +1 -0
- package/dist/docs/assets/style.css +1413 -0
- package/dist/docs/assets/{images/widgets.png → widgets.png} +0 -0
- package/dist/docs/assets/{images/widgets@2x.png → widgets@2x.png} +0 -0
- package/dist/docs/classes/BlobBuilder.BlobBuilder-1.html +7 -0
- package/dist/docs/classes/Data.Data-1.html +65 -0
- package/dist/docs/classes/Expression.BinaryExpression.html +1 -0
- package/dist/docs/classes/Expression.ComplexExpression.html +1 -0
- package/dist/docs/classes/Expression.ExpressionBase.html +1 -0
- package/dist/docs/classes/OrderProperty.OrderProperty-1.html +1 -0
- package/dist/docs/classes/Query.Query-1.html +33 -0
- package/dist/docs/classes/QueryBase.QueryBase-1.html +7 -0
- package/dist/docs/classes/QueryBuilder.QueryBuilder-1.html +1 -0
- package/dist/docs/classes/Requests_BatchRequest.BatchRequest.html +17 -0
- package/dist/docs/classes/Requests_BatchRequest.Transaction.html +17 -0
- package/dist/docs/classes/Requests_ExecutableRequest.ExecutableRequest.html +1 -0
- package/dist/docs/classes/Requests_Request.CreateRelatedRequest.html +1 -0
- package/dist/docs/classes/Requests_Request.CreateRequest.html +1 -0
- package/dist/docs/classes/Requests_Request.DeleteRelatedByIdRequest.html +1 -0
- package/dist/docs/classes/Requests_Request.DeleteRelatedRequest.html +1 -0
- package/dist/docs/classes/Requests_Request.DeleteRequest.html +1 -0
- package/dist/docs/classes/Requests_Request.GetByIdRequest.html +1 -0
- package/dist/docs/classes/Requests_Request.GetRelatedByIdRequest.html +1 -0
- package/dist/docs/classes/Requests_Request.GetRelatedRequest.html +1 -0
- package/dist/docs/classes/Requests_Request.GetRequest.html +1 -0
- package/dist/docs/classes/Requests_Request.UpdateRequest.html +1 -0
- package/dist/docs/classes/Requests_Request.UploadRequest.html +1 -0
- package/dist/docs/classes/Requests_RequestBase.RequestBase.html +1 -0
- package/dist/docs/classes/Requests_RequestFactory.RequestFactory.html +1 -0
- package/dist/docs/classes/Sitefinity.Sitefinity-1.html +5 -0
- package/dist/docs/classes/WhereQuery.WhereQuery-1.html +31 -0
- package/dist/docs/classes/utils.utils-1.html +1 -0
- package/dist/docs/index.html +54 -242
- package/dist/docs/interfaces/Data.CreateRelatedRequestOptions.html +1 -0
- package/dist/docs/interfaces/Data.CreateRequestOptions.html +1 -0
- package/dist/docs/interfaces/Data.OperationsRequestOptions.html +1 -0
- package/dist/docs/interfaces/Data.PropertyRequestOptions.html +1 -0
- package/dist/docs/interfaces/Data.RequestOptionsBase.html +1 -0
- package/dist/docs/interfaces/Data.SingleRelatedItemRequestOptions.html +1 -0
- package/dist/docs/interfaces/Data.UpdateRequestOptions.html +1 -0
- package/dist/docs/interfaces/Data.UploadRequestOptions.html +1 -0
- package/dist/docs/interfaces/Requests_BatchRequest.BatchCreateRelatedRequestOptions.html +1 -0
- package/dist/docs/interfaces/Requests_BatchRequest.BatchCreateRequestOptions.html +1 -0
- package/dist/docs/interfaces/Requests_BatchRequest.BatchPropertyRequestOptions.html +1 -0
- package/dist/docs/interfaces/Requests_BatchRequest.BatchRequestOptionsBase.html +1 -0
- package/dist/docs/interfaces/Requests_BatchRequest.BatchRequestOptionsExtended.html +1 -0
- package/dist/docs/interfaces/Requests_BatchRequest.BatchSingleItemRequestOptions.html +1 -0
- package/dist/docs/interfaces/Requests_BatchRequest.BatchSingleRelatedItemRequestOptions.html +1 -0
- package/dist/docs/interfaces/Requests_BatchRequest.BatchUpdateRequestOptions.html +1 -0
- package/dist/docs/interfaces/Requests_ExecutableRequest.ResponseHandlers.html +5 -0
- package/dist/docs/interfaces/Requests_Request.PostRequestOptionsExtended.html +1 -0
- package/dist/docs/interfaces/Requests_Request.PutRequestOptionsExtended.html +1 -0
- package/dist/docs/interfaces/Requests_Request.RelatedByIdRequestOptionsExtended.html +1 -0
- package/dist/docs/interfaces/Requests_Request.RelatedRequestOptionsExtended.html +1 -0
- package/dist/docs/interfaces/Requests_Request.UploadRequestOptionsExtended.html +1 -0
- package/dist/docs/interfaces/Requests_RequestBase.RequestOptionsBaseExtended.html +1 -0
- package/dist/docs/interfaces/Sitefinity.SDKOptions.html +9 -0
- package/dist/docs/interfaces/Sitefinity.Token.html +1 -0
- package/dist/docs/interfaces/Sitefinity.TypeOptions.html +13 -0
- package/dist/docs/modules/BlobBuilder.html +1 -0
- package/dist/docs/modules/Data.html +1 -0
- package/dist/docs/modules/Expression.html +1 -0
- package/dist/docs/modules/OrderProperty.html +1 -0
- package/dist/docs/modules/Query.html +1 -0
- package/dist/docs/modules/QueryBase.html +1 -0
- package/dist/docs/modules/QueryBuilder.html +1 -0
- package/dist/docs/modules/Requests_BatchRequest.html +1 -0
- package/dist/docs/modules/Requests_ExecutableRequest.html +1 -0
- package/dist/docs/modules/Requests_Request.html +1 -0
- package/dist/docs/modules/Requests_RequestBase.html +1 -0
- package/dist/docs/modules/Requests_RequestFactory.html +1 -0
- package/dist/docs/modules/Sitefinity.html +1 -0
- package/dist/docs/modules/WhereQuery.html +1 -0
- package/dist/docs/modules/constants.html +1 -0
- package/dist/docs/modules/utils.html +1 -0
- package/dist/docs/modules.html +1 -0
- package/dist/samples.html +33 -81
- package/dist/sitefinity-webservices-sdk.d.ts +16 -0
- package/dist/sitefinity-webservices-sdk.js +1159 -1734
- package/dist/sitefinity-webservices-sdk.js.map +1 -1
- package/dist/sitefinity-webservices-sdk.min.js +2 -16
- package/dist/sitefinity-webservices-sdk.min.js.LICENSE.txt +14 -0
- package/dist/src/BlobBuilder.d.ts +14 -0
- package/dist/src/Data.d.ts +144 -0
- package/dist/src/Expression.d.ts +19 -0
- package/dist/src/OrderProperty.d.ts +8 -0
- package/dist/src/Query.d.ts +59 -0
- package/dist/src/QueryBase.d.ts +18 -0
- package/dist/src/QueryBuilder.d.ts +13 -0
- package/dist/src/Requests/BatchRequest.d.ts +146 -0
- package/dist/src/Requests/ExecutableRequest.d.ts +20 -0
- package/dist/src/Requests/Request.d.ts +88 -0
- package/dist/src/Requests/RequestBase.d.ts +28 -0
- package/dist/src/Requests/RequestFactory.d.ts +22 -0
- package/dist/src/Sitefinity.d.ts +66 -0
- package/dist/src/WhereQuery.d.ts +68 -0
- package/dist/src/constants.d.ts +55 -0
- package/dist/src/utils.d.ts +16 -0
- package/karma.conf.js +29 -0
- package/package-lock.json +16108 -6805
- package/package.json +28 -10
- package/sitefinity-webservices-sdk.ts +16 -0
- package/src/BlobBuilder.ts +7 -12
- package/src/Data.spec.ts +160 -0
- package/src/Data.ts +132 -207
- package/src/Expression.ts +6 -3
- package/src/OrderProperty.ts +4 -5
- package/src/Query.ts +52 -78
- package/src/QueryBase.ts +21 -47
- package/src/QueryBuilder.ts +76 -82
- package/src/Requests/BatchRequest.ts +312 -335
- package/src/Requests/ExecutableRequest.ts +46 -73
- package/src/Requests/Request.ts +134 -260
- package/src/Requests/RequestBase.ts +161 -0
- package/src/Requests/RequestFactory.ts +36 -54
- package/src/Requests/request.spec.ts +92 -0
- package/src/Sitefinity.spec.ts +418 -0
- package/src/Sitefinity.ts +77 -146
- package/src/WhereQuery.ts +55 -112
- package/src/constants.ts +58 -39
- package/src/utils.ts +17 -14
- package/template.html +33 -35
- package/tsconfig.json +8 -1
- package/type.txt +1 -1
- package/version.txt +1 -1
- package/config/html.conf.json +0 -5
- package/dist/docs/assets/css/main.css +0 -865
- package/dist/docs/assets/css/main.css.map +0 -7
- package/dist/docs/assets/images/icons.png +0 -0
- package/dist/docs/assets/images/icons@2x.png +0 -0
- package/dist/docs/assets/js/main.js +0 -5
- package/dist/docs/assets/js/search.js +0 -3
- package/dist/docs/classes/_authentication_.authentication.html +0 -527
- package/dist/docs/classes/_blobbuilder_.blobbuilder.html +0 -351
- package/dist/docs/classes/_data_.data.html +0 -974
- package/dist/docs/classes/_expression_.binaryexpression.html +0 -412
- package/dist/docs/classes/_expression_.complexexpression.html +0 -374
- package/dist/docs/classes/_expression_.expressionbase.html +0 -336
- package/dist/docs/classes/_orderproperty_.orderproperty.html +0 -381
- package/dist/docs/classes/_query_.query.html +0 -896
- package/dist/docs/classes/_querybase_.querybase.html +0 -518
- package/dist/docs/classes/_querybuilder_.querybuilder.html +0 -466
- package/dist/docs/classes/_requests_batchrequest_.batchrequest.html +0 -1511
- package/dist/docs/classes/_requests_batchrequest_.transaction.html +0 -804
- package/dist/docs/classes/_requests_executablerequest_.executablerequest.html +0 -549
- package/dist/docs/classes/_requests_request_.createrelatedrequest.html +0 -689
- package/dist/docs/classes/_requests_request_.createrequest.html +0 -680
- package/dist/docs/classes/_requests_request_.deleterelatedbyidrequest.html +0 -687
- package/dist/docs/classes/_requests_request_.deleterelatedrequest.html +0 -673
- package/dist/docs/classes/_requests_request_.deleterequest.html +0 -666
- package/dist/docs/classes/_requests_request_.getbyidrequest.html +0 -666
- package/dist/docs/classes/_requests_request_.getrelatedbyidrequest.html +0 -687
- package/dist/docs/classes/_requests_request_.getrelatedrequest.html +0 -673
- package/dist/docs/classes/_requests_request_.getrequest.html +0 -658
- package/dist/docs/classes/_requests_request_.requestbase.html +0 -687
- package/dist/docs/classes/_requests_request_.updaterequest.html +0 -686
- package/dist/docs/classes/_requests_request_.uploadrequest.html +0 -715
- package/dist/docs/classes/_requests_requestfactory_.requestfactory.html +0 -724
- package/dist/docs/classes/_sitefinity_.sitefinity.html +0 -521
- package/dist/docs/classes/_utils_.utils.html +0 -597
- package/dist/docs/classes/_wherequery_.wherequery.html +0 -971
- package/dist/docs/globals.html +0 -238
- package/dist/docs/modules/_authentication_.html +0 -225
- package/dist/docs/modules/_blobbuilder_.html +0 -225
- package/dist/docs/modules/_constants_.html +0 -528
- package/dist/docs/modules/_contenttypes_.html +0 -248
- package/dist/docs/modules/_data_.html +0 -225
- package/dist/docs/modules/_expression_.html +0 -233
- package/dist/docs/modules/_headers_.html +0 -328
- package/dist/docs/modules/_httpmethods_.html +0 -288
- package/dist/docs/modules/_main_.html +0 -209
- package/dist/docs/modules/_orderproperty_.html +0 -225
- package/dist/docs/modules/_query_.html +0 -225
- package/dist/docs/modules/_querybase_.html +0 -225
- package/dist/docs/modules/_querybuilder_.html +0 -247
- package/dist/docs/modules/_requests_batchrequest_.html +0 -265
- package/dist/docs/modules/_requests_executablerequest_.html +0 -296
- package/dist/docs/modules/_requests_request_.html +0 -333
- package/dist/docs/modules/_requests_requestfactory_.html +0 -247
- package/dist/docs/modules/_sitefinity_.html +0 -225
- package/dist/docs/modules/_utils_.html +0 -225
- package/dist/docs/modules/_wherequery_.html +0 -247
- package/dist/index.html +0 -474
- package/src/Authentication.ts +0 -96
- package/src/ContentTypes.ts +0 -5
- package/src/Headers.ts +0 -12
- package/src/HttpMethods.ts +0 -9
- package/src/main.ts +0 -2
package/src/WhereQuery.ts
CHANGED
|
@@ -1,195 +1,138 @@
|
|
|
1
1
|
import { ComplexExpression, BinaryExpression } from './Expression';
|
|
2
|
-
|
|
2
|
+
import { EXPRESSION_TYPE } from "./constants";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* @class WhereQuery
|
|
7
|
-
* @protected
|
|
5
|
+
* A fluent API operation for creating a filter for a query by chaining different rules.
|
|
8
6
|
*/
|
|
9
|
-
export class WhereQuery {
|
|
10
|
-
|
|
7
|
+
export class WhereQuery<QueryType> {
|
|
11
8
|
private expression: ComplexExpression;
|
|
12
|
-
|
|
9
|
+
|
|
10
|
+
constructor(private parent: QueryType, type: string = EXPRESSION_TYPE.and) {
|
|
13
11
|
this.expression = new ComplexExpression(type, []);
|
|
14
12
|
}
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
*/
|
|
22
|
-
and(): WhereQuery {
|
|
23
|
-
return new WhereQuery(this, OperatorType.and);
|
|
14
|
+
/**
|
|
15
|
+
* Adds an `and` clause to the current condition and returns it for further chaining.
|
|
16
|
+
*/
|
|
17
|
+
and(): WhereQuery<WhereQuery<QueryType>> {
|
|
18
|
+
return new WhereQuery(this, EXPRESSION_TYPE.and);
|
|
24
19
|
}
|
|
20
|
+
|
|
25
21
|
/**
|
|
26
22
|
* Adds an `or` clause to the current condition and returns it for further chaining.
|
|
27
|
-
* @method or
|
|
28
|
-
* @memberOf WhereQuery.prototype
|
|
29
|
-
* @returns {WhereQuery}
|
|
30
23
|
*/
|
|
31
|
-
or(): WhereQuery {
|
|
32
|
-
return new WhereQuery(this,
|
|
24
|
+
or(): WhereQuery<WhereQuery<QueryType>> {
|
|
25
|
+
return new WhereQuery(this, EXPRESSION_TYPE.or);
|
|
33
26
|
}
|
|
34
27
|
|
|
35
28
|
/**
|
|
36
29
|
* Adds an `any` clause to the current condition and returns it for further chaining.
|
|
37
|
-
* @method any
|
|
38
|
-
* @memberOf WhereQuery.prototype
|
|
39
|
-
* @returns {WhereQuery}
|
|
40
30
|
*/
|
|
41
|
-
any(): WhereQuery {
|
|
42
|
-
return new WhereQuery(this,
|
|
31
|
+
any(): WhereQuery<WhereQuery<QueryType>> {
|
|
32
|
+
return new WhereQuery(this, EXPRESSION_TYPE.any);
|
|
43
33
|
}
|
|
34
|
+
|
|
44
35
|
/**
|
|
45
36
|
* Adds a `not` clause to the current condition and returns it for further chaining.
|
|
46
|
-
* @method not
|
|
47
|
-
* @memberOf WhereQuery.prototype
|
|
48
|
-
* @returns {WhereQuery}
|
|
49
37
|
*/
|
|
50
|
-
not(): WhereQuery {
|
|
51
|
-
return new WhereQuery(this,
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
private _simple (type: string, parameter: string, constant: any): WhereQuery {
|
|
55
|
-
var currentExpr = new BinaryExpression(type, parameter, constant);
|
|
56
|
-
var subExpressions = this.expression.getExpressions();
|
|
57
|
-
subExpressions.push(currentExpr);
|
|
58
|
-
|
|
59
|
-
if (this.expression.getType() === OperatorType.not && subExpressions.length > 1)
|
|
60
|
-
throw new Error("Invalid operators count!");
|
|
61
|
-
|
|
62
|
-
return this;
|
|
38
|
+
not(): WhereQuery<WhereQuery<QueryType>> {
|
|
39
|
+
return new WhereQuery(this, EXPRESSION_TYPE.not);
|
|
63
40
|
}
|
|
64
41
|
|
|
65
42
|
/**
|
|
66
43
|
* Adds a condition that a field must be equal to a specific value.
|
|
67
|
-
* @method eq
|
|
68
|
-
* @memberOf WhereQuery.prototype
|
|
69
|
-
* @param {string} field Field name.
|
|
70
|
-
* @param {*} value Comparison value (to which the fields must be equal).
|
|
71
|
-
* @returns {WhereQuery}
|
|
72
44
|
*/
|
|
73
|
-
eq(parameter: string, constant: any): WhereQuery {
|
|
74
|
-
return this.
|
|
45
|
+
eq(parameter: string, constant: any): WhereQuery<QueryType> {
|
|
46
|
+
return this.simple(EXPRESSION_TYPE.eq, parameter, constant);
|
|
75
47
|
}
|
|
48
|
+
|
|
76
49
|
/**
|
|
77
50
|
* Adds a condition that a field must *not* be equal to a specific value.
|
|
78
|
-
* @method ne
|
|
79
|
-
* @memberOf WhereQuery.prototype
|
|
80
|
-
* @param {string} field Field name.
|
|
81
|
-
* @param {*} value Comparison value (to which the field must not be equal).
|
|
82
|
-
* @returns {WhereQuery}
|
|
83
51
|
*/
|
|
84
|
-
ne(parameter: string, constant: any): WhereQuery {
|
|
85
|
-
return this.
|
|
52
|
+
ne(parameter: string, constant: any): WhereQuery<QueryType> {
|
|
53
|
+
return this.simple(EXPRESSION_TYPE.ne, parameter, constant);
|
|
86
54
|
}
|
|
55
|
+
|
|
87
56
|
/**
|
|
88
57
|
* Adds a condition that a field must be `greater than` a certain value. Applicable to Number, String, and Date fields.
|
|
89
|
-
* @method gt
|
|
90
|
-
* @memberOf WhereQuery.prototype
|
|
91
|
-
* @param {string} field Field name.
|
|
92
|
-
* @param {*} value Comparison value (that the field should be greater than).
|
|
93
|
-
* @returns {WhereQuery}
|
|
94
58
|
*/
|
|
95
59
|
gt(parameter: string, constant: any) {
|
|
96
|
-
return this.
|
|
60
|
+
return this.simple(EXPRESSION_TYPE.gt, parameter, constant);
|
|
97
61
|
}
|
|
62
|
+
|
|
98
63
|
/**
|
|
99
64
|
* Adds a condition that a field must be `greater than or equal` to a certain value. Applicable to Number, String, and Date fields.
|
|
100
|
-
* @method gte
|
|
101
|
-
* @memberOf WhereQuery.prototype
|
|
102
|
-
* @param {string} field Field name.
|
|
103
|
-
* @param {*} value Comparison value (that the field should be greater than or equal to).
|
|
104
|
-
* @returns {WhereQuery}
|
|
105
65
|
*/
|
|
106
66
|
gte(parameter: string, constant: any) {
|
|
107
|
-
return this.
|
|
67
|
+
return this.simple(EXPRESSION_TYPE.ge, parameter, constant);
|
|
108
68
|
}
|
|
69
|
+
|
|
109
70
|
/**
|
|
110
71
|
* Adds a condition that a field must be `less than` a certain value. Applicable to Number, String, and Date fields.
|
|
111
|
-
* @method lt
|
|
112
|
-
* @memberOf WhereQuery.prototype
|
|
113
|
-
* @param {string} field Field name.
|
|
114
|
-
* @param {*} value Comparison value (that the field should be less than).
|
|
115
|
-
* @returns {WhereQuery}
|
|
116
72
|
*/
|
|
117
73
|
lt(parameter: string, constant: any) {
|
|
118
|
-
return this.
|
|
74
|
+
return this.simple(EXPRESSION_TYPE.lt, parameter, constant);
|
|
119
75
|
}
|
|
76
|
+
|
|
120
77
|
/**
|
|
121
78
|
* Adds a condition that a field must be `less than or equal` to a certain value. Applicable to Number, String, and Date fields.
|
|
122
|
-
* @method lte
|
|
123
|
-
* @memberOf WhereQuery.prototype
|
|
124
|
-
* @param {string} field Field name.
|
|
125
|
-
* @param {*} value Comparison value (that the field should be less than or equal to).
|
|
126
|
-
* @returns {WhereQuery}
|
|
127
79
|
*/
|
|
128
80
|
lte(parameter: string, constant: any) {
|
|
129
|
-
return this.
|
|
81
|
+
return this.simple(EXPRESSION_TYPE.le, parameter, constant);
|
|
130
82
|
}
|
|
83
|
+
|
|
131
84
|
/**
|
|
132
85
|
* Adds a condition that a field value must *start* with a specified string.
|
|
133
|
-
* @method startsWith
|
|
134
|
-
* @memberOf WhereQuery.prototype
|
|
135
|
-
* @param {string} field Field name.
|
|
136
|
-
* @param {string} value The string that the field should start with.
|
|
137
|
-
* @param {string} [options] A string of regex options to use. See [specs](http://docs.mongodb.org/manual/reference/operator/query/regex/#op._S_options) for a description of available options.
|
|
138
|
-
* @returns {WhereQuery}
|
|
139
86
|
*/
|
|
140
|
-
startsWith(parameter: string, constant: any)
|
|
141
|
-
return this.
|
|
87
|
+
startsWith(parameter: string, constant: any, caseSensitive = true) {
|
|
88
|
+
return this.simple(EXPRESSION_TYPE.startsWith, parameter, constant, caseSensitive);
|
|
142
89
|
}
|
|
143
90
|
|
|
144
91
|
/**
|
|
145
92
|
* Adds a condition that a field value must *contain* a specified string.
|
|
146
|
-
* @method startsWith
|
|
147
|
-
* @memberOf WhereQuery.prototype
|
|
148
|
-
* @param {string} field Field name.
|
|
149
|
-
* @param {string} value The string that the field should start with.
|
|
150
|
-
* @param {string} [options] A string of regex options to use. See [specs](http://docs.mongodb.org/manual/reference/operator/query/regex/#op._S_options) for a description of available options.
|
|
151
|
-
* @returns {WhereQuery}
|
|
152
93
|
*/
|
|
153
|
-
contains(parameter: string, constant: any) {
|
|
154
|
-
return this.
|
|
94
|
+
contains(parameter: string, constant: any, caseSensitive = true) {
|
|
95
|
+
return this.simple(EXPRESSION_TYPE.contains, parameter, constant, caseSensitive);
|
|
155
96
|
}
|
|
156
97
|
|
|
157
98
|
/**
|
|
158
99
|
* Adds a condition that a field value must *end* with a specified string.
|
|
159
|
-
* @method endsWith
|
|
160
|
-
* @memberOf WhereQuery.prototype
|
|
161
|
-
* @param {string} field Field name.
|
|
162
|
-
* @param {string} value The string that the field should end with.
|
|
163
|
-
* @param {string} [options] A string of regex options to use. See [specs](http://docs.mongodb.org/manual/reference/operator/query/regex/#op._S_options) for a description of available options.
|
|
164
|
-
* @returns {WhereQuery}
|
|
165
100
|
*/
|
|
166
|
-
endsWith(parameter: string, constant: any) {
|
|
167
|
-
return this.
|
|
101
|
+
endsWith(parameter: string, constant: any, caseSensitive = true) {
|
|
102
|
+
return this.simple(EXPRESSION_TYPE.endsWith, parameter, constant, caseSensitive);
|
|
168
103
|
}
|
|
169
104
|
|
|
170
105
|
/**
|
|
171
106
|
* Ends the definition of the current WhereQuery. You need to call this method in order to continue with the definition of the parent {@link QueryBase}. All other `WhereQuery` methods return the current instance of `WhereQuery` to allow chaining.
|
|
172
|
-
* @method done
|
|
173
|
-
* @memberOf WhereQuery.prototype
|
|
174
|
-
* @returns {Query}
|
|
175
107
|
*/
|
|
176
|
-
done() {
|
|
108
|
+
done(): QueryType {
|
|
177
109
|
if (this.parent instanceof WhereQuery) {
|
|
178
|
-
this.parent.
|
|
110
|
+
this.parent.addComplexExpression(this);
|
|
179
111
|
// TODO: If has and() || or() must call done() twice
|
|
180
|
-
if (this.expression.getType() ===
|
|
112
|
+
if (this.expression.getType() === EXPRESSION_TYPE.not)
|
|
181
113
|
return this.parent;
|
|
182
114
|
}
|
|
183
115
|
|
|
184
116
|
return this.parent;
|
|
185
117
|
}
|
|
186
118
|
|
|
187
|
-
|
|
119
|
+
getExpression(): ComplexExpression {
|
|
188
120
|
return this.expression;
|
|
189
121
|
}
|
|
190
122
|
|
|
191
|
-
private
|
|
192
|
-
|
|
123
|
+
private simple(type: string, parameter: string, constant: any, caseSensitive = true): WhereQuery<QueryType> {
|
|
124
|
+
const currentExpr = new BinaryExpression(type, parameter, constant, caseSensitive);
|
|
125
|
+
const subExpressions = this.expression.getExpressions();
|
|
126
|
+
subExpressions.push(currentExpr);
|
|
127
|
+
|
|
128
|
+
if (this.expression.getType() === EXPRESSION_TYPE.not && subExpressions.length > 1)
|
|
129
|
+
throw new Error("Invalid operators count!");
|
|
130
|
+
|
|
131
|
+
return this;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
private addComplexExpression(subQuery: WhereQuery<QueryType>): void {
|
|
135
|
+
const subExpression = subQuery.getExpression();
|
|
193
136
|
this.expression.getExpressions().push(subExpression);
|
|
194
137
|
}
|
|
195
138
|
}
|
package/src/constants.ts
CHANGED
|
@@ -1,41 +1,60 @@
|
|
|
1
|
-
const
|
|
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
|
-
|
|
1
|
+
export const EXPRESSION_TYPE = {
|
|
2
|
+
query: 1,
|
|
3
|
+
where: 100,
|
|
4
|
+
and: 'and',
|
|
5
|
+
or: 'or',
|
|
6
|
+
not: 'not',
|
|
7
|
+
eq: 'eq',
|
|
8
|
+
ne: 'ne',
|
|
9
|
+
lt: 'lt',
|
|
10
|
+
le: 'le',
|
|
11
|
+
gt: 'gt',
|
|
12
|
+
ge: 'ge',
|
|
13
|
+
any: 'any',
|
|
14
|
+
contains: 'contains',
|
|
15
|
+
startsWith: 'startsWith',
|
|
16
|
+
endsWith: 'endsWith'
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const ODATA_PARAMS = {
|
|
20
|
+
$filter: '$filter',
|
|
21
|
+
$select: '$select',
|
|
22
|
+
$expand: '$expand',
|
|
23
|
+
$orderby: '$orderby',
|
|
24
|
+
$skip: '$skip',
|
|
25
|
+
$top: '$top',
|
|
26
|
+
$count: '$count',
|
|
27
|
+
$search: '$search'
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const SF_PARAMS = {
|
|
31
|
+
provider: 'sf_provider',
|
|
32
|
+
culture: 'sf_culture',
|
|
33
|
+
siteId: 'sf_site',
|
|
34
|
+
fallbackParams: "sf_fallback_prop_names",
|
|
35
|
+
parentId: "parentId"
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const HEADER_NAMES = {
|
|
39
|
+
contentType: "Content-Type",
|
|
40
|
+
authorization: "Authorization",
|
|
41
|
+
contentEncoding: "Content-Encoding",
|
|
42
|
+
operation: "X-Operation",
|
|
43
|
+
properties: "X-Sf-Properties",
|
|
44
|
+
fileName: "X-File-Name",
|
|
45
|
+
serviceRequest: "X-SF-Service-Request",
|
|
46
|
+
choicesBinaryRepresentation: "X-SF-Binary-Choice-Representation",
|
|
47
|
+
integrationMode: "X-SF-Integration-Mode"
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const HTTP_METHODS = {
|
|
51
|
+
get: "GET",
|
|
52
|
+
put: "PUT",
|
|
53
|
+
post: "POST",
|
|
54
|
+
patch: "PATCH",
|
|
55
|
+
delete: "DELETE"
|
|
39
56
|
};
|
|
40
57
|
|
|
41
|
-
export
|
|
58
|
+
export const CONTENT_TYPES = {
|
|
59
|
+
json: "application/json"
|
|
60
|
+
}
|
package/src/utils.ts
CHANGED
|
@@ -9,11 +9,15 @@
|
|
|
9
9
|
|
|
10
10
|
static isBlob(obj: any): boolean {
|
|
11
11
|
return obj instanceof Blob;
|
|
12
|
-
}
|
|
12
|
+
}
|
|
13
13
|
|
|
14
14
|
static isNumber(value: any): boolean {
|
|
15
15
|
return typeof value === 'number' && isFinite(value);
|
|
16
|
-
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static isFunction(func: any): boolean {
|
|
19
|
+
return typeof func === 'function';
|
|
20
|
+
}
|
|
17
21
|
|
|
18
22
|
static serializeToJSON(data): string {
|
|
19
23
|
if (!utils.isString(data) && !this.isBlob(data)) {
|
|
@@ -28,12 +32,12 @@
|
|
|
28
32
|
return null;
|
|
29
33
|
}
|
|
30
34
|
|
|
31
|
-
|
|
35
|
+
const number = Number(data);
|
|
32
36
|
if (!isNaN(number)) {
|
|
33
37
|
return number;
|
|
34
38
|
}
|
|
35
39
|
|
|
36
|
-
|
|
40
|
+
let result = null;
|
|
37
41
|
|
|
38
42
|
try {
|
|
39
43
|
result = JSON.parse(data);
|
|
@@ -45,13 +49,13 @@
|
|
|
45
49
|
return result;
|
|
46
50
|
}
|
|
47
51
|
|
|
48
|
-
static convertDateFieldToISOString
|
|
52
|
+
static convertDateFieldToISOString(data: object): object {
|
|
49
53
|
/*
|
|
50
54
|
TODOSDK: when write tests for this try to use
|
|
51
55
|
"Object.keys(obj).forEach(function(){})",
|
|
52
56
|
Phantomjs does not recognize "for..in" operator.
|
|
53
57
|
*/
|
|
54
|
-
for (
|
|
58
|
+
for (const obj in data) {
|
|
55
59
|
if (data[obj] instanceof Date) {
|
|
56
60
|
data[obj] = data[obj].toISOString();
|
|
57
61
|
}
|
|
@@ -64,19 +68,19 @@
|
|
|
64
68
|
return Math.floor((1 + Math.random()) * 0x10000).toString(16).substr(1);
|
|
65
69
|
}
|
|
66
70
|
|
|
67
|
-
static addTrailingSlash(url) {
|
|
71
|
+
static addTrailingSlash(url: string): string {
|
|
68
72
|
url = utils.removeSlashes(url);
|
|
69
73
|
url += '/';
|
|
70
74
|
return url;
|
|
71
75
|
}
|
|
72
76
|
|
|
73
|
-
static removeSlashes(url) {
|
|
74
|
-
|
|
75
|
-
|
|
77
|
+
static removeSlashes(url: string) {
|
|
78
|
+
let ret = url;
|
|
79
|
+
const fistChar = ret.substr(0, 1);
|
|
76
80
|
if (fistChar == '/')
|
|
77
81
|
ret = ret.substr(1);
|
|
78
82
|
|
|
79
|
-
|
|
83
|
+
const lastChar = ret.substr(-1);
|
|
80
84
|
if (lastChar == '/')
|
|
81
85
|
ret = ret.substr(0, ret.length - 1);
|
|
82
86
|
|
|
@@ -84,11 +88,10 @@
|
|
|
84
88
|
}
|
|
85
89
|
|
|
86
90
|
static clone(from: any, to = {}, action: Function = null): any {
|
|
87
|
-
|
|
88
91
|
if (!to)
|
|
89
92
|
to = {};
|
|
90
93
|
|
|
91
|
-
for (
|
|
94
|
+
for (const property in from) {
|
|
92
95
|
if (from[property] && from[property].constructor && from[property].constructor === Object && typeof from[property] == 'function') {
|
|
93
96
|
to[property] = to[property]|| { };
|
|
94
97
|
arguments.callee(to[property], from[property]);
|
|
@@ -104,7 +107,7 @@
|
|
|
104
107
|
}
|
|
105
108
|
|
|
106
109
|
private static _parseDateProperties(data) {
|
|
107
|
-
for (
|
|
110
|
+
for (const obj in data) {
|
|
108
111
|
// TODO
|
|
109
112
|
if (data[obj] instanceof Array || (data[obj] instanceof Object && <any>!data[obj] instanceof Function))
|
|
110
113
|
this._parseDateProperties(data[obj]);
|
package/template.html
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
var query = new Sitefinity.Query();
|
|
26
|
+
var query = new Sitefinity.Sitefinity.Query();
|
|
27
27
|
|
|
28
28
|
var query0 = query.where().and().endsWith("Title", "Record").done().or().startsWith('Title', 'asd').done().done();
|
|
29
29
|
var query1 = query.where().or().endsWith("Record", "Title").ne('age', '15').eq('Content', 'test').done().done();
|
|
@@ -64,10 +64,10 @@
|
|
|
64
64
|
|
|
65
65
|
var entitySet = "newsitems";
|
|
66
66
|
|
|
67
|
+
//Replace 'sitefinityUrl' with the location of the server you are using
|
|
67
68
|
var sitefinityUrl = "http://localhost"
|
|
68
|
-
//Replace my_sandbox_location with the location of the server you are using
|
|
69
69
|
var options = {
|
|
70
|
-
|
|
70
|
+
baseUrl: sitefinityUrl + "/api/default/",
|
|
71
71
|
handlers: {
|
|
72
72
|
failureCb: function() {
|
|
73
73
|
console.log("Global error occured");
|
|
@@ -78,19 +78,9 @@
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
// operation data
|
|
82
|
-
var action = {
|
|
83
|
-
action: "Publish",
|
|
84
|
-
actionParameters: {
|
|
85
|
-
Title: "SomeTitle",
|
|
86
|
-
PublicationDate: "2016-06-21T06:26:32.7439661Z",
|
|
87
|
-
ExpirationDate: "2016-06-21T06:26:32.7439661Z"
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
|
|
91
81
|
// Sitefinity object
|
|
92
|
-
var sf = new Sitefinity(options);
|
|
93
|
-
sf.
|
|
82
|
+
var sf = new Sitefinity.Sitefinity(options);
|
|
83
|
+
sf.setToken("");
|
|
94
84
|
|
|
95
85
|
var inputElement = document.getElementById('getGuid');
|
|
96
86
|
var that = this;
|
|
@@ -113,13 +103,23 @@
|
|
|
113
103
|
});
|
|
114
104
|
}
|
|
115
105
|
document.getElementById("containerErr").innerHTML = JSON.stringify(data.responseText);
|
|
116
|
-
}
|
|
106
|
+
};
|
|
117
107
|
|
|
118
108
|
var dataOptions = {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
109
|
+
entitySet,
|
|
110
|
+
provider: "OpenAccessDataProvider",
|
|
111
|
+
culture: "en"
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
// operation data
|
|
115
|
+
var action = {
|
|
116
|
+
action: "Publish",
|
|
117
|
+
actionParameters: {
|
|
118
|
+
Title: "SomeTitle",
|
|
119
|
+
PublicationDate: "2016-06-21T06:26:32.7439661Z",
|
|
120
|
+
ExpirationDate: "2016-06-21T06:26:32.7439661Z"
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
123
|
|
|
124
124
|
function requestGet() {
|
|
125
125
|
var data = sf.data(dataOptions);
|
|
@@ -129,10 +129,10 @@
|
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
function requestGetCount(
|
|
132
|
+
function requestGetCount() {
|
|
133
133
|
var data = sf.data(dataOptions);
|
|
134
134
|
data.get({
|
|
135
|
-
query: query.count(
|
|
135
|
+
query: query.count(),
|
|
136
136
|
successCb: successCb
|
|
137
137
|
});
|
|
138
138
|
}
|
|
@@ -151,7 +151,7 @@
|
|
|
151
151
|
var data = sf.data(dataOptions);
|
|
152
152
|
data.getRelated({
|
|
153
153
|
key: getGuid(),
|
|
154
|
-
|
|
154
|
+
property: "Tags",
|
|
155
155
|
successCb: successCb,
|
|
156
156
|
failureCb: failureCb
|
|
157
157
|
});
|
|
@@ -223,7 +223,7 @@
|
|
|
223
223
|
var createRefLink = "http://localhost:8097/api/odata/flatTaxa(" + getRelatedGuid() + ")";
|
|
224
224
|
data.createRelated({
|
|
225
225
|
key: getGuid(),
|
|
226
|
-
|
|
226
|
+
property: "Tags",
|
|
227
227
|
link: createRefLink,
|
|
228
228
|
successCb: successCb,
|
|
229
229
|
failureCb: failureCb
|
|
@@ -234,7 +234,7 @@
|
|
|
234
234
|
var data = sf.data(dataOptions);
|
|
235
235
|
data.destroyRelated({
|
|
236
236
|
key: getGuid(),
|
|
237
|
-
|
|
237
|
+
property: "Tags",
|
|
238
238
|
successCb: successCb,
|
|
239
239
|
failureCb: failureCb
|
|
240
240
|
});
|
|
@@ -347,7 +347,7 @@
|
|
|
347
347
|
result = btoa(result)
|
|
348
348
|
|
|
349
349
|
var data = sf.data({
|
|
350
|
-
|
|
350
|
+
entitySet: "images"
|
|
351
351
|
});
|
|
352
352
|
data.upload({ /* POST */
|
|
353
353
|
data: {
|
|
@@ -393,13 +393,12 @@
|
|
|
393
393
|
return inputElement.value;
|
|
394
394
|
}
|
|
395
395
|
|
|
396
|
-
function login(
|
|
397
|
-
var url = sitefinityUrl + "/Sitefinity/
|
|
396
|
+
function login() {
|
|
397
|
+
var url = sitefinityUrl + "/Sitefinity/oauth/token";
|
|
398
398
|
var data = {
|
|
399
|
-
username:
|
|
400
|
-
password:
|
|
399
|
+
username: "",
|
|
400
|
+
password: "",
|
|
401
401
|
grant_type: "password",
|
|
402
|
-
scope: "openid",
|
|
403
402
|
client_id: "iris",
|
|
404
403
|
client_secret: "secret"
|
|
405
404
|
};
|
|
@@ -425,7 +424,7 @@
|
|
|
425
424
|
value: token.access_token
|
|
426
425
|
};
|
|
427
426
|
|
|
428
|
-
sf.
|
|
427
|
+
sf.setToken(tokenObj);
|
|
429
428
|
}
|
|
430
429
|
});
|
|
431
430
|
|
|
@@ -437,14 +436,13 @@
|
|
|
437
436
|
</script>
|
|
438
437
|
Usage: <br /><code>
|
|
439
438
|
<b>
|
|
440
|
-
sf = new Sitefinity(options);<br />data = sf.data(
|
|
439
|
+
sf = new Sitefinity(options);<br />data = sf.data(dataOptions);<br />data.get(); data.destroy ...
|
|
441
440
|
<br />data.batch(successCb, failureCb).get().Update...done(); content id's starts from 0 to n ('get' is 0 'update' is 1 etc.).
|
|
442
441
|
</b>
|
|
443
442
|
</code><br /><br />
|
|
444
443
|
<input type="button" value="login" onclick="login()" />
|
|
445
444
|
<input type="button" value="requestGet" onclick="requestGet()" />
|
|
446
|
-
<input type="button" value="
|
|
447
|
-
<input type="button" value="requestGetCount" onclick="requestGetCount(false)" />
|
|
445
|
+
<input type="button" value="requestGetCount" onclick="requestGetCount()" />
|
|
448
446
|
<input type="button" value="requestGetSingle" onclick="requestGetSingle()" />
|
|
449
447
|
<input type="button" value="requestGetRelated" onclick="requestGetRelated()" />
|
|
450
448
|
<input type="button" value="requestUpdate" onclick="requestUpdate()" />
|
package/tsconfig.json
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
"target": "es5",
|
|
4
4
|
"module": "commonjs",
|
|
5
5
|
"moduleResolution": "node",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"outDir": "dist",
|
|
6
8
|
"sourceMap": true,
|
|
7
9
|
"emitDecoratorMetadata": true,
|
|
8
10
|
"experimentalDecorators": true,
|
|
@@ -11,7 +13,7 @@
|
|
|
11
13
|
"noEmitHelpers": true,
|
|
12
14
|
"importHelpers": true,
|
|
13
15
|
"noUnusedLocals": true,
|
|
14
|
-
"noEmit":
|
|
16
|
+
"noEmit": false,
|
|
15
17
|
"typeRoots": [
|
|
16
18
|
"node_modules/@types"
|
|
17
19
|
],
|
|
@@ -19,5 +21,10 @@
|
|
|
19
21
|
"es6",
|
|
20
22
|
"dom"
|
|
21
23
|
]
|
|
24
|
+
},
|
|
25
|
+
"typedocOptions": {
|
|
26
|
+
"entryPoints": [ "./src" ],
|
|
27
|
+
"out": "dist/docs",
|
|
28
|
+
"entryPointStrategy": "expand"
|
|
22
29
|
}
|
|
23
30
|
}
|
package/type.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
major
|
package/version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
1.0.0
|