{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "SPFx Serve Task Configuration",
  "description": "Defines parameters for the webserver which is spun up by the SPFx Serve Task",
  "type": "object",
  "definitions": {
    "SpfxServeSessionConfiguration": {
      "type": "object",
      "additionalProperties": false,
      "required": ["pageUrl"],
      "properties": {
        "pageUrl": {
          "title": "Page URL",
          "description": "The fully-qualified URL of the page to launch",
          "type": "string"
        },

        "customActions": {
          "title": "Custom Actions",
          "description": "An optional list of custom actions to provide as query parameters to the page. The key of this object must be the ID of the custom action component.",
          "type": "object",
          "additionalProperties": false,
          "patternProperties": {
            "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$": {
              "type": "object",
              "required": ["location"],
              "properties": {
                "location": {
                  "title": "Location",
                  "description": "The type of custom action, use \"ClientSideExtension.ApplicationCustomizer\" for the Application Customizer extension.",
                  "type": "string",
                  "enum": [
                    "ClientSideExtension.ApplicationCustomizer",
                    "ClientSideExtension.ListViewCommandSet.ContextMenu",
                    "ClientSideExtension.ListViewCommandSet.CommandBar",
                    "ClientSideExtension.ListViewCommandSet",
                    "ClientSideExtension.SearchQueryModifier"
                  ]
                },
                "properties": {
                  "type": "object"
                }
              }
            }
          }
        },

        "fieldCustomizers": {
          "title": "Field Customizers",
          "description": "An optional list of field customizers to provide as query parameters to the page. The key of this object must be the field ID the customizer applies to.",
          "type": "object",
          "additionalProperties": false,
          "patternProperties": {
            "^[A-z0-9]+$": {
              "type": "object",
              "required": ["id"],
              "properties": {
                "id": {
                  "title": "ID",
                  "description": "The ID of the field customizer component.",
                  "type": "string",
                  "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
                },
                "properties": {
                  "type": "object"
                }
              }
            }
          }
        },

        "formCustomizer": {
          "title": "Form Customizer",
          "description": "An optional form customizer to provide as query parameter to the page.",
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "componentId": {
              "title": "Component Id",
              "description": "The Id of the form customizer component.",
              "type": "string"
            },
            "PageType": {
              "title": "Page Type",
              "description": "Form display mode.",
              "type": "integer"
            },
            "RootFolder": {
              "title": "Root Folder",
              "description": "Server relative URL of the list folder.",
              "type": "string"
            },
            "ContentTypeID": {
              "title": "Content Type ID",
              "description": "The ID of the content type to use for the form.",
              "type": "string"
            },
            "ID": {
              "title": "ID",
              "description": "The ID of the list item",
              "type": "integer"
            },
            "properties": {
              "type": "object"
            }
          }
        }
      }
    }
  },

  "additionalProperties": false,
  "properties": {
    "$schema": {
      "description": "Part of the JSON Schema standard, this optional keyword declares the URL of the schema that the file conforms to. Editors may download the schema and use it to perform syntax highlighting.",
      "type": "string"
    },

    "serveConfigurations": {
      "title": "Serve Configurations",
      "description": "Specify a set of configurations that the serve task can use to load a test page",
      "type": "object",
      "additionalProperties": false,
      "required": ["default"],
      "patternProperties": {
        "\\S+": {
          "$ref": "#/definitions/SpfxServeSessionConfiguration"
        }
      }
    },

    "api": {
      "title": "API server configuration",
      "description": "Parameters which configure the API server, which runs simultaneously and allows for mock testing",
      "type": "object",
      "additionalProperties": false,
      "required": ["port", "entryPath"],
      "properties": {
        "port": {
          "title": "API Port",
          "description": "The port which the API server listens on",
          "type": "number"
        },

        "entryPath": {
          "title": "API Entry Point Path",
          "description": "The path to the script to run as the API server",
          "type": "string"
        }
      }
    },

    "contentBase": {
      "title": "Static Server Base",
      "description": "The project relative path or array of paths to serve static content from",
      "type": ["string", "array"]
    },

    "contentBasePublicPath": {
      "title": "Static Server URL Path",
      "description": "The URL path to serve static content requests from",
      "type": "string"
    },

    "initialPage": {
      "title": "Initial Page",
      "description": "The path to the page which should open automatically after this task completes",
      "type": "string"
    },

    "port": {
      "title": "Port",
      "description": "The port on which to host the file server.",
      "type": "number"
    },

    "hostname": {
      "title": "Hostname",
      "description": "The name of the host on which serve is running. Defaults to 'localhost'",
      "type": "string"
    },

    "ipAddress": {
      "title": "IP Address",
      "description": "IP address of the host on which serve is running. This parameter is helpful when using Docker containers. For example, to set the serve host as '0.0.0.0'.",
      "type": "string"
    },

    "https": {
      "title": "HTTPS Mode",
      "description": "If true, the server should run on HTTPS",
      "type": "boolean"
    },

    "keyPath": {
      "title": "HTTPS Key Path",
      "description": "Path to the HTTPS key",
      "type": "string"
    },

    "certPath": {
      "title": "HTTPS Cert Path",
      "description": "Path to the HTTPS cert",
      "type": "string"
    },

    "pfxPath": {
      "title": "HTTPS PFX Path",
      "description": "Path to the HTTPS PFX cert",
      "type": "string"
    },

    "tryCreateDevCertificate": {
      "title": "Should Create Dev Certificate",
      "description": "If true, when serve is initialized and a dev certificate doesn't already exist and hasn't been specified, attempt to generate one and trust it automatically.",
      "type": "boolean"
    }
  }
}
