/** * Contents utils. */ import { CommercePagesRankingStrategy, type GenerateSEOPathnameQuery } from './types/index.js'; import type { CommercePages, ContentMetadata, QueryCommercePages, QuerySearchContents } from '@farfetch/blackout-client'; /** * Constant that represent all possible static values to apply to an environment * code variable. */ export declare enum ContentEnvironmentCode { Live = "live", Preview = "preview" } /** * Generate a ranking number for each commerce page. * * @example * ``` * const pageRanking = getPageRanking({ custom: { type: "listing" } }); * Result of pageRanking === 0; * ``` * * @param metadata - Content metadata object with custom attributes. * * @returns Ranking number for a specific commerce page. */ export declare const getPageRanking: (metadata: ContentMetadata) => number; /** * Method to check each page ranking and return the best one. * * @example * ``` * const bestRankedCommercePage = getBestRankedCommercePageUsingDefaultStrategy({ entries: [...pages] }); * Result of bestRankedCommercePage === { entries: [bestRankedPage] }; * ``` * * @param result - Commerce page payload result. * * @returns Selected page with best ranking using the default strategy. */ export declare const getBestRankedCommercePageUsingDefaultStrategy: (result: CommercePages) => CommercePages; /** * Method to return the best ranked commerce page with all components from other * pages without duplicates. This implementation only works with content from new Content Tool * * @example * ``` * const bestRankedCommercePage = getBestRankedCommercePageUsingMergeStrategy({ entries: [...pages] }); * Result of bestRankedCommercePage === { entries: [{ components: [...componentsFromAllPagesMerged] }] }; * ``` * * @param result - Commerce page payload result. * * @returns Selected page with best ranking and the components of all commerce pages merged. */ export declare const getBestRankedCommercePageUsingMergeStrategy: (result: CommercePages) => CommercePages; /** * Method to calculate the ranking for commerce pages, according to the selected * strategy. * * @example * ``` * const commercePagesRanked = applyCommercePagesStrategy({ entries: [...pages] }, 'merge'); * ``` * * @param result - Commerce page payload result. * @param strategy - The selected ranking strategy (E.g. 'default | merge'). * * @returns Selected page with best ranking. */ export declare const applyCommercePagesRankingStrategy: (result: CommercePages, strategy?: CommercePagesRankingStrategy) => CommercePages; /** * Build a hash with query object received to identify the type of content, when * searching for contents. * * @example * ``` * const contentHash = generateContentHash({ codes: 'about', contentTypeCode: 'pages', 'target.language': 'en-US' }); * Result of contentHash === 'pages!about!en-US'; * ``` * * @param query - Object with query parameters applied to search contents. * * @returns - Hash built to identify a content. */ export declare const generateContentHash: (query: QuerySearchContents | QueryCommercePages | undefined) => string; /** * Build a hash with query object received to identify the page of the metadata * selected. * * @example * ``` * const pathname = generateSEOPathname({ path: '/about'}); * Result of pathname === '/about'; * ``` * * @param query - Object with query parameters applied to search for metadata. * * @returns - Hash built to identify the metadata for a specific page and pageType. */ export declare const generateSEOPathname: (query?: GenerateSEOPathnameQuery) => string;