@progress/sitefinity-webservices-sdk 0.2.70 → 0.3.1

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 (30) hide show
  1. package/dist/docs/assets/js/search.js +1 -1
  2. package/dist/docs/classes/_data_.data.html +10 -10
  3. package/dist/docs/classes/_expression_.binaryexpression.html +39 -1
  4. package/dist/docs/classes/_expression_.complexexpression.html +3 -3
  5. package/dist/docs/classes/_querybuilder_.querybuilder.html +32 -2
  6. package/dist/docs/classes/_requests_batchrequest_.batchrequest.html +2 -2
  7. package/dist/docs/classes/_requests_request_.createrelatedrequest.html +9 -9
  8. package/dist/docs/classes/_requests_request_.createrequest.html +8 -8
  9. package/dist/docs/classes/_requests_request_.deleterelatedbyidrequest.html +8 -8
  10. package/dist/docs/classes/_requests_request_.deleterelatedrequest.html +7 -7
  11. package/dist/docs/classes/_requests_request_.deleterequest.html +6 -6
  12. package/dist/docs/classes/_requests_request_.getbyidrequest.html +12 -12
  13. package/dist/docs/classes/_requests_request_.getrelatedbyidrequest.html +14 -15
  14. package/dist/docs/classes/_requests_request_.getrelatedrequest.html +13 -14
  15. package/dist/docs/classes/_requests_request_.getrequest.html +12 -12
  16. package/dist/docs/classes/_requests_request_.requestbase.html +4 -4
  17. package/dist/docs/classes/_requests_request_.updaterequest.html +10 -10
  18. package/dist/docs/classes/_requests_request_.uploadrequest.html +12 -12
  19. package/dist/docs/classes/_wherequery_.wherequery.html +31 -10
  20. package/dist/sitefinity-webservices-sdk.js +123 -74
  21. package/dist/sitefinity-webservices-sdk.js.map +1 -1
  22. package/dist/sitefinity-webservices-sdk.min.js +12 -12
  23. package/package-lock.json +2759 -5332
  24. package/package.json +6 -18
  25. package/src/Data.ts +3 -0
  26. package/src/Expression.ts +6 -2
  27. package/src/QueryBuilder.ts +17 -5
  28. package/src/Requests/Request.ts +25 -46
  29. package/src/WhereQuery.ts +18 -15
  30. package/version.txt +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@progress/sitefinity-webservices-sdk",
3
- "version": "0.2.70",
3
+ "version": "0.3.1",
4
4
  "scripts": {
5
5
  "start": "webpack-dev-server --config config/webpack.dev.js",
6
6
  "build:dev": "webpack --config config/webpack.dev.js --progress --profile",
@@ -8,26 +8,14 @@
8
8
  "build:release": "npm run build:prod & npm run build:dev"
9
9
  },
10
10
  "devDependencies": {
11
- "awesome-typescript-loader": "5.0.0",
12
- "compression-webpack-plugin": "1.1.11",
11
+ "awesome-typescript-loader": "5.2.1",
13
12
  "html-webpack-plugin": "3.2.0",
14
- "jasmine-ajax": "2.99.0",
15
- "jasmine-reporters": "0.4.1",
16
- "karma": "0.12.37",
17
- "karma-chrome-launcher": "0.1.12",
18
- "karma-coverage": "0.2.7",
19
- "karma-jasmine": "0.2.3",
20
- "karma-jasmine-ajax": "0.1.13",
21
- "karma-junit-reporter": "0.2.2",
22
- "karma-phantomjs-launcher": "0.1.4",
23
13
  "typedoc": "0.11.1",
24
14
  "typedoc-webpack-plugin": "1.1.4",
25
15
  "typescript": "2.9.1",
26
- "webpack": "4.12.0",
27
- "webpack-cli": "3.0.3",
28
- "webpack-dev-server": "3.1.4",
29
- "webpack-merge": "4.1.2",
30
- "webpack-uglify-js-plugin": "1.1.9",
31
- "zip-webpack-plugin": "3.0.0"
16
+ "webpack": "4.46.0",
17
+ "webpack-cli": "3.3.11",
18
+ "webpack-dev-server": "3.11.0",
19
+ "webpack-merge": "4.1.2"
32
20
  }
33
21
  }
package/src/Data.ts CHANGED
@@ -124,6 +124,9 @@ export class Data {
124
124
  if (!(parameters.data))
125
125
  throw "Parameter 'data' is required!";
126
126
 
127
+ if (parameters.query)
128
+ this.urlOptions.ODataParams = parameters.query;
129
+
127
130
  var request = this.factory.create({
128
131
  urlOptions: this.urlOptions,
129
132
  key: parameters.key,
package/src/Expression.ts CHANGED
@@ -9,7 +9,7 @@ export class ExpressionBase {
9
9
  }
10
10
 
11
11
  export class BinaryExpression extends ExpressionBase {
12
- constructor(type: string, public parameter: string, public constant: any) {
12
+ constructor(type: string, public parameter: string, public constant: any, public caseSensitive: boolean = true) {
13
13
  super(type);
14
14
  }
15
15
 
@@ -20,10 +20,14 @@ export class BinaryExpression extends ExpressionBase {
20
20
  getConstant(): any {
21
21
  return this.constant;
22
22
  }
23
+
24
+ isCaseSensitive(): boolean {
25
+ return this.caseSensitive;
26
+ }
23
27
  }
24
28
 
25
29
  export class ComplexExpression extends ExpressionBase {
26
- constructor (type: string, private expressions: ExpressionBase[]) {
30
+ constructor(type: string, private expressions: ExpressionBase[]) {
27
31
  super(type);
28
32
  }
29
33
 
@@ -140,11 +140,15 @@ export class QueryBuilder {
140
140
 
141
141
  result = `(${expression.getParameter()} ${type} ${this._checkType(constant)})`;
142
142
  break;
143
- // TODO contains is substringOf in Odata ?
143
+ // TODO contains is substringOf in Odata ?
144
144
  case ExpressionType.contains:
145
145
  case ExpressionType.startsWith:
146
146
  case ExpressionType.endsWith:
147
- result = `${type.toLowerCase()}(${expression.getParameter()}, ${this._checkType(expression.getConstant())})`;
147
+ var expressionParameter = this._applyCaseSensitiveSettings(expression, expression.getParameter());
148
+ var expressionConstant = this._checkType(expression.getConstant());
149
+ var expressionValue = this._applyCaseSensitiveSettings(expression, expressionConstant);
150
+
151
+ result = `${type.toLowerCase()}(${expressionParameter}, ${expressionValue})`;
148
152
  break;
149
153
  default:
150
154
  var msg = `Unsupported operator ${type}`;
@@ -154,6 +158,14 @@ export class QueryBuilder {
154
158
  return result;
155
159
  }
156
160
 
161
+ private _applyCaseSensitiveSettings(expression, value) {
162
+ if (expression.isCaseSensitive()) {
163
+ return value;
164
+ }
165
+
166
+ return `tolower(${value})`;
167
+ }
168
+
157
169
  private _checkType(constant: any) {
158
170
  if (this._isGuid(constant))
159
171
  return constant;
@@ -161,12 +173,12 @@ export class QueryBuilder {
161
173
  if (constant == null)
162
174
  return null;
163
175
 
164
- constant = constant.replace(/[+/?%#&]/g, function($0) {
176
+ constant = constant.replace(/[+/?%#&]/g, function ($0) {
165
177
  return encodeURIComponent($0);
166
178
  });
167
179
 
168
- // escapes the apostrophes
169
- constant = constant.replace(/'/g,"''");
180
+ // escapes the apostrophes
181
+ constant = constant.replace(/'/g, "''");
170
182
 
171
183
  return "'" + constant + "'";
172
184
  }
@@ -39,19 +39,40 @@ export class RequestBase {
39
39
  }
40
40
 
41
41
  _getQueryParameters(paramDictionary: any, urlOptions: any) {
42
- var clause = constants.SfParams;
42
+ if (urlOptions.ODataParams) {
43
+ var query = urlOptions.ODataParams.build();
44
+ if (utils.isString(query.$filter))
45
+ paramDictionary[constants.ODataParams.$filter] = query.$filter;
46
+ if (utils.isString(query.$select))
47
+ paramDictionary[constants.ODataParams.$select] = query.$select;
48
+ if (utils.isString(query.$expand))
49
+ paramDictionary[constants.ODataParams.$expand] = query.$expand;
50
+ if (utils.isString(query.$orderby))
51
+ paramDictionary[constants.ODataParams.$orderby] = query.$orderby;
52
+ if (utils.isNumber(query.$skip))
53
+ paramDictionary[constants.ODataParams.$skip] = query.$skip;
54
+ if (utils.isNumber(query.$top))
55
+ paramDictionary[constants.ODataParams.$top] = query.$top;
56
+ if (utils.isString(query.$search))
57
+ paramDictionary[constants.ODataParams.$search] = query.$search;
58
+
59
+ // inline count
60
+ if (utils.isBoolean(query.$count) && query.$count)
61
+ paramDictionary[constants.ODataParams.$count] = query.$count;
62
+ }
63
+
43
64
  if (urlOptions.SFParams) {
44
65
  var sfParams = urlOptions.SFParams;
45
66
  if (sfParams.provider) {
46
- paramDictionary[clause.provider] = sfParams.provider;
67
+ paramDictionary[constants.SfParams.provider] = sfParams.provider;
47
68
  }
48
69
 
49
70
  if (sfParams.culture) {
50
- paramDictionary[clause.culture] = sfParams.culture;
71
+ paramDictionary[constants.SfParams.culture] = sfParams.culture;
51
72
  }
52
73
 
53
74
  if (sfParams.siteId) {
54
- paramDictionary[clause.siteId] = sfParams.siteId;
75
+ paramDictionary[constants.SfParams.siteId] = sfParams.siteId;
55
76
  }
56
77
  }
57
78
 
@@ -144,34 +165,6 @@ export class GetRequest extends RequestBase {
144
165
  _getMethod() {
145
166
  return httpMethods.Get;
146
167
  }
147
-
148
- _getQueryParameters(paramDictionary: any, urlOptions: any) {
149
- var clause = constants.ODataParams;
150
-
151
- if (urlOptions.ODataParams) {
152
- var query = urlOptions.ODataParams.build();
153
- if (utils.isString(query.$filter))
154
- paramDictionary[clause.$filter] = query.$filter;
155
- if (utils.isString(query.$select))
156
- paramDictionary[clause.$select] = query.$select;
157
- if (utils.isString(query.$expand))
158
- paramDictionary[clause.$expand] = query.$expand;
159
- if (utils.isString(query.$orderby))
160
- paramDictionary[clause.$orderby] = query.$orderby;
161
- if (utils.isNumber(query.$skip))
162
- paramDictionary[clause.$skip] = query.$skip;
163
- if (utils.isNumber(query.$top))
164
- paramDictionary[clause.$top] = query.$top;
165
- if (utils.isString(query.$search))
166
- paramDictionary[clause.$search] = query.$search;
167
-
168
- // inline count
169
- if (utils.isBoolean(query.$count) && query.$count)
170
- paramDictionary[clause.$count] = query.$count;
171
- }
172
-
173
- super._getQueryParameters(paramDictionary, urlOptions);
174
- }
175
168
  }
176
169
 
177
170
  export class GetByIdRequest extends RequestBase {
@@ -182,20 +175,6 @@ export class GetByIdRequest extends RequestBase {
182
175
  _getMethod() {
183
176
  return httpMethods.Get;
184
177
  }
185
-
186
- _getQueryParameters(paramDictionary, urlOptions) {
187
- var clause = constants.ODataParams;
188
-
189
- if (urlOptions.ODataParams) {
190
- var query = urlOptions.ODataParams.build();
191
- if (utils.isString(query.$select))
192
- paramDictionary[clause.$select] = query.$select;
193
- if (utils.isString(query.$expand))
194
- paramDictionary[clause.$expand] = query.$expand;
195
- }
196
-
197
- super._getQueryParameters(paramDictionary, urlOptions);
198
- }
199
178
  }
200
179
 
201
180
  export class DeleteRequest extends RequestBase {
package/src/WhereQuery.ts CHANGED
@@ -13,12 +13,12 @@ export class WhereQuery {
13
13
  this.expression = new ComplexExpression(type, []);
14
14
  }
15
15
 
16
- /**
17
- * 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
+ /**
17
+ * 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
+ */
22
22
  and(): WhereQuery {
23
23
  return new WhereQuery(this, OperatorType.and);
24
24
  }
@@ -51,8 +51,8 @@ export class WhereQuery {
51
51
  return new WhereQuery(this, OperatorType.not);
52
52
  }
53
53
 
54
- private _simple (type: string, parameter: string, constant: any): WhereQuery {
55
- var currentExpr = new BinaryExpression(type, parameter, constant);
54
+ private _simple(type: string, parameter: string, constant: any, caseSensitive: boolean = true): WhereQuery {
55
+ var currentExpr = new BinaryExpression(type, parameter, constant, caseSensitive);
56
56
  var subExpressions = this.expression.getExpressions();
57
57
  subExpressions.push(currentExpr);
58
58
 
@@ -134,11 +134,12 @@ export class WhereQuery {
134
134
  * @memberOf WhereQuery.prototype
135
135
  * @param {string} field Field name.
136
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
137
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.
138
139
  * @returns {WhereQuery}
139
140
  */
140
- startsWith(parameter: string, constant: any): WhereQuery {
141
- return this._simple(OperatorType.startsWith, parameter, constant);
141
+ startsWith(parameter: string, constant: any, caseSensitive: boolean = true): WhereQuery {
142
+ return this._simple(OperatorType.startsWith, parameter, constant, caseSensitive);
142
143
  }
143
144
 
144
145
  /**
@@ -147,11 +148,12 @@ export class WhereQuery {
147
148
  * @memberOf WhereQuery.prototype
148
149
  * @param {string} field Field name.
149
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
150
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.
151
153
  * @returns {WhereQuery}
152
154
  */
153
- contains(parameter: string, constant: any) {
154
- return this._simple(OperatorType.contains, parameter, constant);
155
+ contains(parameter: string, constant: any, caseSensitive: boolean = true) {
156
+ return this._simple(OperatorType.contains, parameter, constant, caseSensitive);
155
157
  }
156
158
 
157
159
  /**
@@ -160,11 +162,12 @@ export class WhereQuery {
160
162
  * @memberOf WhereQuery.prototype
161
163
  * @param {string} field Field name.
162
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
163
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.
164
167
  * @returns {WhereQuery}
165
168
  */
166
- endsWith(parameter: string, constant: any) {
167
- return this._simple(OperatorType.endsWith, parameter, constant);
169
+ endsWith(parameter: string, constant: any, caseSensitive: boolean = true) {
170
+ return this._simple(OperatorType.endsWith, parameter, constant, caseSensitive);
168
171
  }
169
172
 
170
173
  /**
@@ -184,7 +187,7 @@ export class WhereQuery {
184
187
  return this.parent;
185
188
  }
186
189
 
187
- _getExpression () {
190
+ _getExpression() {
188
191
  return this.expression;
189
192
  }
190
193
 
package/version.txt CHANGED
@@ -1 +1 @@
1
- 0.2.70
1
+ 0.3.1