{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://owlie.com/docs/schemas/connectors/definitions/flat-file.schema.json",
  "title": "Owlie flat-file connector definition",
  "description": "The definition.json of a flat-file connector (engine major 1). Owlie derives the connector's manifest from it. A value the definition makes install-editable is a bare { \"$oxl\": \"config.<name>\" } naming a field declared under config.properties; each install keeps its own copy, seeded from the field's default.",
  "type": "object",
  "required": ["engine", "feeds"],
  "additionalProperties": false,
  "properties": {
    "engine": {
      "type": "integer",
      "const": 1
    },
    "description": {
      "type": "string",
      "minLength": 1
    },
    "icon": {
      "type": "string",
      "minLength": 1
    },
    "config": {
      "type": "object",
      "properties": {
        "properties": {
          "type": "object",
          "additionalProperties": {
            "type": "object"
          }
        }
      }
    },
    "accountEntityKey": {
      "type": "string",
      "minLength": 1
    },
    "feeds": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "required": ["kind", "fileMatch", "parse"],
        "additionalProperties": false,
        "properties": {
          "kind": {
            "enum": ["entity", "relationship"]
          },
          "entityKey": {
            "type": "string",
            "minLength": 1
          },
          "fileMatch": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1
              },
              {
                "type": "object",
                "required": ["$oxl"],
                "additionalProperties": false,
                "properties": {
                  "$oxl": {
                    "type": "string",
                    "minLength": 1
                  }
                }
              }
            ]
          },
          "parse": {
            "type": "object",
            "required": ["delimiter", "header", "encoding"],
            "additionalProperties": false,
            "properties": {
              "delimiter": {
                "enum": [",", ";", "\t"]
              },
              "header": {
                "type": "boolean"
              },
              "encoding": {
                "const": "utf-8"
              }
            }
          },
          "columns": {
            "anyOf": [
              {
                "type": "object",
                "additionalProperties": {
                  "type": "object",
                  "required": ["position", "type"],
                  "additionalProperties": false,
                  "properties": {
                    "position": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "type": {
                      "enum": ["string", "number", "boolean"]
                    },
                    "identifier": {
                      "type": "boolean"
                    }
                  }
                }
              },
              {
                "type": "object",
                "required": ["$oxl"],
                "additionalProperties": false,
                "properties": {
                  "$oxl": {
                    "type": "string",
                    "minLength": 1
                  }
                }
              }
            ]
          },
          "edge": {
            "type": "object",
            "required": ["edgeKey", "sourceEntityKey", "targetEntityKey", "sourceColumn", "targetColumn"],
            "additionalProperties": false,
            "properties": {
              "edgeKey": {
                "type": "string",
                "minLength": 1
              },
              "sourceEntityKey": {
                "type": "string",
                "minLength": 1
              },
              "targetEntityKey": {
                "type": "string",
                "minLength": 1
              },
              "sourceColumn": {
                "type": "string",
                "minLength": 1
              },
              "targetColumn": {
                "type": "string",
                "minLength": 1
              }
            }
          },
          "isActiveExpr": {
            "type": "string",
            "minLength": 1
          },
          "isDeletedExpr": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    }
  }
}
