The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
refactor: Send favorite as top level value for user content (#40556)
Luca Forstnere063783f7611
diff --git a/apps/studio/components/interfaces/SQLEditor/SQLEditor.constants.ts b/apps/studio/components/interfaces/SQLEditor/SQLEditor.constants.tsindex bb8d77a0cad..4c52b23d7bf 100644--- a/apps/studio/components/interfaces/SQLEditor/SQLEditor.constants.ts+++ b/apps/studio/components/interfaces/SQLEditor/SQLEditor.constants.ts@@ -7,11 +7,11 @@ export const NEW_SQL_SNIPPET_SKELETON: UserContent<SqlSnippets.Content> = {description: '',type: 'sql',visibility: 'user', // default to user scope+ favorite: false,content: {schema_version: SQL_SNIPPET_SCHEMA_VERSION,content_id: '',sql: 'this is a test',- favorite: false,},}diff --git a/apps/studio/data/content/content-insert-mutation.ts b/apps/studio/data/content/content-insert-mutation.tsindex fcf3c72ccac..ef706e70fe9 100644--- a/apps/studio/data/content/content-insert-mutation.ts+++ b/apps/studio/data/content/content-insert-mutation.ts@@ -9,6 +9,7 @@ import { contentKeys } from './keys'export type InsertContentPayload = Omit<components['schemas']['CreateContentBody'], 'content'> & {content: Content['content']+ favorite?: boolean}export type InsertContentVariables = {@@ -33,6 +34,7 @@ export async function insertContent(visibility: payload.visibility,content: payload.content as any,folder_id: payload.folder_id,+ favorite: payload.favorite,},signal,})diff --git a/apps/studio/data/content/content-upsert-mutation.ts b/apps/studio/data/content/content-upsert-mutation.tsindex d57ea090dd0..ae00ca5607f 100644--- a/apps/studio/data/content/content-upsert-mutation.ts+++ b/apps/studio/data/content/content-upsert-mutation.ts@@ -9,6 +9,7 @@ import { contentKeys } from './keys'export type UpsertContentPayload = Omit<components['schemas']['UpsertContentBody'], 'content'> & {content: Partial<Content['content']>+ favorite?: boolean}export type UpsertContentVariables = {diff --git a/apps/studio/pages/api/platform/projects/[ref]/content/folders/index.ts b/apps/studio/pages/api/platform/projects/[ref]/content/folders/index.tsindex cafcf343f7a..7720c8eca7e 100644--- a/apps/studio/pages/api/platform/projects/[ref]/content/folders/index.ts+++ b/apps/studio/pages/api/platform/projects/[ref]/content/folders/index.ts@@ -39,7 +39,6 @@ const handleGetAll = async (req: NextApiRequest, res: NextApiResponse<GetRespons(select version()) as version,(select current_setting('server_version_num')) as version_number;`,schema_version: '1',- favorite: false,},inserted_at: '',updated_at: '',diff --git a/apps/studio/pages/api/platform/projects/[ref]/content/index.ts b/apps/studio/pages/api/platform/projects/[ref]/content/index.tsindex 0a08de15eb3..1d2eee7807e 100644--- a/apps/studio/pages/api/platform/projects/[ref]/content/index.ts+++ b/apps/studio/pages/api/platform/projects/[ref]/content/index.ts@@ -47,7 +47,6 @@ const handleGetAll = async (req: NextApiRequest, res: NextApiResponse<GetRespons(select version()) as version,(select current_setting('server_version_num')) as version_number;`,schema_version: '1',- favorite: false,} as any,favorite: false,inserted_at: '',diff --git a/apps/studio/pages/api/platform/projects/[ref]/content/item/[id].ts b/apps/studio/pages/api/platform/projects/[ref]/content/item/[id].tsindex 350ebac0c61..ee05926344b 100644--- a/apps/studio/pages/api/platform/projects/[ref]/content/item/[id].ts+++ b/apps/studio/pages/api/platform/projects/[ref]/content/item/[id].ts@@ -41,7 +41,6 @@ const handleGetAll = async (req: NextApiRequest, res: NextApiResponse<ResponseDa(select version()) as version,(select current_setting('server_version_num')) as version_number;`,schema_version: '1',- favorite: false,} as any,favorite: false,inserted_at: '',diff --git a/apps/studio/pages/project/[ref]/logs/explorer/index.tsx b/apps/studio/pages/project/[ref]/logs/explorer/index.tsxindex 37325967ef2..1bc393f7aee 100644--- a/apps/studio/pages/project/[ref]/logs/explorer/index.tsx+++ b/apps/studio/pages/project/[ref]/logs/explorer/index.tsx@@ -144,7 +144,6 @@ export const LogsExplorerPage: NextPageWithLayout = () => {const addRecentLogSqlSnippet = (snippet: Partial<LogSqlSnippets.Content>) => {const defaults: LogSqlSnippets.Content = {schema_version: '1',- favorite: false,sql: '',content_id: '',}diff --git a/apps/studio/state/sql-editor-v2.ts b/apps/studio/state/sql-editor-v2.tsindex cd3181d4474..63791fd27c5 100644--- a/apps/studio/state/sql-editor-v2.ts+++ b/apps/studio/state/sql-editor-v2.ts@@ -395,10 +395,10 @@ if (typeof window !== 'undefined') {project_id: project_id ?? 0,owner_id: owner_id,folder_id: folder_id ?? undefined,+ favorite: favorite ?? false,content: {...content!,content_id: id,- favorite: favorite ?? false,},},shouldInvalidatediff --git a/apps/studio/types/userContent.ts b/apps/studio/types/userContent.tsindex ca8fb9e4aa6..71dfab7b74e 100644--- a/apps/studio/types/userContent.ts+++ b/apps/studio/types/userContent.ts@@ -16,6 +16,7 @@ export interface UserContent<project_id?: numberupdated_at?: string // '2021-08-26T08:24:52.040695+00:00'updated_by?: Owner+ favorite?: boolean}export interface UserContentMap {@@ -38,10 +39,6 @@ export namespace SqlSnippets {// we can add some versioning to this schema in case we need to change the format.schema_version: string- // show sql snippet as a favorite.- // this could be problematic if sql snippets have visibility that is != 'user'- favorite: boolean-chart?: {type: 'bar' | 'line'cumulative: boolean@@ -79,7 +76,6 @@ export namespace Dashboards {}interval: '1m' | '5m' | '1h' | '1d' | '1w' | '1M' | '1y' // this is the data intervallayout: Chart[]- favorite?: boolean // not used yet}/**@@ -113,28 +109,6 @@ export namespace Dashboards {}}-export namespace SqlSnippets {- /**- * To be stored in the database: public.user_content.content- * In this case there is only one thing to store, but it's good to- * nest it in an object for future expansion.- */- export interface Content {- // unique id of the sql snippet, possibly to used so snippets can support versioning- content_id: string-- // A full SQL query - this will be hashed on the /content endpoint- sql: string-- // we can add some versioning to this schema in case we need to change the format.- schema_version: string-- // show sql snippet as a favorite.- // this could be problematic if sql snippets have visibility that is != 'user'- favorite: boolean- }-}-export namespace LogSqlSnippets {/*** To be stored in the database: public.user_content.content@@ -150,9 +124,5 @@ export namespace LogSqlSnippets {// we can add some versioning to this schema in case we need to change the format.schema_version: string-- // show sql snippet as a favorite.- // this could be problematic if sql snippets have visibility that is != 'user'- favorite: boolean}}