@progress/sitefinity-webservices-sdk 1.1.15 → 2.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/README.md +84 -51
- package/esm/chunks/chunk-2ID24RPE.mjs +179 -0
- package/esm/chunks/chunk-2ID24RPE.mjs.map +7 -0
- package/esm/chunks/chunk-AHDZ2CWQ.mjs +93 -0
- package/esm/chunks/chunk-AHDZ2CWQ.mjs.map +7 -0
- package/esm/chunks/chunk-BFLQBM7R.mjs +136 -0
- package/esm/chunks/chunk-BFLQBM7R.mjs.map +7 -0
- package/esm/chunks/chunk-CMGV26CS.mjs +66 -0
- package/esm/chunks/chunk-CMGV26CS.mjs.map +7 -0
- package/esm/chunks/chunk-DHWDJAGV.mjs +180 -0
- package/esm/chunks/chunk-DHWDJAGV.mjs.map +7 -0
- package/esm/chunks/chunk-EH4CERVO.mjs +82 -0
- package/esm/chunks/chunk-EH4CERVO.mjs.map +7 -0
- package/esm/chunks/chunk-F4CWOE7M.mjs +57 -0
- package/esm/chunks/chunk-F4CWOE7M.mjs.map +7 -0
- package/esm/chunks/chunk-FUFBYOIF.mjs +98 -0
- package/esm/chunks/chunk-FUFBYOIF.mjs.map +7 -0
- package/esm/chunks/chunk-J2B7UDVZ.mjs +132 -0
- package/esm/chunks/chunk-J2B7UDVZ.mjs.map +7 -0
- package/esm/chunks/chunk-L3IMDFA5.mjs +1 -0
- package/esm/chunks/chunk-L3IMDFA5.mjs.map +7 -0
- package/esm/chunks/chunk-NNYY2VBC.mjs +383 -0
- package/esm/chunks/chunk-NNYY2VBC.mjs.map +7 -0
- package/esm/chunks/chunk-PI55MBSL.mjs +256 -0
- package/esm/chunks/chunk-PI55MBSL.mjs.map +7 -0
- package/esm/chunks/chunk-PXPK2IV6.mjs +568 -0
- package/esm/chunks/chunk-PXPK2IV6.mjs.map +7 -0
- package/esm/chunks/chunk-QPSEKUOI.mjs +35 -0
- package/esm/chunks/chunk-QPSEKUOI.mjs.map +7 -0
- package/esm/chunks/chunk-RQAAYOY6.mjs +72 -0
- package/esm/chunks/chunk-RQAAYOY6.mjs.map +7 -0
- package/esm/chunks/chunk-TTVNTTW5.mjs +145 -0
- package/esm/chunks/chunk-TTVNTTW5.mjs.map +7 -0
- package/esm/chunks/chunk-VLDX2FH2.mjs +235 -0
- package/esm/chunks/chunk-VLDX2FH2.mjs.map +7 -0
- package/esm/chunks/chunk-VWT2RJET.mjs +102 -0
- package/esm/chunks/chunk-VWT2RJET.mjs.map +7 -0
- package/esm/chunks/chunk-W2OWM3L7.mjs +19 -0
- package/esm/chunks/chunk-W2OWM3L7.mjs.map +7 -0
- package/esm/chunks/chunk-WX5J7F5D.mjs +43 -0
- package/esm/chunks/chunk-WX5J7F5D.mjs.map +7 -0
- package/esm/chunks/chunk-YB2LMPUX.mjs +54 -0
- package/esm/chunks/chunk-YB2LMPUX.mjs.map +7 -0
- package/package.json +67 -36
- package/sitefinity-webservices-sdk.cjs +2761 -0
- package/sitefinity-webservices-sdk.cjs.map +7 -0
- package/sitefinity-webservices-sdk.d.mts +1 -0
- package/{dist/sitefinity-webservices-sdk.d.ts → sitefinity-webservices-sdk.d.ts} +6 -0
- package/sitefinity-webservices-sdk.global.d.ts +5 -0
- package/sitefinity-webservices-sdk.js +2764 -0
- package/sitefinity-webservices-sdk.js.map +7 -0
- package/sitefinity-webservices-sdk.min.js +3 -0
- package/sitefinity-webservices-sdk.mjs +124 -0
- package/sitefinity-webservices-sdk.mjs.map +7 -0
- package/src/BlobBuilder.d.ts +12 -0
- package/src/Data.d.ts +259 -0
- package/src/Expression.d.ts +37 -0
- package/src/OrderProperty.d.ts +24 -0
- package/src/Query.d.ts +104 -0
- package/src/QueryBase.d.ts +40 -0
- package/src/QueryBuilder.d.ts +29 -0
- package/src/Requests/BatchRequest.d.ts +174 -0
- package/src/Requests/ExecutableRequest.d.ts +43 -0
- package/src/Requests/Request.d.ts +225 -0
- package/src/Requests/RequestBase.d.ts +58 -0
- package/{dist/src → src}/Requests/RequestFactory.d.ts +24 -2
- package/src/Sitefinity.d.ts +141 -0
- package/src/Transport/FetchTransport.d.ts +17 -0
- package/src/Transport/HttpTransport.d.ts +69 -0
- package/src/Transport/XhrTransport.d.ts +8 -0
- package/src/WhereQuery.d.ts +88 -0
- package/src/chunk-upload/chunk-upload.sdk.d.ts +305 -0
- package/src/chunk-upload/chunked-file-upload.utilities.d.ts +58 -0
- package/{dist/src → src}/constants.d.ts +21 -0
- package/src/utils.d.ts +103 -0
- package/.editorconfig +0 -29
- package/.eslintignore +0 -4
- package/.eslintrc.js +0 -40
- package/config/helpers.ts +0 -8
- package/config/webpack.common.ts +0 -39
- package/config/webpack.dev.ts +0 -37
- package/config/webpack.prod.ts +0 -17
- package/dist/docs/.nojekyll +0 -1
- package/dist/docs/assets/highlight.css +0 -71
- package/dist/docs/assets/main.js +0 -58
- package/dist/docs/assets/search.js +0 -1
- package/dist/docs/assets/style.css +0 -1280
- package/dist/docs/classes/BlobBuilder.BlobBuilder.html +0 -137
- package/dist/docs/classes/Data.Data.html +0 -387
- package/dist/docs/classes/Expression.BinaryExpression.html +0 -184
- package/dist/docs/classes/Expression.ComplexExpression.html +0 -146
- package/dist/docs/classes/Expression.ExpressionBase.html +0 -125
- package/dist/docs/classes/OrderProperty.OrderProperty.html +0 -151
- package/dist/docs/classes/Query.Query.html +0 -353
- package/dist/docs/classes/QueryBase.QueryBase.html +0 -185
- package/dist/docs/classes/QueryBuilder.QueryBuilder.html +0 -206
- package/dist/docs/classes/Requests_BatchRequest.BatchRequest.html +0 -731
- package/dist/docs/classes/Requests_BatchRequest.Transaction.html +0 -332
- package/dist/docs/classes/Requests_ExecutableRequest.ExecutableRequest.html +0 -340
- package/dist/docs/classes/Requests_Request.CommitChunksRequest.html +0 -303
- package/dist/docs/classes/Requests_Request.CreateRelatedRequest.html +0 -310
- package/dist/docs/classes/Requests_Request.CreateRequest.html +0 -307
- package/dist/docs/classes/Requests_Request.DeleteRelatedByIdRequest.html +0 -309
- package/dist/docs/classes/Requests_Request.DeleteRelatedRequest.html +0 -302
- package/dist/docs/classes/Requests_Request.DeleteRequest.html +0 -298
- package/dist/docs/classes/Requests_Request.GetByIdRequest.html +0 -298
- package/dist/docs/classes/Requests_Request.GetRelatedByIdRequest.html +0 -309
- package/dist/docs/classes/Requests_Request.GetRelatedRequest.html +0 -302
- package/dist/docs/classes/Requests_Request.GetRequest.html +0 -295
- package/dist/docs/classes/Requests_Request.UpdateRequest.html +0 -309
- package/dist/docs/classes/Requests_Request.UploadChunkRequest.html +0 -359
- package/dist/docs/classes/Requests_Request.UploadRequest.html +0 -329
- package/dist/docs/classes/Requests_RequestBase.RequestBase.html +0 -275
- package/dist/docs/classes/Requests_RequestFactory.RequestFactory.html +0 -344
- package/dist/docs/classes/Sitefinity.Sitefinity.html +0 -188
- package/dist/docs/classes/WhereQuery.WhereQuery.html +0 -436
- package/dist/docs/classes/chunk_upload_chunk_upload_sdk.ChunkUploadSdk.html +0 -231
- package/dist/docs/classes/chunk_upload_chunked_file_upload_utilities.ChunkedFileUploadUtilities.html +0 -131
- package/dist/docs/classes/utils.utils.html +0 -303
- package/dist/docs/index.html +0 -129
- package/dist/docs/interfaces/Data.CreateRelatedRequestOptions.html +0 -155
- package/dist/docs/interfaces/Data.CreateRequestOptions.html +0 -153
- package/dist/docs/interfaces/Data.OperationsRequestOptions.html +0 -145
- package/dist/docs/interfaces/Data.PropertyRequestOptions.html +0 -149
- package/dist/docs/interfaces/Data.RequestOptionsBase.html +0 -136
- package/dist/docs/interfaces/Data.SingleRelatedItemRequestOptions.html +0 -155
- package/dist/docs/interfaces/Data.UpdateRequestOptions.html +0 -155
- package/dist/docs/interfaces/Data.UploadRequestOptions.html +0 -169
- package/dist/docs/interfaces/Requests_BatchRequest.BatchCreateRelatedRequestOptions.html +0 -161
- package/dist/docs/interfaces/Requests_BatchRequest.BatchCreateRequestOptions.html +0 -153
- package/dist/docs/interfaces/Requests_BatchRequest.BatchPropertyRequestOptions.html +0 -153
- package/dist/docs/interfaces/Requests_BatchRequest.BatchRequestOptionsBase.html +0 -145
- package/dist/docs/interfaces/Requests_BatchRequest.BatchRequestOptionsExtended.html +0 -153
- package/dist/docs/interfaces/Requests_BatchRequest.BatchSingleItemRequestOptions.html +0 -145
- package/dist/docs/interfaces/Requests_BatchRequest.BatchSingleRelatedItemRequestOptions.html +0 -161
- package/dist/docs/interfaces/Requests_BatchRequest.BatchUpdateRequestOptions.html +0 -161
- package/dist/docs/interfaces/Requests_ExecutableRequest.ResponseHandlers.html +0 -98
- package/dist/docs/interfaces/Requests_Request.CommitChunksRequestOptionsExtended.html +0 -215
- package/dist/docs/interfaces/Requests_Request.PostRequestOptionsExtended.html +0 -159
- package/dist/docs/interfaces/Requests_Request.PutRequestOptionsExtended.html +0 -161
- package/dist/docs/interfaces/Requests_Request.RelatedByIdRequestOptionsExtended.html +0 -169
- package/dist/docs/interfaces/Requests_Request.RelatedRequestOptionsExtended.html +0 -163
- package/dist/docs/interfaces/Requests_Request.UploadChunkRequestOptionsExtended.html +0 -217
- package/dist/docs/interfaces/Requests_Request.UploadRequestOptionsExtended.html +0 -180
- package/dist/docs/interfaces/Requests_RequestBase.RequestOptionsBaseExtended.html +0 -148
- package/dist/docs/interfaces/Sitefinity.SDKOptions.html +0 -128
- package/dist/docs/interfaces/Sitefinity.Token.html +0 -94
- package/dist/docs/interfaces/Sitefinity.TypeOptions.html +0 -160
- package/dist/docs/interfaces/chunk_upload_chunk_upload_sdk.ChunkUploadInfoDTO.html +0 -159
- package/dist/docs/interfaces/chunk_upload_chunk_upload_sdk.ChunkUploadResult.html +0 -111
- package/dist/docs/interfaces/chunk_upload_chunk_upload_sdk.CleanUpChunksRequestOptions.html +0 -171
- package/dist/docs/interfaces/chunk_upload_chunk_upload_sdk.CommitChunksRequestOptions.html +0 -204
- package/dist/docs/interfaces/chunk_upload_chunk_upload_sdk.GetChunkUploadInfoRequestOptions.html +0 -166
- package/dist/docs/interfaces/chunk_upload_chunk_upload_sdk.UploadChunkRequestOptions.html +0 -206
- package/dist/docs/interfaces/chunk_upload_chunked_file_upload_utilities.ChunkFileResult.html +0 -101
- package/dist/docs/interfaces/chunk_upload_chunked_file_upload_utilities.FileUploadChunk.html +0 -94
- package/dist/docs/modules/BlobBuilder.html +0 -73
- package/dist/docs/modules/Data.html +0 -92
- package/dist/docs/modules/Expression.html +0 -77
- package/dist/docs/modules/OrderProperty.html +0 -73
- package/dist/docs/modules/Query.html +0 -73
- package/dist/docs/modules/QueryBase.html +0 -73
- package/dist/docs/modules/QueryBuilder.html +0 -73
- package/dist/docs/modules/Requests_BatchRequest.html +0 -94
- package/dist/docs/modules/Requests_ExecutableRequest.html +0 -78
- package/dist/docs/modules/Requests_Request.html +0 -114
- package/dist/docs/modules/Requests_RequestBase.html +0 -78
- package/dist/docs/modules/Requests_RequestFactory.html +0 -73
- package/dist/docs/modules/Sitefinity.html +0 -82
- package/dist/docs/modules/WhereQuery.html +0 -73
- package/dist/docs/modules/chunk_upload_chunk_upload_sdk.html +0 -88
- package/dist/docs/modules/chunk_upload_chunked_file_upload_utilities.html +0 -80
- package/dist/docs/modules/constants.html +0 -83
- package/dist/docs/modules/utils.html +0 -73
- package/dist/docs/modules.html +0 -80
- package/dist/docs/variables/constants.CONTENT_TYPES.html +0 -76
- package/dist/docs/variables/constants.EXPRESSION_TYPE.html +0 -106
- package/dist/docs/variables/constants.HEADER_NAMES.html +0 -102
- package/dist/docs/variables/constants.HTTP_METHODS.html +0 -84
- package/dist/docs/variables/constants.ODATA_PARAMS.html +0 -90
- package/dist/docs/variables/constants.SF_PARAMS.html +0 -84
- package/dist/samples.html +0 -625
- package/dist/sitefinity-webservices-sdk.js +0 -3125
- package/dist/sitefinity-webservices-sdk.js.map +0 -1
- package/dist/sitefinity-webservices-sdk.min.js +0 -1
- package/dist/src/BlobBuilder.d.ts +0 -14
- package/dist/src/Data.d.ts +0 -154
- package/dist/src/Data.spec.d.ts +0 -1
- package/dist/src/Expression.d.ts +0 -19
- package/dist/src/OrderProperty.d.ts +0 -8
- package/dist/src/Query.d.ts +0 -59
- package/dist/src/QueryBase.d.ts +0 -18
- package/dist/src/QueryBuilder.d.ts +0 -13
- package/dist/src/Requests/BatchRequest.d.ts +0 -146
- package/dist/src/Requests/ExecutableRequest.d.ts +0 -22
- package/dist/src/Requests/Request.d.ts +0 -132
- package/dist/src/Requests/RequestBase.d.ts +0 -27
- package/dist/src/Requests/request.spec.d.ts +0 -1
- package/dist/src/Sitefinity.d.ts +0 -75
- package/dist/src/Sitefinity.spec.d.ts +0 -1
- package/dist/src/WhereQuery.d.ts +0 -72
- package/dist/src/chunk-upload/chunk-upload.sdk.d.ts +0 -295
- package/dist/src/chunk-upload/chunk-upload.sdk.spec.d.ts +0 -1
- package/dist/src/chunk-upload/chunked-file-upload.utilities.d.ts +0 -13
- package/dist/src/utils.d.ts +0 -16
- package/karma.conf.js +0 -29
- package/sitefinity-webservices-sdk.ts +0 -15
- package/src/BlobBuilder.ts +0 -20
- package/src/Data.spec.ts +0 -160
- package/src/Data.ts +0 -418
- package/src/Expression.ts +0 -36
- package/src/OrderProperty.ts +0 -39
- package/src/Query.ts +0 -106
- package/src/QueryBase.ts +0 -57
- package/src/QueryBuilder.ts +0 -180
- package/src/Requests/BatchRequest.ts +0 -807
- package/src/Requests/ExecutableRequest.ts +0 -117
- package/src/Requests/Request.ts +0 -327
- package/src/Requests/RequestBase.ts +0 -163
- package/src/Requests/RequestFactory.ts +0 -75
- package/src/Requests/request.spec.ts +0 -132
- package/src/Sitefinity.spec.ts +0 -483
- package/src/Sitefinity.ts +0 -125
- package/src/WhereQuery.ts +0 -145
- package/src/chunk-upload/chunk-upload.sdk.spec.ts +0 -342
- package/src/chunk-upload/chunk-upload.sdk.ts +0 -439
- package/src/chunk-upload/chunked-file-upload.utilities.ts +0 -64
- package/src/constants.ts +0 -66
- package/src/utils.ts +0 -125
- package/template.html +0 -625
- package/tsconfig.json +0 -38
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { RequestBase, RequestOptionsBaseExtended } from "./RequestBase";
|
|
2
|
-
import { utils } from "../utils";
|
|
3
|
-
import { HEADER_NAMES } from "../constants";
|
|
4
|
-
import { SDKOptions, Token } from "../Sitefinity";
|
|
5
|
-
|
|
6
|
-
const XMLHttpRequestDone = 4;
|
|
7
|
-
|
|
8
|
-
export class ExecutableRequest extends RequestBase {
|
|
9
|
-
protected http: XMLHttpRequest;
|
|
10
|
-
|
|
11
|
-
private token: Token;
|
|
12
|
-
private enableUnlimitedChoices: boolean;
|
|
13
|
-
private integrationMode: boolean;
|
|
14
|
-
|
|
15
|
-
constructor(requestOptions: RequestOptionsBaseExtended, token: Token, sdkOptions: SDKOptions) {
|
|
16
|
-
super(requestOptions);
|
|
17
|
-
this.token = token;
|
|
18
|
-
this.successCb = this.successCb || sdkOptions.handlers?.successCb;
|
|
19
|
-
this.failureCb = this.failureCb || sdkOptions.handlers?.failureCb;
|
|
20
|
-
this.enableUnlimitedChoices = sdkOptions.enableUnlimitedChoices;
|
|
21
|
-
this.integrationMode = sdkOptions.integrationMode;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
execute() {
|
|
25
|
-
this.http = new XMLHttpRequest();
|
|
26
|
-
|
|
27
|
-
this.http.onreadystatechange = () => {
|
|
28
|
-
if (this.http.readyState === XMLHttpRequestDone) {
|
|
29
|
-
if (this.http.status > 0) {
|
|
30
|
-
let data = this.parseResponse(this.http);
|
|
31
|
-
|
|
32
|
-
if (this.http.status >= 200 && this.http.status <= 206) {
|
|
33
|
-
if (this.successCb && utils.isFunction(this.successCb)) {
|
|
34
|
-
this.successCb(data);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
else if (this.http.status >= 400) {
|
|
38
|
-
// When the data is string, we save the string as message
|
|
39
|
-
// and convert the data to normal object with message property
|
|
40
|
-
if (utils.isString(data)) {
|
|
41
|
-
data = {
|
|
42
|
-
message: data
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
data.status = this.http.status;
|
|
47
|
-
|
|
48
|
-
// in case of errors we would like there to be one handler for all of the errors
|
|
49
|
-
if (this.failureCb && utils.isFunction(this.failureCb)) {
|
|
50
|
-
this.failureCb(data);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
this.executeProgressEvent();
|
|
59
|
-
|
|
60
|
-
const method = this.getMethod();
|
|
61
|
-
const url = this.buildUrl();
|
|
62
|
-
this.http.open(method, url, true);
|
|
63
|
-
this.setHeaders(this.http, this.getHeaders());
|
|
64
|
-
|
|
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
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
private setHeaders(http: XMLHttpRequest, headers: { [key: string]: string }) {
|
|
79
|
-
const headerKeys = Object.keys(headers);
|
|
80
|
-
for (let i = 0; i < headerKeys.length; i++) {
|
|
81
|
-
const currentHeaderName = headerKeys[i];
|
|
82
|
-
http.setRequestHeader(currentHeaderName, headers[currentHeaderName]);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (this.token) {
|
|
86
|
-
if (typeof this.token === "string") {
|
|
87
|
-
// for backward compatibility
|
|
88
|
-
http.setRequestHeader(HEADER_NAMES.authorization, this.token);
|
|
89
|
-
} else {
|
|
90
|
-
http.setRequestHeader(HEADER_NAMES.authorization, this.token.type + " " + this.token.value);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (this.enableUnlimitedChoices) {
|
|
95
|
-
http.setRequestHeader(HEADER_NAMES.choicesBinaryRepresentation, "true");
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (this.integrationMode) {
|
|
99
|
-
http.setRequestHeader(HEADER_NAMES.integrationMode, "true");
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// for backward compatibility
|
|
103
|
-
http.setRequestHeader(HEADER_NAMES.serviceRequest, "true");
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export interface ResponseHandlers {
|
|
108
|
-
/**
|
|
109
|
-
* The success handler.
|
|
110
|
-
*/
|
|
111
|
-
successCb?: Function;
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* The failure handler.
|
|
115
|
-
*/
|
|
116
|
-
failureCb?: Function;
|
|
117
|
-
}
|
package/src/Requests/Request.ts
DELETED
|
@@ -1,327 +0,0 @@
|
|
|
1
|
-
import { HEADER_NAMES, HTTP_METHODS } from "../constants";
|
|
2
|
-
import { SDKOptions, Token } from "../Sitefinity";
|
|
3
|
-
import { utils } from "../utils";
|
|
4
|
-
import { ExecutableRequest } from "./ExecutableRequest";
|
|
5
|
-
import { RequestOptionsBaseExtended } from "./RequestBase";
|
|
6
|
-
|
|
7
|
-
export class GetRequest extends ExecutableRequest {
|
|
8
|
-
constructor(requestOptions: RequestOptionsBaseExtended, token: Token, sdkOptions: SDKOptions) {
|
|
9
|
-
super(requestOptions, token, sdkOptions);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
getMethod(): string {
|
|
13
|
-
return HTTP_METHODS.get;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export class GetByIdRequest extends ExecutableRequest {
|
|
18
|
-
constructor(requestOptions: RequestOptionsBaseExtended, token: Token, sdkOptions: SDKOptions) {
|
|
19
|
-
super(requestOptions, token, sdkOptions);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
getMethod(): string {
|
|
23
|
-
return HTTP_METHODS.get;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export class DeleteRequest extends ExecutableRequest {
|
|
28
|
-
constructor(requestOptions: RequestOptionsBaseExtended, token: Token, sdkOptions: SDKOptions) {
|
|
29
|
-
super(requestOptions, token, sdkOptions);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
getMethod(): string {
|
|
33
|
-
return HTTP_METHODS.delete;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export class UpdateRequest extends ExecutableRequest {
|
|
38
|
-
private data: object;
|
|
39
|
-
private saveTemp: boolean;
|
|
40
|
-
|
|
41
|
-
constructor(requestOptions: PutRequestOptionsExtended, token: Token, sdkOptions: SDKOptions) {
|
|
42
|
-
super(requestOptions, token, sdkOptions);
|
|
43
|
-
this.data = requestOptions.data;
|
|
44
|
-
this.saveTemp = requestOptions.saveTemp;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
getMethod(): string {
|
|
48
|
-
return HTTP_METHODS.patch;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
getBody(): object {
|
|
52
|
-
const body = utils.convertDateFieldToISOString(this.data);
|
|
53
|
-
return body;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
getHeaders(): { [key: string]: string } {
|
|
57
|
-
const headers = super.getHeaders();
|
|
58
|
-
if (this.saveTemp) {
|
|
59
|
-
headers[HEADER_NAMES.operation] = "SaveTemp";
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return headers;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export class CreateRequest extends ExecutableRequest {
|
|
67
|
-
protected data: object;
|
|
68
|
-
|
|
69
|
-
constructor(requestOptions: PostRequestOptionsExtended, token: Token, sdkOptions: SDKOptions) {
|
|
70
|
-
super(requestOptions, token, sdkOptions);
|
|
71
|
-
this.data = requestOptions.data;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
getMethod(): string {
|
|
75
|
-
return HTTP_METHODS.post;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
getBody(): object {
|
|
79
|
-
if (!(this.data instanceof File)) {
|
|
80
|
-
return utils.convertDateFieldToISOString(this.data);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return this.data;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export class GetRelatedRequest extends GetByIdRequest {
|
|
88
|
-
private property: string;
|
|
89
|
-
|
|
90
|
-
constructor(requestOptions: RelatedRequestOptionsExtended, token: Token, sdkOptions: SDKOptions) {
|
|
91
|
-
super(requestOptions, token, sdkOptions);
|
|
92
|
-
this.property = requestOptions.property;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
buildUrl(): string {
|
|
96
|
-
const url = this.urlOptions.baseUrl + this.urlOptions.entitySet + "(" + this.key + ")/" + this.property;
|
|
97
|
-
return this.addQueryParameters(url);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export class GetRelatedByIdRequest extends GetByIdRequest {
|
|
102
|
-
private property: string;
|
|
103
|
-
private relatedId: string;
|
|
104
|
-
|
|
105
|
-
constructor(requestOptions: RelatedByIdRequestOptionsExtended, token: Token, sdkOptions: SDKOptions) {
|
|
106
|
-
super(requestOptions, token, sdkOptions);
|
|
107
|
-
this.property = requestOptions.property;
|
|
108
|
-
this.relatedId = requestOptions.relatedId;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
buildUrl(): string {
|
|
112
|
-
const url = this.urlOptions.baseUrl + this.urlOptions.entitySet + "(" + this.key + ")/" + this.property + "(" + this.relatedId + ")";
|
|
113
|
-
return this.addQueryParameters(url);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export class DeleteRelatedRequest extends DeleteRequest {
|
|
118
|
-
private property: string;
|
|
119
|
-
|
|
120
|
-
constructor(requestOptions: RelatedRequestOptionsExtended, token: Token, sdkOptions: SDKOptions) {
|
|
121
|
-
super(requestOptions, token, sdkOptions);
|
|
122
|
-
this.property = requestOptions.property;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
buildUrl(): string {
|
|
126
|
-
const url = this.urlOptions.baseUrl + this.urlOptions.entitySet + "(" + this.key + ")/" + this.property + "/$ref";
|
|
127
|
-
return this.addQueryParameters(url);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export class DeleteRelatedByIdRequest extends DeleteRequest {
|
|
132
|
-
private property: string;
|
|
133
|
-
private relatedId: string;
|
|
134
|
-
|
|
135
|
-
constructor(requestOptions: RelatedByIdRequestOptionsExtended, token: Token, sdkOptions: SDKOptions) {
|
|
136
|
-
super(requestOptions, token, sdkOptions);
|
|
137
|
-
this.property = requestOptions.property;
|
|
138
|
-
this.relatedId = requestOptions.relatedId;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
buildUrl(): string {
|
|
142
|
-
const url = this.urlOptions.baseUrl + this.urlOptions.entitySet + "(" + this.key + ")/" + this.property + "(" + this.relatedId + ")/$ref";
|
|
143
|
-
return this.addQueryParameters(url);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export class CreateRelatedRequest extends CreateRequest {
|
|
148
|
-
private property: string;
|
|
149
|
-
|
|
150
|
-
constructor(requestOptions: RelatedRequestOptionsExtended, token: Token, sdkOptions: SDKOptions) {
|
|
151
|
-
super(requestOptions, token, sdkOptions);
|
|
152
|
-
this.property = requestOptions.property;
|
|
153
|
-
this.key = requestOptions.key;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
buildUrl(): string {
|
|
157
|
-
const url = this.urlOptions.baseUrl + this.urlOptions.entitySet + "(" + this.key + ")/" + this.property + "/$ref";
|
|
158
|
-
return this.addQueryParameters(url);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export class UploadRequest extends CreateRequest {
|
|
163
|
-
private fileName: string;
|
|
164
|
-
private uploadProperties: { [key: string]: string };
|
|
165
|
-
private contentType: string;
|
|
166
|
-
|
|
167
|
-
constructor(requestOptions: UploadRequestOptionsExtended, token: Token, sdkOptions: SDKOptions) {
|
|
168
|
-
super(requestOptions, token, sdkOptions);
|
|
169
|
-
this.fileName = requestOptions.fileName;
|
|
170
|
-
this.uploadProperties = requestOptions.uploadProperties;
|
|
171
|
-
this.contentType = requestOptions.contentType;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
getHeaders(): { [key: string]: string } {
|
|
175
|
-
const headers = super.getHeaders();
|
|
176
|
-
headers[HEADER_NAMES.contentType] = this.contentType || "application/octet-stream";
|
|
177
|
-
headers[HEADER_NAMES.fileName] = this.fileName;
|
|
178
|
-
headers[HEADER_NAMES.properties] = JSON.stringify(this.uploadProperties);
|
|
179
|
-
headers[HEADER_NAMES.contentEncoding] = "identity";
|
|
180
|
-
return headers;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
getBody(): object {
|
|
184
|
-
return this.data;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
getMethod(): string {
|
|
188
|
-
if (this.key) {
|
|
189
|
-
return HTTP_METHODS.patch;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
return HTTP_METHODS.post;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
export class UploadChunkRequest extends CreateRequest {
|
|
197
|
-
contentType: string;
|
|
198
|
-
chunkOrdinal: number;
|
|
199
|
-
chunkSize: number;
|
|
200
|
-
chunkedFileUploadSessionId: string;
|
|
201
|
-
numberOfChunks: number;
|
|
202
|
-
positionInQueue: number;
|
|
203
|
-
blobStorageProviderName: string;
|
|
204
|
-
fileName: string;
|
|
205
|
-
|
|
206
|
-
constructor(requestOptions: UploadChunkRequestOptionsExtended, token: Token, sdkOptions: SDKOptions) {
|
|
207
|
-
super(requestOptions, token, sdkOptions);
|
|
208
|
-
this.contentType = requestOptions.fileMimeType;
|
|
209
|
-
this.chunkOrdinal = requestOptions.chunkOrdinal;
|
|
210
|
-
this.chunkedFileUploadSessionId = requestOptions.chunkedFileUploadSessionId;
|
|
211
|
-
this.chunkSize = requestOptions.chunkSize;
|
|
212
|
-
this.numberOfChunks = requestOptions.numberOfChunks;
|
|
213
|
-
this.positionInQueue = requestOptions.positionOfChunkInQueue;
|
|
214
|
-
this.blobStorageProviderName = requestOptions.blobStorageProviderName;
|
|
215
|
-
this.data = requestOptions.chunkBlob;
|
|
216
|
-
this.fileName = requestOptions.fileName;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
getHeaders(): { [key: string]: string } {
|
|
220
|
-
const headers = super.getHeaders();
|
|
221
|
-
headers[HEADER_NAMES.contentEncoding] = "identity";
|
|
222
|
-
headers[HEADER_NAMES.contentType] = this.contentType || "application/octet-stream";
|
|
223
|
-
headers[HEADER_NAMES.chunkOrdinal] = this.chunkOrdinal.toString();
|
|
224
|
-
headers[HEADER_NAMES.chunkedFileUploadSessionId] = this.chunkedFileUploadSessionId;
|
|
225
|
-
headers[HEADER_NAMES.chunkSize] = this.chunkSize.toString();
|
|
226
|
-
headers[HEADER_NAMES.blobStorageProviderName] = this.blobStorageProviderName.toString();
|
|
227
|
-
headers[HEADER_NAMES.fileName] = this.fileName;
|
|
228
|
-
|
|
229
|
-
return headers;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
getBody(): object {
|
|
233
|
-
return this.data;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
getMethod(): string {
|
|
237
|
-
return HTTP_METHODS.post;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
protected override executeProgressEvent(): void {
|
|
241
|
-
if (this.http.upload) {
|
|
242
|
-
this.http.upload.onprogress = () => {
|
|
243
|
-
const payload = {
|
|
244
|
-
lengthComputable: true,
|
|
245
|
-
loaded: this.positionInQueue,
|
|
246
|
-
total: this.numberOfChunks
|
|
247
|
-
};
|
|
248
|
-
|
|
249
|
-
if (this.progressCb && utils.isFunction(this.progressCb)) {
|
|
250
|
-
this.progressCb(payload);
|
|
251
|
-
}
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
export class CommitChunksRequest extends CreateRequest {
|
|
258
|
-
constructor(requestOptions: CommitChunksRequestOptionsExtended, token: Token, sdkOptions: SDKOptions) {
|
|
259
|
-
super(requestOptions, token, sdkOptions);
|
|
260
|
-
|
|
261
|
-
this.action = "Default.CommitChunks";
|
|
262
|
-
|
|
263
|
-
this.data = {
|
|
264
|
-
// ! this must be the param name that the operation provider on the server accepts
|
|
265
|
-
commitChunksDto: {
|
|
266
|
-
chunkedFileUploadSessionId: requestOptions.chunkedFileUploadSessionId,
|
|
267
|
-
contentType: requestOptions.contentType,
|
|
268
|
-
fileTotalSize: requestOptions.fileTotalSize,
|
|
269
|
-
numberOfChunks: requestOptions.numberOfChunks,
|
|
270
|
-
fileName: requestOptions.fileName,
|
|
271
|
-
blobStorageProviderName: requestOptions.blobStorageProviderName,
|
|
272
|
-
itemId: requestOptions.itemId || null,
|
|
273
|
-
// ! must be named properties
|
|
274
|
-
properties: requestOptions.uploadProperties
|
|
275
|
-
}
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
getMethod(): string {
|
|
280
|
-
return HTTP_METHODS.post;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
export interface PostRequestOptionsExtended extends RequestOptionsBaseExtended {
|
|
285
|
-
data?: object;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
export interface PutRequestOptionsExtended extends PostRequestOptionsExtended {
|
|
289
|
-
saveTemp: boolean;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
export interface RelatedRequestOptionsExtended extends PostRequestOptionsExtended {
|
|
293
|
-
property: string;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
export interface RelatedByIdRequestOptionsExtended extends RelatedRequestOptionsExtended {
|
|
297
|
-
relatedId: string;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
export interface UploadRequestOptionsExtended extends PostRequestOptionsExtended {
|
|
301
|
-
fileName: string;
|
|
302
|
-
contentType: string;
|
|
303
|
-
uploadProperties: { [key: string]: string };
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
export interface UploadChunkRequestOptionsExtended extends PostRequestOptionsExtended {
|
|
307
|
-
fileMimeType: string;
|
|
308
|
-
fileName: string;
|
|
309
|
-
chunkedFileUploadSessionId: string;
|
|
310
|
-
chunkSize: number;
|
|
311
|
-
chunkOrdinal: number;
|
|
312
|
-
numberOfChunks: number;
|
|
313
|
-
chunkBlob: Blob;
|
|
314
|
-
blobStorageProviderName: string;
|
|
315
|
-
positionOfChunkInQueue?: number;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
export interface CommitChunksRequestOptionsExtended extends PostRequestOptionsExtended {
|
|
319
|
-
chunkedFileUploadSessionId: string
|
|
320
|
-
blobStorageProviderName: string;
|
|
321
|
-
contentType: string;
|
|
322
|
-
fileTotalSize: number;
|
|
323
|
-
numberOfChunks: number;
|
|
324
|
-
fileName: string;
|
|
325
|
-
uploadProperties: { [key: string]: string };
|
|
326
|
-
itemId?: string;
|
|
327
|
-
}
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import { CONTENT_TYPES, HEADER_NAMES, ODATA_PARAMS, SF_PARAMS } from "../constants";
|
|
2
|
-
import { RequestOptionsBase } from "../Data";
|
|
3
|
-
import { Query } from "../Query";
|
|
4
|
-
import { TypeOptions } from "../Sitefinity";
|
|
5
|
-
import { utils } from "../utils";
|
|
6
|
-
|
|
7
|
-
export class RequestBase {
|
|
8
|
-
public successCb: Function;
|
|
9
|
-
public failureCb: Function;
|
|
10
|
-
public progressCb: Function;
|
|
11
|
-
public key: string | number;
|
|
12
|
-
public urlOptions: TypeOptions;
|
|
13
|
-
protected query: Query;
|
|
14
|
-
protected action: string;
|
|
15
|
-
private fallbackProperties: string[];
|
|
16
|
-
|
|
17
|
-
constructor(options: RequestOptionsBaseExtended) {
|
|
18
|
-
this.successCb = options.successCb;
|
|
19
|
-
this.failureCb = options.failureCb;
|
|
20
|
-
this.progressCb = options.progressCb;
|
|
21
|
-
this.urlOptions = options.urlOptions;
|
|
22
|
-
this.key = options.key;
|
|
23
|
-
this.action = options.action;
|
|
24
|
-
this.fallbackProperties = options.fallbackProperties;
|
|
25
|
-
this.query = options.query;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
getQueryString(urlOptions: TypeOptions, query: Query): string {
|
|
29
|
-
const paramDictionary: { [key: string]: string } = {};
|
|
30
|
-
|
|
31
|
-
this.getQueryParameters(paramDictionary, urlOptions, query);
|
|
32
|
-
const keys = Object.keys(paramDictionary);
|
|
33
|
-
if (keys.length == 0)
|
|
34
|
-
return null;
|
|
35
|
-
|
|
36
|
-
let queryString = "?";
|
|
37
|
-
for (const prop in paramDictionary) {
|
|
38
|
-
queryString += prop + "=" + paramDictionary[prop] + "&";
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
queryString = queryString.substring(0, queryString.length - 1);
|
|
42
|
-
|
|
43
|
-
return queryString;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
getBody(): object {
|
|
47
|
-
return undefined;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
getMethod(): string {
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
getHeaders(): { [key: string]: string } {
|
|
55
|
-
const headers = this.urlOptions.additionalHeaders ?? {};
|
|
56
|
-
if (headers[HEADER_NAMES.contentType] == undefined) {
|
|
57
|
-
headers[HEADER_NAMES.contentType] = CONTENT_TYPES.json;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return headers;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
buildUrl(): string {
|
|
64
|
-
let url = this.urlOptions.baseUrl + (this.urlOptions.entitySet || "");
|
|
65
|
-
url += this.key ? ("(" + this.key + ")") : "";
|
|
66
|
-
if (this.action) {
|
|
67
|
-
url += url.endsWith("/") ? "" : "/";
|
|
68
|
-
url += this.action;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// including count here
|
|
72
|
-
// not the best solution as build() is called once more in getQueryString
|
|
73
|
-
// but not that big of an issue right now
|
|
74
|
-
if (this.query) {
|
|
75
|
-
const getCount = this.query.build().$count;
|
|
76
|
-
|
|
77
|
-
if (utils.isBoolean(getCount) && !getCount) {
|
|
78
|
-
url += "/$count";
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return this.addQueryParameters(url);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
protected parseResponse(http: XMLHttpRequest): string | any {
|
|
86
|
-
const data = utils.parseStringToJson(http.responseText);
|
|
87
|
-
if (data) {
|
|
88
|
-
if (http.status >= 400 && data.error) {
|
|
89
|
-
return data.error;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return data;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return http.responseText;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
protected addQueryParameters(url: string): string {
|
|
99
|
-
let queryString = this.getQueryString(this.urlOptions, this.query);
|
|
100
|
-
|
|
101
|
-
if (queryString) {
|
|
102
|
-
if (url.indexOf("?") > -1 && queryString[0] == "?") {
|
|
103
|
-
queryString = "&" + queryString.substring(1);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
url += queryString;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return url;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
private getQueryParameters(paramDictionary: { [key: string]: string }, urlOptions: TypeOptions, query: Query) {
|
|
113
|
-
if (query) {
|
|
114
|
-
const builtQuery = query.build();
|
|
115
|
-
if (utils.isString(builtQuery.$filter))
|
|
116
|
-
paramDictionary[ODATA_PARAMS.$filter] = builtQuery.$filter;
|
|
117
|
-
if (utils.isString(builtQuery.$select))
|
|
118
|
-
paramDictionary[ODATA_PARAMS.$select] = builtQuery.$select;
|
|
119
|
-
if (utils.isString(builtQuery.$expand))
|
|
120
|
-
paramDictionary[ODATA_PARAMS.$expand] = builtQuery.$expand;
|
|
121
|
-
if (utils.isString(builtQuery.$orderby))
|
|
122
|
-
paramDictionary[ODATA_PARAMS.$orderby] = builtQuery.$orderby;
|
|
123
|
-
if (utils.isNumber(builtQuery.$skip))
|
|
124
|
-
paramDictionary[ODATA_PARAMS.$skip] = builtQuery.$skip;
|
|
125
|
-
if (utils.isNumber(builtQuery.$top))
|
|
126
|
-
paramDictionary[ODATA_PARAMS.$top] = builtQuery.$top;
|
|
127
|
-
if (utils.isString(builtQuery.$search))
|
|
128
|
-
paramDictionary[ODATA_PARAMS.$search] = builtQuery.$search;
|
|
129
|
-
|
|
130
|
-
// inline count
|
|
131
|
-
if (utils.isBoolean(builtQuery.$count) && builtQuery.$count)
|
|
132
|
-
paramDictionary[ODATA_PARAMS.$count] = builtQuery.$count;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (urlOptions.provider) {
|
|
136
|
-
paramDictionary[SF_PARAMS.provider] = urlOptions.provider;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (urlOptions.culture) {
|
|
140
|
-
paramDictionary[SF_PARAMS.culture] = urlOptions.culture;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if (urlOptions.siteId) {
|
|
144
|
-
paramDictionary[SF_PARAMS.siteId] = urlOptions.siteId;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if (this.fallbackProperties) {
|
|
148
|
-
paramDictionary[SF_PARAMS.fallbackParams] = this.fallbackProperties.join();
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (urlOptions.additionalQueryParams) {
|
|
152
|
-
for (const key in urlOptions.additionalQueryParams) {
|
|
153
|
-
if (urlOptions.additionalQueryParams.hasOwnProperty(key)) {
|
|
154
|
-
paramDictionary[key] = urlOptions.additionalQueryParams[key];
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
export interface RequestOptionsBaseExtended extends RequestOptionsBase {
|
|
162
|
-
urlOptions: TypeOptions;
|
|
163
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
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
|
-
import { SDKOptions, Token } from "../Sitefinity";
|
|
3
|
-
import { BatchRequest, BatchRequestOptionsExtended } from "./BatchRequest";
|
|
4
|
-
import { RequestOptionsBaseExtended } from "./RequestBase";
|
|
5
|
-
|
|
6
|
-
export class RequestFactory {
|
|
7
|
-
public token: Token;
|
|
8
|
-
private options: SDKOptions;
|
|
9
|
-
|
|
10
|
-
constructor(options: SDKOptions) {
|
|
11
|
-
this.options = options;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
get(parameters: RequestOptionsBaseExtended) {
|
|
15
|
-
return new GetRequest(parameters, this.token, this.options);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
getSingle(parameters: RequestOptionsBaseExtended) {
|
|
19
|
-
return new GetByIdRequest(parameters, this.token, this.options);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
create(parameters: PostRequestOptionsExtended) {
|
|
23
|
-
return new CreateRequest(parameters, this.token, this.options);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
update(parameters: PutRequestOptionsExtended) {
|
|
27
|
-
return new UpdateRequest(parameters, this.token, this.options);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
destroy(parameters: RequestOptionsBaseExtended) {
|
|
31
|
-
return new DeleteRequest(parameters, this.token, this.options);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
getProperty(parameters: RelatedRequestOptionsExtended) {
|
|
35
|
-
return new GetRelatedRequest(parameters, this.token, this.options);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
getRelated(parameters: RelatedRequestOptionsExtended) {
|
|
39
|
-
return new GetRelatedRequest(parameters, this.token, this.options);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
getRelatedById(parameters: RelatedByIdRequestOptionsExtended) {
|
|
43
|
-
return new GetRelatedByIdRequest(parameters, this.token, this.options);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
destroyRelated(parameters: RelatedRequestOptionsExtended) {
|
|
47
|
-
return new DeleteRelatedRequest(parameters, this.token, this.options);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
destroyRelatedById(parameters: RelatedByIdRequestOptionsExtended) {
|
|
51
|
-
return new DeleteRelatedByIdRequest(parameters, this.token, this.options);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
createRelated(parameters: RelatedRequestOptionsExtended) {
|
|
55
|
-
return new CreateRelatedRequest(parameters, this.token, this.options);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
upload(parameters: UploadRequestOptionsExtended) {
|
|
59
|
-
return new UploadRequest(parameters, this.token, this.options);
|
|
60
|
-
}
|
|
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
|
-
|
|
70
|
-
batch(parameters: RequestOptionsBaseExtended) {
|
|
71
|
-
const batchParams = parameters as BatchRequestOptionsExtended;
|
|
72
|
-
batchParams.factory = this;
|
|
73
|
-
return new BatchRequest(batchParams, this.token, this.options);
|
|
74
|
-
}
|
|
75
|
-
}
|