@stackbit/cms-sanity
Version:
Stackbit Sanity CMS Interface
66 lines • 2.87 kB
TypeScript
import { SanityDocument } from '@sanity/client';
import * as StackbitTypes from '@stackbit/types';
import { DocumentHistory, DocumentHistoryMap } from './sanity-api-client';
import { SchemaContext, ModelWithContext, ModelContext } from './sanity-schema-converter';
export interface SanitySchedule {
author: string;
action: ScheduleAction;
createdAt: string;
dataset: string;
description: string;
documents: {
documentId: string;
documentType?: string;
}[];
executeAt: string | null;
executedAt?: string;
id: string;
name: string;
projectId: string;
state: ScheduleState;
stateReason: string;
}
export type ScheduleAction = 'publish' | 'unpublish';
export type ScheduleState = 'cancelled' | 'scheduled' | 'succeeded';
export type DocumentContext = {
publishedDocument?: SanityDocument;
draftDocument?: SanityDocument;
};
export type AssetContext = DocumentContext;
export type ContextualDocument = StackbitTypes.Document<DocumentContext>;
export type ContextualAsset = StackbitTypes.Asset<AssetContext>;
export declare const DRAFT_ID_PREFIX = "drafts.";
export type GetModelByName = StackbitTypes.Cache<SchemaContext, DocumentContext, AssetContext, ModelContext>['getModelByName'];
export type ConvertDocumentsOptions = {
documents: SanityDocument[];
getModelByName: GetModelByName;
documentsHistory?: DocumentHistoryMap;
studioUrl?: string;
};
export declare function getPureObjectId(objectId: string): string;
export declare function getDraftObjectId(objectId: string): string;
export declare function isDraftId(objectId: string): boolean | "";
export declare function convertAndFilterScheduledActions(sanitySchedules: SanitySchedule[]): StackbitTypes.ScheduledAction[];
export declare function convertScheduledAction(sanitySchedule: SanitySchedule): StackbitTypes.ScheduledAction;
export declare function filterScheduledActions(scheduledActions: StackbitTypes.ScheduledAction[]): StackbitTypes.ScheduledAction[];
export declare function convertDocuments({ documents, getModelByName, documentsHistory, studioUrl }: ConvertDocumentsOptions): ContextualDocument[];
export type ConvertDocumentOptions = {
publishedDocument?: SanityDocument;
draftDocument?: SanityDocument;
getModelByName: GetModelByName;
documentHistory?: DocumentHistory[];
studioUrl?: string;
};
export type ConvertAssetsOptions = {
assets: SanityDocument[];
documentsHistory: DocumentHistoryMap;
};
export declare function convertAssets({ assets, documentsHistory }: ConvertAssetsOptions): ContextualAsset[];
export type ConvertFieldsOptions = {
object: Record<string, any>;
modelFields?: StackbitTypes.Field[];
rootModel: ModelWithContext;
modelFieldPath: string[];
getModelByName: GetModelByName;
};
//# sourceMappingURL=sanity-document-converter.d.ts.map