{
    "title": "JSON schema for OraDBPM Package",
    "$schema": "http://json-schema.org/draft-04/schema#",
    "description": "https://raw.githubusercontent.com/s-oravec/oradb-package/master/oradbpm-package-schema.json",
    "type": "object",
    "definitions": {
        "SemverVersion": {
            "type": "string",
            "format": "semverVersion",
            "description": "Valid semver version (https://github.com/npm/node-semver)."
        },
        "SemverVersionRange": {
            "type": "string",
            "format": "semverVersionRange",
            "description": "Valid semver versionRange (https://github.com/npm/node-semver)."
        },
        "DependencyObject": {
            "type": "object",
            "properties": {
                "version": {
                    "$ref": "#/definitions/SemverVersionRange",
                    "description": "Package semver versionRange declaration."
                },
                "peer": {
                    "type": "boolean",
                    "description": "Dependency should be deployed as peer dependency."
                }
            },
            "required": [
                "version"
            ],
            "description": "Package dependency object.",
            "additionalProperties": false
        },
        "Dependency": {
            "oneOf": [
                {
                    "$ref": "#/definitions/SemverVersionRange",
                    "description": "Package dependency as semver versionRange declaration literal."
                },
                {
                    "$ref": "#/definitions/DependencyObject",
                    "description": "Package dependency object."
                }
            ],
            "description": "Package dependency"
        },
        "Dependencies": {
            "type": "object",
            "patternProperties": {
                "^[a-z][\\$#a-z0-9_]*$": {
                    "$ref": "#/definitions/Dependency",
                    "description": "properties of dependencies object are package names"
                }
            },
            "minProperties": 1,
            "additionalProperties": false,
            "description": "collection of packages and their versionRange declarations"
        },
        "PersonLiteral": {
            "type": "string",
            "pattern": "^.+\\<.+@.+\\..+\\>$",
            "description": "person defined as name <email>"
        },
        "PersonObject": {
            "type": "object",
            "properties": {
                "name": {
                    "type": "string",
                    "description": "person's name"
                },
                "email": {
                    "type": "string",
                    "format": "email",
                    "description": "person's email"
                }
            },
            "required": [
                "name",
                "email"
            ],
            "description": "person defined as person object",
            "additionalProperties": false
        },
        "Person": {
            "oneOf": [
                {
                    "$ref": "#/definitions/PersonLiteral",
                    "description": "person defined as name <email>"
                },
                {
                    "$ref": "#/definitions/PersonObject",
                    "description": "person defined as person object"
                }
            ],
            "description": "person definition"
        }
    },
    "properties": {
        "name": {
            "type": "string",
            "pattern": "^[a-z][\\$#a-z0-9_]*$",
            "description": "package name"
        },
        "version": {
            "$ref": "#/definitions/SemverVersion",
            "description": "package version - must be valid semver version"
        },
        "language": {
            "type": "string",
            "enum": [
                "sql",
                "plsql",
                "sqlplus"
            ],
            "description": "language in which is package implemented"
        },
        "description": {
            "type": "string",
            "description": "package description"
        },
        "license": {
            "type": "string",
            "description": "package license"
        },
        "author": {
            "$ref": "#/definitions/Person",
            "description": "package author"
        },
        "keywords": {
            "type": "array",
            "items": {
                "type": "string",
                "description": "keyword"
            },
            "aditionalItems": "false",
            "minItems": 1,
            "description": "list of keywords",
            "_uniqueItems": true
        },
        "repository": {
            "type": "string",
            "format": "uri",
            "description": "package git repository uri"
        },
        "bugs": {
            "type": "string",
            "format": "uri",
            "description": "package bug & issue tracking page"
        },
        "homepage": {
            "type": "string",
            "format": "uri",
            "description": "Package homepage."
        },
        "dependencies": {
            "$ref": "#/definitions/Dependencies",
            "description": "Collection of package runtime dependencies declarations."
        },
        "devDependencies": {
            "$ref": "#/definitions/Dependencies",
            "description": "Collection of package development dependencies declarations."
        }
    },
    "required": [
        "name",
        "version",
        "language",
        "description",
        "license"
    ],
    "additionalProperties": false
}