import { Linter, Rule, AST } from 'eslint';
import * as ESTree from 'estree';
import { GraphQLSchema, ASTKindToNode } from 'graphql';
import { JSONSchema } from 'json-schema-to-ts';
import { SiblingOperations } from './siblings.js';
import { GraphQLESTreeNode } from './estree-converter/types.js';
import { IGraphQLConfig } from 'graphql-config';
import '@graphql-tools/utils';

type Schema = GraphQLSchema | null;
type Pointer = string | string[];
interface ParserOptions {
    graphQLConfig?: IGraphQLConfig;
    filePath: string;
}
type ParserServices = {
    schema: Schema;
    siblingOperations: SiblingOperations;
};
type GraphQLESLintParseResult = Linter.ESLintParseResult & {
    services: ParserServices;
};
type Location = AST.SourceLocation | ESTree.Position;
type ReportDescriptorLocation = {
    loc: Location;
} | {
    node: {
        loc: Location;
    };
};
type ReportDescriptor = ReportDescriptorLocation & Rule.ReportDescriptorMessage & Rule.ReportDescriptorOptions;
type GraphQLESLintRuleContext<Options = any[]> = Omit<Rule.RuleContext, 'options' | 'parserServices' | 'report'> & {
    options: Options;
    parserServices: ParserServices;
    report(descriptor: ReportDescriptor): void;
};
type CategoryType = 'Operations' | 'Schema';
type RuleMetaDataDocs = Required<Rule.RuleMetaData>['docs'];
type RuleDocsInfo<T> = Omit<RuleMetaDataDocs, 'category' | 'suggestion'> & {
    category: CategoryType | CategoryType[];
    requiresSchema?: true;
    requiresSiblings?: true;
    examples?: {
        title: string;
        code: string;
        usage?: T;
    }[];
    configOptions?: T | {
        schema?: T;
        operations?: T;
    };
    graphQLJSRuleName?: string;
    isDisabledForAllConfig?: true;
};
type GraphQLESLintRuleListener<WithTypeInfo extends boolean = false> = Record<string, any> & {
    [K in keyof ASTKindToNode]?: (node: GraphQLESTreeNode<ASTKindToNode[K], WithTypeInfo>) => void;
};
type GraphQLESLintRule<Options = [], WithTypeInfo extends boolean = false> = {
    meta: Omit<Rule.RuleMetaData, 'docs' | 'schema'> & {
        docs?: RuleDocsInfo<Options>;
        schema: Readonly<JSONSchema> | [];
    };
    create(context: GraphQLESLintRuleContext<Options>): GraphQLESLintRuleListener<WithTypeInfo>;
};
type ValueOf<T> = T[keyof T];
type Id<T> = {
    [P in keyof T]: T[P];
} & {};
type OmitDistributive<T, K extends PropertyKey> = T extends object ? Id<OmitRecursively<T, K>> : T;
type OmitRecursively<T extends object, K extends PropertyKey> = Omit<{
    [P in keyof T]: OmitDistributive<T[P], K>;
}, K>;
type ConfigName = 'operations-all' | 'operations-recommended' | 'schema-all' | 'schema-recommended' | 'schema-relay';

export { CategoryType, ConfigName, GraphQLESLintParseResult, GraphQLESLintRule, GraphQLESLintRuleContext, GraphQLESLintRuleListener, OmitRecursively, ParserOptions, ParserServices, Pointer, ReportDescriptor, RuleDocsInfo, Schema, ValueOf };
