/// declare type Promisify = T extends Promise ? T : Promise; declare type Asyncify = T extends (...args: infer U) => infer R ? (...args: U) => Promisify : never; export declare namespace magic { namespace lambda { type Input = Function; type Output = Asyncify; interface Options { /** * * NodeJS version for this lambda. * * NOT SUPPORTED IN PREVIEW VERSION * * @default "10.x" */ nodejsVersion?: "10.x" | "8.10"; /** * By default, magic will throw a compilation error if access to global mutable state from within a lamdba is * detected. * * For example, with allowMutableState set to false, the following will not compile: * * ```typescript * let i=0 * magic.lamdba(() => i++) * ``` * * This feature relies on the TypeScript compiler, closure analysis and a few heuristics. * It will NOT catch all cases. * * NOT SUPPORTED IN PREVIEW VERSION * * @default false */ allowMutableState?: boolean; } } /** * The magic.lambda component lets you define Node.js powered lambdas. * These components will be deployed transparently (somewhere on the web) and made accessible to all other * components that reference them. * * - You do not need to add a Lambda to a domain/router component if it is only used internally * (by other components) * - You do not need to create an API just to make your Lambdas talk to other components * * @param f A sync or async function that takes and returns JSON serializable parameters * * Note: Preview version supports only JSON serializable RPC. * Magic V1 includes smarter RPC + serialization: Graphs, Cyclic references, * custom serialization, classes, and callbacks. */ function lambda(f: T, opts?: lambda.Options): lambda.Output; /** * The SPA component lets you create Single Page Applications using React. * The first argument is a block of code that returns a JSX.Element, which will be rendered * into a
inside a vanilla HTML container. * * Note: Preview version is missing several features: * - Ability to customize HTML container * - Add SSR hooks (for Server Side Rendering) */ function spa(f: spa.Input, opts?: spa.Options): spa.Output; namespace spa { export type Input = () => JSX.Element; export type Output = { url: string; }; export interface Options { /** * Customize the HTML container. * Container must include a div with id="root" * * @deprecated not implemented in preview version */ html?: string; } } namespace domain { type Input = { /** * A list of simple routes and the components they resolve to. * In the preview version, routes can only be simple strings (ex: "home", "about"), * But in the full version we support routes with parameters * ```typescript * * ``` */ [route: string]: lambda.Output | spa.Output; }; type Output = {}; } /** * * The magic.domain component lets you attach several components to a domain (web). * * In the preview version, routes can only be simple paths ("home", "/", "about"). * * @param domain In the preview version, this is interpreted as a Netlify site ID. Domains are not supported * @param routes */ function domain(domain: string, routes: domain.Input): domain.Output; } export {};