-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5ea6dea
commit 3562080
Showing
10 changed files
with
308 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
packages/client/src/builders/search/contentHighlightingBuilder.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { ContentHighlightProps, ContentSearchSettingsHighlightSettings, HighlightSettings2ContentContentHighlightPropsHighlightSettings2Limits, HighlightSettings2ContentContentHighlightPropsHighlightSettings2ResponseShape } from "src/models/data-contracts"; | ||
|
||
export class ContentHighlightingBuilder { | ||
private enabled: boolean = true; | ||
private highlightable: ContentHighlightProps = { | ||
$type: 'Relewise.Client.Requests.Shared.Highlighting.ContentHighlightProps, Relewise.Client', | ||
displayName: false | ||
}; | ||
private limit: HighlightSettings2ContentContentHighlightPropsHighlightSettings2Limits = {}; | ||
private shape: HighlightSettings2ContentContentHighlightPropsHighlightSettings2ResponseShape = { | ||
includeOffsets: false | ||
}; | ||
|
||
public enable(enabled: boolean): this { | ||
this.enabled = enabled; | ||
|
||
return this; | ||
} | ||
|
||
public setHighlightable(highlightable: { displayName?: boolean, dataKeys?: string[] | null }): this { | ||
this.highlightable.displayName = highlightable.displayName ?? false; | ||
this.highlightable.dataKeys = highlightable.dataKeys; | ||
|
||
return this; | ||
} | ||
|
||
public setLimit(limit: { maxEntryLimit?: number | null; maxSnippetsPerEntry?: number | null; maxSnippetsPerField?: number | null; }): this { | ||
this.limit.maxEntryLimit = limit.maxEntryLimit; | ||
this.limit.maxSnippetsPerEntry = limit.maxSnippetsPerEntry; | ||
this.limit.maxSnippetsPerField = limit.maxSnippetsPerField; | ||
|
||
return this; | ||
} | ||
|
||
public setShape(shape: { includeOffsets: boolean }): this { | ||
this.shape.includeOffsets = shape.includeOffsets; | ||
|
||
return this; | ||
} | ||
|
||
public build(): ContentSearchSettingsHighlightSettings { | ||
return { | ||
$type: 'Relewise.Client.Requests.Search.Settings.ContentSearchSettings+HighlightSettings, Relewise.Client', | ||
enabled: this.enabled, | ||
highlightable: this.highlightable, | ||
limit: this.limit, | ||
shape: this.shape | ||
} as ContentSearchSettingsHighlightSettings; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
packages/client/src/builders/search/productHighlightingBuilder.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { HighlightSettings2ProductProductHighlightPropsHighlightSettings2Limits, HighlightSettings2ProductProductHighlightPropsHighlightSettings2ResponseShape, ProductHighlightProps, ProductSearchSettingsHighlightSettings } from "src/models/data-contracts"; | ||
|
||
export class ProductHighlightingBuilder { | ||
private enabled: boolean = true; | ||
private highlightable: ProductHighlightProps = { | ||
$type: 'Relewise.Client.Requests.Shared.Highlighting.ProductHighlightProps, Relewise.Client', | ||
displayName: false | ||
}; | ||
private limit: HighlightSettings2ProductProductHighlightPropsHighlightSettings2Limits = {}; | ||
private shape: HighlightSettings2ProductProductHighlightPropsHighlightSettings2ResponseShape = { | ||
includeOffsets: false | ||
}; | ||
|
||
public enable(enabled: boolean): this { | ||
this.enabled = enabled; | ||
|
||
return this; | ||
} | ||
|
||
public setHighlightable(highlightable: { displayName?: boolean, dataKeys?: string[] | null }): this { | ||
this.highlightable.displayName = highlightable.displayName ?? false; | ||
this.highlightable.dataKeys = highlightable.dataKeys; | ||
|
||
return this; | ||
} | ||
|
||
public setLimit(limit: { maxEntryLimit?: number | null; maxSnippetsPerEntry?: number | null; maxSnippetsPerField?: number | null; }): this { | ||
this.limit.maxEntryLimit = limit.maxEntryLimit; | ||
this.limit.maxSnippetsPerEntry = limit.maxSnippetsPerEntry; | ||
this.limit.maxSnippetsPerField = limit.maxSnippetsPerField; | ||
|
||
return this; | ||
} | ||
|
||
public setShape(shape: { includeOffsets: boolean }): this { | ||
this.shape.includeOffsets = shape.includeOffsets; | ||
|
||
return this; | ||
} | ||
|
||
public build(): ProductSearchSettingsHighlightSettings { | ||
return { | ||
$type: 'Relewise.Client.Requests.Search.Settings.ProductSearchSettings+HighlightSettings, Relewise.Client', | ||
enabled: this.enabled, | ||
highlightable: this.highlightable, | ||
limit: this.limit, | ||
shape: this.shape | ||
} as ProductSearchSettingsHighlightSettings; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.