From 8eb28a91e21576cac9548192cc7908a5d2ccf38c Mon Sep 17 00:00:00 2001 From: Anthony Emberson Date: Wed, 9 Oct 2024 15:12:15 +0100 Subject: [PATCH 1/3] feat: added support for custom sorting of hierarchies --- src/lib/ContentClient.spec.ts | 102 ++++++++++++++++++ src/lib/ContentClient.ts | 8 ++ .../coordinators/GetByHierarchy/UrlBuilder.ts | 9 +- .../MULTI_LAYER_RESPONSE_ALT_SORT.json | 35 ++++++ .../MULTI_LAYER_RESPONSE_DESC.json | 49 +++++++++ .../MULTI_LAYER_RESULT_ALT_SORT.json | 47 ++++++++ .../hierarchies/MULTI_LAYER_RESULT_DESC.json | 62 +++++++++++ src/lib/content/model/ByHierachy.ts | 7 ++ 8 files changed, 318 insertions(+), 1 deletion(-) create mode 100644 src/lib/content/coordinators/__fixtures__/v2/hierarchies/MULTI_LAYER_RESPONSE_ALT_SORT.json create mode 100644 src/lib/content/coordinators/__fixtures__/v2/hierarchies/MULTI_LAYER_RESPONSE_DESC.json create mode 100644 src/lib/content/coordinators/__fixtures__/v2/hierarchies/MULTI_LAYER_RESULT_ALT_SORT.json create mode 100644 src/lib/content/coordinators/__fixtures__/v2/hierarchies/MULTI_LAYER_RESULT_DESC.json diff --git a/src/lib/ContentClient.spec.ts b/src/lib/ContentClient.spec.ts index 3d32dd6..671b0fd 100644 --- a/src/lib/ContentClient.spec.ts +++ b/src/lib/ContentClient.spec.ts @@ -12,10 +12,14 @@ import * as V1_SINGLE_RESULT from './content/coordinators/__fixtures__/v1/SINGLE import * as V2_SINGLE_RESULT from './content/coordinators/__fixtures__/v2/SINGLE_RESULT.json'; import * as NO_RESULTS from './content/coordinators/__fixtures__/v2/filterBy/NO_RESULTS.json'; import * as MULTI_LAYER_RESPONSE from './content/coordinators/__fixtures__/v2/hierarchies/MULTI_LAYER_RESPONSE.json'; +import * as MULTI_LAYER_RESPONSE_ALT_SORT from './content/coordinators/__fixtures__/v2/hierarchies/MULTI_LAYER_RESPONSE_ALT_SORT.json'; +import * as MULTI_LAYER_RESPONSE_DESC from './content/coordinators/__fixtures__/v2/hierarchies/MULTI_LAYER_RESPONSE_DESC.json'; +import * as MULTI_LAYER_RESULT_DESC from './content/coordinators/__fixtures__/v2/hierarchies/MULTI_LAYER_RESULT_DESC.json'; import * as MULTI_LAYER_RESULT_FILTERED from './content/coordinators/__fixtures__/v2/hierarchies/MULTI_LAYER_RESULT_FILTERED.json'; import * as MULTI_LAYER_RESULT_FILTERED_AND_MUTATED from './content/coordinators/__fixtures__/v2/hierarchies/MULTI_LAYER_RESULT_FILTER_AND_MUTATE.json'; import * as MULTI_LAYER_RESULT_MUTATED from './content/coordinators/__fixtures__/v2/hierarchies/MULTI_LAYER_RESULT_MUTATED.json'; import * as MULTI_LAYER_RESULT from './content/coordinators/__fixtures__/v2/hierarchies/MULTI_LAYER_RESULT.json'; +import * as MULTI_LAYER_RESULT_ALT_SORT from './content/coordinators/__fixtures__/v2/hierarchies/MULTI_LAYER_RESULT_ALT_SORT.json'; import * as ROOT from './content/coordinators/__fixtures__/v2/hierarchies/ROOT.json'; import { ContentClientConfigV1 } from './config/ContentClientConfigV1'; @@ -477,6 +481,104 @@ describe('ContentClient', () => { expect(response).to.deep.eq(expectedContent); }); + it(`getByHierarchy should sort correctly`, async () => { + const urlBuilder = new HierarchyURLBuilder(); + + const mocks = new MockAdapter(null); + + const expectedBody: DefaultContentBody = { + _meta: new ContentMeta(MULTI_LAYER_RESULT_DESC.content._meta), + propertyName1: MULTI_LAYER_RESULT_DESC.content.propertyName1, + }; + + const expectedContent: HierarchyContentItem = { + content: expectedBody, + children: MULTI_LAYER_RESULT_DESC.children as any, + }; + + const cd2RunConfig = { + name: 'cdv2', + hubName: 'hub', + type: 'cdn', + baseUrl: 'https://hub.cdn.content.amplience.net', + config: { hubName: 'hub' }, + } as ContentClientConfigV2; + + mocks + .onGet( + 'https://hub.cdn.content.amplience.net/content/id/90d6fa96-6ce0-4332-b995-4e6c50b1e233?depth=all&format=inlined' + ) + .reply(200, ROOT); + + mocks + .onGet( + cd2RunConfig.baseUrl + + urlBuilder.buildUrl({ + rootId: ROOT.content._meta.deliveryId, + sortOrder: 'DESC', + }) + ) + .reply(200, MULTI_LAYER_RESPONSE_DESC); + + const mergedConfig = { adaptor: mocks.adapter(), ...cd2RunConfig }; + + const client = new ContentClient(mergedConfig); + const response = await client.getByHierarchy({ + rootId: ROOT.content._meta.deliveryId, + sortOrder: 'DESC', + }); + expect(response).to.deep.eq(expectedContent); + }); + + it(`getByHierarchy should apply custom sorts`, async () => { + const urlBuilder = new HierarchyURLBuilder(); + + const mocks = new MockAdapter(null); + + const expectedBody: DefaultContentBody = { + _meta: new ContentMeta(MULTI_LAYER_RESULT_ALT_SORT.content._meta), + propertyName1: MULTI_LAYER_RESULT_ALT_SORT.content.propertyName1, + }; + + const expectedContent: HierarchyContentItem = { + content: expectedBody, + children: MULTI_LAYER_RESULT_ALT_SORT.children as any, + }; + + const cd2RunConfig = { + name: 'cdv2', + hubName: 'hub', + type: 'cdn', + baseUrl: 'https://hub.cdn.content.amplience.net', + config: { hubName: 'hub' }, + } as ContentClientConfigV2; + + mocks + .onGet( + 'https://hub.cdn.content.amplience.net/content/id/90d6fa96-6ce0-4332-b995-4e6c50b1e233?depth=all&format=inlined' + ) + .reply(200, ROOT); + + mocks + .onGet( + cd2RunConfig.baseUrl + + urlBuilder.buildUrl({ + rootId: ROOT.content._meta.deliveryId, + sortName: '_meta/deliveryId', + }) + ) + .reply(200, MULTI_LAYER_RESPONSE_ALT_SORT); + + const mergedConfig = { adaptor: mocks.adapter(), ...cd2RunConfig }; + + const client = new ContentClient(mergedConfig); + const response = await client.getByHierarchy({ + rootId: ROOT.content._meta.deliveryId, + sortName: '_meta/deliveryId', + }); + expect(response).to.deep.eq(expectedContent); + }); + it(`getByHierarchy should apply filter when building a tree with a filter`, async () => { const urlBuilder = new HierarchyURLBuilder(); diff --git a/src/lib/ContentClient.ts b/src/lib/ContentClient.ts index 2a3c5d4..a21445d 100644 --- a/src/lib/ContentClient.ts +++ b/src/lib/ContentClient.ts @@ -295,6 +295,8 @@ export class ContentClient implements GetContentItemById, GetContentItemByKey { rootId: rootItem.body._meta.deliveryId, maximumDepth: requestParameters.maximumDepth, maximumPageSize: requestParameters.maximumPageSize, + sortOrder: requestParameters.sortOrder, + sortName: requestParameters.sortName, }, rootItem ); @@ -318,6 +320,8 @@ export class ContentClient implements GetContentItemById, GetContentItemByKey { rootId: rootItem.body._meta.deliveryId, maximumDepth: requestParameters.maximumDepth, maximumPageSize: requestParameters.maximumPageSize, + sortOrder: requestParameters.sortOrder, + sortName: requestParameters.sortName, }, rootItem ); @@ -340,6 +344,8 @@ export class ContentClient implements GetContentItemById, GetContentItemByKey { rootId: rootItem.body._meta.deliveryId, maximumDepth: requestParameters.maximumDepth, maximumPageSize: requestParameters.maximumPageSize, + sortOrder: requestParameters.sortOrder, + sortName: requestParameters.sortName, }, rootItem ); @@ -364,6 +370,8 @@ export class ContentClient implements GetContentItemById, GetContentItemByKey { rootId: rootItem.body._meta.deliveryId, maximumDepth: requestParameters.maximumDepth, maximumPageSize: requestParameters.maximumPageSize, + sortOrder: requestParameters.sortOrder, + sortName: requestParameters.sortName, }, rootItem ); diff --git a/src/lib/content/coordinators/GetByHierarchy/UrlBuilder.ts b/src/lib/content/coordinators/GetByHierarchy/UrlBuilder.ts index 07b7fa5..1bc08f3 100644 --- a/src/lib/content/coordinators/GetByHierarchy/UrlBuilder.ts +++ b/src/lib/content/coordinators/GetByHierarchy/UrlBuilder.ts @@ -6,7 +6,8 @@ export class HierarchyURLBuilder { static MAXIMUM_DEPTH_PARAM = 'hierarchyDepth'; static MAXIMUM_PAGE_SIZE_PARAM = 'maxPageSize'; static LAST_EVALUATED_PARAM = 'pageCursor'; - + static CUSTOM_SORT_PARAM = 'sortByKey'; + static SORT_ORDER_PARAM = 'sortByOrder'; buildUrl(request: HierarchyRequest): string { const params: string[][] = []; @@ -28,6 +29,12 @@ export class HierarchyURLBuilder { request.pageCursor.toString(), ]); } + if (request.sortOrder !== undefined) { + params.push([HierarchyURLBuilder.SORT_ORDER_PARAM, request.sortOrder]); + } + if (request.sortOrder !== undefined) { + params.push([HierarchyURLBuilder.SORT_ORDER_PARAM, request.sortOrder]); + } if (params.length > 0) { return `${HierarchyURLBuilder.HIERARCHY_URL}${ request.rootId diff --git a/src/lib/content/coordinators/__fixtures__/v2/hierarchies/MULTI_LAYER_RESPONSE_ALT_SORT.json b/src/lib/content/coordinators/__fixtures__/v2/hierarchies/MULTI_LAYER_RESPONSE_ALT_SORT.json new file mode 100644 index 0000000..3d757db --- /dev/null +++ b/src/lib/content/coordinators/__fixtures__/v2/hierarchies/MULTI_LAYER_RESPONSE_ALT_SORT.json @@ -0,0 +1,35 @@ +{ + "responses": [ + { + "content": { + "_meta": { + "name": "C", + "schema": "https://hierarchies.com", + "hierarchy": { + "parentId": "1ebab07d-acd8-4e19-a614-ec632cdf95d5", + "root": false + }, + "deliveryId": "68676cda-5ab2-4a5e-bcfb-58c5cf3eb8ed" + }, + "propertyName1": "C" + } + }, + { + "content": { + "_meta": { + "name": "A", + "schema": "https://hierarchies.com", + "hierarchy": { + "parentId": "90d6fa96-6ce0-4332-b995-4e6c50b1e233", + "root": false + }, + "deliveryId": "1ebab07d-acd8-4e19-a614-ec632cdf95d5" + }, + "propertyName1": "A" + } + } + ], + "page": { + "responseCount": 3 + } +} diff --git a/src/lib/content/coordinators/__fixtures__/v2/hierarchies/MULTI_LAYER_RESPONSE_DESC.json b/src/lib/content/coordinators/__fixtures__/v2/hierarchies/MULTI_LAYER_RESPONSE_DESC.json new file mode 100644 index 0000000..475376e --- /dev/null +++ b/src/lib/content/coordinators/__fixtures__/v2/hierarchies/MULTI_LAYER_RESPONSE_DESC.json @@ -0,0 +1,49 @@ +{ + "responses": [ + { + "content": { + "_meta": { + "name": "C", + "schema": "https://hierarchies.com", + "hierarchy": { + "parentId": "1ebab07d-acd8-4e19-a614-ec632cdf95d5", + "root": false + }, + "deliveryId": "68676cda-5ab2-4a5e-bcfb-58c5cf3eb8ed" + }, + "propertyName1": "C" + } + }, + { + "content": { + "_meta": { + "name": "B", + "schema": "https://hierarchies.com", + "hierarchy": { + "parentId": "1ebab07d-acd8-4e19-a614-ec632cdf95d5", + "root": false + }, + "deliveryId": "4db37251-0c86-4f45-ad8a-583ebf6efc80" + }, + "propertyName1": "B" + } + }, + { + "content": { + "_meta": { + "name": "A", + "schema": "https://hierarchies.com", + "hierarchy": { + "parentId": "90d6fa96-6ce0-4332-b995-4e6c50b1e233", + "root": false + }, + "deliveryId": "1ebab07d-acd8-4e19-a614-ec632cdf95d5" + }, + "propertyName1": "A" + } + } + ], + "page": { + "responseCount": 3 + } +} diff --git a/src/lib/content/coordinators/__fixtures__/v2/hierarchies/MULTI_LAYER_RESULT_ALT_SORT.json b/src/lib/content/coordinators/__fixtures__/v2/hierarchies/MULTI_LAYER_RESULT_ALT_SORT.json new file mode 100644 index 0000000..cb34251 --- /dev/null +++ b/src/lib/content/coordinators/__fixtures__/v2/hierarchies/MULTI_LAYER_RESULT_ALT_SORT.json @@ -0,0 +1,47 @@ +{ + "content": { + "_meta": { + "name": "Root", + "schema": "https://hierarchies.com", + "hierarchy": { + "root": true + }, + "deliveryId": "90d6fa96-6ce0-4332-b995-4e6c50b1e233" + }, + "propertyName1": "Root" + }, + "children": [ + { + "content": { + "_meta": { + "name": "A", + "schema": "https://hierarchies.com", + "hierarchy": { + "parentId": "90d6fa96-6ce0-4332-b995-4e6c50b1e233", + "root": false + }, + "deliveryId": "1ebab07d-acd8-4e19-a614-ec632cdf95d5" + }, + "propertyName1": "A" + }, + "children": [ + + { + "content": { + "_meta": { + "name": "C", + "schema": "https://hierarchies.com", + "hierarchy": { + "parentId": "1ebab07d-acd8-4e19-a614-ec632cdf95d5", + "root": false + }, + "deliveryId": "68676cda-5ab2-4a5e-bcfb-58c5cf3eb8ed" + }, + "propertyName1": "C" + }, + "children": [] + } + ] + } + ] +} diff --git a/src/lib/content/coordinators/__fixtures__/v2/hierarchies/MULTI_LAYER_RESULT_DESC.json b/src/lib/content/coordinators/__fixtures__/v2/hierarchies/MULTI_LAYER_RESULT_DESC.json new file mode 100644 index 0000000..0ab159a --- /dev/null +++ b/src/lib/content/coordinators/__fixtures__/v2/hierarchies/MULTI_LAYER_RESULT_DESC.json @@ -0,0 +1,62 @@ +{ + "content": { + "_meta": { + "name": "Root", + "schema": "https://hierarchies.com", + "hierarchy": { + "root": true + }, + "deliveryId": "90d6fa96-6ce0-4332-b995-4e6c50b1e233" + }, + "propertyName1": "Root" + }, + "children": [ + { + "content": { + "_meta": { + "name": "A", + "schema": "https://hierarchies.com", + "hierarchy": { + "parentId": "90d6fa96-6ce0-4332-b995-4e6c50b1e233", + "root": false + }, + "deliveryId": "1ebab07d-acd8-4e19-a614-ec632cdf95d5" + }, + "propertyName1": "A" + }, + "children": [ + + { + "content": { + "_meta": { + "name": "C", + "schema": "https://hierarchies.com", + "hierarchy": { + "parentId": "1ebab07d-acd8-4e19-a614-ec632cdf95d5", + "root": false + }, + "deliveryId": "68676cda-5ab2-4a5e-bcfb-58c5cf3eb8ed" + }, + "propertyName1": "C" + }, + "children": [] + }, + { + "content": { + "_meta": { + "name": "B", + "schema": "https://hierarchies.com", + "hierarchy": { + "parentId": "1ebab07d-acd8-4e19-a614-ec632cdf95d5", + "root": false + }, + "deliveryId": "4db37251-0c86-4f45-ad8a-583ebf6efc80" + }, + "propertyName1": "B" + }, + "children": [] + } + ] + } + ] +} diff --git a/src/lib/content/model/ByHierachy.ts b/src/lib/content/model/ByHierachy.ts index e4536e3..17c993a 100644 --- a/src/lib/content/model/ByHierachy.ts +++ b/src/lib/content/model/ByHierachy.ts @@ -1,12 +1,15 @@ import { IContentMeta } from './ContentMeta'; import { ContentBody } from './ContentBody'; import { ContentItem } from './ContentItem'; +import { IOrder } from './FilterBy'; export interface HierarchyRequest { rootId: string; maximumDepth?: number; maximumPageSize?: number; pageCursor?: string; + sortName?: string; + sortOrder?: IOrder; } /** @@ -15,6 +18,8 @@ export interface HierarchyRequest { * @member rootItem (optional) to pass the root item if it has already been fetched * @member maximumDepth (optional) specifies the maximum depth of the hierarchy query * @member maximumPageSize (optional) specifies the maximum page size for each page of the hierarchy, + * @member sortOrder (optional) specifies the sort the service should use when retrieving content from the database + * @member sortName (optional) specifies the name of the sort parameter used to retrieve content, this can effect what content is returned * note: maximumDepth and maximumPageSize will not override the limits set by the delivery service. */ export interface ContentClientHierarchyRequest { @@ -22,6 +27,8 @@ export interface ContentClientHierarchyRequest { maximumDepth?: number; maximumPageSize?: number; rootItem?: ContentItem; + sortName?: string; + sortOrder?: IOrder; } export interface HierarchyPage { From 00a0faf0162be95ef3244b08073ad84fd6034851 Mon Sep 17 00:00:00 2001 From: Anthony Emberson Date: Mon, 14 Oct 2024 15:12:39 +0100 Subject: [PATCH 2/3] chore: testing update --- src/lib/ContentClient.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/ContentClient.spec.ts b/src/lib/ContentClient.spec.ts index 2dd7e58..8c77cd1 100644 --- a/src/lib/ContentClient.spec.ts +++ b/src/lib/ContentClient.spec.ts @@ -527,7 +527,7 @@ describe('ContentClient', () => { rootId: ROOT.content._meta.deliveryId, sortOrder: 'DESC', }); - expect(response).to.deep.eq(expectedContent); + expect(response).to.deep.eq(JSON.parse(JSON.stringify(expectedContent))); }); it(`getByHierarchy should apply custom sorts`, async () => { @@ -576,7 +576,7 @@ describe('ContentClient', () => { rootId: ROOT.content._meta.deliveryId, sortName: '_meta/deliveryId', }); - expect(response).to.deep.eq(expectedContent); + expect(response).to.deep.eq(JSON.parse(JSON.stringify(expectedContent))); }); it(`getByHierarchy should apply filter when building a tree with a filter`, async () => { From c2cd4716139e159d507d8820448b8a301c0eb695 Mon Sep 17 00:00:00 2001 From: Anthony Emberson Date: Thu, 24 Oct 2024 12:35:08 +0100 Subject: [PATCH 3/3] refactor: disambiguated sortKey name and fixed bug in URLbuilder --- src/lib/ContentClient.spec.ts | 4 ++-- src/lib/ContentClient.ts | 8 +++---- .../GetByHierarchy/GetHierarchyImpl.spec.ts | 23 ++++++++++++++++++- .../coordinators/GetByHierarchy/UrlBuilder.ts | 6 ++--- src/lib/content/model/ByHierachy.ts | 6 ++--- 5 files changed, 34 insertions(+), 13 deletions(-) diff --git a/src/lib/ContentClient.spec.ts b/src/lib/ContentClient.spec.ts index 8c77cd1..45f537f 100644 --- a/src/lib/ContentClient.spec.ts +++ b/src/lib/ContentClient.spec.ts @@ -564,7 +564,7 @@ describe('ContentClient', () => { cd2RunConfig.baseUrl + urlBuilder.buildUrl({ rootId: ROOT.content._meta.deliveryId, - sortName: '_meta/deliveryId', + sortKey: '_meta/deliveryId', }) ) .reply(200, MULTI_LAYER_RESPONSE_ALT_SORT); @@ -574,7 +574,7 @@ describe('ContentClient', () => { const client = new ContentClient(mergedConfig); const response = await client.getByHierarchy({ rootId: ROOT.content._meta.deliveryId, - sortName: '_meta/deliveryId', + sortKey: '_meta/deliveryId', }); expect(response).to.deep.eq(JSON.parse(JSON.stringify(expectedContent))); }); diff --git a/src/lib/ContentClient.ts b/src/lib/ContentClient.ts index a21445d..6d6443b 100644 --- a/src/lib/ContentClient.ts +++ b/src/lib/ContentClient.ts @@ -296,7 +296,7 @@ export class ContentClient implements GetContentItemById, GetContentItemByKey { maximumDepth: requestParameters.maximumDepth, maximumPageSize: requestParameters.maximumPageSize, sortOrder: requestParameters.sortOrder, - sortName: requestParameters.sortName, + sortKey: requestParameters.sortKey, }, rootItem ); @@ -321,7 +321,7 @@ export class ContentClient implements GetContentItemById, GetContentItemByKey { maximumDepth: requestParameters.maximumDepth, maximumPageSize: requestParameters.maximumPageSize, sortOrder: requestParameters.sortOrder, - sortName: requestParameters.sortName, + sortKey: requestParameters.sortKey, }, rootItem ); @@ -345,7 +345,7 @@ export class ContentClient implements GetContentItemById, GetContentItemByKey { maximumDepth: requestParameters.maximumDepth, maximumPageSize: requestParameters.maximumPageSize, sortOrder: requestParameters.sortOrder, - sortName: requestParameters.sortName, + sortKey: requestParameters.sortKey, }, rootItem ); @@ -371,7 +371,7 @@ export class ContentClient implements GetContentItemById, GetContentItemByKey { maximumDepth: requestParameters.maximumDepth, maximumPageSize: requestParameters.maximumPageSize, sortOrder: requestParameters.sortOrder, - sortName: requestParameters.sortName, + sortKey: requestParameters.sortKey, }, rootItem ); diff --git a/src/lib/content/coordinators/GetByHierarchy/GetHierarchyImpl.spec.ts b/src/lib/content/coordinators/GetByHierarchy/GetHierarchyImpl.spec.ts index d3bb051..b11220d 100644 --- a/src/lib/content/coordinators/GetByHierarchy/GetHierarchyImpl.spec.ts +++ b/src/lib/content/coordinators/GetByHierarchy/GetHierarchyImpl.spec.ts @@ -84,7 +84,6 @@ describe('getByHierarchies', () => { '/content/hierarchies/descendants/id/testId?hierarchyDepth=3&maxPageSize=5&pageCursor=LEKEY' ); }); - it('Url should be constructed properly without max depth', () => { const hierachyURL: HierarchyURLBuilder = new HierarchyURLBuilder(); const request: HierarchyRequest = { @@ -118,6 +117,28 @@ describe('getByHierarchies', () => { '/content/hierarchies/descendants/id/testId?pageCursor=LEKEY' ); }); + it('Url should be constructed properly with sort key', () => { + const hierachyURL: HierarchyURLBuilder = new HierarchyURLBuilder(); + const request: HierarchyRequest = { + rootId: 'testId', + sortKey: '_meta/JSON/ID', + }; + const result = hierachyURL.buildUrl(request); + expect(result).to.deep.eq( + '/content/hierarchies/descendants/id/testId?sortByKey=_meta%2FJSON%2FID' + ); + }); + it('Url should be constructed properly with sort order', () => { + const hierachyURL: HierarchyURLBuilder = new HierarchyURLBuilder(); + const request: HierarchyRequest = { + rootId: 'testId', + sortOrder: 'DESC', + }; + const result = hierachyURL.buildUrl(request); + expect(result).to.deep.eq( + '/content/hierarchies/descendants/id/testId?sortByOrder=DESC' + ); + }); }); describe('Should correctly retrieve and build flat hierarchies', () => { diff --git a/src/lib/content/coordinators/GetByHierarchy/UrlBuilder.ts b/src/lib/content/coordinators/GetByHierarchy/UrlBuilder.ts index 1bc08f3..863c96d 100644 --- a/src/lib/content/coordinators/GetByHierarchy/UrlBuilder.ts +++ b/src/lib/content/coordinators/GetByHierarchy/UrlBuilder.ts @@ -6,7 +6,7 @@ export class HierarchyURLBuilder { static MAXIMUM_DEPTH_PARAM = 'hierarchyDepth'; static MAXIMUM_PAGE_SIZE_PARAM = 'maxPageSize'; static LAST_EVALUATED_PARAM = 'pageCursor'; - static CUSTOM_SORT_PARAM = 'sortByKey'; + static SORT_KEY_PARAM = 'sortByKey'; static SORT_ORDER_PARAM = 'sortByOrder'; buildUrl(request: HierarchyRequest): string { const params: string[][] = []; @@ -29,8 +29,8 @@ export class HierarchyURLBuilder { request.pageCursor.toString(), ]); } - if (request.sortOrder !== undefined) { - params.push([HierarchyURLBuilder.SORT_ORDER_PARAM, request.sortOrder]); + if (request.sortKey !== undefined) { + params.push([HierarchyURLBuilder.SORT_KEY_PARAM, request.sortKey]); } if (request.sortOrder !== undefined) { params.push([HierarchyURLBuilder.SORT_ORDER_PARAM, request.sortOrder]); diff --git a/src/lib/content/model/ByHierachy.ts b/src/lib/content/model/ByHierachy.ts index 17c993a..acf8529 100644 --- a/src/lib/content/model/ByHierachy.ts +++ b/src/lib/content/model/ByHierachy.ts @@ -8,7 +8,7 @@ export interface HierarchyRequest { maximumDepth?: number; maximumPageSize?: number; pageCursor?: string; - sortName?: string; + sortKey?: string; sortOrder?: IOrder; } @@ -19,7 +19,7 @@ export interface HierarchyRequest { * @member maximumDepth (optional) specifies the maximum depth of the hierarchy query * @member maximumPageSize (optional) specifies the maximum page size for each page of the hierarchy, * @member sortOrder (optional) specifies the sort the service should use when retrieving content from the database - * @member sortName (optional) specifies the name of the sort parameter used to retrieve content, this can effect what content is returned + * @member sortKey (optional) specifies the name of the sort parameter used to retrieve content, this can effect what content is returned * note: maximumDepth and maximumPageSize will not override the limits set by the delivery service. */ export interface ContentClientHierarchyRequest { @@ -27,7 +27,7 @@ export interface ContentClientHierarchyRequest { maximumDepth?: number; maximumPageSize?: number; rootItem?: ContentItem; - sortName?: string; + sortKey?: string; sortOrder?: IOrder; }