@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
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { Data } from "./Data";
|
|
2
|
+
import { Query } from "./Query";
|
|
3
|
+
import { ResponseHandlers } from "./Requests/ExecutableRequest";
|
|
4
|
+
import { BatchRequest } from "./Requests/BatchRequest";
|
|
5
|
+
import { HttpTransport } from "./Transport/HttpTransport";
|
|
6
|
+
/**
|
|
7
|
+
* Entry point for querying and modifying content through the Sitefinity Web Services API.
|
|
8
|
+
*/
|
|
9
|
+
export declare class Sitefinity {
|
|
10
|
+
/**
|
|
11
|
+
* Query builder constructor exposed for consumers that need to build OData queries.
|
|
12
|
+
*/
|
|
13
|
+
static Query: typeof Query;
|
|
14
|
+
private factory;
|
|
15
|
+
private baseUrl;
|
|
16
|
+
private siteId;
|
|
17
|
+
/**
|
|
18
|
+
* Creates the SDK entry point.
|
|
19
|
+
*
|
|
20
|
+
* @param options Service URL and optional site-level configuration.
|
|
21
|
+
*/
|
|
22
|
+
constructor(options: SDKOptions);
|
|
23
|
+
/**
|
|
24
|
+
* Creates a data client for an entity set.
|
|
25
|
+
*
|
|
26
|
+
* The returned client uses the SDK defaults unless a URL, provider, culture, site,
|
|
27
|
+
* query parameters, or headers are overridden in `options`.
|
|
28
|
+
*
|
|
29
|
+
* @param options Entity-set and request URL options.
|
|
30
|
+
* @returns A data client for the requested entity set.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* const news = sdk.data({ entitySet: "newsitems", culture: "en" });
|
|
34
|
+
* news.get({ successCb: items => console.log(items) });
|
|
35
|
+
*/
|
|
36
|
+
data(options: TypeOptions): Data;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a batch for grouping requests and optional upload, update, or workflow operations.
|
|
39
|
+
*
|
|
40
|
+
* Call `execute()` after adding requests. The callbacks receive the batch response,
|
|
41
|
+
* failure payload, and progress event respectively. Batch options override SDK URL options.
|
|
42
|
+
*
|
|
43
|
+
* @param success Callback invoked when the batch succeeds.
|
|
44
|
+
* @param failure Callback invoked when the batch fails.
|
|
45
|
+
* @param progress Callback invoked as request progress is reported.
|
|
46
|
+
* @param options Optional URL and request options for the batch.
|
|
47
|
+
* @returns A batch request that can be populated and executed.
|
|
48
|
+
*/
|
|
49
|
+
batch(success?: Function, failure?: Function, progress?: Function, options?: TypeOptions): BatchRequest;
|
|
50
|
+
/**
|
|
51
|
+
* Sets the value sent in the `Authorization` header.
|
|
52
|
+
*
|
|
53
|
+
* The current token form is `{ type, value }`, for example
|
|
54
|
+
* `{ type: "Bearer", value: "token" }`. A raw string is also accepted at runtime
|
|
55
|
+
* for backward compatibility and is sent unchanged.
|
|
56
|
+
*
|
|
57
|
+
* @param token Token object or legacy raw authorization header value.
|
|
58
|
+
*/
|
|
59
|
+
setToken(token: AuthorizationToken): void;
|
|
60
|
+
}
|
|
61
|
+
interface OptionsBase {
|
|
62
|
+
/**
|
|
63
|
+
* Service URL that points to the configured Sitefinity service.
|
|
64
|
+
*/
|
|
65
|
+
baseUrl?: string;
|
|
66
|
+
/**
|
|
67
|
+
* ID of the site for which requests are executed.
|
|
68
|
+
*/
|
|
69
|
+
siteId?: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Configuration options for the SDK entry point.
|
|
73
|
+
*/
|
|
74
|
+
export interface SDKOptions extends OptionsBase {
|
|
75
|
+
/**
|
|
76
|
+
* Default callbacks used when a request does not provide its own callback.
|
|
77
|
+
*/
|
|
78
|
+
handlers?: ResponseHandlers;
|
|
79
|
+
/**
|
|
80
|
+
* Adds the Sitefinity unlimited-choices request header when true.
|
|
81
|
+
*/
|
|
82
|
+
enableUnlimitedChoices?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Adds the Sitefinity integration-mode request header when true.
|
|
85
|
+
*/
|
|
86
|
+
integrationMode?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Sends every HTTP request the SDK makes. Use it to route SDK traffic through your own HTTP stack,
|
|
89
|
+
* such as Angular's `HttpClient` or `fetch`. Defaults to {@link XhrTransport}, which uses `XMLHttpRequest`.
|
|
90
|
+
*/
|
|
91
|
+
transport?: HttpTransport;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Configuration options for an entity-set data client or batch.
|
|
95
|
+
*/
|
|
96
|
+
export interface TypeOptions extends OptionsBase {
|
|
97
|
+
/**
|
|
98
|
+
* URL name of the entity set, such as `"newsitems"` or `"images"`.
|
|
99
|
+
*/
|
|
100
|
+
entitySet?: string;
|
|
101
|
+
/**
|
|
102
|
+
* Provider name. When omitted, Sitefinity uses the site's default provider.
|
|
103
|
+
*/
|
|
104
|
+
provider?: string;
|
|
105
|
+
/**
|
|
106
|
+
* Culture name. When omitted, Sitefinity uses the site's default culture.
|
|
107
|
+
*/
|
|
108
|
+
culture?: string;
|
|
109
|
+
/**
|
|
110
|
+
* Additional query-string values appended to each request URL.
|
|
111
|
+
*/
|
|
112
|
+
additionalQueryParams?: {
|
|
113
|
+
[key: string]: string;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Additional headers sent with each request.
|
|
117
|
+
*/
|
|
118
|
+
additionalHeaders?: {
|
|
119
|
+
[key: string]: string;
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Structured authorization token.
|
|
124
|
+
*
|
|
125
|
+
* `setToken` also accepts a raw string at runtime for backward compatibility.
|
|
126
|
+
*/
|
|
127
|
+
export interface Token {
|
|
128
|
+
/**
|
|
129
|
+
* Authorization scheme, such as `"Bearer"`.
|
|
130
|
+
*/
|
|
131
|
+
type: string;
|
|
132
|
+
/**
|
|
133
|
+
* Token value.
|
|
134
|
+
*/
|
|
135
|
+
value: string;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Structured authorization token or a legacy raw `Authorization` header value.
|
|
139
|
+
*/
|
|
140
|
+
export type AuthorizationToken = Token | string;
|
|
141
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { HttpTransport, HttpTransportRequest, HttpTransportResponse } from "./HttpTransport";
|
|
2
|
+
/**
|
|
3
|
+
* Transport that sends requests with the Fetch API.
|
|
4
|
+
*
|
|
5
|
+
* Fetch cannot report upload progress, so `onUploadProgress` is never called.
|
|
6
|
+
*/
|
|
7
|
+
export declare class FetchTransport implements HttpTransport {
|
|
8
|
+
private readonly fetchImplementation;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a fetch-based transport.
|
|
11
|
+
*
|
|
12
|
+
* @param fetchImplementation Fetch function to use. Defaults to the global `fetch`, resolved when sending.
|
|
13
|
+
*/
|
|
14
|
+
constructor(fetchImplementation?: typeof fetch);
|
|
15
|
+
/** Sends the request with `fetch`. A failure to get any response is reported with status `0`. */
|
|
16
|
+
send(request: HttpTransportRequest, onComplete: (response: HttpTransportResponse) => void): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Upload progress reported by a transport.
|
|
3
|
+
*
|
|
4
|
+
* A DOM `ProgressEvent` satisfies this shape.
|
|
5
|
+
*/
|
|
6
|
+
export interface HttpTransportProgressEvent {
|
|
7
|
+
/** Whether `total` is known. */
|
|
8
|
+
lengthComputable: boolean;
|
|
9
|
+
/** Amount sent so far. */
|
|
10
|
+
loaded: number;
|
|
11
|
+
/** Total amount to send. */
|
|
12
|
+
total: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A request the SDK asks a transport to send.
|
|
16
|
+
*/
|
|
17
|
+
export interface HttpTransportRequest {
|
|
18
|
+
/** HTTP method, such as `GET` or `POST`. */
|
|
19
|
+
method: string;
|
|
20
|
+
/** Absolute URL including the query string. */
|
|
21
|
+
url: string;
|
|
22
|
+
/** Header names and values. A transport must send every entry. */
|
|
23
|
+
headers: {
|
|
24
|
+
[name: string]: string;
|
|
25
|
+
};
|
|
26
|
+
/** JSON text, or a `Blob` for uploads. Absent for requests without content. */
|
|
27
|
+
body?: string | Blob;
|
|
28
|
+
/**
|
|
29
|
+
* Present only when the caller wants upload progress. A transport that can report progress
|
|
30
|
+
* must not subscribe to it when this is absent. A transport that cannot report progress ignores it.
|
|
31
|
+
*/
|
|
32
|
+
onUploadProgress?: (event: HttpTransportProgressEvent) => void;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The outcome of a request, as the SDK needs it.
|
|
36
|
+
*/
|
|
37
|
+
export interface HttpTransportResponse {
|
|
38
|
+
/**
|
|
39
|
+
* HTTP status code, or `0` when no response was received, for example after a network failure.
|
|
40
|
+
* The SDK invokes neither its success nor its failure callback for `0`.
|
|
41
|
+
*/
|
|
42
|
+
status: number;
|
|
43
|
+
/** Response body as text. */
|
|
44
|
+
body: string;
|
|
45
|
+
/** Response headers keyed by lower-case name. */
|
|
46
|
+
headers: {
|
|
47
|
+
[name: string]: string;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Sends the HTTP requests the SDK builds.
|
|
52
|
+
*
|
|
53
|
+
* Pass an implementation as `SDKOptions.transport` to route all SDK traffic through your own HTTP stack,
|
|
54
|
+
* such as Angular's `HttpClient`, `fetch`, or a test double. When none is supplied the SDK uses
|
|
55
|
+
* {@link XhrTransport}.
|
|
56
|
+
*/
|
|
57
|
+
export interface HttpTransport {
|
|
58
|
+
/**
|
|
59
|
+
* Sends a request and calls `onComplete` exactly once, with whatever status the server returned,
|
|
60
|
+
* including error statuses. The SDK decides which statuses are successes or failures.
|
|
61
|
+
*
|
|
62
|
+
* `onComplete` may be called synchronously. The SDK's own callbacks run inside it, so the timing
|
|
63
|
+
* of the SDK's callbacks follows the transport's.
|
|
64
|
+
*
|
|
65
|
+
* @param request The request to send.
|
|
66
|
+
* @param onComplete Called with the response once the request finishes.
|
|
67
|
+
*/
|
|
68
|
+
send(request: HttpTransportRequest, onComplete: (response: HttpTransportResponse) => void): void;
|
|
69
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { HttpTransport, HttpTransportRequest, HttpTransportResponse } from "./HttpTransport";
|
|
2
|
+
/**
|
|
3
|
+
* Default transport. Sends requests with `XMLHttpRequest`.
|
|
4
|
+
*/
|
|
5
|
+
export declare class XhrTransport implements HttpTransport {
|
|
6
|
+
/** Sends the request with a new `XMLHttpRequest` and reports its final state. */
|
|
7
|
+
send(request: HttpTransportRequest, onComplete: (response: HttpTransportResponse) => void): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { ComplexExpression } from "./Expression";
|
|
2
|
+
/**
|
|
3
|
+
* Fluent builder for a query's `$filter` expression.
|
|
4
|
+
*
|
|
5
|
+
* Comparison methods add conditions to the current logical group and return
|
|
6
|
+
* the same builder. Logical methods create nested groups; call `done()` once
|
|
7
|
+
* for each group to return to the parent query or group.
|
|
8
|
+
*
|
|
9
|
+
* Supported comparisons are `eq`, `ne`, `gt`, `gte`, `lt`, `lte`, `in`,
|
|
10
|
+
* `startsWith`, `contains`, and `endsWith`. Values are serialized by the query
|
|
11
|
+
* builder when the query is built.
|
|
12
|
+
*
|
|
13
|
+
* @typeParam QueryType The parent type returned by `done()`.
|
|
14
|
+
*/
|
|
15
|
+
export declare class WhereQuery<QueryType> {
|
|
16
|
+
private parent;
|
|
17
|
+
private expression;
|
|
18
|
+
/** Creates a logical group attached to the supplied parent. */
|
|
19
|
+
constructor(parent: QueryType, type?: string);
|
|
20
|
+
/**
|
|
21
|
+
* Starts a nested `and` group.
|
|
22
|
+
* @returns A nested builder whose `done()` returns this group.
|
|
23
|
+
*/
|
|
24
|
+
and(): WhereQuery<WhereQuery<QueryType>>;
|
|
25
|
+
/**
|
|
26
|
+
* Starts a nested `or` group.
|
|
27
|
+
* @returns A nested builder whose `done()` returns this group.
|
|
28
|
+
*/
|
|
29
|
+
or(): WhereQuery<WhereQuery<QueryType>>;
|
|
30
|
+
/**
|
|
31
|
+
* Starts an OData `any` group for collection-valued properties.
|
|
32
|
+
* @returns A nested builder whose `done()` returns this group.
|
|
33
|
+
*/
|
|
34
|
+
any(): WhereQuery<WhereQuery<QueryType>>;
|
|
35
|
+
/**
|
|
36
|
+
* Starts a negated group.
|
|
37
|
+
* @returns A nested builder whose `done()` returns this group.
|
|
38
|
+
* @throws Error If more than one direct condition is added to the group.
|
|
39
|
+
*/
|
|
40
|
+
not(): WhereQuery<WhereQuery<QueryType>>;
|
|
41
|
+
/**
|
|
42
|
+
* Adds an equality condition.
|
|
43
|
+
* @param parameter Property name.
|
|
44
|
+
* @param constant Value to compare with.
|
|
45
|
+
* @returns This filter builder.
|
|
46
|
+
*/
|
|
47
|
+
eq(parameter: string, constant: any): WhereQuery<QueryType>;
|
|
48
|
+
/**
|
|
49
|
+
* Adds an inequality condition.
|
|
50
|
+
* @param parameter Property name.
|
|
51
|
+
* @param constant Value to compare with.
|
|
52
|
+
* @returns This filter builder.
|
|
53
|
+
*/
|
|
54
|
+
ne(parameter: string, constant: any): WhereQuery<QueryType>;
|
|
55
|
+
/** Adds a greater-than condition for number, string, or date values. */
|
|
56
|
+
gt(parameter: string, constant: any): WhereQuery<QueryType>;
|
|
57
|
+
/** Adds a greater-than-or-equal condition for number, string, or date values. */
|
|
58
|
+
gte(parameter: string, constant: any): WhereQuery<QueryType>;
|
|
59
|
+
/** Adds a less-than condition for number, string, or date values. */
|
|
60
|
+
lt(parameter: string, constant: any): WhereQuery<QueryType>;
|
|
61
|
+
/** Adds a less-than-or-equal condition for number, string, or date values. */
|
|
62
|
+
lte(parameter: string, constant: any): WhereQuery<QueryType>;
|
|
63
|
+
/** Adds a string-prefix condition, optionally using case-insensitive matching. */
|
|
64
|
+
startsWith(parameter: string, constant: any, caseSensitive?: boolean): WhereQuery<QueryType>;
|
|
65
|
+
/** Adds a string-contains condition, optionally using case-insensitive matching. */
|
|
66
|
+
contains(parameter: string, constant: any, caseSensitive?: boolean): WhereQuery<QueryType>;
|
|
67
|
+
/** Adds a string-suffix condition, optionally using case-insensitive matching. */
|
|
68
|
+
endsWith(parameter: string, constant: any, caseSensitive?: boolean): WhereQuery<QueryType>;
|
|
69
|
+
/**
|
|
70
|
+
* Adds an OData `in` condition.
|
|
71
|
+
*
|
|
72
|
+
* The constant must be an array; otherwise `build()` throws an error.
|
|
73
|
+
*/
|
|
74
|
+
in(parameter: string, constant: any): WhereQuery<QueryType>;
|
|
75
|
+
/**
|
|
76
|
+
* Completes this group and returns its parent.
|
|
77
|
+
*
|
|
78
|
+
* Call once for the root filter to return to `Query`, and once for each
|
|
79
|
+
* nested group to continue the surrounding chain.
|
|
80
|
+
*
|
|
81
|
+
* @returns The parent query or enclosing filter group.
|
|
82
|
+
*/
|
|
83
|
+
done(): QueryType;
|
|
84
|
+
/** Returns the expression tree represented by this filter group. */
|
|
85
|
+
getExpression(): ComplexExpression;
|
|
86
|
+
private simple;
|
|
87
|
+
private addComplexExpression;
|
|
88
|
+
}
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import { CreateRequestOptions } from "../Data";
|
|
2
|
+
import { RequestFactory } from "../Requests/RequestFactory";
|
|
3
|
+
import { TypeOptions } from "../Sitefinity";
|
|
4
|
+
import { ChunkFileResult } from "./chunked-file-upload.utilities";
|
|
5
|
+
/**
|
|
6
|
+
* Provides the client-side workflow for uploading a file in chunks.
|
|
7
|
+
*
|
|
8
|
+
* A typical upload calls `getChunkUploadInfo`, uses the returned session and
|
|
9
|
+
* chunk settings with `uploadChunk`, and then calls `commitChunks`. If an
|
|
10
|
+
* upload cannot be completed, call `cleanUpChunks` to remove the server-side
|
|
11
|
+
* chunks. Use `chunkFile` to split a `Blob` or base64 string before uploading.
|
|
12
|
+
*/
|
|
13
|
+
export declare class ChunkUploadSdk {
|
|
14
|
+
private urlOptions;
|
|
15
|
+
private factory;
|
|
16
|
+
constructor(urlOptions: TypeOptions, factory: RequestFactory);
|
|
17
|
+
/**
|
|
18
|
+
* Gets the session, provider, and chunk settings required to start an upload.
|
|
19
|
+
*
|
|
20
|
+
* The `data.libraryId` field must identify the parent library, not a library
|
|
21
|
+
* folder. The inherited callbacks and query options are optional.
|
|
22
|
+
*
|
|
23
|
+
* @param parameters Request data and optional callbacks.
|
|
24
|
+
* @param parameters.data.libraryId Parent library identifier.
|
|
25
|
+
* @param parameters.successCb Receives a {@link ChunkUploadInfoDTO} on success.
|
|
26
|
+
* @param parameters.failureCb Receives the server error response on failure.
|
|
27
|
+
* @param parameters.progressCb Receives upload progress events when supported.
|
|
28
|
+
*/
|
|
29
|
+
getChunkUploadInfo(parameters: GetChunkUploadInfoRequestOptions): void;
|
|
30
|
+
/**
|
|
31
|
+
* Sends one chunk to the server.
|
|
32
|
+
*
|
|
33
|
+
* Upload chunks in ordinal order from `0` through `numberOfChunks - 1`.
|
|
34
|
+
* `chunkSize` is the chunk size in bytes, while `chunkBlob` contains the
|
|
35
|
+
* current chunk and may be smaller for the final chunk. The session,
|
|
36
|
+
* provider, ordinal, count, size, and blob fields are required.
|
|
37
|
+
*
|
|
38
|
+
* @param parameters Chunk data and optional callbacks.
|
|
39
|
+
* @param parameters.data.fileMimeType MIME type of the complete file.
|
|
40
|
+
* @param parameters.data.fileName File name sent with the chunk.
|
|
41
|
+
* @param parameters.data.chunkedFileUploadSessionId Session from
|
|
42
|
+
* `getChunkUploadInfo`.
|
|
43
|
+
* @param parameters.data.chunkSize Size of this chunk in bytes.
|
|
44
|
+
* @param parameters.data.chunkOrdinal Zero-based ordinal of this chunk.
|
|
45
|
+
* @param parameters.data.numberOfChunks Total chunks in the upload.
|
|
46
|
+
* @param parameters.data.positionOfChunkInQueue Optional queue position used
|
|
47
|
+
* to calculate progress for concurrent uploads.
|
|
48
|
+
* @param parameters.data.chunkBlob Bytes for this chunk.
|
|
49
|
+
* @param parameters.data.blobStorageProviderName Provider from the upload info.
|
|
50
|
+
* @param parameters.successCb Receives a {@link ChunkUploadResult} on success.
|
|
51
|
+
* @param parameters.failureCb Receives the server error response on failure.
|
|
52
|
+
* @param parameters.progressCb Receives upload progress events when supported.
|
|
53
|
+
*/
|
|
54
|
+
uploadChunk(parameters: UploadChunkRequestOptions): void;
|
|
55
|
+
/**
|
|
56
|
+
* Commits all uploaded chunks as one media file.
|
|
57
|
+
*
|
|
58
|
+
* Call this only after every ordinal has uploaded successfully. The server
|
|
59
|
+
* validates `numberOfChunks` and `fileTotalSize` before assembling the file.
|
|
60
|
+
* Set `data.itemId` when replacing an existing media item; omit it when
|
|
61
|
+
* creating a new item. A successful commit completes the upload session.
|
|
62
|
+
*
|
|
63
|
+
* @param parameters Commit data and optional callbacks.
|
|
64
|
+
* @param parameters.data.chunkedFileUploadSessionId Session used by the chunks.
|
|
65
|
+
* @param parameters.data.contentType MIME type of the complete file.
|
|
66
|
+
* @param parameters.data.fileTotalSize Complete file size in bytes.
|
|
67
|
+
* @param parameters.data.numberOfChunks Number of uploaded chunks.
|
|
68
|
+
* @param parameters.data.name File name.
|
|
69
|
+
* @param parameters.data.blobStorageProviderName Provider used for the chunks.
|
|
70
|
+
* @param parameters.data.uploadProperties Media item properties such as
|
|
71
|
+
* `Title` and `UrlName`.
|
|
72
|
+
* @param parameters.data.itemId Optional existing item identifier for updates.
|
|
73
|
+
* @param parameters.successCb Receives the commit response on success.
|
|
74
|
+
* @param parameters.failureCb Receives the server error response on failure.
|
|
75
|
+
* @param parameters.progressCb Receives upload progress events when supported.
|
|
76
|
+
*/
|
|
77
|
+
commitChunks(parameters: CommitChunksRequestOptions): void;
|
|
78
|
+
/**
|
|
79
|
+
* Deletes all chunks associated with an incomplete upload session.
|
|
80
|
+
*
|
|
81
|
+
* Call this after a failed chunk upload or failed commit when the session
|
|
82
|
+
* should not be resumed. Cleanup does not commit a file and requires the
|
|
83
|
+
* session and provider used by the upload.
|
|
84
|
+
*
|
|
85
|
+
* @param parameters Session data and optional callbacks.
|
|
86
|
+
* @param parameters.data.chunkedFileUploadSessionId Session to clean up.
|
|
87
|
+
* @param parameters.data.blobStorageProviderName Provider holding the chunks.
|
|
88
|
+
* @param parameters.successCb Called after cleanup succeeds.
|
|
89
|
+
* @param parameters.failureCb Receives the server error response on failure.
|
|
90
|
+
* @param parameters.progressCb Receives request progress events when supported.
|
|
91
|
+
*/
|
|
92
|
+
cleanUpChunks(parameters: CleanUpChunksRequestOptions): void;
|
|
93
|
+
/**
|
|
94
|
+
* Splits a file into uploadable chunks.
|
|
95
|
+
*
|
|
96
|
+
* A `Blob` is sliced directly. A base64 string is decoded with `atob` into
|
|
97
|
+
* a `Blob` using `contentTypeMime`, then sliced. Each returned chunk has a
|
|
98
|
+
* zero-based ordinal, and the last chunk can be smaller than `chunkSize`.
|
|
99
|
+
*
|
|
100
|
+
* @param file Source `Blob` or base64-encoded binary string.
|
|
101
|
+
* @param chunkSize Maximum chunk size in bytes.
|
|
102
|
+
* @param contentTypeMime MIME type assigned to the chunks and decoded Blob.
|
|
103
|
+
* @returns Chunk blobs, their zero-based ordinals, total count, and file size.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```ts
|
|
107
|
+
* const upload = sitefinity.data(typeOptions).chunkUpload;
|
|
108
|
+
* const result = upload.chunkFile(file, 5 * 1024 * 1024, "image/jpeg");
|
|
109
|
+
*
|
|
110
|
+
* for (const chunk of result.chunks) {
|
|
111
|
+
* upload.uploadChunk({
|
|
112
|
+
* data: {
|
|
113
|
+
* fileMimeType: "image/jpeg",
|
|
114
|
+
* chunkedFileUploadSessionId: sessionId,
|
|
115
|
+
* chunkSize: chunk.content.size,
|
|
116
|
+
* chunkOrdinal: chunk.ordinal,
|
|
117
|
+
* numberOfChunks: result.totalChunksCount,
|
|
118
|
+
* chunkBlob: chunk.content,
|
|
119
|
+
* blobStorageProviderName: providerName
|
|
120
|
+
* },
|
|
121
|
+
* successCb: onChunkUploaded,
|
|
122
|
+
* failureCb: onUploadFailed
|
|
123
|
+
* });
|
|
124
|
+
* }
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
chunkFile(file: Blob | string, chunkSize: number, contentTypeMime: string): ChunkFileResult;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Options for uploading one file chunk.
|
|
131
|
+
*
|
|
132
|
+
* The inherited `successCb`, `failureCb`, `progressCb`, `query`, and
|
|
133
|
+
* `fallbackProperties` fields are optional. All fields in `data` are required
|
|
134
|
+
* except `positionOfChunkInQueue`.
|
|
135
|
+
*/
|
|
136
|
+
export interface UploadChunkRequestOptions extends CreateRequestOptions {
|
|
137
|
+
/**
|
|
138
|
+
* Values used to construct the chunk request.
|
|
139
|
+
*/
|
|
140
|
+
data: {
|
|
141
|
+
/**
|
|
142
|
+
* MIME type of the complete file.
|
|
143
|
+
*/
|
|
144
|
+
fileMimeType: string;
|
|
145
|
+
/**
|
|
146
|
+
* File name sent with the chunk.
|
|
147
|
+
*/
|
|
148
|
+
fileName: string;
|
|
149
|
+
/**
|
|
150
|
+
* Session identifier returned by `getChunkUploadInfo`.
|
|
151
|
+
*/
|
|
152
|
+
chunkedFileUploadSessionId: string;
|
|
153
|
+
/**
|
|
154
|
+
* Size of this chunk in bytes.
|
|
155
|
+
*/
|
|
156
|
+
chunkSize: number;
|
|
157
|
+
/**
|
|
158
|
+
* Zero-based ordinal of this chunk.
|
|
159
|
+
*/
|
|
160
|
+
chunkOrdinal: number;
|
|
161
|
+
/**
|
|
162
|
+
* Total number of chunks in the file.
|
|
163
|
+
*/
|
|
164
|
+
numberOfChunks: number;
|
|
165
|
+
/**
|
|
166
|
+
* Optional queue position used to calculate progress for concurrent uploads.
|
|
167
|
+
*/
|
|
168
|
+
positionOfChunkInQueue?: number;
|
|
169
|
+
/**
|
|
170
|
+
* Binary data for this chunk.
|
|
171
|
+
*/
|
|
172
|
+
chunkBlob: Blob;
|
|
173
|
+
/**
|
|
174
|
+
* Name of the blob storage provider holding the upload session.
|
|
175
|
+
*/
|
|
176
|
+
blobStorageProviderName: string;
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Options for committing uploaded chunks into a media file.
|
|
181
|
+
*
|
|
182
|
+
* The inherited callbacks and request query fields are optional. All fields in
|
|
183
|
+
* `data` are required except `itemId`, which is used only for updates.
|
|
184
|
+
*/
|
|
185
|
+
export interface CommitChunksRequestOptions extends CreateRequestOptions {
|
|
186
|
+
/**
|
|
187
|
+
* Values used to construct the commit request.
|
|
188
|
+
*/
|
|
189
|
+
data: {
|
|
190
|
+
/**
|
|
191
|
+
* Session identifier used for all chunks.
|
|
192
|
+
*/
|
|
193
|
+
chunkedFileUploadSessionId: string;
|
|
194
|
+
/**
|
|
195
|
+
* MIME type of the complete file.
|
|
196
|
+
*/
|
|
197
|
+
contentType: string;
|
|
198
|
+
/**
|
|
199
|
+
* Complete file size in bytes.
|
|
200
|
+
*/
|
|
201
|
+
fileTotalSize: number;
|
|
202
|
+
/**
|
|
203
|
+
* Number of chunks uploaded for this session.
|
|
204
|
+
*/
|
|
205
|
+
numberOfChunks: number;
|
|
206
|
+
/**
|
|
207
|
+
* File name.
|
|
208
|
+
*/
|
|
209
|
+
name: string;
|
|
210
|
+
/**
|
|
211
|
+
* Name of the blob storage provider holding the chunks.
|
|
212
|
+
*/
|
|
213
|
+
blobStorageProviderName: string;
|
|
214
|
+
/**
|
|
215
|
+
* Media properties such as `Title` and `UrlName`.
|
|
216
|
+
*/
|
|
217
|
+
uploadProperties: {
|
|
218
|
+
[key: string]: string;
|
|
219
|
+
};
|
|
220
|
+
/**
|
|
221
|
+
* Existing media item identifier when replacing a file.
|
|
222
|
+
*/
|
|
223
|
+
itemId?: string;
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Options for retrieving chunk-upload settings for a media library.
|
|
228
|
+
*
|
|
229
|
+
* The inherited callbacks and request query fields are optional. `libraryId`
|
|
230
|
+
* must identify the parent library, not a folder.
|
|
231
|
+
*/
|
|
232
|
+
export interface GetChunkUploadInfoRequestOptions extends CreateRequestOptions {
|
|
233
|
+
/**
|
|
234
|
+
* Values used to construct the information request.
|
|
235
|
+
*/
|
|
236
|
+
data: {
|
|
237
|
+
/**
|
|
238
|
+
* Parent media library in which the file will be uploaded.
|
|
239
|
+
*/
|
|
240
|
+
libraryId: string;
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Options for deleting all chunks from an upload session.
|
|
245
|
+
*
|
|
246
|
+
* The inherited callbacks and request query fields are optional. Both fields
|
|
247
|
+
* in `data` are required.
|
|
248
|
+
*/
|
|
249
|
+
export interface CleanUpChunksRequestOptions extends CreateRequestOptions {
|
|
250
|
+
/**
|
|
251
|
+
* Values used to construct the cleanup request.
|
|
252
|
+
*/
|
|
253
|
+
data: {
|
|
254
|
+
/**
|
|
255
|
+
* Session identifier whose chunks should be deleted.
|
|
256
|
+
*/
|
|
257
|
+
chunkedFileUploadSessionId: string;
|
|
258
|
+
/**
|
|
259
|
+
* Name of the blob storage provider holding the chunks.
|
|
260
|
+
*/
|
|
261
|
+
blobStorageProviderName: string;
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Server-provided settings and identifiers for a chunk upload session.
|
|
266
|
+
*/
|
|
267
|
+
export interface ChunkUploadInfoDTO {
|
|
268
|
+
/**
|
|
269
|
+
* Whether the provider supports chunked uploads.
|
|
270
|
+
*/
|
|
271
|
+
ProviderSupportsChunkUpload: boolean;
|
|
272
|
+
/**
|
|
273
|
+
* Name of the blob storage provider to use for this session.
|
|
274
|
+
*/
|
|
275
|
+
BlobStorageProviderName: string;
|
|
276
|
+
/**
|
|
277
|
+
* Identifier of the current chunk upload session.
|
|
278
|
+
*/
|
|
279
|
+
ChunkedFileUploadSessionId: string;
|
|
280
|
+
/**
|
|
281
|
+
* Recommended chunk size in bytes.
|
|
282
|
+
*/
|
|
283
|
+
ChunkSize: number;
|
|
284
|
+
/**
|
|
285
|
+
* Maximum number of retries for an individual chunk.
|
|
286
|
+
*/
|
|
287
|
+
MaxRetryCountForChunk: number;
|
|
288
|
+
/**
|
|
289
|
+
* Maximum simultaneous chunk requests for the session.
|
|
290
|
+
*/
|
|
291
|
+
MaxSimultaneousChunkUploadRequestsPerSession: number;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Server response returned after a chunk upload request.
|
|
295
|
+
*/
|
|
296
|
+
export interface ChunkUploadResult {
|
|
297
|
+
/**
|
|
298
|
+
* Whether the chunk was uploaded successfully.
|
|
299
|
+
*/
|
|
300
|
+
SuccessfullyUploaded: boolean;
|
|
301
|
+
/**
|
|
302
|
+
* Identifier of the chunk upload session.
|
|
303
|
+
*/
|
|
304
|
+
ChunkedFileUploadSessionId: string;
|
|
305
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for splitting file content into chunks and normalizing upload input.
|
|
3
|
+
*/
|
|
4
|
+
export declare class ChunkedFileUploadUtilities {
|
|
5
|
+
/**
|
|
6
|
+
* Splits a `Blob` or base64-encoded binary string into sequential chunks.
|
|
7
|
+
*
|
|
8
|
+
* Blob input is sliced directly. A base64 string is decoded with `atob`
|
|
9
|
+
* into a Blob using `contentTypeMime` before it is sliced. Chunk ordinals
|
|
10
|
+
* start at zero; the final chunk can be smaller than `chunkSize`.
|
|
11
|
+
*
|
|
12
|
+
* @param file Blob data or a base64-encoded binary string.
|
|
13
|
+
* @param chunkSize Maximum size of each chunk in bytes.
|
|
14
|
+
* @param contentTypeMime MIME type assigned to each chunk and decoded Blob.
|
|
15
|
+
* @returns The chunks, their total count, and the original file size in bytes.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* const result = new ChunkedFileUploadUtilities().chunkFile(
|
|
20
|
+
* base64File,
|
|
21
|
+
* 5 * 1024 * 1024,
|
|
22
|
+
* "image/jpeg"
|
|
23
|
+
* );
|
|
24
|
+
*
|
|
25
|
+
* result.chunks.forEach(({ ordinal, content }) => {
|
|
26
|
+
* console.log(`Chunk ${ordinal}: ${content.size} bytes`);
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
chunkFile(file: Blob | string, chunkSize: number, contentTypeMime: string): ChunkFileResult;
|
|
31
|
+
/**
|
|
32
|
+
* Converts base64 binary content to a Blob before chunking.
|
|
33
|
+
*
|
|
34
|
+
* The input must contain the base64 payload expected by `atob`; a data URL
|
|
35
|
+
* prefix is not removed automatically.
|
|
36
|
+
*/
|
|
37
|
+
private base64ToBlob;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* One chunk produced by {@link ChunkedFileUploadUtilities.chunkFile}.
|
|
41
|
+
*/
|
|
42
|
+
export interface FileUploadChunk {
|
|
43
|
+
/** Zero-based position of this chunk in the complete file. */
|
|
44
|
+
ordinal: number;
|
|
45
|
+
/** Binary content for this chunk. */
|
|
46
|
+
content: Blob;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Result returned after a file is divided into upload chunks.
|
|
50
|
+
*/
|
|
51
|
+
export interface ChunkFileResult {
|
|
52
|
+
/** Chunks in ascending ordinal order. */
|
|
53
|
+
chunks: Array<FileUploadChunk>;
|
|
54
|
+
/** Number of chunks in `chunks`. */
|
|
55
|
+
totalChunksCount: number;
|
|
56
|
+
/** Size of the source file in bytes. */
|
|
57
|
+
fileTotalSize: number;
|
|
58
|
+
}
|