import { RouteValidatorFullConfig } from './validator' ; export function isSafeMethod ( method ) { return method === 'get' || method === 'options' ; } public export type DestructiveRouteMethod = 'post' | 'put' | 'delete' | 'patch' ; public export type SafeRouteMethod = 'get' | 'options' ; public export type RouteMethod = SafeRouteMethod | DestructiveRouteMethod ; public export const validBodyOutput = [ 'data' , 'stream' ] as const ; public export type RouteContentType = 'application/json' | 'application/*+json' | 'application/octet-stream' | 'application/x-www-form-urlencoded' | 'multipart/form-data' | 'text/*' ; public export interface RouteConfigOptionsBody { /**
     * A string or an array of strings with the allowed mime types for the endpoint. Use this settings to limit the set of allowed mime types. Note that allowing additional mime types not listed
     * above will not enable them to be parsed, and if parse is true, the request will result in an error response.
     *
     * Default value: allows parsing of the following mime types:
     * * application/json
     * * application/*+json
     * * application/octet-stream
     * * application/x-www-form-urlencoded
     * * multipart/form-data
     * * text/*
     */ accepts ? : RouteContentType | RouteContentType [ ] | string | string [ ] ; /**
     * Limits the size of incoming payloads to the specified byte count. Allowing very large payloads may cause the server to run out of memory.
     *
     * Default value: The one set in the kibana.yml config file under the parameter `server.maxPayload`.
     */ maxBytes ? : number ; /**
     * The processed payload format. The value must be one of:
     * * 'data' - the incoming payload is read fully into memory. If parse is true, the payload is parsed (JSON, form-decoded, multipart) based on the 'Content-Type' header. If parse is false, a raw
     * Buffer is returned.
     * * 'stream' - the incoming payload is made available via a Stream.Readable interface. If the payload is 'multipart/form-data' and parse is true, field values are presented as text while files
     * are provided as streams. File streams from a 'multipart/form-data' upload will also have a hapi property containing the filename and headers properties. Note that payload streams for multipart
     * payloads are a synthetic interface created on top of the entire multipart content loaded into memory. To avoid loading large multipart payloads into memory, set parse to false and handle the
     * multipart payload in the handler using a streaming parser (e.g. pez).
     *
     * Default value: 'data', unless no validation.body is provided in the route definition. In that case the default is 'stream' to alleviate memory pressure.
     */ output ? : typeof validBodyOutput [ number ] ; /**
     * Determines if the incoming payload is processed or presented raw. Available values:
     * * true - if the request 'Content-Type' matches the allowed mime types set by allow (for the whole payload as well as parts), the payload is converted into an object when possible. If the
     * format is unknown, a Bad Request (400) error response is sent. Any known content encoding is decoded.
     * * false - the raw payload is returned unmodified.
     * * 'gunzip' - the raw payload is returned unmodified after any known content encoding is decoded.
     *
     * Default value: true, unless no validation.body is provided in the route definition. In that case the default is false to alleviate memory pressure.
     */ parse ? : boolean | 'gunzip' ; } public export interface RouteConfigOptions < Method extends RouteMethod > { /**
     * Defines authentication mode for a route:
     * - true. A user has to have valid credentials to access a resource
     * - false. A user can access a resource without any credentials.
     * - 'optional'. A user can access a resource, and will be authenticated if provided credentials are valid.
     *               Can be useful when we grant access to a resource but want to identify a user if possible.
     *
     * Defaults to `true` if an auth mechanism is registered.
     */ authRequired ? : boolean | 'optional' ; /**
     * Defines xsrf protection requirements for a route:
     * - true. Requires an incoming POST/PUT/DELETE request to contain `kbn-xsrf` header.
     * - false. Disables xsrf protection.
     *
     * Set to true by default
     */ xsrfRequired ? : Method extends 'get' ? never : boolean ; /**
     * Additional metadata tag strings to attach to the route.
     */ tags ? : readonly string [ ] ; /**
     * Additional body options  RouteConfigOptionsBody .
      body ? : Method extends 'get' | 'options' ? undefined : RouteConfigOptionsBody ; /**
     * Defines per-route timeouts.
     */ timeout ? : { /**
         * Milliseconds to receive the payload
         */ payload ? : Method extends 'get' | 'options' ? undefined : number ; /**
         * Milliseconds the socket can be idle before it's closed
         */ idleSocket ? : number ; } ; } public export interface RouteConfig < P , Q , B , Method extends RouteMethod > { remarks E.g. if the router is registered at `/elasticsearch` and the route path is
     * `/search`, the full path for the route is `/elasticsearch/search`.
     * Supports:
     *   - named path segments `path/{name}`.
     *   - optional path segments `path/{position?}`.
     *   - multi-segments `path/{coordinates*2}`.
     * Segments are accessible within a handler function as `params` property of  KibanaRequest object.
     * To have read access to `params` you *must* specify validation schema with  RouteConfig . validate .
      path : string ; remarks example validate : RouteValidatorFullConfig < P , Q , B > | false ; /**
     * Additional route options  RouteConfigOptions .
      options ? : RouteConfigOptions < Method > ; }