From fd84d681cd142a4f3480b6fd937da18519a1a80f Mon Sep 17 00:00:00 2001 From: Wei Zhang Date: Tue, 14 Jan 2025 17:46:48 +0800 Subject: [PATCH] chore: page title and summary could be empty Signed-off-by: Wei Zhang --- .../migrations/0042_page-section.up.sql | 4 +- ee/tabby-db/schema.sqlite | Bin 245760 -> 245760 bytes ee/tabby-db/schema/schema.sql | 21 + ee/tabby-db/schema/schema.svg | 1276 +++++++++-------- ee/tabby-db/src/pages.rs | 4 +- ee/tabby-schema/graphql/schema.graphql | 60 + ee/tabby-schema/src/schema/page/types.rs | 4 +- 7 files changed, 763 insertions(+), 606 deletions(-) diff --git a/ee/tabby-db/migrations/0042_page-section.up.sql b/ee/tabby-db/migrations/0042_page-section.up.sql index e173f03e754b..faac8e45b267 100644 --- a/ee/tabby-db/migrations/0042_page-section.up.sql +++ b/ee/tabby-db/migrations/0042_page-section.up.sql @@ -4,8 +4,8 @@ CREATE TABLE pages( -- The user who created the page author_id INTEGER NOT NULL, - title TEXT NOT NULL, - summary TEXT NOT NULL, + title TEXT, + summary TEXT, created_at TIMESTAMP NOT NULL DEFAULT (DATETIME('now')), updated_at TIMESTAMP NOT NULL DEFAULT (DATETIME('now')), diff --git a/ee/tabby-db/schema.sqlite b/ee/tabby-db/schema.sqlite index 9fcdebecf232337416920f27d2f62b15687f4ccf..f6d9acf109e64388ce2aba47056587841b0a60a7 100644 GIT binary patch delta 236 zcmZo@;BRQ)pCBzL$iTp01H>>8Hc`izQE+3zYJNuRW*&id9sx!mX4=jpz|8KzTh0^4 z2UX3uVsoNG2jlh?fy_@i7|(3)i()>(xZNd&S%Hb$s+rB5U0ht8u{C>oejM`}AssFS zASf=)%}p$-R0wg62-$8Q&wS8elLL!@2qXUz1|R~NYX!t$db6NG5C8Nf^O@ysO%x0) ztxOE9Ow6T1=dWDkH_f}qUF@Qm_eGTxt9w4JJUe~Pgc&PSE&LZSUB11PG5M#B^F%9o RtLTL>*_?H{%Qi3z0082kLO%ci delta 244 zcmZo@;BRQ)pCB#B&%nT71H>>8G*QQxk$+>tYJNtmW*&id9sx!mX4=jpz|8Kzo66(D zrv*{UxMFjnLI>ma6@ko8IT&|s?~7tS!MHsmhMA9v+qzl8on2g9oUx66dSe{(n&~pJ z%=|pXrMbC@MU@I6t`Q;AALKE0Pv;6|wqI7jB(P`#2u)kS%+CpOi!~72Y!)==;h(-_ zJ+r*6v4WwQm5H&Hky*whFw2)41)F9&Pr#^x#GOW|7OR fxdoy^zpwI~X?>f&P;lA9O%5yq+gUa+|KSG!eMn1C diff --git a/ee/tabby-db/schema/schema.sql b/ee/tabby-db/schema/schema.sql index e996b5dc5f2e..78e20c951681 100644 --- a/ee/tabby-db/schema/schema.sql +++ b/ee/tabby-db/schema/schema.sql @@ -261,3 +261,24 @@ CREATE TABLE ldap_credential( created_at TIMESTAMP NOT NULL DEFAULT(DATETIME('now')), updated_at TIMESTAMP NOT NULL DEFAULT(DATETIME('now')) ); +CREATE TABLE pages( + id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + -- The user who created the page + author_id INTEGER NOT NULL, + title TEXT, + summary TEXT, + created_at TIMESTAMP NOT NULL DEFAULT(DATETIME('now')), + updated_at TIMESTAMP NOT NULL DEFAULT(DATETIME('now')), + FOREIGN KEY(author_id) REFERENCES users(id) ON DELETE CASCADE +); +CREATE TABLE page_sections( + id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + page_id INTEGER NOT NULL, + position INTEGER NOT NULL, + title TEXT NOT NULL, + content TEXT NOT NULL, + created_at TIMESTAMP NOT NULL DEFAULT(DATETIME('now')), + updated_at TIMESTAMP NOT NULL DEFAULT(DATETIME('now')), + FOREIGN KEY(page_id) REFERENCES pages(id) ON DELETE CASCADE, + CONSTRAINT `page_id_position` UNIQUE(page_id, position) +); diff --git a/ee/tabby-db/schema/schema.svg b/ee/tabby-db/schema/schema.svg index d8689004dbe8..41f09841c62c 100644 --- a/ee/tabby-db/schema/schema.svg +++ b/ee/tabby-db/schema/schema.svg @@ -4,11 +4,11 @@ - - + + structs - + _sqlx_migrations @@ -122,265 +122,341 @@ invitations - -invitations - -🔑 - -id - -  - -email - -  - -code - -  - -created_at + +invitations + +🔑 + +id + +  + +email + +  + +code + +  + +created_at job_runs - -job_runs - -🔑 - -id - -  - -job - -  - -start_ts - -  - -end_ts - -  - -exit_code - -  - -stdout - -  - -stderr - -  - -created_at - -  - -updated_at - -  - -command - -  - -started_at + +job_runs + +🔑 + +id + +  + +job + +  + +start_ts + +  + +end_ts + +  + +exit_code + +  + +stdout + +  + +stderr + +  + +created_at + +  + +updated_at + +  + +command + +  + +started_at ldap_credential - -ldap_credential - -🔑 - -id - -  - -host - -  - -port - -  - -bind_dn - -  - -bind_password - -  - -base_dn - -  - -user_filter - -  - -encryption - -  - -skip_tls_verify - -  - -email_attribute - -  - -name_attribute - -  - -created_at - -  - -updated_at + +ldap_credential + +🔑 + +id + +  + +host + +  + +port + +  + +bind_dn + +  + +bind_password + +  + +base_dn + +  + +user_filter + +  + +encryption + +  + +skip_tls_verify + +  + +email_attribute + +  + +name_attribute + +  + +created_at + +  + +updated_at notifications - -notifications - -🔑 - -id - -  - -created_at - -  - -updated_at - -  - -recipient - -  - -content + +notifications + +🔑 + +id + +  + +created_at + +  + +updated_at + +  + +recipient + +  + +content oauth_credential - -oauth_credential - -🔑 - -id - -  - -provider - -  - -client_id - -  - -client_secret - -  - -created_at - -  - -updated_at - - + +oauth_credential + +🔑 + +id + +  + +provider + +  + +client_id + +  + +client_secret + +  + +created_at + +  + +updated_at + + -password_reset - -password_reset - -🔑 - -id - -  - -user_id - -  - -code - -  - -created_at +page_sections + +page_sections + +🔑 + +id + +  + +page_id + +  + +position + +  + +title + +  + +content + +  + +created_at + +  + +updated_at + + + +pages + +pages + +🔑 + +id + +  + +author_id + +  + +title + +  + +summary + +  + +created_at + +  + +updated_at + + + +page_sections:e->pages:w + + - + users - -users - -🔑 - -id - -  - -email - -  - -is_admin - -  - -created_at - -  - -updated_at - -  - -auth_token - -  - -active - -  - -password_encrypted - -  - -avatar - -  - -name + +users + +🔑 + +id + +  + +email + +  + +is_admin + +  + +created_at + +  + +updated_at + +  + +auth_token + +  + +active + +  + +password_encrypted + +  + +avatar + +  + +name + + + +pages:e->users:w + + + + + +password_reset + +password_reset + +🔑 + +id + +  + +user_id + +  + +code + +  + +created_at - + password_reset:e->users:w - - + + - + provided_repositories provided_repositories @@ -418,440 +494,440 @@ updated_at - + provided_repositories:e->integrations:w - + read_notifications - -read_notifications - -🔑 - -id - -  - -user_id - -  - -notification_id - -  - -created_at - -  - -updated_at + +read_notifications + +🔑 + +id + +  + +user_id + +  + +notification_id + +  + +created_at + +  + +updated_at - + read_notifications:e->notifications:w - - + + - + read_notifications:e->users:w - - + + - + refresh_tokens - -refresh_tokens - -🔑 - -id - -  - -user_id - -  - -token - -  - -expires_at - -  - -created_at + +refresh_tokens + +🔑 + +id + +  + +user_id + +  + +token + +  + +expires_at + +  + +created_at - + refresh_tokens:e->users:w - - + + - + registration_token - -registration_token - -🔑 - -id - -  - -token - -  - -created_at - -  - -updated_at + +registration_token + +🔑 + +id + +  + +token + +  + +created_at + +  + +updated_at - + repositories - -repositories - -🔑 - -id - -  - -name - -  - -git_url + +repositories + +🔑 + +id + +  + +name + +  + +git_url - + server_setting - -server_setting - -🔑 - -id - -  - -security_allowed_register_domain_list - -  - -security_disable_client_side_telemetry - -  - -network_external_url - -  - -billing_enterprise_license + +server_setting + +🔑 + +id + +  + +security_allowed_register_domain_list + +  + +security_disable_client_side_telemetry + +  + +network_external_url + +  + +billing_enterprise_license - + source_id_read_access_policies - -source_id_read_access_policies - -🔑 - -id - -  - -source_id - -  - -user_group_id - -  - -created_at - -  - -updated_at + +source_id_read_access_policies + +🔑 + +id + +  + +source_id + +  + +user_group_id + +  + +created_at + +  + +updated_at - + user_groups - -user_groups - -🔑 - -id - -  - -name - -  - -created_at - -  - -updated_at + +user_groups + +🔑 + +id + +  + +name + +  + +created_at + +  + +updated_at - + source_id_read_access_policies:e->user_groups:w - - + + - + thread_messages - -thread_messages - -🔑 - -id - -  - -thread_id - -  - -role - -  - -content - -  - -code_attachments - -  - -client_code_attachments - -  - -doc_attachments - -  - -created_at - -  - -updated_at - -  - -code_source_id + +thread_messages + +🔑 + +id + +  + +thread_id + +  + +role + +  + +content + +  + +code_attachments + +  + +client_code_attachments + +  + +doc_attachments + +  + +created_at + +  + +updated_at + +  + +code_source_id - + threads - -threads - -🔑 - -id - -  - -is_ephemeral - -  - -user_id - -  - -created_at - -  - -updated_at - -  - -relevant_questions + +threads + +🔑 + +id + +  + +is_ephemeral + +  + +user_id + +  + +created_at + +  + +updated_at + +  + +relevant_questions - + thread_messages:e->threads:w - - + + - + threads:e->users:w - - + + - + user_completions - -user_completions - -🔑 - -id - -  - -user_id - -  - -completion_id - -  - -language - -  - -views - -  - -selects - -  - -dismisses - -  - -created_at - -  - -updated_at + +user_completions + +🔑 + +id + +  + +user_id + +  + +completion_id + +  + +language + +  + +views + +  + +selects + +  + +dismisses + +  + +created_at + +  + +updated_at - + user_completions:e->users:w - - + + - + user_events - -user_events - -🔑 - -id - -  - -user_id - -  - -kind - -  - -created_at - -  - -payload + +user_events + +🔑 + +id + +  + +user_id + +  + +kind + +  + +created_at + +  + +payload - + user_events:e->users:w - - + + - + user_group_memberships - -user_group_memberships - -🔑 - -id - -  - -user_id - -  - -user_group_id - -  - -is_group_admin - -  - -created_at - -  - -updated_at + +user_group_memberships + +🔑 + +id + +  + +user_id + +  + +user_group_id + +  + +is_group_admin + +  + +created_at + +  + +updated_at - + user_group_memberships:e->user_groups:w - - + + - + user_group_memberships:e->users:w - - + + - + web_documents - -web_documents - -🔑 - -id - -  - -name - -  - -url - -  - -is_preset - -  - -created_at - -  - -updated_at + +web_documents + +🔑 + +id + +  + +name + +  + +url + +  + +is_preset + +  + +created_at + +  + +updated_at diff --git a/ee/tabby-db/src/pages.rs b/ee/tabby-db/src/pages.rs index 43f1bd3180f3..cb775669580e 100644 --- a/ee/tabby-db/src/pages.rs +++ b/ee/tabby-db/src/pages.rs @@ -9,8 +9,8 @@ use crate::DbConn; pub struct PageDAO { pub id: i64, pub author_id: i64, - pub title: String, - pub summary: String, + pub title: Option, + pub summary: Option, pub created_at: DateTime, pub updated_at: DateTime, } diff --git a/ee/tabby-schema/graphql/schema.graphql b/ee/tabby-schema/graphql/schema.graphql index 80df435749c0..eaa5952d7698 100644 --- a/ee/tabby-schema/graphql/schema.graphql +++ b/ee/tabby-schema/graphql/schema.graphql @@ -180,6 +180,12 @@ input EmailSettingInput { smtpPassword: String } +input GenerateSectionInput { + pageId: ID! + position: Int! + content: String! +} + input MessageAttachmentCodeInput { filepath: String "When start line is `None`, it represents the entire file." startLine: Int @@ -206,6 +212,12 @@ input PasswordResetInput { password2: String! } +input ReorderSectionsInput { + pageId: ID! + id: ID! + position: Int! +} + input RequestInvitationInput { email: String! } @@ -652,6 +664,13 @@ type Mutation { "Turn on persisted status for a thread." setThreadPersisted(threadId: ID!): Boolean! updateThreadMessage(input: UpdateMessageInput!): Boolean! + convertThreadToPage(threadId: ID!): ID! + generatePageTitle(id: ID!): String! + generatePageSummary(id: ID!): String! + deletePage(id: ID!): ID! + generatePageSection(input: GenerateSectionInput!): Section! + reorderPageSections(input: ReorderSectionsInput!): Boolean! + deletePageSection(sectionId: ID!): ID! createCustomDocument(input: CreateCustomDocumentInput!): ID! deleteCustomDocument(id: ID!): Boolean! setPresetDocumentActive(input: SetPresetDocumentActiveInput!): Boolean! @@ -682,6 +701,25 @@ type OAuthCredential { updatedAt: DateTime! } +type Page { + id: ID! + authorId: ID! + title: String! + summary: String! + createdAt: DateTime! + updatedAt: DateTime! +} + +type PageConnection { + edges: [PageEdge!]! + pageInfo: PageInfo! +} + +type PageEdge { + node: Page! + cursor: String! +} + type PageInfo { hasPreviousPage: Boolean! hasNextPage: Boolean! @@ -788,6 +826,8 @@ type Query { Thread is public within an instance, so no need to check for ownership. """ threadMessages(threadId: ID!, after: String, before: String, first: Int, last: Int): MessageConnection! + pages(ids: [ID!], after: String, before: String, first: Int, last: Int): PageConnection! + pageSections(pageId: ID!, after: String, before: String, first: Int, last: Int): SectionConnection! customWebDocuments(ids: [ID!], after: String, before: String, first: Int, last: Int): CustomDocumentConnection! presetWebDocuments(ids: [ID!], after: String, before: String, first: Int, last: Int, isActive: Boolean): PresetDocumentConnection! "List user groups." @@ -834,6 +874,26 @@ type RepositoryGrepOutput { elapsedMs: Int! } +type Section { + id: ID! + pageId: ID! + position: Int! + title: String! + content: String! + createdAt: DateTime! + updatedAt: DateTime! +} + +type SectionConnection { + edges: [SectionEdge!]! + pageInfo: PageInfo! +} + +type SectionEdge { + node: Section! + cursor: String! +} + type SecuritySetting { allowedRegisterDomainList: [String!]! disableClientSideTelemetry: Boolean! diff --git a/ee/tabby-schema/src/schema/page/types.rs b/ee/tabby-schema/src/schema/page/types.rs index f829b2f6295c..789ccc120522 100644 --- a/ee/tabby-schema/src/schema/page/types.rs +++ b/ee/tabby-schema/src/schema/page/types.rs @@ -8,8 +8,8 @@ use crate::{juniper::relay::NodeType, Context}; pub struct Page { pub id: ID, pub author_id: ID, - pub title: String, - pub summary: String, + pub title: Option, + pub summary: Option, pub created_at: DateTime, pub updated_at: DateTime, }