1 |
|
2 | import { GraphQLSchema, GraphQLNamedType, GraphQLFieldResolver } from 'graphql';
|
3 | import { SanityWebhookBody } from './sanity';
|
4 | interface GatsbyEventEmitter {
|
5 | on: (event: String, fn: Function) => null;
|
6 | off: (event: String, fn: Function) => null;
|
7 | }
|
8 | interface GatsbyStoreState {
|
9 | program: {
|
10 | directory: string;
|
11 | };
|
12 | }
|
13 | interface GatsbyStore {
|
14 | getState: () => GatsbyStoreState;
|
15 | }
|
16 | export interface GatsbyNode {
|
17 | id: string;
|
18 | _id: string;
|
19 | parent?: string | null;
|
20 | children?: string[];
|
21 | internal?: {
|
22 | mediaType?: string;
|
23 | type: string;
|
24 | contentDigest: string;
|
25 | };
|
26 | [key: string]: any;
|
27 | }
|
28 | export interface GatsbyReporter {
|
29 | info: (msg: string) => null;
|
30 | warn: (msg: string) => null;
|
31 | error: (msg: string) => null;
|
32 | panic: (msg: string) => null;
|
33 | panicOnBuild: (msg: string) => null;
|
34 | }
|
35 | export interface GatsbyParentChildLink {
|
36 | parent: GatsbyNode;
|
37 | child: GatsbyNode;
|
38 | }
|
39 | export interface GatsbyDeleteOptions {
|
40 | node: GatsbyNode;
|
41 | }
|
42 | export declare type GatsbyNodeModel = {
|
43 | getNodeById: (args: {
|
44 | id: string;
|
45 | }) => GatsbyNode;
|
46 | };
|
47 | export declare type GatsbyGraphQLContext = {
|
48 | nodeModel: GatsbyNodeModel;
|
49 | };
|
50 | export interface MinimalGatsbyContext {
|
51 | createNodeId: GatsbyNodeIdCreator;
|
52 | getNode: (id: string) => GatsbyNode | undefined;
|
53 | }
|
54 | export declare type GatsbyTypesCreator = (types: string) => null;
|
55 | export declare type GatsbyResolverMap = {
|
56 | [typeName: string]: {
|
57 | [fieldName: string]: {
|
58 | type?: string;
|
59 | resolve: GraphQLFieldResolver<{
|
60 | [key: string]: any;
|
61 | }, GatsbyGraphQLContext>;
|
62 | };
|
63 | };
|
64 | };
|
65 | export declare type GatsbyResolversCreator = (resolvers: GatsbyResolverMap) => null;
|
66 | export declare type GatsbyNodeCreator = (node: GatsbyNode) => null;
|
67 | export declare type GatsbyNodeDeletor = (options: GatsbyDeleteOptions) => null;
|
68 | export declare type GatsbyNodeIdCreator = (id: string, namespace?: string) => string;
|
69 | export declare type GatsbyContentDigester = (content: string) => string;
|
70 | export declare type GatsbyParentChildLinker = (link: GatsbyParentChildLink) => null;
|
71 | export interface GatsbyCache {
|
72 | name: string;
|
73 | cache: {
|
74 | del: (key: string) => Promise<any>;
|
75 | get: (key: string) => Promise<any>;
|
76 | set: (key: string, value: any) => Promise<any>;
|
77 | mset: (key1: string, val1: any, key2: string, val2: any, key3?: string, val3?: any) => Promise<any>;
|
78 | };
|
79 | }
|
80 | export interface GatsbyOnNodeTypeContext {
|
81 | type: GraphQLNamedType;
|
82 | }
|
83 | export interface GatsbyContext {
|
84 | emitter: GatsbyEventEmitter;
|
85 | cache: GatsbyCache;
|
86 | actions: GatsbyActions;
|
87 | createNodeId: GatsbyNodeIdCreator;
|
88 | createContentDigest: GatsbyContentDigester;
|
89 | store: GatsbyStore;
|
90 | getNode: (id: string) => GatsbyNode | undefined;
|
91 | getNodes: () => GatsbyNode[];
|
92 | reporter: GatsbyReporter;
|
93 | webhookBody?: SanityWebhookBody;
|
94 | }
|
95 | export interface GatsbySsrContext {
|
96 | setHeadComponents: (components: React.ReactElement[]) => undefined;
|
97 | }
|
98 | export interface GatsbyActions {
|
99 | createTypes: GatsbyTypesCreator;
|
100 | createResolvers: GatsbyResolversCreator;
|
101 | createNode: GatsbyNodeCreator;
|
102 | deleteNode: GatsbyNodeDeletor;
|
103 | createParentChildLink: GatsbyParentChildLinker;
|
104 | touchNode: (options: {
|
105 | nodeId: string;
|
106 | }) => null;
|
107 | addThirdPartySchema: (schema: {
|
108 | schema: GraphQLSchema | string;
|
109 | }) => null;
|
110 | }
|
111 | export interface ReduxSetSchemaAction {
|
112 | payload: GraphQLSchema;
|
113 | }
|
114 | export {};
|