{
  "id": "client-side-component-loader-configuration.schema.json",
  "title": "Client-side component manifest",
  "description": "All client side components built on the SharePoint framework need a valid component manifest. This interface represents properties that are required by all types of client side components like Applications and Web Parts. Component specific manifests will extend this interface to add properties required by that component type.",

  "definitions": {
    "moduleConfiguration": {
      "id": "moduleConfiguration",
      "type": "object",
      "title": "Module Configuration",
      "description": "This is the base interface for a script module's definition.",

      "required": ["type"],
      "properties": {
        "type": {
          "type": "string",
          "enum": ["component", "path", "localizedPath"]
        },

        "shouldNotPreload": {
          "type": "boolean",
          "title": "Should Not Preload",
          "description": "If set to \"true\", this module should not be preloaded when loading the component."
        }
      },

      "additionalProperties": true
    },

    "path": {
      "oneOf": [
        {
          "type": "object",
          "additionalProperties": false,
          "required": ["path"],
          "properties": {
            "path": {
              "type": "string",
              "title": "Path",
              "description": "The path to the resource.",
              "minLength": 1
            },
            "integrity": {
              "type": "string",
              "title": "Integrity",
              "description": "The subresource integrity hash of the resource referenced in \"path\".",
              "minLength": 1
            }
          }
        },
        {
          "type": "string",
          "minLength": 1
        }
      ]
    }
  },

  "oneOf": [
    {
      "type": "object",
      "required": ["internalModuleBaseUrls"],
      "properties": {
        "internalModuleBaseUrls": {
          "type": "array",
          "title": "Internal Module Base URLs",
          "description": "This is an array of fully-qualified paths to be prepended to each of the script resource paths with the \"internal\" or \"localized\" type. If one fails to load, the loader will attempt to load from the next until there are no base paths remaining. All \"internal\" and \"localized\" script resources that do not have fully-qualified URLs as their \"path\" field values must be hosted under each of the paths listed in this property.",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 10
          }
        },

        "entryModuleId": {
          "type": "string",
          "title": "Entry Module ID",
          "description": "This is the ID of one of the entries in the \"scriptResources\" dictionary. The loader will download and evaluate the script resource referenced in this field, resolve all dependencies against the keys in the \"scriptResources\", and return the exported object to the loader's calling function. The entry referenced in the \"scriptResources\" dictionary must be of the \"internal\" or the \"localized\" type.",
          "minLength": 1,
          "maxLength": 100
        },

        "exportName": {
          "type": "string",
          "title": "Export Name",
          "description": "This value points to a top-level field from the entryModuleId module's export. If this parameter is set, the field referenced in the entryModuleId module's export is returned by the module loader when this manifest is loaded, instead of the top-level export.",
          "minLength": 1,
          "maxLength": 100
        },

        "scriptResources": {
          "type": "object",
          "title": "Script Resources",
          "description": "This is a dictionary of named script resources. \"internal\" and \"localized\" modules may reference each other and \"framework\" modules are expected to be provided by the framework runtime. The resource named in the \"entryModuleId\" must contain the component's exported object.",
          "minProperties": 1,
          "patternProperties": {
            ".{1,}": {
              "oneOf": [
                {
                  "title": "Framework Module Configuration",
                  "description": "This is the interface for a script module with the \"framework\" type. Modules of this type will be provided by the framework runtime. The key in the \"scriptResources\" dictionary must be the name of a standard framework library.",
                  "type": "object",
                  "allOf": [
                    {
                      "type": "object",
                      "properties": {
                        "type": { "$ref": "any-value.schema.json" },
                        "shouldNotPreload": { "$ref": "any-value.schema.json" },
                        "version": { "$ref": "any-value.schema.json" },
                        "id": { "$ref": "any-value.schema.json" },
                        "failoverPath": { "$ref": "any-value.schema.json" },
                        "fallbackVersion": { "$ref": "any-value.schema.json" }
                      },
                      "additionalProperties": false
                    },
                    {
                      "$ref": "#/definitions/moduleConfiguration"
                    },
                    {
                      "type": "object",
                      "required": ["type", "version", "id"],
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": ["component"]
                        },

                        "version": {
                          "title": "Version",
                          "description": "The version of the framework-supplied component to be loaded. For framework runtime component such as \"@microsoft/sp-client-base,\" it is recommended the version of the framework component the component was developed against be specified.",
                          "oneOf": [
                            {
                              "$ref": "semver.schema.json"
                            },
                            {
                              "type": "string",
                              "enum": ["latest"]
                            }
                          ]
                        },

                        "id": {
                          "title": "ID",
                          "description": "The ID of the framework-supplied component to be loaded.",
                          "$ref": "guid.schema.json"
                        },

                        "failoverPath": {
                          "title": "Failover Path",
                          "description": "A path to the framework-supplied module in case the framework fails to load the requested version. This must be either a fully-qualified URL, or a path under the paths specified in the \"internalModuleBaseUrls\" field. If this field is not specified and the version is not available in the framework runtime, the closest matching version of the module will be provided instead.",
                          "$ref": "#/definitions/path"
                        },

                        "fallbackVersion": {
                          "$ref": "component-fallback-version.schema.json"
                        }
                      },
                      "additionalProperties": true
                    }
                  ]
                },

                {
                  "title": "Internal Module Configuration",
                  "description": "This is the interface for a script module with the \"internal\" type. Modules of this type must be provided by the component developer.",
                  "type": "object",
                  "allOf": [
                    {
                      "type": "object",
                      "properties": {
                        "type": { "$ref": "any-value.schema.json" },
                        "shouldNotPreload": { "$ref": "any-value.schema.json" },
                        "path": { "$ref": "any-value.schema.json" },
                        "globalName": { "$ref": "any-value.schema.json" },
                        "globalDependencies": { "$ref": "any-value.schema.json" }
                      },
                      "additionalProperties": false
                    },
                    {
                      "$ref": "#/definitions/moduleConfiguration"
                    },
                    {
                      "type": "object",
                      "required": ["type", "path"],
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": ["path"]
                        },

                        "path": {
                          "title": "Path",
                          "description": "A path to this module's javascript resource either as a fully-qualified URL or as a path under the paths provided in the \"internalModuleBaseUrls\" field.",
                          "$ref": "#/definitions/path"
                        },

                        "globalName": {
                          "title": "Global Name",
                          "description": "In order to load scripts that don't follow the AMD/module-pattern where \"define\" or \"require\" is called and dependencies are explicitly listed and exports are explicitly returned, the module loader needs to know which global variable must be examined. If this property is specified, this module is considered non-AMD and the module loader will not expect \"define\" or \"require\" to be called. Instead, it will wait for the script to finish loading and examine the global variable specified in this field.",
                          "type": "string",
                          "minLength": 1
                        },

                        "globalDependencies": {
                          "title": "Global Dependencies",
                          "description": "For non-AMD/module-pattern scripts that have dependencies (for example, jQuery plugins), the module loader will ensure that those dependencies are already loaded. Entries in the array specified in this field must refer to other non-AMD modules in this component. This field is not required to have a value for non-AMD modules. If any values are specified that do not refer to other modules in the same component manifest that this module is specified, the module loader will throw an exception and the component will fail to load.",
                          "type": "array",
                          "minItems": 1,
                          "items": {
                            "type": "string",
                            "minLength": 1
                          }
                        }
                      },
                      "additionalProperties": true
                    }
                  ]
                },

                {
                  "title": "Localized Internal Module Configuration",
                  "description": "This is the interface for a script module with the \"localized\" type. Modules of this type must be provided by the component developer. These script resources are similar to those of the \"internal\" type, but they may be present at a number of different paths, to be selected by the user's locale. Paths in this module type are loaded exactly the same way as \"internal\" modules are.",
                  "type": "object",
                  "allOf": [
                    {
                      "type": "object",
                      "properties": {
                        "type": { "$ref": "any-value.schema.json" },
                        "shouldNotPreload": { "$ref": "any-value.schema.json" },
                        "defaultPath": { "$ref": "any-value.schema.json" },
                        "paths": { "$ref": "any-value.schema.json" }
                      },
                      "additionalProperties": false
                    },
                    {
                      "$ref": "#/definitions/moduleConfiguration"
                    },
                    {
                      "type": "object",
                      "required": ["type", "defaultPath"],
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": ["localizedPath"]
                        },

                        "defaultPath": {
                          "title": "Default Path",
                          "description": "A path to this module's default locale javascript resource either as a fully-qualified URL or as a path under the paths provided in the \"internalModuleBaseUrls\" field. If the user's locale does not resolve to one of the paths specified in the \"paths\" field, the path in this field is used. Paths in this module type are treated exactly the same way paths in modules of the \"internal\" type are treated.",
                          "$ref": "#/definitions/path"
                        },

                        "paths": {
                          "title": "Paths",
                          "description": "This is a dictionary of locale keys (in the \"ll-cc\" format) to paths to this module's locale javascript resource either as a fully-qualified URL or as a path under the paths provided in the \"internalModuleBaseUrls\" field. The loader will attempt to resolve the user's locale to one of the paths provided by this field, and will load the script resource under that path. If the user's locale does not resolve to one of the paths specified in this field, the path in \"defaultPath\" field is used.",
                          "type": "object",
                          "patternProperties": {
                            ".+": {
                              "$ref": "#/definitions/path"
                            }
                          }
                        }
                      },
                      "additionalProperties": true
                    }
                  ]
                }
              ]
            }
          },
          "additionalProperties": false
        }
      },

      "additionalProperties": false
    },
    {
      "type": "null"
    }
  ]
}
