@stackbit/cms-sanity
Version:
Stackbit Sanity CMS Interface
60 lines • 2.36 kB
TypeScript
import type { PatchOperations, SanityDocument } from '@sanity/client';
import type * as StackbitTypes from '@stackbit/types';
import type { ModelContext, ModelWithContext } from './sanity-schema-converter';
import type { GetModelByName } from './sanity-document-converter';
export declare function convertUpdateOperation({ operation, ...rest }: {
operation: StackbitTypes.UpdateOperation;
sanityDocument: SanityDocument;
getModelByName: GetModelByName;
model: ModelWithContext;
}): PatchOperations;
export declare const Operations: {
[Type in StackbitTypes.UpdateOperation as Type['opType']]: ({ sanityDocument, operation, getModelByName }: {
sanityDocument: SanityDocument;
operation: Type;
getModelByName: GetModelByName;
model: StackbitTypes.Model<ModelContext>;
}) => PatchOperations;
};
export declare function mapUpdateOperationFieldToSanityValue({ updateOperationField, getModelByName, modelField, rootModel, modelFieldPath, locale, isInList }: {
updateOperationField: StackbitTypes.UpdateOperationField;
getModelByName: GetModelByName;
modelField: StackbitTypes.FieldSpecificProps;
rootModel: StackbitTypes.Model<ModelContext>;
modelFieldPath: string[];
locale: string | undefined;
isInList?: boolean;
}): any;
/**
* In Sanity, a localized field is represented by an array of objects containing the localized field values.
* Each object has three properties:
* - `_key` holds the field's locale
* - `_type` holds the type of the localized value
* - `value` holds the localized value.
*
* Note: the `_type` is not the regular type such as `string` or `object`,
* but a special localized type generated by the Sanity Internationalized Array plugin.
* The map between the localized fields and these types is stored in the model's context.
* title: [
* {
* _key: 'us',
* _type: 'internationalizedArrayStringValue',
* value: 'hello',
* }, {
* _key: 'es',
* _type: 'internationalizedArrayStringValue',
* value: 'hola',
* }
* ]
*/
export declare function localizedValue({ value, model, modelFieldPath, locale }: {
value: any;
model: ModelWithContext;
modelFieldPath: string[];
locale?: string;
}): {
_key: string;
_type: string;
value: any;
};
//# sourceMappingURL=sanity-operation-converter.d.ts.map