1 | import { LinkHints } from 'hal-types';
|
2 | export declare type Link = {
|
3 | |
4 |
|
5 |
|
6 | href: string;
|
7 | |
8 |
|
9 |
|
10 |
|
11 |
|
12 | context: string;
|
13 | |
14 |
|
15 |
|
16 | rel: string;
|
17 | |
18 |
|
19 |
|
20 | title?: string;
|
21 | |
22 |
|
23 |
|
24 | type?: string;
|
25 | |
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | anchor?: string;
|
32 | |
33 |
|
34 |
|
35 | hreflang?: string;
|
36 | |
37 |
|
38 |
|
39 | media?: string;
|
40 | |
41 |
|
42 |
|
43 | templated?: boolean;
|
44 | |
45 |
|
46 |
|
47 | hints?: LinkHints;
|
48 | };
|
49 | declare type NewLink = Omit<Link, 'context'>;
|
50 |
|
51 |
|
52 |
|
53 | export declare class Links {
|
54 | defaultContext: string;
|
55 | private store;
|
56 | constructor(defaultContext: string, links?: Link[] | Links);
|
57 | /**
|
58 | * Adds a link to the list
|
59 | */
|
60 | add(...links: (Link | NewLink)[]): void;
|
61 | add(rel: string, href: string): void;
|
62 | /**
|
63 | * Set a link
|
64 | *
|
65 | * If a link with the provided 'rel' already existed, it will be overwritten.
|
66 | */
|
67 | set(link: Link | NewLink): void;
|
68 | set(rel: string, href: string): void;
|
69 | /**
|
70 | * Return a single link by its 'rel'.
|
71 | *
|
72 | * If the link does not exist, undefined is returned.
|
73 | */
|
74 | get(rel: string): Link | undefined;
|
75 | /**
|
76 | * Delete all links with the given 'rel'.
|
77 | */
|
78 | delete(rel: string): void;
|
79 | /**
|
80 | * Return all links that have a given rel.
|
81 | *
|
82 | * If no links with the rel were found, an empty array is returned.
|
83 | */
|
84 | getMany(rel: string): Link[];
|
85 | /**
|
86 | * Return all links.
|
87 | */
|
88 | getAll(): Link[];
|
89 | /**
|
90 | * Returns true if at least 1 link with the given rel exists.
|
91 | */
|
92 | has(rel: string): boolean;
|
93 | }
|
94 | /**
|
95 | * The LinkNotFound error gets thrown whenever something tries to follow a
|
96 | * link by its rel, that doesn't exist
|
97 | */
|
98 | export declare class LinkNotFound extends Error {
|
99 | }
|
100 |
|
101 |
|
102 |
|
103 | export declare type LinkVariables = {
|
104 | [key: string]: string | number;
|
105 | };
|
106 | export {};
|