{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://harryvince.github.io/lambda-dev/schema.json",
  "type": "object",
  "properties": {
    "version": {
      "type": "number",
      "const": 1,
      "description": "Config format version. Must be 1."
    },
    "defaultTarget": {
      "description": "Target used when none is passed on the command line.",
      "type": "string"
    },
    "targets": {
      "type": "object",
      "propertyNames": {
        "type": "string",
        "minLength": 1
      },
      "additionalProperties": {
        "type": "object",
        "properties": {
          "functionName": {
            "type": "string",
            "minLength": 1,
            "description": "Name or ARN of an existing Lambda function."
          },
          "region": {
            "type": "string",
            "minLength": 1,
            "description": "AWS region, e.g. eu-west-2."
          },
          "profile": {
            "description": "Named AWS profile. Without it, the default AWS SDK credential chain is used.",
            "type": "string",
            "minLength": 1
          },
          "environment": {
            "description": "Environment variables to set (string) or delete (null). Unlisted variables are left unchanged.",
            "type": "object",
            "propertyNames": {
              "type": "string",
              "pattern": "^[A-Za-z][A-Za-z0-9_]+$",
              "not": {
                "enum": [
                  "_HANDLER",
                  "_X_AMZN_TRACE_ID",
                  "AWS_DEFAULT_REGION",
                  "AWS_REGION",
                  "AWS_EXECUTION_ENV",
                  "AWS_LAMBDA_FUNCTION_NAME",
                  "AWS_LAMBDA_FUNCTION_MEMORY_SIZE",
                  "AWS_LAMBDA_FUNCTION_VERSION",
                  "AWS_LAMBDA_INITIALIZATION_TYPE",
                  "AWS_LAMBDA_LOG_GROUP_NAME",
                  "AWS_LAMBDA_LOG_STREAM_NAME",
                  "AWS_ACCESS_KEY",
                  "AWS_ACCESS_KEY_ID",
                  "AWS_SECRET_ACCESS_KEY",
                  "AWS_SESSION_TOKEN",
                  "AWS_LAMBDA_RUNTIME_API",
                  "LAMBDA_TASK_ROOT",
                  "LAMBDA_RUNTIME_DIR",
                  "AWS_LAMBDA_MAX_CONCURRENCY",
                  "AWS_LAMBDA_METADATA_API",
                  "AWS_LAMBDA_METADATA_TOKEN"
                ]
              }
            },
            "additionalProperties": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "protected": {
            "default": false,
            "description": "Ask for confirmation before deploy or rollback changes this function, and refuse to watch it. --yes skips the question.",
            "type": "boolean"
          },
          "rollbackOnFailure": {
            "default": true,
            "description": "When deploy's checks or invoke.expect fail, put back the code and environment the function had before that deploy.",
            "type": "boolean"
          },
          "snapshot": {
            "default": true,
            "description": "Save the function's code and environment before the first deploy, so rollback can restore them.",
            "type": "boolean"
          },
          "build": {
            "type": "object",
            "properties": {
              "entry": {
                "type": "string",
                "minLength": 1,
                "description": "Handler source file, relative to the config file. Bundled to index.js."
              },
              "bundle": {
                "default": true,
                "description": "Bundle dependencies into index.js.",
                "type": "boolean"
              },
              "platform": {
                "default": "node",
                "description": "esbuild platform.",
                "type": "string",
                "enum": [
                  "node",
                  "browser",
                  "neutral"
                ]
              },
              "target": {
                "default": "node20",
                "description": "esbuild target, e.g. node22. Match the function's runtime.",
                "type": "string"
              },
              "format": {
                "default": "cjs",
                "description": "Output module format.",
                "type": "string",
                "enum": [
                  "cjs",
                  "esm",
                  "iife"
                ]
              },
              "sourcemap": {
                "default": true,
                "description": "Emit index.js.map and include it in the zip.",
                "type": "boolean"
              },
              "minify": {
                "default": false,
                "description": "Minify the bundle.",
                "type": "boolean"
              },
              "external": {
                "default": [],
                "description": "Packages to leave out of the bundle, e.g. \"@aws-sdk/*\".",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "define": {
                "default": {},
                "description": "esbuild define replacements. Values are code, so strings need inner quotes: '\"dev\"'.",
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {
                  "type": "string"
                }
              },
              "copy": {
                "default": [],
                "description": "Extra files to copy into the build output and zip.",
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "from": {
                      "type": "string",
                      "minLength": 1,
                      "description": "File, directory, or glob, relative to the config file."
                    },
                    "to": {
                      "type": "string",
                      "minLength": 1,
                      "description": "Destination relative to the zip root. Use . for the root."
                    }
                  },
                  "required": [
                    "from",
                    "to"
                  ],
                  "additionalProperties": false
                }
              },
              "cache": {
                "default": true,
                "description": "Reuse the zip from an earlier build, by any target, with the same options and unchanged input files.",
                "type": "boolean"
              },
              "outDir": {
                "description": "Build output directory. Defaults to .lambda-dev/<target>. Cleared on every build.",
                "type": "string"
              }
            },
            "required": [
              "entry"
            ],
            "additionalProperties": false,
            "description": "esbuild options for the handler bundle."
          },
          "watch": {
            "default": {
              "include": [
                "src/**/*"
              ],
              "exclude": [
                "node_modules/**",
                "dist/**",
                ".lambda-dev/**"
              ],
              "debounceMs": 300
            },
            "description": "File watching for the watch command.",
            "type": "object",
            "properties": {
              "include": {
                "default": [
                  "src/**/*"
                ],
                "description": "Globs of files that trigger a deploy.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "exclude": {
                "default": [
                  "node_modules/**",
                  "dist/**",
                  ".lambda-dev/**"
                ],
                "description": "Globs to ignore, even if included.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "debounceMs": {
                "default": 300,
                "description": "Quiet period after the last change before deploying.",
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              }
            },
            "additionalProperties": false
          },
          "invoke": {
            "default": {
              "afterDeploy": false,
              "logType": "Tail"
            },
            "description": "Test invocation settings.",
            "type": "object",
            "properties": {
              "afterDeploy": {
                "default": false,
                "description": "Invoke after every deploy and watch cycle.",
                "type": "boolean"
              },
              "payloadFile": {
                "description": "JSON event file, relative to the config file.",
                "type": "string"
              },
              "payloadJson": {
                "description": "Inline event. Takes priority over payload files.",
                "allOf": [
                  {
                    "$ref": "#/definitions/__schema0"
                  }
                ]
              },
              "logType": {
                "default": "Tail",
                "description": "Tail requests the last 4 KB of logs with the response.",
                "type": "string",
                "enum": [
                  "None",
                  "Tail"
                ]
              },
              "expect": {
                "type": "object",
                "properties": {
                  "statusCode": {
                    "description": "Lambda's invoke status code, normally 200. Not the statusCode in your payload.",
                    "type": "integer",
                    "minimum": -9007199254740991,
                    "maximum": 9007199254740991
                  },
                  "functionError": {
                    "default": false,
                    "description": "Whether the function should fail with an unhandled error (FunctionError). Default false.",
                    "type": "boolean"
                  },
                  "payload": {
                    "description": "Expected response. Objects match if every listed key matches, so other keys are ignored; arrays and other values must be equal.",
                    "allOf": [
                      {
                        "$ref": "#/definitions/__schema0"
                      }
                    ]
                  },
                  "exact": {
                    "default": false,
                    "description": "Require the payload to equal the expected one exactly, with no extra keys.",
                    "type": "boolean"
                  }
                },
                "additionalProperties": false,
                "description": "What a successful response looks like. The command fails otherwise."
              }
            },
            "additionalProperties": false
          },
          "checks": {
            "default": {},
            "description": "Named checks, such as a health check, run by the check command and deploy --check.",
            "type": "object",
            "propertyNames": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]*$"
            },
            "additionalProperties": {
              "type": "object",
              "properties": {
                "payloadFile": {
                  "description": "JSON event file, relative to the config file.",
                  "type": "string"
                },
                "payloadJson": {
                  "description": "Inline event. Takes priority over payloadFile.",
                  "allOf": [
                    {
                      "$ref": "#/definitions/__schema0"
                    }
                  ]
                },
                "expect": {
                  "type": "object",
                  "properties": {
                    "statusCode": {
                      "description": "Lambda's invoke status code, normally 200. Not the statusCode in your payload.",
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991
                    },
                    "functionError": {
                      "default": false,
                      "description": "Whether the function should fail with an unhandled error (FunctionError). Default false.",
                      "type": "boolean"
                    },
                    "payload": {
                      "description": "Expected response. Objects match if every listed key matches, so other keys are ignored; arrays and other values must be equal.",
                      "allOf": [
                        {
                          "$ref": "#/definitions/__schema0"
                        }
                      ]
                    },
                    "exact": {
                      "default": false,
                      "description": "Require the payload to equal the expected one exactly, with no extra keys.",
                      "type": "boolean"
                    }
                  },
                  "additionalProperties": false,
                  "description": "What a successful response looks like. The command fails otherwise."
                }
              },
              "required": [
                "expect"
              ],
              "additionalProperties": false,
              "description": "An invocation with a known event and an expected response."
            }
          }
        },
        "required": [
          "functionName",
          "region",
          "build"
        ],
        "additionalProperties": false,
        "description": "One Lambda function to build and deploy."
      },
      "description": "Map of target name to target settings.",
      "minProperties": 1
    }
  },
  "required": [
    "version",
    "targets"
  ],
  "additionalProperties": false,
  "title": "aws-lambda-dev config",
  "description": "Configuration for aws-lambda-dev (lambda-dev.yml).",
  "definitions": {
    "__schema0": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "number"
        },
        {
          "type": "boolean"
        },
        {
          "type": "null"
        },
        {
          "type": "array",
          "items": {
            "$ref": "#/definitions/__schema0"
          }
        },
        {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "$ref": "#/definitions/__schema0"
          }
        }
      ]
    }
  }
}
