gatsby-source-sanity
Version:
Gatsby source plugin for building websites using Sanity.io as a backend.
83 lines (82 loc) • 2.48 kB
TypeScript
import { GraphQLSchema, GraphQLNamedType } from 'graphql';
interface GatsbyEventEmitter {
on: (event: String, fn: Function) => null;
off: (event: String, fn: Function) => null;
}
interface GatsbyStoreState {
program: {
directory: string;
};
}
interface GatsbyStore {
getState: () => GatsbyStoreState;
}
export interface GatsbyNode {
id: string;
_id: string;
parent?: string | null;
children?: string[];
internal?: {
mediaType?: string;
type: string;
contentDigest: string;
};
[key: string]: any;
}
export interface GatsbyReporter {
info: (msg: string) => null;
warn: (msg: string) => null;
error: (msg: string) => null;
panic: (msg: string) => null;
panicOnBuild: (msg: string) => null;
}
export interface GatsbyParentChildLink {
parent: GatsbyNode;
child: GatsbyNode;
}
export interface GatsbyDeleteOptions {
node: GatsbyNode;
}
export declare type GatsbyNodeCreator = (node: GatsbyNode) => null;
export declare type GatsbyNodeDeletor = (options: GatsbyDeleteOptions) => null;
export declare type GatsbyNodeIdCreator = (id: string, namespace?: string) => string;
export declare type GatsbyContentDigester = (content: string) => string;
export declare type GatsbyParentChildLinker = (link: GatsbyParentChildLink) => null;
export interface GatsbyCache {
name: string;
cache: {
del: (key: string) => Promise<any>;
get: (key: string) => Promise<any>;
set: (key: string, value: any) => Promise<any>;
mset: (key1: string, val1: any, key2: string, val2: any, key3?: string, val3?: any) => Promise<any>;
};
}
export interface GatsbyOnNodeTypeContext {
type: GraphQLNamedType;
}
export interface GatsbyContext {
emitter: GatsbyEventEmitter;
cache: GatsbyCache;
actions: GatsbyActions;
createNodeId: GatsbyNodeIdCreator;
createContentDigest: GatsbyContentDigester;
store: GatsbyStore;
getNode: (id: string) => GatsbyNode | undefined;
getNodes: () => GatsbyNode[];
reporter: GatsbyReporter;
}
export interface GatsbyActions {
createNode: GatsbyNodeCreator;
deleteNode: GatsbyNodeDeletor;
createParentChildLink: GatsbyParentChildLinker;
touchNode: (options: {
nodeId: string;
}) => null;
addThirdPartySchema: (schema: {
schema: GraphQLSchema | string;
}) => null;
}
export interface ReduxSetSchemaAction {
payload: GraphQLSchema;
}
export {};