---
# System prepended metadata

title: Unidict protocol v2

---

# Unidict protocol v2
```graphql
schema {
  query: QueryRoot
  mutation: MutationRoot
  subscription: SubscriptionRoot
}

input ArticleIdInput {
  id: Int!
}

type DictArticle {
  articleId: Int!
  eventDate: NaiveDateTime!
  eventLatitude: Float!
  eventLongitude: Float!
  fields: [DictArticleFieldValue!]!
}

enum DictArticleDataType {
  INTEGER
  FLOAT
  STRING
  BOOLEAN
  DATE
  COORDINATES
  PHONE
  EMAIL
  IMAGE
  FILE
  CHOICE_FROM_VAR
  DICT_LINK
  DATETIME
  PASSPORT
}

scalar DictArticleDataValue

type DictArticleField {
  name: String!
  numbering: Int!
  title: String!
  dataType: DictArticleDataType!
  dataIsList: Boolean!
}

input DictArticleFieldCondition {
  name: String!
  condition: DictValueCondition!
  value: String!
}

type DictArticleFieldValue {
  name: String!
  title: String!
  numbering: Int!
  dataType: DictArticleDataType!
  dataIsList: Boolean!
  value: DictArticleDataValue!
}

type DictId {
  id: DictIdType!
}

input DictIdInput {
  id: DictIdType!
}

enum DictIdType {
  ARTICLE
}

type DictInfo {
  hasEvents: Boolean!
  hasCoordinates: Boolean!
  hasPersonalDataInName: Boolean!
  articleNameFormat: String!
}

enum DictValueCondition {
  EQUAL
  LESS
  GREATER
  CONTAINS
}

type Expertise {
  metaData: [Int!]!
  reportAccess: Boolean!
  dataAccess: Boolean!
}

type ExpertiseId {
  id: [Int!]!
}

input ExpertiseIdInput {
  id: [Int!]!
}

type ExpertiseReport {
  key: [Int!]!
  data: [Int!]!
}

type IncomingAccessRequest {
  # Public key of the user that requested an access.
  forUserId: UserId!
  expertiseId: ExpertiseId!
  report: Boolean!
  data: Boolean!
}

type MutationRoot {
  # user_info is Ed25519-signed JSON-serialized UserInfo.
  registerUser(userId: UserId!, userInfo: [Int!]!): Boolean!
  queryReportAccess(userId: UserId!, expertiseId: ExpertiseIdInput!): Boolean!
  queryDataAccess(userId: UserId!, expertiseId: ExpertiseIdInput!): Boolean!
  grantAccess(
    userId: UserId!
    forUserId: UserId!
    expertiseId: ExpertiseIdInput!
    reportKey: [Int!]
    dataKey: [Int!]
  ): Boolean!
  refuseAccessQuery(
    userId: UserId!
    forUserId: UserId!
    articleId: ExpertiseIdInput!
  ): Boolean!
}

# ISO 8601 combined date and time without timezone.
#
# # Examples
#
# * `2015-07-01T08:59:60.123`,
scalar NaiveDateTime

type OutgoingAccessRequest {
  # Hash of an expertise.
  expertiseId: ExpertiseId!
  report: Boolean!
  data: Boolean!
}

type QueryDict {
  getDictInfo: DictInfo!
  getFields: [DictArticleField!]!
  getArticles(
    filter: [DictArticleFieldCondition!]!
    pageNumber: Int!
    pageSize: Int!
  ): [DictArticle!]!
  countArticles(filter: [DictArticleFieldCondition!]!): Int!
  getArticle(articleId: ArticleIdInput!): DictArticle!
}

type QueryRoot {
  listDicts: [DictId!]!
  uniDict(dictId: DictIdInput!): QueryDict!
  article(userId: UserId!, expertiseId: ExpertiseIdInput!): Expertise!
  report(userId: UserId!, expertiseId: ExpertiseIdInput!): ExpertiseReport!
  accessRequestsOut(userId: UserId!): [OutgoingAccessRequest!]!
  accessRequestsIn(userId: UserId!): [IncomingAccessRequest!]!
  userInfo(userId: UserId!): UserInfo!
}

type SubscriptionRoot {
  checkExpertises: [String!]!
  accessQueries: [IncomingAccessRequest!]!
}

scalar UserId

type UserInfo {
  firstName: String!
  middleName: String!
  lastName: String!
  position: String!
  country: String!
  region: String!
  district: String!
  organization: String!
}

```

Additional rest query:

```
/uniDictFile?dictId={}&articleId={}&fileId={}
```