{
    "definitions": {
        "manifest": {
            "type": "object",
            "properties": {
                "control": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/control" },
                    "maxItems": 1
                }
            },
            "required": ["control"],
            "additionalProperties": false
        },

        "control": {
            "type": "object",
            "properties": {
                "$": { "$ref": "#/definitions/controlAttribs" },
                "external-service-usage": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/external-service-usage"},
                    "maxItems": 1
                },
                "type-group": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/type-group" }
                },
                "property": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/property" }
                },
                "common-property": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/common-property" }
                },
                "property-dependencies": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/propertyDependencies" },
                    "maxItems": 1
                },
                "data-set": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/dataSet" }
                },
                "resources": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/resource" },
                    "maxItems": 1
                },
                "feature-usage": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/featureUsage" },
                    "maxItems": 1
                },
                "event": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/event" }
                },
                "common-event": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/commonEvent" }
                },
                "subscribed-functionalities": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/subscribed-functionalities" },
                    "maxItems": 1
                },
                "supported-platforms": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/supportedPlatforms" },
                    "maxItems": 1
                },
                "action": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/action" }
                },
                "platform-action": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/platform-action" }
                }
            },
            "required": ["$", "resources"],
            "additionalProperties": false
        },

        "controlAttribs": {
            "type": "object",
            "properties": {
                "namespace": {
                    "type": "string",
                    "pattern": "^(?!\\.|\\d)(?!.*\\.$)(?!.*?\\.\\d)(?!.*?\\.\\.)[a-zA-Z0-9.]+$"
                },
                "constructor": {
                    "type": "string",
                    "pattern": "^(?!\\d)[a-zA-Z0-9]+$"
                },
                "version": { "$ref": "#/definitions/versionType" },
                "display-name-key": { "type": "string" },
                "description-key": { "type": "string" },
                "control-type": {
                    "type": "string",
                    "enum": ["standard", "virtual", "none", "react"]
                },
                "preview-image": { "type": "string" },
                "api-version": { "type": "string" },
                "design-mapping-file": { "type": "string" },
                "authoring-manifest": { "type": "string" },
                "hidden": { "$ref": "#/definitions/booleanType" }
            },
            "required": ["namespace", "constructor", "version", "display-name-key"],
            "additionalProperties": false
        },

        "property": {
            "type": "object",
            "properties": {
                "$": { "$ref": "#/definitions/propertyAttribs" },
                "value": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/enum" }
                }
            },
            "required": ["$"],
            "additionalProperties": false
        },

        "common-property": {
            "type": "object",
            "properties": {
                "$": { "$ref": "#/definitions/commonPropertyAttribs" },
                "value": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/enum" }
                }
            },
            "required": ["$"],
            "additionalProperties": false
        },

        "propertyAttribs": {
            "type": "object",
            "properties": {
                "name": { "type": "string" },
                "usage": { "$ref": "#/definitions/usageType" },
                "required": { "$ref": "#/definitions/booleanType" },
                "of-type" : { "$ref": "#/definitions/dataType" },
                "of-type-group": { "type": "string" },
                "display-name-key": { "type": "string" },
                "description-key": { "type": "string" },
                "default-value": { "type": "string" },
                "pfx-default-value": { "type": "string" },
                "resettable": { "$ref": "#/definitions/booleanType" },
                "hidden": { "$ref": "#/definitions/booleanType" }
            },
            "required": ["name", "usage", "display-name-key"],
            "additionalProperties": false
        },

        "commonPropertyAttribs": {
            "type": "object",
            "properties": {
                "name": { "type": "string" },
                "null-default": { "type": "string" },
                "default-value": { "type": "string" },
                "pfx-default-value": { "type": "string" },
                "phone-default-value": { "type": "string" },
                "web-default-value": { "type": "string" }
            },
            "required": ["name", "default-value"],
            "additionalProperties": false
        },

        "subscribed-functionalities": {
            "type": "object",
            "properties": {
                "subscribed-functionality": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/subscribed-functionality" }
                }
            }
        },

        "subscribed-functionality": {
            "type": "object",
            "properties": {
                "$": { "$ref": "#/definitions/subFuncAttribs" }
            },
            "required": ["$"],
            "additionalProperties": false
        },

        "subFuncAttribs": {
            "type": "object",
            "properties": {
                "name": { "type": "string" },
                "value": { "type": "string" }
            },
            "required": ["name", "value"],
            "additionalProperties": false
        },

        "event": {
            "type": "object",
            "properties": {
                "$": { "$ref": "#/definitions/eventAttribs" }
            },
            "required": ["$"],
            "additionalProperties": false
        },

        "eventAttribs": {
            "type": "object",
            "properties": {
                "name": { "type": "string" },
                "display-name-key": { "type": "string" },
                "description-key": { "type": "string" },
                "pfx-default-value": { "type": "string" },
                "hidden": { "$ref": "#/definitions/booleanType" }
            },
            "required": ["name"],
            "additionalProperties": false
        },

        "commonEvent": {
            "type": "object",
            "properties": {
                "$": { "$ref": "#/definitions/commonEventAttribs" }
            },
            "required": ["$"],
            "additionalProperties": false
        },

        "commonEventAttribs": {
            "type": "object",
            "properties": {
                "name": { "$ref": "#/definitions/commonEventType" },
                "pfx-default-value": { "type": "string" }
            },
            "required": ["name"],
            "additionalProperties": false
        },

        "propertyDependencies": {
            "type": "object",
            "properties": {
                "property-dependency": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/propertyDependency" }
                }
            },
            "required": ["property-dependency"],
            "additionalProperties": false
        },

        "propertyDependency": {
            "type": "object",
            "properties": {
                "$": { "$ref": "#/definitions/propertyDependencyAttribs" }
            },
            "required": ["$"],
            "additionalProperties": false
        },

        "propertyDependencyAttribs": {
            "type": "object",
            "properties": {
                "input": { "type": "string" },
                "output": { "type": "string" },
                "required-for": { "type": "string" }
            },
            "required": ["input", "output", "required-for"],
            "additionalProperties": false
        },

        "enum": {
            "type": "object",
            "properties": {
                "$": { "$ref": "#/definitions/enumAttribs" },
                "_": { "type": "string" }
            },
            "required": ["$", "_"],
            "additionalProperties": false
        },

        "enumAttribs": {
            "type": "object",
            "properties": {
                "name": { "type": "string" },
                "display-name-key": { "type": "string" },
                "description-key": { "type": "string" },
                "default": { "type": "string" }
            },
            "required": ["name", "display-name-key"],
            "additionalProperties": false
        },

        "propertySet": {
            "type": "object",
            "properties": {
                "$": { "$ref": "#/definitions/propertySetAttribs" }
            },
            "required": ["$"],
            "additionalProperties": false
        },

        "propertySetAttribs": {
            "type": "object",
            "properties": {
                "name": { "type": "string" },
                "usage": { "$ref": "#/definitions/usageType" },
                "required": { "$ref": "#/definitions/booleanType" },
                "of-type" : { "$ref": "#/definitions/dataType" },
                "of-type-group": { "type": "string" },
                "display-name-key": { "type": "string" },
                "description-key": { "type": "string" }
            },
            "required": ["name", "usage", "display-name-key"],
            "additionalProperties": false
        },

        "dataSet": {
            "type": "object",
            "properties": {
                "$": { "$ref": "#/definitions/dataSetAttribs" },
                "property-set": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/propertySet" }
                }
            },
            "required": ["$"],
            "additionalProperties": false
        },

        "dataSetAttribs": {
            "type": "object",
            "properties": {
                "name": { "type": "string" },
                "display-name-key": { "type": "string" },
                "description-key": { "type": "string" },
                "cds-data-set-options": { "type": "string" },
                "allow-default-selected-items": { "$ref": "#/definitions/booleanType" },
                "pfx-default-value": { "type": "string" }
            },
            "required": ["name", "display-name-key"],
            "additionalProperties": false
        },

        "external-service-usage": {
            "type": "object",
            "properties": {
                "$": {
                    "type": "object",
                    "properties": {
                        "enabled": { "$ref": "#/definitions/booleanType"}
                    },
                    "required": ["enabled"],
                    "additionalProperties": false
                },
                "domain": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/domain" }
                }
            },
            "required": ["$"],
            "additionalProperties": false
        },

        "domain": {
            "type": "string"
        },

        "featureUsage": {
            "type": "object",
            "properties": {
                "uses-feature": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/usesFeature" }
                },
                "uses-connector": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/usesConnector" }
                }
            },
            "additionalProperties": false
        },

        "usesFeature": {
            "type": "object",
            "properties": {
                "$": { "$ref": "#/definitions/usesFeatureAttribs" }
            },
            "required": ["$"],
            "additionalProperties": false
        },

        "usesFeatureAttribs": {
            "type": "object",
            "properties": {
                "name": { "type": "string" },
                "type": { "$ref": "#/definitions/usesFeatureType" },
                "required": { "$ref": "#/definitions/booleanType" }
            },
            "required": ["name", "required"],
            "additionalProperties": false
        },

        "usesConnector": {
            "type": "object",
            "properties": {
                "$": { "$ref": "#/definitions/usesConnectorAttribs" }
            },
            "required": ["$"],
            "additionalProperties": false
        },

        "usesConnectorAttribs": {
            "type": "object",
            "properties": {
                "name": { "type": "string" },
                "id": { "type": "string" },
                "required": { "$ref": "#/definitions/booleanType" }
            },
            "required": ["name", "id", "required"],
            "additionalProperties": false
        },

        "type-group": {
            "type": "object",
            "properties": {
                "$": {
                    "type": "object",
                    "properties": {
                        "name": { "type": "string" }
                    },
                    "required": ["name"],
                    "additionalProperties": false
                },
                "type": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/dataType" }
                }
            },
            "required": ["$", "type"],
            "additionalProperties": false
        },

        "supportedPlatforms": {
            "type": "object",
            "properties": {
                "supported-platform": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/supportedPlatform" }
                }
            },
            "required": ["supported-platform"],
            "additionalProperties": false
        },

        "supportedPlatform": {
            "type": "object",
            "properties": {
                "$": {
                    "type": "object",
                    "properties": {
                        "name": { "type": "string" }
                    },
                    "required": ["name"],
                    "additionalProperties": false
                }
            },
            "required": ["$"],
            "additionalProperties": false
        },

        "action": {
            "type": "object",
            "properties": {
                "$": {
                    "type": "object",
                    "properties": {
                        "name": { "type": "string" },
                        "display-name-key": { "type": "string" },
                        "description-key": { "type": "string" }
                    },
                    "required": ["name"],
                    "additionalProperties": false
                },
                "parameter": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/parameter" }
                }
            },
            "required": ["$"],
            "additionalProperties": false
        },

        "platform-action": {
            "type": "object",
            "properties": {
                "$": {
                    "type": "object",
                    "properties": {
                        "action-type": { "type": "string" }
                    },
                    "required": ["action-type"],
                    "additionalProperties": false
                }
            },
            "required": ["$"],
            "additionalProperties": false
        },

        "parameter": {
            "type": "object",
            "properties": {
                "$": {
                    "type": "object",
                    "properties": {
                        "name": { "type": "string" },
                        "display-name-key": { "type": "string" },
                        "description-key": { "type": "string" },
                        "of-type": { "type": "string" },
                        "required": { "$ref": "#/definitions/booleanType" }
                    },
                    "required": ["name"],
                    "additionalProperties": false
                 }
            },
            "required": ["$"],
            "additionalProperties": false
        },

        "resource": {
            "type": "object",
            "properties": {
                "code": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/code" },
                    "maxItems": 1
                },
                "css": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/css" }
                },
                "resx": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/resx" }
                },
                "img": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/img" }
                },
                "html": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/html" }
                },
                "library": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/library" }
                },
                "platform-library": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/platform-library" }
                },
                "dependency": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/resource-dependency" }
                }
            },
            "required": ["code"],
            "additionalProperties": false
        },

        "code": {
            "type": "object",
            "properties": {
                "$": {
                    "type": "object",
                    "properties": {
                        "path": { "type": "string", "pattern": "^.+\\.ts$", "minLength": 1 },
                        "order": { "$ref": "#/definitions/orderType" }
                    },
                    "required": ["path", "order"],
                    "additionalProperties": false
                }
            },
            "required": ["$"],
            "additionalProperties": false
        },

        "css": {
            "type": "object",
            "properties": {
                "$": {
                    "type": "object",
                    "properties": {
                        "path": { "$ref": "#/definitions/pathType" },
                        "order": { "$ref": "#/definitions/orderType" },
                        "outputDirectory" : { "$ref" : "#/definitions/outputDirectory"}
                    },
                    "required": ["path"],
                    "additionalProperties": false
                }
            },
            "required": ["$"],
            "additionalProperties": false
        },

        "img": {
            "type": "object",
            "properties": {
                "$": {
                    "type": "object",
                    "properties": {
                        "path": { "$ref": "#/definitions/pathType" },
                        "outputDirectory" : { "$ref" : "#/definitions/outputDirectory"}
                    },
                    "required": ["path"],
                    "additionalProperties": false
                }
            },
            "required": ["$"],
            "additionalProperties": false
        },

        "html": {
            "type": "object",
            "properties": {
                "$": {
                    "type": "object",
                    "properties": {
                        "path": { "$ref": "#/definitions/pathType" },
                        "order": { "$ref": "#/definitions/orderType" },
                        "outputDirectory" : { "$ref" : "#/definitions/outputDirectory"}
                    },
                    "required": ["path"],
                    "additionalProperties": false
                }
            },
            "required": ["$"],
            "additionalProperties": false
        },

        "library": {
            "type": "object",
            "properties": {
                "$": {
                    "type": "object",
                    "properties": {
                        "name": { "type": "string" },
                        "version": { "$ref": "#/definitions/versionType" },
                        "order": { "$ref": "#/definitions/orderType" }
                    },
                    "required": ["name", "version", "order"],
                    "additionalProperties": false
                },
                "packaged_library": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/packagedLibrary" },
                    "maxItems": 1
                },
                "required": ["$"],
                "additionalProperties": false
            }
        },

        "platform-library": {
            "type": "object",
            "properties": {
                "$": {
                    "type": "object",
                    "properties": {
                        "name": { "type": "string" },
                        "version": { "$ref": "#/definitions/versionType" }
                    },
                    "required": ["name", "version"],
                    "additionalProperties": false
                },
                "required": ["$"],
                "additionalProperties": false
            }
        },

        "resource-dependency": {
            "type": "object",
            "properties": {
                "$": {
                    "type": "object",
                    "properties": {
                        "name": { "type": "string" },
                        "version": { "type": "string" },
                        "order": { "$ref": "#/definitions/orderType" },
                        "type": { "$ref": "#/definitions/dependencyType" },
                        "load-type": { "$ref": "#/definitions/loadType" }
                    },
                    "required": ["name", "type"],
                    "additionalProperties": false
                },
                "required": ["$"],
                "additionalProperties": false
            }
        },

        "resx": {
            "type": "object",
            "properties": {
                "$": {
                    "type": "object",
                    "properties": {
                        "path": { "$ref": "#/definitions/pathType" },
                        "version": { "$ref": "#/definitions/versionType" },
                        "outputDirectory" : { "$ref" : "#/definitions/outputDirectory"}
                    },
                    "required": ["path", "version"],
                    "additionalProperties": false
                }
            },
            "required": ["$"],
            "additionalProperties": false
        },

        "packagedLibrary": {
            "type": "object",
            "properties": {
                "$": {
                    "type": "object",
                    "properties": {
                        "path": { "$ref": "#/definitions/pathType" },
                        "version": { "$ref": "#/definitions/versionType" },
                        "outputDirectory" : { "$ref" : "#/definitions/outputDirectory"}
                    },
                    "required": ["path", "version"],
                    "additionalProperties": false
                }
            },
            "required": ["$"],
            "additionalProperties": false
        },

        "orderType": {
            "type": "string",
            "pattern": "^[1-9]\\d*$"
        },
        "versionType": {
            "type": "string",
            "pattern": "^[\\^=>]*\\d+(\\.\\d+)*$"
        },
        "pathType": {
            "type": "string",
            "minLength": 1
        },
        "outputDirectory": {
            "type": "string",
            "minLength": 1
        },
        "booleanType": {
            "type": "string",
            "enum": ["true", "false"]
        },
        "usageType": {
            "type": "string",
            "enum": ["bound", "input", "output"]
        },
        "usesFeatureType": {
            "type": "string",
            "enum": ["api"]
        },
        "dataType": {
            "type": "string",
            "enum": [
                "Currency",
                "DateAndTime.DateAndTime",
                "DateAndTime.DateOnly",
                "Decimal",
                "Enum",
                "File",
                "Form.Main",
                "FP",
                "Lookup.Customer",
                "Lookup.Owner",
                "Lookup.PartyList",
                "Lookup.Regarding",
                "Lookup.Simple",
                "Multiple",
                "MultiSelectOptionSet",
                "Object",
                "OptionSet",
                "SingleLine.Email",
                "SingleLine.Phone",
                "SingleLine.Text",
                "SingleLine.TextArea",
                "SingleLine.Ticker",
                "SingleLine.URL",
                "TwoOptions",
                "Whole.None"
            ]
        },
        "commonEventType": {
            "type": "string",
            "enum": [
                "OnSelect",
                "OnChange"
            ]
        },
        "loadType": {
            "type": "string",
            "enum": [
                "order",
                "onDemand"
            ]
        },
        "dependencyType":  {
            "type":  "string",
            "enum":  [
                "control"
            ]
        }
    },

    "type": "object",
    "properties": {
        "manifest": { "$ref": "#/definitions/manifest" }
    },
    "required": ["manifest"]
}
