{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "/schema/person",
  "title": "Person minimum definition to link a person to a pagan identity",
  "description": "A person is a human with a apxtrib identity (alias = Public Private Key) that accept to be part of a tribe (a person is store inside a tribe). Information stored for a person are only visible from the town's Mayor and the tribe's Druid. You need at least trust the druid that trust the mayor (for sensitive data Mayor and Druid can be the same apx Identity.) Only a pagan that have the privateKey can read cipher data. The purpose of this schema is to link a person to a tribe and manage basic activities, profil for specific purpose will be a tribe object that can be add additionalProperties of this is set at true.",
  "type": "object",
  "properties": {
    "alias": {
      "title": "alias",
      "description": "A unique string identifying a unique public key",
      "type": "string",
      "minLength": 5,
      "pattern": "^[a-z0-9]*$"
    },
    "owner": {
      "title": "Owner of this person",
      "description": "For accessright purpose this is always equal as alias",
      "type": "string",
      "format": "Alias"
    },
    "dt_create": {
      "type": "string",
      "format": "date-time",
      "default": "dayjs.now()"
    },
    "dt_update": {
      "type": "string",
      "format": "date-time"
    },
    "dt_lastlogin": {
      "title": "Last time login",
      "description": "Last time this person authentify as alias access to this tribe",
      "type": "string",
      "format": "date-time"
    },
    "dt_delete": {
      "title": "Date of leaving tribe",
      "description": "Date from when this alias is ban of tribe by druid or want to leave. A pocess of data cleaning has to be run depending of Tribe's rules.",
      "type": "string",
      "format": "date"
    },
    "will": {
      "title": "Will script after leaving tribe",
      "description": "This will script will be apply on your data 30 days after your delete",
      "type": "string",
      "format": "js"
    },
    "recoveryauth": {
      "title": "Store numeric identity to recover it by email",
      "description": "This object store numeric identity alias with an email mainly used at Person level to recover by email a private and passphrase key associate to alias",
      "type": "object",
      "properties": {
        "email": {
          "type": "string",
          "format": "email"
        },
        "privatekey": {
          "type": "string",
          "format": "pgpprivatekey"
        },
        "publickey": {
          "type": "string",
          "format": "pgppublickey"
        },
        "passphrase": {
          "type": "string"
        }
      }
    },
    "firstname": {
      "title": "A firstname",
      "description": "This will be use to present yourself",
      "type": "string"
    },
    "lastname": {
      "title": "A lastname",
      "description": "This will be use to present yourself",
      "type": "string"
    },
    "dt_birth": {
      "title": "Your birthdate",
      "description": "Date of birth you want to communicate",
      "type": "string",
      "format": "date"
    },
    "pronom": {
      "title": "Your pronom",
      "description": "The way you want people communicate with you",
      "type": "string",
      "enum": ["0", "1", "2"]
    },
    "emailcom": {
      "title": "email use to communicate with you",
      "description": "email used by tribe to communicate with you, depending of your profil you can also define other mail to interact with other person",
      "type": "string",
      "format": "email"
    },
    "hobbies": {
      "title": "My hobbies",
      "type": "array",
      "comment": "from a tree word combinaison /lg/hobbies_xx.json"
    },
    "biography": {
      "title": "Your bio or few words to define yourself",
      "description": "Use this to share your values, this will be public to all of tribe's members and link to your person",
      "type": "string",
      "pattern": "^.{O,150}$"
    },
    "mbti": {
      "type": "object"
    },
    "imgavatar": {
      "title": "A picture of your person or personnality",
      "description": "This picture will be public to all tribe's member",
      "type": "url"
    },
    "profils": {
      "title": "Array of profil",
      "description": "List of profil to get accessright on object",
      "type": "array"
    }
  },
  "required": ["alias", "profilaccess"],
  "additionalProperties": true,
  "apxid": "alias",
  "apxuniquekey": ["alias"],
  "apxidx": [
    {
      "name": "lst_alias",
      "keyval": "alias"
    },
    {
      "name": "alias",
      "keyval": "alias"
    },
    {
      "name": "profils_alias",
      "keyval": "profils",
      "objkey": "alias"
    },
    {
      "name": "emailcom_alias",
      "keyval": "emailcom",
      "objkey": "alias"
    },
    {
      "name": "hobbies_alias",
      "keyval": "hobbies",
      "objkey": "alias"
    }
  ],
  "apxaccessrights": {
    "owner": {
      "D": [],
      "R": [
        "alias",
        "dt_create",
        "dt_update",
        "last_login",
        "firstname",
        "lastname",
        "dt_birth",
        "pronom",
        "emailcom",
        "hobies",
        "biography",
        "imgavatar",
        "profilaccess"
      ],
      "U": [
        "firstname",
        "lastname",
        "dt_birth",
        "pronom",
        "emailcom",
        "hobies",
        "biography",
        "imgavatar",
        "profilaccess"
      ]
    },
    "pagan": {
      "C": []
    },
    "mayor": {
      "D": [],
      "R": ["alias"]
    },
    "druid": {
      "D": [],
      "R": ["alias"]
    }
  }
}
