mvp
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://sadtech.ir/schemas/operation.schema.json",
|
||||
"title": "Operation",
|
||||
"description": "An operation is a single action that can be performed on the database by sync protocol.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"description": "The unique identifier of the operation.",
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"description": "The type of the operation.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"insert",
|
||||
"update",
|
||||
"delete"
|
||||
]
|
||||
},
|
||||
"device_id": {
|
||||
"description": "The unique identifier of the device that performed the operation.",
|
||||
"type": "string"
|
||||
},
|
||||
"timestamp": {
|
||||
"description": "The timestamp of the operation.",
|
||||
"type": "string",
|
||||
"format": "int64"
|
||||
},
|
||||
"payload": {
|
||||
"description": "The payload of the operation.",
|
||||
"type": "object"
|
||||
},
|
||||
"entity_type": {
|
||||
"description": "The type of the entity that the operation is performed on.",
|
||||
"type": "string"
|
||||
},
|
||||
"entity_id": {
|
||||
"description": "The unique identifier of the entity that the operation is performed on.",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://sadtech.ir/schemas/snapshot.schema.json",
|
||||
"title": "Snapshot",
|
||||
"description": "A snapshot is a complete copy of the database on the server. It is sent to the device when the device's local database is out of sync with the server's database.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"description": "The unique identifier of the snapshot.",
|
||||
"type": "string"
|
||||
},
|
||||
"cursor": {
|
||||
"description": "The cursor is a string that represents the last known state of the database on the device. It is used to determine which operations need to be sent to the device.",
|
||||
"type": "integer"
|
||||
},
|
||||
"data": {
|
||||
"description": "The data is a complete copy of the database on the server. It is sent to the device when the device's local database is out of sync with the server's database.",
|
||||
"type": "object"
|
||||
},
|
||||
"timestamp": {
|
||||
"description": "The timestamp of the snapshot.",
|
||||
"type": "string",
|
||||
"format": "int64"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://sadtech.ir/schemas/sync-request.schema.json",
|
||||
"title": "SyncRequest",
|
||||
"description": "A sync request is a request sent by a device to the server to synchronize its local database with the server's database.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"device_id": {
|
||||
"description": "The unique identifier of the device that is sending the sync request.",
|
||||
"type": "string"
|
||||
},
|
||||
"cursor": {
|
||||
"description": "The cursor is a string that represents the last known state of the database on the device. It is used to determine which operations need to be sent to the device.",
|
||||
"type": "integer"
|
||||
},
|
||||
"operations": {
|
||||
"description": "The operations are the changes that have been made to the database on the device since the last sync. They are sent to the server to be applied to the server's database.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "operation.schema.json"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"device_id",
|
||||
"cursor",
|
||||
"operations"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://sadtech.ir/schemas/sync-response.schema.json",
|
||||
"title": "SyncResponse",
|
||||
"description": "A sync response is a response sent by the server to a device to synchronize its local database with the server's database.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"cursor": {
|
||||
"description": "The cursor is a string that represents the last known state of the database on the device. It is used to determine which operations need to be sent to the device.",
|
||||
"type": "integer"
|
||||
},
|
||||
"operations": {
|
||||
"description": "The operations are the changes that have been made to the database on the device since the last sync. They are sent to the server to be applied to the server's database.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "operation.schema.json"
|
||||
}
|
||||
},
|
||||
"snapshot": {
|
||||
"description": "The snapshot is a complete copy of the database on the server. It is sent to the device when the device's local database is out of sync with the server's database.",
|
||||
"$ref": "snapshot.schema.json"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"cursor",
|
||||
"operations"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user