{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://themwdesk.com/schemas/listings.schema.json",
  "title": "The MW Desk public listings feed",
  "description": "Public, permissioned records only. No worker profiles, private contacts, precise asset addresses, payment credentials, or confidential material.",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "schema_version": {
      "const": "1.0"
    },
    "generated_at": {
      "type": "string",
      "format": "date-time"
    },
    "source_updated_at": {
      "type": "string",
      "format": "date-time"
    },
    "status": {
      "enum": [
        "empty",
        "snapshot"
      ]
    },
    "note": {
      "type": "string"
    },
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9-]+$"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "pattern": "^https://"
          },
          "category": {
            "enum": [
              "space",
              "sublease",
              "gear",
              "housing"
            ]
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "market": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "city": {
                "type": "string"
              },
              "region": {
                "type": "string"
              },
              "country": {
                "type": "string",
                "pattern": "^[A-Z]{2}$"
              }
            },
            "required": [
              "city",
              "region",
              "country"
            ]
          },
          "blind": {
            "const": true
          },
          "contact_url": {
            "type": "string",
            "pattern": "^https://themwdesk\\.com/(marketplace|jobs)/"
          },
          "price": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "amount": {
                "type": [
                  "number",
                  "null"
                ],
                "minimum": 0
              },
              "currency": {
                "type": "string"
              },
              "model": {
                "type": "string"
              }
            },
            "required": [
              "amount",
              "currency",
              "model"
            ]
          },
          "attributes": {
            "oneOf": [
              {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "listing_type": {
                    "enum": [
                      "colocation",
                      "powered_shell",
                      "full_data_center",
                      "land",
                      "power_supply"
                    ]
                  },
                  "critical_it_mw": {
                    "type": [
                      "number",
                      "null"
                    ],
                    "minimum": 0
                  },
                  "area_sf": {
                    "type": [
                      "number",
                      "null"
                    ],
                    "minimum": 0
                  },
                  "delivery_date": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "date_status": {
                    "enum": [
                      "energized_actual",
                      "target",
                      "unknown"
                    ]
                  },
                  "utility": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "power_status": {
                    "enum": [
                      "energized",
                      "contracted",
                      "queued",
                      "unknown"
                    ]
                  }
                },
                "required": [
                  "listing_type",
                  "critical_it_mw",
                  "area_sf",
                  "delivery_date",
                  "date_status",
                  "utility",
                  "power_status"
                ]
              },
              {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "term_remaining": {
                    "type": "string"
                  },
                  "term_end": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "critical_it_kw": {
                    "type": [
                      "number",
                      "null"
                    ],
                    "minimum": 0
                  },
                  "cabinets_cages": {
                    "type": "string"
                  },
                  "landlord_consent": {
                    "enum": [
                      "obtained",
                      "pending",
                      "not_requested",
                      "denied",
                      "unknown"
                    ]
                  }
                },
                "required": [
                  "term_remaining",
                  "term_end",
                  "critical_it_kw",
                  "cabinets_cages",
                  "landlord_consent"
                ]
              },
              {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "equipment_type": {
                    "type": "string"
                  },
                  "make_model": {
                    "type": "string"
                  },
                  "capacity_rating": {
                    "type": "string"
                  },
                  "year": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "condition": {
                    "type": "string"
                  },
                  "availability": {
                    "type": "string"
                  }
                },
                "required": [
                  "equipment_type",
                  "make_model",
                  "capacity_rating",
                  "year",
                  "condition",
                  "availability"
                ]
              },
              {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "housing_type": {
                    "type": "string"
                  },
                  "stay_terms": {
                    "type": "string"
                  },
                  "availability": {
                    "type": "string"
                  },
                  "commute_details": {
                    "type": "string"
                  }
                },
                "required": [
                  "housing_type",
                  "stay_terms",
                  "availability",
                  "commute_details"
                ]
              }
            ]
          },
          "source": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "name": {
                "type": "string"
              },
              "url": {
                "type": "string",
                "format": "uri",
                "pattern": "^https://"
              },
              "publication_rights": {
                "enum": [
                  "employer_permission",
                  "owner_permission",
                  "licensed_feed",
                  "original_reporting"
                ]
              }
            },
            "required": [
              "name",
              "url",
              "publication_rights"
            ]
          },
          "last_verified_at": {
            "type": "string",
            "format": "date-time"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "publication_status": {
            "const": "active"
          },
          "featured": {
            "type": "boolean"
          }
        },
        "required": [
          "id",
          "url",
          "category",
          "title",
          "description",
          "market",
          "blind",
          "contact_url",
          "price",
          "attributes",
          "source",
          "last_verified_at",
          "expires_at",
          "publication_status",
          "featured"
        ],
        "allOf": [
          {
            "if": {
              "properties": {
                "category": {
                  "const": "space"
                }
              }
            },
            "then": {
              "properties": {
                "attributes": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "listing_type": {
                      "enum": [
                        "colocation",
                        "powered_shell",
                        "full_data_center",
                        "land",
                        "power_supply"
                      ]
                    },
                    "critical_it_mw": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "minimum": 0
                    },
                    "area_sf": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "minimum": 0
                    },
                    "delivery_date": {
                      "anyOf": [
                        {
                          "type": "string",
                          "format": "date"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "date_status": {
                      "enum": [
                        "energized_actual",
                        "target",
                        "unknown"
                      ]
                    },
                    "utility": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "power_status": {
                      "enum": [
                        "energized",
                        "contracted",
                        "queued",
                        "unknown"
                      ]
                    }
                  },
                  "required": [
                    "listing_type",
                    "critical_it_mw",
                    "area_sf",
                    "delivery_date",
                    "date_status",
                    "utility",
                    "power_status"
                  ]
                }
              }
            }
          },
          {
            "if": {
              "properties": {
                "category": {
                  "const": "sublease"
                }
              }
            },
            "then": {
              "properties": {
                "attributes": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "term_remaining": {
                      "type": "string"
                    },
                    "term_end": {
                      "anyOf": [
                        {
                          "type": "string",
                          "format": "date"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "critical_it_kw": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "minimum": 0
                    },
                    "cabinets_cages": {
                      "type": "string"
                    },
                    "landlord_consent": {
                      "enum": [
                        "obtained",
                        "pending",
                        "not_requested",
                        "denied",
                        "unknown"
                      ]
                    }
                  },
                  "required": [
                    "term_remaining",
                    "term_end",
                    "critical_it_kw",
                    "cabinets_cages",
                    "landlord_consent"
                  ]
                }
              }
            }
          },
          {
            "if": {
              "properties": {
                "category": {
                  "const": "gear"
                }
              }
            },
            "then": {
              "properties": {
                "attributes": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "equipment_type": {
                      "type": "string"
                    },
                    "make_model": {
                      "type": "string"
                    },
                    "capacity_rating": {
                      "type": "string"
                    },
                    "year": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "condition": {
                      "type": "string"
                    },
                    "availability": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "equipment_type",
                    "make_model",
                    "capacity_rating",
                    "year",
                    "condition",
                    "availability"
                  ]
                }
              }
            }
          },
          {
            "if": {
              "properties": {
                "category": {
                  "const": "housing"
                }
              }
            },
            "then": {
              "properties": {
                "attributes": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "housing_type": {
                      "type": "string"
                    },
                    "stay_terms": {
                      "type": "string"
                    },
                    "availability": {
                      "type": "string"
                    },
                    "commute_details": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "housing_type",
                    "stay_terms",
                    "availability",
                    "commute_details"
                  ]
                }
              }
            }
          }
        ]
      }
    }
  },
  "required": [
    "schema_version",
    "generated_at",
    "source_updated_at",
    "status",
    "note",
    "items"
  ],
  "allOf": [
    {
      "if": {
        "properties": {
          "status": {
            "const": "empty"
          }
        }
      },
      "then": {
        "properties": {
          "items": {
            "maxItems": 0
          }
        }
      }
    }
  ]
}
