///
import { FieldConfig, NamespaceConfig } from './typeDefs';
export declare type AstNodeKinds = 'rootType' | 'dir' | 'file' | 'root';
export interface AstBaseNode {
kind: AstNodeKinds;
name: string;
absPath: string;
}
export interface AstRootTypeNode extends AstBaseNode {
kind: 'rootType';
children: AstDirChildren;
namespaceConfig?: AstFileNode;
}
export declare type AstDirChildren = {
[key: string]: AstDirNode | AstFileNode;
};
export interface AstDirNode extends AstBaseNode {
kind: 'dir';
children: AstDirChildren;
namespaceConfig?: AstFileNode;
}
export interface AstFileNode extends AstBaseNode {
kind: 'file';
code: {
default?: FieldConfig | NamespaceConfig;
};
/**
* This FieldConfig loaded from `code` and validated.
* This property is used by ast transformers and stores the last version of modified config.
* This value will be used by astToSchema method.
*/
fieldConfig: FieldConfig;
}
export declare type RootTypeNames = 'query' | 'mutation' | 'subscription';
export interface AstRootNode extends AstBaseNode {
kind: 'root';
children: Record;
}
export declare const defaultOptions: DirectoryToAstOptions;
export interface DirectoryToAstOptions {
/** Scan relative directory to `module` which was provided as a first arg to directoryToAst method. By default `.` */
rootDir?: string;
/** Which file extensions should be loaded. By default: .js, .ts */
extensions?: string[];
/** Regexp or custom function which determines should be loaded file/dir or not */
include?: RegExp | ((path: string, kind: 'dir' | 'file', filename: string) => boolean);
/** Regexp or custom function which determines should file/dir be skipped. It take precedence over `include` option. */
exclude?: RegExp | ((path: string, kind: 'dir' | 'file', filename: string) => boolean);
}
/**
* Traverses directories and construct AST for your graphql entrypoints.
*
* @param m – is a NodeJS Module which provides a way to load modules from scanned dir in the regular nodejs way
* @param options – set of options which helps to customize rules of what files/dirs should be loaded or not
*/
export declare function directoryToAst(m: NodeModule, options?: DirectoryToAstOptions): AstRootNode;
export declare function getAstForDir(m: NodeModule, absPath: string, options?: DirectoryToAstOptions): AstDirNode | void;
export declare function getAstForFile(m: NodeModule, absPath: string, options?: DirectoryToAstOptions): AstFileNode | void;
//# sourceMappingURL=directoryToAst.d.ts.map