@progress/sitefinity-webservices-sdk 1.1.16 → 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/.github/copilot-instructions.md +0 -72
- package/.github/instructions/sitefinity-webservices-sdk.instructions.md +0 -53
- 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 -3243
- 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 -154
- 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 -347
- 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
package/src/Sitefinity.ts
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { RequestFactory } from "./Requests/RequestFactory";
|
|
2
|
-
import { Data } from "./Data";
|
|
3
|
-
import { Query } from "./Query";
|
|
4
|
-
import { utils } from "./utils";
|
|
5
|
-
import { ResponseHandlers } from "./Requests/ExecutableRequest";
|
|
6
|
-
import { BatchRequest } from "./Requests/BatchRequest";
|
|
7
|
-
|
|
8
|
-
export class Sitefinity {
|
|
9
|
-
public static Query: typeof Query = Query;
|
|
10
|
-
|
|
11
|
-
private factory: RequestFactory;
|
|
12
|
-
private baseUrl: string;
|
|
13
|
-
private siteId: string;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* The constructor of the Sitefinity JavaScript SDK. This is the entry point for the SDK.
|
|
17
|
-
*/
|
|
18
|
-
constructor(options: SDKOptions) {
|
|
19
|
-
this.baseUrl = options.baseUrl;
|
|
20
|
-
this.siteId = options.siteId;
|
|
21
|
-
this.factory = new RequestFactory(options);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
data(options: TypeOptions): Data {
|
|
25
|
-
const urlOptions: TypeOptions = {
|
|
26
|
-
baseUrl: utils.addTrailingSlash(options.baseUrl || this.baseUrl),
|
|
27
|
-
provider: options.provider,
|
|
28
|
-
culture: options.culture,
|
|
29
|
-
siteId: options.siteId || this.siteId,
|
|
30
|
-
additionalQueryParams: options.additionalQueryParams,
|
|
31
|
-
additionalHeaders: options.additionalHeaders,
|
|
32
|
-
entitySet: options.entitySet
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
return new Data(urlOptions, this.factory);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
batch(success?: Function, failure?: Function, progress?: Function, options?: TypeOptions): BatchRequest {
|
|
39
|
-
if (!options)
|
|
40
|
-
options = {};
|
|
41
|
-
|
|
42
|
-
const batch = this.factory.batch({
|
|
43
|
-
successCb: success,
|
|
44
|
-
failureCb: failure,
|
|
45
|
-
progressCb: progress,
|
|
46
|
-
urlOptions: {
|
|
47
|
-
baseUrl: utils.addTrailingSlash(options.baseUrl || this.baseUrl),
|
|
48
|
-
provider: options.provider,
|
|
49
|
-
culture: options.culture,
|
|
50
|
-
siteId: options.siteId || this.siteId,
|
|
51
|
-
additionalQueryParams: options.additionalQueryParams,
|
|
52
|
-
additionalHeaders: options.additionalHeaders
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
return batch;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Sets the authentication token.
|
|
61
|
-
*/
|
|
62
|
-
setToken(token: Token) {
|
|
63
|
-
this.factory.token = token;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
interface OptionsBase {
|
|
68
|
-
/**
|
|
69
|
-
* Your service url that points to the configured instance of Sitefinity service.
|
|
70
|
-
*/
|
|
71
|
-
baseUrl?: string;
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* The ID of the site, for which the queries will be executed.
|
|
75
|
-
*/
|
|
76
|
-
siteId?: string;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Defines an object containing configuration options for the SDK object.
|
|
81
|
-
*/
|
|
82
|
-
export interface SDKOptions extends OptionsBase {
|
|
83
|
-
/**
|
|
84
|
-
* The global handlers for request execution
|
|
85
|
-
*/
|
|
86
|
-
handlers?: ResponseHandlers;
|
|
87
|
-
|
|
88
|
-
enableUnlimitedChoices?: boolean;
|
|
89
|
-
integrationMode?: boolean;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Defines an object containing configuration options related to a specific type.
|
|
94
|
-
*/
|
|
95
|
-
export interface TypeOptions extends OptionsBase {
|
|
96
|
-
/**
|
|
97
|
-
* The URL name of the type.
|
|
98
|
-
*/
|
|
99
|
-
entitySet?: string;
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* The name of the provider. If empty the default provider for the site will be used.
|
|
103
|
-
*/
|
|
104
|
-
provider?: string;
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* The name of the culture. If empty the default culture for the site will be used.
|
|
108
|
-
*/
|
|
109
|
-
culture?: string;
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Query params to be added to the request url.
|
|
113
|
-
*/
|
|
114
|
-
additionalQueryParams?: { [key: string]: string };
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Headers to be added to the request.
|
|
118
|
-
*/
|
|
119
|
-
additionalHeaders?: { [key: string]: string };
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export interface Token {
|
|
123
|
-
type: string;
|
|
124
|
-
value: string;
|
|
125
|
-
}
|
package/src/WhereQuery.ts
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { ComplexExpression, BinaryExpression } from "./Expression";
|
|
2
|
-
import { EXPRESSION_TYPE } from "./constants";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* A fluent API operation for creating a filter for a query by chaining different rules.
|
|
6
|
-
*/
|
|
7
|
-
export class WhereQuery<QueryType> {
|
|
8
|
-
private expression: ComplexExpression;
|
|
9
|
-
|
|
10
|
-
constructor(private parent: QueryType, type: string = EXPRESSION_TYPE.and) {
|
|
11
|
-
this.expression = new ComplexExpression(type, []);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Adds an `and` clause to the current condition and returns it for further chaining.
|
|
16
|
-
*/
|
|
17
|
-
and(): WhereQuery<WhereQuery<QueryType>> {
|
|
18
|
-
return new WhereQuery(this, EXPRESSION_TYPE.and);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Adds an `or` clause to the current condition and returns it for further chaining.
|
|
23
|
-
*/
|
|
24
|
-
or(): WhereQuery<WhereQuery<QueryType>> {
|
|
25
|
-
return new WhereQuery(this, EXPRESSION_TYPE.or);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Adds an `any` clause to the current condition and returns it for further chaining.
|
|
30
|
-
*/
|
|
31
|
-
any(): WhereQuery<WhereQuery<QueryType>> {
|
|
32
|
-
return new WhereQuery(this, EXPRESSION_TYPE.any);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Adds a `not` clause to the current condition and returns it for further chaining.
|
|
37
|
-
*/
|
|
38
|
-
not(): WhereQuery<WhereQuery<QueryType>> {
|
|
39
|
-
return new WhereQuery(this, EXPRESSION_TYPE.not);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Adds a condition that a field must be equal to a specific value.
|
|
44
|
-
*/
|
|
45
|
-
eq(parameter: string, constant: any): WhereQuery<QueryType> {
|
|
46
|
-
return this.simple(EXPRESSION_TYPE.eq, parameter, constant);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Adds a condition that a field must *not* be equal to a specific value.
|
|
51
|
-
*/
|
|
52
|
-
ne(parameter: string, constant: any): WhereQuery<QueryType> {
|
|
53
|
-
return this.simple(EXPRESSION_TYPE.ne, parameter, constant);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Adds a condition that a field must be `greater than` a certain value. Applicable to Number, String, and Date fields.
|
|
58
|
-
*/
|
|
59
|
-
gt(parameter: string, constant: any) {
|
|
60
|
-
return this.simple(EXPRESSION_TYPE.gt, parameter, constant);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Adds a condition that a field must be `greater than or equal` to a certain value. Applicable to Number, String, and Date fields.
|
|
65
|
-
*/
|
|
66
|
-
gte(parameter: string, constant: any) {
|
|
67
|
-
return this.simple(EXPRESSION_TYPE.ge, parameter, constant);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Adds a condition that a field must be `less than` a certain value. Applicable to Number, String, and Date fields.
|
|
72
|
-
*/
|
|
73
|
-
lt(parameter: string, constant: any) {
|
|
74
|
-
return this.simple(EXPRESSION_TYPE.lt, parameter, constant);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Adds a condition that a field must be `less than or equal` to a certain value. Applicable to Number, String, and Date fields.
|
|
79
|
-
*/
|
|
80
|
-
lte(parameter: string, constant: any) {
|
|
81
|
-
return this.simple(EXPRESSION_TYPE.le, parameter, constant);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Adds a condition that a field value must *start* with a specified string.
|
|
86
|
-
*/
|
|
87
|
-
startsWith(parameter: string, constant: any, caseSensitive = true) {
|
|
88
|
-
return this.simple(EXPRESSION_TYPE.startsWith, parameter, constant, caseSensitive);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Adds a condition that a field value must *contain* a specified string.
|
|
93
|
-
*/
|
|
94
|
-
contains(parameter: string, constant: any, caseSensitive = true) {
|
|
95
|
-
return this.simple(EXPRESSION_TYPE.contains, parameter, constant, caseSensitive);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Adds a condition that a field value must *end* with a specified string.
|
|
100
|
-
*/
|
|
101
|
-
endsWith(parameter: string, constant: any, caseSensitive = true) {
|
|
102
|
-
return this.simple(EXPRESSION_TYPE.endsWith, parameter, constant, caseSensitive);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Adds a condition that specific values should be found in that field e.g. Id in (id1, id2, id3).
|
|
107
|
-
*/
|
|
108
|
-
in(parameter: string, constant: any) {
|
|
109
|
-
return this.simple(EXPRESSION_TYPE.in, parameter, constant);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Ends the definition of the current WhereQuery. You need to call this method in order to continue with the definition of the parent {@link Query}. All other `WhereQuery` methods return the current instance of `WhereQuery` to allow chaining.
|
|
114
|
-
*/
|
|
115
|
-
done(): QueryType {
|
|
116
|
-
if (this.parent instanceof WhereQuery) {
|
|
117
|
-
this.parent.addComplexExpression(this);
|
|
118
|
-
// TODO: If has and() || or() must call done() twice
|
|
119
|
-
if (this.expression.getType() === EXPRESSION_TYPE.not)
|
|
120
|
-
return this.parent;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return this.parent;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
getExpression(): ComplexExpression {
|
|
127
|
-
return this.expression;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
private simple(type: string, parameter: string, constant: any, caseSensitive = true): WhereQuery<QueryType> {
|
|
131
|
-
const currentExpr = new BinaryExpression(type, parameter, constant, caseSensitive);
|
|
132
|
-
const subExpressions = this.expression.getExpressions();
|
|
133
|
-
subExpressions.push(currentExpr);
|
|
134
|
-
|
|
135
|
-
if (this.expression.getType() === EXPRESSION_TYPE.not && subExpressions.length > 1)
|
|
136
|
-
throw new Error("Invalid operators count!");
|
|
137
|
-
|
|
138
|
-
return this;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
private addComplexExpression(subQuery: WhereQuery<QueryType>): void {
|
|
142
|
-
const subExpression = subQuery.getExpression();
|
|
143
|
-
this.expression.getExpressions().push(subExpression);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
@@ -1,347 +0,0 @@
|
|
|
1
|
-
import { Sitefinity, TypeOptions } from "../Sitefinity";
|
|
2
|
-
import { ChunkUploadInfoDTO, ChunkUploadResult, ChunkUploadSdk, CleanUpChunksRequestOptions, CommitChunksRequestOptions, GetChunkUploadInfoRequestOptions, UploadChunkRequestOptions } from "./chunk-upload.sdk";
|
|
3
|
-
import { FileUploadChunk } from "./chunked-file-upload.utilities";
|
|
4
|
-
|
|
5
|
-
const baseUrl = "http://www.mysite.com/api/default/";
|
|
6
|
-
const chunkSize10MegaBytes = 10000000;
|
|
7
|
-
const typeOptions: TypeOptions = {
|
|
8
|
-
entitySet: "images"
|
|
9
|
-
};
|
|
10
|
-
const mimeType = "image/jpeg";
|
|
11
|
-
const libraryId = "4dff7037-e3e4-4980-8cd2-333333333333";
|
|
12
|
-
const chunkedFileUploadSessionId = "4dff7037-e3e4-4980-8cd2-666666666666";
|
|
13
|
-
const blobStorageProviderName = "Database";
|
|
14
|
-
const itemId = "4dff7037-e3e4-4980-8cd2-999999999999";
|
|
15
|
-
const fileName = "fakeImage тест.jpeg";
|
|
16
|
-
const uploadProperties = {
|
|
17
|
-
"Title": "asd",
|
|
18
|
-
"UrlName": "asd"
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
describe("Chunk upload tests", () => {
|
|
22
|
-
let sitefinity: Sitefinity;
|
|
23
|
-
let chunkUploadSdk: ChunkUploadSdk;
|
|
24
|
-
|
|
25
|
-
beforeAll(() => {
|
|
26
|
-
sitefinity = new Sitefinity({
|
|
27
|
-
baseUrl
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
chunkUploadSdk = sitefinity.data(typeOptions).chunkUpload;
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
beforeEach(function () {
|
|
34
|
-
jasmine.Ajax.install();
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
afterEach(function () {
|
|
38
|
-
jasmine.Ajax.uninstall();
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it("chunkFile should take base64 string input and convert it successfully to a blob and produce expected chunks result", () => {
|
|
42
|
-
const result = chunkUploadSdk.chunkFile(getBase64Image713BytesInSize(), chunkSize10MegaBytes, mimeType);
|
|
43
|
-
|
|
44
|
-
// a bit of magic, but this is the size of the base64
|
|
45
|
-
expect(result.fileTotalSize).toEqual(713);
|
|
46
|
-
// there should be only 1 chunk since the chunk size is 10MB
|
|
47
|
-
expect(result.totalChunksCount).toBe(1);
|
|
48
|
-
|
|
49
|
-
expect(result.chunks[0].content instanceof Blob).toBeTrue();
|
|
50
|
-
expect(result.chunks[0].content.size).toEqual(713);
|
|
51
|
-
expect(result.chunks[0].content.type).toEqual(mimeType);
|
|
52
|
-
expect(result.chunks[0].ordinal).toEqual(0);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it("chunkFile should generate correct number of chunks with correct size when the chunk size divides the files size with a remainder.", () => {
|
|
56
|
-
// if we have a file that is 713 bytes in size and we chunk it in parts with the size of
|
|
57
|
-
// 2 bytes, we should get 357 chunks, (713/2 = 356.5), thus there should be 356 chunks with
|
|
58
|
-
// size of 2 bytes and the 357th chunk should have a size of 1 byte.
|
|
59
|
-
const testFileSize = 713;
|
|
60
|
-
const chunkSize2Bytes = 2;
|
|
61
|
-
const expectedSizeOfLastChunk = testFileSize % chunkSize2Bytes;
|
|
62
|
-
const expectNumberOfChunks = Math.ceil(testFileSize / chunkSize2Bytes);
|
|
63
|
-
|
|
64
|
-
const result = chunkUploadSdk.chunkFile(getBase64Image713BytesInSize(), chunkSize2Bytes, mimeType);
|
|
65
|
-
|
|
66
|
-
expect(result.fileTotalSize).toEqual(testFileSize);
|
|
67
|
-
expect(result.totalChunksCount).toEqual(expectNumberOfChunks);
|
|
68
|
-
|
|
69
|
-
result.chunks.forEach((chunk, i) => {
|
|
70
|
-
expect(chunk.ordinal).toEqual(i);
|
|
71
|
-
expect(chunk.content.type).toEqual(mimeType);
|
|
72
|
-
|
|
73
|
-
if (i === result.totalChunksCount - 1) {
|
|
74
|
-
expect(chunk.content.size).toEqual(expectedSizeOfLastChunk);
|
|
75
|
-
} else {
|
|
76
|
-
expect(chunk.content.size).toEqual(chunkSize2Bytes);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it("getChunkUploadInfo should set correct action name and parameter and be a GET request", () => {
|
|
83
|
-
const requestOptions: GetChunkUploadInfoRequestOptions = {
|
|
84
|
-
data: {
|
|
85
|
-
libraryId
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
chunkUploadSdk.getChunkUploadInfo(requestOptions);
|
|
90
|
-
|
|
91
|
-
const getChunkUploadInfoRequest = jasmine.Ajax.requests.mostRecent();
|
|
92
|
-
|
|
93
|
-
assertGetChunkUploadInfoRequest(getChunkUploadInfoRequest);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it("cleanUpChunks should set correct action name and parameters and be a POST request", () => {
|
|
97
|
-
const cleanUpChunksRequestOptions: CleanUpChunksRequestOptions = {
|
|
98
|
-
data: {
|
|
99
|
-
chunkedFileUploadSessionId,
|
|
100
|
-
blobStorageProviderName
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
chunkUploadSdk.cleanUpChunks(cleanUpChunksRequestOptions);
|
|
105
|
-
|
|
106
|
-
const cleanUpChunksRequest = jasmine.Ajax.requests.mostRecent();
|
|
107
|
-
|
|
108
|
-
expect(cleanUpChunksRequest.url).toContain("Default.CleanUpChunks");
|
|
109
|
-
expect(cleanUpChunksRequest.params).toBe(JSON.stringify(cleanUpChunksRequestOptions.data));
|
|
110
|
-
expect(cleanUpChunksRequest.url).toContain(typeOptions.entitySet);
|
|
111
|
-
expect(cleanUpChunksRequest.method).toBe("POST");
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it("commitChunks should set correct action name and parameters and be a POST request", () => {
|
|
115
|
-
const fileTotalSize = 1000;
|
|
116
|
-
const numberOfChunks = Math.ceil(fileTotalSize / chunkSize10MegaBytes);
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const commitChunksRequestOptions: CommitChunksRequestOptions = {
|
|
120
|
-
data: {
|
|
121
|
-
chunkedFileUploadSessionId,
|
|
122
|
-
contentType: mimeType,
|
|
123
|
-
fileTotalSize,
|
|
124
|
-
numberOfChunks,
|
|
125
|
-
name: fileName,
|
|
126
|
-
blobStorageProviderName,
|
|
127
|
-
itemId,
|
|
128
|
-
uploadProperties
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
chunkUploadSdk.commitChunks(commitChunksRequestOptions);
|
|
133
|
-
|
|
134
|
-
const commitChunksRequest = jasmine.Ajax.requests.mostRecent();
|
|
135
|
-
assertCommitChunksRequest(commitChunksRequest, commitChunksRequestOptions);
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
it("uploadChunk should set correct url, headers, body to be a Blob and be a POST request", () => {
|
|
139
|
-
const result = chunkUploadSdk.chunkFile(getBase64Image713BytesInSize(), chunkSize10MegaBytes, mimeType);
|
|
140
|
-
|
|
141
|
-
const expectedChunksCount = Math.ceil(713 / chunkSize10MegaBytes);
|
|
142
|
-
|
|
143
|
-
expect(result.totalChunksCount).toEqual(expectedChunksCount);
|
|
144
|
-
|
|
145
|
-
result.chunks.forEach(chunk => {
|
|
146
|
-
const uploadChunkRequestOptions: UploadChunkRequestOptions = {
|
|
147
|
-
data: {
|
|
148
|
-
fileName: fileName,
|
|
149
|
-
fileMimeType: mimeType,
|
|
150
|
-
chunkedFileUploadSessionId,
|
|
151
|
-
chunkSize: chunkSize10MegaBytes,
|
|
152
|
-
chunkOrdinal: chunk.ordinal,
|
|
153
|
-
numberOfChunks: result.totalChunksCount,
|
|
154
|
-
positionOfChunkInQueue: chunk.ordinal,
|
|
155
|
-
chunkBlob: chunk.content,
|
|
156
|
-
blobStorageProviderName: blobStorageProviderName
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
chunkUploadSdk.uploadChunk(uploadChunkRequestOptions);
|
|
161
|
-
|
|
162
|
-
const chunkUploadRequest = jasmine.Ajax.requests.mostRecent();
|
|
163
|
-
|
|
164
|
-
assertChunkUploadRequest(chunkUploadRequest, chunk);
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it("partially simulate chunk upload", () => {
|
|
169
|
-
const GET_CHUNK_UPLOAD_INFO_RESPONSE_MOCK = {
|
|
170
|
-
"@odata.context": "http://localhost:1337/sf/system/$metadata#Telerik.Sitefinity.Web.Api.OData.Operations.Media.Models.ChunkUploadInfo",
|
|
171
|
-
"ProviderSupportsChunkUpload": true,
|
|
172
|
-
"BlobStorageProviderName": "Database",
|
|
173
|
-
"ChunkedFileUploadSessionId": chunkedFileUploadSessionId,
|
|
174
|
-
"ChunkSize": chunkSize10MegaBytes,
|
|
175
|
-
"MaxRetryCountForChunk": 5,
|
|
176
|
-
"MaxSimultaneousChunkUploadRequestsPerSession": 10
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
const CHUNK_UPLOAD_RESPONSE_MOCK = {
|
|
180
|
-
"SuccessfullyUploaded": true,
|
|
181
|
-
"ChunkedFileUploadSessionId": chunkedFileUploadSessionId
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
const COMMIT_CHUNKS_RESPONSE_MOCK = {
|
|
185
|
-
"@odata.context": "http://localhost:1337/sf/system/$metadata#images/$entity", "Id": "e3dfab01-3e0b-4e60-9a38-934c640c937d", "LastModified": "2022-09-07T08:23:36Z", "PublicationDate": "2022-09-07T08:23:34Z", "Title": "christmas_pack", "Description": "", "DateCreated": "2022-09-07T08:23:34Z", "IncludeInSitemap": true, "SystemSourceKey": null, "Ordinal": -1, "UrlName": "christmas_pack", "ItemDefaultUrl": "/images/default-source/default-album/christmas_pack", "Author": "", "Extension": ".jpg", "MimeType": "image/jpeg", "TotalSize": 141429, "Tags": [], "Category": [], "Width": 600, "Height": 400, "AlternativeText": "", "FolderId": null, "ParentId": "4ba7ad46-f29b-4e65-be17-9bf7ce5ba1fb", "Urls": [], "MediaFileUrlName": "christmas_pack", "MediaFileUrls": [], "Provider": "OpenAccessDataProvider", "Url": "http://localhost:1337/images/default-source/default-album/christmas_pack.jpg?Status=Master&sfvrsn=4ed4e51c_1", "ThumbnailUrl": "http://localhost:1337/images/default-source/default-album/christmas_pack.tmb-0.jpg?Status=Master&Culture=en&sfvrsn=4ed4e51c_1", "IsDamMedia": false, "Breadcrumb": ["Default Library"], "CreatedBy": "stefan koserkov", "LastModifiedBy": "stefan koserkov", "AvailableLanguages": ["en"], "LibraryTitle": "Default Library", "Thumbnails": [{ "Title": "0", "Url": "http://localhost:1337/images/default-source/default-album/christmas_pack.tmb-0.jpg?Status=Master&Culture=en&sfvrsn=4ed4e51c_1", "Width": 240, "Height": 160, "MimeType": "image/jpeg" }], "LockedStatus": { "Date": "2022-09-07T08:23:34.503Z", "User": "User Not Found", "Id": "User Not Found" }, "DisplayStatus": [{ "Name": "Draft", "Source": "Lifecycle", "Label": "Draft", "DetailedLabel": "Saved as draft", "PublicationDate": null, "ExpirationDate": null, "Date": "2022-09-07T08:23:36.44Z", "User": "stefan koserkov", "Id": null, "Message": { "Title": null, "Description": null, "Operations": [] } }], "FirstPublished": null, "LastPublished": null
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
const expectedChunksCount = Math.ceil(713 / GET_CHUNK_UPLOAD_INFO_RESPONSE_MOCK.ChunkSize);
|
|
189
|
-
let successfullyUploadedChunks = 0;
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
const getChunkUploadInfoOptions: GetChunkUploadInfoRequestOptions = {
|
|
193
|
-
data: {
|
|
194
|
-
libraryId
|
|
195
|
-
},
|
|
196
|
-
successCb: (dto: ChunkUploadInfoDTO) => {
|
|
197
|
-
const result = chunkUploadSdk.chunkFile(getBase64Image713BytesInSize(), chunkSize10MegaBytes, mimeType);
|
|
198
|
-
expect(result.totalChunksCount).toEqual(expectedChunksCount);
|
|
199
|
-
|
|
200
|
-
result.chunks.forEach(chunk => {
|
|
201
|
-
const uploadChunkRequestOptions: UploadChunkRequestOptions = {
|
|
202
|
-
data: {
|
|
203
|
-
fileName: fileName,
|
|
204
|
-
fileMimeType: mimeType,
|
|
205
|
-
chunkedFileUploadSessionId: dto.ChunkedFileUploadSessionId,
|
|
206
|
-
chunkSize: dto.ChunkSize,
|
|
207
|
-
chunkOrdinal: chunk.ordinal,
|
|
208
|
-
numberOfChunks: result.totalChunksCount,
|
|
209
|
-
positionOfChunkInQueue: chunk.ordinal,
|
|
210
|
-
chunkBlob: chunk.content,
|
|
211
|
-
blobStorageProviderName: dto.BlobStorageProviderName
|
|
212
|
-
},
|
|
213
|
-
successCb: (chunkResult: ChunkUploadResult) => {
|
|
214
|
-
if (chunkResult.SuccessfullyUploaded) {
|
|
215
|
-
successfullyUploadedChunks++;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
if (successfullyUploadedChunks === result.totalChunksCount) {
|
|
219
|
-
const commitChunksRequestOptions: CommitChunksRequestOptions = {
|
|
220
|
-
data: {
|
|
221
|
-
chunkedFileUploadSessionId,
|
|
222
|
-
contentType: mimeType,
|
|
223
|
-
fileTotalSize: result.fileTotalSize,
|
|
224
|
-
numberOfChunks: result.totalChunksCount,
|
|
225
|
-
name: fileName,
|
|
226
|
-
blobStorageProviderName: dto.BlobStorageProviderName,
|
|
227
|
-
uploadProperties,
|
|
228
|
-
itemId: null
|
|
229
|
-
},
|
|
230
|
-
successCb: commitChunksResponse => {
|
|
231
|
-
expect(commitChunksResponse).toEqual(COMMIT_CHUNKS_RESPONSE_MOCK);
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
chunkUploadSdk.commitChunks(commitChunksRequestOptions);
|
|
236
|
-
|
|
237
|
-
// responds to chunkUploadSdk.commitChunks
|
|
238
|
-
const commitChunksRequest = jasmine.Ajax.requests.mostRecent();
|
|
239
|
-
assertCommitChunksRequest(commitChunksRequest, commitChunksRequestOptions);
|
|
240
|
-
commitChunksRequest.respondWith({
|
|
241
|
-
status: 200,
|
|
242
|
-
responseText: JSON.stringify(COMMIT_CHUNKS_RESPONSE_MOCK)
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
chunkUploadSdk.uploadChunk(uploadChunkRequestOptions);
|
|
249
|
-
|
|
250
|
-
// responds to chunkUploadSdk.uploadChunk
|
|
251
|
-
const chunkUploadRequest = jasmine.Ajax.requests.mostRecent();
|
|
252
|
-
assertChunkUploadRequest(chunkUploadRequest, chunk);
|
|
253
|
-
chunkUploadRequest.respondWith({
|
|
254
|
-
status: 200,
|
|
255
|
-
responseText: JSON.stringify(CHUNK_UPLOAD_RESPONSE_MOCK)
|
|
256
|
-
});
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
chunkUploadSdk.getChunkUploadInfo(getChunkUploadInfoOptions);
|
|
262
|
-
|
|
263
|
-
// responds to chunkUploadSdk.getChunkUploadInfo
|
|
264
|
-
const getChunkUploadInfoRequest = jasmine.Ajax.requests.mostRecent();
|
|
265
|
-
assertGetChunkUploadInfoRequest(getChunkUploadInfoRequest);
|
|
266
|
-
getChunkUploadInfoRequest.respondWith({
|
|
267
|
-
status: 200,
|
|
268
|
-
responseText: JSON.stringify(GET_CHUNK_UPLOAD_INFO_RESPONSE_MOCK)
|
|
269
|
-
});
|
|
270
|
-
});
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
function assertCommitChunksRequest(commitChunksRequest: JasmineAjaxRequest, commitChunksRequestOptions: CommitChunksRequestOptions) {
|
|
274
|
-
const expectedPayload = {
|
|
275
|
-
commitChunksDto: {
|
|
276
|
-
chunkedFileUploadSessionId: commitChunksRequestOptions.data.chunkedFileUploadSessionId,
|
|
277
|
-
contentType: commitChunksRequestOptions.data.contentType,
|
|
278
|
-
fileTotalSize: commitChunksRequestOptions.data.fileTotalSize,
|
|
279
|
-
numberOfChunks: commitChunksRequestOptions.data.numberOfChunks,
|
|
280
|
-
fileName: commitChunksRequestOptions.data.name,
|
|
281
|
-
blobStorageProviderName: commitChunksRequestOptions.data.blobStorageProviderName,
|
|
282
|
-
itemId: commitChunksRequestOptions.data.itemId,
|
|
283
|
-
properties: commitChunksRequestOptions.data.uploadProperties
|
|
284
|
-
}
|
|
285
|
-
};
|
|
286
|
-
|
|
287
|
-
expect(commitChunksRequest.url).toContain("Default.CommitChunks");
|
|
288
|
-
expect(commitChunksRequest.params).toEqual(JSON.stringify(expectedPayload));
|
|
289
|
-
expect(commitChunksRequest.url).toContain(typeOptions.entitySet);
|
|
290
|
-
expect(commitChunksRequest.method).toEqual("POST");
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
function assertChunkUploadRequest(chunkUploadRequest: JasmineAjaxRequest, chunk: FileUploadChunk) {
|
|
294
|
-
expect(chunkUploadRequest.url)
|
|
295
|
-
.withContext(`Chunk request for chunk number ${chunk.ordinal}, should contain ${baseUrl}${typeOptions.entitySet}`)
|
|
296
|
-
.toEqual(`${baseUrl}${typeOptions.entitySet}`);
|
|
297
|
-
|
|
298
|
-
expect(chunkUploadRequest.method)
|
|
299
|
-
.withContext(`Chunk request for chunk number ${chunk.ordinal}, should be a POST request`)
|
|
300
|
-
.toEqual("POST");
|
|
301
|
-
expect(chunkUploadRequest.params instanceof Blob)
|
|
302
|
-
.withContext(`Chunk request for chunk number ${chunk.ordinal} body must be of type Blob`)
|
|
303
|
-
.toBeTrue();
|
|
304
|
-
expect((chunkUploadRequest.params as Blob).size)
|
|
305
|
-
.withContext(`Chunk request for chunk number ${chunk.ordinal}, should have size of ${chunk.content.size}`)
|
|
306
|
-
.toBe(chunk.content.size);
|
|
307
|
-
expect((chunkUploadRequest.params as Blob).type)
|
|
308
|
-
.withContext(`Chunk request for chunk number ${chunk.ordinal} body param should have a mime type of ${mimeType}`)
|
|
309
|
-
.toBe(mimeType);
|
|
310
|
-
expect(chunkUploadRequest.requestHeaders["Content-Encoding"])
|
|
311
|
-
.withContext(`Chunk request for chunk number ${chunk.ordinal}, should have header "Content-Encoding" with value identity`)
|
|
312
|
-
.toEqual("identity");
|
|
313
|
-
expect(chunkUploadRequest.requestHeaders["Content-Type"])
|
|
314
|
-
.withContext(`Chunk request for chunk number ${chunk.ordinal}, should have header "Content-type" with value ${mimeType}`)
|
|
315
|
-
.toEqual(mimeType);
|
|
316
|
-
expect(chunkUploadRequest.requestHeaders["X-SF-Blob-Storage-Provider-Name"])
|
|
317
|
-
.withContext(`Chunk request for chunk number ${chunk.ordinal}, should have header "X-SF-Blob-Storage-Provider-Name" with value ${blobStorageProviderName}`)
|
|
318
|
-
.toEqual(blobStorageProviderName);
|
|
319
|
-
expect(chunkUploadRequest.requestHeaders["X-SF-Chunk-Ordinal"])
|
|
320
|
-
.withContext(`Chunk request for chunk number ${chunk.ordinal}, should have header "X-SF-Chunk-Ordinal" with value ${chunk.ordinal}`)
|
|
321
|
-
.toEqual(chunk.ordinal.toString());
|
|
322
|
-
expect(chunkUploadRequest.requestHeaders["X-SF-Chunk-Size"])
|
|
323
|
-
.withContext(`Chunk request for chunk number ${chunk.ordinal}, should have header "X-SF-Chunk-Size" with value ${chunkSize10MegaBytes}`)
|
|
324
|
-
.toEqual(chunkSize10MegaBytes.toString());
|
|
325
|
-
expect(chunkUploadRequest.requestHeaders["X-SF-Chunked-File-Upload-Session-Id"])
|
|
326
|
-
.withContext(`Chunk request for chunk number ${chunk.ordinal}, should have header "X-SF-Chunked-File-Upload-Session-Id" with value ${chunkedFileUploadSessionId}`)
|
|
327
|
-
.toEqual(chunkedFileUploadSessionId);
|
|
328
|
-
expect(chunkUploadRequest.requestHeaders["X-SF-Service-Request"])
|
|
329
|
-
.withContext(`Chunk request for chunk number ${chunk.ordinal}, should have header "X-SF-Service-Request" with value true`)
|
|
330
|
-
.toEqual("true");
|
|
331
|
-
|
|
332
|
-
const expectedFileNameHeaderValue = encodeURIComponent(fileName);
|
|
333
|
-
expect(chunkUploadRequest.requestHeaders["X-File-Name"])
|
|
334
|
-
.withContext(`Chunk request for chunk number ${chunk.ordinal}, should have header "X-File-Name" with value ${expectedFileNameHeaderValue}`)
|
|
335
|
-
.toEqual(expectedFileNameHeaderValue);
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
function assertGetChunkUploadInfoRequest(getChunkUploadInfoRequest: JasmineAjaxRequest) {
|
|
339
|
-
expect(getChunkUploadInfoRequest.url).toContain(`Default.GetChunkUploadInfo(libraryId=${libraryId})`);
|
|
340
|
-
expect(getChunkUploadInfoRequest.url).toContain(typeOptions.entitySet);
|
|
341
|
-
expect(getChunkUploadInfoRequest.method).toBe("GET");
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
function getBase64Image713BytesInSize() {
|
|
345
|
-
// ! 713 Bytes
|
|
346
|
-
return "/9j/4AAQSkZJRgABAQEAYABgAAD/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAEAAAAAAAD/2wBDAAIBAQIBAQICAgICAgICAwUDAwMDAwYEBAMFBwYHBwcGBwcICQsJCAgKCAcHCg0KCgsMDAwMBwkODw0MDgsMDAz/2wBDAQICAgMDAwYDAwYMCAcIDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAz/wAARCAAOAA4DASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD91PFnxd8M+A/HXhXwxqusWun6944nubbQbKXPmanLb273MyR8YykMbuQSPlQ46V1FFFAH/9k=";
|
|
347
|
-
}
|