Skip to content

Commit

Permalink
Add supplementary data to KiwiPage (#29)
Browse files Browse the repository at this point in the history
Closes #28
  • Loading branch information
chrisrohr authored Jul 6, 2023
1 parent 3568bfc commit 52c5dbc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions __tests__/search/kiwi-page.t.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ describe('KiwiPage', () => {
});
});

describe('addSupplementaryData', () => {
it('should set the supplementary data on the KiwiPage', () => {
const page = KiwiPage.of(10, 1, 100, []);
page.addSupplementaryData({ aggregations: {} });

expect(page.supplementaryData).toEqual({ aggregations: {}});
});
});

describe('usingZeroAsFirstPage', () => {
it('should set pagingStartsWith to zero', () => {
const page = KiwiPage.of(10, 1, 100, []);
Expand Down
10 changes: 10 additions & 0 deletions src/search/kiwi-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ export class KiwiPage {
*/
pagingStartsWith: number = 0;

/**
* Optional extra supplementary data related to the page
*/
supplementaryData: object = {};

constructor(content: object[], size: number, number: number, numberOfElements: number, totalPages: number, totalElements: number, sort: KiwiSort) {
this.content = content;
this.size = size;
Expand Down Expand Up @@ -99,4 +104,9 @@ export class KiwiPage {
isSorted(): boolean {
return this.sort !== undefined && this.sort !== null;
}

addSupplementaryData(supplementaryData: object): this {
this.supplementaryData = supplementaryData;
return this;
}
}

0 comments on commit 52c5dbc

Please sign in to comment.