{
  "version": 3,
  "sources": ["../../src/aws-lambda/callback-function.ts"],
  "sourcesContent": ["import { Runtime } from \"aws-cdk-lib/aws-lambda\";\nimport { Construct } from \"constructs\";\n\n/**\n * {@link Handler} context parameter.\n * See {@link https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-context.html AWS documentation}.\n */\n// Would prefer to use the \"aws-lambda\" package, but it fails to build the\n// types when using unbuild.\nexport interface Context {\n  callbackWaitsForEmptyEventLoop: boolean;\n  functionName: string;\n  functionVersion: string;\n  invokedFunctionArn: string;\n  memoryLimitInMB: string;\n  awsRequestId: string;\n  logGroupName: string;\n  logStreamName: string;\n\n  getRemainingTimeInMillis(): number;\n}\n\nimport { codeFromFunction } from \"./code-from-function.js\";\nimport { IEventSource } from \"./event-source.js\";\nimport { IFunction } from \"./function-base.js\";\nimport { FunctionProps, Function } from \"./function.js\";\nimport { OpaqueType } from \"../opaque-type/index.js\";\n\nexport type FunctionName<InputType, OutputType> = OpaqueType<\n  string,\n  { readonly t: unique symbol; readonly i: InputType; readonly o: OutputType }\n>;\n\nexport interface CallbackFunctionProps<InputType, OutputType>\n  extends Omit<FunctionProps, \"code\" | \"handler\" | \"runtime\" | \"events\"> {\n  /**\n     * The function that Lambda calls. The function serialization captures any variables captured by the function body and serializes those values into the generated text along with the function body. This process is recursive, so that functions referenced by the body of the serialized function will themselves be serialized as well. This process also deeply serializes captured object values, including prototype chains and property descriptors, such that the semantics of the function when deserialized should match the original function.\n\n     * There are several known limitations:\n\n     * - If a native function is captured either directly or indirectly, closure serialization will return an error.\n     * - Captured values will be serialized based on their values at the time that serializeFunction is called. Mutations to these values after that (but before the deserialized function is used) will not be observed by the deserialized function.\n     */\n  handler: (input: InputType, context: Context) => Promise<OutputType>;\n\n  /**\n   * Event sources for this function.\n   *\n   * You can also add event sources using `addEventSource`.\n   *\n   * @default - No event sources.\n   */\n  events?: IEventSource<InputType>[];\n}\n\nconst handler = \"index.handler\";\n\nconst runtime = Runtime.NODEJS_18_X;\n\nexport class CallbackFunction<InputType, OutputType>\n  extends Function\n  implements IFunction<InputType, OutputType>\n{\n  /**\n   * Name of this function.\n   */\n  public declare readonly functionName: FunctionName<InputType, OutputType>;\n\n  constructor(\n    scope: Construct,\n    id: string,\n    properties: CallbackFunctionProps<InputType, OutputType>,\n  ) {\n    const code = codeFromFunction(properties.handler);\n\n    super(scope, id, {\n      ...properties,\n      code: code.then((value) => value.code),\n      handler,\n      runtime,\n    });\n\n    code\n      .then(({ tokens }) => {\n        for (const { construct, cfnToken, hash } of tokens) {\n          this.node.addDependency(construct);\n          this.addEnvironment(hash, cfnToken);\n        }\n      })\n      .catch((error) => {\n        throw error;\n      });\n  }\n}\n"],
  "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAwB,kCAsBxBC,EAAiC,mCAGjCC,EAAwC,yBA8BxC,MAAMC,EAAU,gBAEVC,EAAU,UAAQ,YAEjB,MAAMN,UACH,UAEV,CAME,YACEO,EACAC,EACAC,EACA,CACA,MAAMC,KAAO,oBAAiBD,EAAW,OAAO,EAEhD,MAAMF,EAAOC,EAAI,CACf,GAAGC,EACH,KAAMC,EAAK,KAAMC,GAAUA,EAAM,IAAI,EACrC,QAAAN,EACA,QAAAC,CACF,CAAC,EAEDI,EACG,KAAK,CAAC,CAAE,OAAAE,CAAO,IAAM,CACpB,SAAW,CAAE,UAAAC,EAAW,SAAAC,EAAU,KAAAC,CAAK,IAAKH,EAC1C,KAAK,KAAK,cAAcC,CAAS,EACjC,KAAK,eAAeE,EAAMD,CAAQ,CAEtC,CAAC,EACA,MAAOE,GAAU,CAChB,MAAMA,CACR,CAAC,CACL,CACF",
  "names": ["callback_function_exports", "__export", "CallbackFunction", "__toCommonJS", "import_aws_lambda", "import_code_from_function", "import_function", "handler", "runtime", "scope", "id", "properties", "code", "value", "tokens", "construct", "cfnToken", "hash", "error"]
}
