Contentful Personalization & Analytics
    Preparing search index...

    Helper methods for resolving Contentful entries against selected optimizations.

    interface UseEntryResolverResult {
        resolveEntry: ResolveEntry;
        resolveEntryData: {
            <
                S extends EntrySkeletonType = EntrySkeletonType,
                L extends string = string,
            >(
                entry: Entry<S, undefined, L>,
                selectedOptimizations?: {
                    experienceId: string;
                    sticky?: boolean;
                    variantIndex: number;
                    variants: Record<string, string>;
                }[],
            ): ResolvedData<S, undefined, L>;
            <
                S extends EntrySkeletonType,
                M extends ChainModifiers = ChainModifiers,
                L extends string = string,
            >(
                entry: Entry<S, M, L>,
                selectedOptimizations?: {
                    experienceId: string;
                    sticky?: boolean;
                    variantIndex: number;
                    variants: Record<string, string>;
                }[],
            ): ResolvedData<S, M, L>;
        };
        resolveOptimizedEntry: {
            <
                S extends EntrySkeletonType = EntrySkeletonType,
                L extends string = string,
            >(
                entry: Entry<S, undefined, L>,
                selectedOptimizations?: {
                    experienceId: string;
                    sticky?: boolean;
                    variantIndex: number;
                    variants: Record<string, string>;
                }[],
            ): ResolvedData<S, undefined, L>;
            <
                S extends EntrySkeletonType,
                M extends ChainModifiers = ChainModifiers,
                L extends string = string,
            >(
                entry: Entry<S, M, L>,
                selectedOptimizations?: {
                    experienceId: string;
                    sticky?: boolean;
                    variantIndex: number;
                    variants: Record<string, string>;
                }[],
            ): ResolvedData<S, M, L>;
        };
    }
    Index

    Properties

    resolveEntry: ResolveEntry

    Resolves an entry and returns only the resolved entry. Use resolveEntryData when the result controls rendering so empty variants can be omitted.

    resolveEntryData: {
        <
            S extends EntrySkeletonType = EntrySkeletonType,
            L extends string = string,
        >(
            entry: Entry<S, undefined, L>,
            selectedOptimizations?: {
                experienceId: string;
                sticky?: boolean;
                variantIndex: number;
                variants: Record<string, string>;
            }[],
        ): ResolvedData<S, undefined, L>;
        <
            S extends EntrySkeletonType,
            M extends ChainModifiers = ChainModifiers,
            L extends string = string,
        >(
            entry: Entry<S, M, L>,
            selectedOptimizations?: {
                experienceId: string;
                sticky?: boolean;
                variantIndex: number;
                variants: Record<string, string>;
            }[],
        ): ResolvedData<S, M, L>;
    }

    Resolves an entry and returns the full result needed to omit empty variants before rendering.

    Type Declaration

      • <S extends EntrySkeletonType = EntrySkeletonType, L extends string = string>(
            entry: Entry<S, undefined, L>,
            selectedOptimizations?: {
                experienceId: string;
                sticky?: boolean;
                variantIndex: number;
                variants: Record<string, string>;
            }[],
        ): ResolvedData<S, undefined, L>
      • Resolve a Contentful entry to the appropriate optimized variant (or return the baseline entry if no matching variant is selected).

        Type Parameters

        Parameters

        • entry: Entry<S, undefined, L>

          The baseline entry to resolve.

        • OptionalselectedOptimizations: {
              experienceId: string;
              sticky?: boolean;
              variantIndex: number;
              variants: Record<string, string>;
          }[]

          Optional selected optimization array for the current profile.

          • experienceId: string

            Identifier of the personalization or experiment experience.

          • Optionalsticky?: boolean

            Indicates whether this optimization selection is sticky for the user.

            false
            

            Reuse sticky selections on subsequent requests for the same user rather than re-allocating a new variant.

          • variantIndex: number

            Index of the selected variant within the experience configuration.

            Typically corresponds to the index of the selected OptimizationConfig entry.

          • variants: Record<string, string>

            Mapping of baseline entry IDs to their selected variant entry IDs.

            The keys are component identifiers and the values are the identifiers of the selected variant for that component.

        Returns ResolvedData<S, undefined, L>

        ResolvedData containing the resolved entry and selected optimization metadata (if any).

        This helper is intended for request-local resolution. When the supplied entry comes from a shared application cache, avoid mutating the returned entry in place unless you first clone it.

        const { entry, selectedOptimization } = core.resolveOptimizedEntry(
        baselineEntry,
        data.selectedOptimizations,
        )
      • <
            S extends EntrySkeletonType,
            M extends ChainModifiers = ChainModifiers,
            L extends string = string,
        >(
            entry: Entry<S, M, L>,
            selectedOptimizations?: {
                experienceId: string;
                sticky?: boolean;
                variantIndex: number;
                variants: Record<string, string>;
            }[],
        ): ResolvedData<S, M, L>
      • Type Parameters

        Parameters

        • entry: Entry<S, M, L>
        • OptionalselectedOptimizations: {
              experienceId: string;
              sticky?: boolean;
              variantIndex: number;
              variants: Record<string, string>;
          }[]
          • experienceId: string

            Identifier of the personalization or experiment experience.

          • Optionalsticky?: boolean

            Indicates whether this optimization selection is sticky for the user.

            false
            

            Reuse sticky selections on subsequent requests for the same user rather than re-allocating a new variant.

          • variantIndex: number

            Index of the selected variant within the experience configuration.

            Typically corresponds to the index of the selected OptimizationConfig entry.

          • variants: Record<string, string>

            Mapping of baseline entry IDs to their selected variant entry IDs.

            The keys are component identifiers and the values are the identifiers of the selected variant for that component.

        Returns ResolvedData<S, M, L>

    resolveOptimizedEntry: {
        <
            S extends EntrySkeletonType = EntrySkeletonType,
            L extends string = string,
        >(
            entry: Entry<S, undefined, L>,
            selectedOptimizations?: {
                experienceId: string;
                sticky?: boolean;
                variantIndex: number;
                variants: Record<string, string>;
            }[],
        ): ResolvedData<S, undefined, L>;
        <
            S extends EntrySkeletonType,
            M extends ChainModifiers = ChainModifiers,
            L extends string = string,
        >(
            entry: Entry<S, M, L>,
            selectedOptimizations?: {
                experienceId: string;
                sticky?: boolean;
                variantIndex: number;
                variants: Record<string, string>;
            }[],
        ): ResolvedData<S, M, L>;
    }

    Resolves an entry and returns the full SDK resolver payload.

    Type Declaration

      • <S extends EntrySkeletonType = EntrySkeletonType, L extends string = string>(
            entry: Entry<S, undefined, L>,
            selectedOptimizations?: {
                experienceId: string;
                sticky?: boolean;
                variantIndex: number;
                variants: Record<string, string>;
            }[],
        ): ResolvedData<S, undefined, L>
      • Resolve a Contentful entry to the appropriate optimized variant (or return the baseline entry if no matching variant is selected).

        Type Parameters

        Parameters

        • entry: Entry<S, undefined, L>

          The baseline entry to resolve.

        • OptionalselectedOptimizations: {
              experienceId: string;
              sticky?: boolean;
              variantIndex: number;
              variants: Record<string, string>;
          }[]

          Optional selected optimization array for the current profile.

          • experienceId: string

            Identifier of the personalization or experiment experience.

          • Optionalsticky?: boolean

            Indicates whether this optimization selection is sticky for the user.

            false
            

            Reuse sticky selections on subsequent requests for the same user rather than re-allocating a new variant.

          • variantIndex: number

            Index of the selected variant within the experience configuration.

            Typically corresponds to the index of the selected OptimizationConfig entry.

          • variants: Record<string, string>

            Mapping of baseline entry IDs to their selected variant entry IDs.

            The keys are component identifiers and the values are the identifiers of the selected variant for that component.

        Returns ResolvedData<S, undefined, L>

        ResolvedData containing the resolved entry and selected optimization metadata (if any).

        This helper is intended for request-local resolution. When the supplied entry comes from a shared application cache, avoid mutating the returned entry in place unless you first clone it.

        const { entry, selectedOptimization } = core.resolveOptimizedEntry(
        baselineEntry,
        data.selectedOptimizations,
        )
      • <
            S extends EntrySkeletonType,
            M extends ChainModifiers = ChainModifiers,
            L extends string = string,
        >(
            entry: Entry<S, M, L>,
            selectedOptimizations?: {
                experienceId: string;
                sticky?: boolean;
                variantIndex: number;
                variants: Record<string, string>;
            }[],
        ): ResolvedData<S, M, L>
      • Type Parameters

        Parameters

        • entry: Entry<S, M, L>
        • OptionalselectedOptimizations: {
              experienceId: string;
              sticky?: boolean;
              variantIndex: number;
              variants: Record<string, string>;
          }[]
          • experienceId: string

            Identifier of the personalization or experiment experience.

          • Optionalsticky?: boolean

            Indicates whether this optimization selection is sticky for the user.

            false
            

            Reuse sticky selections on subsequent requests for the same user rather than re-allocating a new variant.

          • variantIndex: number

            Index of the selected variant within the experience configuration.

            Typically corresponds to the index of the selected OptimizationConfig entry.

          • variants: Record<string, string>

            Mapping of baseline entry IDs to their selected variant entry IDs.

            The keys are component identifiers and the values are the identifiers of the selected variant for that component.

        Returns ResolvedData<S, M, L>