Skip to content

Commit 664665a

Browse files
authored
Merge pull request #90 from Relewise/feat/prelease-2-5
feat: prerelease version 2.5.0
2 parents b2c008e + 5df44b7 commit 664665a

File tree

8 files changed

+69
-50
lines changed

8 files changed

+69
-50
lines changed

packages/client/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@relewise/client",
3-
"version": "2.4.0",
3+
"version": "2.5.0-alpha.1",
44
"description": "Relewise is a next generation personalization SaaS-platform, which offers functionality within product- and content recommendations and personalized search. This official SDK helps you interact with our API.",
55
"repository": {
66
"type": "git",
@@ -32,7 +32,7 @@
3232
"prebuild:types": "rimraf ./build",
3333
"build:types": "tsc -p ./tsconfig.json --outDir build --declaration true && api-extractor run",
3434
"clean": "rimraf ./build ./dist ./docs",
35-
"gen-api": "swagger-typescript-api -p https://api.relewise.com/public/swagger.json -o src/models --modular --no-client --enum-names-as-values && node fix-exports.js",
35+
"gen-api": "swagger-typescript-api -p https://stage01-api.relewise.com/public/swagger.json -o src/models --modular --no-client --enum-names-as-values && node fix-exports.js",
3636
"gen-api-dev": "swagger-typescript-api -p swagger.json -o src/models --modular --no-client --enum-names-as-values && node fix-exports.js",
3737
"publish": "npm run gen-api && npm run build && npm run build:types"
3838
},

packages/client/src/builders/search/contentHighlightingBuilder.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ContentHighlightProps, ContentSearchSettingsHighlightSettings, HighlightSettings2ContentContentHighlightPropsHighlightSettings2Limits, HighlightSettings2ContentContentHighlightPropsHighlightSettings2ResponseShape, HighlightSettings2ContentContentHighlightPropsHighlightSettings2TextSnippetsSettings } from '../../models/data-contracts';
1+
import { ContentHighlightProps, ContentSearchSettingsHighlightSettings, HighlightSettings2ContentContentHighlightPropsHighlightSettings2Limits, HighlightSettings2ContentContentHighlightPropsHighlightSettings2ResponseShape } from '../../models/data-contracts';
22

33
export class ContentHighlightingBuilder {
44
private enabledState: boolean = true;
@@ -7,9 +7,7 @@ export class ContentHighlightingBuilder {
77
displayName: false
88
};
99
private limit: HighlightSettings2ContentContentHighlightPropsHighlightSettings2Limits = {};
10-
private shape: HighlightSettings2ContentContentHighlightPropsHighlightSettings2ResponseShape = {
11-
includeOffsets: false
12-
};
10+
private shape: HighlightSettings2ContentContentHighlightPropsHighlightSettings2ResponseShape = { };
1311

1412
public enabled(enabled: boolean): this {
1513
this.enabledState = enabled;
@@ -30,9 +28,8 @@ export class ContentHighlightingBuilder {
3028
return this;
3129
}
3230

33-
public setShape(shape: { includeOffsets: boolean, textSnippets?: HighlightSettings2ContentContentHighlightPropsHighlightSettings2TextSnippetsSettings }): this {
34-
this.shape.includeOffsets = shape.includeOffsets;
35-
this.shape.textSnippets = shape.textSnippets;
31+
public setShape(shape: HighlightSettings2ContentContentHighlightPropsHighlightSettings2ResponseShape): this {
32+
this.shape = shape;
3633

3734
return this;
3835
}

packages/client/src/builders/search/productHighlightingBuilder.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { HighlightSettings2ProductProductHighlightPropsHighlightSettings2Limits, HighlightSettings2ProductProductHighlightPropsHighlightSettings2ResponseShape, HighlightSettings2ProductProductHighlightPropsHighlightSettings2TextSnippetsSettings, ProductHighlightProps, ProductSearchSettingsHighlightSettings } from '../../models/data-contracts';
1+
import { HighlightSettings2ProductProductHighlightPropsHighlightSettings2Limits, HighlightSettings2ProductProductHighlightPropsHighlightSettings2ResponseShape, ProductHighlightProps, ProductSearchSettingsHighlightSettings } from '../../models/data-contracts';
22

33
export class ProductHighlightingBuilder {
44
private enabledState: boolean = true;
@@ -8,7 +8,6 @@ export class ProductHighlightingBuilder {
88
};
99
private limit: HighlightSettings2ProductProductHighlightPropsHighlightSettings2Limits = {};
1010
private shape: HighlightSettings2ProductProductHighlightPropsHighlightSettings2ResponseShape = {
11-
includeOffsets: false
1211
};
1312

1413
public enabled(enabled: boolean): this {
@@ -30,9 +29,8 @@ export class ProductHighlightingBuilder {
3029
return this;
3130
}
3231

33-
public setShape(shape: { includeOffsets: boolean, textSnippets?: HighlightSettings2ProductProductHighlightPropsHighlightSettings2TextSnippetsSettings }): this {
34-
this.shape.includeOffsets = shape.includeOffsets;
35-
this.shape.textSnippets = shape.textSnippets;
32+
public setShape(shape: HighlightSettings2ProductProductHighlightPropsHighlightSettings2ResponseShape): this {
33+
this.shape = shape;
3634

3735
return this;
3836
}

packages/client/src/models/data-contracts.ts

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ export type BrandFacet = StringValueFacet;
423423
export type BrandFacetResult = StringBrandNameAndIdResultValueFacetResult;
424424

425425
export type BrandIdFilter = Filter & {
426-
brandIds: string[];
426+
brandIds?: string[] | null;
427427
};
428428

429429
export type BrandIdRelevanceModifier = RelevanceModifier & {
@@ -2357,8 +2357,22 @@ export interface HighlightResultOffset {
23572357
}
23582358

23592359
export interface HighlightResultSnippet {
2360-
displayName: string[];
2361-
data: StringStringArrayKeyValuePair[];
2360+
displayName: HighlightResultSnippetDisplayNameSnippetMatch[];
2361+
data: StringFieldSnippetMatchArrayKeyValuePair[];
2362+
}
2363+
2364+
export type HighlightResultSnippetDisplayNameSnippetMatch = HighlightResultSnippetSnippetMatch;
2365+
2366+
export type HighlightResultSnippetFieldSnippetMatch = HighlightResultSnippetSnippetMatch;
2367+
2368+
export interface HighlightResultSnippetMatchMatchedWord {
2369+
offset?: Int32Range | null;
2370+
}
2371+
2372+
export interface HighlightResultSnippetSnippetMatch {
2373+
$type: string;
2374+
text: string;
2375+
matchedWords?: HighlightResultSnippetMatchMatchedWord[] | null;
23622376
}
23632377

23642378
export interface HighlightSettings2ContentContentHighlightPropsHighlightSettings2Limits {
@@ -2378,14 +2392,19 @@ export interface HighlightSettings2ContentContentHighlightPropsHighlightSettings
23782392
maxSentencesToIncludeAfterMatch?: number | null;
23792393
}
23802394

2395+
export interface HighlightSettings2ContentContentHighlightPropsHighlightSettings2OffsetSettings {
2396+
include: boolean;
2397+
}
2398+
23812399
export interface HighlightSettings2ContentContentHighlightPropsHighlightSettings2ResponseShape {
2382-
includeOffsets: boolean;
2383-
textSnippets?: HighlightSettings2ContentContentHighlightPropsHighlightSettings2TextSnippetsSettings | null;
2400+
offsets?: HighlightSettings2ContentContentHighlightPropsHighlightSettings2OffsetSettings | null;
2401+
snippets?: HighlightSettings2ContentContentHighlightPropsHighlightSettings2SnippetsSettings | null;
23842402
}
23852403

2386-
export interface HighlightSettings2ContentContentHighlightPropsHighlightSettings2TextSnippetsSettings {
2387-
includeTextSnippets: boolean;
2388-
includeEllipses: boolean;
2404+
export interface HighlightSettings2ContentContentHighlightPropsHighlightSettings2SnippetsSettings {
2405+
include: boolean;
2406+
useEllipses: boolean;
2407+
includeMatchedWords: boolean;
23892408
}
23902409

23912410
export interface HighlightSettings2ProductProductHighlightPropsHighlightSettings2Limits {
@@ -2405,14 +2424,19 @@ export interface HighlightSettings2ProductProductHighlightPropsHighlightSettings
24052424
maxSentencesToIncludeAfterMatch?: number | null;
24062425
}
24072426

2427+
export interface HighlightSettings2ProductProductHighlightPropsHighlightSettings2OffsetSettings {
2428+
include: boolean;
2429+
}
2430+
24082431
export interface HighlightSettings2ProductProductHighlightPropsHighlightSettings2ResponseShape {
2409-
includeOffsets: boolean;
2410-
textSnippets?: HighlightSettings2ProductProductHighlightPropsHighlightSettings2TextSnippetsSettings | null;
2432+
offsets?: HighlightSettings2ProductProductHighlightPropsHighlightSettings2OffsetSettings | null;
2433+
snippets?: HighlightSettings2ProductProductHighlightPropsHighlightSettings2SnippetsSettings | null;
24112434
}
24122435

2413-
export interface HighlightSettings2ProductProductHighlightPropsHighlightSettings2TextSnippetsSettings {
2414-
includeTextSnippets: boolean;
2415-
includeEllipses: boolean;
2436+
export interface HighlightSettings2ProductProductHighlightPropsHighlightSettings2SnippetsSettings {
2437+
include: boolean;
2438+
useEllipses: boolean;
2439+
includeMatchedWords: boolean;
24162440
}
24172441

24182442
export type HtmlParser = Parser;
@@ -5324,6 +5348,11 @@ export interface StringDataObjectValueFacetResult {
53245348
field: "Category" | "Assortment" | "ListPrice" | "SalesPrice" | "Brand" | "Data" | "VariantSpecification" | "User";
53255349
}
53265350

5351+
export interface StringFieldSnippetMatchArrayKeyValuePair {
5352+
key: string;
5353+
value: HighlightResultSnippetFieldSnippetMatch[];
5354+
}
5355+
53275356
export interface StringProductCategoryDataValueFacet {
53285357
$type: string;
53295358
key: string;
@@ -5367,11 +5396,6 @@ export interface StringRange1ArrayKeyValuePair {
53675396
value: Int32Range[];
53685397
}
53695398

5370-
export interface StringStringArrayKeyValuePair {
5371-
key: string;
5372-
value: string[];
5373-
}
5374-
53755399
export interface StringStringKeyValuePair {
53765400
key: string;
53775401
value: string;

packages/client/tests/integration-tests/contentSearch.integration.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,14 @@ test('Highlighting', async() => {
4545
h.setLimit({ maxWordsBeforeMatch: 3 })
4646
// You have to specify to include the offset.
4747
// Currently offset is the only way to get a result, so if not set, you won't get a result.
48-
h.setShape({ includeOffsets: true, textSnippets: { includeTextSnippets: true, includeEllipses: true } })
48+
h.setShape({
49+
offsets: { include: true },
50+
snippets: { include: true, includeMatchedWords: true, useEllipses: true }
51+
})
4952
}).build();
5053

5154
const result = await searcher.searchContents(request);
5255

5356
expect(result?.results![0].highlight?.offsets?.data[0].value.length).toBeGreaterThan(0);
54-
expect(result?.results![0].highlight?.snippets?.data[0].value[0]).toBe("...word should be highlighted");
57+
expect(result?.results![0].highlight?.snippets?.data[0].value[0].text).toBe("...word should be highlighted");
5558
})

packages/client/tests/integration-tests/productSearch.integration.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,13 @@ test('Highlighting', async() => {
102102
h.setHighlightable({ dataKeys: ['SomeString'] })
103103
// You have to specify to include the offset.
104104
// Currently offset is the only way to get a result, so if not set, you won't get a result.
105-
h.setShape({ includeOffsets: true, textSnippets: { includeTextSnippets: true, includeEllipses: true } })
105+
h.setShape({
106+
offsets: { include: true },
107+
snippets: { include: true, includeMatchedWords: true, useEllipses: true }
108+
})
106109
}).build();
107110
const result = await searcher.searchProducts(request);
108111

109112
expect(result?.results![0].highlight?.offsets?.data[0].value.length).toBeGreaterThan(0);
110-
expect(result?.results![0].highlight?.snippets?.data[0].value[0]).toBe("SomeValue");
113+
expect(result?.results![0].highlight?.snippets?.data[0].value[0].text).toBe("SomeValue");
111114
})

packages/client/tests/unit-tests/builders/search/contentSearchBuilder.unit.test.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,8 @@ test('searchHightlighting', () => {
2626
maxSnippetsPerField: 3
2727
});
2828
h.setShape({
29-
includeOffsets: true,
30-
textSnippets: {
31-
includeEllipses: true,
32-
includeTextSnippets: true
33-
}
29+
offsets: { include: true },
30+
snippets: { include: true, includeMatchedWords: true, useEllipses: true }
3431
});
3532
}).build();
3633

@@ -41,6 +38,6 @@ test('searchHightlighting', () => {
4138
expect(subject.settings?.highlight?.limit.maxEntryLimit).toBe(1);
4239
expect(subject.settings?.highlight?.limit.maxSnippetsPerEntry).toBe(2);
4340
expect(subject.settings?.highlight?.limit.maxSnippetsPerField).toBe(3);
44-
expect(subject.settings?.highlight?.shape.includeOffsets).toBe(true);
45-
expect(subject.settings?.highlight?.shape.textSnippets?.includeTextSnippets).toBe(true);
41+
expect(subject.settings?.highlight?.shape.offsets?.include).toBe(true);
42+
expect(subject.settings?.highlight?.shape.snippets?.include).toBe(true);
4643
});

packages/client/tests/unit-tests/builders/search/productSearchBuilder.unit.test.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,8 @@ test('searchHightlighting', () => {
120120
maxSnippetsPerField: 3
121121
});
122122
h.setShape({
123-
includeOffsets: true,
124-
textSnippets: {
125-
includeEllipses: true,
126-
includeTextSnippets: true,
127-
}
123+
offsets: { include: true },
124+
snippets: { include: true, includeMatchedWords: true, useEllipses: true }
128125
});
129126
}).build();
130127

@@ -135,8 +132,8 @@ test('searchHightlighting', () => {
135132
expect(subject.settings?.highlight?.limit.maxEntryLimit).toBe(1);
136133
expect(subject.settings?.highlight?.limit.maxSnippetsPerEntry).toBe(2);
137134
expect(subject.settings?.highlight?.limit.maxSnippetsPerField).toBe(3);
138-
expect(subject.settings?.highlight?.shape.includeOffsets).toBe(true);
139-
expect(subject.settings?.highlight?.shape.textSnippets?.includeTextSnippets).toBe(true);
135+
expect(subject.settings?.highlight?.shape.offsets?.include).toBe(true);
136+
expect(subject.settings?.highlight?.shape.snippets?.include).toBe(true);
140137
});
141138

142139
test('includeDisabled in ProductHasVariantsFilter', () => {

0 commit comments

Comments
 (0)