simple-web-app

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit e42a8b9e1c04ccbd1f3f983457156326e1fb2d73
parent ff1226bdec4947327494488f825b5c8e7cb13e54
Author: Silas Brack <silasbrack@gmail.com>
Date:   Sun,  7 Jun 2026 21:29:18 +0200

chore: regenerate types from trailbase schema via quicktype

No manual edits needed — quicktype correctly handles nullable
fields as Option<T> from the JSON schema.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Diffstat:
Mschemas/category.json | 6+++++-
Aschemas/comment.json | 47+++++++++++++++++++++++++++++++++++++++++++++++
Aschemas/story.json | 61+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aschemas/story_category.json | 21+++++++++++++++++++++
Aschemas/user_profile.json | 35+++++++++++++++++++++++++++++++++++
Aschemas/vote.json | 29+++++++++++++++++++++++++++++
Msrc/trailbase_types.rs | 45++++++++++++++++++++++-----------------------
7 files changed, 220 insertions(+), 24 deletions(-)

diff --git a/schemas/category.json b/schemas/category.json @@ -1,10 +1,14 @@ { + "$schema": "https://json-schema.org/draft/2020-12/schema", "properties": { "id": { "type": "integer" }, "name": { - "type": "string" + "type": [ + "null", + "string" + ] } }, "required": [ diff --git a/schemas/comment.json b/schemas/comment.json @@ -0,0 +1,47 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "created_at": { + "type": "string" + }, + "created_by": { + "type": "string" + }, + "depth": { + "type": "integer" + }, + "id": { + "type": "integer" + }, + "parent_id": { + "type": [ + "null", + "integer" + ] + }, + "path": { + "type": "string" + }, + "score": { + "type": "integer" + }, + "story_id": { + "type": "integer" + }, + "text": { + "type": "string" + } + }, + "required": [ + "id", + "story_id", + "path", + "depth", + "text", + "score", + "created_at", + "created_by" + ], + "title": "comment", + "type": "object" +} diff --git a/schemas/story.json b/schemas/story.json @@ -0,0 +1,61 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "author": { + "type": [ + "null", + "string" + ] + }, + "comment_count": { + "type": "integer" + }, + "created_by": { + "type": [ + "null", + "string" + ] + }, + "domain": { + "type": [ + "null", + "string" + ] + }, + "id": { + "type": "integer" + }, + "language": { + "type": "string" + }, + "published": { + "type": "string" + }, + "score": { + "type": "integer" + }, + "text": { + "type": "string" + }, + "title": { + "type": "string" + }, + "url": { + "type": [ + "null", + "string" + ] + } + }, + "required": [ + "id", + "title", + "text", + "published", + "language", + "score", + "comment_count" + ], + "title": "story", + "type": "object" +} diff --git a/schemas/story_category.json b/schemas/story_category.json @@ -0,0 +1,21 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "category_id": { + "type": "integer" + }, + "id": { + "type": "integer" + }, + "news_item_id": { + "type": "integer" + } + }, + "required": [ + "id", + "news_item_id", + "category_id" + ], + "title": "story_category", + "type": "object" +} diff --git a/schemas/user_profile.json b/schemas/user_profile.json @@ -0,0 +1,35 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "about": { + "type": [ + "null", + "string" + ] + }, + "created_at": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "karma": { + "type": "integer" + }, + "user_id": { + "type": "string" + }, + "username": { + "type": "string" + } + }, + "required": [ + "id", + "user_id", + "username", + "karma", + "created_at" + ], + "title": "user_profile", + "type": "object" +} diff --git a/schemas/vote.json b/schemas/vote.json @@ -0,0 +1,29 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "created_at": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "target_id": { + "type": "integer" + }, + "target_type": { + "type": "integer" + }, + "user_id": { + "type": "string" + } + }, + "required": [ + "id", + "user_id", + "target_type", + "target_id", + "created_at" + ], + "title": "vote", + "type": "object" +} diff --git a/src/trailbase_types.rs b/src/trailbase_types.rs @@ -1,53 +1,53 @@ //! Auto-generated types from Trailbase schema. //! Run `./scripts/generate-types.sh` to regenerate. -use serde::{Deserialize, Serialize}; +use serde::{Serialize, Deserialize}; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Story { - pub id: i64, - pub url: Option<String>, - pub title: String, - pub text: String, - pub published: String, pub author: Option<String>, - pub language: String, - pub created_by: Option<String>, - pub score: i64, pub comment_count: i64, + pub created_by: Option<String>, pub domain: Option<String>, + pub id: i64, + pub language: String, + pub published: String, + pub score: i64, + pub text: String, + pub title: String, + pub url: Option<String>, } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Comment { + pub created_at: String, + pub created_by: String, + pub depth: i64, pub id: i64, - pub story_id: i64, pub parent_id: Option<i64>, pub path: String, - pub depth: i64, - pub text: String, pub score: i64, - pub created_at: String, - pub created_by: String, + pub story_id: i64, + pub text: String, } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Vote { + pub created_at: String, pub id: i64, - pub user_id: String, - pub target_type: i64, // 1=story, 2=comment pub target_id: i64, - pub created_at: String, + pub target_type: i64, + pub user_id: String, } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct UserProfile { + pub about: Option<String>, + pub created_at: String, pub id: i64, + pub karma: i64, pub user_id: String, pub username: String, - pub about: Option<String>, - pub karma: i64, - pub created_at: String, } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -57,9 +57,8 @@ pub struct Category { } #[derive(Debug, Clone, Serialize, Deserialize)] -#[allow(dead_code)] pub struct StoryCategory { - pub id: i64, - pub news_item_id: i64, // Still references old column name in DB pub category_id: i64, + pub id: i64, + pub news_item_id: i64, }