From cd0b98c018193330f34205b4dc2c8649467545e9 Mon Sep 17 00:00:00 2001 From: Darko Atanasovski Date: Wed, 22 Apr 2026 11:47:04 +0200 Subject: [PATCH] [FEEDS-0] updated feeds jsonschems --- jsonschemas/feeds/activity.schema.json | 62 +++++++++++++---- jsonschemas/feeds/bookmark.schema.json | 33 +++++++++ jsonschemas/feeds/collection.schema.json | 16 +++-- jsonschemas/feeds/comment.schema.json | 49 +++++++++---- jsonschemas/feeds/feed.schema.json | 25 ++++--- jsonschemas/feeds/feed_group.schema.json | 23 +++--- jsonschemas/feeds/feed_view.schema.json | 17 +++++ jsonschemas/feeds/follow.schema.json | 32 ++++++--- jsonschemas/feeds/item.schema.json | 39 +++++++++++ jsonschemas/feeds/reaction.schema.json | 26 +++++-- jsonschemas/feeds/user.schema.json | 89 ++++++++++++++++++------ 11 files changed, 321 insertions(+), 90 deletions(-) create mode 100644 jsonschemas/feeds/bookmark.schema.json create mode 100644 jsonschemas/feeds/feed_view.schema.json create mode 100644 jsonschemas/feeds/item.schema.json diff --git a/jsonschemas/feeds/activity.schema.json b/jsonschemas/feeds/activity.schema.json index 09250c554..7d1e4c546 100644 --- a/jsonschemas/feeds/activity.schema.json +++ b/jsonschemas/feeds/activity.schema.json @@ -2,13 +2,21 @@ "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "activity.schema.json", "type": "object", + "description": "Activity entity for feeds import.", + "required": ["id", "type", "user_id", "fids"], "properties": { - "id": { "type": "string" }, - "type": { "type": "string" }, - "user_id": { "type": "string" }, + "id": { "type": "string", "minLength": 1 }, + "type": { + "type": "string", + "minLength": 1, + "description": "Activity type, e.g. 'post', 'photo'." + }, + "user_id": { "type": "string", "minLength": 1 }, "fids": { "type": "array", - "items": { "type": "string" } + "items": { "type": "string", "minLength": 1 }, + "minItems": 1, + "description": "List of feed IDs (fids) this activity is posted to." }, "text": { "type": "string" }, "attachments": { @@ -16,17 +24,39 @@ "items": { "type": "object", "properties": { - "type": { "type": "string" }, - "image_url": { "type": "string" }, - "thumb_url": { "type": "string" }, - "asset_url": { "type": "string" }, + "type": { + "type": "string", + "description": "e.g. text, image, audio, video, file, poll." + }, + "image_url": { + "type": "string", + "format": "uri", + "pattern": "^https://" + }, + "thumb_url": { + "type": "string", + "format": "uri", + "pattern": "^https://" + }, + "asset_url": { + "type": "string", + "format": "uri", + "pattern": "^https://" + }, "migrate_resources": { "type": "boolean" }, - "custom": { "type": "object" } + "custom": { "type": "object", "additionalProperties": true } } } }, - "visibility": { "type": "string" }, - "visibility_tag": { "type": "string" }, + "visibility": { + "type": "string", + "enum": ["public", "private", "tag"], + "description": "Defaults to 'public' when empty." + }, + "visibility_tag": { + "type": "string", + "description": "Required semantics when visibility='tag' (enforced at runtime, not in schema)." + }, "location": { "type": "object", "properties": { @@ -41,7 +71,7 @@ }, "parent_id": { "type": "string" }, "poll_id": { "type": "string" }, - "custom": { "type": "object" }, + "custom": { "type": "object", "additionalProperties": true }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" }, "edited_at": { "type": "string", "format": "date-time" }, @@ -53,7 +83,11 @@ "interest_tags": { "type": "array", "items": { "type": "string" } + }, + "collection_refs": { + "type": "array", + "items": { "type": "string" }, + "description": "Collection IDs this activity references." } - }, - "required": ["id", "type", "user_id", "fids"] + } } diff --git a/jsonschemas/feeds/bookmark.schema.json b/jsonschemas/feeds/bookmark.schema.json new file mode 100644 index 000000000..23213f689 --- /dev/null +++ b/jsonschemas/feeds/bookmark.schema.json @@ -0,0 +1,33 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "bookmark.schema.json", + "type": "object", + "description": "Bookmark entity for feeds import. Use 'object_id' (with optional 'object_type'). 'activity_id' is supported for backward compatibility only. See importer/v2/items/bookmark.go.", + "required": ["user_id"], + "properties": { + "user_id": { "type": "string", "minLength": 1 }, + "object_id": { + "type": "string", + "description": "ID of the bookmarked object (activity or comment)." + }, + "object_type": { + "type": "string", + "enum": ["activity", "comment"], + "default": "activity", + "description": "Type of the bookmarked object. Defaults to 'activity' when empty." + }, + "activity_id": { + "type": "string", + "deprecated": true, + "description": "Deprecated: use 'object_id'. If 'object_id' is empty, 'activity_id' is copied over for backward compatibility." + }, + "folder_id": { "type": "string" }, + "custom": { "type": "object", "additionalProperties": true }, + "created_at": { "type": "string", "format": "date-time" }, + "updated_at": { "type": "string", "format": "date-time" } + }, + "anyOf": [ + { "required": ["object_id"] }, + { "required": ["activity_id"] } + ] +} diff --git a/jsonschemas/feeds/collection.schema.json b/jsonschemas/feeds/collection.schema.json index 17a3faaaa..30ffc538a 100644 --- a/jsonschemas/feeds/collection.schema.json +++ b/jsonschemas/feeds/collection.schema.json @@ -2,14 +2,20 @@ "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "collection.schema.json", "type": "object", + "description": "Collection entity for feeds import.", + "required": ["name", "id", "custom"], "properties": { - "name": { "type": "string" }, - "id": { "type": "string" }, + "name": { "type": "string", "minLength": 1 }, + "id": { "type": "string", "minLength": 1 }, "user_id": { "type": "string" }, - "custom": { "type": "object" }, + "custom": { + "type": "object", + "minProperties": 1, + "additionalProperties": true, + "description": "Must contain at least one key." + }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" }, "deleted_at": { "type": "string", "format": "date-time" } - }, - "required": ["name", "id"] + } } diff --git a/jsonschemas/feeds/comment.schema.json b/jsonschemas/feeds/comment.schema.json index 491a27889..357ac7d3c 100644 --- a/jsonschemas/feeds/comment.schema.json +++ b/jsonschemas/feeds/comment.schema.json @@ -2,16 +2,26 @@ "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "comment.schema.json", "type": "object", + "description": "Comment entity for feeds import.", + "required": ["id", "object_type", "object_id", "user_id", "text"], "properties": { - "id": { "type": "string" }, - "object_type": { "type": "string", "enum": ["activity"] }, - "object_id": { "type": "string" }, - "user_id": { "type": "string" }, - "parent_id": { "type": "string" }, - "text": { "type": "string" }, + "id": { "type": "string", "minLength": 1 }, + "object_type": { + "type": "string", + "enum": ["activity"], + "description": "Currently only 'activity' is supported for imported comments." + }, + "object_id": { "type": "string", "minLength": 1 }, + "user_id": { "type": "string", "minLength": 1 }, + "parent_id": { + "type": ["string", "null"], + "description": "ID of the parent comment when this is a reply." + }, + "text": { "type": "string", "minLength": 1 }, "status": { "type": "string", - "enum": ["active", "deleted", "removed", "hidden"] + "enum": ["active", "deleted", "removed", "hidden"], + "default": "active" }, "attachments": { "type": "array", @@ -19,11 +29,23 @@ "type": "object", "properties": { "type": { "type": "string" }, - "image_url": { "type": "string" }, - "thumb_url": { "type": "string" }, - "asset_url": { "type": "string" }, + "image_url": { + "type": "string", + "format": "uri", + "pattern": "^https://" + }, + "thumb_url": { + "type": "string", + "format": "uri", + "pattern": "^https://" + }, + "asset_url": { + "type": "string", + "format": "uri", + "pattern": "^https://" + }, "migrate_resources": { "type": "boolean" }, - "custom": { "type": "object" } + "custom": { "type": "object", "additionalProperties": true } } } }, @@ -31,10 +53,9 @@ "type": "array", "items": { "type": "string" } }, - "custom": { "type": "object" }, + "custom": { "type": "object", "additionalProperties": true }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" }, "deleted_at": { "type": "string", "format": "date-time" } - }, - "required": ["id", "object_type", "object_id", "user_id", "text"] + } } diff --git a/jsonschemas/feeds/feed.schema.json b/jsonschemas/feeds/feed.schema.json index 3df4a0e21..d176dfe66 100644 --- a/jsonschemas/feeds/feed.schema.json +++ b/jsonschemas/feeds/feed.schema.json @@ -2,23 +2,32 @@ "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "feed.schema.json", "type": "object", + "description": "Feed entity for feeds import.", + "required": ["group_id", "id", "fid", "created_by_id"], "properties": { - "group_id": { "type": "string" }, - "id": { "type": "string" }, - "fid": { "type": "string" }, + "group_id": { "type": "string", "minLength": 1 }, + "id": { "type": "string", "minLength": 1 }, + "fid": { + "type": "string", + "minLength": 1, + "description": "Fully-qualified feed id, typically '{group_id}:{id}'." + }, "name": { "type": "string" }, "description": { "type": "string" }, - "custom": { "type": "object" }, + "custom": { "type": "object", "additionalProperties": true }, "filter_tags": { "type": "array", "items": { "type": "string" } }, - "visibility": { "type": "string" }, - "created_by_id": { "type": "string" }, + "visibility": { + "type": "string", + "enum": ["public", "visible", "followers", "members", "private"], + "description": "Defaults to 'visible' when empty." + }, + "created_by_id": { "type": "string", "minLength": 1 }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" }, "deleted_at": { "type": "string", "format": "date-time" }, "last_watched_at": { "type": "string", "format": "date-time" } - }, - "required": ["group_id", "id", "fid", "created_by_id"] + } } diff --git a/jsonschemas/feeds/feed_group.schema.json b/jsonschemas/feeds/feed_group.schema.json index af127f426..73025818a 100644 --- a/jsonschemas/feeds/feed_group.schema.json +++ b/jsonschemas/feeds/feed_group.schema.json @@ -2,27 +2,28 @@ "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "feed_group.schema.json", "type": "object", + "description": "FeedGroup entity for feeds import.", + "required": ["group_id"], "properties": { "id": { "type": "integer" }, - "group_id": { "type": "string" }, + "group_id": { "type": "string", "minLength": 1 }, "app_pk": { "type": "integer" }, "default_view_id": { "type": "string" }, - "default_visibility": { "type": "string" }, + "default_visibility": { + "type": "string", + "enum": ["", "public", "visible", "followers", "members", "private"], + "description": "Default feed visibility for feeds in this group. Falls back to the global default when empty." + }, "last_feed_get_at": { "type": ["string", "null"], "format": "date-time" }, "notification": { "type": "object", "additionalProperties": true }, "stories": { "type": "object", "additionalProperties": true }, - "activity_processors": { - "type": "array" - }, - "activity_selectors": { - "type": "array" - }, + "activity_processors": { "type": "array" }, + "activity_selectors": { "type": "array" }, "ranking": { "type": "object", "additionalProperties": true }, "aggregation": { "type": "object", "additionalProperties": true }, "aggregation_version": { "type": "integer" }, "push_notification": { "type": "object", "additionalProperties": true }, "created_at": { "type": "string", "format": "date-time" }, - "custom": { "type": "object" } - }, - "required": ["group_id", "activity_selectors"] + "custom": { "type": "object", "additionalProperties": true } + } } diff --git a/jsonschemas/feeds/feed_view.schema.json b/jsonschemas/feeds/feed_view.schema.json new file mode 100644 index 000000000..14a1ad64b --- /dev/null +++ b/jsonschemas/feeds/feed_view.schema.json @@ -0,0 +1,17 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "feed_view.schema.json", + "type": "object", + "description": "FeedView entity for feeds import.", + "required": ["view_id"], + "properties": { + "view_id": { "type": "string", "minLength": 1 }, + "app_pk": { "type": "integer" }, + "activity_selectors": { "type": "array" }, + "ranking": { "type": "object", "additionalProperties": true }, + "aggregation": { "type": "object", "additionalProperties": true }, + "aggregation_version": { "type": "integer" }, + "last_feed_get_at": { "type": ["string", "null"], "format": "date-time" }, + "created_at": { "type": "string", "format": "date-time" } + } +} diff --git a/jsonschemas/feeds/follow.schema.json b/jsonschemas/feeds/follow.schema.json index 0d3e628d5..07d6bf36e 100644 --- a/jsonschemas/feeds/follow.schema.json +++ b/jsonschemas/feeds/follow.schema.json @@ -2,25 +2,37 @@ "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "follow.schema.json", "type": "object", + "description": "Follow entity for feeds import. 'source_fid' and 'target_fid' must differ (enforced at runtime).", + "required": ["source_fid", "target_fid"], "properties": { - "source_fid": { "type": "string" }, - "target_fid": { "type": "string" }, + "source_fid": { "type": "string", "minLength": 1 }, + "target_fid": { "type": "string", "minLength": 1 }, "status": { "type": "string", - "enum": ["accepted", "pending", "rejected"] + "enum": ["accepted", "pending", "rejected"], + "default": "accepted" }, "push_preference": { "type": "string", - "enum": ["all", "none"] + "enum": ["all", "none"], + "default": "none" }, - "custom": { "type": "object" }, + "custom": { "type": "object", "additionalProperties": true }, "request_accepted_at": { "type": "string", "format": "date-time" }, "request_rejected_at": { "type": "string", "format": "date-time" }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" }, - "source_created_by_id": { "type": "string" }, - "target_created_by_id": { "type": "string" }, - "follower_role": { "type": "string" } - }, - "required": ["source", "target"] + "source_created_by_id": { + "type": "string", + "description": "User ID of the creator of the source feed." + }, + "target_created_by_id": { + "type": "string", + "description": "User ID of the creator of the target feed." + }, + "follower_role": { + "type": "string", + "description": "Role assigned to the follower. Defaults to the 'feed_follower' role when empty." + } + } } diff --git a/jsonschemas/feeds/item.schema.json b/jsonschemas/feeds/item.schema.json new file mode 100644 index 000000000..9c31e3c10 --- /dev/null +++ b/jsonschemas/feeds/item.schema.json @@ -0,0 +1,39 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "item.schema.json", + "type": "object", + "description": "Envelope for a single JSONL line in a feeds import file. The 'type' field discriminates the payload in 'data'.", + "additionalProperties": false, + "required": ["type", "data"], + "properties": { + "type": { + "type": "string", + "enum": [ + "user", + "feed", + "feed_group", + "feed_view", + "activity", + "comment", + "reaction", + "bookmark", + "follow", + "collection" + ] + }, + "data": { + "anyOf": [ + { "$ref": "user.schema.json" }, + { "$ref": "feed.schema.json" }, + { "$ref": "feed_group.schema.json" }, + { "$ref": "feed_view.schema.json" }, + { "$ref": "activity.schema.json" }, + { "$ref": "comment.schema.json" }, + { "$ref": "reaction.schema.json" }, + { "$ref": "bookmark.schema.json" }, + { "$ref": "follow.schema.json" }, + { "$ref": "collection.schema.json" } + ] + } + } +} diff --git a/jsonschemas/feeds/reaction.schema.json b/jsonschemas/feeds/reaction.schema.json index ea0b96790..6c836d528 100644 --- a/jsonschemas/feeds/reaction.schema.json +++ b/jsonschemas/feeds/reaction.schema.json @@ -2,14 +2,26 @@ "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "reaction.schema.json", "type": "object", + "description": "Feeds reaction entity for import.", + "required": ["user_id", "activity_id", "type"], "properties": { - "user_id": { "type": "string" }, - "activity_id": { "type": "string" }, - "comment_id": { "type": "string" }, - "type": { "type": "string" }, - "custom": { "type": "object" }, + "user_id": { "type": "string", "minLength": 1 }, + "activity_id": { + "type": "string", + "minLength": 1, + "description": "Activity this reaction targets. Required even when 'comment_id' is set." + }, + "comment_id": { + "type": "string", + "description": "Set when reacting to a comment on the activity." + }, + "type": { + "type": "string", + "minLength": 1, + "description": "Reaction type, e.g. 'like', 'upvote'." + }, + "custom": { "type": "object", "additionalProperties": true }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" } - }, - "required": ["user_id", "activity_id", "type"] + } } diff --git a/jsonschemas/feeds/user.schema.json b/jsonschemas/feeds/user.schema.json index 9d54f9d01..898f6924b 100644 --- a/jsonschemas/feeds/user.schema.json +++ b/jsonschemas/feeds/user.schema.json @@ -1,24 +1,71 @@ { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "user.schema.json", - "type": "object", - "required": ["id"], - "properties": { - "id": { "type": "string", "maxLength": 255, "pattern": "^[@\\w-]*$" }, - "role": { "type": "string", "description": "Must be a valid app role" }, - "teams": { "type": "array", "items": { "type": "string" } }, - "teams_role": { - "type": "object", - "additionalProperties": { "type": "string", "description": "Valid team role" } - }, - "language": { "type": "string" }, - "blocked_user_ids": { "type": "array", "items": { "type": "string" } }, - "blocked_by_user_ids": { "type": "array", "items": { "type": "string" } }, - "invisible": { "type": "boolean" }, - "deactivated_at": { "type": "string", "format": "date-time" }, - "deleted_at": { "type": "string", "format": "date-time" }, - "created_at": { "type": "string", "format": "date-time" }, - "channel_mutes": { "type": "array", "items": { "type": "string" } }, - "user_mutes": { "type": "array", "items": { "type": "string" } } + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "user.schema.json", + "type": "object", + "description": "User entity for feeds import.", + "required": ["id"], + "properties": { + "id": { + "type": "string", + "minLength": 1, + "maxLength": 255, + "pattern": "^[@\\w .-]*$" + }, + "role": { + "type": "string", + "description": "Must be a valid app role. Defaults to 'user' when empty." + }, + "teams": { "type": "array", "items": { "type": "string" } }, + "teams_role": { + "type": "object", + "additionalProperties": { + "type": "string", + "description": "Valid team role" + } + }, + "language": { "type": "string" }, + "blocked_user_ids": { "type": "array", "items": { "type": "string" } }, + "invisible": { "type": "boolean" }, + "custom": { "type": "object", "additionalProperties": true }, + "deactivated_at": { "type": "string", "format": "date-time" }, + "deleted_at": { "type": "string", "format": "date-time" }, + "created_at": { "type": "string", "format": "date-time" }, + "updated_at": { "type": "string", "format": "date-time" }, + "channel_mutes": { "type": "array", "items": { "type": "string" } }, + "user_mutes": { "type": "array", "items": { "type": "string" } }, + "push_preferences": { + "type": "object", + "description": "User push preferences.", + "additionalProperties": false, + "properties": { + "chat_level": { "type": "string", "enum": ["all", "none", "mentions"] }, + "disabled_until": { "type": "string", "format": "date-time" } + } + }, + "privacy_settings": { + "type": "object", + "description": "User privacy settings.", + "additionalProperties": false, + "properties": { + "typing_indicators": { + "type": "object", + "additionalProperties": false, + "required": ["enabled"], + "properties": { "enabled": { "type": "boolean" } } + }, + "read_receipts": { + "type": "object", + "additionalProperties": false, + "required": ["enabled"], + "properties": { "enabled": { "type": "boolean" } } + }, + "delivery_receipts": { + "type": "object", + "additionalProperties": false, + "required": ["enabled"], + "properties": { "enabled": { "type": "boolean" } } + } + } } + } }