Skip to content

Commit f6e3ea6

Browse files
authored
Merge pull request #109 from badgateway/update-link-hints
Update link-hints to latest draft
2 parents f4b26a5 + a4778de commit f6e3ea6

File tree

3 files changed

+29
-70
lines changed

3 files changed

+29
-70
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ It exports the following interfaces:
99
1. `HalLink`, representing an individual [HAL Link][1]
1010
2. `HalResource`, representing a single [HAL document][2], with at least a
1111
`_links` property and optionally `_embedded` property and `_templates` properties.
12-
3. `LinkHints`, an extension to links, as defined in [draft-nottingham-link-hint][3].
12+
3. `LinkHints`, an extension to links, as defined in [draft-ietf-httpapi-link-hint][3].
1313
4. `HalFormsTemplate`, A [HAL Forms][4] template object.
1414
5. `HalFormsProperty` A single property from a HAL Form.
1515

1616
[1]: https://tools.ietf.org/html/draft-kelly-json-hal-00#section-5
1717
[2]: https://tools.ietf.org/html/draft-kelly-json-hal-00#section-4
18-
[3]: https://tools.ietf.org/html/draft-nottingham-link-hint
18+
[3]: https://datatracker.ietf.org/doc/html/draft-ietf-httpapi-link-hint
1919
[4]: http://rwcbook.github.io/hal-forms/
2020

2121
# Usage

changelog.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
ChangeLog
22
=========
33

4+
2.0.0 (????-??-??)
5+
------------------
6+
7+
* Update link-hint to latest draft. The types changed in a few different
8+
places, so if you used link-hints, this is likely a BC break for you.
9+
10+
411
1.9.0 (2023-01-08)
512
------------------
613

7-
* `placeholder` from HAL Forms was incorrectly cased as `placeHolder`.
8-
This is fixed but could be a BC break. (@dayre)
14+
* `placeholder` from HAL Forms was incorrectly cased as `placeHolder`. This is
15+
fixed but could be a BC break. (@dayre)
916

1017

1118
1.8.0 (2022-06-26)
1219
------------------
1320

14-
* Add `name`, `deprecation` and `profile` properties to HAL Links. These
15-
were part of the base spec and should always have been there.
21+
* Add `name`, `deprecation` and `profile` properties to HAL Links. These were
22+
part of the base spec and should always have been there.
1623

1724

1825
1.7.7 (2022-05-04)
@@ -21,6 +28,7 @@ ChangeLog
2128
* Fix a second BC breaking change. `_links` should not be omitted. If `_links`
2229
may be omitted this change might be re-introduce in a major version.
2330

31+
2432
1.7.6 (2022-05-04)
2533
------------------
2634

@@ -56,19 +64,16 @@ ChangeLog
5664
------------------
5765

5866
* Added type: range
59-
* Now exporting:
60-
* `HalFormsSimpleProperty`
61-
* `HalFormsRangeProperty`
62-
* `HalFormsOptionsInline`
63-
* `HalFormsOptionsLink`
67+
* Now exporting: * `HalFormsSimpleProperty` * `HalFormsRangeProperty` *
68+
`HalFormsOptionsInline` * `HalFormsOptionsLink`
6469

6570

6671
1.7.0 (2021-02-20)
6772
------------------
6873

6974
* Updated to HAL Forms 2021-02-20, which adds support for the 'options'
70-
property. This property can be used to generate lists of possible values
71-
in form fields, including values from external HTTP sources.
75+
property. This property can be used to generate lists of possible values in
76+
form fields, including values from external HTTP sources.
7277

7378

7479
1.6.1 (2021-01-03)
@@ -89,7 +94,7 @@ ChangeLog
8994

9095

9196
1.5.0 (2020-12-30)
92-
-----------------
97+
------------------
9398

9499
* Update to HAL-Forms 2020-12-29, which adds support for a `textarea` type, and
95100
`cols` and `rows` fields on form fields.
@@ -141,6 +146,7 @@ ChangeLog
141146

142147
* Forgot to build files before publishing.
143148

149+
144150
0.1.1 (2019-09-30)
145151
------------------
146152

src/link-hints.ts

Lines changed: 9 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { HalLink } from './hal';
2-
31
/**
42
* Link hints.
53
*
@@ -17,25 +15,13 @@ export interface LinkHints {
1715
* List of supported formats (used in for example GET responses
1816
* or PUT requests
1917
*/
20-
formats?: LinkHintFormats;
21-
22-
/**
23-
* List of links that exists at the context of the hint.
24-
*
25-
* This allows to specify links that exists at the target
26-
* resource. For example, you might add an 'edit-form' link
27-
* on a link, allowing clients to render an edit button
28-
* for a target.
29-
*/
30-
links?: {
31-
[rel: string]: HalLink;
32-
};
18+
formats?: string[];
3319

3420
/**
3521
* A list of media-types the target resource supports for
3622
* POST request bodies
3723
*/
38-
'accept-post'?: LinkHintFormats;
24+
'accept-post'?: string[];
3925

4026
/**
4127
* Array of media-types that the target resource supports for
@@ -69,9 +55,14 @@ export interface LinkHints {
6955

7056
/**
7157
* A list of authentication schemes that are required at the target
72-
* resource
58+
* resource, for example 'Basic', 'Digest', 'Bearer'.
7359
*/
74-
'auth-schemes'?: LinkHintAuthScheme[];
60+
'auth-schemes'?: string[];
61+
62+
/**
63+
* A list of authentication realms available at the target
64+
*/
65+
'auth-realms'?: string[];
7566

7667
/**
7768
* A status for the resource.
@@ -82,41 +73,3 @@ export interface LinkHints {
8273
status?: 'deprecated' | 'gone';
8374

8475
}
85-
86-
/**
87-
* A supported format, indexed by media type
88-
*/
89-
interface LinkHintFormats {
90-
91-
[mediaType: string]: {
92-
/**
93-
* Relevant links to the format.
94-
*
95-
* Mainly this could contain a 'profile' or 'describedby'
96-
* link. These both describe a schema for the format
97-
*/
98-
links?: {
99-
[rel: string]: HalLink;
100-
};
101-
102-
/**
103-
* If set to true, it indicates that this format is
104-
* deprecated
105-
*/
106-
deprecated?: boolean;
107-
};
108-
}
109-
110-
interface LinkHintAuthScheme {
111-
/**
112-
* A registered authenticaiton scheme such as 'Basic', 'Digest' or 'Bearer'.
113-
*/
114-
scheme: string;
115-
116-
/**
117-
* Realm information from the authentation scheme, similar to the "realm"
118-
* attribute on the WWW-Authentication header.
119-
*/
120-
realm?: string;
121-
122-
}

0 commit comments

Comments
 (0)