typedrest 0.3.5 → 0.4.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 +2 -2
- package/endpoints/Endpoint.js +11 -11
- package/endpoints/Endpoint.ts +11 -11
- package/endpoints/EntryEndpoint.js +9 -9
- package/endpoints/EntryEndpoint.ts +8 -8
- package/endpoints/generic/ETagEndpointBase.js +24 -24
- package/endpoints/generic/ETagEndpointBase.ts +21 -21
- package/endpoints/generic/ElementEndpoint.js +33 -33
- package/endpoints/generic/ElementEndpoint.ts +30 -30
- package/endpoints/generic/GenericCollectionEndpoint.js +37 -37
- package/endpoints/generic/GenericCollectionEndpoint.ts +36 -36
- package/endpoints/generic/IndexerEndpoint.js +1 -1
- package/endpoints/generic/IndexerEndpoint.ts +1 -1
- package/endpoints/index.js +18 -8
- package/endpoints/raw/BlobEndpoint.js +23 -20
- package/endpoints/raw/BlobEndpoint.test.ts +2 -2
- package/endpoints/raw/BlobEndpoint.ts +22 -19
- package/endpoints/raw/UploadEndpoint.js +12 -9
- package/endpoints/raw/UploadEndpoint.test.ts +17 -5
- package/endpoints/raw/UploadEndpoint.ts +12 -8
- package/endpoints/rpc/ActionEndpoint.js +4 -4
- package/endpoints/rpc/ActionEndpoint.ts +4 -4
- package/endpoints/rpc/ConsumerEndpoint.js +4 -4
- package/endpoints/rpc/ConsumerEndpoint.ts +4 -4
- package/endpoints/rpc/FunctionEndpoint.js +4 -4
- package/endpoints/rpc/FunctionEndpoint.ts +4 -4
- package/endpoints/rpc/ProducerEndpoint.js +4 -4
- package/endpoints/rpc/ProducerEndpoint.ts +4 -4
- package/endpoints/rpc/RpcEndpointBase.js +4 -4
- package/endpoints/rpc/RpcEndpointBase.ts +4 -4
- package/errors/DefaultErrorHandler.js +10 -10
- package/errors/DefaultErrorHandler.ts +8 -8
- package/errors/ErrorHandler.ts +1 -1
- package/errors/Errors.js +8 -9
- package/errors/Errors.ts +7 -9
- package/http/FetchHttpClient.js +3 -3
- package/http/FetchHttpClient.ts +2 -2
- package/http/HttpHeader.js +2 -2
- package/http/HttpMethod.js +2 -2
- package/http/HttpStatusCode.js +2 -2
- package/http/ResponseCache.js +2 -2
- package/index.js +18 -8
- package/jest.config.js +12 -0
- package/links/AggregateLinkExtractor.js +2 -2
- package/links/AggregateLinkExtractor.ts +1 -1
- package/links/HalLinkExtractor.js +2 -2
- package/links/HalLinkExtractor.ts +1 -1
- package/links/HeaderLinkExtractor.js +3 -3
- package/links/HeaderLinkExtractor.ts +1 -1
- package/package.json +10 -17
- package/serializers/JsonSerializer.js +3 -3
- package/serializers/JsonSerializer.ts +3 -3
- package/docs/assets/main.js +0 -52
- package/docs/assets/search.js +0 -1
- package/endpoints/_doc.js +0 -7
- package/endpoints/_doc.ts +0 -5
- package/endpoints/generic/_doc.js +0 -6
- package/endpoints/generic/_doc.ts +0 -4
- package/endpoints/raw/_doc.js +0 -6
- package/endpoints/raw/_doc.ts +0 -4
- package/endpoints/rpc/_doc.js +0 -6
- package/endpoints/rpc/_doc.ts +0 -4
- package/errors/_doc.js +0 -7
- package/errors/_doc.ts +0 -5
- package/http/_doc.js +0 -6
- package/http/_doc.ts +0 -4
- package/links/_doc.js +0 -7
- package/links/_doc.ts +0 -5
- package/serializers/_doc.js +0 -6
- package/serializers/_doc.ts +0 -4
|
@@ -29,10 +29,10 @@ export class ElementEndpoint<TEntity> extends ETagEndpointBase {
|
|
|
29
29
|
/**
|
|
30
30
|
* Returns the `TEntity`.
|
|
31
31
|
* @param signal Used to cancel the request.
|
|
32
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
33
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
34
|
-
* @throws {@link NotFoundError}: {@link HttpStatusCode.NotFound} or {@link HttpStatusCode.Gone}
|
|
35
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
32
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
33
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
34
|
+
* @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
|
|
35
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
36
36
|
*/
|
|
37
37
|
async read(signal?: AbortSignal) {
|
|
38
38
|
return this.serializer.deserialize<TEntity>(await this.getContent(signal));
|
|
@@ -41,9 +41,9 @@ export class ElementEndpoint<TEntity> extends ETagEndpointBase {
|
|
|
41
41
|
/**
|
|
42
42
|
* Determines whether the element currently exists.
|
|
43
43
|
* @param signal Used to cancel the request.
|
|
44
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
45
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
46
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
44
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
45
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
46
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
47
47
|
*/
|
|
48
48
|
async exists(signal?: AbortSignal) {
|
|
49
49
|
const response = await this.httpClient.send(this.uri, HttpMethod.Head, signal);
|
|
@@ -66,12 +66,12 @@ export class ElementEndpoint<TEntity> extends ETagEndpointBase {
|
|
|
66
66
|
* @param entity The new `TEntity`.
|
|
67
67
|
* @param signal Used to cancel the request.
|
|
68
68
|
* @returns The `TEntity` as returned by the server, possibly with additional fields set. undefined if the server does not respond with a result entity.
|
|
69
|
-
* @throws {@link ConcurrencyError}: The entity has changed since it was last retrieved with {@link read}. Your changes were rejected to prevent a lost update.
|
|
70
|
-
* @throws {@link BadRequestError}: {@link HttpStatusCode.BadRequest}
|
|
71
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
72
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
73
|
-
* @throws {@link NotFoundError}: {@link HttpStatusCode.NotFound} or {@link HttpStatusCode.Gone}
|
|
74
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
69
|
+
* @throws {@link errors!ConcurrencyError}: The entity has changed since it was last retrieved with {@link read}. Your changes were rejected to prevent a lost update.
|
|
70
|
+
* @throws {@link errors!BadRequestError}: {@link http!HttpStatusCode.BadRequest}
|
|
71
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
72
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
73
|
+
* @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
|
|
74
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
75
75
|
*/
|
|
76
76
|
async set(entity: TEntity, signal?: AbortSignal): Promise<(TEntity | undefined)> {
|
|
77
77
|
const response = await this.putContent(entity, signal);
|
|
@@ -93,12 +93,12 @@ export class ElementEndpoint<TEntity> extends ETagEndpointBase {
|
|
|
93
93
|
* @param entity The `TEntity` data to merge with the existing element.
|
|
94
94
|
* @param signal Used to cancel the request.
|
|
95
95
|
* @returns The `TEntity` as returned by the server, possibly with additional fields set. undefined if the server does not respond with a result entity.
|
|
96
|
-
* @throws {@link ConcurrencyError}: The entity has changed since it was last retrieved with {@link read}. Your changes were rejected to prevent a lost update.
|
|
97
|
-
* @throws {@link BadRequestError}: {@link HttpStatusCode.BadRequest}
|
|
98
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
99
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
100
|
-
* @throws {@link NotFoundError}: {@link HttpStatusCode.NotFound} or {@link HttpStatusCode.Gone}
|
|
101
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
96
|
+
* @throws {@link errors!ConcurrencyError}: The entity has changed since it was last retrieved with {@link read}. Your changes were rejected to prevent a lost update.
|
|
97
|
+
* @throws {@link errors!BadRequestError}: {@link http!HttpStatusCode.BadRequest}
|
|
98
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
99
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
100
|
+
* @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
|
|
101
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
102
102
|
*/
|
|
103
103
|
async merge(entity: TEntity, signal?: AbortSignal): Promise<(TEntity | undefined)> {
|
|
104
104
|
this.responseCache = undefined;
|
|
@@ -118,12 +118,12 @@ export class ElementEndpoint<TEntity> extends ETagEndpointBase {
|
|
|
118
118
|
* @param maxRetries The maximum number of retries to perform for optimistic concurrency before giving up.
|
|
119
119
|
* @param signal Used to cancel the request.
|
|
120
120
|
* @returns The `TEntity` as returned by the server, possibly with additional fields set. undefined if the server does not respond with a result entity.
|
|
121
|
-
* @throws {@link ConcurrencyError}: The maximum number of retries to perform for optimistic concurrency before giving up.
|
|
122
|
-
* @throws {@link BadRequestError}: {@link HttpStatusCode.BadRequest}
|
|
123
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
124
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
125
|
-
* @throws {@link NotFoundError}: {@link HttpStatusCode.NotFound} or {@link HttpStatusCode.Gone}
|
|
126
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
121
|
+
* @throws {@link errors!ConcurrencyError}: The maximum number of retries to perform for optimistic concurrency before giving up.
|
|
122
|
+
* @throws {@link errors!BadRequestError}: {@link http!HttpStatusCode.BadRequest}
|
|
123
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
124
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
125
|
+
* @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
|
|
126
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
127
127
|
*/
|
|
128
128
|
async update(updateAction: (entity: TEntity) => void, maxRetries: number = 3, signal?: AbortSignal): Promise<(TEntity | undefined)> {
|
|
129
129
|
let retryCounter = 0;
|
|
@@ -149,11 +149,11 @@ export class ElementEndpoint<TEntity> extends ETagEndpointBase {
|
|
|
149
149
|
/**
|
|
150
150
|
* Deletes the element.
|
|
151
151
|
* @param signal Used to cancel the request.
|
|
152
|
-
* @throws {@link ConcurrencyError}: The entity has changed since it was last retrieved with {@link read}. Your changes were rejected to prevent a lost update.
|
|
153
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
154
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
155
|
-
* @throws {@link NotFoundError}: {@link HttpStatusCode.NotFound} or {@link HttpStatusCode.Gone}
|
|
156
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
152
|
+
* @throws {@link errors!ConcurrencyError}: The entity has changed since it was last retrieved with {@link read}. Your changes were rejected to prevent a lost update.
|
|
153
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
154
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
155
|
+
* @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
|
|
156
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
157
157
|
*/
|
|
158
158
|
async delete(signal?: AbortSignal) {
|
|
159
159
|
await this.deleteContent(signal);
|
|
@@ -59,10 +59,10 @@ class GenericCollectionEndpoint extends ETagEndpointBase_1.ETagEndpointBase {
|
|
|
59
59
|
/**
|
|
60
60
|
* Returns all `TEntity`s in the collection.
|
|
61
61
|
* @param signal Used to cancel the request.
|
|
62
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
63
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
64
|
-
* @throws {@link ConflictError}: {@link HttpStatusCode.Conflict}
|
|
65
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
62
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
63
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
64
|
+
* @throws {@link errors!ConflictError}: {@link http!HttpStatusCode.Conflict}
|
|
65
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
66
66
|
*/
|
|
67
67
|
readAll(signal) {
|
|
68
68
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -80,11 +80,11 @@ class GenericCollectionEndpoint extends ETagEndpointBase_1.ETagEndpointBase {
|
|
|
80
80
|
* @param entity The new `TEntity`.
|
|
81
81
|
* @param signal Used to cancel the request.
|
|
82
82
|
* @returns An endpoint for the newly created entity; `undefined` if the server returned neither a "Location" header nor an entity with an ID in the response body.
|
|
83
|
-
* @throws {@link BadRequestError}: {@link HttpStatusCode.BadRequest}
|
|
84
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
85
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
86
|
-
* @throws {@link ConflictError}: {@link HttpStatusCode.Conflict}
|
|
87
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
83
|
+
* @throws {@link errors!BadRequestError}: {@link http!HttpStatusCode.BadRequest}
|
|
84
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
85
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
86
|
+
* @throws {@link errors!ConflictError}: {@link http!HttpStatusCode.Conflict}
|
|
87
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
88
88
|
*/
|
|
89
89
|
create(entity, signal) {
|
|
90
90
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -121,11 +121,11 @@ class GenericCollectionEndpoint extends ETagEndpointBase_1.ETagEndpointBase {
|
|
|
121
121
|
* Adds (or updates) multiple `TEntity`s as elements in the collection.
|
|
122
122
|
* @param entities The `TEntity`s to create or modify.
|
|
123
123
|
* @param signal Used to cancel the request.
|
|
124
|
-
* @throws {@link BadRequestError}: {@link HttpStatusCode.BadRequest}
|
|
125
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
126
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
127
|
-
* @throws {@link ConflictError}: {@link HttpStatusCode.Conflict}
|
|
128
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
124
|
+
* @throws {@link errors!BadRequestError}: {@link http!HttpStatusCode.BadRequest}
|
|
125
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
126
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
127
|
+
* @throws {@link errors!ConflictError}: {@link http!HttpStatusCode.Conflict}
|
|
128
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
129
129
|
*/
|
|
130
130
|
createAll(entities, signal) {
|
|
131
131
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -143,11 +143,11 @@ class GenericCollectionEndpoint extends ETagEndpointBase_1.ETagEndpointBase {
|
|
|
143
143
|
/**
|
|
144
144
|
* Replaces the entire content of the collection with new `TEntity`s.
|
|
145
145
|
* @param entities The `TEntity`s to create or modify.
|
|
146
|
-
* @throws {@link BadRequestError}: {@link HttpStatusCode.BadRequest}
|
|
147
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
148
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
149
|
-
* @throws {@link ConflictError}: {@link HttpStatusCode.Conflict}
|
|
150
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
146
|
+
* @throws {@link errors!BadRequestError}: {@link http!HttpStatusCode.BadRequest}
|
|
147
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
148
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
149
|
+
* @throws {@link errors!ConflictError}: {@link http!HttpStatusCode.Conflict}
|
|
150
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
151
151
|
*/
|
|
152
152
|
setAll(entities) {
|
|
153
153
|
return __awaiter(this, void 0, void 0, function* () { yield this.putContent(entities); });
|
|
@@ -155,42 +155,42 @@ class GenericCollectionEndpoint extends ETagEndpointBase_1.ETagEndpointBase {
|
|
|
155
155
|
/**
|
|
156
156
|
* Determines whether the collection contains a specific element.
|
|
157
157
|
* @param element The ID identifying the entity or an entity to extract the ID from.
|
|
158
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
159
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
160
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
158
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
159
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
160
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
161
161
|
*/
|
|
162
162
|
contains(element) { return this.get(element).exists(); }
|
|
163
163
|
/**
|
|
164
164
|
* Sets/replaces an existing element in the collection.
|
|
165
165
|
* @param element The new state of the element.
|
|
166
166
|
* @returns The `TEntity` as returned by the server, possibly with additional fields set. undefined if the server does not respond with a result entity.
|
|
167
|
-
* @throws {@link BadRequestError}: {@link HttpStatusCode.BadRequest}
|
|
168
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
169
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
170
|
-
* @throws {@link NotFoundError}: {@link HttpStatusCode.NotFound} or {@link HttpStatusCode.Gone}
|
|
171
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
167
|
+
* @throws {@link errors!BadRequestError}: {@link http!HttpStatusCode.BadRequest}
|
|
168
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
169
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
170
|
+
* @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
|
|
171
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
172
172
|
*/
|
|
173
173
|
set(element) { return this.get(element).set(element); }
|
|
174
174
|
/**
|
|
175
175
|
* Modifies an existing element in the collection by merging changes on the server-side.
|
|
176
176
|
* @param element The `TEntity` data to merge with the existing element.
|
|
177
177
|
* @returns The `TEntity` as returned by the server, possibly with additional fields set. undefined if the server does not respond with a result entity.
|
|
178
|
-
* @throws {@link BadRequestError}: {@link HttpStatusCode.BadRequest}
|
|
179
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
180
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
181
|
-
* @throws {@link NotFoundError}: {@link HttpStatusCode.NotFound} or {@link HttpStatusCode.Gone}
|
|
182
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
178
|
+
* @throws {@link errors!BadRequestError}: {@link http!HttpStatusCode.BadRequest}
|
|
179
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
180
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
181
|
+
* @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
|
|
182
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
183
183
|
*/
|
|
184
184
|
merge(element) { return this.get(element).merge(element); }
|
|
185
185
|
/**
|
|
186
186
|
* Deletes an existing element from the collection.
|
|
187
187
|
* @param element The ID identifying the entity or an entity to extract the ID from.
|
|
188
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
189
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
190
|
-
* @throws {@link NotFoundError}: {@link HttpStatusCode.NotFound} or {@link HttpStatusCode.Gone}
|
|
191
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
188
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
189
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
190
|
+
* @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
|
|
191
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
192
192
|
*/
|
|
193
193
|
delete(element) { return this.get(element).delete(); }
|
|
194
194
|
}
|
|
195
195
|
exports.GenericCollectionEndpoint = GenericCollectionEndpoint;
|
|
196
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
196
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiR2VuZXJpY0NvbGxlY3Rpb25FbmRwb2ludC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIkdlbmVyaWNDb2xsZWN0aW9uRW5kcG9pbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7O0FBQUEseURBQXNEO0FBSXRELHFDQUFtRTtBQUVuRTs7Ozs7R0FLRztBQUNILE1BQWEseUJBQXNGLFNBQVEsbUNBQWdCO0lBQ3ZIOzs7OztPQUtHO0lBQ0gsWUFBWSxRQUFrQixFQUFFLFdBQXlCLEVBQW1CLGVBQXVFO1FBQy9JLEtBQUssQ0FBQyxRQUFRLEVBQUUsV0FBVyxDQU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QUksQ0FBQyxVQUFVLENBQUMsUUFBUSxDQUFDLENBQUMsQ0FBQyxDQUFDO0tBQUE7SUFFdEU7Ozs7OztPQU1HO0lBQ0gsUUFBUSxDQUFDLE9BQTJCLElBQUksT0FBTyxJQUFJLENBQUMsR0FBRyxDQUFDLE9BQU8sQ0FBQyxDQUFDLE1BQU0sRUFBRSxDQUFDLENBQUMsQ0FBQztJQUU1RTs7Ozs7Ozs7O09BU0c7SUFDSCxHQUFHLENBQUMsT0FBZ0IsSUFBSSxPQUFPLElBQUksQ0FBQyxHQUFHLENBQUMsT0FBTyxDQUFDLENBQUMsR0FBRyxDQUFDLE9BQU8sQ0FBQyxDQUFDLENBQUMsQ0FBQztJQUVoRTs7Ozs7Ozs7O09BU0c7SUFDSCxLQUFLLENBQUMsT0FBZ0IsSUFBSSxPQUFPLElBQUksQ0FBQyxHQUFHLENBQUMsT0FBTyxDQUFDLENBQUMsS0FBSyxDQUFDLE9BQU8sQ0FBQyxDQUFDLENBQUMsQ0FBQztJQUVwRTs7Ozs7OztPQU9HO0lBQ0gsTUFBTSxDQUFDLE9BQTJCLElBQUksT0FBTyxJQUFJLENBQUMsR0FBRyxDQUFDLE9BQU8sQ0FBQyxDQUFDLE1BQU0sRUFBRSxDQUFDLENBQUMsQ0FBQztDQUM3RTtBQS9LRCw4REErS0MifQ==
|
|
@@ -51,10 +51,10 @@ export class GenericCollectionEndpoint<TEntity, TElementEndpoint extends Element
|
|
|
51
51
|
/**
|
|
52
52
|
* Returns all `TEntity`s in the collection.
|
|
53
53
|
* @param signal Used to cancel the request.
|
|
54
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
55
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
56
|
-
* @throws {@link ConflictError}: {@link HttpStatusCode.Conflict}
|
|
57
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
54
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
55
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
56
|
+
* @throws {@link errors!ConflictError}: {@link http!HttpStatusCode.Conflict}
|
|
57
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
58
58
|
*/
|
|
59
59
|
async readAll(signal?: AbortSignal) {
|
|
60
60
|
return this.serializer.deserialize<TEntity[]>(await this.getContent(signal));
|
|
@@ -72,11 +72,11 @@ export class GenericCollectionEndpoint<TEntity, TElementEndpoint extends Element
|
|
|
72
72
|
* @param entity The new `TEntity`.
|
|
73
73
|
* @param signal Used to cancel the request.
|
|
74
74
|
* @returns An endpoint for the newly created entity; `undefined` if the server returned neither a "Location" header nor an entity with an ID in the response body.
|
|
75
|
-
* @throws {@link BadRequestError}: {@link HttpStatusCode.BadRequest}
|
|
76
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
77
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
78
|
-
* @throws {@link ConflictError}: {@link HttpStatusCode.Conflict}
|
|
79
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
75
|
+
* @throws {@link errors!BadRequestError}: {@link http!HttpStatusCode.BadRequest}
|
|
76
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
77
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
78
|
+
* @throws {@link errors!ConflictError}: {@link http!HttpStatusCode.Conflict}
|
|
79
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
80
80
|
*/
|
|
81
81
|
async create(entity: TEntity, signal?: AbortSignal): Promise<TElementEndpoint | undefined> {
|
|
82
82
|
const response = await this.send(HttpMethod.Post, signal, {
|
|
@@ -113,11 +113,11 @@ export class GenericCollectionEndpoint<TEntity, TElementEndpoint extends Element
|
|
|
113
113
|
* Adds (or updates) multiple `TEntity`s as elements in the collection.
|
|
114
114
|
* @param entities The `TEntity`s to create or modify.
|
|
115
115
|
* @param signal Used to cancel the request.
|
|
116
|
-
* @throws {@link BadRequestError}: {@link HttpStatusCode.BadRequest}
|
|
117
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
118
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
119
|
-
* @throws {@link ConflictError}: {@link HttpStatusCode.Conflict}
|
|
120
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
116
|
+
* @throws {@link errors!BadRequestError}: {@link http!HttpStatusCode.BadRequest}
|
|
117
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
118
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
119
|
+
* @throws {@link errors!ConflictError}: {@link http!HttpStatusCode.Conflict}
|
|
120
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
121
121
|
*/
|
|
122
122
|
async createAll(entities: TEntity[], signal?: AbortSignal) {
|
|
123
123
|
await this.send(HttpMethod.Patch, signal, {
|
|
@@ -135,20 +135,20 @@ export class GenericCollectionEndpoint<TEntity, TElementEndpoint extends Element
|
|
|
135
135
|
/**
|
|
136
136
|
* Replaces the entire content of the collection with new `TEntity`s.
|
|
137
137
|
* @param entities The `TEntity`s to create or modify.
|
|
138
|
-
* @throws {@link BadRequestError}: {@link HttpStatusCode.BadRequest}
|
|
139
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
140
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
141
|
-
* @throws {@link ConflictError}: {@link HttpStatusCode.Conflict}
|
|
142
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
138
|
+
* @throws {@link errors!BadRequestError}: {@link http!HttpStatusCode.BadRequest}
|
|
139
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
140
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
141
|
+
* @throws {@link errors!ConflictError}: {@link http!HttpStatusCode.Conflict}
|
|
142
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
143
143
|
*/
|
|
144
144
|
async setAll(entities: TEntity[]) { await this.putContent(entities); }
|
|
145
145
|
|
|
146
146
|
/**
|
|
147
147
|
* Determines whether the collection contains a specific element.
|
|
148
148
|
* @param element The ID identifying the entity or an entity to extract the ID from.
|
|
149
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
150
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
151
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
149
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
150
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
151
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
152
152
|
*/
|
|
153
153
|
contains(element: (TEntity | string)) { return this.get(element).exists(); }
|
|
154
154
|
|
|
@@ -156,11 +156,11 @@ export class GenericCollectionEndpoint<TEntity, TElementEndpoint extends Element
|
|
|
156
156
|
* Sets/replaces an existing element in the collection.
|
|
157
157
|
* @param element The new state of the element.
|
|
158
158
|
* @returns The `TEntity` as returned by the server, possibly with additional fields set. undefined if the server does not respond with a result entity.
|
|
159
|
-
* @throws {@link BadRequestError}: {@link HttpStatusCode.BadRequest}
|
|
160
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
161
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
162
|
-
* @throws {@link NotFoundError}: {@link HttpStatusCode.NotFound} or {@link HttpStatusCode.Gone}
|
|
163
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
159
|
+
* @throws {@link errors!BadRequestError}: {@link http!HttpStatusCode.BadRequest}
|
|
160
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
161
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
162
|
+
* @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
|
|
163
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
164
164
|
*/
|
|
165
165
|
set(element: TEntity) { return this.get(element).set(element); }
|
|
166
166
|
|
|
@@ -168,21 +168,21 @@ export class GenericCollectionEndpoint<TEntity, TElementEndpoint extends Element
|
|
|
168
168
|
* Modifies an existing element in the collection by merging changes on the server-side.
|
|
169
169
|
* @param element The `TEntity` data to merge with the existing element.
|
|
170
170
|
* @returns The `TEntity` as returned by the server, possibly with additional fields set. undefined if the server does not respond with a result entity.
|
|
171
|
-
* @throws {@link BadRequestError}: {@link HttpStatusCode.BadRequest}
|
|
172
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
173
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
174
|
-
* @throws {@link NotFoundError}: {@link HttpStatusCode.NotFound} or {@link HttpStatusCode.Gone}
|
|
175
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
171
|
+
* @throws {@link errors!BadRequestError}: {@link http!HttpStatusCode.BadRequest}
|
|
172
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
173
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
174
|
+
* @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
|
|
175
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
176
176
|
*/
|
|
177
177
|
merge(element: TEntity) { return this.get(element).merge(element); }
|
|
178
178
|
|
|
179
179
|
/**
|
|
180
180
|
* Deletes an existing element from the collection.
|
|
181
181
|
* @param element The ID identifying the entity or an entity to extract the ID from.
|
|
182
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
183
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
184
|
-
* @throws {@link NotFoundError}: {@link HttpStatusCode.NotFound} or {@link HttpStatusCode.Gone}
|
|
185
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
182
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
183
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
184
|
+
* @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
|
|
185
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
186
186
|
*/
|
|
187
187
|
delete(element: (TEntity | string)) { return this.get(element).delete(); }
|
|
188
188
|
}
|
|
@@ -4,7 +4,7 @@ exports.IndexerEndpoint = void 0;
|
|
|
4
4
|
const Endpoint_1 = require("../Endpoint");
|
|
5
5
|
/**
|
|
6
6
|
* Endpoint that addresses child `TElementEndpoint`s by ID.
|
|
7
|
-
* @typeParam The type of @
|
|
7
|
+
* @typeParam TElementEndpoint The type of {@link Endpoint} to provide for individual elements.
|
|
8
8
|
*/
|
|
9
9
|
class IndexerEndpoint extends Endpoint_1.Endpoint {
|
|
10
10
|
/**
|
|
@@ -2,7 +2,7 @@ import { Endpoint } from "../Endpoint";
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Endpoint that addresses child `TElementEndpoint`s by ID.
|
|
5
|
-
* @typeParam The type of @
|
|
5
|
+
* @typeParam TElementEndpoint The type of {@link Endpoint} to provide for individual elements.
|
|
6
6
|
*/
|
|
7
7
|
export class IndexerEndpoint<TElementEndpoint extends Endpoint> extends Endpoint {
|
|
8
8
|
/**
|
package/endpoints/index.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
26
36
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
37
|
};
|
|
@@ -33,4 +43,4 @@ exports.raw = __importStar(require("./raw"));
|
|
|
33
43
|
__exportStar(require("./Endpoint"), exports);
|
|
34
44
|
__exportStar(require("./EntryEndpoint"), exports);
|
|
35
45
|
__exportStar(require("./CachingEndpoint"), exports);
|
|
36
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
46
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJpbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSxxREFBcUM7QUFDckMsNkNBQTZCO0FBQzdCLDZDQUE2QjtBQUU3Qiw2Q0FBMkI7QUFDM0Isa0RBQWdDO0FBQ2hDLG9EQUFrQyJ9
|
|
@@ -12,6 +12,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.BlobEndpoint = void 0;
|
|
13
13
|
const Endpoint_1 = require("../Endpoint");
|
|
14
14
|
const http_1 = require("../../http");
|
|
15
|
+
/**
|
|
16
|
+
* Endpoint for a binary blob that can be downloaded or uploaded.
|
|
17
|
+
*/
|
|
15
18
|
class BlobEndpoint extends Endpoint_1.Endpoint {
|
|
16
19
|
/**
|
|
17
20
|
* Creates a new blob endpoint.
|
|
@@ -24,10 +27,10 @@ class BlobEndpoint extends Endpoint_1.Endpoint {
|
|
|
24
27
|
/**
|
|
25
28
|
* Queries the server about capabilities of the endpoint without performing any action.
|
|
26
29
|
* @param signal Used to cancel the request.
|
|
27
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
28
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
29
|
-
* @throws {@link NotFoundError}: {@link HttpStatusCode.NotFound} or {@link HttpStatusCode.Gone}
|
|
30
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
30
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
31
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
32
|
+
* @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
|
|
33
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
31
34
|
*/
|
|
32
35
|
probe(signal) {
|
|
33
36
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -43,11 +46,11 @@ class BlobEndpoint extends Endpoint_1.Endpoint {
|
|
|
43
46
|
/**
|
|
44
47
|
* Downloads the blob's content.
|
|
45
48
|
* @param signal Used to cancel the request.
|
|
46
|
-
* @throws {@link BadRequestError}: {@link HttpStatusCode.BadRequest}
|
|
47
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
48
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
49
|
-
* @throws {@link NotFoundError}: {@link HttpStatusCode.NotFound} or {@link HttpStatusCode.Gone}
|
|
50
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
49
|
+
* @throws {@link errors!BadRequestError}: {@link http!HttpStatusCode.BadRequest}
|
|
50
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
51
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
52
|
+
* @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
|
|
53
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
51
54
|
*/
|
|
52
55
|
download(signal) {
|
|
53
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -65,12 +68,12 @@ class BlobEndpoint extends Endpoint_1.Endpoint {
|
|
|
65
68
|
* Uploads data as the blob's content.
|
|
66
69
|
* @param blob The blob to read the upload data from.
|
|
67
70
|
* @param signal Used to cancel the request.
|
|
68
|
-
* @throws {@link BadRequestError}: {@link HttpStatusCode.BadRequest}
|
|
69
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
70
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
71
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
71
|
+
* @throws {@link errors!BadRequestError}: {@link http!HttpStatusCode.BadRequest}
|
|
72
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
73
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
74
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
72
75
|
*/
|
|
73
|
-
|
|
76
|
+
uploadFrom(blob, signal) {
|
|
74
77
|
return __awaiter(this, void 0, void 0, function* () {
|
|
75
78
|
yield this.send(http_1.HttpMethod.Put, signal, { [http_1.HttpHeader.ContentType]: blob.type }, blob);
|
|
76
79
|
});
|
|
@@ -84,11 +87,11 @@ class BlobEndpoint extends Endpoint_1.Endpoint {
|
|
|
84
87
|
/**
|
|
85
88
|
* Deletes the blob from the server.
|
|
86
89
|
* @param signal Used to cancel the request.
|
|
87
|
-
* @throws {@link BadRequestError}: {@link HttpStatusCode.BadRequest}
|
|
88
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
89
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
90
|
-
* @throws {@link NotFoundError}: {@link HttpStatusCode.NotFound} or {@link HttpStatusCode.Gone}
|
|
91
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
90
|
+
* @throws {@link errors!BadRequestError}: {@link http!HttpStatusCode.BadRequest}
|
|
91
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
92
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
93
|
+
* @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
|
|
94
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
92
95
|
*/
|
|
93
96
|
delete(signal) {
|
|
94
97
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -97,4 +100,4 @@ class BlobEndpoint extends Endpoint_1.Endpoint {
|
|
|
97
100
|
}
|
|
98
101
|
}
|
|
99
102
|
exports.BlobEndpoint = BlobEndpoint;
|
|
100
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
103
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQmxvYkVuZ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BQzdDLE1BQU0sSUFBSSxDQUFDLElBQUksQ0FBQyxpQkFBVSxDQUFDLEdBQUcsRUFBRSxNQUFNLEVBQUUsRUFBRSxDQUFDLGlCQUFVLENBQUMsV0FBVyxDQUFDLEVBQUUsSUFBSSxDQUFDLElBQUksRUFBRSxFQUFFLElBQUksQ0FBQyxDQUFDO1FBQzNGLENBQUM7S0FBQTtJQUVEOzs7O09BSUc7SUFDSCxJQUFJLGFBQWEsS0FBSyxPQUFPLElBQUksQ0FBQyxlQUFlLENBQUMsaUJBQVUsQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUM7SUFFdkU7Ozs7Ozs7O09BUUc7SUFDRyxNQUFNLENBQUMsTUFBb0I7O1lBQzdCLE1BQU0sSUFBSSxDQUFDLElBQUksQ0FBQyxpQkFBVSxDQUFDLE1BQU0sRUFBRSxNQUFNLENBQUMsQ0FBQztRQUMvQyxDQUFDO0tBQUE7Q0FDSjtBQWxGRCxvQ0FrRkMifQ==
|
|
@@ -37,7 +37,7 @@ test('download', async () => {
|
|
|
37
37
|
await endpoint.download();
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
-
test('
|
|
40
|
+
test('uploadFrom', async () => {
|
|
41
41
|
const data = new Blob([new Uint8Array([1, 2, 3])], { type: 'mock/type' });
|
|
42
42
|
|
|
43
43
|
fetchMock.mockOnceIf(
|
|
@@ -48,5 +48,5 @@ test('upload', async () => {
|
|
|
48
48
|
}
|
|
49
49
|
);
|
|
50
50
|
|
|
51
|
-
await endpoint.
|
|
51
|
+
await endpoint.uploadFrom(data);
|
|
52
52
|
});
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Endpoint } from "../Endpoint";
|
|
2
2
|
import { HttpMethod, HttpHeader } from "../../http";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Endpoint for a binary blob that can be downloaded or uploaded.
|
|
6
|
+
*/
|
|
4
7
|
export class BlobEndpoint extends Endpoint {
|
|
5
8
|
/**
|
|
6
9
|
* Creates a new blob endpoint.
|
|
@@ -14,10 +17,10 @@ export class BlobEndpoint extends Endpoint {
|
|
|
14
17
|
/**
|
|
15
18
|
* Queries the server about capabilities of the endpoint without performing any action.
|
|
16
19
|
* @param signal Used to cancel the request.
|
|
17
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
18
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
19
|
-
* @throws {@link NotFoundError}: {@link HttpStatusCode.NotFound} or {@link HttpStatusCode.Gone}
|
|
20
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
20
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
21
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
22
|
+
* @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
|
|
23
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
21
24
|
*/
|
|
22
25
|
async probe(signal?: AbortSignal) {
|
|
23
26
|
await this.send(HttpMethod.Options, signal);
|
|
@@ -33,11 +36,11 @@ export class BlobEndpoint extends Endpoint {
|
|
|
33
36
|
/**
|
|
34
37
|
* Downloads the blob's content.
|
|
35
38
|
* @param signal Used to cancel the request.
|
|
36
|
-
* @throws {@link BadRequestError}: {@link HttpStatusCode.BadRequest}
|
|
37
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
38
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
39
|
-
* @throws {@link NotFoundError}: {@link HttpStatusCode.NotFound} or {@link HttpStatusCode.Gone}
|
|
40
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
39
|
+
* @throws {@link errors!BadRequestError}: {@link http!HttpStatusCode.BadRequest}
|
|
40
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
41
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
42
|
+
* @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
|
|
43
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
41
44
|
*/
|
|
42
45
|
async download(signal?: AbortSignal): Promise<Blob> {
|
|
43
46
|
const response = await this.send(HttpMethod.Get, signal);
|
|
@@ -55,12 +58,12 @@ export class BlobEndpoint extends Endpoint {
|
|
|
55
58
|
* Uploads data as the blob's content.
|
|
56
59
|
* @param blob The blob to read the upload data from.
|
|
57
60
|
* @param signal Used to cancel the request.
|
|
58
|
-
* @throws {@link BadRequestError}: {@link HttpStatusCode.BadRequest}
|
|
59
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
60
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
61
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
61
|
+
* @throws {@link errors!BadRequestError}: {@link http!HttpStatusCode.BadRequest}
|
|
62
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
63
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
64
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
62
65
|
*/
|
|
63
|
-
async
|
|
66
|
+
async uploadFrom(blob: Blob, signal?: AbortSignal) {
|
|
64
67
|
await this.send(HttpMethod.Put, signal, { [HttpHeader.ContentType]: blob.type }, blob);
|
|
65
68
|
}
|
|
66
69
|
|
|
@@ -74,11 +77,11 @@ export class BlobEndpoint extends Endpoint {
|
|
|
74
77
|
/**
|
|
75
78
|
* Deletes the blob from the server.
|
|
76
79
|
* @param signal Used to cancel the request.
|
|
77
|
-
* @throws {@link BadRequestError}: {@link HttpStatusCode.BadRequest}
|
|
78
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
79
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
80
|
-
* @throws {@link NotFoundError}: {@link HttpStatusCode.NotFound} or {@link HttpStatusCode.Gone}
|
|
81
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
80
|
+
* @throws {@link errors!BadRequestError}: {@link http!HttpStatusCode.BadRequest}
|
|
81
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
82
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
83
|
+
* @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
|
|
84
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
82
85
|
*/
|
|
83
86
|
async delete(signal?: AbortSignal) {
|
|
84
87
|
await this.send(HttpMethod.Delete, signal);
|