{
  "$id": "https://github.com/data-fair/lib/session-state",
  "x-exports": ["types", "validate", "schema"],
  "type":"object",
  "title": "session state",
  "additionalProperties":false,
  "properties":{
    "user":{
      "$ref":"#/$defs/user"
    },
    "organization":{
      "$ref":"#/$defs/organizationMembership"
    },
    "account":{
      "$ref":"#/$defs/account"
    },
    "accountRole":{
      "type":"string"
    },
    "lang":{
      "type":"string"
    },
    "dark":{
      "type":"boolean"
    }
  },
  "$defs":{
    "organizationMembership":{
      "type":"object",
      "additionalProperties":false,
      "required":[
        "id",
        "name",
        "role"
      ],
      "properties":{
        "id":{
          "type":"string"
        },
        "name":{
          "type":"string"
        },
        "role":{
          "type":"string"
        },
        "department":{
          "type":"string"
        },
        "departmentName":{
          "type":"string"
        },
        "dflt":{
          "type":"boolean"
        }
      }
    },
    "userRef":{
      "type":"object",
      "additionalProperties":false,
      "required":[
        "id",
        "name"
      ],
      "properties":{
        "id":{
          "type":"string"
        },
        "name":{
          "type":"string"
        }
      }
    },
    "user":{
      "type":"object",
      "additionalProperties":false,
      "required":[
        "email",
        "id",
        "name",
        "organizations"
      ],
      "properties":{
        "email":{
          "type":"string",
          "format":"email"
        },
        "id":{
          "type":"string"
        },
        "name":{
          "type":"string"
        },
        "organizations":{
          "type":"array",
          "items":{
            "$ref":"#/$defs/organizationMembership"
          }
        },
        "isAdmin":{
          "type":"integer",
          "enum":[
            0,
            1
          ]
        },
        "adminMode":{
          "type":"integer",
          "enum":[
            0,
            1
          ]
        },
        "asAdmin":{
          "$ref":"#/$defs/userRef"
        },
        "pd":{
          "type":"string",
          "format":"date"
        },
        "ipa":{
          "type":"integer",
          "enum":[
            0,
            1
          ]
        }
      }
    },
    "account":{
      "type":"object",
      "additionalProperties":false,
      "required":[
        "type",
        "id",
        "name"
      ],
      "properties":{
        "type":{
          "type":"string",
          "enum": ["user", "organization"]
        },
        "id":{
          "type":"string"
        },
        "name":{
          "type":"string"
        },
        "department":{
          "type":"string"
        },
        "departmentName":{
          "type":"string"
        }
      }
    }
  }
}