typedrest 0.4.1 → 0.6.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.
Files changed (110) hide show
  1. package/README.md +42 -4
  2. package/endpoints/{CachingEndpoint.ts → CachingEndpoint.d.ts} +0 -1
  3. package/endpoints/Endpoint.d.ts +121 -0
  4. package/endpoints/Endpoint.js +9 -22
  5. package/endpoints/{EntryEndpoint.ts → EntryEndpoint.d.ts} +7 -27
  6. package/endpoints/EntryEndpoint.js +3 -14
  7. package/endpoints/generic/{CollectionEndpoint.ts → CollectionEndpoint.d.ts} +2 -5
  8. package/endpoints/generic/{ETagEndpointBase.ts → ETagEndpointBase.d.ts} +7 -38
  9. package/endpoints/generic/ETagEndpointBase.js +27 -42
  10. package/endpoints/generic/{ElementEndpoint.ts → ElementEndpoint.d.ts} +12 -70
  11. package/endpoints/generic/ElementEndpoint.js +39 -60
  12. package/endpoints/generic/{GenericCollectionEndpoint.ts → GenericCollectionEndpoint.d.ts} +43 -75
  13. package/endpoints/generic/GenericCollectionEndpoint.js +70 -44
  14. package/endpoints/generic/{IndexerEndpoint.ts → IndexerEndpoint.d.ts} +4 -11
  15. package/endpoints/generic/PartialResponse.d.ts +19 -0
  16. package/endpoints/generic/PartialResponse.js +33 -0
  17. package/endpoints/generic/{index.ts → index.d.ts} +1 -0
  18. package/endpoints/generic/index.js +2 -1
  19. package/endpoints/{index.ts → index.d.ts} +2 -2
  20. package/endpoints/index.js +3 -2
  21. package/endpoints/raw/{BlobEndpoint.ts → BlobEndpoint.d.ts} +9 -29
  22. package/endpoints/raw/BlobEndpoint.js +10 -27
  23. package/endpoints/raw/{UploadEndpoint.ts → UploadEndpoint.d.ts} +4 -18
  24. package/endpoints/raw/UploadEndpoint.js +11 -22
  25. package/endpoints/reactive/Delay.d.ts +7 -0
  26. package/endpoints/reactive/Delay.js +27 -0
  27. package/endpoints/reactive/GenericStreamingCollectionEndpoint.d.ts +32 -0
  28. package/endpoints/reactive/GenericStreamingCollectionEndpoint.js +79 -0
  29. package/endpoints/reactive/PollingEndpoint.d.ts +39 -0
  30. package/endpoints/reactive/PollingEndpoint.js +67 -0
  31. package/endpoints/reactive/SseStreamingEndpoint.d.ts +50 -0
  32. package/endpoints/reactive/SseStreamingEndpoint.js +120 -0
  33. package/endpoints/reactive/StreamingCollectionEndpoint.d.ts +17 -0
  34. package/endpoints/reactive/StreamingCollectionEndpoint.js +23 -0
  35. package/endpoints/reactive/StreamingEndpoint.d.ts +28 -0
  36. package/endpoints/reactive/StreamingEndpoint.js +56 -0
  37. package/endpoints/reactive/index.d.ts +5 -0
  38. package/endpoints/reactive/index.js +22 -0
  39. package/endpoints/rpc/{ActionEndpoint.ts → ActionEndpoint.d.ts} +3 -10
  40. package/endpoints/rpc/ActionEndpoint.js +3 -14
  41. package/endpoints/rpc/{ConsumerEndpoint.ts → ConsumerEndpoint.d.ts} +3 -12
  42. package/endpoints/rpc/ConsumerEndpoint.js +5 -16
  43. package/endpoints/rpc/{FunctionEndpoint.ts → FunctionEndpoint.d.ts} +3 -14
  44. package/endpoints/rpc/FunctionEndpoint.js +6 -17
  45. package/endpoints/rpc/{ProducerEndpoint.ts → ProducerEndpoint.d.ts} +3 -11
  46. package/endpoints/rpc/ProducerEndpoint.js +4 -15
  47. package/endpoints/rpc/{RpcEndpointBase.ts → RpcEndpointBase.d.ts} +4 -12
  48. package/endpoints/rpc/RpcEndpointBase.js +3 -14
  49. package/errors/DefaultErrorHandler.d.ts +21 -0
  50. package/errors/DefaultErrorHandler.js +19 -27
  51. package/errors/{Errors.ts → Errors.d.ts} +23 -19
  52. package/errors/Errors.js +8 -2
  53. package/http/EntityStream.d.ts +10 -0
  54. package/http/EntityStream.js +42 -0
  55. package/http/FetchHttpClient.d.ts +15 -0
  56. package/http/FetchHttpClient.js +1 -1
  57. package/http/{HttpClient.ts → HttpClient.d.ts} +1 -3
  58. package/http/HttpContentRange.d.ts +23 -0
  59. package/http/HttpContentRange.js +39 -0
  60. package/http/HttpHeader.d.ts +16 -0
  61. package/http/HttpHeader.js +6 -1
  62. package/http/{HttpMethod.ts → HttpMethod.d.ts} +1 -1
  63. package/http/{HttpStatusCode.ts → HttpStatusCode.d.ts} +5 -2
  64. package/http/HttpStatusCode.js +4 -1
  65. package/http/ResponseCache.d.ts +19 -0
  66. package/http/ResponseCache.js +4 -15
  67. package/http/RetryAfter.d.ts +6 -0
  68. package/http/RetryAfter.js +24 -0
  69. package/http/ServerSentEvents.d.ts +50 -0
  70. package/http/ServerSentEvents.js +140 -0
  71. package/http/{index.ts → index.d.ts} +4 -0
  72. package/http/index.js +5 -1
  73. package/links/AggregateLinkExtractor.d.ts +17 -0
  74. package/links/AggregateLinkExtractor.js +7 -18
  75. package/links/HalLinkExtractor.d.ts +13 -0
  76. package/links/HalLinkExtractor.js +9 -20
  77. package/links/HeaderLinkExtractor.d.ts +13 -0
  78. package/links/HeaderLinkExtractor.js +4 -15
  79. package/links/{Link.ts → Link.d.ts} +6 -2
  80. package/links/{LinkExtractor.ts → LinkExtractor.d.ts} +0 -1
  81. package/package.json +66 -16
  82. package/serializers/JsonSerializer.d.ts +18 -0
  83. package/serializers/{Serializer.ts → Serializer.d.ts} +0 -2
  84. package/endpoints/Endpoint.test.ts +0 -300
  85. package/endpoints/Endpoint.ts +0 -247
  86. package/endpoints/generic/CollectionEndpoint.test.ts +0 -215
  87. package/endpoints/generic/ElementEndpoint.test.ts +0 -262
  88. package/endpoints/generic/IndexerEndpoint.test.ts +0 -12
  89. package/endpoints/raw/BlobEndpoint.test.ts +0 -52
  90. package/endpoints/raw/UploadEndpoint.test.ts +0 -47
  91. package/endpoints/rpc/ActionEndpoint.test.ts +0 -36
  92. package/endpoints/rpc/ConsumerEndpoint.test.ts +0 -29
  93. package/endpoints/rpc/FunctionEndpoint.test.ts +0 -29
  94. package/endpoints/rpc/ProducerEndpoint.test.ts +0 -32
  95. package/errors/DefaultErrorHandler.ts +0 -62
  96. package/http/FetchHttpClient.ts +0 -26
  97. package/http/HttpHeader.ts +0 -11
  98. package/http/ResponseCache.ts +0 -25
  99. package/jest.config.js +0 -12
  100. package/links/AggregateLinkExtractor.ts +0 -28
  101. package/links/HalLinkExtractor.ts +0 -45
  102. package/links/HeaderLinkExtractor.ts +0 -56
  103. package/serializers/JsonSerializer.ts +0 -25
  104. /package/endpoints/raw/{index.ts → index.d.ts} +0 -0
  105. /package/endpoints/rpc/{index.ts → index.d.ts} +0 -0
  106. /package/errors/{ErrorHandler.ts → ErrorHandler.d.ts} +0 -0
  107. /package/errors/{index.ts → index.d.ts} +0 -0
  108. /package/{index.ts → index.d.ts} +0 -0
  109. /package/links/{index.ts → index.d.ts} +0 -0
  110. /package/serializers/{index.ts → index.d.ts} +0 -0
@@ -1,31 +1,20 @@
1
1
  import { ETagEndpointBase } from "./ETagEndpointBase";
2
2
  import { Endpoint } from "../Endpoint";
3
- import { HttpMethod, HttpHeader, HttpStatusCode } from "../../http";
4
- import { ConcurrencyError } from "../../errors";
5
-
6
3
  /**
7
4
  * Endpoint for an individual resource.
8
5
  * @typeParam TEntity The type of entity the endpoint represents.
9
6
  */
10
- export class ElementEndpoint<TEntity> extends ETagEndpointBase {
7
+ export declare class ElementEndpoint<TEntity> extends ETagEndpointBase {
11
8
  /**
12
9
  * Creates a new element endpoint.
13
10
  * @param referrer The endpoint used to navigate to this one.
14
11
  * @param relativeUri The URI of this endpoint relative to the `referrer`'s. Add a `./` prefix here to imply a trailing slash in the `referrer`'s URI.
15
12
  */
16
- constructor(referrer: Endpoint, relativeUri: URL | string) {
17
- super(referrer, relativeUri);
18
- }
19
-
13
+ constructor(referrer: Endpoint, relativeUri: URL | string);
20
14
  /**
21
15
  * A cached copy of the entity as received from the server.
22
16
  */
23
- public get response(): TEntity | undefined {
24
- return this.responseCache
25
- ? this.serializer.deserialize<TEntity>(this.responseCache.content)
26
- : undefined;
27
- }
28
-
17
+ get response(): TEntity | undefined;
29
18
  /**
30
19
  * Returns the `TEntity`.
31
20
  * @param signal Used to cancel the request.
@@ -34,10 +23,7 @@ export class ElementEndpoint<TEntity> extends ETagEndpointBase {
34
23
  * @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
35
24
  * @throws {@link errors!HttpError}: Other non-success status code
36
25
  */
37
- async read(signal?: AbortSignal) {
38
- return this.serializer.deserialize<TEntity>(await this.getContent(signal));
39
- }
40
-
26
+ read(signal?: AbortSignal): Promise<TEntity>;
41
27
  /**
42
28
  * Determines whether the element currently exists.
43
29
  * @param signal Used to cancel the request.
@@ -45,22 +31,13 @@ export class ElementEndpoint<TEntity> extends ETagEndpointBase {
45
31
  * @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
46
32
  * @throws {@link errors!HttpError}: Other non-success status code
47
33
  */
48
- async exists(signal?: AbortSignal) {
49
- const response = await this.httpClient.send(this.uri, HttpMethod.Head, signal);
50
- if (response.ok) return true;
51
- if (response.status === HttpStatusCode.NotFound || response.status === HttpStatusCode.Gone) return false;
52
-
53
- await this.errorHandler.handle(response);
54
- return false;
55
- }
56
-
34
+ exists(signal?: AbortSignal): Promise<boolean>;
57
35
  /**
58
36
  * Shows whether the server has indicated that {@link set} is currently allowed.
59
37
  * Uses cached data from last response.
60
38
  * @returns `true` if the method is allowed, `false` if the method is not allowed, `undefined` if no request has been sent yet or the server did not specify allowed methods.
61
39
  */
62
- get setAllowed() { return this.isMethodAllowed(HttpMethod.Put); }
63
-
40
+ get setAllowed(): boolean | undefined;
64
41
  /**
65
42
  * Sets/replaces the `TEntity`.
66
43
  * @param entity The new `TEntity`.
@@ -73,21 +50,13 @@ export class ElementEndpoint<TEntity> extends ETagEndpointBase {
73
50
  * @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
74
51
  * @throws {@link errors!HttpError}: Other non-success status code
75
52
  */
76
- async set(entity: TEntity, signal?: AbortSignal): Promise<(TEntity | undefined)> {
77
- const response = await this.putContent(entity, signal);
78
- const text = await response.text();
79
- if (text) {
80
- return this.serializer.deserialize<TEntity>(text);
81
- }
82
- }
83
-
53
+ set(entity: TEntity, signal?: AbortSignal): Promise<(TEntity | undefined)>;
84
54
  /**
85
55
  * Shows whether the server has indicated that {@link merge} is currently allowed.
86
56
  * Uses cached data from last response.
87
57
  * @returns `true` if the method is allowed, `false` if the method is not allowed, `undefined` if no request has been sent yet or the server did not specify allowed methods.
88
58
  */
89
- get mergeAllowed() { return this.isMethodAllowed(HttpMethod.Patch); }
90
-
59
+ get mergeAllowed(): boolean | undefined;
91
60
  /**
92
61
  * Modifies an existing `TEntity` by merging changes on the server-side.
93
62
  * @param entity The `TEntity` data to merge with the existing element.
@@ -100,18 +69,7 @@ export class ElementEndpoint<TEntity> extends ETagEndpointBase {
100
69
  * @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
101
70
  * @throws {@link errors!HttpError}: Other non-success status code
102
71
  */
103
- async merge(entity: TEntity, signal?: AbortSignal): Promise<(TEntity | undefined)> {
104
- this.responseCache = undefined;
105
- const response = await this.send(HttpMethod.Patch, signal, {
106
- [HttpHeader.ContentType]: this.serializer.supportedMediaTypes[0]
107
- }, this.serializer.serialize(entity));
108
-
109
- const text = await response.text();
110
- if (text) {
111
- return this.serializer.deserialize<TEntity>(text);
112
- }
113
- }
114
-
72
+ merge(entity: TEntity, signal?: AbortSignal): Promise<(TEntity | undefined)>;
115
73
  /**
116
74
  * Reads the current state of the entity, applies a change to it and stores the result. Applies optimistic concurrency using automatic retries.
117
75
  * @param updateAction A callback that takes the current state of the entity and applies the desired modifications.
@@ -125,27 +83,13 @@ export class ElementEndpoint<TEntity> extends ETagEndpointBase {
125
83
  * @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
126
84
  * @throws {@link errors!HttpError}: Other non-success status code
127
85
  */
128
- async update(updateAction: (entity: TEntity) => void, maxRetries: number = 3, signal?: AbortSignal): Promise<(TEntity | undefined)> {
129
- let retryCounter = 0;
130
- while (true) {
131
- const entity = await this.read(signal);
132
- updateAction(entity);
133
- try {
134
- return await this.set(entity, signal);
135
- } catch (err) {
136
- if (retryCounter++ >= maxRetries || !(err instanceof ConcurrencyError))
137
- throw err;
138
- }
139
- }
140
- }
141
-
86
+ update(updateAction: (entity: TEntity) => void, maxRetries?: number, signal?: AbortSignal): Promise<(TEntity | undefined)>;
142
87
  /**
143
88
  * Shows whether the server has indicated that {@link delete} is currently allowed.
144
89
  * Uses cached data from last response.
145
90
  * @returns `true` if the method is allowed, `false` if the method is not allowed, `undefined` if no request has been sent yet or the server did not specify allowed methods.
146
91
  */
147
- get deleteAllowed() { return this.isMethodAllowed(HttpMethod.Delete); }
148
-
92
+ get deleteAllowed(): boolean | undefined;
149
93
  /**
150
94
  * Deletes the element.
151
95
  * @param signal Used to cancel the request.
@@ -155,7 +99,5 @@ export class ElementEndpoint<TEntity> extends ETagEndpointBase {
155
99
  * @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
156
100
  * @throws {@link errors!HttpError}: Other non-success status code
157
101
  */
158
- async delete(signal?: AbortSignal) {
159
- await this.deleteContent(signal);
160
- }
102
+ delete(signal?: AbortSignal): Promise<void>;
161
103
  }
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.ElementEndpoint = void 0;
13
4
  const ETagEndpointBase_1 = require("./ETagEndpointBase");
@@ -42,10 +33,8 @@ class ElementEndpoint extends ETagEndpointBase_1.ETagEndpointBase {
42
33
  * @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
43
34
  * @throws {@link errors!HttpError}: Other non-success status code
44
35
  */
45
- read(signal) {
46
- return __awaiter(this, void 0, void 0, function* () {
47
- return this.serializer.deserialize(yield this.getContent(signal));
48
- });
36
+ async read(signal) {
37
+ return this.serializer.deserialize(await this.getContent(signal));
49
38
  }
50
39
  /**
51
40
  * Determines whether the element currently exists.
@@ -54,16 +43,14 @@ class ElementEndpoint extends ETagEndpointBase_1.ETagEndpointBase {
54
43
  * @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
55
44
  * @throws {@link errors!HttpError}: Other non-success status code
56
45
  */
57
- exists(signal) {
58
- return __awaiter(this, void 0, void 0, function* () {
59
- const response = yield this.httpClient.send(this.uri, http_1.HttpMethod.Head, signal);
60
- if (response.ok)
61
- return true;
62
- if (response.status === http_1.HttpStatusCode.NotFound || response.status === http_1.HttpStatusCode.Gone)
63
- return false;
64
- yield this.errorHandler.handle(response);
46
+ async exists(signal) {
47
+ const response = await this.httpClient.send(this.uri, http_1.HttpMethod.Head, signal);
48
+ if (response.ok)
49
+ return true;
50
+ if (response.status === http_1.HttpStatusCode.NotFound || response.status === http_1.HttpStatusCode.Gone)
65
51
  return false;
66
- });
52
+ await this.errorHandler.handle(response);
53
+ return false;
67
54
  }
68
55
  /**
69
56
  * Shows whether the server has indicated that {@link set} is currently allowed.
@@ -83,14 +70,12 @@ class ElementEndpoint extends ETagEndpointBase_1.ETagEndpointBase {
83
70
  * @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
84
71
  * @throws {@link errors!HttpError}: Other non-success status code
85
72
  */
86
- set(entity, signal) {
87
- return __awaiter(this, void 0, void 0, function* () {
88
- const response = yield this.putContent(entity, signal);
89
- const text = yield response.text();
90
- if (text) {
91
- return this.serializer.deserialize(text);
92
- }
93
- });
73
+ async set(entity, signal) {
74
+ const response = await this.putContent(entity, signal);
75
+ const text = await response.text();
76
+ if (text) {
77
+ return this.serializer.deserialize(text);
78
+ }
94
79
  }
95
80
  /**
96
81
  * Shows whether the server has indicated that {@link merge} is currently allowed.
@@ -110,17 +95,15 @@ class ElementEndpoint extends ETagEndpointBase_1.ETagEndpointBase {
110
95
  * @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
111
96
  * @throws {@link errors!HttpError}: Other non-success status code
112
97
  */
113
- merge(entity, signal) {
114
- return __awaiter(this, void 0, void 0, function* () {
115
- this.responseCache = undefined;
116
- const response = yield this.send(http_1.HttpMethod.Patch, signal, {
117
- [http_1.HttpHeader.ContentType]: this.serializer.supportedMediaTypes[0]
118
- }, this.serializer.serialize(entity));
119
- const text = yield response.text();
120
- if (text) {
121
- return this.serializer.deserialize(text);
122
- }
123
- });
98
+ async merge(entity, signal) {
99
+ this.responseCache = undefined;
100
+ const response = await this.send(http_1.HttpMethod.Patch, signal, {
101
+ [http_1.HttpHeader.ContentType]: this.serializer.supportedMediaTypes[0]
102
+ }, this.serializer.serialize(entity));
103
+ const text = await response.text();
104
+ if (text) {
105
+ return this.serializer.deserialize(text);
106
+ }
124
107
  }
125
108
  /**
126
109
  * Reads the current state of the entity, applies a change to it and stores the result. Applies optimistic concurrency using automatic retries.
@@ -135,21 +118,19 @@ class ElementEndpoint extends ETagEndpointBase_1.ETagEndpointBase {
135
118
  * @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
136
119
  * @throws {@link errors!HttpError}: Other non-success status code
137
120
  */
138
- update(updateAction_1) {
139
- return __awaiter(this, arguments, void 0, function* (updateAction, maxRetries = 3, signal) {
140
- let retryCounter = 0;
141
- while (true) {
142
- const entity = yield this.read(signal);
143
- updateAction(entity);
144
- try {
145
- return yield this.set(entity, signal);
146
- }
147
- catch (err) {
148
- if (retryCounter++ >= maxRetries || !(err instanceof errors_1.ConcurrencyError))
149
- throw err;
150
- }
121
+ async update(updateAction, maxRetries = 3, signal) {
122
+ let retryCounter = 0;
123
+ while (true) {
124
+ const entity = await this.read(signal);
125
+ updateAction(entity);
126
+ try {
127
+ return await this.set(entity, signal);
128
+ }
129
+ catch (err) {
130
+ if (retryCounter++ >= maxRetries || !(err instanceof errors_1.ConcurrencyError))
131
+ throw err;
151
132
  }
152
- });
133
+ }
153
134
  }
154
135
  /**
155
136
  * Shows whether the server has indicated that {@link delete} is currently allowed.
@@ -166,11 +147,9 @@ class ElementEndpoint extends ETagEndpointBase_1.ETagEndpointBase {
166
147
  * @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
167
148
  * @throws {@link errors!HttpError}: Other non-success status code
168
149
  */
169
- delete(signal) {
170
- return __awaiter(this, void 0, void 0, function* () {
171
- yield this.deleteContent(signal);
172
- });
150
+ async delete(signal) {
151
+ await this.deleteContent(signal);
173
152
  }
174
153
  }
175
154
  exports.ElementEndpoint = ElementEndpoint;
176
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRWxlbWVudEVuZHBvaW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiRWxlbWVudEVuZHBvaW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7OztBQUFBLHlEQUFzRDtBQUV0RCxxQ0FBb0U7QUFDcEUseUNBQWdEO0FBRWhEOzs7R0FHRztBQUNILE1BQWEsZUFBeUIsU0FBUSxtQ0FBZ0I7SUFDMUQ7Ozs7T0FJRztJQUNILFlBQVksUUFBa0IsRUFBRSxXQUF5QjtRQUNyRCxLQUFLLENBQUMsUUFBUSxFQUFFLFdBQVcsQ0FBQyxDQUFDO0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1BQU0sR0FBRyxDQUFDO1lBQ2xCLENBQUM7UUFDTCxDQUFDO0lBQ0wsQ0FBQztJQUVEOzs7O09BSUc7SUFDSCxJQUFJLGFBQWEsS0FBSyxPQUFPLElBQUksQ0FBQyxlQUFlLENBQUMsaUJBQVUsQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUM7SUFFdkU7Ozs7Ozs7O09BUUc7SUFDSCxLQUFLLENBQUMsTUFBTSxDQUFDLE1BQW9CO1FBQzdCLE1BQU0sSUFBSSxDQUFDLGFBQWEsQ0FBQyxNQUFNLENBQUMsQ0FBQztJQUNyQyxDQUFDO0NBQ0o7QUF2SkQsMENBdUpDIn0=
@@ -1,53 +1,33 @@
1
1
  import { ETagEndpointBase } from "./ETagEndpointBase";
2
2
  import { ElementEndpoint } from "./ElementEndpoint";
3
+ import { PartialResponse } from "./PartialResponse";
3
4
  import { Endpoint } from "../Endpoint";
4
- import { CachingEndpoint } from "../CachingEndpoint";
5
- import { HttpMethod, HttpHeader, ResponseCache } from "../../http";
6
-
7
5
  /**
8
6
  * Endpoint for a collection of `TEntity`s addressable as `TElementEndpoint`s.<br>
9
7
  * Use {@link CollectionEndpoint} instead if you wish to use the default {@link ElementEndpoint} type.
10
8
  * @typeParam TEntity The type of individual elements in the collection.
11
9
  * @typeParam TElementEndpoint The type of {@link ElementEndpoint} to provide for individual `TEntity`s.
12
10
  */
13
- export class GenericCollectionEndpoint<TEntity, TElementEndpoint extends ElementEndpoint<TEntity>> extends ETagEndpointBase {
11
+ export declare class GenericCollectionEndpoint<TEntity, TElementEndpoint extends ElementEndpoint<TEntity>> extends ETagEndpointBase {
12
+ private readonly elementEndpoint;
14
13
  /**
15
14
  * Creates a new collection endpoint.
16
15
  * @param referrer The endpoint used to navigate to this one.
17
16
  * @param relativeUri The URI of this endpoint relative to the `referrer`'s. Add a `./` prefix here to imply a trailing slash in the `referrer`'s URI.
18
17
  * @param elementEndpoint A factory method for creating instances of `TElementEndpoint`.
19
18
  */
20
- constructor(referrer: Endpoint, relativeUri: URL | string, private readonly elementEndpoint: new (referrer: Endpoint, uri: URL) => TElementEndpoint) {
21
- super(referrer, relativeUri);
22
- this.setDefaultLinkTemplate("child", "./{id}");
23
- }
24
-
19
+ constructor(referrer: Endpoint, relativeUri: URL | string, elementEndpoint: new (referrer: Endpoint, uri: URL) => TElementEndpoint);
25
20
  /**
26
21
  * Returns an `TElementEndpoint` for a specific child element.
27
22
  * @param element The ID identifying the entity or an entity to extract the ID from.
28
23
  */
29
- get(element: (TEntity | string)): TElementEndpoint {
30
- if (element == null) throw new Error("element must not be null or unspecified.");
31
-
32
- let id: string;
33
- if (typeof element === "string") {
34
- id = element;
35
- } else {
36
- id = (element as any).id;
37
- if (id === undefined) throw new Error(`Element ${element} does not have an id property.`);
38
- }
39
- if (id == null || id === "") throw new Error("id must not be null or empty.");
40
-
41
- return new this.elementEndpoint(this, this.linkTemplate("child", { id }));
42
- }
43
-
24
+ get(element: (TEntity | string)): TElementEndpoint;
44
25
  /**
45
26
  * Shows whether the server has indicated that {@link readAll} is currently allowed.
46
27
  * Uses cached data from last response.
47
28
  * @returns `true` if the method is allowed, `false` if the method is not allowed, `undefined` if no request has been sent yet or the server did not specify allowed methods.
48
29
  */
49
- get readAllAllowed() { return this.isMethodAllowed(HttpMethod.Get); }
50
-
30
+ get readAllAllowed(): boolean | undefined;
51
31
  /**
52
32
  * Returns all `TEntity`s in the collection.
53
33
  * @param signal Used to cancel the request.
@@ -56,17 +36,39 @@ export class GenericCollectionEndpoint<TEntity, TElementEndpoint extends Element
56
36
  * @throws {@link errors!ConflictError}: {@link http!HttpStatusCode.Conflict}
57
37
  * @throws {@link errors!HttpError}: Other non-success status code
58
38
  */
59
- async readAll(signal?: AbortSignal) {
60
- return this.serializer.deserialize<TEntity[]>(await this.getContent(signal));
61
- }
62
-
39
+ readAll(signal?: AbortSignal): Promise<TEntity[]>;
40
+ /**
41
+ * The unit used when requesting ranges of elements. Sent in the {@link http!HttpHeader.Range} header.
42
+ */
43
+ rangeUnit: string;
44
+ private acceptedRangeUnits;
45
+ /**
46
+ * @inheritDoc
47
+ */
48
+ protected handleCapabilities(response: Response): void;
49
+ /**
50
+ * Shows whether the server has indicated that {@link readRange} is currently allowed.
51
+ * Uses cached data from last response.
52
+ * @returns `true` if the method is allowed, `false` if the method is not allowed, `undefined` if no request has been sent yet or the server did not specify accepted range units.
53
+ */
54
+ get readRangeAllowed(): boolean | undefined;
55
+ /**
56
+ * Returns a subset of the `TEntity`s in the collection.
57
+ * @param from The index of the first element to return. Leave unspecified to return the last `to` elements ("tail").
58
+ * @param to The index of the last element to return. Leave unspecified to return all elements starting at `from`.
59
+ * @param signal Used to cancel the request.
60
+ * @throws {@link errors!AuthenticationError}: {@link http!HttpStatusCode.Unauthorized}
61
+ * @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
62
+ * @throws {@link errors!RangeNotSatisfiableError}: {@link http!HttpStatusCode.RangeNotSatisfiable}, i.e. the requested range lies outside of the elements currently available
63
+ * @throws {@link errors!HttpError}: Other non-success status code
64
+ */
65
+ readRange(from?: number, to?: number, signal?: AbortSignal): Promise<PartialResponse<TEntity>>;
63
66
  /**
64
67
  * Shows whether the server has indicated that {@link create} is currently allowed.
65
68
  * Uses cached data from last response.
66
69
  * @returns `true` if the method is allowed, `false` if the method is not allowed, `undefined` if no request has been sent yet or the server did not specify allowed methods.
67
70
  */
68
- get createAllowed() { return this.isMethodAllowed(HttpMethod.Post); }
69
-
71
+ get createAllowed(): boolean | undefined;
70
72
  /**
71
73
  * Adds a `TEntity` as a new element to the collection.
72
74
  * @param entity The new `TEntity`.
@@ -78,37 +80,13 @@ export class GenericCollectionEndpoint<TEntity, TElementEndpoint extends Element
78
80
  * @throws {@link errors!ConflictError}: {@link http!HttpStatusCode.Conflict}
79
81
  * @throws {@link errors!HttpError}: Other non-success status code
80
82
  */
81
- async create(entity: TEntity, signal?: AbortSignal): Promise<TElementEndpoint | undefined> {
82
- const response = await this.send(HttpMethod.Post, signal, {
83
- [HttpHeader.ContentType]: this.serializer.supportedMediaTypes[0]
84
- }, this.serializer.serialize(entity));
85
- const location = response.headers.get(HttpHeader.Location);
86
-
87
- let elementEndpoint: TElementEndpoint;
88
- if (location) {
89
- // Explicit element endpoint URL from "Location" header
90
- elementEndpoint = new this.elementEndpoint(this, this.join(location));
91
- } else {
92
- try {
93
- // Infer URL from entity ID in response body
94
- elementEndpoint = this.get(this.serializer.deserialize(await response.clone().text()));
95
- } catch {
96
- // No element endpoint
97
- return undefined;
98
- }
99
- }
100
-
101
- (elementEndpoint as CachingEndpoint).responseCache = await ResponseCache.from(response);
102
- return elementEndpoint;
103
- }
104
-
83
+ create(entity: TEntity, signal?: AbortSignal): Promise<TElementEndpoint | undefined>;
105
84
  /**
106
85
  * Shows whether the server has indicated that {@link createAll} is currently allowed.
107
86
  * Uses cached data from last response.
108
87
  * @returns `true` if the method is allowed, `false` if the method is not allowed, `undefined` if no request has been sent yet or the server did not specify allowed methods.
109
88
  */
110
- get createAllAllowed() { return this.isMethodAllowed(HttpMethod.Patch); }
111
-
89
+ get createAllAllowed(): boolean | undefined;
112
90
  /**
113
91
  * Adds (or updates) multiple `TEntity`s as elements in the collection.
114
92
  * @param entities The `TEntity`s to create or modify.
@@ -119,19 +97,13 @@ export class GenericCollectionEndpoint<TEntity, TElementEndpoint extends Element
119
97
  * @throws {@link errors!ConflictError}: {@link http!HttpStatusCode.Conflict}
120
98
  * @throws {@link errors!HttpError}: Other non-success status code
121
99
  */
122
- async createAll(entities: TEntity[], signal?: AbortSignal) {
123
- await this.send(HttpMethod.Patch, signal, {
124
- [HttpHeader.ContentType]: this.serializer.supportedMediaTypes[0]
125
- }, this.serializer.serialize(entities));
126
- }
127
-
100
+ createAll(entities: TEntity[], signal?: AbortSignal): Promise<void>;
128
101
  /**
129
102
  * Shows whether the server has indicated that {@link setAll} is currently allowed.
130
103
  * Uses cached data from last response.
131
104
  * @returns `true` if the method is allowed, `false` if the method is not allowed, `undefined` if no request has been sent yet or the server did not specify allowed methods.
132
105
  */
133
- get setAllAllowed() { return this.isMethodAllowed(HttpMethod.Put); }
134
-
106
+ get setAllAllowed(): boolean | undefined;
135
107
  /**
136
108
  * Replaces the entire content of the collection with new `TEntity`s.
137
109
  * @param entities The `TEntity`s to create or modify.
@@ -141,8 +113,7 @@ export class GenericCollectionEndpoint<TEntity, TElementEndpoint extends Element
141
113
  * @throws {@link errors!ConflictError}: {@link http!HttpStatusCode.Conflict}
142
114
  * @throws {@link errors!HttpError}: Other non-success status code
143
115
  */
144
- async setAll(entities: TEntity[]) { await this.putContent(entities); }
145
-
116
+ setAll(entities: TEntity[]): Promise<void>;
146
117
  /**
147
118
  * Determines whether the collection contains a specific element.
148
119
  * @param element The ID identifying the entity or an entity to extract the ID from.
@@ -150,8 +121,7 @@ export class GenericCollectionEndpoint<TEntity, TElementEndpoint extends Element
150
121
  * @throws {@link errors!AuthorizationError}: {@link http!HttpStatusCode.Forbidden}
151
122
  * @throws {@link errors!HttpError}: Other non-success status code
152
123
  */
153
- contains(element: (TEntity | string)) { return this.get(element).exists(); }
154
-
124
+ contains(element: (TEntity | string)): Promise<boolean>;
155
125
  /**
156
126
  * Sets/replaces an existing element in the collection.
157
127
  * @param element The new state of the element.
@@ -162,8 +132,7 @@ export class GenericCollectionEndpoint<TEntity, TElementEndpoint extends Element
162
132
  * @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
163
133
  * @throws {@link errors!HttpError}: Other non-success status code
164
134
  */
165
- set(element: TEntity) { return this.get(element).set(element); }
166
-
135
+ set(element: TEntity): Promise<TEntity | undefined>;
167
136
  /**
168
137
  * Modifies an existing element in the collection by merging changes on the server-side.
169
138
  * @param element The `TEntity` data to merge with the existing element.
@@ -174,8 +143,7 @@ export class GenericCollectionEndpoint<TEntity, TElementEndpoint extends Element
174
143
  * @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
175
144
  * @throws {@link errors!HttpError}: Other non-success status code
176
145
  */
177
- merge(element: TEntity) { return this.get(element).merge(element); }
178
-
146
+ merge(element: TEntity): Promise<TEntity | undefined>;
179
147
  /**
180
148
  * Deletes an existing element from the collection.
181
149
  * @param element The ID identifying the entity or an entity to extract the ID from.
@@ -184,5 +152,5 @@ export class GenericCollectionEndpoint<TEntity, TElementEndpoint extends Element
184
152
  * @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
185
153
  * @throws {@link errors!HttpError}: Other non-success status code
186
154
  */
187
- delete(element: (TEntity | string)) { return this.get(element).delete(); }
155
+ delete(element: (TEntity | string)): Promise<void>;
188
156
  }