@stackbit/cms-sanity
Version:
Stackbit Sanity CMS Interface
56 lines • 2.36 kB
TypeScript
import { Field } from '@stackbit/types';
import * as StackbitTypes from '@stackbit/types';
import { ModelWithContext } from './sanity-schema-converter';
export declare function resolveLabelFieldForModel(model: any, modelLabelFieldPath: string, fields: Field[]): string;
export declare function getSanityAliasFieldType({ resolvedType, model, modelFieldPath }: {
resolvedType: string;
model: ModelWithContext;
modelFieldPath: string[];
}): string;
export declare function resolvedFieldType({ sanityFieldType, model, modelFieldPath }: {
sanityFieldType: string;
model: ModelWithContext;
modelFieldPath: string[];
}): string;
export declare function isLocalizedModelField(modelField: StackbitTypes.Field | StackbitTypes.FieldListItems): boolean | undefined;
export interface FieldListMultiItem {
type: 'list';
items: StackbitTypes.FieldListItems | StackbitTypes.FieldListItems[];
}
/**
* Sanity 'Array' field type can hold multiple field types.
*
* For example, Sanity Arrays can simultaneously include items of `model`
* and `reference` types. https://www.sanity.io/docs/array-type#wT47gyCx
*
* With that, Sanity Arrays cannot include both primitive and complex types:
* https://www.sanity.io/docs/array-type#fNBIr84P
*
* TODO:
* This is not yet supported by Stackbit's TypeScript types, so the `any`
* must be used. Additionally, if a Sanity array has multiple types of items one
* of which is the 'object' type, then it will also have the 'name' property to
* allow matching 'object' items to their types. The 'name' property is not
* supported in Stackbit list items, so '@ts-ignore' is used.
*
* However, Stackbit client app should be able to render this types of lists correctly.
*
* @example A list that can include items of type 'model', 'reference' and 'object'.
* {
* type: 'list',
* items: [{
* type: 'model',
* models: [...]
* }, {
* type: 'reference',
* models: [...]
* }, {
* type: 'object',
* name: 'nested_object_name',
* fields: {...}
* }]
* }
*/
export declare function getItemTypeForListItem(listItem: any, fieldModel: FieldListMultiItem): StackbitTypes.FieldListItems | null;
export declare function typeIsPrimitive(type: string): type is 'string' | 'number' | 'boolean';
//# sourceMappingURL=utils.d.ts.map