import type { Loader } from "esbuild";
import { Construct } from "constructs";
import * as cdk from "aws-cdk-lib";
import * as lambda from "aws-cdk-lib/aws-lambda";
import * as lambdaNode from "aws-cdk-lib/aws-lambda-nodejs";
import * as logs from "aws-cdk-lib/aws-logs";
import { Stack } from "./Stack.js";
import { Secret, Parameter } from "./Config.js";
import { SSTConstruct } from "./Construct.js";
import { Size } from "./util/size.js";
import { Duration } from "./util/duration.js";
import { Permissions } from "./util/permission.js";
import * as functionUrlCors from "./util/functionUrlCors.js";
export interface FunctionUrlCorsProps extends functionUrlCors.CorsProps {
}
export declare type FunctionInlineDefinition = string | Function;
export declare type FunctionDefinition = string | Function | FunctionProps;
export declare type Runtime = "nodejs" | "nodejs4.3" | "nodejs6.10" | "nodejs8.10" | "nodejs10.x" | "nodejs12.x" | "nodejs14.x" | "nodejs16.x" | "python2.7" | "python3.6" | "python3.7" | "python3.8" | "python3.9" | "dotnetcore1.0" | "dotnetcore2.0" | "dotnetcore2.1" | "dotnetcore3.1" | "dotnet6" | "java8" | "java11" | "go1.x";
export interface FunctionProps extends Omit<lambda.FunctionOptions, "functionName" | "memorySize" | "timeout" | "runtime" | "tracing" | "layers" | "architecture" | "logRetention"> {
    /**
     * The CPU architecture of the lambda function.
     *
     * @default "x86_64"
     *
     * @example
     * ```js
     * new Function(stack, "Function", {
     *   architecture: "arm_64",
     * })
     * ```
     */
    architecture?: Lowercase<keyof Pick<typeof lambda.Architecture, "ARM_64" | "X86_64">>;
    /**
     * By default, the name of the function is auto-generated by AWS. You can configure the name by providing a string.
     *
     * @default Auto-generated function name
     *
     * @example
     * ```js
     * new Function(stack, "Function", {
     *   handler: "src/function.handler",
     *   functionName: "my-function",
     * })
     *```
     */
    functionName?: string | ((props: FunctionNameProps) => string);
    /**
     * Path to the entry point and handler function. Of the format:
     * `/path/to/file.function`.
     *
     * @example
     * ```js
     * new Function(stack, "Function", {
     *   handler: "src/function.handler",
     * })
     *```
     */
    handler?: string;
    /**
     * Root directory of the project, typically where package.json is located. Set if using a monorepo with multiple subpackages
     *
     * @default Defaults to the same directory as sst.json
     *
     * @example
     * ```js
     * new Function(stack, "Function", {
     *   srcPath: "packages/backend",
     *   handler: "function.handler",
     * })
     *```
     */
    srcPath?: string;
    /**
     * The runtime environment. Only runtimes of the Node.js, Python, Go, and .NET (C# and F#) family are supported.
     *
     * @default "nodejs14.x"
     *
     * @example
     * ```js
     * new Function(stack, "Function", {
     *   handler: "src/function.handler",
     *   runtime: "nodejs16.x",
     * })
     *```
     */
    runtime?: Runtime;
    /**
     * The amount of disk storage in MB allocated.
     *
     * @default "512 MB"
     *
     * @example
     * ```js
     * new Function(stack, "Function", {
     *   handler: "src/function.handler",
     *   diskSize: "2 GB",
     * })
     *```
     */
    diskSize?: number | Size;
    /**
     * The amount of memory in MB allocated.
     *
     * @default "1 GB"
     *
     * @example
     * ```js
     * new Function(stack, "Function", {
     *   handler: "src/function.handler",
     *   memorySize: "2 GB",
     * })
     *```
     */
    memorySize?: number | Size;
    /**
     * The execution timeout in seconds.
     *
     * @default "10 seconds"
     *
     * @example
     * ```js
     * new Function(stack, "Function", {
     *   handler: "src/function.handler",
     *   timeout: "30 seconds",
     * })
     *```
     */
    timeout?: number | Duration;
    /**
     * Enable AWS X-Ray Tracing.
     *
     * @default "active"
     *
     * @example
     * ```js
     * new Function(stack, "Function", {
     *   handler: "src/function.handler",
     *   tracing: "pass_through",
     * })
     *```
     */
    tracing?: Lowercase<keyof typeof lambda.Tracing>;
    /**
     * Can be used to disable Live Lambda Development when using `sst start`. Useful for things like Custom Resources that need to execute during deployment.
     *
     * @default true
     *
     * @example
     * ```js
     * new Function(stack, "Function", {
     *   handler: "src/function.handler",
     *   enableLiveDev: false
     * })
     *```
     */
    enableLiveDev?: boolean;
    /**
     * Configure environment variables for the function
     *
     * @example
     * ```js
     * new Function(stack, "Function", {
     *   handler: "src/function.handler",
     *   config: [
     *     STRIPE_KEY,
     *     API_URL,
     *   ]
     * })
     * ```
     */
    config?: (Secret | Parameter)[];
    /**
     * Configure environment variables for the function
     *
     * @example
     * ```js
     * new Function(stack, "Function", {
     *   handler: "src/function.handler",
     *   environment: {
     *     TABLE_NAME: table.tableName,
     *   }
     * })
     * ```
     */
    environment?: Record<string, string>;
    /**
     * Configure or disable bundling options
     *
     * @example
     * ```js
     * new Function(stack, "Function", {
     *   handler: "src/function.handler",
     *   bundle: {
     *     copyFiles: [{ from: "src/index.js" }]
     *   }
     * })
     *```
     */
    bundle?: FunctionBundleProp;
    /**
     * Attaches the given list of permissions to the function. Configuring this property is equivalent to calling `attachPermissions()` after the function is created.
     *
     * @example
     * ```js
     * new Function(stack, "Function", {
     *   handler: "src/function.handler",
     *   permissions: ["ses", bucket]
     * })
     * ```
     */
    permissions?: Permissions;
    /**
     * Enable function URLs, a dedicated endpoint for your Lambda function.
     * @default Disabled
     * @example
     * ```js
     * new Function(stack, "Function", {
     *   handler: "src/function.handler",
     *   url: true
     * })
     * ```
     *
     * ```js
     * new Function(stack, "Function", {
     *   handler: "src/function.handler",
     *   url: {
     *     authorizer: "iam",
     *     cors: {
     *       allowedOrigins: ['https://example.com'],
     *     },
     *   },
     * })
     * ```
     */
    url?: boolean | FunctionUrlProps;
    /**
     * A list of Layers to add to the function's execution environment.
     *
     * Note that, if a Layer is created in a stack (say `stackA`) and is referenced in another stack (say `stackB`), SST automatically creates an SSM parameter in `stackA` with the Layer's ARN. And in `stackB`, SST reads the ARN from the SSM parameter, and then imports the Layer.
     *
     *  This is to get around the limitation that a Lambda Layer ARN cannot be referenced across stacks via a stack export. The Layer ARN contains a version number that is incremented everytime the Layer is modified. When you refer to a Layer's ARN across stacks, a CloudFormation export is created. However, CloudFormation does not allow an exported value to be updated. Once exported, if you try to deploy the updated layer, the CloudFormation update will fail. You can read more about this issue here - https://github.com/serverless-stack/sst/issues/549.
     *
     * @default no layers
     *
     * @example
     * ```js
     * new Function(stack, "Function", {
     *   layers: ["arn:aws:lambda:us-east-1:764866452798:layer:chrome-aws-lambda:22", myLayer]
     * })
     * ```
     */
    layers?: (string | lambda.ILayerVersion)[];
    /**
     * The duration function logs are kept in CloudWatch Logs.
     *
     * When updating this property, unsetting it doesn't retain the logs indefinitely. Explicitly set the value to "infinite".
     * @default Logs retained indefinitely
     * @example
     * ```js
     * new Function(stack, "Function", {
     *   handler: "src/function.handler",
     *   logRetention: "one_week"
     * })
     * ```
     */
    logRetention?: Lowercase<keyof typeof logs.RetentionDays>;
}
export interface FunctionNameProps {
    /**
     * The stack the function is being created in
     */
    stack: Stack;
    /**
     * The function properties
     */
    functionProps: FunctionProps;
}
export interface FunctionHandlerProps {
    srcPath: string;
    handler: string;
    bundle: FunctionBundleProp;
    runtime: string;
}
export interface FunctionUrlProps {
    /**
     * The authorizer for the function URL
     * @default "none"
     * @example
     * ```js
     * new Function(stack, "Function", {
     *   handler: "src/function.handler",
     *   url: {
     *     authorizer: "iam",
     *   },
     * })
     * ```
     */
    authorizer?: "none" | "iam";
    /**
     * CORS support for the function URL
     * @default true
     * @example
     * ```js
     * new Function(stack, "Function", {
     *   handler: "src/function.handler",
     *   url: {
     *     cors: true,
     *   },
     * })
     * ```
     *
     * ```js
     * new Function(stack, "Function", {
     *   handler: "src/function.handler",
     *   url: {
     *     cors: {
     *       allowedMethods: ["GET", "POST"]
     *       allowedOrigins: ['https://example.com'],
     *     },
     *   },
     * })
     * ```
     */
    cors?: boolean | FunctionUrlCorsProps;
}
export declare type FunctionBundleProp = FunctionBundleNodejsProps | FunctionBundlePythonProps | boolean;
interface FunctionBundleBase {
    /**
     * Used to configure additional files to copy into the function bundle
     *
     * @example
     * ```js
     * new Function(stack, "Function", {
     *   bundle: {
     *     copyFiles: [{ from: "src/index.js" }]
     *   }
     * })
     *```
     */
    copyFiles?: FunctionBundleCopyFilesProps[];
}
/**
 * Used to configure NodeJS bundling options
 *
 * @example
 * ```js
 * new Function(stack, "Function", {
 *   bundle: {
 *    format: "esm",
 *    minify: false
 *   }
 * })
 * ```
 */
export interface FunctionBundleNodejsProps extends FunctionBundleBase {
    /**
     * Configure additional esbuild loaders for other file extensions
     *
     * @example
     * ```js
     * new Function(stack, "Function", {
     *   bundle: {
     *     loader: {
     *      ".png": "file"
     *     }
     *   }
     * })
     * ```
     */
    loader?: Record<string, Loader>;
    /**
     * Packages that will not be included in the bundle. Usually used to exclude dependencies that are provided in layers
     *
     * @example
     * ```js
     * new Function(stack, "Function", {
     *   bundle: {
     *     externalModules: ["prisma"]
     *   }
     * })
     * ```
     */
    externalModules?: string[];
    /**
     * Packages that will be excluded from the bundle and installed into node_modules instead. Useful for dependencies that cannot be bundled, like those with binary dependencies.
     *
     * @example
     * ```js
     * new Function(stack, "Function", {
     *   bundle: {
     *     nodeModules: ["pg"]
     *   }
     * })
     * ```
     */
    nodeModules?: string[];
    /**
     * Use this to insert an arbitrary string at the beginning of generated JavaScript and CSS files.
     *
     * @example
     * ```js
     * new Function(stack, "Function", {
     *   bundle: {
     *     banner: "console.log('Function starting')"
     *   }
     * })
     * ```
     */
    banner?: string;
    /**
     * Hooks to run at various stages of bundling
     */
    commandHooks?: lambdaNode.ICommandHooks;
    /**
     * This allows you to customize esbuild config.
     */
    esbuildConfig?: {
        /**
         * Replace global identifiers with constant expressions.
         *
         * @example
         * ```js
         * new Function(stack, "Function", {
         *   bundle: {
         *     esbuildConfig: {
         *       define: {
         *         str: "text"
         *       }
         *     }
         *   }
         * })
         * ```
         */
        define?: Record<string, string>;
        /**
         * When minifying preserve names of functions and variables
         *
         * @example
         * ```js
         * new Function(stack, "Function", {
         *   bundle: {
         *     esbuildConfig: {
         *       keepNames: true
         *     }
         *   }
         * })
         * ```
         */
        keepNames?: boolean;
        /**
         * Path to a file that returns an array of esbuild plugins
         *
         * @example
         * ```js
         * new Function(stack, "Function", {
         *   bundle: {
         *     esbuildConfig: {
         *       plugins: "path/to/plugins.js"
         *     }
         *   }
         * })
         * ```
         *
         * Where `path/to/plugins.js` looks something like this:
         *
         * ```js
         * const { esbuildDecorators } = require("@anatine/esbuild-decorators");
         *
         * module.exports = [
         *   esbuildDecorators(),
         * ];
         * ```
         */
        plugins?: string;
    };
    /**
     * Enable or disable minification
     *
     * @default true
     *
     * @example
     * ```js
     * new Function(stack, "Function", {
     *   bundle: {
     *     minify: false
     *   }
     * })
     * ```
     */
    minify?: boolean;
    /**
     * Configure bundle format
     *
     * @default "cjs"
     *
     * @example
     * ```js
     * new Function(stack, "Function", {
     *   bundle: {
     *     format: "esm"
     *   }
     * })
     * ```
     */
    format?: "cjs" | "esm";
    /**
     * Configure if sourcemaps are generated when the function is bundled for production. Since they increase payload size and potentially cold starts they are not generated by default. They are always generated during local development mode.
     *
     * @default false
     *
     * @example
     * ```js
     * new Function(stack, "Function", {
     *   bundle: {
     *   sourcemap: true
     *   }
     * })
     * ```
     */
    sourcemap?: boolean;
}
/**
 * Used to configure Python bundling options
 */
export interface FunctionBundlePythonProps extends FunctionBundleBase {
    /**
     * A list of commands to override the [default installing behavior](Function#bundle) for Python dependencies.
     *
     * Each string in the array is a command that'll be run. For example:
     *
     * @default "[]"
     *
     * @example
     * ```js
     * new Function(stack, "Function", {
     *   bundle: {
     *     installCommands: [
     *       'export VARNAME="my value"',
     *       'pip install --index-url https://domain.com/pypi/myprivatemodule/simple/ --extra-index-url https://pypi.org/simple -r requirements.txt .',
     *     ]
     *   }
     * })
     * ```
     */
    installCommands?: string[];
}
/**
 * Used to configure additional files to copy into the function bundle
 *
 * @example
 * ```js
 * new Function(stack, "Function", {
 *   bundle: {
 *     copyFiles: [{ from: "src/index.js" }]
 *   }
 * })
 *```
 */
export interface FunctionBundleCopyFilesProps {
    /**
     * Source path relative to sst.json
     */
    from: string;
    /**
     * Destination path relative to function root in bundle
     */
    to?: string;
}
/**
 * The `Function` construct is a higher level CDK construct that makes it easy to create a Lambda Function with support for Live Lambda Development.
 *
 * @example
 *
 * ```js
 * import { Function } from "@serverless-stack/resources";
 *
 * new Function(stack, "MySnsLambda", {
 *   handler: "src/sns/index.main",
 * });
 * ```
 */
export declare class Function extends lambda.Function implements SSTConstruct {
    readonly _isLiveDevEnabled: boolean;
    private readonly localId;
    private functionUrl?;
    private props;
    constructor(scope: Construct, id: string, props: FunctionProps);
    /**
     * The AWS generated URL of the Function.
     */
    get url(): string | undefined;
    /**
     * Attaches additional permissions to function
     *
     * @example
     * ```js {20}
     * fn.attachPermissions(["s3"]);
     * ```
     */
    attachPermissions(permissions: Permissions): void;
    getConstructMetadata(): {
        type: "Function";
        data: {
            localId: string;
            arn: string;
            secrets: string[];
        };
    };
    private createUrl;
    private handleConfig;
    static buildLayers(scope: Construct, id: string, props: FunctionProps): cdk.aws_lambda.ILayerVersion[];
    static normalizeMemorySize(memorySize?: number | Size): number;
    static normalizeDiskSize(diskSize?: number | Size): cdk.Size;
    static normalizeTimeout(timeout?: number | Duration): cdk.Duration;
    static normalizeRuntime(runtime?: string): lambda.Runtime;
    static normalizeSrcPath(srcPath: string): string;
    static copyFiles(bundle: FunctionBundleProp | undefined, srcPath: string, buildPath: string): void;
    static handleImportedLayer(scope: Construct, layer: lambda.ILayerVersion): lambda.ILayerVersion;
    static isInlineDefinition(definition: any): definition is FunctionInlineDefinition;
    static fromDefinition(scope: Construct, id: string, definition: FunctionDefinition, inheritedProps?: FunctionProps, inheritErrorMessage?: string): Function;
    static mergeProps(baseProps?: FunctionProps, props?: FunctionProps): FunctionProps;
}
export {};
