{
  "plugin": {
    "summary": {
      "description": "Archives, compresses and decompresses files.",
      "icon": "ArchiveExtract"
    },
    "parameters": {
      "schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "anyOf": [
          {
            "$ref": "#/definitions/ArchiveParams"
          },
          {
            "$ref": "#/definitions/ExtractParams"
          }
        ],
        "definitions": {
          "AdditionalFile": {
            "additionalProperties": false,
            "properties": {
              "destination": {
                "description": "Query Param: file-dest\n\nThe destination path to save the additional file to in the resulting file archive.\n\nYou may specify this parameter multiple times: once per `file` parameter.\n\nMust include a `\"/\"` prefix.",
                "title": "Additional File Destination",
                "type": "string"
              },
              "filePath": {
                "description": "Query Param: file\n\nAdditional file to add to the resulting file archive.\n\nYou may specify this parameter multiple times.\n\nTo use: specify the \"file path\" attribute of a file uploaded to your Upload account as the query parameter's value.",
                "title": "Additional File",
                "type": "string"
              }
            },
            "required": ["filePath"],
            "type": "object"
          },
          "ArchiveOnlyParams": {
            "additionalProperties": false,
            "properties": {
              "format": {
                "description": "Query Param: out\nQuery Param Title: Output Format\nQuery Param Precedence: 3\n\nOutput file will be saved as a `.tar` archive when using `m=archive`.",
                "enum": ["tar"],
                "title": "Output Format",
                "type": "string"
              }
            },
            "required": ["format"],
            "title": "Archive only",
            "type": "object"
          },
          "ArchiveParams": {
            "additionalProperties": false,
            "properties": {
              "additionalFiles": {
                "items": {
                  "$ref": "#/definitions/AdditionalFile"
                },
                "type": "array"
              },
              "destination": {
                "description": "Query Param: dest\n\nThe destination path to save the primary file to in the resulting file archive.\n\nMust include a `\"/\"` prefix.",
                "title": "Destination",
                "type": "string"
              },
              "mode": {
                "description": "Query Param: m\n\nArchives the file.\n\nResponse is the archived file, in the format specified by the `out` parameter.",
                "enum": ["archive"],
                "title": "Mode",
                "type": "string"
              },
              "settings": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ArchiveOnlyParams"
                  },
                  {
                    "$ref": "#/definitions/TarGzParams"
                  },
                  {
                    "$ref": "#/definitions/ZipParams"
                  }
                ],
                "title": "Archive settings"
              }
            },
            "required": ["mode", "settings"],
            "title": "Archive",
            "type": "object"
          },
          "ExtractParams": {
            "additionalProperties": false,
            "properties": {
              "format": {
                "anyOf": [
                  {
                    "additionalProperties": false,
                    "properties": {
                      "type": {
                        "description": "Query Param: in\nQuery Param Title: Input Format\nQuery Param Precedence: 1\n\nInput file will be treated as a `.zip` archive when using `m=extract`.",
                        "enum": ["zip"],
                        "title": "Input Format",
                        "type": "string"
                      }
                    },
                    "required": ["type"],
                    "type": "object"
                  },
                  {
                    "additionalProperties": false,
                    "properties": {
                      "type": {
                        "description": "Query Param: in\nQuery Param Title: Input Format\nQuery Param Precedence: 2\n\nInput file will be treated as a `.tar` archive when using `m=extract`.",
                        "enum": ["tar"],
                        "title": "Input Format",
                        "type": "string"
                      }
                    },
                    "required": ["type"],
                    "type": "object"
                  },
                  {
                    "additionalProperties": false,
                    "properties": {
                      "type": {
                        "description": "Query Param: in\nQuery Param Title: Input Format\nQuery Param Precedence: 3\n\nInput file will be treated as a `.tar.gz` (or `.tgz`) archive when using `m=extract`.",
                        "enum": ["tar.gz"],
                        "title": "Input Format",
                        "type": "string"
                      }
                    },
                    "required": ["type"],
                    "type": "object"
                  }
                ]
              },
              "mode": {
                "description": "Query Param: m\n\nExtracts the file archive.\n\nResponse is a text file containing a list of file sizes and relative file paths, which you can download using the `artifact` query parameter.",
                "enum": ["extract"],
                "title": "Mode",
                "type": "string"
              }
            },
            "required": ["mode"],
            "title": "Extract",
            "type": "object"
          },
          "TarGzParams": {
            "additionalProperties": false,
            "properties": {
              "compressionLevel": {
                "default": 7,
                "description": "Query Param: c\nQuery Param Title: Compression Level\n\nOnly applicable to `m=archive`.\n\nSets the compression level for the resulting file archive.\n\n- `0` = lowest compression and largest file size.\n\n- `9` = highest compression and smallest file size.\n\nNote: if `c` is set then `out` must be `zip` or `tar.gz` (`tar` files are uncompressed).",
                "maximum": 9,
                "minimum": 0,
                "title": "Compression Level",
                "type": "integer"
              },
              "format": {
                "description": "Query Param: out\nQuery Param Title: Output Format\nQuery Param Precedence: 2\n\nOutput file will be saved as a `.tar.gz` archive when using `m=archive`.",
                "enum": ["tar.gz"],
                "title": "Output Format",
                "type": "string"
              }
            },
            "required": ["compressionLevel", "format"],
            "type": "object"
          },
          "ZipParams": {
            "additionalProperties": false,
            "properties": {
              "compressionLevel": {
                "default": 7,
                "description": "Query Param: c\nQuery Param Title: Compression Level\n\nOnly applicable to `m=archive`.\n\nSets the compression level for the resulting file archive.\n\n- `0` = lowest compression and largest file size.\n\n- `9` = highest compression and smallest file size.\n\nNote: if `c` is set then `out` must be `zip` or `tar.gz` (`tar` files are uncompressed).",
                "maximum": 9,
                "minimum": 0,
                "title": "Compression Level",
                "type": "integer"
              },
              "format": {
                "description": "Query Param: out\nQuery Param Title: Output Format\nQuery Param Precedence: 1\n\nOutput file will be saved as a `.zip` archive when using `m=archive`.",
                "enum": ["zip"],
                "title": "Output Format",
                "type": "string"
              }
            },
            "required": ["compressionLevel", "format"],
            "type": "object"
          }
        }
      },
      "ui": {
        "settings": {
          "ui:order": ["format", "compressionLevel"],
          "compressionLevel": {
            "ui:widget": "range"
          }
        },
        "mode": {
          "ui:widget": "hidden"
        }
      }
    }
  },
  "templates": {
    "compress": {
      "summary": {
        "name": "Compress a file",
        "description": "Compresses the file using the given compression level.",
        "category": "archival",
        "icon": "ArchiveCompress",
        "promoted": true
      },
      "transformation": {
        "description": {
          "ref": "join('', ['Compresses the file into a ', to_string(format), ' archive.'])"
        },
        "slug": "compress",
        "steps": [
          {
            "plugin": {
              "packageName": "upload-compression-plugin",
              "packageVersion": "3.21.0"
            },
            "params": {
              "mode": "archive",
              "settings": {
                "format": {
                  "ref": "format"
                },
                "compressionLevel": {
                  "ref": "compressionLevel"
                }
              }
            }
          }
        ]
      },
      "transformationVariables": {
        "schema": {
          "$schema": "http://json-schema.org/draft-07/schema#",
          "type": "object",
          "properties": {
            "format": {
              "enum": ["zip", "tar.gz"],
              "title": "Output Format",
              "type": "string",
              "default": "zip"
            },
            "compressionLevel": {
              "maximum": 9,
              "minimum": 0,
              "title": "Compression Level",
              "type": "integer",
              "default": 5
            }
          },
          "required": ["format", "compressionLevel"]
        },
        "ui": {
          "compressionLevel": {
            "ui:widget": "range"
          },
          "format": {
            "zip": {
              "ui:title": "ZIP"
            },
            "tar.gz": {
              "ui:title": "TAR.GZ"
            }
          }
        }
      }
    },
    "extract": {
      "summary": {
        "name": "Extract an archive",
        "description": "Extracts the file & returns a response containing relative URLs to the content.",
        "category": "archival",
        "icon": "ArchiveExtract",
        "promoted": true
      },
      "transformation": {
        "description": {
          "ref": "join('', ['Extracts a ', to_string(format), ' archive.'])"
        },
        "slug": "extract",
        "steps": [
          {
            "plugin": {
              "packageName": "upload-compression-plugin",
              "packageVersion": "3.21.0"
            },
            "params": {
              "mode": "extract",
              "format": {
                "type": {
                  "ref": "format"
                }
              }
            }
          }
        ]
      },
      "transformationVariables": {
        "schema": {
          "$schema": "http://json-schema.org/draft-07/schema#",
          "type": "object",
          "properties": {
            "format": {
              "enum": ["zip", "tar.gz", "tar"],
              "title": "Input Format",
              "description": "The input archive must use this file format.",
              "type": "string",
              "default": "zip"
            }
          },
          "required": ["format"]
        },
        "ui": {
          "format": {
            "zip": {
              "ui:title": "ZIP"
            },
            "tar.gz": {
              "ui:title": "TAR.GZ"
            },
            "tar": {
              "ui:title": "TAR"
            }
          }
        }
      }
    }
  }
}
