///
import { GraphQLError, GraphQLSchema, SourceLocation, DocumentNode } from 'graphql';
import { IncomingMessage, ServerResponse } from 'http';
import { PluginHookFn } from './postgraphile/pluginHook';
import { Pool } from 'pg';
import { Plugin, PostGraphileCoreOptions } from 'postgraphile-core';
import jwt = require('jsonwebtoken');
import { EventEmitter } from 'events';
import { PostGraphileResponse } from './postgraphile/http/frameworks';
import { ShutdownActions } from './postgraphile/shutdownActions';
import { KeyObject } from 'crypto';
declare type PromiseOrDirect = T | Promise;
declare type DirectOrCallback = T | ((req: Request) => PromiseOrDirect);
/**
* A narrower type than `any` that won’t swallow errors from assumptions about
* code.
*
* For example `(x as any).anything()` is ok. That function then returns `any`
* as well so the problem compounds into `(x as any).anything().else()` and the
* problem just goes from there. `any` is a type black hole that swallows any
* useful type information and shouldn’t be used unless you know what you’re
* doing.
*
* With `mixed` you must *prove* the type is what you want to use.
*
* The `mixed` type is identical to the `mixed` type in Flow.
*
* @see https://github.com/Microsoft/TypeScript/issues/9999
* @see https://flowtype.org/docs/builtins.html#mixed
*/
export declare type mixed = Record | string | number | boolean | undefined | null;
export declare type Middleware = (req: Request, res: Response, next: (errOrEscape?: any) => void) => void;
export interface PostGraphileOptions extends PostGraphileCoreOptions {
watchPg?: boolean;
retryOnInitFail?: boolean | ((error: Error, attempts: number) => boolean | Promise);
ownerConnectionString?: string;
subscriptions?: boolean;
live?: boolean;
websockets?: ('v0' | 'v1')[];
websocketOperations?: 'all' | 'subscriptions';
websocketMiddlewares?: Array>;
pgDefaultRole?: string;
dynamicJson?: boolean;
setofFunctionsContainNulls?: boolean;
classicIds?: boolean;
disableDefaultMutations?: boolean;
ignoreRBAC?: boolean;
ignoreIndexes?: boolean;
includeExtensionResources?: boolean;
showErrorStack?: boolean | 'json';
extendedErrors?: Array;
handleErrors?: (errors: ReadonlyArray, req: Request, res: Response) => ReadonlyArray;
appendPlugins?: Array;
prependPlugins?: Array;
replaceAllPlugins?: Array;
skipPlugins?: Array;
readCache?: string | Record;
writeCache?: string;
exportJsonSchemaPath?: string;
exportGqlSchemaPath?: string;
sortExport?: boolean;
graphqlRoute?: string;
eventStreamRoute?: string;
externalGraphqlRoute?: string;
externalEventStreamRoute?: string;
graphiqlRoute?: string;
externalUrlBase?: string;
graphiql?: boolean;
graphiqlCredentials?: 'include' | 'omit' | 'same-origin';
enhanceGraphiql?: boolean;
enableCors?: boolean;
bodySizeLimit?: string;
enableQueryBatching?: boolean;
jwtSecret?: Exclude;
jwtPublicKey?: jwt.Secret | jwt.GetPublicKeyOrSecret;
jwtVerifyOptions?: jwt.VerifyOptions;
jwtSignOptions?: jwt.SignOptions;
jwtRole?: Array;
jwtPgTypeIdentifier?: string;
jwtAudiences?: Array;
legacyRelations?: 'only' | 'deprecated' | 'omit';
legacyJsonUuid?: boolean;
disableQueryLog?: boolean;
pgSettings?: DirectOrCallback;
allowExplain?: DirectOrCallback;
additionalGraphQLContextFromRequest?: (req: Request, res: Response) => Promise>;
pluginHook?: PluginHookFn;
simpleCollections?: 'omit' | 'both' | 'only';
queryCacheMaxSize?: number;
}
export interface CreateRequestHandlerOptions extends PostGraphileOptions {
getGqlSchema: () => Promise;
pgPool: Pool;
_emitter: EventEmitter;
shutdownActions: ShutdownActions;
}
export interface GraphQLFormattedErrorExtended {
message: string;
locations: ReadonlyArray | void;
path: ReadonlyArray | void;
extensions?: {
[s: string]: any;
};
}
export declare type GraphQLErrorExtended = GraphQLError & {
extensions: {
exception: {
hint?: string;
detail?: string;
code: string;
};
};
};
/**
* A request handler for one of many different `http` frameworks.
*/
export interface HttpRequestHandler {
(req: Request, res: Response, next?: (error?: mixed) => void): Promise;
(ctx: {
req: Request;
res: Response;
}, next: () => void): Promise;
formatError: (e: GraphQLError) => GraphQLFormattedErrorExtended;
getGraphQLSchema: () => Promise;
pgPool: Pool;
withPostGraphileContextFromReqRes: (req: Request, res: Response, moreOptions: any, fn: (ctx: mixed) => any) => Promise;
options: CreateRequestHandlerOptions;
handleErrors: (errors: ReadonlyArray, req: Request, res: Response) => ReadonlyArray;
graphqlRoute: string;
graphqlRouteHandler: (res: PostGraphileResponse) => Promise;
graphiqlRoute: string;
graphiqlRouteHandler: ((res: PostGraphileResponse) => Promise) | null;
faviconRouteHandler: ((res: PostGraphileResponse) => Promise) | null;
eventStreamRoute: string;
eventStreamRouteHandler: ((res: PostGraphileResponse) => Promise) | null;
/** Experimental! */
release: () => Promise;
}
/**
* Options passed to the `withPostGraphileContext` function
*/
export interface WithPostGraphileContextOptions {
pgPool: Pool;
jwtToken?: string;
jwtSecret?: Exclude;
jwtPublicKey?: jwt.Secret | jwt.GetPublicKeyOrSecret;
jwtAudiences?: Array;
jwtRole?: Array;
jwtVerifyOptions?: jwt.VerifyOptions;
pgDefaultRole?: string;
pgSettings?: {
[key: string]: mixed;
};
explain?: boolean;
queryDocumentAst?: DocumentNode;
operationName?: string;
pgForceTransaction?: boolean;
singleStatement?: boolean;
variables?: any;
}
export {};