@progress/sitefinity-webservices-sdk 1.0.4 → 1.1.3
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/.eslintrc.js +30 -9
- package/README.md +28 -11
- package/config/helpers.ts +8 -0
- package/config/webpack.common.ts +39 -0
- package/config/webpack.dev.ts +37 -0
- package/config/webpack.prod.ts +17 -0
- package/dist/docs/assets/highlight.css +23 -9
- package/dist/docs/assets/main.js +58 -52
- package/dist/docs/assets/search.js +1 -1
- package/dist/docs/assets/style.css +488 -621
- package/dist/docs/classes/BlobBuilder.BlobBuilder.html +137 -0
- package/dist/docs/classes/Data.Data.html +387 -0
- package/dist/docs/classes/Expression.BinaryExpression.html +184 -1
- package/dist/docs/classes/Expression.ComplexExpression.html +146 -1
- package/dist/docs/classes/Expression.ExpressionBase.html +125 -1
- package/dist/docs/classes/OrderProperty.OrderProperty.html +151 -0
- package/dist/docs/classes/Query.Query.html +353 -0
- package/dist/docs/classes/QueryBase.QueryBase.html +185 -0
- package/dist/docs/classes/QueryBuilder.QueryBuilder.html +204 -0
- package/dist/docs/classes/Requests_BatchRequest.BatchRequest.html +731 -17
- package/dist/docs/classes/Requests_BatchRequest.Transaction.html +332 -17
- package/dist/docs/classes/Requests_ExecutableRequest.ExecutableRequest.html +340 -1
- package/dist/docs/classes/Requests_Request.CommitChunksRequest.html +303 -0
- package/dist/docs/classes/Requests_Request.CreateRelatedRequest.html +310 -1
- package/dist/docs/classes/Requests_Request.CreateRequest.html +307 -1
- package/dist/docs/classes/Requests_Request.DeleteRelatedByIdRequest.html +309 -1
- package/dist/docs/classes/Requests_Request.DeleteRelatedRequest.html +302 -1
- package/dist/docs/classes/Requests_Request.DeleteRequest.html +298 -1
- package/dist/docs/classes/Requests_Request.GetByIdRequest.html +298 -1
- package/dist/docs/classes/Requests_Request.GetRelatedByIdRequest.html +309 -1
- package/dist/docs/classes/Requests_Request.GetRelatedRequest.html +302 -1
- package/dist/docs/classes/Requests_Request.GetRequest.html +295 -1
- package/dist/docs/classes/Requests_Request.UpdateRequest.html +309 -1
- package/dist/docs/classes/Requests_Request.UploadChunkRequest.html +352 -0
- package/dist/docs/classes/Requests_Request.UploadRequest.html +329 -1
- package/dist/docs/classes/Requests_RequestBase.RequestBase.html +275 -1
- package/dist/docs/classes/Requests_RequestFactory.RequestFactory.html +344 -1
- package/dist/docs/classes/Sitefinity.Sitefinity.html +188 -0
- package/dist/docs/classes/WhereQuery.WhereQuery.html +417 -0
- package/dist/docs/classes/chunk_upload_chunk_upload_sdk.ChunkUploadSdk.html +231 -0
- package/dist/docs/classes/chunk_upload_chunked_file_upload_utilities.ChunkedFileUploadUtilities.html +131 -0
- package/dist/docs/classes/utils.utils.html +303 -0
- package/dist/docs/index.html +84 -15
- package/dist/docs/interfaces/Data.CreateRelatedRequestOptions.html +155 -1
- package/dist/docs/interfaces/Data.CreateRequestOptions.html +153 -1
- package/dist/docs/interfaces/Data.OperationsRequestOptions.html +145 -1
- package/dist/docs/interfaces/Data.PropertyRequestOptions.html +149 -1
- package/dist/docs/interfaces/Data.RequestOptionsBase.html +136 -1
- package/dist/docs/interfaces/Data.SingleRelatedItemRequestOptions.html +155 -1
- package/dist/docs/interfaces/Data.UpdateRequestOptions.html +155 -1
- package/dist/docs/interfaces/Data.UploadRequestOptions.html +169 -1
- package/dist/docs/interfaces/Requests_BatchRequest.BatchCreateRelatedRequestOptions.html +161 -1
- package/dist/docs/interfaces/Requests_BatchRequest.BatchCreateRequestOptions.html +153 -1
- package/dist/docs/interfaces/Requests_BatchRequest.BatchPropertyRequestOptions.html +153 -1
- package/dist/docs/interfaces/Requests_BatchRequest.BatchRequestOptionsBase.html +145 -1
- package/dist/docs/interfaces/Requests_BatchRequest.BatchRequestOptionsExtended.html +153 -1
- package/dist/docs/interfaces/Requests_BatchRequest.BatchSingleItemRequestOptions.html +145 -1
- package/dist/docs/interfaces/Requests_BatchRequest.BatchSingleRelatedItemRequestOptions.html +161 -1
- package/dist/docs/interfaces/Requests_BatchRequest.BatchUpdateRequestOptions.html +161 -1
- package/dist/docs/interfaces/Requests_ExecutableRequest.ResponseHandlers.html +98 -5
- package/dist/docs/interfaces/Requests_Request.CommitChunksRequestOptionsExtended.html +215 -0
- package/dist/docs/interfaces/Requests_Request.PostRequestOptionsExtended.html +159 -1
- package/dist/docs/interfaces/Requests_Request.PutRequestOptionsExtended.html +161 -1
- package/dist/docs/interfaces/Requests_Request.RelatedByIdRequestOptionsExtended.html +169 -1
- package/dist/docs/interfaces/Requests_Request.RelatedRequestOptionsExtended.html +163 -1
- package/dist/docs/interfaces/Requests_Request.UploadChunkRequestOptionsExtended.html +210 -0
- package/dist/docs/interfaces/Requests_Request.UploadRequestOptionsExtended.html +180 -1
- package/dist/docs/interfaces/Requests_RequestBase.RequestOptionsBaseExtended.html +148 -1
- package/dist/docs/interfaces/Sitefinity.SDKOptions.html +128 -9
- package/dist/docs/interfaces/Sitefinity.Token.html +94 -1
- package/dist/docs/interfaces/Sitefinity.TypeOptions.html +144 -13
- package/dist/docs/interfaces/chunk_upload_chunk_upload_sdk.ChunkUploadInfoDTO.html +159 -0
- package/dist/docs/interfaces/chunk_upload_chunk_upload_sdk.ChunkUploadResult.html +111 -0
- package/dist/docs/interfaces/chunk_upload_chunk_upload_sdk.CleanUpChunksRequestOptions.html +171 -0
- package/dist/docs/interfaces/chunk_upload_chunk_upload_sdk.CommitChunksRequestOptions.html +204 -0
- package/dist/docs/interfaces/chunk_upload_chunk_upload_sdk.GetChunkUploadInfoRequestOptions.html +166 -0
- package/dist/docs/interfaces/chunk_upload_chunk_upload_sdk.UploadChunkRequestOptions.html +201 -0
- package/dist/docs/interfaces/chunk_upload_chunked_file_upload_utilities.ChunkFileResult.html +101 -0
- package/dist/docs/interfaces/chunk_upload_chunked_file_upload_utilities.FileUploadChunk.html +94 -0
- package/dist/docs/modules/BlobBuilder.html +73 -1
- package/dist/docs/modules/Data.html +92 -1
- package/dist/docs/modules/Expression.html +77 -1
- package/dist/docs/modules/OrderProperty.html +73 -1
- package/dist/docs/modules/Query.html +73 -1
- package/dist/docs/modules/QueryBase.html +73 -1
- package/dist/docs/modules/QueryBuilder.html +73 -1
- package/dist/docs/modules/Requests_BatchRequest.html +94 -1
- package/dist/docs/modules/Requests_ExecutableRequest.html +78 -1
- package/dist/docs/modules/Requests_Request.html +114 -1
- package/dist/docs/modules/Requests_RequestBase.html +78 -1
- package/dist/docs/modules/Requests_RequestFactory.html +73 -1
- package/dist/docs/modules/Sitefinity.html +82 -1
- package/dist/docs/modules/WhereQuery.html +73 -1
- package/dist/docs/modules/chunk_upload_chunk_upload_sdk.html +88 -0
- package/dist/docs/modules/chunk_upload_chunked_file_upload_utilities.html +80 -0
- package/dist/docs/modules/constants.html +83 -1
- package/dist/docs/modules/utils.html +73 -1
- package/dist/docs/modules.html +80 -1
- package/dist/docs/variables/constants.CONTENT_TYPES.html +76 -0
- package/dist/docs/variables/constants.EXPRESSION_TYPE.html +104 -0
- package/dist/docs/variables/constants.HEADER_NAMES.html +102 -0
- package/dist/docs/variables/constants.HTTP_METHODS.html +84 -0
- package/dist/docs/variables/constants.ODATA_PARAMS.html +90 -0
- package/dist/docs/variables/constants.SF_PARAMS.html +84 -0
- package/dist/samples.html +237 -38
- package/dist/sitefinity-webservices-sdk.d.ts +0 -1
- package/dist/sitefinity-webservices-sdk.js +524 -119
- package/dist/sitefinity-webservices-sdk.js.map +1 -1
- package/dist/sitefinity-webservices-sdk.min.js +1 -2
- package/dist/src/Data.d.ts +10 -0
- package/dist/src/Data.spec.d.ts +1 -0
- package/dist/src/Query.d.ts +3 -3
- package/dist/src/Requests/ExecutableRequest.d.ts +3 -1
- package/dist/src/Requests/Request.d.ts +42 -0
- package/dist/src/Requests/RequestBase.d.ts +1 -2
- package/dist/src/Requests/RequestFactory.d.ts +3 -1
- package/dist/src/Requests/request.spec.d.ts +1 -0
- package/dist/src/Sitefinity.d.ts +2 -2
- package/dist/src/Sitefinity.spec.d.ts +1 -0
- package/dist/src/WhereQuery.d.ts +2 -2
- package/dist/src/chunk-upload/chunk-upload.sdk.d.ts +290 -0
- package/dist/src/chunk-upload/chunk-upload.sdk.spec.d.ts +1 -0
- package/dist/src/chunk-upload/chunked-file-upload.utilities.d.ts +13 -0
- package/dist/src/constants.d.ts +5 -0
- package/package.json +24 -22
- package/sitefinity-webservices-sdk.ts +0 -1
- package/src/Data.spec.ts +12 -12
- package/src/Data.ts +19 -4
- package/src/OrderProperty.ts +7 -7
- package/src/Query.ts +4 -4
- package/src/QueryBase.ts +4 -4
- package/src/QueryBuilder.ts +38 -38
- package/src/Requests/BatchRequest.ts +25 -25
- package/src/Requests/ExecutableRequest.ts +30 -24
- package/src/Requests/Request.ts +109 -2
- package/src/Requests/RequestBase.ts +3 -4
- package/src/Requests/RequestFactory.ts +9 -1
- package/src/Requests/request.spec.ts +10 -10
- package/src/Sitefinity.spec.ts +6 -6
- package/src/Sitefinity.ts +5 -5
- package/src/WhereQuery.ts +2 -2
- package/src/chunk-upload/chunk-upload.sdk.spec.ts +340 -0
- package/src/chunk-upload/chunk-upload.sdk.ts +436 -0
- package/src/chunk-upload/chunked-file-upload.utilities.ts +64 -0
- package/src/constants.ts +35 -30
- package/src/utils.ts +10 -10
- package/template.html +191 -38
- package/tsconfig.json +11 -3
- package/.npmignore +0 -92
- package/ci/pipelines/ci.yml +0 -219
- package/config/helpers.js +0 -10
- package/config/webpack.common.js +0 -39
- package/config/webpack.dev.js +0 -19
- package/config/webpack.prod.js +0 -25
- package/dist/docs/assets/icons.css +0 -1043
- package/dist/docs/assets/icons.png +0 -0
- package/dist/docs/assets/icons@2x.png +0 -0
- package/dist/docs/assets/widgets.png +0 -0
- package/dist/docs/assets/widgets@2x.png +0 -0
- package/dist/docs/classes/BlobBuilder.BlobBuilder-1.html +0 -7
- package/dist/docs/classes/Data.Data-1.html +0 -65
- package/dist/docs/classes/OrderProperty.OrderProperty-1.html +0 -1
- package/dist/docs/classes/Query.Query-1.html +0 -33
- package/dist/docs/classes/QueryBase.QueryBase-1.html +0 -7
- package/dist/docs/classes/QueryBuilder.QueryBuilder-1.html +0 -1
- package/dist/docs/classes/Sitefinity.Sitefinity-1.html +0 -5
- package/dist/docs/classes/WhereQuery.WhereQuery-1.html +0 -31
- package/dist/docs/classes/utils.utils-1.html +0 -1
- package/dist/sitefinity-webservices-sdk.min.js.LICENSE.txt +0 -14
- package/package-lock.json +0 -17487
- package/type.txt +0 -1
- package/version.txt +0 -1
package/src/QueryBuilder.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { WhereQuery } from
|
|
2
|
-
import { ComplexExpression, BinaryExpression } from
|
|
3
|
-
import { OrderProperty } from
|
|
4
|
-
import { utils } from
|
|
1
|
+
import { WhereQuery } from "./WhereQuery";
|
|
2
|
+
import { ComplexExpression, BinaryExpression } from "./Expression";
|
|
3
|
+
import { OrderProperty } from "./OrderProperty";
|
|
4
|
+
import { utils } from "./utils";
|
|
5
5
|
import { ODATA_PARAMS, EXPRESSION_TYPE } from "./constants";
|
|
6
6
|
import { Query } from "./Query";
|
|
7
7
|
|
|
@@ -24,12 +24,12 @@ export class QueryBuilder {
|
|
|
24
24
|
|
|
25
25
|
const selectClause = this.query.selectProperties;
|
|
26
26
|
if (selectClause instanceof Array) {
|
|
27
|
-
queryParameters[ODATA_PARAMS.$select] = selectClause.join(
|
|
27
|
+
queryParameters[ODATA_PARAMS.$select] = selectClause.join(", ");
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
const expandClause = this.query.expandProperties;
|
|
31
31
|
if (expandClause instanceof Array)
|
|
32
|
-
queryParameters[ODATA_PARAMS.$expand] = expandClause.join(
|
|
32
|
+
queryParameters[ODATA_PARAMS.$expand] = expandClause.join(", ");
|
|
33
33
|
|
|
34
34
|
const orderByClause = this.query.orderProperties;
|
|
35
35
|
if (orderByClause instanceof Array) {
|
|
@@ -38,7 +38,7 @@ export class QueryBuilder {
|
|
|
38
38
|
if (orderByClause[i] instanceof OrderProperty)
|
|
39
39
|
order.push(orderByClause[i].getValue());
|
|
40
40
|
}
|
|
41
|
-
queryParameters[ODATA_PARAMS.$orderby] = order.join(
|
|
41
|
+
queryParameters[ODATA_PARAMS.$orderby] = order.join(", ");
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
const take = this.query.takeValue;
|
|
@@ -62,10 +62,10 @@ export class QueryBuilder {
|
|
|
62
62
|
|
|
63
63
|
private buildComplexExpression(expression: ComplexExpression, parent: string): string {
|
|
64
64
|
if (!(expression instanceof ComplexExpression))
|
|
65
|
-
throw new Error(
|
|
65
|
+
throw new Error("Invalid complex expression");
|
|
66
66
|
|
|
67
67
|
let counter = 0;
|
|
68
|
-
let result =
|
|
68
|
+
let result = "";
|
|
69
69
|
const subExpressions = expression.getExpressions();
|
|
70
70
|
if (!subExpressions.length) {
|
|
71
71
|
return result;
|
|
@@ -79,12 +79,12 @@ export class QueryBuilder {
|
|
|
79
79
|
else if (currentExp instanceof ComplexExpression) {
|
|
80
80
|
const complexResult = this.buildComplexExpression(currentExp, expression.type);
|
|
81
81
|
if (complexResult) {
|
|
82
|
-
result +=
|
|
82
|
+
result += "(" + complexResult + ")";
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
if (expression.getType() === EXPRESSION_TYPE.not)
|
|
87
|
-
result = expression.getType() +
|
|
87
|
+
result = expression.getType() + " " + result;
|
|
88
88
|
// TODOSDK: Rethink this!
|
|
89
89
|
if (expression.getType() === EXPRESSION_TYPE.any) {
|
|
90
90
|
const exprVal = [];
|
|
@@ -92,16 +92,16 @@ export class QueryBuilder {
|
|
|
92
92
|
if (subExpressions[index].type == EXPRESSION_TYPE.contains || subExpressions[index].type == EXPRESSION_TYPE.startsWith || subExpressions[index].type == EXPRESSION_TYPE.endsWith)
|
|
93
93
|
exprVal.push(subExpressions[index].type.toLowerCase() + "(x, '" + (subExpressions[index] as BinaryExpression).constant + "')");
|
|
94
94
|
else
|
|
95
|
-
exprVal.push(
|
|
95
|
+
exprVal.push("x " + subExpressions[index].type.toLowerCase() + " " + this.checkType((subExpressions[index] as BinaryExpression).constant));
|
|
96
96
|
}
|
|
97
|
-
result = (currentExp as BinaryExpression).parameter +
|
|
97
|
+
result = (currentExp as BinaryExpression).parameter + "/" + expression.getType() + "(x:" + exprVal.join(" " + parent + " ") + ")";
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
counter++;
|
|
101
101
|
if (counter == subExpressions.length)
|
|
102
102
|
break;
|
|
103
103
|
|
|
104
|
-
result +=
|
|
104
|
+
result += " " + expression.getType() + " ";
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
return result;
|
|
@@ -111,30 +111,30 @@ export class QueryBuilder {
|
|
|
111
111
|
let result: string = null;
|
|
112
112
|
const type = expression.getType();
|
|
113
113
|
switch (type) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
114
|
+
case EXPRESSION_TYPE.eq:
|
|
115
|
+
case EXPRESSION_TYPE.ne:
|
|
116
|
+
case EXPRESSION_TYPE.lt:
|
|
117
|
+
case EXPRESSION_TYPE.le:
|
|
118
|
+
case EXPRESSION_TYPE.gt:
|
|
119
|
+
case EXPRESSION_TYPE.ge: {
|
|
120
|
+
const constant = expression.getConstant();
|
|
121
|
+
result = `(${expression.getParameter()} ${type} ${this.checkType(constant)})`;
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
case EXPRESSION_TYPE.contains:
|
|
125
|
+
case EXPRESSION_TYPE.startsWith:
|
|
126
|
+
case EXPRESSION_TYPE.endsWith: {
|
|
127
|
+
const expressionParameter = this.applyCaseSensitiveSettings(expression, expression.getParameter());
|
|
128
|
+
const expressionConstant = this.checkType(expression.getConstant());
|
|
129
|
+
const expressionValue = this.applyCaseSensitiveSettings(expression, expressionConstant);
|
|
130
|
+
|
|
131
|
+
result = `${type.toLowerCase()}(${expressionParameter}, ${expressionValue})`;
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
default: {
|
|
135
|
+
const msg = `Unsupported operator ${type}`;
|
|
136
|
+
throw new Error(msg);
|
|
137
|
+
}
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
return result;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RequestFactory } from "./RequestFactory";
|
|
2
|
-
import { BlobBuilder } from
|
|
3
|
-
import { utils } from
|
|
2
|
+
import { BlobBuilder } from "../BlobBuilder";
|
|
3
|
+
import { utils } from "../utils";
|
|
4
4
|
import { HEADER_NAMES, HTTP_METHODS } from "../constants";
|
|
5
5
|
import { ExecutableRequest } from "./ExecutableRequest";
|
|
6
6
|
import { SDKOptions, Token, TypeOptions } from "../Sitefinity";
|
|
@@ -77,13 +77,13 @@ export class Transaction {
|
|
|
77
77
|
const options: PostRequestOptionsExtended = {
|
|
78
78
|
urlOptions: urlOptions,
|
|
79
79
|
key: parameters.key,
|
|
80
|
-
action:
|
|
80
|
+
action: "operation",
|
|
81
81
|
data: parameters.data
|
|
82
82
|
};
|
|
83
83
|
|
|
84
84
|
const request = this.factory.create(options);
|
|
85
85
|
|
|
86
|
-
this.overrideUrlGeneration(request, parameters.key,
|
|
86
|
+
this.overrideUrlGeneration(request, parameters.key, "operation", options.urlOptions, options.query);
|
|
87
87
|
this.addRequest(request);
|
|
88
88
|
}
|
|
89
89
|
|
|
@@ -147,7 +147,7 @@ export class Transaction {
|
|
|
147
147
|
|
|
148
148
|
const request = this.factory.destroyRelated(options);
|
|
149
149
|
|
|
150
|
-
const propertyURL = (request as any).property +
|
|
150
|
+
const propertyURL = (request as any).property + "/$ref";
|
|
151
151
|
this.overrideUrlGeneration(request, parameters.key, propertyURL, options.urlOptions, options.query);
|
|
152
152
|
|
|
153
153
|
this.addRequest(request);
|
|
@@ -191,8 +191,8 @@ export class Transaction {
|
|
|
191
191
|
}
|
|
192
192
|
|
|
193
193
|
const data = {
|
|
194
|
-
|
|
195
|
-
}
|
|
194
|
+
"@odata.id": parameters.link
|
|
195
|
+
};
|
|
196
196
|
|
|
197
197
|
const options: RelatedRequestOptionsExtended = {
|
|
198
198
|
urlOptions: urlOptions,
|
|
@@ -202,7 +202,7 @@ export class Transaction {
|
|
|
202
202
|
};
|
|
203
203
|
|
|
204
204
|
const request = this.factory.createRelated(options);
|
|
205
|
-
const propertyURL = (request as any).property +
|
|
205
|
+
const propertyURL = (request as any).property + "/$ref";
|
|
206
206
|
this.overrideUrlGeneration(request, parameters.key, propertyURL, options.urlOptions, options.query);
|
|
207
207
|
|
|
208
208
|
return this.addRequest(request);
|
|
@@ -216,7 +216,7 @@ export class Transaction {
|
|
|
216
216
|
request.buildUrl = function () {
|
|
217
217
|
let uri = "$" + key;
|
|
218
218
|
if (additionalPropertyURL !== undefined) {
|
|
219
|
-
uri = uri +
|
|
219
|
+
uri = uri + "/" + additionalPropertyURL;
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
if (urlOptions) {
|
|
@@ -227,7 +227,7 @@ export class Transaction {
|
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
return uri;
|
|
230
|
-
}
|
|
230
|
+
};
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
233
|
}
|
|
@@ -258,7 +258,7 @@ export class BatchRequest extends ExecutableRequest {
|
|
|
258
258
|
|
|
259
259
|
|
|
260
260
|
public static constants = {
|
|
261
|
-
newLine:
|
|
261
|
+
newLine: "\r\n"
|
|
262
262
|
};
|
|
263
263
|
|
|
264
264
|
constructor(requestOptions: BatchRequestOptionsExtended, token: Token, sdkOptions: SDKOptions) {
|
|
@@ -415,7 +415,7 @@ export class BatchRequest extends ExecutableRequest {
|
|
|
415
415
|
const queryString = this.getQueryString(this.urlOptions, this.query);
|
|
416
416
|
|
|
417
417
|
if (queryString) {
|
|
418
|
-
url += queryString
|
|
418
|
+
url += queryString;
|
|
419
419
|
}
|
|
420
420
|
|
|
421
421
|
return url;
|
|
@@ -470,7 +470,7 @@ export class BatchRequest extends ExecutableRequest {
|
|
|
470
470
|
const responseCheck = function (r) {
|
|
471
471
|
let success = true;
|
|
472
472
|
if (r.data && r.data.hasOwnProperty("Success")) {
|
|
473
|
-
success = r.data.Success
|
|
473
|
+
success = r.data.Success;
|
|
474
474
|
}
|
|
475
475
|
|
|
476
476
|
return success;
|
|
@@ -582,10 +582,10 @@ export class BatchRequest extends ExecutableRequest {
|
|
|
582
582
|
let i, len;
|
|
583
583
|
for (i = 1, len = contentTypeParts.length; i < len; i++) {
|
|
584
584
|
const contentTypeParams = contentTypeParts[i].split("=");
|
|
585
|
-
properties[contentTypeParams[0].replace(/^\s+|\s+$/g,
|
|
585
|
+
properties[contentTypeParams[0].replace(/^\s+|\s+$/g, "")] = contentTypeParams[1];
|
|
586
586
|
}
|
|
587
587
|
|
|
588
|
-
return { mediaType: contentTypeParts[0].replace(/^\s+|\s+$/g,
|
|
588
|
+
return { mediaType: contentTypeParts[0].replace(/^\s+|\s+$/g, ""), properties: properties };
|
|
589
589
|
}
|
|
590
590
|
|
|
591
591
|
private readTo(text, str, context) {
|
|
@@ -657,7 +657,7 @@ export class BatchRequest extends ExecutableRequest {
|
|
|
657
657
|
|
|
658
658
|
private buildRequestBody() {
|
|
659
659
|
const builder = new BlobBuilder();
|
|
660
|
-
builder.append(
|
|
660
|
+
builder.append("");
|
|
661
661
|
|
|
662
662
|
for (let index = 0; index < this.requests.length; index += 1) {
|
|
663
663
|
|
|
@@ -681,12 +681,12 @@ export class BatchRequest extends ExecutableRequest {
|
|
|
681
681
|
|
|
682
682
|
private buildRequest(request: RequestBase): Blob {
|
|
683
683
|
const builder = new BlobBuilder();
|
|
684
|
-
builder.append(BatchRequest.constants.newLine +
|
|
685
|
-
BatchRequest.constants.newLine +
|
|
684
|
+
builder.append(BatchRequest.constants.newLine + "Content-Type: application/http" +
|
|
685
|
+
BatchRequest.constants.newLine + "Content-Transfer-Encoding: binary" +
|
|
686
686
|
BatchRequest.constants.newLine +
|
|
687
687
|
BatchRequest.constants.newLine +
|
|
688
688
|
request.getMethod() +
|
|
689
|
-
|
|
689
|
+
" " + request.buildUrl() + " HTTP/1.1");
|
|
690
690
|
|
|
691
691
|
return builder.build();
|
|
692
692
|
}
|
|
@@ -699,7 +699,7 @@ export class BatchRequest extends ExecutableRequest {
|
|
|
699
699
|
builder.append(BatchRequest.constants.newLine);
|
|
700
700
|
|
|
701
701
|
const changeset = this.createBoundary("sf_changeset_");
|
|
702
|
-
builder.append(
|
|
702
|
+
builder.append("Content-Type: multipart/mixed; boundary=" + changeset);
|
|
703
703
|
|
|
704
704
|
const changesetRequests = transaction.requests;
|
|
705
705
|
for (let index = 0; index < changesetRequests.length; index += 1) {
|
|
@@ -708,12 +708,12 @@ export class BatchRequest extends ExecutableRequest {
|
|
|
708
708
|
// we shouldn't add new lines after blob content. Otherwise they are added to the blob and corrupt it
|
|
709
709
|
const shouldAddNewLine = index === 0 || !utils.isBlob(changesetRequests[index - 1].request.getBody());
|
|
710
710
|
builder.append(this.createDelimeter(changeset, false, shouldAddNewLine) +
|
|
711
|
-
BatchRequest.constants.newLine +
|
|
712
|
-
BatchRequest.constants.newLine +
|
|
713
|
-
BatchRequest.constants.newLine +
|
|
711
|
+
BatchRequest.constants.newLine + "Content-Type: application/http" +
|
|
712
|
+
BatchRequest.constants.newLine + "Content-Transfer-Encoding: binary" +
|
|
713
|
+
BatchRequest.constants.newLine + "Content-ID: " + changesetRequests[index].id);
|
|
714
714
|
|
|
715
715
|
const requestUrl = currentRequest.buildUrl();
|
|
716
|
-
builder.append(BatchRequest.constants.newLine + BatchRequest.constants.newLine + currentRequest.getMethod() +
|
|
716
|
+
builder.append(BatchRequest.constants.newLine + BatchRequest.constants.newLine + currentRequest.getMethod() + " " + requestUrl + " HTTP/1.1");
|
|
717
717
|
|
|
718
718
|
const headers = currentRequest.getHeaders();
|
|
719
719
|
const headerNames = Object.keys(headers);
|
|
@@ -749,7 +749,7 @@ export class BatchRequest extends ExecutableRequest {
|
|
|
749
749
|
}
|
|
750
750
|
|
|
751
751
|
private createBoundary(prefix) {
|
|
752
|
-
return prefix + utils.hex16() +
|
|
752
|
+
return prefix + utils.hex16() + "-" + utils.hex16() + "-" + utils.hex16();
|
|
753
753
|
}
|
|
754
754
|
|
|
755
755
|
private addRequest(request: RequestBase) {
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { RequestBase, RequestOptionsBaseExtended } from
|
|
2
|
-
import { utils } from
|
|
1
|
+
import { RequestBase, RequestOptionsBaseExtended } from "./RequestBase";
|
|
2
|
+
import { utils } from "../utils";
|
|
3
3
|
import { HEADER_NAMES } from "../constants";
|
|
4
4
|
import { SDKOptions, Token } from "../Sitefinity";
|
|
5
5
|
|
|
6
6
|
const XMLHttpRequestDone = 4;
|
|
7
7
|
|
|
8
8
|
export class ExecutableRequest extends RequestBase {
|
|
9
|
+
protected http: XMLHttpRequest;
|
|
10
|
+
|
|
9
11
|
private token: Token;
|
|
10
12
|
private enableUnlimitedChoices: boolean;
|
|
11
13
|
private integrationMode: boolean;
|
|
@@ -20,20 +22,19 @@ export class ExecutableRequest extends RequestBase {
|
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
execute() {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
http.onreadystatechange = () => {
|
|
26
|
-
if (http.readyState === XMLHttpRequestDone) {
|
|
27
|
-
if (http.status > 0) {
|
|
28
|
-
let data = this.parseResponse(http);
|
|
25
|
+
this.http = new XMLHttpRequest();
|
|
29
26
|
|
|
30
|
-
|
|
27
|
+
this.http.onreadystatechange = () => {
|
|
28
|
+
if (this.http.readyState === XMLHttpRequestDone) {
|
|
29
|
+
if (this.http.status > 0) {
|
|
30
|
+
let data = this.parseResponse(this.http);
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
if (this.http.status >= 200 && this.http.status <= 206) {
|
|
33
|
+
if (this.successCb && utils.isFunction(this.successCb)) {
|
|
33
34
|
this.successCb(data);
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
|
-
else if (http.status >= 400) {
|
|
37
|
+
else if (this.http.status >= 400) {
|
|
37
38
|
// When the data is string, we save the string as message
|
|
38
39
|
// and convert the data to normal object with message property
|
|
39
40
|
if (utils.isString(data)) {
|
|
@@ -42,10 +43,10 @@ export class ExecutableRequest extends RequestBase {
|
|
|
42
43
|
};
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
data.status = http.status;
|
|
46
|
+
data.status = this.http.status;
|
|
46
47
|
|
|
47
48
|
// in case of errors we would like there to be one handler for all of the errors
|
|
48
|
-
if (utils.isFunction(this.failureCb)) {
|
|
49
|
+
if (this.failureCb && utils.isFunction(this.failureCb)) {
|
|
49
50
|
this.failureCb(data);
|
|
50
51
|
}
|
|
51
52
|
}
|
|
@@ -53,20 +54,25 @@ export class ExecutableRequest extends RequestBase {
|
|
|
53
54
|
}
|
|
54
55
|
};
|
|
55
56
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
http.upload.onprogress = (event) => {
|
|
59
|
-
this.progressCb(event);
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
}
|
|
57
|
+
|
|
58
|
+
this.executeProgressEvent();
|
|
63
59
|
|
|
64
60
|
const method = this.getMethod();
|
|
65
61
|
const url = this.buildUrl();
|
|
66
|
-
http.open(method, url, true);
|
|
67
|
-
this.setHeaders(http, this.getHeaders());
|
|
62
|
+
this.http.open(method, url, true);
|
|
63
|
+
this.setHeaders(this.http, this.getHeaders());
|
|
68
64
|
|
|
69
|
-
http.send(utils.serializeToJSON(this.getBody()));
|
|
65
|
+
this.http.send(utils.serializeToJSON(this.getBody()));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
protected executeProgressEvent() {
|
|
69
|
+
if (this.http.upload) {
|
|
70
|
+
this.http.upload.onprogress = (event) => {
|
|
71
|
+
if (this.progressCb && utils.isFunction(this.progressCb)) {
|
|
72
|
+
this.progressCb(event);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
70
76
|
}
|
|
71
77
|
|
|
72
78
|
private setHeaders(http: XMLHttpRequest, headers: { [key: string]: string }) {
|
|
@@ -77,7 +83,7 @@ export class ExecutableRequest extends RequestBase {
|
|
|
77
83
|
}
|
|
78
84
|
|
|
79
85
|
if (this.token) {
|
|
80
|
-
if (typeof this.token ===
|
|
86
|
+
if (typeof this.token === "string") {
|
|
81
87
|
// for backward compatibility
|
|
82
88
|
http.setRequestHeader(HEADER_NAMES.authorization, this.token);
|
|
83
89
|
} else {
|
package/src/Requests/Request.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HEADER_NAMES, HTTP_METHODS } from "../constants";
|
|
2
2
|
import { SDKOptions, Token } from "../Sitefinity";
|
|
3
|
-
import { utils } from
|
|
3
|
+
import { utils } from "../utils";
|
|
4
4
|
import { ExecutableRequest } from "./ExecutableRequest";
|
|
5
5
|
import { RequestOptionsBaseExtended } from "./RequestBase";
|
|
6
6
|
|
|
@@ -120,7 +120,7 @@ export class DeleteRelatedRequest extends DeleteRequest {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
buildUrl(): string {
|
|
123
|
-
const url = this.urlOptions.baseUrl + this.urlOptions.entitySet + "(" + this.key + ")/" + this.property + "/$ref"
|
|
123
|
+
const url = this.urlOptions.baseUrl + this.urlOptions.entitySet + "(" + this.key + ")/" + this.property + "/$ref";
|
|
124
124
|
return this.addQueryParameters(url);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
@@ -190,6 +190,91 @@ export class UploadRequest extends CreateRequest {
|
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
+
export class UploadChunkRequest extends CreateRequest {
|
|
194
|
+
contentType: string;
|
|
195
|
+
chunkOrdinal: number;
|
|
196
|
+
chunkSize: number;
|
|
197
|
+
chunkedFileUploadSessionId: string;
|
|
198
|
+
numberOfChunks: number;
|
|
199
|
+
positionInQueue: number;
|
|
200
|
+
blobStorageProviderName: string;
|
|
201
|
+
|
|
202
|
+
constructor(requestOptions: UploadChunkRequestOptionsExtended, token: Token, sdkOptions: SDKOptions) {
|
|
203
|
+
super(requestOptions, token, sdkOptions);
|
|
204
|
+
this.contentType = requestOptions.fileMimeType;
|
|
205
|
+
this.chunkOrdinal = requestOptions.chunkOrdinal;
|
|
206
|
+
this.chunkedFileUploadSessionId = requestOptions.chunkedFileUploadSessionId;
|
|
207
|
+
this.chunkSize = requestOptions.chunkSize;
|
|
208
|
+
this.numberOfChunks = requestOptions.numberOfChunks;
|
|
209
|
+
this.positionInQueue = requestOptions.positionOfChunkInQueue;
|
|
210
|
+
this.blobStorageProviderName = requestOptions.blobStorageProviderName;
|
|
211
|
+
this.data = requestOptions.chunkBlob;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
getHeaders(): { [key: string]: string } {
|
|
215
|
+
const headers = super.getHeaders();
|
|
216
|
+
headers[HEADER_NAMES.contentEncoding] = "identity";
|
|
217
|
+
headers[HEADER_NAMES.contentType] = this.contentType || "application/octet-stream";
|
|
218
|
+
headers[HEADER_NAMES.chunkOrdinal] = this.chunkOrdinal.toString();
|
|
219
|
+
headers[HEADER_NAMES.chunkedFileUploadSessionId] = this.chunkedFileUploadSessionId;
|
|
220
|
+
headers[HEADER_NAMES.chunkSize] = this.chunkSize.toString();
|
|
221
|
+
headers[HEADER_NAMES.blobStorageProviderName] = this.blobStorageProviderName.toString();
|
|
222
|
+
|
|
223
|
+
return headers;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
getBody(): object {
|
|
227
|
+
return this.data;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
getMethod(): string {
|
|
231
|
+
return HTTP_METHODS.post;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
protected override executeProgressEvent(): void {
|
|
235
|
+
if (this.http.upload) {
|
|
236
|
+
this.http.upload.onprogress = () => {
|
|
237
|
+
const payload = {
|
|
238
|
+
lengthComputable: true,
|
|
239
|
+
loaded: this.positionInQueue,
|
|
240
|
+
total: this.numberOfChunks
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
if (this.progressCb && utils.isFunction(this.progressCb)) {
|
|
244
|
+
this.progressCb(payload);
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export class CommitChunksRequest extends CreateRequest {
|
|
252
|
+
constructor(requestOptions: CommitChunksRequestOptionsExtended, token: Token, sdkOptions: SDKOptions) {
|
|
253
|
+
super(requestOptions, token, sdkOptions);
|
|
254
|
+
|
|
255
|
+
this.action = "Default.CommitChunks";
|
|
256
|
+
|
|
257
|
+
this.data = {
|
|
258
|
+
// ! this must be the param name that the operation provider on the server accepts
|
|
259
|
+
commitChunksDto: {
|
|
260
|
+
chunkedFileUploadSessionId: requestOptions.chunkedFileUploadSessionId,
|
|
261
|
+
contentType: requestOptions.contentType,
|
|
262
|
+
fileTotalSize: requestOptions.fileTotalSize,
|
|
263
|
+
numberOfChunks: requestOptions.numberOfChunks,
|
|
264
|
+
fileName: requestOptions.fileName,
|
|
265
|
+
blobStorageProviderName: requestOptions.blobStorageProviderName,
|
|
266
|
+
itemId: requestOptions.itemId || null,
|
|
267
|
+
// ! must be named properties
|
|
268
|
+
properties: requestOptions.uploadProperties
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
getMethod(): string {
|
|
274
|
+
return HTTP_METHODS.post;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
193
278
|
export interface PostRequestOptionsExtended extends RequestOptionsBaseExtended {
|
|
194
279
|
data?: object;
|
|
195
280
|
}
|
|
@@ -211,3 +296,25 @@ export interface UploadRequestOptionsExtended extends PostRequestOptionsExtended
|
|
|
211
296
|
contentType: string;
|
|
212
297
|
uploadProperties: { [key: string]: string };
|
|
213
298
|
}
|
|
299
|
+
|
|
300
|
+
export interface UploadChunkRequestOptionsExtended extends PostRequestOptionsExtended {
|
|
301
|
+
fileMimeType: string;
|
|
302
|
+
chunkedFileUploadSessionId: string;
|
|
303
|
+
chunkSize: number;
|
|
304
|
+
chunkOrdinal: number;
|
|
305
|
+
numberOfChunks: number;
|
|
306
|
+
chunkBlob: Blob;
|
|
307
|
+
blobStorageProviderName: string;
|
|
308
|
+
positionOfChunkInQueue?: number;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export interface CommitChunksRequestOptionsExtended extends PostRequestOptionsExtended {
|
|
312
|
+
chunkedFileUploadSessionId: string
|
|
313
|
+
blobStorageProviderName: string;
|
|
314
|
+
contentType: string;
|
|
315
|
+
fileTotalSize: number;
|
|
316
|
+
numberOfChunks: number;
|
|
317
|
+
fileName: string;
|
|
318
|
+
uploadProperties: { [key: string]: string };
|
|
319
|
+
itemId?: string;
|
|
320
|
+
}
|
|
@@ -2,7 +2,7 @@ import { CONTENT_TYPES, HEADER_NAMES, ODATA_PARAMS, SF_PARAMS } from "../constan
|
|
|
2
2
|
import { RequestOptionsBase } from "../Data";
|
|
3
3
|
import { Query } from "../Query";
|
|
4
4
|
import { TypeOptions } from "../Sitefinity";
|
|
5
|
-
import { utils } from
|
|
5
|
+
import { utils } from "../utils";
|
|
6
6
|
|
|
7
7
|
export class RequestBase {
|
|
8
8
|
public successCb: Function;
|
|
@@ -11,14 +11,14 @@ export class RequestBase {
|
|
|
11
11
|
public key: string | number;
|
|
12
12
|
public urlOptions: TypeOptions;
|
|
13
13
|
protected query: Query;
|
|
14
|
-
|
|
14
|
+
protected action: string;
|
|
15
15
|
private fallbackProperties: string[];
|
|
16
16
|
|
|
17
17
|
constructor(options: RequestOptionsBaseExtended) {
|
|
18
18
|
this.successCb = options.successCb;
|
|
19
19
|
this.failureCb = options.failureCb;
|
|
20
|
-
this.urlOptions = options.urlOptions;
|
|
21
20
|
this.progressCb = options.progressCb;
|
|
21
|
+
this.urlOptions = options.urlOptions;
|
|
22
22
|
this.key = options.key;
|
|
23
23
|
this.action = options.action;
|
|
24
24
|
this.fallbackProperties = options.fallbackProperties;
|
|
@@ -156,6 +156,5 @@ export class RequestBase {
|
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
export interface RequestOptionsBaseExtended extends RequestOptionsBase {
|
|
159
|
-
progressCb?: Function;
|
|
160
159
|
urlOptions: TypeOptions;
|
|
161
160
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GetRequest, GetByIdRequest, CreateRequest, UpdateRequest, DeleteRequest, GetRelatedRequest, GetRelatedByIdRequest, DeleteRelatedRequest, DeleteRelatedByIdRequest, CreateRelatedRequest, UploadRequest, PostRequestOptionsExtended, PutRequestOptionsExtended, RelatedRequestOptionsExtended, RelatedByIdRequestOptionsExtended, UploadRequestOptionsExtended } from "./Request";
|
|
1
|
+
import { GetRequest, GetByIdRequest, CreateRequest, UpdateRequest, DeleteRequest, GetRelatedRequest, GetRelatedByIdRequest, DeleteRelatedRequest, DeleteRelatedByIdRequest, CreateRelatedRequest, UploadRequest, PostRequestOptionsExtended, PutRequestOptionsExtended, RelatedRequestOptionsExtended, RelatedByIdRequestOptionsExtended, UploadRequestOptionsExtended, UploadChunkRequest, CommitChunksRequest, CommitChunksRequestOptionsExtended, UploadChunkRequestOptionsExtended } from "./Request";
|
|
2
2
|
import { SDKOptions, Token } from "../Sitefinity";
|
|
3
3
|
import { BatchRequest, BatchRequestOptionsExtended } from "./BatchRequest";
|
|
4
4
|
import { RequestOptionsBaseExtended } from "./RequestBase";
|
|
@@ -59,6 +59,14 @@ export class RequestFactory {
|
|
|
59
59
|
return new UploadRequest(parameters, this.token, this.options);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
uploadChunk(parameters: UploadChunkRequestOptionsExtended) {
|
|
63
|
+
return new UploadChunkRequest(parameters, this.token, this.options);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
commitChunks(parameters: CommitChunksRequestOptionsExtended) {
|
|
67
|
+
return new CommitChunksRequest(parameters, this.token, this.options);
|
|
68
|
+
}
|
|
69
|
+
|
|
62
70
|
batch(parameters: RequestOptionsBaseExtended) {
|
|
63
71
|
const batchParams = parameters as BatchRequestOptionsExtended;
|
|
64
72
|
batchParams.factory = this;
|
|
@@ -2,7 +2,7 @@ import { Query } from "../Query";
|
|
|
2
2
|
import { Sitefinity } from "../Sitefinity";
|
|
3
3
|
|
|
4
4
|
describe("SDK basic tests", () => {
|
|
5
|
-
const baseUrl = "http://www.mysite.com/api/default/"
|
|
5
|
+
const baseUrl = "http://www.mysite.com/api/default/";
|
|
6
6
|
let sitefinity: Sitefinity;
|
|
7
7
|
let query: Query;
|
|
8
8
|
|
|
@@ -23,13 +23,13 @@ describe("SDK basic tests", () => {
|
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
it("query assert", () => {
|
|
26
|
-
const testQuery = (query.where().and().endsWith("Title", "Record").done() as any).or().startsWith(
|
|
26
|
+
const testQuery = (query.where().and().endsWith("Title", "Record").done() as any).or().startsWith("Title", "asd").done().done();
|
|
27
27
|
const resultingQuery = testQuery.build();
|
|
28
28
|
expect(resultingQuery.$filter).toEqual("(endswith(Title, 'Record')) and (startswith(Title, 'asd'))");
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
it("complex query assert", () => {
|
|
32
|
-
const testQuery = query.where().not().endsWith("Record", "Title").done().and().not().eq(
|
|
32
|
+
const testQuery = query.where().not().endsWith("Record", "Title").done().and().not().eq("Content", "test").done().done().done();
|
|
33
33
|
const resultingQuery = testQuery.build();
|
|
34
34
|
expect(resultingQuery.$filter).toEqual("(not endswith(Record, 'Title')) and ((not (Content eq 'test')))");
|
|
35
35
|
});
|
|
@@ -42,12 +42,12 @@ describe("SDK basic tests", () => {
|
|
|
42
42
|
data.get({query: query.count(false)});
|
|
43
43
|
|
|
44
44
|
let request = jasmine.Ajax.requests.mostRecent();
|
|
45
|
-
expect(request.url).toBe(
|
|
45
|
+
expect(request.url).toBe("http://www.mysite.com/api/default/newsitems/$count");
|
|
46
46
|
|
|
47
47
|
data.get({query: query.count(true)});
|
|
48
48
|
|
|
49
49
|
request = jasmine.Ajax.requests.mostRecent();
|
|
50
|
-
expect(request.url).toBe(
|
|
50
|
+
expect(request.url).toBe("http://www.mysite.com/api/default/newsitems?$count=true");
|
|
51
51
|
});
|
|
52
52
|
|
|
53
53
|
it("request assert", () => {
|
|
@@ -58,14 +58,14 @@ describe("SDK basic tests", () => {
|
|
|
58
58
|
}).get({query: null});
|
|
59
59
|
|
|
60
60
|
const request = jasmine.Ajax.requests.mostRecent();
|
|
61
|
-
expect(request.url).toBe(
|
|
62
|
-
expect(request.method).toBe(
|
|
61
|
+
expect(request.url).toBe("http://www.mysite.com/api/default/newsitems?sf_provider=newsProvider&sf_culture=en-US");
|
|
62
|
+
expect(request.method).toBe("GET");
|
|
63
63
|
expect(request.data()).toEqual({});
|
|
64
64
|
});
|
|
65
65
|
|
|
66
66
|
it("batch assert", async () => {
|
|
67
67
|
const batch = sitefinity.batch();
|
|
68
|
-
const getQuery = query.where().eq(
|
|
68
|
+
const getQuery = query.where().eq("Title", "newTitleN11").done();
|
|
69
69
|
|
|
70
70
|
batch.get({
|
|
71
71
|
entitySet: "newsitems",
|
|
@@ -83,8 +83,8 @@ describe("SDK basic tests", () => {
|
|
|
83
83
|
(batch as any).execute();
|
|
84
84
|
|
|
85
85
|
const request = jasmine.Ajax.requests.mostRecent();
|
|
86
|
-
expect(request.url).toBe(
|
|
87
|
-
expect(request.method).toBe(
|
|
86
|
+
expect(request.url).toBe("http://www.mysite.com/api/default/$batch");
|
|
87
|
+
expect(request.method).toBe("POST");
|
|
88
88
|
|
|
89
89
|
await readBlobAsText(request.params).then((result) => {
|
|
90
90
|
expect(result).toContain("{\"title\":\"Test\"}");
|