import * as fetcher from './sanity-schema-fetcher';
import * as converter from './sanity-schema-legacy-converter';
import { UserCommandSpawner } from '@stackbit/types';
export * from './sanity-content-source';
export { SchemaContext, ModelContext, ModelWithContext } from './sanity-schema-converter';
export { DocumentContext, AssetContext, ContextualDocument, ContextualAsset } from './sanity-document-converter';
export { default as SanityEncoderDelegate } from './sanity-encoder-delegate';

export interface LegacyFetchAndConvertSchemaOptions {
    studioPath: string;
    nodePath?: string;
    repoPath: string;
    logger: any;
    spawnRunner: UserCommandSpawner;
    stackbitModels: any;
    presets: any;
}

export function fetchAndConvertSchema(options: LegacyFetchAndConvertSchemaOptions) {
    return fetcher.spawnFetchSchema(options).then((result) => {
        return converter.convertSchema(result, options);
    });
}
