mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-16 22:43:03 +00:00
68930: add embed query param for followLinks in buildHref + tests
removed fdescribe
This commit is contained in:
1
.java-version
Normal file
1
.java-version
Normal file
@@ -0,0 +1 @@
|
|||||||
|
1.8
|
10
src/app/core/cache/builders/link.service.spec.ts
vendored
10
src/app/core/cache/builders/link.service.spec.ts
vendored
@@ -90,7 +90,7 @@ describe('LinkService', () => {
|
|||||||
propertyName: 'predecessor'
|
propertyName: 'predecessor'
|
||||||
});
|
});
|
||||||
spyOnFunction(decorators, 'getDataServiceFor').and.returnValue(TestDataService);
|
spyOnFunction(decorators, 'getDataServiceFor').and.returnValue(TestDataService);
|
||||||
service.resolveLink(testModel, followLink('predecessor', {}, followLink('successor')))
|
service.resolveLink(testModel, followLink('predecessor', {}, true, followLink('successor')))
|
||||||
});
|
});
|
||||||
it('should call dataservice.findByHref with the correct href and nested links', () => {
|
it('should call dataservice.findByHref with the correct href and nested links', () => {
|
||||||
expect(testDataService.findByHref).toHaveBeenCalledWith(testModel._links.predecessor.href, followLink('successor'));
|
expect(testDataService.findByHref).toHaveBeenCalledWith(testModel._links.predecessor.href, followLink('successor'));
|
||||||
@@ -105,7 +105,7 @@ describe('LinkService', () => {
|
|||||||
isList: true
|
isList: true
|
||||||
});
|
});
|
||||||
spyOnFunction(decorators, 'getDataServiceFor').and.returnValue(TestDataService);
|
spyOnFunction(decorators, 'getDataServiceFor').and.returnValue(TestDataService);
|
||||||
service.resolveLink(testModel, followLink('predecessor', { some: 'options '} as any, followLink('successor')))
|
service.resolveLink(testModel, followLink('predecessor', { some: 'options '} as any, true, followLink('successor')))
|
||||||
});
|
});
|
||||||
it('should call dataservice.findAllByHref with the correct href, findListOptions, and nested links', () => {
|
it('should call dataservice.findAllByHref with the correct href, findListOptions, and nested links', () => {
|
||||||
expect(testDataService.findAllByHref).toHaveBeenCalledWith(testModel._links.predecessor.href, { some: 'options '} as any, followLink('successor'));
|
expect(testDataService.findAllByHref).toHaveBeenCalledWith(testModel._links.predecessor.href, { some: 'options '} as any, followLink('successor'));
|
||||||
@@ -119,7 +119,7 @@ describe('LinkService', () => {
|
|||||||
propertyName: 'predecessor'
|
propertyName: 'predecessor'
|
||||||
});
|
});
|
||||||
spyOnFunction(decorators, 'getDataServiceFor').and.returnValue(TestDataService);
|
spyOnFunction(decorators, 'getDataServiceFor').and.returnValue(TestDataService);
|
||||||
result = service.resolveLink(testModel, followLink('predecessor', {}, followLink('successor')))
|
result = service.resolveLink(testModel, followLink('predecessor', {}, true, followLink('successor')))
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call getLinkDefinition with the correct model and link', () => {
|
it('should call getLinkDefinition with the correct model and link', () => {
|
||||||
@@ -144,7 +144,7 @@ describe('LinkService', () => {
|
|||||||
});
|
});
|
||||||
it('should throw an error', () => {
|
it('should throw an error', () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
service.resolveLink(testModel, followLink('predecessor', {}, followLink('successor')))
|
service.resolveLink(testModel, followLink('predecessor', {}, true, followLink('successor')))
|
||||||
}).toThrow();
|
}).toThrow();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -160,7 +160,7 @@ describe('LinkService', () => {
|
|||||||
});
|
});
|
||||||
it('should throw an error', () => {
|
it('should throw an error', () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
service.resolveLink(testModel, followLink('predecessor', {}, followLink('successor')))
|
service.resolveLink(testModel, followLink('predecessor', {}, true, followLink('successor')))
|
||||||
}).toThrow();
|
}).toThrow();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,21 +1,23 @@
|
|||||||
import { DataService } from './data.service';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { RequestService } from './request.service';
|
|
||||||
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
|
|
||||||
import { CoreState } from '../core.reducers';
|
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
import { compare, Operation } from 'fast-json-patch';
|
||||||
import { Observable, of as observableOf } from 'rxjs';
|
import { Observable, of as observableOf } from 'rxjs';
|
||||||
import { FindListOptions } from './request.models';
|
import * as uuidv4 from 'uuid/v4';
|
||||||
|
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||||
|
import { createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils';
|
||||||
|
import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
|
||||||
|
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
|
||||||
import { SortDirection, SortOptions } from '../cache/models/sort-options.model';
|
import { SortDirection, SortOptions } from '../cache/models/sort-options.model';
|
||||||
import { ObjectCacheService } from '../cache/object-cache.service';
|
import { ObjectCacheService } from '../cache/object-cache.service';
|
||||||
import { compare, Operation } from 'fast-json-patch';
|
import { CoreState } from '../core.reducers';
|
||||||
|
import { Collection } from '../shared/collection.model';
|
||||||
import { DSpaceObject } from '../shared/dspace-object.model';
|
import { DSpaceObject } from '../shared/dspace-object.model';
|
||||||
import { ChangeAnalyzer } from './change-analyzer';
|
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||||
import { HttpClient } from '@angular/common/http';
|
|
||||||
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
|
||||||
import { Item } from '../shared/item.model';
|
import { Item } from '../shared/item.model';
|
||||||
import * as uuidv4 from 'uuid/v4';
|
import { ChangeAnalyzer } from './change-analyzer';
|
||||||
import { createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils';
|
import { DataService } from './data.service';
|
||||||
|
import { FindListOptions } from './request.models';
|
||||||
|
import { RequestService } from './request.service';
|
||||||
|
|
||||||
const endpoint = 'https://rest.api/core';
|
const endpoint = 'https://rest.api/core';
|
||||||
|
|
||||||
@@ -40,6 +42,7 @@ class TestService extends DataService<any> {
|
|||||||
return observableOf(endpoint);
|
return observableOf(endpoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DummyChangeAnalyzer implements ChangeAnalyzer<Item> {
|
class DummyChangeAnalyzer implements ChangeAnalyzer<Item> {
|
||||||
diff(object1: Item, object2: Item): Operation[] {
|
diff(object1: Item, object2: Item): Operation[] {
|
||||||
return compare((object1 as any).metadata, (object2 as any).metadata);
|
return compare((object1 as any).metadata, (object2 as any).metadata);
|
||||||
@@ -50,7 +53,7 @@ class DummyChangeAnalyzer implements ChangeAnalyzer<Item> {
|
|||||||
describe('DataService', () => {
|
describe('DataService', () => {
|
||||||
let service: TestService;
|
let service: TestService;
|
||||||
let options: FindListOptions;
|
let options: FindListOptions;
|
||||||
const requestService = {generateRequestId: () => uuidv4()} as RequestService;
|
const requestService = { generateRequestId: () => uuidv4() } as RequestService;
|
||||||
const halService = {} as HALEndpointService;
|
const halService = {} as HALEndpointService;
|
||||||
const rdbService = {} as RemoteDataBuildService;
|
const rdbService = {} as RemoteDataBuildService;
|
||||||
const notificationsService = {} as NotificationsService;
|
const notificationsService = {} as NotificationsService;
|
||||||
@@ -144,7 +147,73 @@ describe('DataService', () => {
|
|||||||
(service as any).getFindAllHref(options).subscribe((value) => {
|
(service as any).getFindAllHref(options).subscribe((value) => {
|
||||||
expect(value).toBe(expected);
|
expect(value).toBe(expected);
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
|
it('should include single linksToFollow as embed', () => {
|
||||||
|
const mockFollowLinkConfig: FollowLinkConfig<Item> = Object.assign(new FollowLinkConfig(), {
|
||||||
|
name: 'bundles' as any,
|
||||||
|
});
|
||||||
|
const expected = `${endpoint}?embed=bundles`;
|
||||||
|
|
||||||
|
(service as any).getFindAllHref({}, null, mockFollowLinkConfig).subscribe((value) => {
|
||||||
|
expect(value).toBe(expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should include multiple linksToFollow as embed', () => {
|
||||||
|
const mockFollowLinkConfig: FollowLinkConfig<Item> = Object.assign(new FollowLinkConfig(), {
|
||||||
|
name: 'bundles' as any,
|
||||||
|
});
|
||||||
|
const mockFollowLinkConfig2: FollowLinkConfig<Item> = Object.assign(new FollowLinkConfig(), {
|
||||||
|
name: 'owningCollection' as any,
|
||||||
|
});
|
||||||
|
const mockFollowLinkConfig3: FollowLinkConfig<Item> = Object.assign(new FollowLinkConfig(), {
|
||||||
|
name: 'templateItemOf' as any,
|
||||||
|
});
|
||||||
|
const expected = `${endpoint}?embed=bundles&embed=owningCollection&embed=templateItemOf`;
|
||||||
|
|
||||||
|
(service as any).getFindAllHref({}, null, mockFollowLinkConfig, mockFollowLinkConfig2, mockFollowLinkConfig3).subscribe((value) => {
|
||||||
|
expect(value).toBe(expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not include linksToFollow with forwardToRest = false', () => {
|
||||||
|
const mockFollowLinkConfig: FollowLinkConfig<Item> = Object.assign(new FollowLinkConfig(), {
|
||||||
|
name: 'bundles' as any,
|
||||||
|
forwardToRest: false,
|
||||||
|
});
|
||||||
|
const mockFollowLinkConfig2: FollowLinkConfig<Item> = Object.assign(new FollowLinkConfig(), {
|
||||||
|
name: 'owningCollection' as any,
|
||||||
|
forwardToRest: false,
|
||||||
|
});
|
||||||
|
const mockFollowLinkConfig3: FollowLinkConfig<Item> = Object.assign(new FollowLinkConfig(), {
|
||||||
|
name: 'templateItemOf' as any,
|
||||||
|
});
|
||||||
|
const expected = `${endpoint}?embed=templateItemOf`;
|
||||||
|
|
||||||
|
(service as any).getFindAllHref({}, null, mockFollowLinkConfig, mockFollowLinkConfig2, mockFollowLinkConfig3).subscribe((value) => {
|
||||||
|
expect(value).toBe(expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should include nested linksToFollow 3lvl', () => {
|
||||||
|
const mockFollowLinkConfig3: FollowLinkConfig<Item> = Object.assign(new FollowLinkConfig(), {
|
||||||
|
name: 'relationships' as any,
|
||||||
|
});
|
||||||
|
const mockFollowLinkConfig2: FollowLinkConfig<Collection> = Object.assign(new FollowLinkConfig(), {
|
||||||
|
name: 'itemtemplate' as any,
|
||||||
|
linksToFollow: mockFollowLinkConfig3,
|
||||||
|
});
|
||||||
|
const mockFollowLinkConfig: FollowLinkConfig<Item> = Object.assign(new FollowLinkConfig(), {
|
||||||
|
name: 'owningCollection' as any,
|
||||||
|
linksToFollow: mockFollowLinkConfig2,
|
||||||
|
});
|
||||||
|
const expected = `${endpoint}?embed=owningCollection/itemtemplate/relationships`;
|
||||||
|
|
||||||
|
(service as any).getFindAllHref({}, null, mockFollowLinkConfig).subscribe((value) => {
|
||||||
|
expect(value).toBe(expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
describe('patch', () => {
|
describe('patch', () => {
|
||||||
let operations;
|
let operations;
|
||||||
|
@@ -83,14 +83,15 @@ export abstract class DataService<T extends CacheableObject> {
|
|||||||
* @param linkPath The link path for the object
|
* @param linkPath The link path for the object
|
||||||
* @return {Observable<string>}
|
* @return {Observable<string>}
|
||||||
* Return an observable that emits created HREF
|
* Return an observable that emits created HREF
|
||||||
|
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved
|
||||||
*/
|
*/
|
||||||
protected getFindAllHref(options: FindListOptions = {}, linkPath?: string): Observable<string> {
|
protected getFindAllHref(options: FindListOptions = {}, linkPath?: string, ...linksToFollow: Array<FollowLinkConfig<T>>): Observable<string> {
|
||||||
let result$: Observable<string>;
|
let result$: Observable<string>;
|
||||||
const args = [];
|
const args = [];
|
||||||
|
|
||||||
result$ = this.getBrowseEndpoint(options, linkPath).pipe(distinctUntilChanged());
|
result$ = this.getBrowseEndpoint(options, linkPath).pipe(distinctUntilChanged());
|
||||||
|
|
||||||
return result$.pipe(map((result: string) => this.buildHrefFromFindOptions(result, options, args)));
|
return result$.pipe(map((result: string) => this.buildHrefFromFindOptions(result, options, args, ...linksToFollow)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -100,8 +101,9 @@ export abstract class DataService<T extends CacheableObject> {
|
|||||||
* @param options The [[FindListOptions]] object
|
* @param options The [[FindListOptions]] object
|
||||||
* @return {Observable<string>}
|
* @return {Observable<string>}
|
||||||
* Return an observable that emits created HREF
|
* Return an observable that emits created HREF
|
||||||
|
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved
|
||||||
*/
|
*/
|
||||||
protected getSearchByHref(searchMethod: string, options: FindListOptions = {}): Observable<string> {
|
protected getSearchByHref(searchMethod: string, options: FindListOptions = {}, ...linksToFollow: Array<FollowLinkConfig<T>>): Observable<string> {
|
||||||
let result$: Observable<string>;
|
let result$: Observable<string>;
|
||||||
const args = [];
|
const args = [];
|
||||||
|
|
||||||
@@ -113,7 +115,7 @@ export abstract class DataService<T extends CacheableObject> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return result$.pipe(map((result: string) => this.buildHrefFromFindOptions(result, options, args)));
|
return result$.pipe(map((result: string) => this.buildHrefFromFindOptions(result, options, args, ...linksToFollow)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -124,8 +126,9 @@ export abstract class DataService<T extends CacheableObject> {
|
|||||||
* @param extraArgs Array with additional params to combine with query string
|
* @param extraArgs Array with additional params to combine with query string
|
||||||
* @return {Observable<string>}
|
* @return {Observable<string>}
|
||||||
* Return an observable that emits created HREF
|
* Return an observable that emits created HREF
|
||||||
|
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved
|
||||||
*/
|
*/
|
||||||
protected buildHrefFromFindOptions(href: string, options: FindListOptions, extraArgs: string[] = []): string {
|
protected buildHrefFromFindOptions(href: string, options: FindListOptions, extraArgs: string[] = [], ...linksToFollow: Array<FollowLinkConfig<T>>): string {
|
||||||
|
|
||||||
let args = [...extraArgs];
|
let args = [...extraArgs];
|
||||||
|
|
||||||
@@ -142,6 +145,7 @@ export abstract class DataService<T extends CacheableObject> {
|
|||||||
if (hasValue(options.startsWith)) {
|
if (hasValue(options.startsWith)) {
|
||||||
args = [...args, `startsWith=${options.startsWith}`];
|
args = [...args, `startsWith=${options.startsWith}`];
|
||||||
}
|
}
|
||||||
|
args = this.addEmbedParams(args, linksToFollow);
|
||||||
if (isNotEmpty(args)) {
|
if (isNotEmpty(args)) {
|
||||||
return new URLCombiner(href, `?${args.join('&')}`).toString();
|
return new URLCombiner(href, `?${args.join('&')}`).toString();
|
||||||
} else {
|
} else {
|
||||||
@@ -149,6 +153,45 @@ export abstract class DataService<T extends CacheableObject> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the embed options to the link for the request
|
||||||
|
* @param args params for the query string
|
||||||
|
* @param linksToFollow links we want to embed in query string if forwardToRest is true
|
||||||
|
*/
|
||||||
|
protected addEmbedParams(args: any, linksToFollow: Array<FollowLinkConfig<T>>) {
|
||||||
|
if (linksToFollow !== undefined) {
|
||||||
|
linksToFollow.forEach((linkToFollow: FollowLinkConfig<T>) => {
|
||||||
|
console.log('linksToFollow', linksToFollow)
|
||||||
|
if (linkToFollow.forwardToRest) {
|
||||||
|
const embedString = 'embed=' + String(linkToFollow.name);
|
||||||
|
const embedWithNestedString = this.addNestedEmbeds(embedString, linkToFollow.linksToFollow);
|
||||||
|
args = [...args, embedWithNestedString];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the nested followLinks to the embed param, recursively, separated by a /
|
||||||
|
* @param embedString
|
||||||
|
* @param linksToFollow
|
||||||
|
*/
|
||||||
|
protected addNestedEmbeds(embedString: string, linksToFollow: Array<FollowLinkConfig<T>>): string {
|
||||||
|
let nestEmbed = embedString;
|
||||||
|
if (linksToFollow !== undefined) {
|
||||||
|
linksToFollow.forEach((linkToFollow: FollowLinkConfig<T>) => {
|
||||||
|
if (linkToFollow.forwardToRest) {
|
||||||
|
nestEmbed = nestEmbed + '/' + String(linkToFollow.name);
|
||||||
|
if (linkToFollow.linksToFollow !== undefined) {
|
||||||
|
nestEmbed = this.addNestedEmbeds(nestEmbed, linkToFollow.linksToFollow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return nestEmbed;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns {@link RemoteData} of all object with a list of {@link FollowLinkConfig}, to indicate which embedded
|
* Returns {@link RemoteData} of all object with a list of {@link FollowLinkConfig}, to indicate which embedded
|
||||||
* info should be added to the objects
|
* info should be added to the objects
|
||||||
@@ -223,7 +266,7 @@ export abstract class DataService<T extends CacheableObject> {
|
|||||||
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved
|
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved
|
||||||
*/
|
*/
|
||||||
findByHref(href: string, ...linksToFollow: Array<FollowLinkConfig<T>>): Observable<RemoteData<T>> {
|
findByHref(href: string, ...linksToFollow: Array<FollowLinkConfig<T>>): Observable<RemoteData<T>> {
|
||||||
const requestHref = this.buildHrefFromFindOptions(href, {}, []);
|
const requestHref = this.buildHrefFromFindOptions(href, {}, [], ...linksToFollow);
|
||||||
const request = new GetRequest(this.requestService.generateRequestId(), requestHref);
|
const request = new GetRequest(this.requestService.generateRequestId(), requestHref);
|
||||||
if (hasValue(this.responseMsToLive)) {
|
if (hasValue(this.responseMsToLive)) {
|
||||||
request.responseMsToLive = this.responseMsToLive;
|
request.responseMsToLive = this.responseMsToLive;
|
||||||
@@ -240,7 +283,7 @@ export abstract class DataService<T extends CacheableObject> {
|
|||||||
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved
|
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved
|
||||||
*/
|
*/
|
||||||
findAllByHref(href: string, findListOptions: FindListOptions = {}, ...linksToFollow: Array<FollowLinkConfig<T>>): Observable<RemoteData<PaginatedList<T>>> {
|
findAllByHref(href: string, findListOptions: FindListOptions = {}, ...linksToFollow: Array<FollowLinkConfig<T>>): Observable<RemoteData<PaginatedList<T>>> {
|
||||||
const requestHref = this.buildHrefFromFindOptions(href, findListOptions, []);
|
const requestHref = this.buildHrefFromFindOptions(href, findListOptions, [], ...linksToFollow);
|
||||||
const request = new GetRequest(this.requestService.generateRequestId(), requestHref);
|
const request = new GetRequest(this.requestService.generateRequestId(), requestHref);
|
||||||
if (hasValue(this.responseMsToLive)) {
|
if (hasValue(this.responseMsToLive)) {
|
||||||
request.responseMsToLive = this.responseMsToLive;
|
request.responseMsToLive = this.responseMsToLive;
|
||||||
@@ -271,7 +314,7 @@ export abstract class DataService<T extends CacheableObject> {
|
|||||||
*/
|
*/
|
||||||
protected searchBy(searchMethod: string, options: FindListOptions = {}, ...linksToFollow: Array<FollowLinkConfig<T>>): Observable<RemoteData<PaginatedList<T>>> {
|
protected searchBy(searchMethod: string, options: FindListOptions = {}, ...linksToFollow: Array<FollowLinkConfig<T>>): Observable<RemoteData<PaginatedList<T>>> {
|
||||||
|
|
||||||
const hrefObs = this.getSearchByHref(searchMethod, options);
|
const hrefObs = this.getSearchByHref(searchMethod, options, ...linksToFollow);
|
||||||
|
|
||||||
return hrefObs.pipe(
|
return hrefObs.pipe(
|
||||||
find((href: string) => hasValue(href)),
|
find((href: string) => hasValue(href)),
|
||||||
|
@@ -23,6 +23,11 @@ export class FollowLinkConfig<R extends HALResource> {
|
|||||||
* use on the retrieved object.
|
* use on the retrieved object.
|
||||||
*/
|
*/
|
||||||
linksToFollow?: Array<FollowLinkConfig<any>>;
|
linksToFollow?: Array<FollowLinkConfig<any>>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forward to rest which links we're following, so these can already be embedded
|
||||||
|
*/
|
||||||
|
forwardToRest? = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,15 +41,19 @@ export class FollowLinkConfig<R extends HALResource> {
|
|||||||
* in a certain way
|
* in a certain way
|
||||||
* @param linksToFollow: a list of {@link FollowLinkConfig}s to
|
* @param linksToFollow: a list of {@link FollowLinkConfig}s to
|
||||||
* use on the retrieved object.
|
* use on the retrieved object.
|
||||||
|
* @param forwardToRest: boolean to check whether to forward info on followLinks to rest,
|
||||||
|
* so these can be embedded, default true
|
||||||
*/
|
*/
|
||||||
export const followLink = <R extends HALResource>(
|
export const followLink = <R extends HALResource>(
|
||||||
linkName: keyof R['_links'],
|
linkName: keyof R['_links'],
|
||||||
findListOptions?: FindListOptions,
|
findListOptions?: FindListOptions,
|
||||||
|
forwardToRest = true,
|
||||||
...linksToFollow: Array<FollowLinkConfig<any>>
|
...linksToFollow: Array<FollowLinkConfig<any>>
|
||||||
): FollowLinkConfig<R> => {
|
): FollowLinkConfig<R> => {
|
||||||
return {
|
return {
|
||||||
name: linkName,
|
name: linkName,
|
||||||
findListOptions,
|
findListOptions,
|
||||||
|
forwardToRest,
|
||||||
linksToFollow
|
linksToFollow
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user