{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://mfeflow.github.io/mfeflow/schema/feature.json",
  "title": "feature.json",
  "type": "object",
  "properties": {
    "$schema": {
      "type": "string"
    },
    "name": {
      "type": "string",
      "pattern": "^(@[a-z0-9-]+\\/)?[a-z][a-z0-9-]*$"
    },
    "version": {
      "type": "string"
    },
    "description": {
      "type": "string"
    },
    "keywords": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "prompts": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "pattern": "^[A-Za-z_$][A-Za-z0-9_$]*$"
          },
          "type": {
            "enum": [
              "boolean",
              "string",
              "select"
            ]
          },
          "message": {
            "type": "string"
          },
          "default": {
            "type": [
              "string",
              "boolean"
            ]
          },
          "choices": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "name",
          "type"
        ]
      }
    },
    "requires": {
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^(@[a-z0-9-]+\\/)?[a-z][a-z0-9-]*$"
      }
    },
    "conflicts": {
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^(@[a-z0-9-]+\\/)?[a-z][a-z0-9-]*$"
      }
    },
    "files": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "to": {
            "type": "string",
            "pattern": "^(?![A-Za-z]:)(?!\\.\\.?(?:\\/|$))[^/\\\\\\u0000]+(?:\\/(?!\\.\\.?(?:\\/|$))[^/\\\\\\u0000]+)*$"
          },
          "target": {
            "type": "string",
            "pattern": "^(root|shell|remotes|(app:)?[a-z][a-z0-9_]*)$"
          },
          "when": {
            "type": "object",
            "minProperties": 1,
            "propertyNames": {
              "type": "string",
              "pattern": "^[A-Za-z_$][A-Za-z0-9_$]*$"
            },
            "additionalProperties": {
              "type": [
                "string",
                "boolean"
              ]
            }
          },
          "from": {
            "type": "string",
            "pattern": "^(?![A-Za-z]:)(?!\\.\\.?(?:\\/|$))[^/\\\\\\u0000]+(?:\\/(?!\\.\\.?(?:\\/|$))[^/\\\\\\u0000]+)*$"
          },
          "content": {
            "type": "string"
          },
          "template": {
            "type": "boolean"
          },
          "atRoot": {
            "type": "boolean"
          }
        },
        "required": [
          "to"
        ],
        "oneOf": [
          {
            "required": [
              "from"
            ]
          },
          {
            "required": [
              "content"
            ]
          }
        ]
      }
    },
    "dependencies": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "pattern": "^(@[a-z0-9-~][a-z0-9-._~]*\\/)?[a-z0-9-~][a-z0-9-._~]*$|^\\{\\{scope\\}\\}\\/[a-z0-9-~][a-z0-9-._~]*$"
          },
          "range": {
            "type": "string"
          },
          "dev": {
            "type": "boolean"
          },
          "target": {
            "type": "string",
            "pattern": "^(root|shell|remotes|(app:)?[a-z][a-z0-9_]*)$"
          },
          "when": {
            "type": "object",
            "minProperties": 1,
            "propertyNames": {
              "type": "string",
              "pattern": "^[A-Za-z_$][A-Za-z0-9_$]*$"
            },
            "additionalProperties": {
              "type": [
                "string",
                "boolean"
              ]
            }
          }
        },
        "required": [
          "name",
          "range"
        ]
      }
    },
    "scripts": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "pattern": "^[A-Za-z0-9:_.-]+$"
          },
          "command": {
            "type": "string"
          },
          "target": {
            "type": "string",
            "pattern": "^(root|shell|remotes|(app:)?[a-z][a-z0-9_]*)$"
          },
          "when": {
            "type": "object",
            "minProperties": 1,
            "propertyNames": {
              "type": "string",
              "pattern": "^[A-Za-z_$][A-Za-z0-9_$]*$"
            },
            "additionalProperties": {
              "type": [
                "string",
                "boolean"
              ]
            }
          }
        },
        "required": [
          "name",
          "command"
        ]
      }
    },
    "transforms": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "op": {
            "enum": [
              "add-import",
              "wrap-provider",
              "add-shared",
              "add-boot-step",
              "add-env-key",
              "add-route",
              "add-workflow-step"
            ]
          }
        },
        "required": [
          "op"
        ],
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "op": {
                "const": "add-import"
              },
              "file": {
                "type": "string",
                "pattern": "^(?![A-Za-z]:)(?!\\.\\.?(?:\\/|$))[^/\\\\\\u0000]+(?:\\/(?!\\.\\.?(?:\\/|$))[^/\\\\\\u0000]+)*$"
              },
              "target": {
                "type": "string",
                "pattern": "^(root|shell|remotes|(app:)?[a-z][a-z0-9_]*)$"
              },
              "when": {
                "type": "object",
                "minProperties": 1,
                "propertyNames": {
                  "type": "string",
                  "pattern": "^[A-Za-z_$][A-Za-z0-9_$]*$"
                },
                "additionalProperties": {
                  "type": [
                    "string",
                    "boolean"
                  ]
                }
              },
              "from": {
                "type": "string"
              },
              "named": {
                "type": "array",
                "items": {
                  "type": "string",
                  "pattern": "^[A-Za-z_$][A-Za-z0-9_$]*$"
                }
              },
              "default": {
                "type": "string",
                "pattern": "^[A-Za-z_$][A-Za-z0-9_$]*$"
              },
              "namespace": {
                "type": "string",
                "pattern": "^[A-Za-z_$][A-Za-z0-9_$]*$"
              },
              "typeOnly": {
                "type": "boolean"
              }
            },
            "required": [
              "op",
              "file",
              "from"
            ]
          },
          {
            "type": "object",
            "properties": {
              "op": {
                "const": "wrap-provider"
              },
              "file": {
                "type": "string",
                "pattern": "^(?![A-Za-z]:)(?!\\.\\.?(?:\\/|$))[^/\\\\\\u0000]+(?:\\/(?!\\.\\.?(?:\\/|$))[^/\\\\\\u0000]+)*$"
              },
              "target": {
                "type": "string",
                "pattern": "^(root|shell|remotes|(app:)?[a-z][a-z0-9_]*)$"
              },
              "when": {
                "type": "object",
                "minProperties": 1,
                "propertyNames": {
                  "type": "string",
                  "pattern": "^[A-Za-z_$][A-Za-z0-9_$]*$"
                },
                "additionalProperties": {
                  "type": [
                    "string",
                    "boolean"
                  ]
                }
              },
              "component": {
                "type": "string",
                "pattern": "^[A-Za-z_$][A-Za-z0-9_$]*$"
              },
              "from": {
                "type": "string"
              },
              "props": {
                "type": "object",
                "additionalProperties": {
                  "type": [
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              },
              "defaultImport": {
                "type": "boolean"
              },
              "function": {
                "type": "string",
                "pattern": "^[A-Za-z_$][A-Za-z0-9_$]*$"
              }
            },
            "required": [
              "op",
              "file",
              "component",
              "from"
            ]
          },
          {
            "type": "object",
            "properties": {
              "op": {
                "const": "add-shared"
              },
              "file": {
                "type": "string",
                "pattern": "^(?![A-Za-z]:)(?!\\.\\.?(?:\\/|$))[^/\\\\\\u0000]+(?:\\/(?!\\.\\.?(?:\\/|$))[^/\\\\\\u0000]+)*$"
              },
              "target": {
                "type": "string",
                "pattern": "^(root|shell|remotes|(app:)?[a-z][a-z0-9_]*)$"
              },
              "when": {
                "type": "object",
                "minProperties": 1,
                "propertyNames": {
                  "type": "string",
                  "pattern": "^[A-Za-z_$][A-Za-z0-9_$]*$"
                },
                "additionalProperties": {
                  "type": [
                    "string",
                    "boolean"
                  ]
                }
              },
              "name": {
                "type": "string",
                "pattern": "^(@[a-z0-9-~][a-z0-9-._~]*\\/)?[a-z0-9-~][a-z0-9-._~]*$"
              },
              "list": {
                "type": "string",
                "pattern": "^[A-Za-z_$][A-Za-z0-9_$]*$"
              }
            },
            "required": [
              "op",
              "file",
              "name"
            ]
          },
          {
            "type": "object",
            "properties": {
              "op": {
                "const": "add-boot-step"
              },
              "file": {
                "type": "string",
                "pattern": "^(?![A-Za-z]:)(?!\\.\\.?(?:\\/|$))[^/\\\\\\u0000]+(?:\\/(?!\\.\\.?(?:\\/|$))[^/\\\\\\u0000]+)*$"
              },
              "target": {
                "type": "string",
                "pattern": "^(root|shell|remotes|(app:)?[a-z][a-z0-9_]*)$"
              },
              "when": {
                "type": "object",
                "minProperties": 1,
                "propertyNames": {
                  "type": "string",
                  "pattern": "^[A-Za-z_$][A-Za-z0-9_$]*$"
                },
                "additionalProperties": {
                  "type": [
                    "string",
                    "boolean"
                  ]
                }
              },
              "call": {
                "type": "string",
                "pattern": "^[A-Za-z_$][A-Za-z0-9_$]*$"
              },
              "from": {
                "type": "string"
              },
              "args": {
                "type": "array",
                "items": {
                  "type": [
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              },
              "await": {
                "type": "boolean"
              },
              "defaultImport": {
                "type": "boolean"
              },
              "before": {
                "type": "string",
                "pattern": "^[A-Za-z_$][A-Za-z0-9_$]*$"
              },
              "after": {
                "type": "string",
                "pattern": "^[A-Za-z_$][A-Za-z0-9_$]*$"
              },
              "function": {
                "type": "string",
                "pattern": "^[A-Za-z_$][A-Za-z0-9_$]*$"
              }
            },
            "required": [
              "op",
              "file",
              "call",
              "from"
            ]
          },
          {
            "type": "object",
            "properties": {
              "op": {
                "const": "add-env-key"
              },
              "file": {
                "type": "string",
                "pattern": "^(?![A-Za-z]:)(?!\\.\\.?(?:\\/|$))[^/\\\\\\u0000]+(?:\\/(?!\\.\\.?(?:\\/|$))[^/\\\\\\u0000]+)*$"
              },
              "target": {
                "type": "string",
                "pattern": "^(root|shell|remotes|(app:)?[a-z][a-z0-9_]*)$"
              },
              "when": {
                "type": "object",
                "minProperties": 1,
                "propertyNames": {
                  "type": "string",
                  "pattern": "^[A-Za-z_$][A-Za-z0-9_$]*$"
                },
                "additionalProperties": {
                  "type": [
                    "string",
                    "boolean"
                  ]
                }
              },
              "key": {
                "type": "string",
                "pattern": "^[A-Za-z_][A-Za-z0-9_]*$"
              },
              "scope": {
                "enum": [
                  "server",
                  "runtime"
                ]
              },
              "schema": {
                "type": "string"
              },
              "value": {
                "type": [
                  "string",
                  "number",
                  "boolean",
                  "null"
                ]
              },
              "object": {
                "type": "string",
                "pattern": "^[A-Za-z_$][A-Za-z0-9_$]*$"
              },
              "example": {
                "type": "string",
                "pattern": "^(?![A-Za-z]:)(?!\\.\\.?(?:\\/|$))[^/\\\\\\u0000]+(?:\\/(?!\\.\\.?(?:\\/|$))[^/\\\\\\u0000]+)*$"
              },
              "configFiles": {
                "type": "array",
                "items": {
                  "type": "string",
                  "pattern": "^(?![A-Za-z]:)(?!\\.\\.?(?:\\/|$))[^/\\\\\\u0000]+(?:\\/(?!\\.\\.?(?:\\/|$))[^/\\\\\\u0000]+)*$"
                }
              }
            },
            "required": [
              "op",
              "file",
              "key",
              "scope",
              "schema"
            ]
          },
          {
            "type": "object",
            "properties": {
              "op": {
                "const": "add-route"
              },
              "file": {
                "type": "string",
                "pattern": "^(?![A-Za-z]:)(?!\\.\\.?(?:\\/|$))[^/\\\\\\u0000]+(?:\\/(?!\\.\\.?(?:\\/|$))[^/\\\\\\u0000]+)*$"
              },
              "target": {
                "type": "string",
                "pattern": "^(root|shell|remotes|(app:)?[a-z][a-z0-9_]*)$"
              },
              "when": {
                "type": "object",
                "minProperties": 1,
                "propertyNames": {
                  "type": "string",
                  "pattern": "^[A-Za-z_$][A-Za-z0-9_$]*$"
                },
                "additionalProperties": {
                  "type": [
                    "string",
                    "boolean"
                  ]
                }
              },
              "path": {
                "type": "string",
                "pattern": "^\\/[A-Za-z0-9/_:*.-]*$"
              },
              "component": {
                "type": "string",
                "pattern": "^[A-Za-z_$][A-Za-z0-9_$]*$"
              },
              "from": {
                "type": "string"
              },
              "defaultImport": {
                "type": "boolean"
              },
              "routes": {
                "type": "string",
                "pattern": "^[A-Za-z_$][A-Za-z0-9_$]*$"
              }
            },
            "required": [
              "op",
              "file",
              "path",
              "component",
              "from"
            ]
          },
          {
            "type": "object",
            "properties": {
              "op": {
                "const": "add-workflow-step"
              },
              "file": {
                "type": "string",
                "pattern": "^(?![A-Za-z]:)(?!\\.\\.?(?:\\/|$))[^/\\\\\\u0000]+(?:\\/(?!\\.\\.?(?:\\/|$))[^/\\\\\\u0000]+)*$"
              },
              "target": {
                "type": "string",
                "pattern": "^(root|shell|remotes|(app:)?[a-z][a-z0-9_]*)$"
              },
              "when": {
                "type": "object",
                "minProperties": 1,
                "propertyNames": {
                  "type": "string",
                  "pattern": "^[A-Za-z_$][A-Za-z0-9_$]*$"
                },
                "additionalProperties": {
                  "type": [
                    "string",
                    "boolean"
                  ]
                }
              },
              "job": {
                "type": "string",
                "pattern": "^[A-Za-z_][A-Za-z0-9_-]*$"
              },
              "after": {
                "type": "string"
              },
              "step": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "id": {
                    "type": "string"
                  },
                  "uses": {
                    "type": "string"
                  },
                  "run": {
                    "type": "string"
                  },
                  "with": {
                    "type": "object",
                    "additionalProperties": {
                      "type": [
                        "string",
                        "number",
                        "boolean",
                        "null"
                      ]
                    }
                  },
                  "env": {
                    "type": "object",
                    "additionalProperties": {
                      "type": [
                        "string",
                        "number",
                        "boolean",
                        "null"
                      ]
                    }
                  },
                  "if": {
                    "type": "string"
                  }
                },
                "required": [
                  "name"
                ],
                "anyOf": [
                  {
                    "required": [
                      "uses"
                    ]
                  },
                  {
                    "required": [
                      "run"
                    ]
                  }
                ]
              }
            },
            "required": [
              "op",
              "file",
              "job",
              "step"
            ]
          }
        ]
      }
    },
    "migrations": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "from": {
            "type": "string"
          },
          "to": {
            "type": "string"
          },
          "module": {
            "type": "string",
            "pattern": "^(?![A-Za-z]:)(?!\\.\\.?(?:\\/|$))[^/\\\\\\u0000]+(?:\\/(?!\\.\\.?(?:\\/|$))[^/\\\\\\u0000]+)*$"
          }
        },
        "required": [
          "from",
          "to",
          "module"
        ]
      }
    }
  },
  "required": [
    "name",
    "version"
  ]
}
