tests and documentation

This commit is contained in:
Art Lowel
2020-02-18 18:15:18 +01:00
parent 08dedb2dc3
commit bc00c000a6
19 changed files with 430 additions and 75 deletions

View File

@@ -1,12 +1,42 @@
import { FindListOptions } from '../../core/data/request.models';
import { HALResource } from '../../core/shared/hal-resource.model';
/**
* A class to configure the retrieval of a HALLink
*/
export class FollowLinkConfig<R extends HALResource> {
/**
* The name of the link to fetch.
* Can only be a HALLink of the object you're working with
*/
name: keyof R['_links'];
/**
* {@link FindListOptions} for the query,
* allows you to resolve the link using a certain page, or sorted
* in a certain way
*/
findListOptions?: FindListOptions;
/**
* A list of {@link FollowLinkConfig}s to
* use on the retrieved object.
*/
linksToFollow?: Array<FollowLinkConfig<any>>;
}
/**
* A factory function for {@link FollowLinkConfig}s,
* in order to create them in a less verbose way.
*
* @param linkName: the name of the link to fetch.
* Can only be a HALLink of the object you're working with
* @param findListOptions: {@link FindListOptions} for the query,
* allows you to resolve the link using a certain page, or sorted
* in a certain way
* @param linksToFollow: a list of {@link FollowLinkConfig}s to
* use on the retrieved object.
*/
export const followLink = <R extends HALResource>(
linkName: keyof R['_links'],
findListOptions?: FindListOptions,