typedrest 0.3.5 → 0.3.7
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/endpoints/Endpoint.js +11 -11
- package/endpoints/Endpoint.ts +11 -11
- package/endpoints/EntryEndpoint.js +8 -8
- package/endpoints/EntryEndpoint.ts +8 -8
- package/endpoints/generic/ETagEndpointBase.js +20 -20
- package/endpoints/generic/ETagEndpointBase.ts +21 -21
- package/endpoints/generic/ElementEndpoint.js +30 -30
- package/endpoints/generic/ElementEndpoint.ts +30 -30
- package/endpoints/generic/GenericCollectionEndpoint.js +36 -36
- package/endpoints/generic/GenericCollectionEndpoint.ts +36 -36
- package/endpoints/generic/IndexerEndpoint.js +1 -1
- package/endpoints/generic/IndexerEndpoint.ts +1 -1
- package/endpoints/raw/BlobEndpoint.js +22 -19
- package/endpoints/raw/BlobEndpoint.ts +21 -18
- package/endpoints/raw/UploadEndpoint.js +9 -6
- package/endpoints/raw/UploadEndpoint.ts +8 -5
- 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 +8 -8
- 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 +2 -2
- package/http/FetchHttpClient.ts +2 -2
- package/jest.config.js +12 -0
- package/links/AggregateLinkExtractor.js +1 -1
- package/links/AggregateLinkExtractor.ts +1 -1
- package/links/HalLinkExtractor.js +1 -1
- package/links/HalLinkExtractor.ts +1 -1
- package/links/HeaderLinkExtractor.js +1 -1
- package/links/HeaderLinkExtractor.ts +1 -1
- package/package.json +9 -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
package/endpoints/Endpoint.js
CHANGED
|
@@ -15,8 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.Endpoint = void 0;
|
|
16
16
|
const http_1 = require("../http");
|
|
17
17
|
const errors_1 = require("../errors");
|
|
18
|
-
const
|
|
19
|
-
require("urijs/src/URITemplate");
|
|
18
|
+
const url_template_1 = __importDefault(require("url-template"));
|
|
20
19
|
class Endpoint {
|
|
21
20
|
/**
|
|
22
21
|
* Creates a new endpoint.
|
|
@@ -89,7 +88,7 @@ class Endpoint {
|
|
|
89
88
|
* @param signal Used to cancel the request.
|
|
90
89
|
* @param headers The HTTP headers to set.
|
|
91
90
|
* @param body The body to send.
|
|
92
|
-
* @throws {@link HttpError}
|
|
91
|
+
* @throws {@link errors!HttpError}
|
|
93
92
|
*/
|
|
94
93
|
send(method, signal, headers, body) {
|
|
95
94
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -101,7 +100,7 @@ class Endpoint {
|
|
|
101
100
|
/**
|
|
102
101
|
* Handles various cross-cutting concerns regarding a response message such as discovering links and handling errors.
|
|
103
102
|
* @param response The response to process.
|
|
104
|
-
* @throws {@link HttpError}
|
|
103
|
+
* @throws {@link errors!HttpError}
|
|
105
104
|
*/
|
|
106
105
|
handle(response) {
|
|
107
106
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -159,33 +158,34 @@ class Endpoint {
|
|
|
159
158
|
/**
|
|
160
159
|
* Resolves a single link with a specific relation type. Uses cached data from last response.
|
|
161
160
|
* @param rel The relation type of the link to look for.
|
|
162
|
-
* @throws {@link NotFoundError}: No link with the specified `rel` could be found.
|
|
161
|
+
* @throws {@link errors!NotFoundError}: No link with the specified `rel` could be found.
|
|
163
162
|
*/
|
|
164
163
|
link(rel) {
|
|
165
164
|
const links = this.getLinks(rel);
|
|
166
165
|
if (links.length === 0)
|
|
167
|
-
throw new errors_1.NotFoundError(`No link with rel=${rel} provided by endpoint ${this.uri}.`,
|
|
166
|
+
throw new errors_1.NotFoundError(`No link with rel=${rel} provided by endpoint ${this.uri}.`, http_1.HttpStatusCode.NotFound);
|
|
168
167
|
return links[0].uri;
|
|
169
168
|
}
|
|
170
169
|
/**
|
|
171
170
|
* Resolves a link template with a specific relation type. Uses cached data from last response.
|
|
172
171
|
* @param rel The relation type of the link template to look for.
|
|
173
172
|
* @param variables Variables for resolving the template.
|
|
174
|
-
* @throws {@link NotFoundError}: No link template with the specified `rel` could be found.
|
|
173
|
+
* @throws {@link errors!NotFoundError}: No link template with the specified `rel` could be found.
|
|
175
174
|
*/
|
|
176
175
|
linkTemplate(rel, variables) {
|
|
177
|
-
|
|
176
|
+
const tmpl = url_template_1.default.parse(this.getLinkTemplate(rel));
|
|
177
|
+
return new URL(this.join(tmpl.expand(variables)));
|
|
178
178
|
}
|
|
179
179
|
/**
|
|
180
180
|
* Retrieves a link template with a specific relation type. Uses cached data from last response. Prefer {@link linkTemplate} when possible.
|
|
181
181
|
* @param rel The relation type of the link template to look for.
|
|
182
|
-
* @throws {@link NotFoundError}: No link template with the specified `rel` could be found.
|
|
182
|
+
* @throws {@link errors!NotFoundError}: No link template with the specified `rel` could be found.
|
|
183
183
|
*/
|
|
184
184
|
getLinkTemplate(rel) {
|
|
185
185
|
var _a, _b;
|
|
186
186
|
const template = (_b = (_a = this.links.find(x => x.templated && x.rel === rel)) === null || _a === void 0 ? void 0 : _a.href) !== null && _b !== void 0 ? _b : this.defaultLinkTemplates.get(rel);
|
|
187
187
|
if (!template)
|
|
188
|
-
throw new errors_1.NotFoundError(`No link template with rel=${rel} provided by endpoint ${this.uri}.`,
|
|
188
|
+
throw new errors_1.NotFoundError(`No link template with rel=${rel} provided by endpoint ${this.uri}.`, http_1.HttpStatusCode.NotFound);
|
|
189
189
|
return template;
|
|
190
190
|
}
|
|
191
191
|
/**
|
|
@@ -210,4 +210,4 @@ class Endpoint {
|
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
exports.Endpoint = Endpoint;
|
|
213
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
213
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRW5kcG9pbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJFbmRwb2ludC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7QUFBQSxrQ0FBNkU7QUFFN0Usc0NBQXdEO0FBRXhELGdFQUFvQztBQUVwQyxNQUFhLFFBQVE7SUEwQmpCOzs7Ozs7OztPQVFHO0lBQ0gsWUFDSSxRQUE4QixFQUM5QixHQUFpQixFQUNqQixVQUF1QixFQUN2QixZQUEyQixFQUMzQixhQUE2QixFQUM3QixVQUF1QjtRQThFM0Isb0ZBQW9GO1FBQzVFLFVBQUssR0FBVyxFQUFFLENBQUM7UUFFM0IsNERBQTREO1FBQ3BELGlCQUFZLEdBQUcsSUFBSSxHQUFHLEVBQWUsQ0FBQztRQUN0Qyx5QkF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yxDQUFDO1FBRTFDLElBQUksQ0FBQyxRQUFRO1lBQ1QsTUFBTSxJQUFJLHNCQUFhLENBQUMsNkJBQTZCLEdBQUcseUJBQXlCLElBQUksQ0FBQyxHQUFHLEdBQUcsRUFBRSxxQkFBYyxDQUFDLFFBQVEsQ0FBQyxDQUFDO1FBRTNILE9BQU8sUUFBUSxDQUFDO0lBQ3BCLENBQUM7SUFLRDs7T0FFRztJQUNPLGtCQUFrQixDQUFDLFFBQWtCO1FBQzNDLE1BQU0sTUFBTSxHQUFHLFFBQVEsQ0FBQyxPQUFPLENBQUMsR0FBRyxDQUFDLGlCQUFVLENBQUMsS0FBSyxDQUFDLENBQUM7UUFDdEQsSUFBSSxNQUFNLEVBQUU7WUFDUixJQUFJLENBQUMsY0FBYyxHQUFHLE1BQU0sQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFpQixDQUFDO1NBQzVEO0lBQ0wsQ0FBQztJQUVEOzs7OztPQUtHO0lBQ08sZUFBZSxDQUFDLE1BQWtCO1FBQ3hDLElBQUksSUFBSSxDQUFDLGNBQWMsQ0FBQyxNQUFNLEtBQUssQ0FBQztZQUNoQyxPQUFPLFNBQVMsQ0FBQztRQUVyQixPQUFPLElBQUksQ0FBQyxjQUFjLENBQUMsT0FBTyxDQUFDLE1BQU0sQ0FBQyxLQUFLLENBQUMsQ0FBQyxDQUFDO0lBQ3RELENBQUM7Q0FDSjtBQWhQRCw0QkFnUEMifQ==
|
package/endpoints/Endpoint.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { HttpMethod, HttpHeader, HttpClient } from "../http";
|
|
1
|
+
import { HttpMethod, HttpHeader, HttpStatusCode, HttpClient } from "../http";
|
|
2
2
|
import { Serializer } from "../serializers";
|
|
3
3
|
import { ErrorHandler, NotFoundError } from "../errors";
|
|
4
4
|
import { LinkExtractor, Link } from "../links";
|
|
5
|
-
import
|
|
6
|
-
import "urijs/src/URITemplate";
|
|
5
|
+
import template from 'url-template';
|
|
7
6
|
|
|
8
7
|
export class Endpoint {
|
|
9
8
|
/**
|
|
@@ -105,7 +104,7 @@ export class Endpoint {
|
|
|
105
104
|
* @param signal Used to cancel the request.
|
|
106
105
|
* @param headers The HTTP headers to set.
|
|
107
106
|
* @param body The body to send.
|
|
108
|
-
* @throws {@link HttpError}
|
|
107
|
+
* @throws {@link errors!HttpError}
|
|
109
108
|
*/
|
|
110
109
|
protected async send(method: HttpMethod, signal?: AbortSignal, headers?: HeadersInit, body?: BodyInit): Promise<Response> {
|
|
111
110
|
const response = await this.httpClient.send(this.uri, method, signal, headers, body);
|
|
@@ -116,7 +115,7 @@ export class Endpoint {
|
|
|
116
115
|
/**
|
|
117
116
|
* Handles various cross-cutting concerns regarding a response message such as discovering links and handling errors.
|
|
118
117
|
* @param response The response to process.
|
|
119
|
-
* @throws {@link HttpError}
|
|
118
|
+
* @throws {@link errors!HttpError}
|
|
120
119
|
*/
|
|
121
120
|
protected async handle(response: Response) {
|
|
122
121
|
this.links = await this.linkExtractor.getLinks(response);
|
|
@@ -183,13 +182,13 @@ export class Endpoint {
|
|
|
183
182
|
/**
|
|
184
183
|
* Resolves a single link with a specific relation type. Uses cached data from last response.
|
|
185
184
|
* @param rel The relation type of the link to look for.
|
|
186
|
-
* @throws {@link NotFoundError}: No link with the specified `rel` could be found.
|
|
185
|
+
* @throws {@link errors!NotFoundError}: No link with the specified `rel` could be found.
|
|
187
186
|
*/
|
|
188
187
|
link(rel: string): URL {
|
|
189
188
|
const links = this.getLinks(rel);
|
|
190
189
|
|
|
191
190
|
if (links.length === 0)
|
|
192
|
-
throw new NotFoundError(`No link with rel=${rel} provided by endpoint ${this.uri}.`,
|
|
191
|
+
throw new NotFoundError(`No link with rel=${rel} provided by endpoint ${this.uri}.`, HttpStatusCode.NotFound);
|
|
193
192
|
|
|
194
193
|
return links[0].uri;
|
|
195
194
|
}
|
|
@@ -198,23 +197,24 @@ export class Endpoint {
|
|
|
198
197
|
* Resolves a link template with a specific relation type. Uses cached data from last response.
|
|
199
198
|
* @param rel The relation type of the link template to look for.
|
|
200
199
|
* @param variables Variables for resolving the template.
|
|
201
|
-
* @throws {@link NotFoundError}: No link template with the specified `rel` could be found.
|
|
200
|
+
* @throws {@link errors!NotFoundError}: No link template with the specified `rel` could be found.
|
|
202
201
|
*/
|
|
203
202
|
linkTemplate(rel: string, variables: { [key: string]: any; }): URL {
|
|
204
|
-
|
|
203
|
+
const tmpl = template.parse(this.getLinkTemplate(rel))
|
|
204
|
+
return new URL(this.join(tmpl.expand(variables)))
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
/**
|
|
208
208
|
* Retrieves a link template with a specific relation type. Uses cached data from last response. Prefer {@link linkTemplate} when possible.
|
|
209
209
|
* @param rel The relation type of the link template to look for.
|
|
210
|
-
* @throws {@link NotFoundError}: No link template with the specified `rel` could be found.
|
|
210
|
+
* @throws {@link errors!NotFoundError}: No link template with the specified `rel` could be found.
|
|
211
211
|
*/
|
|
212
212
|
getLinkTemplate(rel: string) {
|
|
213
213
|
const template = this.links.find(x => x.templated && x.rel === rel)?.href
|
|
214
214
|
?? this.defaultLinkTemplates.get(rel);
|
|
215
215
|
|
|
216
216
|
if (!template)
|
|
217
|
-
throw new NotFoundError(`No link template with rel=${rel} provided by endpoint ${this.uri}.`,
|
|
217
|
+
throw new NotFoundError(`No link template with rel=${rel} provided by endpoint ${this.uri}.`, HttpStatusCode.NotFound);
|
|
218
218
|
|
|
219
219
|
return template;
|
|
220
220
|
}
|
|
@@ -22,10 +22,10 @@ class EntryEndpoint extends Endpoint_1.Endpoint {
|
|
|
22
22
|
/**
|
|
23
23
|
* Creates a new entry endpoint.
|
|
24
24
|
* @param uri The base URI of the REST API.<br>Missing trailing slash will be appended automatically.
|
|
25
|
-
* @param serializer Controls the serialization of entities sent to and received from the server.<br>Defaults to {@link JsonSerializer} if undefined.
|
|
26
|
-
* @param errorHandler Handles errors in HTTP responses.<br>Defaults to {@link DefaultErrorHandler} if undefined.
|
|
27
|
-
* @param linkExtractor Detects links in HTTP responses.<br>Defaults to {@link HeaderLinkExtractor} and {@link HalLinkExtractor} combined via {@link AggregateLinkExtractor} if undefined.
|
|
28
|
-
* @param httpClient The HTTP client used to communicate with the REST API.<br>Defaults to {@link FetchHttpClient} if undefined.
|
|
25
|
+
* @param serializer Controls the serialization of entities sent to and received from the server.<br>Defaults to {@link serializers!JsonSerializer} if undefined.
|
|
26
|
+
* @param errorHandler Handles errors in HTTP responses.<br>Defaults to {@link errors!DefaultErrorHandler} if undefined.
|
|
27
|
+
* @param linkExtractor Detects links in HTTP responses.<br>Defaults to {@link links!HeaderLinkExtractor} and {@link links!HalLinkExtractor} combined via {@link links!AggregateLinkExtractor} if undefined.
|
|
28
|
+
* @param httpClient The HTTP client used to communicate with the REST API.<br>Defaults to {@link http!FetchHttpClient} if undefined.
|
|
29
29
|
*/
|
|
30
30
|
constructor(uri, serializer, errorHandler, linkExtractor, httpClient) {
|
|
31
31
|
super(undefined, Endpoint_1.Endpoint.ensureTrailingSlash(uri), serializer !== null && serializer !== void 0 ? serializer : new serializers_1.JsonSerializer(), errorHandler !== null && errorHandler !== void 0 ? errorHandler : new errors_1.DefaultErrorHandler(), linkExtractor !== null && linkExtractor !== void 0 ? linkExtractor : new links_1.AggregateLinkExtractor(new links_1.HeaderLinkExtractor(), new links_1.HalLinkExtractor()), httpClient !== null && httpClient !== void 0 ? httpClient : new http_1.FetchHttpClient());
|
|
@@ -36,10 +36,10 @@ class EntryEndpoint extends Endpoint_1.Endpoint {
|
|
|
36
36
|
/**
|
|
37
37
|
* Fetches meta data such as links from the server.
|
|
38
38
|
* @param signal Used to cancel the request.
|
|
39
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
40
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
41
|
-
* @throws {@link NotFoundError}: {@link HttpStatusCode.NotFound} or {@link HttpStatusCode.Gone}
|
|
42
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
39
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
40
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
41
|
+
* @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
|
|
42
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
43
43
|
*/
|
|
44
44
|
readMeta(signal) {
|
|
45
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -11,10 +11,10 @@ export class EntryEndpoint extends Endpoint {
|
|
|
11
11
|
/**
|
|
12
12
|
* Creates a new entry endpoint.
|
|
13
13
|
* @param uri The base URI of the REST API.<br>Missing trailing slash will be appended automatically.
|
|
14
|
-
* @param serializer Controls the serialization of entities sent to and received from the server.<br>Defaults to {@link JsonSerializer} if undefined.
|
|
15
|
-
* @param errorHandler Handles errors in HTTP responses.<br>Defaults to {@link DefaultErrorHandler} if undefined.
|
|
16
|
-
* @param linkExtractor Detects links in HTTP responses.<br>Defaults to {@link HeaderLinkExtractor} and {@link HalLinkExtractor} combined via {@link AggregateLinkExtractor} if undefined.
|
|
17
|
-
* @param httpClient The HTTP client used to communicate with the REST API.<br>Defaults to {@link FetchHttpClient} if undefined.
|
|
14
|
+
* @param serializer Controls the serialization of entities sent to and received from the server.<br>Defaults to {@link serializers!JsonSerializer} if undefined.
|
|
15
|
+
* @param errorHandler Handles errors in HTTP responses.<br>Defaults to {@link errors!DefaultErrorHandler} if undefined.
|
|
16
|
+
* @param linkExtractor Detects links in HTTP responses.<br>Defaults to {@link links!HeaderLinkExtractor} and {@link links!HalLinkExtractor} combined via {@link links!AggregateLinkExtractor} if undefined.
|
|
17
|
+
* @param httpClient The HTTP client used to communicate with the REST API.<br>Defaults to {@link http!FetchHttpClient} if undefined.
|
|
18
18
|
*/
|
|
19
19
|
constructor(
|
|
20
20
|
uri: URL | string,
|
|
@@ -37,10 +37,10 @@ export class EntryEndpoint extends Endpoint {
|
|
|
37
37
|
/**
|
|
38
38
|
* Fetches meta data such as links from the server.
|
|
39
39
|
* @param signal Used to cancel the request.
|
|
40
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
41
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
42
|
-
* @throws {@link NotFoundError}: {@link HttpStatusCode.NotFound} or {@link HttpStatusCode.Gone}
|
|
43
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
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
|
|
44
44
|
*/
|
|
45
45
|
async readMeta(signal?: AbortSignal) {
|
|
46
46
|
await this.send(HttpMethod.Get, signal);
|
|
@@ -25,13 +25,13 @@ class ETagEndpointBase extends Endpoint_1.Endpoint {
|
|
|
25
25
|
super(referrer, relativeUri);
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
-
* Performs an {@link HttpMethod.Put} request on the {@link uri} and caches the response if the server sends an {@link HttpHeader.ETag}.
|
|
28
|
+
* Performs an {@link http!HttpMethod.Put} request on the {@link uri} and caches the response if the server sends an {@link http!HttpHeader.ETag}.
|
|
29
29
|
* @param signal Used to cancel the request.
|
|
30
|
-
* @throws {@link BadRequestError}: {@link HttpStatusCode.BadRequest}
|
|
31
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
32
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
33
|
-
* @throws {@link NotFoundError}: {@link HttpStatusCode.NotFound} or {@link HttpStatusCode.Gone}
|
|
34
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
30
|
+
* @throws {@link errors!BadRequestError}: {@link http!HttpStatusCode.BadRequest}
|
|
31
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
32
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
33
|
+
* @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
|
|
34
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
35
35
|
*/
|
|
36
36
|
getContent(signal) {
|
|
37
37
|
var _a, _b;
|
|
@@ -48,14 +48,14 @@ class ETagEndpointBase extends Endpoint_1.Endpoint {
|
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
|
-
* Performs an {@link HttpMethod.Put} request on the {@link uri}. Sets {@link HttpHeader.IfMatch} if there is a cached {@link HttpHeader.ETag} to detect lost updates.
|
|
51
|
+
* Performs an {@link http!HttpMethod.Put} request on the {@link uri}. Sets {@link http!HttpHeader.IfMatch} if there is a cached {@link http!HttpHeader.ETag} to detect lost updates.
|
|
52
52
|
* @param signal Used to cancel the request.
|
|
53
|
-
* @throws {@link ConcurrencyError}: The entity has changed since it was last retrieved with {@link getContent}. Your changes were rejected to prevent a lost update.
|
|
54
|
-
* @throws {@link BadRequestError}: {@link HttpStatusCode.BadRequest}
|
|
55
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
56
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
57
|
-
* @throws {@link NotFoundError}: {@link HttpStatusCode.NotFound} or {@link HttpStatusCode.Gone}
|
|
58
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
53
|
+
* @throws {@link errors!ConcurrencyError}: The entity has changed since it was last retrieved with {@link getContent}. Your changes were rejected to prevent a lost update.
|
|
54
|
+
* @throws {@link errors!BadRequestError}: {@link http!HttpStatusCode.BadRequest}
|
|
55
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
56
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
57
|
+
* @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
|
|
58
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
59
59
|
*/
|
|
60
60
|
putContent(content, signal) {
|
|
61
61
|
var _a;
|
|
@@ -69,14 +69,14 @@ class ETagEndpointBase extends Endpoint_1.Endpoint {
|
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
|
-
* Performs an {@link HttpMethod.Delete} request on the {@link uri}. Sets {@link HttpHeader.IfMatch} if there is a cached {@link HttpHeader.ETag} to detect lost updates.
|
|
72
|
+
* Performs an {@link http!HttpMethod.Delete} request on the {@link uri}. Sets {@link http!HttpHeader.IfMatch} if there is a cached {@link http!HttpHeader.ETag} to detect lost updates.
|
|
73
73
|
* @param signal Used to cancel the request.
|
|
74
|
-
* @throws {@link ConcurrencyError}: The entity has changed since it was last retrieved with {@link getContent}. Your changes were rejected to prevent a lost update.
|
|
75
|
-
* @throws {@link BadRequestError}: {@link HttpStatusCode.BadRequest}
|
|
76
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
77
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
78
|
-
* @throws {@link NotFoundError}: {@link HttpStatusCode.NotFound} or {@link HttpStatusCode.Gone}
|
|
79
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
74
|
+
* @throws {@link errors!ConcurrencyError}: The entity has changed since it was last retrieved with {@link getContent}. Your changes were rejected to prevent a lost update.
|
|
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!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
|
|
79
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
80
80
|
*/
|
|
81
81
|
deleteContent(signal) {
|
|
82
82
|
var _a;
|
|
@@ -16,18 +16,18 @@ export class ETagEndpointBase extends Endpoint implements CachingEndpoint {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* @
|
|
19
|
+
* @inheritDoc
|
|
20
20
|
*/
|
|
21
21
|
public responseCache?: ResponseCache;
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
* Performs an {@link HttpMethod.Put} request on the {@link uri} and caches the response if the server sends an {@link HttpHeader.ETag}.
|
|
24
|
+
* Performs an {@link http!HttpMethod.Put} request on the {@link uri} and caches the response if the server sends an {@link http!HttpHeader.ETag}.
|
|
25
25
|
* @param signal Used to cancel the request.
|
|
26
|
-
* @throws {@link BadRequestError}: {@link HttpStatusCode.BadRequest}
|
|
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
|
|
26
|
+
* @throws {@link errors!BadRequestError}: {@link http!HttpStatusCode.BadRequest}
|
|
27
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
28
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
29
|
+
* @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
|
|
30
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
31
31
|
*/
|
|
32
32
|
protected async getContent(signal?: AbortSignal): Promise<string> {
|
|
33
33
|
const headers = new Headers();
|
|
@@ -43,14 +43,14 @@ export class ETagEndpointBase extends Endpoint implements CachingEndpoint {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
|
-
* Performs an {@link HttpMethod.Put} request on the {@link uri}. Sets {@link HttpHeader.IfMatch} if there is a cached {@link HttpHeader.ETag} to detect lost updates.
|
|
46
|
+
* Performs an {@link http!HttpMethod.Put} request on the {@link uri}. Sets {@link http!HttpHeader.IfMatch} if there is a cached {@link http!HttpHeader.ETag} to detect lost updates.
|
|
47
47
|
* @param signal Used to cancel the request.
|
|
48
|
-
* @throws {@link ConcurrencyError}: The entity has changed since it was last retrieved with {@link getContent}. Your changes were rejected to prevent a lost update.
|
|
49
|
-
* @throws {@link BadRequestError}: {@link HttpStatusCode.BadRequest}
|
|
50
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
51
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
52
|
-
* @throws {@link NotFoundError}: {@link HttpStatusCode.NotFound} or {@link HttpStatusCode.Gone}
|
|
53
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
48
|
+
* @throws {@link errors!ConcurrencyError}: The entity has changed since it was last retrieved with {@link getContent}. Your changes were rejected to prevent a lost update.
|
|
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
|
|
54
54
|
*/
|
|
55
55
|
protected async putContent(content: any, signal?: AbortSignal): Promise<Response> {
|
|
56
56
|
const headers = new Headers();
|
|
@@ -62,14 +62,14 @@ export class ETagEndpointBase extends Endpoint implements CachingEndpoint {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
|
-
* Performs an {@link HttpMethod.Delete} request on the {@link uri}. Sets {@link HttpHeader.IfMatch} if there is a cached {@link HttpHeader.ETag} to detect lost updates.
|
|
65
|
+
* Performs an {@link http!HttpMethod.Delete} request on the {@link uri}. Sets {@link http!HttpHeader.IfMatch} if there is a cached {@link http!HttpHeader.ETag} to detect lost updates.
|
|
66
66
|
* @param signal Used to cancel the request.
|
|
67
|
-
* @throws {@link ConcurrencyError}: The entity has changed since it was last retrieved with {@link getContent}. Your changes were rejected to prevent a lost update.
|
|
68
|
-
* @throws {@link BadRequestError}: {@link HttpStatusCode.BadRequest}
|
|
69
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
70
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
71
|
-
* @throws {@link NotFoundError}: {@link HttpStatusCode.NotFound} or {@link HttpStatusCode.Gone}
|
|
72
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
67
|
+
* @throws {@link errors!ConcurrencyError}: The entity has changed since it was last retrieved with {@link getContent}. Your changes were rejected to prevent a lost update.
|
|
68
|
+
* @throws {@link errors!BadRequestError}: {@link http!HttpStatusCode.BadRequest}
|
|
69
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
70
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
71
|
+
* @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
|
|
72
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
73
73
|
*/
|
|
74
74
|
protected async deleteContent(signal?: AbortSignal): Promise<Response> {
|
|
75
75
|
const headers = new Headers();
|
|
@@ -37,10 +37,10 @@ class ElementEndpoint extends ETagEndpointBase_1.ETagEndpointBase {
|
|
|
37
37
|
/**
|
|
38
38
|
* Returns the `TEntity`.
|
|
39
39
|
* @param signal Used to cancel the request.
|
|
40
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
41
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
42
|
-
* @throws {@link NotFoundError}: {@link HttpStatusCode.NotFound} or {@link HttpStatusCode.Gone}
|
|
43
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
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
|
|
44
44
|
*/
|
|
45
45
|
read(signal) {
|
|
46
46
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -50,9 +50,9 @@ class ElementEndpoint extends ETagEndpointBase_1.ETagEndpointBase {
|
|
|
50
50
|
/**
|
|
51
51
|
* Determines whether the element currently exists.
|
|
52
52
|
* @param signal Used to cancel the request.
|
|
53
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
54
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
55
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
53
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
54
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
55
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
56
56
|
*/
|
|
57
57
|
exists(signal) {
|
|
58
58
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -76,12 +76,12 @@ class ElementEndpoint extends ETagEndpointBase_1.ETagEndpointBase {
|
|
|
76
76
|
* @param entity The new `TEntity`.
|
|
77
77
|
* @param signal Used to cancel the request.
|
|
78
78
|
* @returns The `TEntity` as returned by the server, possibly with additional fields set. undefined if the server does not respond with a result entity.
|
|
79
|
-
* @throws {@link ConcurrencyError}: The entity has changed since it was last retrieved with {@link read}. Your changes were rejected to prevent a lost update.
|
|
80
|
-
* @throws {@link BadRequestError}: {@link HttpStatusCode.BadRequest}
|
|
81
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
82
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
83
|
-
* @throws {@link NotFoundError}: {@link HttpStatusCode.NotFound} or {@link HttpStatusCode.Gone}
|
|
84
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
79
|
+
* @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.
|
|
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
|
|
85
85
|
*/
|
|
86
86
|
set(entity, signal) {
|
|
87
87
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -103,12 +103,12 @@ class ElementEndpoint extends ETagEndpointBase_1.ETagEndpointBase {
|
|
|
103
103
|
* @param entity The `TEntity` data to merge with the existing element.
|
|
104
104
|
* @param signal Used to cancel the request.
|
|
105
105
|
* @returns The `TEntity` as returned by the server, possibly with additional fields set. undefined if the server does not respond with a result entity.
|
|
106
|
-
* @throws {@link ConcurrencyError}: The entity has changed since it was last retrieved with {@link read}. Your changes were rejected to prevent a lost update.
|
|
107
|
-
* @throws {@link BadRequestError}: {@link HttpStatusCode.BadRequest}
|
|
108
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
109
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
110
|
-
* @throws {@link NotFoundError}: {@link HttpStatusCode.NotFound} or {@link HttpStatusCode.Gone}
|
|
111
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
106
|
+
* @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.
|
|
107
|
+
* @throws {@link errors!BadRequestError}: {@link http!HttpStatusCode.BadRequest}
|
|
108
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
109
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
110
|
+
* @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
|
|
111
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
112
112
|
*/
|
|
113
113
|
merge(entity, signal) {
|
|
114
114
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -128,12 +128,12 @@ class ElementEndpoint extends ETagEndpointBase_1.ETagEndpointBase {
|
|
|
128
128
|
* @param maxRetries The maximum number of retries to perform for optimistic concurrency before giving up.
|
|
129
129
|
* @param signal Used to cancel the request.
|
|
130
130
|
* @returns The `TEntity` as returned by the server, possibly with additional fields set. undefined if the server does not respond with a result entity.
|
|
131
|
-
* @throws {@link ConcurrencyError}: The maximum number of retries to perform for optimistic concurrency before giving up.
|
|
132
|
-
* @throws {@link BadRequestError}: {@link HttpStatusCode.BadRequest}
|
|
133
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
134
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
135
|
-
* @throws {@link NotFoundError}: {@link HttpStatusCode.NotFound} or {@link HttpStatusCode.Gone}
|
|
136
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
131
|
+
* @throws {@link errors!ConcurrencyError}: The maximum number of retries to perform for optimistic concurrency before giving up.
|
|
132
|
+
* @throws {@link errors!BadRequestError}: {@link http!HttpStatusCode.BadRequest}
|
|
133
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
134
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
135
|
+
* @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
|
|
136
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
137
137
|
*/
|
|
138
138
|
update(updateAction, maxRetries = 3, signal) {
|
|
139
139
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -160,11 +160,11 @@ class ElementEndpoint extends ETagEndpointBase_1.ETagEndpointBase {
|
|
|
160
160
|
/**
|
|
161
161
|
* Deletes the element.
|
|
162
162
|
* @param signal Used to cancel the request.
|
|
163
|
-
* @throws {@link ConcurrencyError}: The entity has changed since it was last retrieved with {@link read}. Your changes were rejected to prevent a lost update.
|
|
164
|
-
* @throws {@link AuthenticationError}: {@link HttpStatusCode.Unauthorized}
|
|
165
|
-
* @throws {@link AuthorizationError}: {@link HttpStatusCode.Forbidden}
|
|
166
|
-
* @throws {@link NotFoundError}: {@link HttpStatusCode.NotFound} or {@link HttpStatusCode.Gone}
|
|
167
|
-
* @throws {@link HttpError}: Other non-success status code
|
|
163
|
+
* @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.
|
|
164
|
+
* @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
|
|
165
|
+
* @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
|
|
166
|
+
* @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
|
|
167
|
+
* @throws {@link errors!HttpError}: Other non-success status code
|
|
168
168
|
*/
|
|
169
169
|
delete(signal) {
|
|
170
170
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -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);
|