import { CorsOptions, CorsOptionsDelegate } from "cors"; import bodyParser from "body-parser"; import cookieParser from "cookie-parser"; import { TObject } from "./base"; import { AlokaiContainer, ApiClientExtension, ApiMethods, ApiMethodsFactory, MiddlewareContext } from "./common"; import { FileUploadOptions, FileUploadRequest } from "./fileUpload"; export interface ClientContext { client: CLIENT; config: CONFIG; [x: string]: any; } export interface IntegrationContext extends MiddlewareContext { client: CLIENT; config: CONFIG; api: API; extendedApi: EXTENDED_API; [x: string]: any; } export interface Context { [x: string]: IntegrationContext | any; } export type PlatformApi = { [functionName: string]: (context: Context, ...args: any[]) => Promise; }; export type ContextedPlatformApi = { [P in keyof T]: T[P] extends (context: Context, ...arg: infer X) => Promise ? (...arg: X) => Promise : never; }; export interface FactoryParams { provide?: (context: Context) => any; api?: Partial; } export interface ApiInstance { api: API; client: CLIENT; settings: CONFIG; } /** * All available API methods without first argument - `context`, because this prop is set automatically. */ export type ContextualizedApi = { [T in keyof API]: API[T] extends (context: any, ...arguments_: infer P) => infer R ? (...arguments_: P) => R : never; }; export interface ApiClient { api: API; client: CLIENT; settings: CONFIG & { integrationName: string; }; } export interface ApiClientConfig { client?: CLIENT; extensions?: ApiClientExtension[]; [x: string]: any; } export type CreateApiClientFn = { (givenConfig: CONFIG, customApi?: ApiMethods): Promise>; _predefinedExtensions?: ApiClientExtension[]; }; export interface ApiClientFactoryParams { api: API | ApiMethodsFactory; isProxy?: boolean; onCreate: (config: CONFIG, alokai: AlokaiContainer) => Promise<{ client: CLIENT; config: ApiClientConfig; }> | { client: CLIENT; config: ApiClientConfig; }; extensions?: ApiClientExtension[]; } export interface ApiClientFactory { createApiClient: CreateApiClientFn; /** * Sets up integration config, runs once. */ init?: (configuration: TObject, alokai: AlokaiContainer) => TObject; } export type CreateApiProxyFn = (givenConfig: any, customApi?: any) => ApiInstance; /** * Function that will be called to determine readiness of middleware to accept connections * @returns Return value is never considered - only thrown exceptions * @throws The implementation *must* throw an exception at some point in the code, which means that the readiness check should fail */ export type ReadinessProbe = () => Promise; export interface CreateServerOptions { /** * The options for the `express.json` middleware. * If not provided, the default options will be used. * @see https://www.npmjs.com/package/body-parser */ bodyParser?: bodyParser.OptionsJson; /** * The options for the `cookie-parser` middleware. * If not provided, the default options will be used. * @see https://www.npmjs.com/package/cookie-parser */ cookieParser?: { secret: string | string[]; options: cookieParser.CookieParseOptions; }; /** * The options for the `cors` middleware. * If not provided, the following configuration will be used: * ```json * { * "credentials": true, * "origin": ["http://localhost:3000", "http://localhost:4000"] * } * ``` * @see https://www.npmjs.com/package/cors */ cors?: CorsOptions | CorsOptionsDelegate; /** * Array of functions that will be called in parallel every time the /readyz endpoint receives a GET request * If at least one function throws an exception, the response from the /readyz endpoint will report an error * @see https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-readiness-probes */ readinessProbes?: ReadinessProbe[]; /** * Configuration options for handling file uploads. * @see FileUploadOptions */ fileUpload?: FileUploadOptions | ((req: FileUploadRequest) => FileUploadOptions); } //# sourceMappingURL=server.d.ts.map