@progress/sitefinity-webservices-sdk 0.3.1 → 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.
Files changed (201) hide show
  1. package/.eslintignore +4 -0
  2. package/.eslintrc.js +19 -0
  3. package/ci/pipelines/ci.yml +219 -0
  4. package/config/helpers.js +0 -6
  5. package/config/webpack.common.js +1 -3
  6. package/config/webpack.dev.js +2 -9
  7. package/config/webpack.prod.js +5 -6
  8. package/dist/docs/.nojekyll +1 -0
  9. package/dist/docs/assets/highlight.css +57 -0
  10. package/dist/docs/assets/icons.css +1043 -0
  11. package/dist/docs/assets/icons.png +0 -0
  12. package/dist/docs/assets/icons@2x.png +0 -0
  13. package/dist/docs/assets/main.js +52 -0
  14. package/dist/docs/assets/search.js +1 -0
  15. package/dist/docs/assets/style.css +1413 -0
  16. package/dist/docs/assets/{images/widgets.png → widgets.png} +0 -0
  17. package/dist/docs/assets/{images/widgets@2x.png → widgets@2x.png} +0 -0
  18. package/dist/docs/classes/BlobBuilder.BlobBuilder-1.html +7 -0
  19. package/dist/docs/classes/Data.Data-1.html +65 -0
  20. package/dist/docs/classes/Expression.BinaryExpression.html +1 -0
  21. package/dist/docs/classes/Expression.ComplexExpression.html +1 -0
  22. package/dist/docs/classes/Expression.ExpressionBase.html +1 -0
  23. package/dist/docs/classes/OrderProperty.OrderProperty-1.html +1 -0
  24. package/dist/docs/classes/Query.Query-1.html +33 -0
  25. package/dist/docs/classes/QueryBase.QueryBase-1.html +7 -0
  26. package/dist/docs/classes/QueryBuilder.QueryBuilder-1.html +1 -0
  27. package/dist/docs/classes/Requests_BatchRequest.BatchRequest.html +17 -0
  28. package/dist/docs/classes/Requests_BatchRequest.Transaction.html +17 -0
  29. package/dist/docs/classes/Requests_ExecutableRequest.ExecutableRequest.html +1 -0
  30. package/dist/docs/classes/Requests_Request.CreateRelatedRequest.html +1 -0
  31. package/dist/docs/classes/Requests_Request.CreateRequest.html +1 -0
  32. package/dist/docs/classes/Requests_Request.DeleteRelatedByIdRequest.html +1 -0
  33. package/dist/docs/classes/Requests_Request.DeleteRelatedRequest.html +1 -0
  34. package/dist/docs/classes/Requests_Request.DeleteRequest.html +1 -0
  35. package/dist/docs/classes/Requests_Request.GetByIdRequest.html +1 -0
  36. package/dist/docs/classes/Requests_Request.GetRelatedByIdRequest.html +1 -0
  37. package/dist/docs/classes/Requests_Request.GetRelatedRequest.html +1 -0
  38. package/dist/docs/classes/Requests_Request.GetRequest.html +1 -0
  39. package/dist/docs/classes/Requests_Request.UpdateRequest.html +1 -0
  40. package/dist/docs/classes/Requests_Request.UploadRequest.html +1 -0
  41. package/dist/docs/classes/Requests_RequestBase.RequestBase.html +1 -0
  42. package/dist/docs/classes/Requests_RequestFactory.RequestFactory.html +1 -0
  43. package/dist/docs/classes/Sitefinity.Sitefinity-1.html +5 -0
  44. package/dist/docs/classes/WhereQuery.WhereQuery-1.html +31 -0
  45. package/dist/docs/classes/utils.utils-1.html +1 -0
  46. package/dist/docs/index.html +54 -242
  47. package/dist/docs/interfaces/Data.CreateRelatedRequestOptions.html +1 -0
  48. package/dist/docs/interfaces/Data.CreateRequestOptions.html +1 -0
  49. package/dist/docs/interfaces/Data.OperationsRequestOptions.html +1 -0
  50. package/dist/docs/interfaces/Data.PropertyRequestOptions.html +1 -0
  51. package/dist/docs/interfaces/Data.RequestOptionsBase.html +1 -0
  52. package/dist/docs/interfaces/Data.SingleRelatedItemRequestOptions.html +1 -0
  53. package/dist/docs/interfaces/Data.UpdateRequestOptions.html +1 -0
  54. package/dist/docs/interfaces/Data.UploadRequestOptions.html +1 -0
  55. package/dist/docs/interfaces/Requests_BatchRequest.BatchCreateRelatedRequestOptions.html +1 -0
  56. package/dist/docs/interfaces/Requests_BatchRequest.BatchCreateRequestOptions.html +1 -0
  57. package/dist/docs/interfaces/Requests_BatchRequest.BatchPropertyRequestOptions.html +1 -0
  58. package/dist/docs/interfaces/Requests_BatchRequest.BatchRequestOptionsBase.html +1 -0
  59. package/dist/docs/interfaces/Requests_BatchRequest.BatchRequestOptionsExtended.html +1 -0
  60. package/dist/docs/interfaces/Requests_BatchRequest.BatchSingleItemRequestOptions.html +1 -0
  61. package/dist/docs/interfaces/Requests_BatchRequest.BatchSingleRelatedItemRequestOptions.html +1 -0
  62. package/dist/docs/interfaces/Requests_BatchRequest.BatchUpdateRequestOptions.html +1 -0
  63. package/dist/docs/interfaces/Requests_ExecutableRequest.ResponseHandlers.html +5 -0
  64. package/dist/docs/interfaces/Requests_Request.PostRequestOptionsExtended.html +1 -0
  65. package/dist/docs/interfaces/Requests_Request.PutRequestOptionsExtended.html +1 -0
  66. package/dist/docs/interfaces/Requests_Request.RelatedByIdRequestOptionsExtended.html +1 -0
  67. package/dist/docs/interfaces/Requests_Request.RelatedRequestOptionsExtended.html +1 -0
  68. package/dist/docs/interfaces/Requests_Request.UploadRequestOptionsExtended.html +1 -0
  69. package/dist/docs/interfaces/Requests_RequestBase.RequestOptionsBaseExtended.html +1 -0
  70. package/dist/docs/interfaces/Sitefinity.SDKOptions.html +9 -0
  71. package/dist/docs/interfaces/Sitefinity.Token.html +1 -0
  72. package/dist/docs/interfaces/Sitefinity.TypeOptions.html +13 -0
  73. package/dist/docs/modules/BlobBuilder.html +1 -0
  74. package/dist/docs/modules/Data.html +1 -0
  75. package/dist/docs/modules/Expression.html +1 -0
  76. package/dist/docs/modules/OrderProperty.html +1 -0
  77. package/dist/docs/modules/Query.html +1 -0
  78. package/dist/docs/modules/QueryBase.html +1 -0
  79. package/dist/docs/modules/QueryBuilder.html +1 -0
  80. package/dist/docs/modules/Requests_BatchRequest.html +1 -0
  81. package/dist/docs/modules/Requests_ExecutableRequest.html +1 -0
  82. package/dist/docs/modules/Requests_Request.html +1 -0
  83. package/dist/docs/modules/Requests_RequestBase.html +1 -0
  84. package/dist/docs/modules/Requests_RequestFactory.html +1 -0
  85. package/dist/docs/modules/Sitefinity.html +1 -0
  86. package/dist/docs/modules/WhereQuery.html +1 -0
  87. package/dist/docs/modules/constants.html +1 -0
  88. package/dist/docs/modules/utils.html +1 -0
  89. package/dist/docs/modules.html +1 -0
  90. package/dist/samples.html +33 -81
  91. package/dist/sitefinity-webservices-sdk.d.ts +16 -0
  92. package/dist/sitefinity-webservices-sdk.js +1141 -1737
  93. package/dist/sitefinity-webservices-sdk.js.map +1 -1
  94. package/dist/sitefinity-webservices-sdk.min.js +2 -16
  95. package/dist/sitefinity-webservices-sdk.min.js.LICENSE.txt +14 -0
  96. package/dist/src/BlobBuilder.d.ts +14 -0
  97. package/dist/src/Data.d.ts +144 -0
  98. package/dist/src/Expression.d.ts +19 -0
  99. package/dist/src/OrderProperty.d.ts +8 -0
  100. package/dist/src/Query.d.ts +59 -0
  101. package/dist/src/QueryBase.d.ts +18 -0
  102. package/dist/src/QueryBuilder.d.ts +13 -0
  103. package/dist/src/Requests/BatchRequest.d.ts +146 -0
  104. package/dist/src/Requests/ExecutableRequest.d.ts +20 -0
  105. package/dist/src/Requests/Request.d.ts +88 -0
  106. package/dist/src/Requests/RequestBase.d.ts +28 -0
  107. package/dist/src/Requests/RequestFactory.d.ts +22 -0
  108. package/dist/src/Sitefinity.d.ts +66 -0
  109. package/dist/src/WhereQuery.d.ts +68 -0
  110. package/dist/src/constants.d.ts +55 -0
  111. package/dist/src/utils.d.ts +16 -0
  112. package/karma.conf.js +29 -0
  113. package/package-lock.json +16108 -6805
  114. package/package.json +28 -10
  115. package/sitefinity-webservices-sdk.ts +16 -0
  116. package/src/BlobBuilder.ts +7 -12
  117. package/src/Data.spec.ts +160 -0
  118. package/src/Data.ts +132 -207
  119. package/src/Expression.ts +0 -1
  120. package/src/OrderProperty.ts +4 -5
  121. package/src/Query.ts +52 -78
  122. package/src/QueryBase.ts +21 -47
  123. package/src/QueryBuilder.ts +64 -82
  124. package/src/Requests/BatchRequest.ts +312 -335
  125. package/src/Requests/ExecutableRequest.ts +46 -73
  126. package/src/Requests/Request.ts +134 -260
  127. package/src/Requests/RequestBase.ts +161 -0
  128. package/src/Requests/RequestFactory.ts +36 -54
  129. package/src/Requests/request.spec.ts +92 -0
  130. package/src/Sitefinity.spec.ts +418 -0
  131. package/src/Sitefinity.ts +77 -146
  132. package/src/WhereQuery.ts +52 -112
  133. package/src/constants.ts +58 -39
  134. package/src/utils.ts +17 -14
  135. package/template.html +33 -35
  136. package/tsconfig.json +8 -1
  137. package/type.txt +1 -1
  138. package/version.txt +1 -1
  139. package/config/html.conf.json +0 -5
  140. package/dist/docs/assets/css/main.css +0 -865
  141. package/dist/docs/assets/css/main.css.map +0 -7
  142. package/dist/docs/assets/images/icons.png +0 -0
  143. package/dist/docs/assets/images/icons@2x.png +0 -0
  144. package/dist/docs/assets/js/main.js +0 -5
  145. package/dist/docs/assets/js/search.js +0 -3
  146. package/dist/docs/classes/_authentication_.authentication.html +0 -527
  147. package/dist/docs/classes/_blobbuilder_.blobbuilder.html +0 -351
  148. package/dist/docs/classes/_data_.data.html +0 -974
  149. package/dist/docs/classes/_expression_.binaryexpression.html +0 -450
  150. package/dist/docs/classes/_expression_.complexexpression.html +0 -374
  151. package/dist/docs/classes/_expression_.expressionbase.html +0 -336
  152. package/dist/docs/classes/_orderproperty_.orderproperty.html +0 -381
  153. package/dist/docs/classes/_query_.query.html +0 -896
  154. package/dist/docs/classes/_querybase_.querybase.html +0 -518
  155. package/dist/docs/classes/_querybuilder_.querybuilder.html +0 -496
  156. package/dist/docs/classes/_requests_batchrequest_.batchrequest.html +0 -1511
  157. package/dist/docs/classes/_requests_batchrequest_.transaction.html +0 -804
  158. package/dist/docs/classes/_requests_executablerequest_.executablerequest.html +0 -549
  159. package/dist/docs/classes/_requests_request_.createrelatedrequest.html +0 -689
  160. package/dist/docs/classes/_requests_request_.createrequest.html +0 -680
  161. package/dist/docs/classes/_requests_request_.deleterelatedbyidrequest.html +0 -687
  162. package/dist/docs/classes/_requests_request_.deleterelatedrequest.html +0 -673
  163. package/dist/docs/classes/_requests_request_.deleterequest.html +0 -666
  164. package/dist/docs/classes/_requests_request_.getbyidrequest.html +0 -666
  165. package/dist/docs/classes/_requests_request_.getrelatedbyidrequest.html +0 -687
  166. package/dist/docs/classes/_requests_request_.getrelatedrequest.html +0 -673
  167. package/dist/docs/classes/_requests_request_.getrequest.html +0 -658
  168. package/dist/docs/classes/_requests_request_.requestbase.html +0 -687
  169. package/dist/docs/classes/_requests_request_.updaterequest.html +0 -686
  170. package/dist/docs/classes/_requests_request_.uploadrequest.html +0 -715
  171. package/dist/docs/classes/_requests_requestfactory_.requestfactory.html +0 -724
  172. package/dist/docs/classes/_sitefinity_.sitefinity.html +0 -521
  173. package/dist/docs/classes/_utils_.utils.html +0 -597
  174. package/dist/docs/classes/_wherequery_.wherequery.html +0 -992
  175. package/dist/docs/globals.html +0 -238
  176. package/dist/docs/modules/_authentication_.html +0 -225
  177. package/dist/docs/modules/_blobbuilder_.html +0 -225
  178. package/dist/docs/modules/_constants_.html +0 -528
  179. package/dist/docs/modules/_contenttypes_.html +0 -248
  180. package/dist/docs/modules/_data_.html +0 -225
  181. package/dist/docs/modules/_expression_.html +0 -233
  182. package/dist/docs/modules/_headers_.html +0 -328
  183. package/dist/docs/modules/_httpmethods_.html +0 -288
  184. package/dist/docs/modules/_main_.html +0 -209
  185. package/dist/docs/modules/_orderproperty_.html +0 -225
  186. package/dist/docs/modules/_query_.html +0 -225
  187. package/dist/docs/modules/_querybase_.html +0 -225
  188. package/dist/docs/modules/_querybuilder_.html +0 -247
  189. package/dist/docs/modules/_requests_batchrequest_.html +0 -265
  190. package/dist/docs/modules/_requests_executablerequest_.html +0 -296
  191. package/dist/docs/modules/_requests_request_.html +0 -333
  192. package/dist/docs/modules/_requests_requestfactory_.html +0 -247
  193. package/dist/docs/modules/_sitefinity_.html +0 -225
  194. package/dist/docs/modules/_utils_.html +0 -225
  195. package/dist/docs/modules/_wherequery_.html +0 -247
  196. package/dist/index.html +0 -474
  197. package/src/Authentication.ts +0 -96
  198. package/src/ContentTypes.ts +0 -5
  199. package/src/Headers.ts +0 -12
  200. package/src/HttpMethods.ts +0 -9
  201. package/src/main.ts +0 -2
package/src/WhereQuery.ts CHANGED
@@ -1,198 +1,138 @@
1
1
  import { ComplexExpression, BinaryExpression } from './Expression';
2
- const OperatorType = require('./constants').default.ExpressionType;
2
+ import { EXPRESSION_TYPE } from "./constants";
3
3
 
4
4
  /**
5
- * @classdesc A fluent API operation for creating a filter for a query by chaining different rules.
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
- constructor(private parent: any, type: string = OperatorType.and) {
9
+
10
+ constructor(private parent: QueryType, type: string = EXPRESSION_TYPE.and) {
13
11
  this.expression = new ComplexExpression(type, []);
14
12
  }
15
13
 
16
14
  /**
17
15
  * Adds an `and` clause to the current condition and returns it for further chaining.
18
- * @method and
19
- * @memberOf WhereQuery.prototype
20
- * @returns {WhereQuery}
21
16
  */
22
- and(): WhereQuery {
23
- return new WhereQuery(this, OperatorType.and);
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, OperatorType.or);
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, OperatorType.any);
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, OperatorType.not);
52
- }
53
-
54
- private _simple(type: string, parameter: string, constant: any, caseSensitive: boolean = true): WhereQuery {
55
- var currentExpr = new BinaryExpression(type, parameter, constant, caseSensitive);
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._simple(OperatorType.eq, parameter, constant);
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._simple(OperatorType.ne, parameter, constant);
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._simple(OperatorType.gt, parameter, constant);
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._simple(OperatorType.ge, parameter, constant);
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._simple(OperatorType.lt, parameter, constant);
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._simple(OperatorType.le, parameter, constant);
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 {boolean} caseSensitive A flag indicating if tolower should be applied to the parameter
138
- * @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.
139
- * @returns {WhereQuery}
140
86
  */
141
- startsWith(parameter: string, constant: any, caseSensitive: boolean = true): WhereQuery {
142
- return this._simple(OperatorType.startsWith, parameter, constant, caseSensitive);
87
+ startsWith(parameter: string, constant: any, caseSensitive = true) {
88
+ return this.simple(EXPRESSION_TYPE.startsWith, parameter, constant, caseSensitive);
143
89
  }
144
90
 
145
91
  /**
146
92
  * Adds a condition that a field value must *contain* a specified string.
147
- * @method startsWith
148
- * @memberOf WhereQuery.prototype
149
- * @param {string} field Field name.
150
- * @param {string} value The string that the field should start with.
151
- * @param {boolean} caseSensitive A flag indicating if tolower should be applied to the parameter
152
- * @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.
153
- * @returns {WhereQuery}
154
93
  */
155
- contains(parameter: string, constant: any, caseSensitive: boolean = true) {
156
- return this._simple(OperatorType.contains, parameter, constant, caseSensitive);
94
+ contains(parameter: string, constant: any, caseSensitive = true) {
95
+ return this.simple(EXPRESSION_TYPE.contains, parameter, constant, caseSensitive);
157
96
  }
158
97
 
159
98
  /**
160
99
  * Adds a condition that a field value must *end* with a specified string.
161
- * @method endsWith
162
- * @memberOf WhereQuery.prototype
163
- * @param {string} field Field name.
164
- * @param {string} value The string that the field should end with.
165
- * @param {boolean} caseSensitive A flag indicating if tolower should be applied to the parameter
166
- * @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.
167
- * @returns {WhereQuery}
168
100
  */
169
- endsWith(parameter: string, constant: any, caseSensitive: boolean = true) {
170
- return this._simple(OperatorType.endsWith, parameter, constant, caseSensitive);
101
+ endsWith(parameter: string, constant: any, caseSensitive = true) {
102
+ return this.simple(EXPRESSION_TYPE.endsWith, parameter, constant, caseSensitive);
171
103
  }
172
104
 
173
105
  /**
174
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.
175
- * @method done
176
- * @memberOf WhereQuery.prototype
177
- * @returns {Query}
178
107
  */
179
- done() {
108
+ done(): QueryType {
180
109
  if (this.parent instanceof WhereQuery) {
181
- this.parent._addComplexExpression(this);
110
+ this.parent.addComplexExpression(this);
182
111
  // TODO: If has and() || or() must call done() twice
183
- if (this.expression.getType() === OperatorType.not)
112
+ if (this.expression.getType() === EXPRESSION_TYPE.not)
184
113
  return this.parent;
185
114
  }
186
115
 
187
116
  return this.parent;
188
117
  }
189
118
 
190
- _getExpression() {
119
+ getExpression(): ComplexExpression {
191
120
  return this.expression;
192
121
  }
193
122
 
194
- private _addComplexExpression(subQuery): void {
195
- var subExpression = subQuery._getExpression();
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();
196
136
  this.expression.getExpressions().push(subExpression);
197
137
  }
198
138
  }
package/src/constants.ts CHANGED
@@ -1,41 +1,60 @@
1
- const constants = {
2
- ExpressionType: {
3
- query: 1,
4
- where: 100,
5
- and: 'and',
6
- or: 'or',
7
- not: 'not',
8
- eq: 'eq',
9
- ne: 'ne',
10
- lt: 'lt',
11
- le: 'le',
12
- gt: 'gt',
13
- ge: 'ge',
14
- any: 'any',
15
- /*isin: 126,
16
- notin: 127,
17
- all: 128,
18
- size: 129,
19
- regex: 130,*/
20
- contains: 'contains',
21
- startsWith: 'startsWith',
22
- endsWith: 'endsWith'
23
- },
24
- ODataParams: {
25
- $filter: '$filter',
26
- $select: '$select',
27
- $expand: '$expand',
28
- $orderby: '$orderby',
29
- $skip: '$skip',
30
- $top: '$top',
31
- $count: '$count',
32
- $search: '$search'
33
- },
34
- SfParams: {
35
- provider: 'sf_provider',
36
- culture: 'sf_culture',
37
- siteId: 'sf_site'
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 default constants;
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
- var number = Number(data);
35
+ const number = Number(data);
32
36
  if (!isNaN(number)) {
33
37
  return number;
34
38
  }
35
39
 
36
- var result = null;
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 = function (data) {
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 (let obj in data) {
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
- var ret = url;
75
- var fistChar = ret.substr(0, 1);
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
- var lastChar = ret.substr(-1);
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 (var property in from) {
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 (var obj in data) {
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
- serviceUrl: sitefinityUrl + "/api/default/",
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.authentication.setToken("");
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
- urlName: entitySet,
120
- providerName: "OpenAccessDataProvider",
121
- cultureName: "en"
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(inline) {
132
+ function requestGetCount() {
133
133
  var data = sf.data(dataOptions);
134
134
  data.get({
135
- query: query.count(inline),
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
- navigationProperty: "Tags",
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
- navigationProperty: "Tags",
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
- navigationProperty: "Tags",
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
- urlName: "images"
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(username, password) {
397
- var url = sitefinityUrl + "/Sitefinity/Authenticate/OpenID/connect/token";
396
+ function login() {
397
+ var url = sitefinityUrl + "/Sitefinity/oauth/token";
398
398
  var data = {
399
- username: username,
400
- password: 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.authentication.setToken(tokenObj);
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(entitySet);<br />data.get(); data.destroy ...
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="requestGetCountInline" onclick="requestGetCount(true)" />
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": true,
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
- patch
1
+ major
package/version.txt CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 1.0.0
@@ -1,5 +0,0 @@
1
- {
2
- "filename": "index.html",
3
- "template": "template.html",
4
- "inject": "head"
5
- }