{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://catalog.lintel.tools/schemas/schemastore/anywork-automation-configuration/latest.json",
  "title": "AnyWork Automation Configuration schema",
  "description": "Used to configure any part of AnyWork automation.",
  "x-lintel": {
    "source": "https://www.schemastore.org/anywork-ac-1.1.json",
    "sourceSha256": "ae5e7a422810bc3ce182220ed4005338eb4a6205514b3aeeff060a1abccf6f1b",
    "fileMatch": [
      ".awc.yaml",
      ".awc.yml",
      ".awc.json",
      ".awc.jsonc",
      ".awc"
    ],
    "parsers": [
      "json",
      "jsonc",
      "yaml"
    ]
  },
  "type": "object",
  "properties": {
    "ctype": {
      "type": "string",
      "description": "type of configuration, means who will use this configuration."
    },
    "cversion": {
      "type": "integer",
      "default": 1,
      "description": "Version of configuration. The reader will parse configuration based on this."
    }
  },
  "required": [
    "ctype",
    "cversion"
  ],
  "additionalProperties": true,
  "$defs": {
    "version": {
      "pattern": "^[\\^~]?(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"
    },
    "buildId": {
      "type": "number",
      "description": "The `BUILD_ID` to use for this task.",
      "default": 0
    },
    "generateId": {
      "type": "number",
      "description": "The `GENERATE_ID` to use for this task.",
      "default": 0
    },
    "disable": {
      "type": "boolean",
      "description": "Determines if this task is disabled.",
      "default": true
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "ctype": {
            "const": "swagger-codegen"
          }
        }
      },
      "then": {
        "required": [
          "swagger-codegen"
        ],
        "properties": {
          "swagger-codegen": {
            "title": "swagger codegen",
            "type": "object",
            "description": "swagger-codegen Configuration",
            "properties": {
              "schemas": {
                "type": "array",
                "description": "List of schemas (microservices) to generate it's libraries.",
                "items": {
                  "title": "schema",
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string",
                      "pattern": "[a-zA-Z]+",
                      "description": "Name of schema. This will be used to generate codes, only `[a-zA-Z]+` is accepted.",
                      "examples": [
                        "authorization"
                      ]
                    },
                    "disable": {
                      "type": "boolean",
                      "default": true,
                      "description": "Disables all actions over this schema."
                    },
                    "actions": {
                      "type": "array",
                      "description": "Determines the actions should be applied over this schema.",
                      "uniqueItems": true,
                      "items": {
                        "anyOf": [
                          {
                            "title": "action",
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "download",
                                "description": "Type of action to apply."
                              },
                              "sourceUrl": {
                                "type": "string",
                                "examples": [
                                  "http://somewhere/path/to/swagger.json"
                                ],
                                "pattern": "http[s]?:\\/\\/.*\\/swagger\\.json",
                                "description": "Source of `swagger.json` schema to download"
                              },
                              "id": {
                                "type": "number",
                                "description": "A unique specific ID of this download to be referenced (`DOWNLOAD_ID`).",
                                "default": 0
                              },
                              "disable": {
                                "$ref": "#/$defs/disable"
                              }
                            },
                            "description": "Defines a download schema task.",
                            "required": [
                              "type",
                              "sourceUrl",
                              "id"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "title": "action",
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "generate",
                                "description": "Type of action to apply."
                              },
                              "ngVersion": {
                                "$ref": "#/$defs/version",
                                "description": "Specifies Angular version which codes will be generated for.",
                                "default": "12.2.14"
                              },
                              "id": {
                                "type": "number",
                                "description": "A unique specific ID of this generation to be referenced (`GENERATE_ID`).",
                                "default": 0
                              },
                              "downloadId": {
                                "type": "number",
                                "description": "The `DOWNLOAD_ID` of downloaded schema to generate codes based on.",
                                "default": 0
                              },
                              "disable": {
                                "$ref": "#/$defs/disable"
                              }
                            },
                            "description": "Defines a TS code generator task.",
                            "required": [
                              "type",
                              "ngVersion",
                              "id",
                              "downloadId"
                            ],
                            "additionalProperties": true
                          },
                          {
                            "title": "action",
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "correction",
                                "description": "Type of action to apply."
                              },
                              "generateId": {
                                "$ref": "#/$defs/generateId"
                              },
                              "disable": {
                                "$ref": "#/$defs/disable"
                              }
                            },
                            "description": "Defines a code correction task.",
                            "required": [
                              "type",
                              "generateId"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "title": "action",
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "build",
                                "description": "Type of action to apply."
                              },
                              "typescriptVersion": {
                                "$ref": "#/$defs/version",
                                "description": "Specifies TypeScript version to install before build.",
                                "default": "4.3.5"
                              },
                              "id": {
                                "type": "number",
                                "description": "A unique specific ID of this build to be referenced (`BUILD_ID`)."
                              },
                              "generateId": {
                                "$ref": "#/$defs/generateId"
                              },
                              "disable": {
                                "$ref": "#/$defs/disable"
                              }
                            },
                            "description": "Defines a TS code builder task.",
                            "required": [
                              "type",
                              "typescriptVersion",
                              "id",
                              "generateId"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "title": "action",
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "publish",
                                "description": "Type of action to apply."
                              },
                              "registryUrl": {
                                "type": "string",
                                "description": "The Url of registry accepting this repository.",
                                "pattern": "http[s]?://.*",
                                "default": "http://verdaccio.anywork.local:4873"
                              },
                              "token": {
                                "type": "string",
                                "description": "Token to use access registry.",
                                "default": "bzKaK7hK2OAoCK9d72S0UevXGZEjj8rZpv8AFoaZ+/w=",
                                "examples": [
                                  "bzKaK7hK2OAoCK9d72S0UevXGZEjj8rZpv8AFoaZ+/w="
                                ]
                              },
                              "buildId": {
                                "$ref": "#/$defs/buildId"
                              },
                              "id": {
                                "type": "number",
                                "description": "A unique specific ID of this publish to be referenced (`PUBLISH_ID`).",
                                "default": 0
                              },
                              "disable": {
                                "$ref": "#/$defs/disable"
                              }
                            },
                            "description": "Defines a `npm publish` task.",
                            "required": [
                              "type",
                              "registryUrl",
                              "token",
                              "id"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "title": "action",
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "install",
                                "description": "Type of action to apply."
                              },
                              "publishId": {
                                "type": "number",
                                "description": "The `PUBLISH_ID` to use for this task.",
                                "default": 0
                              },
                              "targetPath": {
                                "type": "string",
                                "description": "The relative or absolute physical path of directory containing `packages.json` to install specified"
                              },
                              "disable": {
                                "$ref": "#/$defs/disable"
                              }
                            },
                            "description": "Defines a Api install task.",
                            "required": [
                              "type",
                              "targetPath",
                              "publishId"
                            ],
                            "additionalProperties": false
                          }
                        ]
                      }
                    }
                  },
                  "required": [
                    "name",
                    "actions"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "schemas"
            ],
            "additionalProperties": false
          }
        },
        "type": "object"
      }
    }
  ]
}
