config-central/schemas/profile.schema.json

425 lines
10 KiB
JSON

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://config-central.local/schemas/profile.schema.json",
"title": "Config Central profile",
"type": "object",
"additionalProperties": false,
"required": [
"schemaVersion",
"name"
],
"properties": {
"$schema": { "type": "string" },
"schemaVersion": {
"const": 1
},
"name": {
"type": "string",
"pattern": "^[a-z0-9][a-z0-9-]*$"
},
"description": {
"type": "string"
},
"packages": {
"type": "array",
"items": {
"$ref": "#/$defs/package"
},
"default": []
},
"configs": {
"type": "array",
"items": {
"$ref": "#/$defs/config"
},
"default": []
}
},
"$defs": {
"package": {
"type": "object",
"additionalProperties": false,
"required": [
"id"
],
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"source": {
"type": "string",
"minLength": 1,
"default": "winget"
},
"scope": {
"enum": [
"user",
"machine"
]
},
"version": {
"type": "string",
"minLength": 1
},
"update": {
"enum": [
"latest",
"pinned",
"install-only"
],
"default": "latest"
},
"state": {
"enum": [
"present",
"absent"
],
"default": "present"
},
"enabled": {
"type": "boolean",
"default": true
},
"provider": {
"enum": [
"winget",
"portable"
],
"default": "winget"
},
"url": {
"type": "string",
"pattern": "^https://[^\\s]+\\.zip(\\?[^\\s]*)?$"
},
"sha256": {
"type": "string",
"pattern": "^[a-fA-F0-9]{64}$"
},
"executable": {
"type": "string",
"pattern": "^[A-Za-z0-9_-][A-Za-z0-9._/-]*\\.exe$"
},
"releaseApi": {
"type": "string",
"pattern": "^https://[^/]+(?:/[^/]+)*/api/v1/repos/[^/]+/[^/]+/releases/?$"
},
"releaseChannel": {
"enum": [
"stable",
"prerelease"
]
},
"assetTemplate": {
"type": "string",
"pattern": "^[A-Za-z0-9._+{}-]*\\{version\\}[A-Za-z0-9._+{}-]*\\.zip$"
},
"executableTemplate": {
"type": "string",
"pattern": "^[A-Za-z0-9_{}-][A-Za-z0-9._/{}/-]*\\.exe$"
},
"checksumAsset": {
"type": "string",
"pattern": "^[A-Za-z0-9._+-]+$",
"default": "SHA256SUMS"
},
"displayName": {
"type": "string",
"minLength": 1,
"maxLength": 64,
"pattern": "^[^\\x00-\\x1f]+$"
},
"fileAssociations": {
"type": "array",
"minItems": 1,
"uniqueItems": true,
"items": {
"type": "string",
"pattern": "^\\.[a-z0-9]{1,16}$"
}
},
"fileAssociationIcon": {
"type": "string",
"pattern": "^assets/[A-Za-z0-9_-][A-Za-z0-9._/-]*\\.ico$"
},
"replaces": {
"type": "array",
"minItems": 1,
"uniqueItems": true,
"items": {
"type": "object",
"additionalProperties": false,
"required": ["source", "id"],
"properties": {
"source": {
"type": "string",
"pattern": "^[a-z0-9][a-z0-9-]{0,63}$"
},
"id": {
"type": "string",
"pattern": "^[a-z0-9][a-z0-9-]{0,63}$"
},
"fileAssociations": {
"type": "array",
"minItems": 1,
"uniqueItems": true,
"items": {
"type": "string",
"pattern": "^\\.[a-z0-9]{1,16}$"
}
},
"legacyRegistration": {
"type": "object",
"additionalProperties": false,
"required": ["registeredApplication", "progIds"],
"properties": {
"registeredApplication": {
"type": "string",
"minLength": 1,
"maxLength": 64,
"pattern": "^[^\\x00-\\x1f\\\\/]+$"
},
"progIds": {
"type": "array",
"minItems": 1,
"uniqueItems": true,
"items": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$"
}
}
}
}
}
}
}
},
"allOf": [
{
"if": {
"properties": {
"provider": {
"const": "portable"
}
},
"required": [
"provider"
]
},
"then": {
"properties": {
"id": {
"pattern": "^[a-z0-9][a-z0-9-]{0,63}$"
},
"source": {
"pattern": "^[a-z0-9][a-z0-9-]{0,63}$"
},
"scope": {
"const": "user"
},
"state": {
"const": "present"
}
},
"allOf": [
{
"if": {
"properties": {
"enabled": {
"const": false
}
},
"required": [
"enabled"
]
},
"else": {
"required": [
"version",
"url",
"sha256",
"executable",
"update"
],
"properties": {
"version": {
"pattern": "^\\d+\\.\\d+(\\.\\d+){0,2}$"
},
"update": {
"enum": [
"pinned",
"install-only"
]
}
},
"dependentRequired": {
"fileAssociations": [
"displayName"
],
"fileAssociationIcon": [
"fileAssociations"
],
"releaseApi": [
"releaseChannel",
"assetTemplate",
"executableTemplate"
],
"releaseChannel": [
"releaseApi",
"assetTemplate",
"executableTemplate"
],
"assetTemplate": [
"releaseApi",
"releaseChannel",
"executableTemplate"
],
"executableTemplate": [
"releaseApi",
"releaseChannel",
"assetTemplate"
],
"checksumAsset": [
"releaseApi",
"releaseChannel",
"assetTemplate",
"executableTemplate"
]
}
}
}
]
},
"else": {
"not": {
"anyOf": [
{
"required": [
"url"
]
},
{
"required": [
"sha256"
]
},
{
"required": [
"displayName"
]
},
{
"required": [
"fileAssociations"
]
},
{
"required": [
"fileAssociationIcon"
]
},
{
"required": [
"replaces"
]
},
{
"required": [
"executable"
]
},
{
"required": [
"releaseApi"
]
},
{
"required": [
"releaseChannel"
]
},
{
"required": [
"assetTemplate"
]
},
{
"required": [
"executableTemplate"
]
},
{
"required": [
"checksumAsset"
]
}
]
}
}
}
]
},
"config": {
"type": "object",
"additionalProperties": false,
"required": [
"name"
],
"properties": {
"name": {
"type": "string",
"pattern": "^[a-z0-9][a-z0-9-]*$"
},
"source": {
"type": "string",
"minLength": 1
},
"target": {
"type": "string",
"minLength": 1
},
"mode": {
"enum": [
"copy",
"ini-overlay",
"registry",
"hosts-block",
"windows-sounds",
"windows-power"
],
"default": "copy"
},
"requiresPackage": {
"type": "string",
"minLength": 1
},
"enabled": {
"type": "boolean",
"default": true
}
},
"allOf": [
{
"if": {
"properties": {
"enabled": {
"const": false
}
},
"required": [
"enabled"
]
},
"then": {},
"else": {
"required": [
"source",
"target"
]
}
}
]
}
}
}