typedrest 0.5.0 → 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 (88) hide show
  1. package/README.md +41 -5
  2. package/endpoints/{CachingEndpoint.ts → CachingEndpoint.d.ts} +0 -1
  3. package/endpoints/Endpoint.d.ts +121 -0
  4. package/endpoints/Endpoint.js +1 -1
  5. package/endpoints/{EntryEndpoint.ts → EntryEndpoint.d.ts} +7 -27
  6. package/endpoints/generic/{CollectionEndpoint.ts → CollectionEndpoint.d.ts} +2 -5
  7. package/endpoints/generic/{ETagEndpointBase.ts → ETagEndpointBase.d.ts} +7 -38
  8. package/endpoints/generic/{ElementEndpoint.ts → ElementEndpoint.d.ts} +12 -70
  9. package/endpoints/generic/{GenericCollectionEndpoint.ts → GenericCollectionEndpoint.d.ts} +21 -106
  10. package/endpoints/generic/{IndexerEndpoint.ts → IndexerEndpoint.d.ts} +4 -11
  11. package/endpoints/generic/PartialResponse.d.ts +19 -0
  12. package/endpoints/{index.ts → index.d.ts} +1 -2
  13. package/endpoints/raw/{BlobEndpoint.ts → BlobEndpoint.d.ts} +9 -29
  14. package/endpoints/raw/{UploadEndpoint.ts → UploadEndpoint.d.ts} +4 -18
  15. package/endpoints/reactive/Delay.d.ts +7 -0
  16. package/endpoints/reactive/GenericStreamingCollectionEndpoint.d.ts +32 -0
  17. package/endpoints/reactive/{PollingEndpoint.ts → PollingEndpoint.d.ts} +7 -34
  18. package/endpoints/reactive/SseStreamingEndpoint.d.ts +50 -0
  19. package/endpoints/reactive/{StreamingCollectionEndpoint.ts → StreamingCollectionEndpoint.d.ts} +2 -5
  20. package/endpoints/reactive/{StreamingEndpoint.ts → StreamingEndpoint.d.ts} +5 -27
  21. package/endpoints/rpc/{ActionEndpoint.ts → ActionEndpoint.d.ts} +3 -10
  22. package/endpoints/rpc/{ConsumerEndpoint.ts → ConsumerEndpoint.d.ts} +3 -12
  23. package/endpoints/rpc/{FunctionEndpoint.ts → FunctionEndpoint.d.ts} +3 -14
  24. package/endpoints/rpc/{ProducerEndpoint.ts → ProducerEndpoint.d.ts} +3 -11
  25. package/endpoints/rpc/{RpcEndpointBase.ts → RpcEndpointBase.d.ts} +4 -12
  26. package/errors/DefaultErrorHandler.d.ts +21 -0
  27. package/errors/{Errors.ts → Errors.d.ts} +20 -21
  28. package/http/EntityStream.d.ts +10 -0
  29. package/http/FetchHttpClient.d.ts +15 -0
  30. package/http/FetchHttpClient.js +1 -1
  31. package/http/{HttpClient.ts → HttpClient.d.ts} +1 -3
  32. package/http/HttpContentRange.d.ts +23 -0
  33. package/http/{HttpHeader.ts → HttpHeader.d.ts} +1 -1
  34. package/http/{HttpMethod.ts → HttpMethod.d.ts} +1 -1
  35. package/http/{HttpStatusCode.ts → HttpStatusCode.d.ts} +1 -1
  36. package/http/ResponseCache.d.ts +19 -0
  37. package/http/RetryAfter.d.ts +6 -0
  38. package/http/ServerSentEvents.d.ts +50 -0
  39. package/links/AggregateLinkExtractor.d.ts +17 -0
  40. package/links/HalLinkExtractor.d.ts +13 -0
  41. package/links/HeaderLinkExtractor.d.ts +13 -0
  42. package/links/{Link.ts → Link.d.ts} +6 -2
  43. package/links/{LinkExtractor.ts → LinkExtractor.d.ts} +0 -1
  44. package/package.json +64 -14
  45. package/serializers/JsonSerializer.d.ts +18 -0
  46. package/serializers/{Serializer.ts → Serializer.d.ts} +0 -2
  47. package/endpoints/Endpoint.test.ts +0 -300
  48. package/endpoints/Endpoint.ts +0 -247
  49. package/endpoints/generic/CollectionEndpoint.test.ts +0 -215
  50. package/endpoints/generic/ElementEndpoint.test.ts +0 -262
  51. package/endpoints/generic/GenericCollectionEndpoint.test.ts +0 -123
  52. package/endpoints/generic/IndexerEndpoint.test.ts +0 -12
  53. package/endpoints/generic/PartialResponse.ts +0 -28
  54. package/endpoints/raw/BlobEndpoint.test.ts +0 -52
  55. package/endpoints/raw/UploadEndpoint.test.ts +0 -47
  56. package/endpoints/reactive/Delay.ts +0 -26
  57. package/endpoints/reactive/GenericStreamingCollectionEndpoint.ts +0 -73
  58. package/endpoints/reactive/PollingEndpoint.test.ts +0 -84
  59. package/endpoints/reactive/SseStreamingEndpoint.test.ts +0 -169
  60. package/endpoints/reactive/SseStreamingEndpoint.ts +0 -115
  61. package/endpoints/reactive/StreamingCollectionEndpoint.test.ts +0 -110
  62. package/endpoints/reactive/StreamingEndpoint.test.ts +0 -130
  63. package/endpoints/rpc/ActionEndpoint.test.ts +0 -36
  64. package/endpoints/rpc/ConsumerEndpoint.test.ts +0 -29
  65. package/endpoints/rpc/FunctionEndpoint.test.ts +0 -29
  66. package/endpoints/rpc/ProducerEndpoint.test.ts +0 -32
  67. package/errors/DefaultErrorHandler.ts +0 -65
  68. package/http/EntityStream.ts +0 -40
  69. package/http/FetchHttpClient.ts +0 -26
  70. package/http/HttpContentRange.ts +0 -41
  71. package/http/ResponseCache.ts +0 -25
  72. package/http/RetryAfter.ts +0 -19
  73. package/http/ServerSentEvents.ts +0 -145
  74. package/jest.config.js +0 -12
  75. package/links/AggregateLinkExtractor.ts +0 -28
  76. package/links/HalLinkExtractor.ts +0 -45
  77. package/links/HeaderLinkExtractor.ts +0 -56
  78. package/serializers/JsonSerializer.ts +0 -25
  79. /package/endpoints/generic/{index.ts → index.d.ts} +0 -0
  80. /package/endpoints/raw/{index.ts → index.d.ts} +0 -0
  81. /package/endpoints/reactive/{index.ts → index.d.ts} +0 -0
  82. /package/endpoints/rpc/{index.ts → index.d.ts} +0 -0
  83. /package/errors/{ErrorHandler.ts → ErrorHandler.d.ts} +0 -0
  84. /package/errors/{index.ts → index.d.ts} +0 -0
  85. /package/http/{index.ts → index.d.ts} +0 -0
  86. /package/{index.ts → index.d.ts} +0 -0
  87. /package/links/{index.ts → index.d.ts} +0 -0
  88. /package/serializers/{index.ts → index.d.ts} +0 -0
package/README.md CHANGED
@@ -1,9 +1,42 @@
1
1
  # ![TypedRest](https://raw.githubusercontent.com/TypedRest/TypedRest-TypeScript/master/logo.svg) for TypeScript
2
2
 
3
- [![TypedRest](https://img.shields.io/npm/v/typedrest.svg)](https://www.npmjs.com/package/typedrest)
3
+ [![Build](https://github.com/TypedRest/TypedRest-TypeScript/actions/workflows/build.yml/badge.svg)](https://github.com/TypedRest/TypedRest-TypeScript/actions/workflows/build.yml)
4
4
  [![API documentation](https://img.shields.io/badge/api-docs-orange.svg)](https://typescript.typedrest.net/)
5
- [![Build](https://github.com/TypedRest/TypedRest-TypeScript/actions/workflows/build.yml/badge.svg)](https://github.com/TypedRest/TypedRest-TypeScript/actions/workflows/build.yml)
6
- TypedRest helps you build type-safe, fluent-style REST API clients. Common REST patterns such as collections are represented as classes, allowing you to write more idiomatic code.
5
+ [![TypedRest](https://img.shields.io/npm/v/typedrest.svg)](https://www.npmjs.com/package/typedrest)
6
+
7
+ **Describe your REST API as a tree of endpoints, not a list of HTTP calls.**
8
+
9
+ TypedRest helps you build type-safe, fluent-style REST API clients. Common REST patterns are represented as classes that you compose to mirror the URL structure of your API.
10
+
11
+ Tell TypedRest that `/contacts` is a collection and get type-safe listing, creating, reading, updating and deleting in return. Unlike typical generated clients, which give you one flat method per operation, TypedRest gives you a navigable tree of endpoints.
12
+
13
+ ## Define your client
14
+
15
+ A few lines are enough to describe an API with a collection of contacts plus a "notes" endpoint nested underneath:
16
+
17
+ ```typescript
18
+ class MyClient extends EntryEndpoint {
19
+ get contacts() {
20
+ return new ContactCollectionEndpoint(this);
21
+ }
22
+ }
23
+
24
+ class ContactCollectionEndpoint extends GenericCollectionEndpoint<Contact, ContactEndpoint> {
25
+ constructor(referrer: Endpoint) {
26
+ super(referrer, "./contacts", ContactEndpoint);
27
+ }
28
+ }
29
+
30
+ class ContactEndpoint extends ElementEndpoint<Contact> {
31
+ get note() {
32
+ return new ElementEndpoint<Note>(this, "./note");
33
+ }
34
+ }
35
+ ```
36
+
37
+ ## Use it
38
+
39
+ Navigate the API like an object model, with code completion guiding the way:
7
40
 
8
41
  ```typescript
9
42
  const client = new MyClient(new URL("http://example.com/"));
@@ -28,6 +61,9 @@ const note: Note = await smith.note.read();
28
61
  await smith.delete();
29
62
  ```
30
63
 
31
- Read a more detailed **[Introduction](https://typedrest.net/introduction/)** to TypedRest or jump right in with the **[setup guide](https://typedrest.net/setup/typescript/)**.
64
+ ## Learn more
65
+
66
+ Read a more detailed **[Introduction](https://typedrest.net/introduction/)** to TypedRest or jump right in with the **[setup guide](https://typedrest.net/setup/typescript/)**.
67
+ You can also **[build your first client](https://typedrest.net/tutorials/first-client/)** step by step or **[generate one from OpenAPI](https://typedrest.net/tutorials/from-openapi/)**.
32
68
 
33
- You can also take a look at our [Sample project](https://github.com/TypedRest/Sample-TypeScript).
69
+ Take a look at our [Sample project](https://github.com/TypedRest/Sample-TypeScript) to see TypedRest in action.
@@ -1,5 +1,4 @@
1
1
  import { ResponseCache } from "../http";
2
-
3
2
  /**
4
3
  * Endpoint that caches the last response.
5
4
  */
@@ -0,0 +1,121 @@
1
+ import { HttpMethod, HttpClient } from "../http";
2
+ import { Serializer } from "../serializers";
3
+ import { ErrorHandler } from "../errors";
4
+ import { LinkExtractor } from "../links";
5
+ export declare class Endpoint {
6
+ /**
7
+ * The HTTP URI of the remote resource.
8
+ */
9
+ readonly uri: URL;
10
+ /**
11
+ * The HTTP client used to communicate with the remote resource.
12
+ */
13
+ readonly httpClient: HttpClient;
14
+ /**
15
+ * Controls the serialization of entities sent to and received from the server.
16
+ */
17
+ readonly serializer: Serializer;
18
+ /**
19
+ * Handles errors in responses.
20
+ */
21
+ readonly errorHandler: ErrorHandler;
22
+ /**
23
+ * Extracts links from responses.
24
+ */
25
+ readonly linkExtractor: LinkExtractor;
26
+ /**
27
+ * Creates a new endpoint.
28
+ * @param referrer The endpoint used to navigate to this one. Must be defined except for top-level endpoint.
29
+ * @param uri The HTTP URI of the remote element. May be relative if `referrer` is defined.
30
+ * @param serializer Controls the serialization of entities sent to and received from the server. Taken from `referrer` instead if it is defined.
31
+ * @param errorHandler Handles errors in responses. Taken from `referrer` instead if it is defined.
32
+ * @param linkExtractor Extracts links from responses. Taken from `referrer` instead if it is defined.
33
+ * @param httpClient The HTTP client used to communicate with the remote resource. Taken from `referrer` instead if it is defined.
34
+ */
35
+ constructor(referrer: Endpoint | undefined, uri: URL | string, serializer?: Serializer, errorHandler?: ErrorHandler, linkExtractor?: LinkExtractor, httpClient?: HttpClient);
36
+ /**
37
+ * Resolves a relative URI using this endpoint's URI as the base.
38
+ * @param relativeUri The relative URI to resolve. Prepend `./` to imply a trailing slash in the base URI even if it is missing there.
39
+ */
40
+ protected join(relativeUri: string): URL;
41
+ /**
42
+ * Adds a trailing slash to the URI if it does not already have one.
43
+ */
44
+ protected static ensureTrailingSlash(uri: URL | string): URL;
45
+ /**
46
+ * Sends an HTTP request to this endpoint's URI.
47
+ * Handles various cross-cutting concerns regarding a response message such as discovering links and handling errors.
48
+ * @param method The HTTP method to use.
49
+ * @param signal Used to cancel the request.
50
+ * @param headers The HTTP headers to set.
51
+ * @param body The body to send.
52
+ * @throws {@link errors!HttpError}
53
+ */
54
+ protected send(method: HttpMethod, signal?: AbortSignal, headers?: RequestInit["headers"], body?: RequestInit["body"]): Promise<Response>;
55
+ /**
56
+ * Handles various cross-cutting concerns regarding a response message such as discovering links and handling errors.
57
+ * @param response The response to process.
58
+ * @throws {@link errors!HttpError}
59
+ */
60
+ protected handle(response: Response): Promise<void>;
61
+ private links;
62
+ private defaultLinks;
63
+ private defaultLinkTemplates;
64
+ /**
65
+ * Registers one or more default links for a specific relation type.
66
+ * These links are used when no links with this relation type are provided by the server.
67
+ * This should only be called during initial setup of the endpoint.
68
+ * @param rel The relation type of the link to add.
69
+ * @param href The href of the link relative to this endpoint's URI. Leave unspecified to remove any previous entries for the relation type.
70
+ */
71
+ setDefaultLink(rel: string, href?: string): void;
72
+ /**
73
+ * Registers a default link template for a specific relation type.
74
+ * This template is used when no template with this relation type is provided by the server.
75
+ * This should only be called during initial setup of the endpoint.
76
+ * @param rel The relation type of the link to add.
77
+ * @param href The templates href relative to this endpoint's URI. Leave unspecified to remove any previous entries for the relation type.
78
+ */
79
+ setDefaultLinkTemplate(rel: string, href?: string): void;
80
+ /**
81
+ * Resolves all links with a specific relation type. Uses cached data from last response.
82
+ * @param rel The relation type of the links to look for.
83
+ */
84
+ getLinks(rel: string): {
85
+ uri: URL;
86
+ title?: string;
87
+ }[];
88
+ /**
89
+ * Resolves a single link with a specific relation type. Uses cached data from last response.
90
+ * @param rel The relation type of the link to look for.
91
+ * @throws {@link errors!NotFoundError}: No link with the specified `rel` could be found.
92
+ */
93
+ link(rel: string): URL;
94
+ /**
95
+ * Resolves a link template with a specific relation type. Uses cached data from last response.
96
+ * @param rel The relation type of the link template to look for.
97
+ * @param variables Variables for resolving the template.
98
+ * @throws {@link errors!NotFoundError}: No link template with the specified `rel` could be found.
99
+ */
100
+ linkTemplate(rel: string, variables: {
101
+ [key: string]: any;
102
+ }): URL;
103
+ /**
104
+ * Retrieves a link template with a specific relation type. Uses cached data from last response. Prefer {@link linkTemplate} when possible.
105
+ * @param rel The relation type of the link template to look for.
106
+ * @throws {@link errors!NotFoundError}: No link template with the specified `rel` could be found.
107
+ */
108
+ getLinkTemplate(rel: string): string;
109
+ private allowedMethods;
110
+ /**
111
+ * Handles allowed HTTP methods and other capabilities reported by the server.
112
+ */
113
+ protected handleCapabilities(response: Response): void;
114
+ /**
115
+ * Shows whether the server has indicated that a specific HTTP method is currently allowed.
116
+ * Uses cached data from last response.
117
+ * @param method The HTTP methods (e.g. GET, POST, ...) to check.
118
+ * @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.
119
+ */
120
+ protected isMethodAllowed(method: HttpMethod): boolean | undefined;
121
+ }
@@ -197,4 +197,4 @@ class Endpoint {
197
197
  }
198
198
  }
199
199
  exports.Endpoint = Endpoint;
200
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRW5kcG9pbnQuanMiLCJzb3VyY2VSb290I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RyxNQUFNLENBQUMsS0FBSyxDQUFDLElBQUksQ0FBaUIsQ0FBQztRQUM3RCxDQUFDO0lBQ0wsQ0FBQztJQUVEOzs7OztPQUtHO0lBQ08sZUFBZSxDQUFDLE1BQWtCO1FBQ3hDLElBQUksSUFBSSxDQUFDLGNBQWMsQ0FBQyxNQUFNLEtBQUssQ0FBQztZQUNoQyxPQUFPLFNBQVMsQ0FBQztRQUVyQixPQUFPLElBQUksQ0FBQyxjQUFjLENBQUMsT0FBTyxDQUFDLE1BQU0sQ0FBQyxLQUFLLENBQUMsQ0FBQyxDQUFDO0lBQ3RELENBQUM7Q0FDSjtBQWhQRCw0QkFnUEMifQ==
@@ -1,13 +1,12 @@
1
1
  import { Endpoint } from "./Endpoint";
2
- import { HttpMethod, HttpClient, FetchHttpClient, HttpHeader } from "../http";
3
- import { Serializer, JsonSerializer } from "../serializers";
4
- import { ErrorHandler, DefaultErrorHandler } from "../errors";
5
- import { LinkExtractor, AggregateLinkExtractor, HeaderLinkExtractor, HalLinkExtractor } from "../links";
6
-
2
+ import { HttpClient } from "../http";
3
+ import { Serializer } from "../serializers";
4
+ import { ErrorHandler } from "../errors";
5
+ import { LinkExtractor } from "../links";
7
6
  /**
8
7
  * Represent the top-level URI of an API. Derive from this class and add your own set of child-{@link Endpoint}s as properties.
9
8
  */
10
- export class EntryEndpoint extends Endpoint {
9
+ export declare class EntryEndpoint extends Endpoint {
11
10
  /**
12
11
  * Creates a new entry endpoint.
13
12
  * @param uri The base URI of the REST API.<br>Missing trailing slash will be appended automatically.
@@ -16,24 +15,7 @@ export class EntryEndpoint extends Endpoint {
16
15
  * @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
16
  * @param httpClient The HTTP client used to communicate with the REST API.<br>Defaults to {@link http!FetchHttpClient} if undefined.
18
17
  */
19
- constructor(
20
- uri: URL | string,
21
- serializer?: Serializer,
22
- errorHandler?: ErrorHandler,
23
- linkExtractor?: LinkExtractor,
24
- httpClient?: HttpClient) {
25
- super(undefined,
26
- Endpoint.ensureTrailingSlash(uri),
27
- serializer ?? new JsonSerializer(),
28
- errorHandler ?? new DefaultErrorHandler(),
29
- linkExtractor ?? new AggregateLinkExtractor(new HeaderLinkExtractor(), new HalLinkExtractor()),
30
- httpClient ?? new FetchHttpClient());
31
-
32
- for (const mediaType of this.serializer.supportedMediaTypes) {
33
- this.httpClient.defaultHeaders.append(HttpHeader.Accept, mediaType);
34
- }
35
- }
36
-
18
+ constructor(uri: URL | string, serializer?: Serializer, errorHandler?: ErrorHandler, linkExtractor?: LinkExtractor, httpClient?: HttpClient);
37
19
  /**
38
20
  * Fetches meta data such as links from the server.
39
21
  * @param signal Used to cancel the request.
@@ -42,7 +24,5 @@ export class EntryEndpoint extends Endpoint {
42
24
  * @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
43
25
  * @throws {@link errors!HttpError}: Other non-success status code
44
26
  */
45
- async readMeta(signal?: AbortSignal) {
46
- await this.send(HttpMethod.Get, signal);
47
- }
27
+ readMeta(signal?: AbortSignal): Promise<void>;
48
28
  }
@@ -1,19 +1,16 @@
1
1
  import { GenericCollectionEndpoint } from "./GenericCollectionEndpoint";
2
2
  import { ElementEndpoint } from "./ElementEndpoint";
3
3
  import { Endpoint } from "../Endpoint";
4
-
5
4
  /**
6
5
  * Endpoint for a collection of `TEntity`s addressable as `ElementEndpoint<TEntity>`s.<br>
7
6
  * Use {@link GenericCollectionEndpoint} instead if you wish to customize the element endpoint type.
8
7
  * @typeParam TEntity The type of individual elements in the collection.
9
8
  */
10
- export class CollectionEndpoint<TEntity> extends GenericCollectionEndpoint<TEntity, ElementEndpoint<TEntity>> {
9
+ export declare class CollectionEndpoint<TEntity> extends GenericCollectionEndpoint<TEntity, ElementEndpoint<TEntity>> {
11
10
  /**
12
11
  * Creates a new collection endpoint.
13
12
  * @param referrer The endpoint used to navigate to this one.
14
13
  * @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
14
  */
16
- constructor(referrer: Endpoint, relativeUri: URL | string) {
17
- super(referrer, relativeUri, ElementEndpoint);
18
- }
15
+ constructor(referrer: Endpoint, relativeUri: URL | string);
19
16
  }
@@ -1,25 +1,20 @@
1
1
  import { Endpoint } from "../Endpoint";
2
2
  import { CachingEndpoint } from "../CachingEndpoint";
3
- import { HttpMethod, HttpHeader, HttpStatusCode, ResponseCache } from "../../http";
4
-
3
+ import { ResponseCache } from "../../http";
5
4
  /**
6
5
  * Base class for building endpoints that use ETags (entity tags) for caching and to avoid lost updates.
7
6
  */
8
- export class ETagEndpointBase extends Endpoint implements CachingEndpoint {
7
+ export declare class ETagEndpointBase extends Endpoint implements CachingEndpoint {
9
8
  /**
10
9
  * Creates a new endpoint.
11
10
  * @param referrer The endpoint used to navigate to this one.
12
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.
13
12
  */
14
- constructor(referrer: Endpoint, relativeUri: URL | string) {
15
- super(referrer, relativeUri);
16
- }
17
-
13
+ constructor(referrer: Endpoint, relativeUri: URL | string);
18
14
  /**
19
15
  * @inheritDoc
20
16
  */
21
- public responseCache?: ResponseCache;
22
-
17
+ responseCache?: ResponseCache;
23
18
  /**
24
19
  * 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
20
  * @param signal Used to cancel the request.
@@ -29,19 +24,7 @@ export class ETagEndpointBase extends Endpoint implements CachingEndpoint {
29
24
  * @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
30
25
  * @throws {@link errors!HttpError}: Other non-success status code
31
26
  */
32
- protected async getContent(signal?: AbortSignal): Promise<string> {
33
- const headers = new Headers();
34
- if (this.responseCache?.eTag) headers.append(HttpHeader.IfNoneMatch, this.responseCache.eTag);
35
-
36
- const response = await this.httpClient.send(this.uri, HttpMethod.Get, signal, new Headers(headers));
37
- if (response.status !== HttpStatusCode.NotModified || !this.responseCache?.content) {
38
- await this.handle(response);
39
- this.responseCache = await ResponseCache.from(response);
40
- }
41
-
42
- return this.responseCache.content;
43
- }
44
-
27
+ protected getContent(signal?: AbortSignal): Promise<string>;
45
28
  /**
46
29
  * 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
30
  * @param signal Used to cancel the request.
@@ -52,15 +35,7 @@ export class ETagEndpointBase extends Endpoint implements CachingEndpoint {
52
35
  * @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
53
36
  * @throws {@link errors!HttpError}: Other non-success status code
54
37
  */
55
- protected async putContent(content: any, signal?: AbortSignal): Promise<Response> {
56
- const headers = new Headers();
57
- headers.append(HttpHeader.ContentType, this.serializer.supportedMediaTypes[0])
58
- if (this.responseCache?.eTag) headers.append(HttpHeader.IfMatch, this.responseCache.eTag);
59
-
60
- this.responseCache = undefined;
61
- return this.send(HttpMethod.Put, signal, headers, this.serializer.serialize(content));
62
- }
63
-
38
+ protected putContent(content: any, signal?: AbortSignal): Promise<Response>;
64
39
  /**
65
40
  * 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
41
  * @param signal Used to cancel the request.
@@ -71,11 +46,5 @@ export class ETagEndpointBase extends Endpoint implements CachingEndpoint {
71
46
  * @throws {@link errors!NotFoundError}: {@link http!HttpStatusCode.NotFound} or {@link http!HttpStatusCode.Gone}
72
47
  * @throws {@link errors!HttpError}: Other non-success status code
73
48
  */
74
- protected async deleteContent(signal?: AbortSignal): Promise<Response> {
75
- const headers = new Headers();
76
- if (this.responseCache?.eTag) headers.append(HttpHeader.IfMatch, this.responseCache.eTag);
77
-
78
- this.responseCache = undefined;
79
- return this.send(HttpMethod.Delete, signal, headers);
80
- }
49
+ protected deleteContent(signal?: AbortSignal): Promise<Response>;
81
50
  }
@@ -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
  }