import { Construct } from "constructs"; import { Function as Fn, FunctionProps, FunctionDefinition } from "./Function.js"; import { SSTConstruct } from "./Construct.js"; import { Permissions } from "./util/permission.js"; export interface ScriptProps { /** * An object of input parameters to be passed to the script. Made available in the `event` object of the function. * * @example * ```js * import { Script } from "@serverless-stack/resources"; * * new Script(stack, "Script", { * onCreate: "src/script.create", * params: { * hello: "world", * }, * }); * ``` */ params?: Record; defaults?: { /** * The default function props to be applied to all the Lambda functions in the API. The `environment`, `permissions` and `layers` properties will be merged with per route definitions if they are defined. * * @example * ```js * new Script(stack, "Api", { * defaults: { * function: { * timeout: 20, * } * } * }); * ``` */ function?: FunctionProps; }; /** * Creates the function that runs when the Script is created. * * @example * ```js * new Script(stack, "Api", { * onCreate: "src/function.handler", * }) * ``` */ onCreate?: FunctionDefinition; /** * Creates the function that runs on every deploy after the Script is created * * @example * ```js * new Script(stack, "Api", { * onUpdate: "src/function.handler", * }) * ``` */ onUpdate?: FunctionDefinition; /** * Create the function that runs when the Script is deleted from the stack. * * @example * ```js * new Script(stack, "Api", { * onDelete: "src/function.handler", * }) * ``` */ onDelete?: FunctionDefinition; } /** * The `Script` construct is a higher level CDK construct that makes it easy to run a script in a Lambda function during the deployment process. * * @example * * ```js * import { Script } from "@serverless-stack/resources"; * * new Script(stack, "Script", { * onCreate: "src/function.create", * onUpdate: "src/function.update", * onDelete: "src/function.delete", * }); * ``` */ export declare class Script extends Construct { /** * The internally created onCreate `Function` instance. */ readonly createFunction?: Fn; /** * The internally created onUpdate `Function` instance. */ readonly updateFunction?: Fn; /** * The internally created onDelete `Function` instance. */ readonly deleteFunction?: Fn; protected readonly props: ScriptProps; constructor(scope: Construct, id: string, props: ScriptProps); /** * Binds additional resources to the script * * @example * ```js * script.bind([STRIPE_KEY, bucket]); * ``` */ bind(constructs: SSTConstruct[]): void; /** * Grants additional permissions to the script * * @example * ```js * script.attachPermissions(["s3"]); * ``` */ attachPermissions(permissions: Permissions): void; protected createUserFunction(type: string, fnDef?: FunctionDefinition): Fn | undefined; private createCustomResourceFunction; private createCustomResource; private checkDeprecatedFunction; }