import { Model } from '@stackbit/sdk'; import { Field, FieldListItems } from '@stackbit/types'; import * as ContentStoreTypes from '../types'; export declare function getModelFieldAtFieldPath({ document, fieldPath, modelMap, locale }: { document: ContentStoreTypes.Document; fieldPath: (string | number)[]; modelMap: Record; locale?: string; }): Field | FieldListItems; export type GetDocumentFieldAtFieldPathOptions = { document: ContentStoreTypes.Document; fieldPath: (string | number)[]; locale?: string; isFullFieldPath?: boolean; returnUndefined?: boolean; }; export type GetDocumentFieldAtFieldPathOptionsThrow = GetDocumentFieldAtFieldPathOptions & { returnUndefined?: false; }; export type GetDocumentFieldAtFieldPathOptionsUndefined = GetDocumentFieldAtFieldPathOptions & { returnUndefined: true; }; /** * This function receives a `document` and returns DocumentFieldNonLocalized at * the specified `fieldPath` while resolving any localized fields with the * specified `locale`. * * @example * getDocumentFieldAtFieldPath({ * document, * locale, * fieldPath: ['sections', 1, 'title'] * }) * * For improved localization support, use the getModelAndDocumentFieldForLocalizedFieldPath * method instead. * * The `isFullFieldPath` flag specifies if the `fieldPath` includes container * specifiers such as "fields" and "items". * * By default, if the document field at the specified `fieldPath` not found, this * function will throw exception. Setting `returnUndefined` to true will allow * the function to return `undefined` if the document field is not found. * * @example * isFullFieldPath: false => fieldPath: ['sections', 1, 'title'] * isFullFieldPath: true => fieldPath: ['fields', 'sections', 'items', 1, 'fields', 'title'] */ export declare function getDocumentFieldAtFieldPath(options: GetDocumentFieldAtFieldPathOptionsThrow): ContentStoreTypes.DocumentFieldNonLocalized; export declare function getDocumentFieldAtFieldPath(options: GetDocumentFieldAtFieldPathOptionsUndefined): ContentStoreTypes.DocumentFieldNonLocalized | undefined; /** * This function receives a `document` and a `modelMap` and returns an object * with DocumentFieldNonLocalized and a model Field at the specified `fieldPath` * while resolving any localized fields with the specified `locale`. * * @example * getDocumentAndModelFieldAtFieldPath({ * document, * locale, * modelMap, * fieldPath: ['sections', 1, 'title'] * }) * * For improved localization support, use the getModelAndDocumentFieldForLocalizedFieldPath * method instead. * * The `isFullFieldPath` flag specifies if the `fieldPath` includes container * specifiers such as "fields" and "items". * * @example * isFullFieldPath: false => fieldPath: ['sections', 1, 'title'] * isFullFieldPath: true => fieldPath: ['fields', 'sections', 'items', 1, 'fields', 'title'] */ export declare function getDocumentAndModelFieldAtFieldPath({ document, fieldPath, modelMap, locale, isFullFieldPath }: { document: ContentStoreTypes.Document; fieldPath: (string | number)[]; modelMap: Record; locale?: string; isFullFieldPath?: boolean; }): { modelField: Field | FieldListItems; documentField: ContentStoreTypes.DocumentFieldNonLocalized; }; /** * This function receives a `document` and a `modelMap` and returns an object * with DocumentField and a model Field at the specified `fieldPath`. * * If some fields along the fieldPath are localized, the `fieldPath` must * contain the locale of the field under the "locales" property. The locales * along the field path don't have to be the same. * * @example * fieldPath: ['fields', 'button', 'locales', 'en', 'fields', 'title', 'locales', 'es'] * * If the provided `fieldPath` points to a list item, the returned model field * and document field will belong to a list item. In this case, the model field * will contain only field-specific properties and the document field will be * localized. * * @example * fieldPath: ['fields', 'buttons', 'items', 2] * * The `isFullFieldPath` flag specifies if the `fieldPath` includes container * specifiers such as "fields" and "items". * * @example * isFullFieldPath: false => fieldPath: ['sections', 1, 'title', 'es'] * isFullFieldPath: true => fieldPath: ['fields', 'sections', 'items', 1, 'fields', 'title', 'locales', 'es'] */ export declare function getModelAndDocumentFieldForLocalizedFieldPath({ document, fieldPath, modelMap, isFullFieldPath }: { document: ContentStoreTypes.Document; fieldPath: (string | number)[]; modelMap: Record; isFullFieldPath?: boolean; }): { modelField: Field | FieldListItems; documentField?: ContentStoreTypes.DocumentField | ContentStoreTypes.DocumentListFieldItems; }; //# sourceMappingURL=field-path-utils.d.ts.map