UNPKG

@relewise/client

Version:

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.

1,123 lines (1,113 loc) 274 kB
'use strict'; class DataValueBase { constructor(type, value) { this.type = type; this.value = value; } } class StringDataValue extends DataValueBase { constructor(value) { super('String', value); this.isCollection = false; } } class StringCollectionDataValue extends DataValueBase { constructor(value) { super('StringList', { $type: 'System.Collections.Generic.List`1[[System.String, System.Private.CoreLib]], System.Private.CoreLib', $values: value, }); this.isCollection = true; } } class MultilingualCollectionDataValue extends DataValueBase { constructor(values) { super('MultilingualCollection', { $type: 'Relewise.Client.DataTypes.MultilingualCollection, Relewise.Client', values: values.map(x => ({ values: x.values, language: { value: x.language } })), }); this.isCollection = true; } } class NumberDataValue extends DataValueBase { constructor(value) { super('Double', value); this.isCollection = false; } } class DoubleCollectionDataValue extends DataValueBase { constructor(value) { super('DoubleList', { $type: 'System.Collections.Generic.List`1[[System.Double, System.Private.CoreLib]], System.Private.CoreLib', $values: value, }); this.isCollection = true; } } class BooleanDataValue extends DataValueBase { constructor(value) { super('Boolean', value); this.isCollection = false; } } class BooleanCollectionDataValue extends DataValueBase { constructor(value) { super('BooleanList', { $type: 'System.Collections.Generic.List`1[[System.Boolean, System.Private.CoreLib]], System.Private.CoreLib', $values: value, }); this.isCollection = true; } } class MultiCurrencyDataValue extends DataValueBase { constructor(values) { super('MultiCurrency', { $type: 'Relewise.Client.DataTypes.MultiCurrency, Relewise.Client', values: values.map(x => ({ amount: x.amount, currency: { value: x.currency } })), }); this.isCollection = false; } } class MultilingualDataValue extends DataValueBase { constructor(values) { super('Multilingual', { $type: 'Relewise.Client.DataTypes.Multilingual, Relewise.Client', values: values.map(x => ({ text: x.value, language: { value: x.language } })), }); this.isCollection = false; } } class ObjectDataValue extends DataValueBase { constructor(dataObject) { super('Object', { $type: 'Relewise.Client.DataTypes.DataObject, Relewise.Client', data: dataObject, }); this.isCollection = false; } } class ObjectCollectionDataValue extends DataValueBase { constructor(dataObjects) { super('ObjectList', { $type: 'System.Collections.Generic.List`1[[Relewise.Client.DataTypes.DataObject, Relewise.Client]], System.Private.CoreLib', $values: dataObjects.map(x => ({ $type: 'Relewise.Client.DataTypes.DataObject, Relewise.Client', data: x })), }); this.isCollection = true; } } class FilterScopesBuilder { constructor() { this.fillScope = undefined; this.defaultScope = undefined; } fill({ apply }) { this.fillScope = { $type: 'Relewise.Client.Requests.Filters.Settings.ApplyFilterSettings, Relewise.Client', apply, }; return this; } default({ apply }) { this.defaultScope = { $type: 'Relewise.Client.Requests.Filters.Settings.ApplyFilterSettings, Relewise.Client', apply, }; return this; } build() { return this.fillScope || this.defaultScope ? { fill: this.fillScope, default: this.defaultScope, } : null; } } class FilterSettingsBuilder { constructor() { this.scopesBuilder = new FilterScopesBuilder(); } scopes(builder) { builder(this.scopesBuilder); return this; } build() { const scopes = this.scopesBuilder.build(); return scopes ? { scopes: scopes } : null; } } class DataObjectFilterConditionBuilder { constructor() { this.conditions = []; } addContainsCondition(key, value, mode = 'All', objectPath, negated = false) { const condition = { $type: 'Relewise.Client.Requests.Filters.DataObjects.Conditions.ObjectValueContainsCondition, Relewise.Client', key: key, value: value, objectPath: objectPath, mode: mode, negated: negated, }; this.conditions.push(condition); return this; } addEqualsCondition(key, value, objectPath, negated = false) { const condition = { $type: 'Relewise.Client.Requests.Filters.DataObjects.Conditions.ObjectValueEqualsCondition, Relewise.Client', value: value, objectPath: objectPath, negated: negated, key: key, }; this.conditions.push(condition); return this; } addInRangeCondition(key, range, objectPath, negated = false) { const condition = { $type: 'Relewise.Client.Requests.Filters.DataObjects.Conditions.ObjectValueInRangeCondition, Relewise.Client', range: range, key: key, objectPath: objectPath, negated: negated, }; this.conditions.push(condition); return this; } addGreaterThanCondition(key, value, objectPath, negated = false) { const condition = { $type: 'Relewise.Client.Requests.Filters.DataObjects.Conditions.ObjectValueGreaterThanCondition, Relewise.Client', value: value, negated: negated, key: key, objectPath: objectPath, }; this.conditions.push(condition); return this; } addLessThanCondition(key, value, objectPath, negated = false) { const condition = { $type: 'Relewise.Client.Requests.Filters.DataObjects.Conditions.ObjectValueLessThanCondition, Relewise.Client', value: value, negated: negated, key: key, objectPath: objectPath, }; this.conditions.push(condition); return this; } addMinByCondition(key, objectPath, negated = false) { const condition = { $type: 'Relewise.Client.Requests.Filters.DataObjects.Conditions.ObjectValueMinByCondition, Relewise.Client', negated: negated, key: key, objectPath: objectPath, }; this.conditions.push(condition); return this; } addMaxByCondition(key, objectPath, negated = false) { const condition = { $type: 'Relewise.Client.Requests.Filters.DataObjects.Conditions.ObjectValueMaxByCondition, Relewise.Client', negated: negated, key: key, objectPath: objectPath, }; this.conditions.push(condition); return this; } addObjectValueIsSubsetOfCondition(key, value, objectPath, negated = false) { const condition = { $type: 'Relewise.Client.Requests.Filters.DataObjects.Conditions.ObjectValueIsSubsetOfCondition, Relewise.Client', value: value, key: key, objectPath: objectPath, negated: negated, }; this.conditions.push(condition); return this; } build() { return this.conditions.length === 0 ? null : this.conditions; } } class FilterBuilderBase { constructor(TFilterBuilderCtor) { this.TFilterBuilderCtor = TFilterBuilderCtor; this.filters = []; } /** * Adds an AND filter to the request. * @param filterBuilder - Function to build the AND filter. * @param negated - If true, negates the filter (default is false). * @param options - Optional settings for the filter. * @returns The FilterBuilderBase instance for chaining. */ and(filterBuilder, negated = false, options) { var _a; const builder = new this.TFilterBuilderCtor(); filterBuilder(builder); const internalSettingsBuilder = new FilterSettingsBuilder(); (_a = options === null || options === void 0 ? void 0 : options.filterSettings) === null || _a === void 0 ? void 0 : _a.call(options, internalSettingsBuilder); const filters = builder.build(); if (filters === null || !filters.items || filters.items.length <= 0) { throw new Error('And-filters must contain at least 1 filter'); } const filter = { $type: 'Relewise.Client.Requests.Filters.AndFilter, Relewise.Client', filters: filters.items, negated: negated, settings: internalSettingsBuilder.build(), }; this.filters.push(filter); return this; } /** * Adds an OR filter to the request. * @param filterBuilder - Function to build the OR filter. * @param negated - If true, negates the filter (default is false). * @param options - Optional settings for the filter. * @returns The FilterBuilderBase instance for chaining. */ or(filterBuilder, negated = false, options) { var _a; const builder = new this.TFilterBuilderCtor(); filterBuilder(builder); const internalSettingsBuilder = new FilterSettingsBuilder(); (_a = options === null || options === void 0 ? void 0 : options.filterSettings) === null || _a === void 0 ? void 0 : _a.call(options, internalSettingsBuilder); const filters = builder.build(); if (filters === null || !filters.items || filters.items.length <= 0) { throw new Error('Or-filters must contain at least 1 filter'); } const filter = { $type: 'Relewise.Client.Requests.Filters.OrFilter, Relewise.Client', filters: filters.items, negated: negated, settings: internalSettingsBuilder.build(), }; this.filters.push(filter); return this; } /** * Resets the filters. * @returns The FilterBuilderBase instance for chaining. */ reset() { this.filters = []; return this; } /** * Builds the filter collection. * @returns The FilterCollection or null if no filters are added. */ build() { return this.filters.length === 0 ? null : { items: this.filters }; } } class ConditionBuilder { constructor() { this.conditions = []; } addContainsCondition(value, valueCollectionEvaluationMode = 'All', negated = false) { const condition = { $type: 'Relewise.Client.Requests.Conditions.ContainsCondition, Relewise.Client', value: value, valueCollectionEvaluationMode: valueCollectionEvaluationMode, negated: negated, }; this.conditions.push(condition); return this; } addDistinctCondition(numberOfOccurrencesAllowedWithTheSameValue, negated = false) { const condition = { $type: 'Relewise.Client.Requests.Conditions.DistinctCondition, Relewise.Client', numberOfOccurrencesAllowedWithTheSameValue: numberOfOccurrencesAllowedWithTheSameValue, negated: negated, }; this.conditions.push(condition); return this; } addEqualsCondition(value, negated = false) { const condition = { $type: 'Relewise.Client.Requests.Conditions.EqualsCondition, Relewise.Client', value: value, negated: negated, }; this.conditions.push(condition); return this; } addGreaterThanCondition(value, negated = false) { const condition = { $type: 'Relewise.Client.Requests.Conditions.GreaterThanCondition, Relewise.Client', value: value, negated: negated, }; this.conditions.push(condition); return this; } addLessThanCondition(value, negated = false) { const condition = { $type: 'Relewise.Client.Requests.Conditions.LessThanCondition, Relewise.Client', value: value, negated: negated, }; this.conditions.push(condition); return this; } addDataObjectCondition(conditions, skip, take, negated = false) { const conditionsBuilder = new DataObjectFilterConditionBuilder(); conditions(conditionsBuilder); const condition = { $type: 'Relewise.Client.Requests.Conditions.ContainsCondition, Relewise.Client', objectFilter: { conditions: conditionsBuilder.build(), skip: skip, take: take, }, valueCollectionEvaluationMode: 'All', negated: negated, }; this.conditions.push(condition); return this; } addHasValueCondition(negated = false) { const condition = { $type: 'Relewise.Client.Requests.Conditions.HasValueCondition, Relewise.Client', negated: negated, }; this.conditions.push(condition); return this; } addRelativeDateTimeCondition(comparison, unit, currentTimeOffset = 0, negated = false) { const condition = { $type: 'Relewise.Client.Requests.Conditions.RelativeDateTimeCondition, Relewise.Client', comparison: comparison, currentTimeOffset: currentTimeOffset, unit: unit, negated: negated, }; this.conditions.push(condition); return this; } build() { return this.conditions.length === 0 ? null : { items: this.conditions }; } } class BrandFilterBuilder extends FilterBuilderBase { constructor() { super(BrandFilterBuilder); } /** * Adds a brand assortment filter to the request. * @param assortmentIds - Array of assortment IDs or a single ID. * @param negated - If true, negates the filter (default is false). * @param options - Optional settings for the filter. * @returns The BrandFilterBuilder instance for chaining. */ addBrandAssortmentFilter(assortmentIds, negated = false, options) { var _a; const assortments = Array.isArray(assortmentIds) ? assortmentIds : [assortmentIds]; const internalSettingsBuilder = new FilterSettingsBuilder(); (_a = options === null || options === void 0 ? void 0 : options.filterSettings) === null || _a === void 0 ? void 0 : _a.call(options, internalSettingsBuilder); const filter = { $type: 'Relewise.Client.Requests.Filters.BrandAssortmentFilter, Relewise.Client', assortments: assortments, negated: negated, settings: internalSettingsBuilder.build(), }; this.filters.push(filter); return this; } /** * Filters the request to only return the specified brands. * @param brandIds - Array of brand IDs or a single ID. * @param negated - If true, negates the filter (default is false). * @param options - Optional settings for the filter. * @returns The BrandFilterBuilder instance for chaining. */ addBrandIdFilter(brandIds, negated = false, options) { var _a; const ids = Array.isArray(brandIds) ? brandIds : [brandIds]; const internalSettingsBuilder = new FilterSettingsBuilder(); (_a = options === null || options === void 0 ? void 0 : options.filterSettings) === null || _a === void 0 ? void 0 : _a.call(options, internalSettingsBuilder); const filter = { $type: 'Relewise.Client.Requests.Filters.BrandIdFilter, Relewise.Client', brandIds: ids, negated: negated, settings: internalSettingsBuilder.build(), }; this.filters.push(filter); return this; } /** * Adds a brand data filter to the request. * @param key - Data key. * @param conditionBuilder - Function to build the condition. * @param mustMatchAllConditions - If true, all conditions must be met (default is true). * @param filterOutIfKeyIsNotFound - If true, filters out brands without the key (default is true). * @param negated - If true, negates the filter (default is false). * @param options - Optional settings for the filter. * @returns The BrandFilterBuilder instance for chaining. */ addBrandDataFilter(key, conditionBuilder, mustMatchAllConditions = true, filterOutIfKeyIsNotFound = true, negated = false, options) { var _a; const builder = new ConditionBuilder(); conditionBuilder(builder); const internalSettingsBuilder = new FilterSettingsBuilder(); (_a = options === null || options === void 0 ? void 0 : options.filterSettings) === null || _a === void 0 ? void 0 : _a.call(options, internalSettingsBuilder); const filter = { $type: 'Relewise.Client.Requests.Filters.BrandDataFilter, Relewise.Client', key: key, filterOutIfKeyIsNotFound: filterOutIfKeyIsNotFound, mustMatchAllConditions: mustMatchAllConditions, conditions: builder.build(), negated: negated, objectPath: options === null || options === void 0 ? void 0 : options.objectPath, settings: internalSettingsBuilder.build(), }; this.filters.push(filter); return this; } /** * Adds a brand has key filter to the request. * @param key - Data key. * @param negated - If true, negates the filter (default is false). * @param options - Optional settings for the filter. * @returns The BrandFilterBuilder instance for chaining. */ addBrandDataHasKeyFilter(key, negated = false, options) { var _a; const internalSettingsBuilder = new FilterSettingsBuilder(); (_a = options === null || options === void 0 ? void 0 : options.filterSettings) === null || _a === void 0 ? void 0 : _a.call(options, internalSettingsBuilder); const filter = { $type: 'Relewise.Client.Requests.Filters.BrandDataHasKeyFilter, Relewise.Client', key: key, negated: negated, settings: internalSettingsBuilder.build(), }; this.filters.push(filter); return this; } /** * Adds a brand is disabled filter to the request. Only works for brand queries, not in searches or recommendations. * @param negated - If true, negates the filter (default is false). * @param options - Optional settings for the filter. * @returns The BrandFilterBuilder instance for chaining. */ addBrandDisabledFilter(negated = false, options) { var _a; const internalSettingsBuilder = new FilterSettingsBuilder(); (_a = options === null || options === void 0 ? void 0 : options.filterSettings) === null || _a === void 0 ? void 0 : _a.call(options, internalSettingsBuilder); const filter = { $type: 'Relewise.Client.Requests.Filters.BrandDisabledFilter, Relewise.Client', negated: negated, settings: internalSettingsBuilder.build(), }; this.filters.push(filter); return this; } } class CompanyFilterBuilder extends FilterBuilderBase { constructor() { super(CompanyFilterBuilder); } /** * Filters the request to only return the specified companies. * @param companyIds - Array of company IDs or a single ID. * @param negated - If true, negates the filter (default is false). * @param options - Optional settings for the filter. * @returns The CompanyFilterBuilder instance for chaining. */ addCompanyIdFilter(companyIds, negated = false, options) { var _a; const ids = Array.isArray(companyIds) ? companyIds : [companyIds]; const internalSettingsBuilder = new FilterSettingsBuilder(); (_a = options === null || options === void 0 ? void 0 : options.filterSettings) === null || _a === void 0 ? void 0 : _a.call(options, internalSettingsBuilder); const filter = { $type: 'Relewise.Client.Requests.Filters.CompanyIdFilter, Relewise.Client', companyIds: ids, negated: negated, settings: internalSettingsBuilder.build(), }; this.filters.push(filter); return this; } /** * Adds a company data filter to the request. * @param key - Data key. * @param conditionBuilder - Function to build the condition. * @param mustMatchAllConditions - If true, all conditions must be met (default is true). * @param filterOutIfKeyIsNotFound - If true, filters out companies without the key (default is true). * @param negated - If true, negates the filter (default is false). * @param options - Optional settings for the filter. * @returns The CompanyFilterBuilder instance for chaining. */ addCompanyDataFilter(key, conditionBuilder, mustMatchAllConditions = true, filterOutIfKeyIsNotFound = true, negated = false, options) { var _a; const builder = new ConditionBuilder(); conditionBuilder(builder); const internalSettingsBuilder = new FilterSettingsBuilder(); (_a = options === null || options === void 0 ? void 0 : options.filterSettings) === null || _a === void 0 ? void 0 : _a.call(options, internalSettingsBuilder); const filter = { $type: 'Relewise.Client.Requests.Filters.CompanyDataFilter, Relewise.Client', key: key, filterOutIfKeyIsNotFound: filterOutIfKeyIsNotFound, mustMatchAllConditions: mustMatchAllConditions, conditions: builder.build(), negated: negated, objectPath: options === null || options === void 0 ? void 0 : options.objectPath, settings: internalSettingsBuilder.build(), }; this.filters.push(filter); return this; } /** * Adds a company has key filter to the request. * @param key - Data key. * @param negated - If true, negates the filter (default is false). * @param options - Optional settings for the filter. * @returns The CompanyFilterBuilder instance for chaining. */ addCompanyDataHasKeyFilter(key, negated = false, options) { var _a; const internalSettingsBuilder = new FilterSettingsBuilder(); (_a = options === null || options === void 0 ? void 0 : options.filterSettings) === null || _a === void 0 ? void 0 : _a.call(options, internalSettingsBuilder); const filter = { $type: 'Relewise.Client.Requests.Filters.CompanyDataHasKeyFilter, Relewise.Client', key: key, negated: negated, settings: internalSettingsBuilder.build(), }; this.filters.push(filter); return this; } /** * Adds a company is disabled filter to the request. Only works for company queries, not in searches or recommendations. * @param negated - If true, negates the filter (default is false). * @param options - Optional settings for the filter. * @returns The CompanyFilterBuilder instance for chaining. */ addCompanyDisabledFilter(negated = false, options) { var _a; const internalSettingsBuilder = new FilterSettingsBuilder(); (_a = options === null || options === void 0 ? void 0 : options.filterSettings) === null || _a === void 0 ? void 0 : _a.call(options, internalSettingsBuilder); const filter = { $type: 'Relewise.Client.Requests.Filters.CompanyDisabledFilter, Relewise.Client', negated: negated, settings: internalSettingsBuilder.build(), }; this.filters.push(filter); return this; } } class ContentFilterBuilder extends FilterBuilderBase { constructor() { super(ContentFilterBuilder); } /** * Adds a content assortment filter to the request. * @param assortmentIds - Array of assortment IDs or a single ID. * @param negated - If true, negates the filter (default is false). * @param options - Optional settings for the filter. * @returns The ContentFilterBuilder instance for chaining. */ addContentAssortmentFilter(assortmentIds, negated = false, options) { var _a; const assortments = Array.isArray(assortmentIds) ? assortmentIds : [assortmentIds]; const internalSettingsBuilder = new FilterSettingsBuilder(); (_a = options === null || options === void 0 ? void 0 : options.filterSettings) === null || _a === void 0 ? void 0 : _a.call(options, internalSettingsBuilder); const filter = { $type: 'Relewise.Client.Requests.Filters.ContentAssortmentFilter, Relewise.Client', assortments: assortments, negated: negated, settings: internalSettingsBuilder.build(), }; this.filters.push(filter); return this; } /** * Adds a content category assortment filter to the request. * @param assortmentIds - Array of assortment IDs or a single ID. * @param negated - If true, negates the filter (default is false). * @param options - Optional settings for the filter. * @returns The ContentFilterBuilder instance for chaining. */ addContentCategoryAssortmentFilter(assortmentIds, negated = false, options) { var _a; const assortments = Array.isArray(assortmentIds) ? assortmentIds : [assortmentIds]; const internalSettingsBuilder = new FilterSettingsBuilder(); (_a = options === null || options === void 0 ? void 0 : options.filterSettings) === null || _a === void 0 ? void 0 : _a.call(options, internalSettingsBuilder); const filter = { $type: 'Relewise.Client.Requests.Filters.ContentCategoryAssortmentFilter, Relewise.Client', assortments: assortments, negated: negated, settings: internalSettingsBuilder.build(), }; this.filters.push(filter); return this; } /** * Filters the request to only return contents within the specified categories. * @param evaluationScope - Scope of the category evaluation (ImmediateParent, ImmediateParentOrItsParent, Ancestor). * @param categoryIds - Array of category IDs or a single ID. * @param negated - If true, negates the filter (default is false). * @param options - Optional settings for the filter. * @returns The ContentFilterBuilder instance for chaining. */ addContentCategoryIdFilter(evaluationScope, categoryIds, negated = false, options) { var _a; const ids = Array.isArray(categoryIds) ? categoryIds : [categoryIds]; const internalSettingsBuilder = new FilterSettingsBuilder(); (_a = options === null || options === void 0 ? void 0 : options.filterSettings) === null || _a === void 0 ? void 0 : _a.call(options, internalSettingsBuilder); const filter = { $type: 'Relewise.Client.Requests.Filters.ContentCategoryIdFilter, Relewise.Client', evaluationScope: evaluationScope, categoryIds: ids, negated: negated, settings: internalSettingsBuilder.build(), }; this.filters.push(filter); return this; } /** * Filters the request to only return the specified contents. * @param contentIds - Array of content IDs or a single ID. * @param negated - If true, negates the filter (default is false). * @param options - Optional settings for the filter. * @returns The ContentFilterBuilder instance for chaining. */ addContentIdFilter(contentIds, negated = false, options) { var _a; const ids = Array.isArray(contentIds) ? contentIds : [contentIds]; const internalSettingsBuilder = new FilterSettingsBuilder(); (_a = options === null || options === void 0 ? void 0 : options.filterSettings) === null || _a === void 0 ? void 0 : _a.call(options, internalSettingsBuilder); const filter = { $type: 'Relewise.Client.Requests.Filters.ContentIdFilter, Relewise.Client', contentIds: ids, negated: negated, settings: internalSettingsBuilder.build(), }; this.filters.push(filter); return this; } /** * Adds a content category level filter to the request. * @param levels - Array of category levels or a single level. * @param negated - If true, negates the filter (default is false). * @param options - Optional settings for the filter. * @returns The ContentFilterBuilder instance for chaining. */ addContentCategoryLevelFilter(levels, negated = false, options) { var _a; const internalSettingsBuilder = new FilterSettingsBuilder(); (_a = options === null || options === void 0 ? void 0 : options.filterSettings) === null || _a === void 0 ? void 0 : _a.call(options, internalSettingsBuilder); const filter = { $type: 'Relewise.Client.Requests.Filters.ContentCategoryLevelFilter, Relewise.Client', levels: Array.isArray(levels) ? levels : [levels], negated: negated, settings: internalSettingsBuilder.build(), }; this.filters.push(filter); return this; } /** * Adds a content category has parent filter to the request. * @param categoryIds - Array of category IDs or a single ID (optional). * @param negated - If true, negates the filter (default is false). * @param options - Optional settings for the filter. * @returns The ContentFilterBuilder instance for chaining. */ addContentCategoryHasParentFilter(categoryIds, negated = false, options) { var _a; const internalSettingsBuilder = new FilterSettingsBuilder(); (_a = options === null || options === void 0 ? void 0 : options.filterSettings) === null || _a === void 0 ? void 0 : _a.call(options, internalSettingsBuilder); const filter = { $type: 'Relewise.Client.Requests.Filters.ContentCategoryHasParentFilter, Relewise.Client', categoryIds: categoryIds ? (Array.isArray(categoryIds) ? categoryIds : [categoryIds]) : undefined, negated: negated, settings: internalSettingsBuilder.build(), }; this.filters.push(filter); return this; } /** * Adds a content category has child filter to the request. * @param categoryIds - Array of category IDs or a single ID (optional). * @param negated - If true, negates the filter (default is false). * @param options - Optional settings for the filter. * @returns The ContentFilterBuilder instance for chaining. */ addContentCategoryHasChildFilter(categoryIds, negated = false, options) { var _a; const internalSettingsBuilder = new FilterSettingsBuilder(); (_a = options === null || options === void 0 ? void 0 : options.filterSettings) === null || _a === void 0 ? void 0 : _a.call(options, internalSettingsBuilder); const filter = { $type: 'Relewise.Client.Requests.Filters.ContentCategoryHasChildFilter, Relewise.Client', categoryIds: categoryIds ? (Array.isArray(categoryIds) ? categoryIds : [categoryIds]) : undefined, negated: negated, settings: internalSettingsBuilder.build(), }; this.filters.push(filter); return this; } /** * Adds a content category has ancestor filter to the request. * @param categoryIds - Array of category IDs or a single ID (optional). * @param negated - If true, negates the filter (default is false). * @param options - Optional settings for the filter. * @returns The ContentFilterBuilder instance for chaining. */ addContentCategoryHasAncestorFilter(categoryIds, negated = false, options) { var _a; const internalSettingsBuilder = new FilterSettingsBuilder(); (_a = options === null || options === void 0 ? void 0 : options.filterSettings) === null || _a === void 0 ? void 0 : _a.call(options, internalSettingsBuilder); const filter = { $type: 'Relewise.Client.Requests.Filters.ContentCategoryHasAncestorFilter, Relewise.Client', categoryIds: categoryIds ? (Array.isArray(categoryIds) ? categoryIds : [categoryIds]) : undefined, negated: negated, settings: internalSettingsBuilder.build(), }; this.filters.push(filter); return this; } /** * Adds a content category has contents filter to the request ensuring that only categories with content in them are returned. * @param negated - If true, negates the filter (default is false). * @param options - Optional settings for the filter. * @returns The ContentFilterBuilder instance for chaining. */ addContentCategoryHasContentsFilter(negated = false, options) { var _a; const internalSettingsBuilder = new FilterSettingsBuilder(); (_a = options === null || options === void 0 ? void 0 : options.filterSettings) === null || _a === void 0 ? void 0 : _a.call(options, internalSettingsBuilder); const filter = { $type: 'Relewise.Client.Requests.Filters.ContentCategoryHasContentsFilter, Relewise.Client', negated: negated, settings: internalSettingsBuilder.build(), }; this.filters.push(filter); return this; } /** * Adds a content category data filter to the request. * @param key - Data key. * @param conditionBuilder - Function to build the condition. * @param mustMatchAllConditions - If true, all conditions must be met (default is true). * @param filterOutIfKeyIsNotFound - If true, filters out categories without the key (default is true). * @param negated - If true, negates the filter (default is false). * @param options - Optional settings for the filter. * @returns The ContentFilterBuilder instance for chaining. */ addContentCategoryDataFilter(key, conditionBuilder, mustMatchAllConditions = true, filterOutIfKeyIsNotFound = true, negated = false, options) { var _a; const builder = new ConditionBuilder(); conditionBuilder(builder); const internalSettingsBuilder = new FilterSettingsBuilder(); (_a = options === null || options === void 0 ? void 0 : options.filterSettings) === null || _a === void 0 ? void 0 : _a.call(options, internalSettingsBuilder); const filter = { $type: 'Relewise.Client.Requests.Filters.ContentCategoryDataFilter, Relewise.Client', key: key, filterOutIfKeyIsNotFound: filterOutIfKeyIsNotFound, mustMatchAllConditions: mustMatchAllConditions, conditions: builder.build(), negated: negated, objectPath: options === null || options === void 0 ? void 0 : options.objectPath, settings: internalSettingsBuilder.build(), }; this.filters.push(filter); return this; } /** * Adds a content data filter to the request. * @param key - Data key. * @param conditionBuilder - Function to build the condition. * @param mustMatchAllConditions - If true, all conditions must be met (default is true). * @param filterOutIfKeyIsNotFound - If true, filters out contents without the key (default is true). * @param negated - If true, negates the filter (default is false). * @param options - Optional settings for the filter. * @returns The ContentFilterBuilder instance for chaining. */ addContentDataFilter(key, conditionBuilder, mustMatchAllConditions = true, filterOutIfKeyIsNotFound = true, negated = false, options) { var _a; const builder = new ConditionBuilder(); conditionBuilder(builder); const internalSettingsBuilder = new FilterSettingsBuilder(); (_a = options === null || options === void 0 ? void 0 : options.filterSettings) === null || _a === void 0 ? void 0 : _a.call(options, internalSettingsBuilder); const filter = { $type: 'Relewise.Client.Requests.Filters.ContentDataFilter, Relewise.Client', key: key, filterOutIfKeyIsNotFound: filterOutIfKeyIsNotFound, mustMatchAllConditions: mustMatchAllConditions, conditions: builder.build(), negated: negated, objectPath: options === null || options === void 0 ? void 0 : options.objectPath, settings: internalSettingsBuilder.build(), }; this.filters.push(filter); return this; } /** * Adds a content category has key filter to the request. * @param key - Data key. * @param negated - If true, negates the filter (default is false). * @param options - Optional settings for the filter. * @returns The ContentFilterBuilder instance for chaining. */ addContentCategoryDataHasKeyFilter(key, negated = false, options) { var _a; const internalSettingsBuilder = new FilterSettingsBuilder(); (_a = options === null || options === void 0 ? void 0 : options.filterSettings) === null || _a === void 0 ? void 0 : _a.call(options, internalSettingsBuilder); const filter = { $type: 'Relewise.Client.Requests.Filters.ContentCategoryDataHasKeyFilter, Relewise.Client', key: key, negated: negated, settings: internalSettingsBuilder.build(), }; this.filters.push(filter); return this; } /** * Adds a content category is disabled filter to the request. Only works for content queries, not in searches or recommendations. * @param negated - If true, negates the filter (default is false). * @param options - Optional settings for the filter. * @returns The ContentFilterBuilder instance for chaining. */ addContentCategoryDisabledFilter(negated = false, options) { var _a; const internalSettingsBuilder = new FilterSettingsBuilder(); (_a = options === null || options === void 0 ? void 0 : options.filterSettings) === null || _a === void 0 ? void 0 : _a.call(options, internalSettingsBuilder); const filter = { $type: 'Relewise.Client.Requests.Filters.ContentCategoryDisabledFilter, Relewise.Client', negated: negated, settings: internalSettingsBuilder.build(), }; this.filters.push(filter); return this; } /** * Adds a filter to only return content categories recently viewed by the user. * @param sinceMinutesAgo - Time in minutes since the category was viewed. * @param negated - If true, negates the filter (default is false). * @param options - Optional settings for the filter. * @returns The ContentFilterBuilder instance for chaining. */ addContentCategoryRecentlyViewedByUserFilter(sinceMinutesAgo, negated = false, options) { var _a; const internalSettingsBuilder = new FilterSettingsBuilder(); (_a = options === null || options === void 0 ? void 0 : options.filterSettings) === null || _a === void 0 ? void 0 : _a.call(options, internalSettingsBuilder); const filter = { $type: 'Relewise.Client.Requests.Filters.ContentCategoryRecentlyViewedByUserFilter, Relewise.Client', sinceMinutesAgo: sinceMinutesAgo, negated: negated, settings: internalSettingsBuilder.build(), }; this.filters.push(filter); return this; } /** * Adds a content has key filter to the request. * @param key - Data key. * @param negated - If true, negates the filter (default is false). * @param options - Optional settings for the filter. * @returns The ContentFilterBuilder instance for chaining. */ addContentDataHasKeyFilter(key, negated = false, options) { var _a; const internalSettingsBuilder = new FilterSettingsBuilder(); (_a = options === null || options === void 0 ? void 0 : options.filterSettings) === null || _a === void 0 ? void 0 : _a.call(options, internalSettingsBuilder); const filter = { $type: 'Relewise.Client.Requests.Filters.ContentDataHasKeyFilter, Relewise.Client', key: key, negated: negated, settings: internalSettingsBuilder.build(), }; this.filters.push(filter); return this; } /** * Adds a content is disabled filter to the request. Only works for content queries, not in searches or recommendations. * @param negated - If true, negates the filter (default is false). * @param options - Optional settings for the filter. * @returns The ContentFilterBuilder instance for chaining. */ addContentDisabledFilter(negated = false, options) { var _a; const internalSettingsBuilder = new FilterSettingsBuilder(); (_a = options === null || options === void 0 ? void 0 : options.filterSettings) === null || _a === void 0 ? void 0 : _a.call(options, internalSettingsBuilder); const filter = { $type: 'Relewise.Client.Requests.Filters.ContentDisabledFilter, Relewise.Client', negated: negated, settings: internalSettingsBuilder.build(), }; this.filters.push(filter); return this; } /** * Adds a filter to only return content recently viewed by the user. * @param sinceMinutesAgo - Time in minutes since the content was viewed. * @param negated - If true, negates the filter (default is false). * @param options - Optional settings for the filter. * @returns The ContentFilterBuilder instance for chaining. */ addContentRecentlyViewedByUserFilter(sinceMinutesAgo, negated = false, options) { var _a; const internalSettingsBuilder = new FilterSettingsBuilder(); (_a = options === null || options === void 0 ? void 0 : options.filterSettings) === null || _a === void 0 ? void 0 : _a.call(options, internalSettingsBuilder); const filter = { $type: 'Relewise.Client.Requests.Filters.ContentRecentlyViewedByUserFilter, Relewise.Client', sinceMinutesAgo: sinceMinutesAgo, negated: negated, settings: internalSettingsBuilder.build(), }; this.filters.push(filter); return this; } /** * Adds a content has categories filter to the request. * @param negated - If true, negates the filter (default is false). * @param options - Optional settings for the filter. * @returns The ContentFilterBuilder instance for chaining. */ addContentHasCategoriesFilter(negated = false, options) { var _a; const internalSettingsBuilder = new FilterSettingsBuilder(); (_a = options === null || options === void 0 ? void 0 : options.filterSettings) === null || _a === void 0 ? void 0 : _a.call(options, internalSettingsBuilder); const filter = { $type: 'Relewise.Client.Requests.Filters.ContentHasCategoriesFilter, Relewise.Client', negated: negated, settings: internalSettingsBuilder.build(), }; this.filters.push(filter); return this; } } class ProductFilterBuilder extends FilterBuilderBase { constructor() { super(ProductFilterBuilder); } /** * Adds a product assortment filter to the request. * @param assortmentIds - Array of assortment IDs or a single ID. * @param negated - If true, negates the filter (default is false). * @param options - Optional settings for the filter. * @returns The ProductFilterBuilder instance for chaining. */ addProductAssortmentFilter(assortmentIds, negated = false, options) { var _a; const assortments = Array.isArray(assortmentIds) ? assortmentIds : [assortmentIds]; const internalSettingsBuilder = new FilterSettingsBuilder(); (_a = options === null || options === void 0 ? void 0 : options.filterSettings) === null || _a === void 0 ? void 0 : _a.call(options, internalSettingsBuilder); const filter = { $type: 'Relewise.Client.Requests.Filters.ProductAssortmentFilter, Relewise.Client', assortments: assortments, negated: negated, settings: internalSettingsBuilder.build(), }; this.filters.push(filter); return this; } /** * Adds a product category assortment filter to the request. * @param assortmentIds - Array of assortment IDs or a single ID. * @param negated - If true, negates the filter (default is false). * @param options - Optional settings for the filter. * @returns The ProductFilterBuilder instance for chaining. */ addProductCategoryAssortmentFilter(assortmentIds, negated = false, options) { var _a; const assortments = Array.isArray(assortmentIds) ? assortmentIds : [assortmentIds]; const internalSettingsBuilder = new FilterSettingsBuilder(); (_a = options === null || options === void 0 ? void 0 : options.filterSettings) === null || _a === void 0 ? void 0 : _a.call(options, internalSettingsBuilder); const filter = { $type: 'Relewise.Client.Requests.Filters.ProductCategoryAssortmentFilter, Relewise.Client', assortments: assortments, negated: negated, settings: internalSettingsBuilder.build(), }; this.filters.push(filter); return this; } /** * Filters the request to only return products within the specified categories. * @param evaluationScope - Scope of the category evaluation (ImmediateParent, ImmediateParentOrItsParent, Ancestor). * @param categoryIds - Array of category IDs or a single ID. * @param negated - If true, negates the filter (default is false). * @param options - Optional settings for the filter. * @returns The ProductFilterBuilder instance for chaining. */ addProductCategoryIdFilter(evaluationScope, categoryIds, negated = false, options) { var _a; const ids = Array.isArray(categoryIds) ? categoryIds : [categoryIds]; const internalSettingsBuilder = new FilterSettingsBuilder(); (_a = options === null || options === void 0 ? void 0 : options.filterSettings) === null || _a === void 0 ? void 0 : _a.call(options, internalSettingsBuilder); const filter = { $type: 'Relewise.Client.Requests.Filters.ProductCategoryIdFilter, Relewise.Client', evaluationScope: evaluationScope, categoryIds: ids, negated: negated, settings: internalSettingsBuilder.build(), }; this.filters.push(filter); return this; } /** * Adds a product category data filter to the request. * @param key - Data key. * @param conditionBuilder - Function to build the condition. * @param mustMatchAllConditions - If true, all conditions must be met (default is true). * @param filterOutIfKeyIsNotFound - If true, filters out categories without the key (default is true). * @param negated - If true, negates the filter (default is false). * @param options - Optional settings for the filter. * @returns The ProductFilterBuilder instance for chaining. */ addProductCategoryDataFilter(key, conditionBuilder, mustMatchAllConditions = true, filterOutIfKeyIsNotFound = true, negated = false, options) { var _a; const builder = new ConditionBuilder(); conditionBuilder(builder); const internalSettingsBuilder = new FilterSettingsBuilder(); (_a = options === null || options === void 0 ? void 0 : options.filterSettings) === null || _a === void 0 ? void 0 : _a.call(options, internalSettingsBuilder); const filter = { $type: 'Relewise.Client.Requests.Filters.ProductCategoryDataFilter, Relewise.Client', key: key, filterOutIfKeyIsNotFound: filterOutIfKeyIsNotFound, mustMatchAllConditions: mustMatchAllConditions, conditions: builder.build(), negated: negated, objectPath: options === null || options === void 0 ? void 0 : options.objectPath, settings: internalSettingsBuilder.build(), }; this.filters.push(filter); return this; } /** * Filters the request to only return the specified products. * @param productIds - Array of product IDs or a single ID. * @param negated - If true, negates the filter (default is false). * @param options - Optional settings for the filter. * @returns The ProductFilterBuilder instance for chaining. */ addProductIdFilter(productIds, negated = false, options) { var _a; const ids = Array.isArray(productIds) ? productIds : [productIds]; const internalSettingsBuilder = new FilterSettingsBuilder(); (_a = options === null || options === void 0 ? void 0 : options.filterSettings) === null || _a === void 0 ? void 0 : _a.call(options, inte