Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ab47470

Browse filesBrowse files
zfcbVic-Dev
authored andcommitted
feat(BBD-852): Javascript API Updated for RestrictID and Sort By ID (#82)
1 parent 2272c54 commit ab47470
Copy full SHA for ab47470

4 files changed

+23-19Lines changed: 23 additions & 19 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/models/request.ts‎

Copy file name to clipboardExpand all lines: src/models/request.ts
+9-2Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,15 @@ export interface Request {
3434
wildcardSearchEnabled: boolean;
3535
}
3636

37+
export namespace Sort {
38+
export type Type = 'ByIds' | 'Field';
39+
}
40+
3741
export interface Sort {
38-
field: string;
39-
order: SortOrder;
42+
type: Sort.Type;
43+
ids?: string[];
44+
field?: string;
45+
order?: SortOrder;
4046
}
4147

4248
export interface CustomUrlParam {
@@ -79,6 +85,7 @@ export interface Bias {
7985

8086
export interface Biasing {
8187
bringToTop?: string[];
88+
restrictToIds?: string[];
8289
augmentBiases: boolean;
8390
biases: Bias[];
8491
influence?: number;
Collapse file

‎test/unit/core/query.ts‎

Copy file name to clipboardExpand all lines: test/unit/core/query.ts
+10-7Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ suite('Query', ({ expect }) => {
4040
id: ''
4141
})
4242
.withQueryParams('?what=unused')
43-
.withSorts({ field: 'price', order: 'Ascending' }, { field: 'boost', order: 'Descending' })
43+
.withSorts({ type: 'Field', field: 'price', order: 'Ascending' },
44+
{ type: 'Field', field: 'boost', order: 'Descending' })
4445
.withPageSize(300)
4546
.skip(40)
4647
.restrictNavigation({
@@ -221,23 +222,25 @@ suite('Query', ({ expect }) => {
221222

222223
it('should allow sorts to be unselected', () => {
223224
query.withQuery('')
224-
.withSorts({ field: 'this', order: 'Ascending' }, { field: 'that', order: 'Descending' });
225+
.withSorts({ type: 'Field', field: 'this', order: 'Ascending' },
226+
{ type: 'Field', field: 'that', order: 'Descending' });
225227
expect(query.raw.sort.length).to.eq(2);
226-
query.withoutSorts({ field: 'that', order: 'Ascending' });
228+
query.withoutSorts({ type: 'Field', field: 'that', order: 'Ascending' });
227229
expect(query.raw.sort.length).to.eq(1);
228230
expect(query.raw.sort[0].field).to.eq('this');
229-
query.withoutSorts({ field: 'this', order: 'Ascending' });
231+
query.withoutSorts({ type: 'Field', field: 'this', order: 'Ascending' });
230232
expect(query.raw.sort.length).to.eq(0);
231233
});
232234

233235
it('should default query to empty string', () => {
234236
const noQuery = new Query();
235-
query.withSorts({ field: 'this', order: 'Ascending' }, { field: 'that', order: 'Descending' });
237+
query.withSorts({ type: 'Field', field: 'this', order: 'Ascending' },
238+
{ type: 'Field', field: 'that', order: 'Descending' });
236239
expect(query.raw.sort.length).to.eq(2);
237-
query.withoutSorts({ field: 'that', order: 'Ascending' });
240+
query.withoutSorts({ type: 'Field', field: 'that', order: 'Ascending' });
238241
expect(query.raw.sort.length).to.eq(1);
239242
expect(query.raw.sort[0].field).to.eq('this');
240-
query.withoutSorts({ field: 'this', order: 'Ascending' });
243+
query.withoutSorts({ type: 'Field', field: 'this', order: 'Ascending' });
241244
expect(query.raw.sort.length).to.eq(0);
242245
});
243246
});
Collapse file

‎test/unit/fixtures.ts‎

Copy file name to clipboardExpand all lines: test/unit/fixtures.ts
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
export let COMPLEX_REQUEST = {
22
query: 'complex',
33
sort: [
4-
{ field: 'price', order: 'Ascending' },
5-
{ field: 'boost', order: 'Descending' }
4+
{ type: 'Field', field: 'price', order: 'Ascending' },
5+
{ type: 'Field', field: 'boost', order: 'Descending' }
66
],
77
fields: ['title', 'description'],
88
orFields: ['brand', 'colour'],
@@ -39,8 +39,8 @@ export let COMPLEX_REQUEST = {
3939
export let BULK_REQUEST = {
4040
query: 'bulk',
4141
sort: [
42-
{ field: 'price', order: 'Ascending' },
43-
{ field: 'boost', order: 'Descending' }
42+
{ type: 'Field', field: 'price', order: 'Ascending' },
43+
{ type: 'Field', field: 'boost', order: 'Descending' }
4444
],
4545
fields: ['title', 'description'],
4646
orFields: ['brand', 'colour'],
Collapse file

‎yarn.lock‎

Copy file name to clipboardExpand all lines: yarn.lock
-6Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,12 +287,6 @@ aws4@^1.2.1:
287287
version "1.5.0"
288288
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.5.0.tgz#0a29ffb79c31c9e712eeb087e8e7a64b4a56d755"
289289

290-
axios@^0.12.0:
291-
version "0.12.0"
292-
resolved "https://registry.yarnpkg.com/axios/-/axios-0.12.0.tgz#b907b0221cc34ec1c9fac18ec7f07ddf95785ba4"
293-
dependencies:
294-
follow-redirects "0.0.7"
295-
296290
babel-code-frame@^6.16.0, babel-code-frame@^6.22.0:
297291
version "6.22.0"
298292
resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.22.0.tgz#027620bee567a88c32561574e7fd0801d33118e4"

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.