{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://trooth.co/schemas/network-search.v1.schema.json",
  "title": "Trooth Network discovery response, version 1",
  "description": "A page of matching companies.",
  "type": "object",
  "required": [
    "format",
    "results",
    "total",
    "next_cursor",
    "partial",
    "order",
    "how_to_read",
    "consistency"
  ],
  "additionalProperties": false,
  "properties": {
    "format": {
      "const": "trooth.network-search.v1",
      "description": "Names this shape."
    },
    "results": {
      "type": "array",
      "description": "The companies on this page.",
      "items": {
        "$ref": "#/$defs/result"
      }
    },
    "total": {
      "type": "integer",
      "description": "How many companies match, across all pages, on this read.",
      "minimum": 0
    },
    "next_cursor": {
      "description": "Send as cursor, with the same filters, for the next page; null at the end.",
      "oneOf": [
        {
          "type": "null"
        },
        {
          "type": "string",
          "minLength": 1
        }
      ]
    },
    "partial": {
      "description": "Set when this answer covers part of the directory; null when it is whole.",
      "oneOf": [
        {
          "type": "null"
        },
        {
          "type": "object",
          "description": "Present when the read stopped at its ceiling.",
          "required": [
            "shown",
            "total"
          ],
          "additionalProperties": false,
          "properties": {
            "shown": {
              "type": "integer",
              "description": "Profiles read.",
              "minimum": 0
            },
            "total": {
              "description": "Published profiles in all, or null when the count could not be taken.",
              "oneOf": [
                {
                  "type": "null"
                },
                {
                  "type": "integer",
                  "description": "Published profiles in all.",
                  "minimum": 0
                }
              ]
            }
          }
        }
      ]
    },
    "order": {
      "type": "string",
      "description": "The ordering rule, in words."
    },
    "how_to_read": {
      "type": "string",
      "description": "How to read this answer."
    },
    "consistency": {
      "type": "object",
      "description": "What a walk of this list promises and does not.",
      "required": [
        "mode",
        "completeEnumeration",
        "note",
        "cursorScope"
      ],
      "additionalProperties": false,
      "properties": {
        "mode": {
          "const": "best-effort",
          "description": "Pages read the live directory; there is no snapshot."
        },
        "completeEnumeration": {
          "const": false,
          "description": "A walk is not a consistent full export."
        },
        "note": {
          "type": "string",
          "description": "The guarantee, in words."
        },
        "cursorScope": {
          "type": "string",
          "description": "What a cursor is bound to."
        }
      }
    }
  },
  "$defs": {
    "result": {
      "type": "object",
      "description": "One company, as its published page shows it.",
      "required": [
        "slug",
        "domain",
        "name",
        "record_url",
        "profile_url",
        "witnessed",
        "last_witnessed_at",
        "profile_updated_at",
        "industries",
        "products",
        "country",
        "residency",
        "hosting",
        "facts"
      ],
      "additionalProperties": false,
      "properties": {
        "slug": {
          "description": "The published profile's slug, or null for a witnessed company with no profile.",
          "oneOf": [
            {
              "type": "null"
            },
            {
              "type": "string",
              "description": "Profile slug."
            }
          ]
        },
        "domain": {
          "description": "The company's domain, or null.",
          "oneOf": [
            {
              "type": "null"
            },
            {
              "type": "string",
              "description": "Domain."
            }
          ]
        },
        "name": {
          "type": "string",
          "description": "The company's name as it publishes it."
        },
        "record_url": {
          "description": "The full machine record, GET /api/network/profile.",
          "oneOf": [
            {
              "type": "null"
            },
            {
              "type": "string",
              "description": "URL."
            }
          ]
        },
        "profile_url": {
          "description": "The company's page on trooth.co.",
          "oneOf": [
            {
              "type": "null"
            },
            {
              "type": "string",
              "description": "URL."
            }
          ]
        },
        "witnessed": {
          "type": "boolean",
          "description": "True when the company is in Trooth's live witnessed feed. A statement about whether evidence exists, not about the company."
        },
        "last_witnessed_at": {
          "description": "When Trooth last witnessed the company, or null.",
          "oneOf": [
            {
              "type": "null"
            },
            {
              "type": "string",
              "description": "ISO 8601 time."
            }
          ]
        },
        "profile_updated_at": {
          "description": "When the published profile last changed, or null.",
          "oneOf": [
            {
              "type": "null"
            },
            {
              "type": "string",
              "description": "ISO 8601 time."
            }
          ]
        },
        "industries": {
          "type": "array",
          "description": "Industries the company published.",
          "items": {
            "type": "string",
            "description": "An industry."
          }
        },
        "products": {
          "type": "array",
          "description": "Product names from the company's visible offering section.",
          "items": {
            "type": "string",
            "description": "A product name."
          }
        },
        "country": {
          "description": "The HQ country the company published, or null.",
          "oneOf": [
            {
              "type": "null"
            },
            {
              "type": "string",
              "description": "Country."
            }
          ]
        },
        "residency": {
          "type": "array",
          "description": "Data residency regions the company published, when its page shows them.",
          "items": {
            "type": "string",
            "description": "A region, as written."
          }
        },
        "hosting": {
          "type": "array",
          "description": "Deployment models the company published, when its page shows them.",
          "items": {
            "type": "string",
            "description": "A deployment model."
          }
        },
        "facts": {
          "type": "object",
          "description": "Whole days counted from timestamps on the record at the time of the response. They rate nothing.",
          "required": [
            "days_since_last_witnessed",
            "days_since_profile_updated"
          ],
          "additionalProperties": false,
          "properties": {
            "days_since_last_witnessed": {
              "description": "Days since the last witnessed reading, or null.",
              "oneOf": [
                {
                  "type": "null"
                },
                {
                  "type": "integer",
                  "description": "Days.",
                  "minimum": 0
                }
              ]
            },
            "days_since_profile_updated": {
              "description": "Days since the profile last changed, or null.",
              "oneOf": [
                {
                  "type": "null"
                },
                {
                  "type": "integer",
                  "description": "Days.",
                  "minimum": 0
                }
              ]
            }
          }
        }
      }
    }
  }
}
