GuideIntegration appsAPIPOST /api/1/synchronizer/schema

Integration app must provide data schema in advance so Fibery will be able to create approriate types and relations and then be able to maintain them.

It should provide a schema for all requested types. Each type must contain name and id field. In additional there is a reserved field __syncAction that should be added to the schema if delta synchronization with possibility of removing items should be supported.

Request

Request contains:

  • types - an array of selected type ids
  • filter - currently configured filter
  • account - selected account

Request example:

{
    "types": ["pullrequest", "repository"],
    "filter": {
        "owner": "fibery",
        "repositories": ["fibery/core", "fibery/ui"]
    },
    "account": {
        "token": "token"
    }
}

Response

Includes schema for all requested types

Response example:

{
  "repository": {
    "id": {
      "type": "id",
      "name": "Id"
    },
    "name": {
      "type": "text",
      "name": "Name"
    },
    "url": {
      "type": "text",
      "name": "Original URL",
      "subType": "url"
    } 
  },
  "pullrequest": {
    "id": {
      "type": "id",
      "name": "Id"
    },
    "name": {
      "type": "text",
      "name": "Name"
    },
    "repositoryId": {
      "type": "text",
      "name": "Repository Id",
      "relation": {
        "cardinality": "many-to-one",
        "name": "Repository",
        "targetName": "Pull Requests",
        "targetType": "repository",
        "targetFieldId": "id"
      }
    },
    "__syncAction": {
      "type": "text",
      "name": "Sync Action"
    }
  }
}

Schema is JSON object where key is field and value if field description. Field description contains:

fielddescriptiontype
idField idstring
ignoreIs field visible in fields catalogboolean
nameField namestring
descriptionField descriptionstring
readonlyDisable modify field name and typeboolean
typeType of field"id" | "text" | "number" | "date" | "array[text]" | "array[number]" | "array[date]"
relationRelation between typessee relations section
subTypeOptional Fibery sub type"url" | "integer" | "email" | "boolean" | "html" | "md" |

Relations

relation field provides a possibility to create a relation between entities in Fibery. It contains following fields:

fielddescriptiontype
cardinalityType of relation"many-to-one" | "many-to-many"
nameName of the field on source sidestring
targetTypeId of target typestring
targetNameField name of target sidestring
targetFieldIdFind relation by value from fieldstring

Example:

{
  "repository": {
    "id": {
      "type": "id",
      "name": "Id"
    },
    "name": {
      "type": "text",
      "name": "Name"
    },
    "url": {
      "type": "text",
      "name": "Original URL",
      "subType": "url"
    } 
  },
  "pullrequest": {
    "id": {
      "type": "id",
      "name": "Id"
    },
    "name": {
      "type": "text",
      "name": "Name"
    },
    "repositoryId": {
      "type": "text",
      "name": "Repository Id",
      "relation": {
        "cardinality": "many-to-one",
        "name": "Repository",
        "targetName": "Pull Requests",
        "targetType": "repository",
        "targetFieldId": "id"
      }
    }
  }
}

Repository will have following fields (example includes only relation fields):

  • Pull Requests - Array

Pull Request will have following fields:

  • Repository Id - string - this field will be hidden from end user
  • Repository - Repository

Reserved field - __syncAction

Sync action is reserved field that won't be visible for end user. The field is used for delta synchronization when entity should be deleted.