Skip to content

Commit c2d9386

Browse files
committed
add jsonschemas
1 parent e278a96 commit c2d9386

17 files changed

+409
-0
lines changed

jsonschemas/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Stream offers the ability to import data for both the **[Chat](https://getstream.io/chat/docs/javascript/import/)** and **[Feeds](https://getstream.io/activity-feeds/docs/javascript/importing_data_feeds/)** products.
2+
3+
To simplify data generation and ensure it conforms to the expected format, we provide **JSON Schema** files that can be used to validate the data before import.
4+
5+
There are many **[JSON Schema validators](https://json-schema.org/tools?query=&sortBy=name&sortOrder=ascending&groupBy=toolingTypes&licenses=&languages=&drafts=&toolingTypes=&environments=&showObsolete=false&supportsBowtie=false#validator)** available for different programming languages that you can use to validate your data.
6+
7+
For more information, please refer to the **[JSON Schema documentation](https://json-schema.org/docs)**.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "attachment.schema.json",
4+
"type": "object",
5+
"additionalProperties": false,
6+
"properties": {
7+
"type": { "type": "string" },
8+
"image_url": { "type": "string", "format": "uri", "pattern": "^https://", "description": "Must be HTTPS and accessible" },
9+
"thumb_url": { "type": "string", "format": "uri", "pattern": "^https://", "description": "Must be HTTPS and accessible" },
10+
"asset_url": { "type": "string", "format": "uri", "pattern": "^https://", "description": "Must be HTTPS and accessible" },
11+
"migrate_resources": { "type": "boolean" }
12+
}
13+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "channel.schema.json",
4+
"type": "object",
5+
"required": ["type", "created_by"],
6+
"properties": {
7+
"id": { "type": "string", "pattern": "^[\\w-]*$", "maxLength": 64 },
8+
"member_ids": { "type": "array", "items": { "type": "string" }, "minItems": 1 },
9+
"type": { "type": "string", "pattern": "^[\\w-]*$", "maxLength": 64 },
10+
"created_by": { "type": "string" },
11+
"team": { "type": "string" },
12+
"disabled": { "type": "boolean" },
13+
"frozen": { "type": "boolean" },
14+
"truncated_at": { "type": "string", "format": "date-time" },
15+
"created_at": { "type": "string", "format": "date-time" },
16+
"updated_at": { "type": "string", "format": "date-time" }
17+
},
18+
"anyOf": [
19+
{ "required": ["id"], "not": { "required": ["member_ids"] } },
20+
{ "required": ["member_ids"], "not": { "required": ["id"] } }
21+
]
22+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "channel_member.schema.json",
4+
"type": "object",
5+
"required": ["user_id", "channel_type"],
6+
"properties": {
7+
"user_id": { "type": "string" },
8+
"channel_type": { "type": "string" },
9+
"channel_id": { "type": "string" },
10+
"channel_member_ids": { "type": "array", "items": { "type": "string" }, "minItems": 1 },
11+
"channel_role": { "type": "string", "description": "Valid channel role; defaults to channel_member" },
12+
"invited": { "type": "boolean" },
13+
"invite_accepted_at": { "type": "string", "format": "date-time" },
14+
"invite_rejected_at": { "type": "string", "format": "date-time" },
15+
"hide_channel": { "type": "boolean" },
16+
"hide_messages_before": { "type": "string", "format": "date-time" },
17+
"last_read": { "type": "string", "format": "date-time" },
18+
"archived_at": { "type": "string", "format": "date-time" },
19+
"created_at": { "type": "string", "format": "date-time" }
20+
},
21+
"anyOf": [
22+
{ "required": ["channel_id"], "not": { "required": ["channel_member_ids"] } },
23+
{ "required": ["channel_member_ids"], "not": { "required": ["channel_id"] } }
24+
]
25+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "device.schema.json",
4+
"type": "object",
5+
"additionalProperties": false,
6+
"required": ["id", "user_id", "push_provider_type"],
7+
"properties": {
8+
"id": { "type": "string", "maxLength": 255 },
9+
"user_id": { "type": "string", "maxLength": 255 },
10+
"push_provider_type": { "type": "string", "enum": ["firebase", "apn", "huawei", "xiaomi"] },
11+
"push_provider_name": { "type": "string" },
12+
"created_at": { "type": "string", "format": "date-time" }
13+
}
14+
}

jsonschemas/chat/item.schema.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "item.schema.json",
4+
"type": "object",
5+
"additionalProperties": false,
6+
"required": ["type", "data"],
7+
"properties": {
8+
"type": { "type": "string", "enum": ["user", "device", "channel", "channel_member", "message", "reaction"] },
9+
"data": {
10+
"anyOf": [
11+
{ "$ref": "user.schema.json" },
12+
{ "$ref": "device.schema.json" },
13+
{ "$ref": "channel.schema.json" },
14+
{ "$ref": "channel_member.schema.json" },
15+
{ "$ref": "message.schema.json" },
16+
{ "$ref": "reaction.schema.json" }
17+
]
18+
}
19+
}
20+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "message.schema.json",
4+
"type": "object",
5+
"required": ["id", "channel_type", "user"],
6+
"properties": {
7+
"id": { "type": "string", "minLength": 1 },
8+
"parent_id": { "type": "string" },
9+
"channel_type": { "type": "string" },
10+
"channel_id": { "type": "string" },
11+
"channel_member_ids": { "type": "array", "items": { "type": "string" }, "minItems": 1 },
12+
"text": { "type": "string" },
13+
"html": { "type": "string" },
14+
"attachments": { "type": "array", "items": { "$ref": "attachment.schema.json" }, "maxItems": 30 },
15+
"user": { "type": "string" },
16+
"type": { "type": "string", "enum": ["", "regular", "deleted", "system", "reply"], "default": "regular" },
17+
"show_in_channel": { "type": "boolean" },
18+
"created_at": { "type": "string", "format": "date-time" },
19+
"updated_at": { "type": "string", "format": "date-time" },
20+
"deleted_at": { "type": "string", "format": "date-time" },
21+
"mentioned_users_ids": { "type": "array", "items": { "type": "string" } },
22+
"quoted_message_id": { "type": "string" },
23+
"pinned_at": { "type": "string", "format": "date-time" },
24+
"pinned_by_id": { "type": "string" },
25+
"pin_expires": { "type": "string", "format": "date-time" }
26+
},
27+
"anyOf": [
28+
{ "required": ["channel_id"], "not": { "required": ["channel_member_ids"] } },
29+
{ "required": ["channel_member_ids"], "not": { "required": ["channel_id"] } }
30+
],
31+
"allOf": [
32+
{ "if": { "properties": { "type": { "const": "reply" } }, "required": ["type"] }, "then": { "required": ["parent_id"] } },
33+
{ "if": { "properties": { "type": { "const": "deleted" } }, "required": ["type"] }, "then": { "required": ["deleted_at"] } },
34+
{ "if": { "properties": { "deleted_at": { "type": "string" } }, "required": ["deleted_at"] }, "then": { "properties": { "type": { "enum": ["deleted"] } } } },
35+
{ "if": { "properties": { "pinned_by_id": { "type": "string" } }, "required": ["pinned_by_id"] }, "then": { "required": ["pinned_at"] } },
36+
{ "if": { "properties": { "pinned_at": { "type": "string" } }, "required": ["pinned_at"] }, "then": { "required": ["pinned_by_id"] } },
37+
{ "if": { "properties": { "pin_expires": { "type": "string" } }, "required": ["pin_expires"] }, "then": { "required": ["pinned_at", "pinned_by_id"] } }
38+
]
39+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "reaction.schema.json",
4+
"type": "object",
5+
"required": ["message_id", "type", "user_id", "created_at"],
6+
"properties": {
7+
"message_id": { "type": "string" },
8+
"type": { "type": "string" },
9+
"user_id": { "type": "string" },
10+
"created_at": { "type": "string", "format": "date-time" }
11+
}
12+
}

jsonschemas/chat/user.schema.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "user.schema.json",
4+
"type": "object",
5+
"required": ["id"],
6+
"properties": {
7+
"id": { "type": "string", "maxLength": 255, "pattern": "^[@\\w-]*$" },
8+
"role": { "type": "string", "description": "Must be a valid app role" },
9+
"teams": { "type": "array", "items": { "type": "string" } },
10+
"teams_role": {
11+
"type": "object",
12+
"additionalProperties": { "type": "string", "description": "Valid team role" }
13+
},
14+
"language": { "type": "string" },
15+
"blocked_user_ids": { "type": "array", "items": { "type": "string" } },
16+
"blocked_by_user_ids": { "type": "array", "items": { "type": "string" } },
17+
"invisible": { "type": "boolean" },
18+
"deactivated_at": { "type": "string", "format": "date-time" },
19+
"deleted_at": { "type": "string", "format": "date-time" },
20+
"created_at": { "type": "string", "format": "date-time" },
21+
"updated_at": { "type": "string", "format": "date-time" },
22+
"channel_mutes": { "type": "array", "items": { "type": "string" } },
23+
"user_mutes": { "type": "array", "items": { "type": "string" } }
24+
}
25+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "activity.schema.json",
4+
"type": "object",
5+
"properties": {
6+
"id": { "type": "string" },
7+
"type": { "type": "string" },
8+
"user_id": { "type": "string" },
9+
"fids": {
10+
"type": "array",
11+
"items": { "type": "string" }
12+
},
13+
"text": { "type": "string" },
14+
"attachments": {
15+
"type": "array",
16+
"items": {
17+
"type": "object",
18+
"properties": {
19+
"type": { "type": "string" },
20+
"image_url": { "type": "string" },
21+
"thumb_url": { "type": "string" },
22+
"asset_url": { "type": "string" },
23+
"migrate_resources": { "type": "boolean" },
24+
"custom": { "type": "object" }
25+
}
26+
}
27+
},
28+
"visibility": { "type": "string" },
29+
"visibility_tag": { "type": "string" },
30+
"location": {
31+
"type": "object",
32+
"properties": {
33+
"lat": { "type": "number" },
34+
"lng": { "type": "number" }
35+
}
36+
},
37+
"expires_at": { "type": "string", "format": "date-time" },
38+
"mentioned_user_ids": {
39+
"type": "array",
40+
"items": { "type": "string" }
41+
},
42+
"parent_id": { "type": "string" },
43+
"poll_id": { "type": "string" },
44+
"custom": { "type": "object" },
45+
"created_at": { "type": "string", "format": "date-time" },
46+
"updated_at": { "type": "string", "format": "date-time" },
47+
"edited_at": { "type": "string", "format": "date-time" },
48+
"deleted_at": { "type": "string", "format": "date-time" },
49+
"filter_tags": {
50+
"type": "array",
51+
"items": { "type": "string" }
52+
},
53+
"interest_tags": {
54+
"type": "array",
55+
"items": { "type": "string" }
56+
}
57+
},
58+
"required": ["id", "type", "user_id", "fids"]
59+
}

0 commit comments

Comments
 (0)