import { EdgeBodyEncoding } from './EdgeBodyEncoding.js'
import { EdgeHeaders } from './EdgeHeaders.js'

/**
 * @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-generating-http-responses-in-requests.html#lambda-generating-http-responses-object
 */
export type EdgeResponse = {
  /**
   * Headers that you want CloudFront to return in the generated response.
   */
  headers?: EdgeHeaders
  /**
   * The HTTP status code.
   * Provide the status code as a string.
   * CloudFront uses the provided status code for the following:
   * - Return in the response
   * - Cache in the CloudFront edge cache, when the response was generated by a function that was triggered by an origin request event
   * - Log in CloudFront [Configuring and using standard logs (access logs)](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/AccessLogs.html)
   * If the status value isn't between 200 and 599, CloudFront returns an error to the viewer.
   * @example '200'
   * @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-updating-http-responses.html
   */
  status: string
  /**
   * The description that you want CloudFront to return in the response, to accompany the HTTP status code.
   * You don't need to use standard descriptions, such as OK for an HTTP status code of 200.
   * @example 'OK'
   */
  statusDescription?: string
  /**
   * The encoding for the value that you specified in the body.
   * The only valid encodings are text and base64.
   * If you include body in the response object but omit bodyEncoding, CloudFront treats the body as text.
   * If you specify bodyEncoding as base64 but the body is not valid base64, CloudFront returns an error.
   * @default 'text'
   */
  bodyEncoding?: EdgeBodyEncoding
  /**
   * The body, if any, that you want CloudFront to return in the generated response.
   */
  body?: string
}
