Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ export class ContentHighlightingBuilder {
private highlightable: ContentHighlightProps = {
$type: 'Relewise.Client.Requests.Shared.Highlighting.ContentHighlightProps, Relewise.Client',
displayName: false
};
};
private limit: HighlightSettings2ContentContentHighlightPropsHighlightSettings2Limits = {};
private shape: HighlightSettings2ContentContentHighlightPropsHighlightSettings2ResponseShape = {
includeOffsets: false
};

public enabled(enabled: boolean): this {
this.enabledState = enabled;

return this;
}

Expand All @@ -24,10 +24,8 @@ export class ContentHighlightingBuilder {
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;
public setLimit(limit: HighlightSettings2ContentContentHighlightPropsHighlightSettings2Limits): this {
this.limit = limit;

return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ export class ProductHighlightingBuilder {
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;
public setLimit(limit: HighlightSettings2ProductProductHighlightPropsHighlightSettings2Limits): this {
this.limit = limit;

return this;
}
Expand Down
77 changes: 67 additions & 10 deletions packages/client/src/models/data-contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export interface AbandonedCartTriggerResultTriggerConfiguration {

export type AbandonedSearchTriggerConfiguration = AbandonedSearchTriggerResultTriggerConfiguration & {
searchTypesInPrioritizedOrder: ("Product" | "ProductCategory" | "Content")[];
searchTermCondition?: SearchTermCondition | null;
searchTermCondition?: SearchTermCondition | RetailMediaSearchTermCondition | null;
suppressOnEntityFromSearchResultViewed: boolean;
/** @format int32 */
considerAbandonedAfterMinutes: number;
Expand Down Expand Up @@ -567,6 +567,7 @@ export type Campaign = CampaignEntityStateCampaignMetadataValuesRetailMediaEntit
advertiserId: string;
budget: CPMBudget;
status: CampaignStatusWithHistory;
conditions?: RetailMediaConditions | null;
};

export interface CampaignAnalytics {
Expand Down Expand Up @@ -2122,9 +2123,11 @@ export interface FieldIndexConfiguration {
included: boolean;
/** @format int32 */
weight: number;
/** @deprecated */
predictionSourceType: "Disabled" | "IndividualWords" | "PartialWordSequences" | "CompleteWordSequence";
parser?: ClearTextParser | HtmlParser | null;
matchTypeSettings?: MatchTypeSettings | null;
predictionConfiguration?: PredictionConfiguration | null;
}

export interface Filter {
Expand Down Expand Up @@ -2365,6 +2368,14 @@ export interface HighlightSettings2ContentContentHighlightPropsHighlightSettings
maxSnippetsPerEntry?: number | null;
/** @format int32 */
maxSnippetsPerField?: number | null;
/** @format int32 */
maxWordsBeforeMatch?: number | null;
/** @format int32 */
maxWordsAfterMatch?: number | null;
/** @format int32 */
maxSentencesToIncludeBeforeMatch?: number | null;
/** @format int32 */
maxSentencesToIncludeAfterMatch?: number | null;
}

export interface HighlightSettings2ContentContentHighlightPropsHighlightSettings2ResponseShape {
Expand All @@ -2374,6 +2385,7 @@ export interface HighlightSettings2ContentContentHighlightPropsHighlightSettings

export interface HighlightSettings2ContentContentHighlightPropsHighlightSettings2TextSnippetsSettings {
includeTextSnippets: boolean;
includeEllipses: boolean;
}

export interface HighlightSettings2ProductProductHighlightPropsHighlightSettings2Limits {
Expand All @@ -2383,6 +2395,14 @@ export interface HighlightSettings2ProductProductHighlightPropsHighlightSettings
maxSnippetsPerEntry?: number | null;
/** @format int32 */
maxSnippetsPerField?: number | null;
/** @format int32 */
maxWordsBeforeMatch?: number | null;
/** @format int32 */
maxWordsAfterMatch?: number | null;
/** @format int32 */
maxSentencesToIncludeBeforeMatch?: number | null;
/** @format int32 */
maxSentencesToIncludeAfterMatch?: number | null;
}

export interface HighlightSettings2ProductProductHighlightPropsHighlightSettings2ResponseShape {
Expand All @@ -2392,6 +2412,7 @@ export interface HighlightSettings2ProductProductHighlightPropsHighlightSettings

export interface HighlightSettings2ProductProductHighlightPropsHighlightSettings2TextSnippetsSettings {
includeTextSnippets: boolean;
includeEllipses: boolean;
}

export type HtmlParser = Parser;
Expand Down Expand Up @@ -3034,10 +3055,14 @@ export interface PopularityMultiplierSelector {
$type: string;
}

export interface PredictionConfiguration {
includeInPredictions: boolean;
}

export type PredictionRule = SearchRule & {
condition: SearchTermCondition;
promote: PredictionRulePromotion;
suppress: PredictionRuleSuppression;
condition: SearchTermCondition | RetailMediaSearchTermCondition;
promote?: PredictionRulePromotion | null;
suppress?: PredictionRuleSuppression | null;
};

export interface PredictionRulePromotion {
Expand Down Expand Up @@ -3917,6 +3942,7 @@ export interface ProductProductHighlightPropsHighlightSettings {

export type ProductPromotion = Promotion & {
filters?: FilterCollection | null;
conditions?: RetailMediaConditions | null;
};

export type ProductPromotionSpecification = PromotionSpecification & {
Expand Down Expand Up @@ -4398,6 +4424,27 @@ export type PurchasedWithProductRequest = ProductRecommendationRequest & {
productAndVariantId: ProductAndVariantId;
};

export interface RebuildStatus {
isRebuilding: boolean;
isStale: boolean;
/** @format date-time */
lastRebuildStarted: string;
/** @format date-time */
lastRebuildCompleted: string;
/** @format date-time */
lastRebuildOpportunity: string;
/** @format date-span */
lastRebuildDuration: string;
isBuilt: boolean;
isPartial: boolean;
/** @format date-time */
lastMarkedAsStale: string;
/** @format date-span */
staleDuration: string;
/** @format date-span */
lastStaleDuration: string;
}

export type RecentlyPurchasedFacet = BooleanValueFacet & {
purchaseQualifiers: PurchaseQualifiers;
};
Expand Down Expand Up @@ -4460,13 +4507,13 @@ export interface RecommendationTypeCollection {
export interface RedirectResult {
/** @format uuid */
id: string;
condition: SearchTermCondition;
condition: SearchTermCondition | RetailMediaSearchTermCondition;
destination?: string | null;
data?: Record<string, string>;
}

export type RedirectRule = SearchRule & {
condition: SearchTermCondition;
condition: SearchTermCondition | RetailMediaSearchTermCondition;
destination?: string | null;
data?: Record<string, string>;
};
Expand Down Expand Up @@ -4585,6 +4632,10 @@ export type ResultMustHaveVariantConstraint = ProductSearchResultConstraint & {
exceptWhenProductHasNoVariants: boolean;
};

export interface RetailMediaConditions {
searchTerm?: RetailMediaSearchTermCondition | null;
}

export interface RetailMediaEntity2AdvertiserEntityStateAdvertiserMetadataValuesRetailMediaEntity2EntityFilters {
$type: string;
term?: string | null;
Expand Down Expand Up @@ -4637,6 +4688,8 @@ export interface RetailMediaResultPlacementResultEntityProduct {
result: ProductResult;
}

export type RetailMediaSearchTermCondition = SearchTermCondition;

export type SaveAdvertisersRequest = AdvertiserSaveEntitiesRequest;

export type SaveAdvertisersResponse = AdvertiserSaveEntitiesResponse;
Expand Down Expand Up @@ -4724,6 +4777,7 @@ export interface SearchIndex {
modifiedBy?: string | null;
custom?: Record<string, string | null>;
configuration?: IndexConfiguration | null;
rebuildStatus?: RebuildStatus | null;
}

export type SearchIndexCollectionResponse = TimedResponse & {
Expand Down Expand Up @@ -4789,7 +4843,7 @@ export type SearchResponseCollection = SearchResponse & {
};

export type SearchResultModifierRule = SearchRule & {
condition: SearchTermCondition;
condition: SearchTermCondition | RetailMediaSearchTermCondition;
actions: (SearchResultModifierRuleAddFiltersAction | SearchResultModifierRuleAddTermFilterAction)[];
};

Expand Down Expand Up @@ -4889,16 +4943,18 @@ export type SearchTermBasedProductRecommendationRequest = ProductRecommendationR
};

export interface SearchTermCondition {
$type: string;
kind?: "Equals" | "StartsWith" | "EndsWith" | "Contains" | null;
value?: string | null;
andConditions?: SearchTermCondition[] | null;
orConditions?: SearchTermCondition[] | null;
andConditions?: (SearchTermCondition | RetailMediaSearchTermCondition)[] | null;
orConditions?: (SearchTermCondition | RetailMediaSearchTermCondition)[] | null;
/** @format int32 */
minimumLength?: number | null;
negated: boolean;
}

export type SearchTermModifierRule = SearchRule & {
condition: SearchTermCondition;
condition: SearchTermCondition | RetailMediaSearchTermCondition;
actions: (
| SearchTermModifierRuleAppendToTermAction
| SearchTermModifierRuleRemoveFromTermAction
Expand Down Expand Up @@ -4985,6 +5041,7 @@ export interface SearchTermPredictionResult {
/** @format int32 */
rank: number;
expectedResultTypes?: ExpectedSearchTermResult[] | null;
/** @deprecated */
type: "Match" | "WordContinuation" | "Word" | "WordSequence";
correctedWordsMask?: boolean[] | null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ test('Highlighting', async() => {
.setTerm('highlighted')
.highlighting(h => {
h.setHighlightable({ dataKeys: ['Description'] })
h.setLimit({ maxWordsBeforeMatch: 3 })
// You have to specify to include the offset.
// Currently offset is the only way to get a result, so if not set, you won't get a result.
h.setShape({ includeOffsets: true, textSnippets: { includeTextSnippets: true } })
h.setShape({ includeOffsets: true, textSnippets: { includeTextSnippets: true, includeEllipses: true } })
}).build();

const result = await searcher.searchContents(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ test('ProductSearch with search constraint', async() => {

test('Highlighting', async() => {
const request: ProductSearchRequest = baseProductBuilder()
.setTerm('highlighted')
.setTerm('SomeValue')
.highlighting(h => {
h.setHighlightable({ dataKeys: ['Description'] })
h.setHighlightable({ dataKeys: ['SomeString'] })
// You have to specify to include the offset.
// Currently offset is the only way to get a result, so if not set, you won't get a result.
h.setShape({ includeOffsets: true, textSnippets: { includeTextSnippets: true } })
h.setShape({ includeOffsets: true, textSnippets: { includeTextSnippets: true, includeEllipses: true } })
}).build();
const result = await searcher.searchProducts(request);

expect(result?.results![0].highlight?.offsets?.data[0].value.length).toBeGreaterThan(0);
expect(result?.results![0].highlight?.snippets?.data[0].value[0]).toBe("...last word is highlighted");
expect(result?.results![0].highlight?.snippets?.data[0].value[0]).toBe("SomeValue");
})
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ test('searchHightlighting', () => {
h.setShape({
includeOffsets: true,
textSnippets: {
includeEllipses: true,
includeTextSnippets: true
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ test('searchHightlighting', () => {
h.setShape({
includeOffsets: true,
textSnippets: {
includeEllipses: true,
includeTextSnippets: true,
}
});
Expand Down