The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Merge branch 'master' into feat/logs-recent-queries
Jonathan Summers-Muirb1d5dfff85f6
diff --cc studio/stores/content/ProjectContentStore.tsindex 57f824ddfa6,731e9cf1532..58b197cccec--- a/studio/stores/content/ProjectContentStore.ts+++ b/studio/stores/content/ProjectContentStore.ts@@@ -15,17 -14,16 +15,21 @@@ export interface IProjectContentStoreisInitialized: booleanisLoaded: booleanerror: any+ recentLogSqlSnippets: LogSqlSnippets.Content[]+ baseUrl: string+ projectRef?: string+load: () => void+ loadPersistentData: () => Promise<void>create: (x: UserContent) => { data: UserContent; error: { error: { message: string } } }list: (filter?: any) => any[]reports: (filter?: any) => any[]sqlSnippets: (filter?: any) => any[]+ logSqlSnippets: (filter?: CustomFilter) => UserContent[]+ addRecentLogSqlSnippet: (snippet: Partial<LogSqlSnippets.Content>) => void+ clearRecentLogSqlSnippets: () => void+ setProjectRef: (ref?: string) => void}export default class ProjectContentStore implements IProjectContentStore {@@@ -39,22 -37,18 +43,24 @@@}baseUrl: string+ localStorageKey: string+ recentLogSqlKey: string+ projectRef: string+data: UserContentMap = {}+ recentLogSqlSnippets: LogSqlSnippets.Content[] = []state = this.STATES.INITIALerror = null-constructor(rootStore: IRootStore, options: { projectRef: string }) {const { projectRef } = options+ this.projectRef = projectRefthis.rootStore = rootStore- this.baseUrl = `${API_URL}/projects/${projectRef}/content`+ this.localStorageKey = `project-content-${projectRef}`+ this.recentLogSqlKey = `${this.localStorageKey}-recent-log-sql`+ this.loadPersistentData()+ this.baseUrl = ``makeAutoObservable(this)}@@@ -105,11 -97,6 +111,13 @@@const sqlSnippets = this.sqlSnippets((x: any) => x.owner_id === userId)}+ loadRecentLogSqlSnippets() {- if (typeof window === 'undefined') return;- this.recentLogSqlSnippets = JSON.parse((window as any).localStorage.getItem(this.recentLogSqlKey) || "[]")++ if (typeof window === 'undefined') return++ this.recentLogSqlSnippets = JSON.parse(++ (window as any).localStorage.getItem(this.recentLogSqlKey) || '[]'++ )+ }+list(filter?: any) {const arr = Object.values(this.data)if (!!filter) {@@@ -152,26 -139,6 +160,34 @@@return arr_filtered}}+ public addRecentLogSqlSnippet(snippet: Partial<LogSqlSnippets.Content>) {- if (typeof window === 'undefined') return;- const defaults : LogSqlSnippets.Content= {schema_version: "1", favorite: false, sql: "", content_id: ""}- this.recentLogSqlSnippets.push({...defaults, ...snippet});- (window as any).localStorage.setItem(this.recentLogSqlKey, JSON.stringify(this.recentLogSqlSnippets))++ if (typeof window === 'undefined') return++ const defaults: LogSqlSnippets.Content = {++ schema_version: '1',++ favorite: false,++ sql: '',++ content_id: '',++ }++ this.recentLogSqlSnippets.push({ ...defaults, ...snippet })++ ;(window as any).localStorage.setItem(++ this.recentLogSqlKey,++ JSON.stringify(this.recentLogSqlSnippets)++ )+ }+ public clearRecentLogSqlSnippets() {- if (typeof window === 'undefined') return;- this.recentLogSqlSnippets = [];- (window as any).localStorage.setItem(this.recentLogSqlKey, JSON.stringify([]))++ if (typeof window === 'undefined') return++ this.recentLogSqlSnippets = []++ ;(window as any).localStorage.setItem(this.recentLogSqlKey, JSON.stringify([]))+ }++ logSqlSnippets(filter?: CustomFilter) {- let arr = (Object.values(this.data)[0] as any || []) as UserContent[]- let snippets = arr.filter(c => c.type === 'log_sql')++ let arr = ((Object.values(this.data)[0] as any) || []) as UserContent[]++ let snippets = arr.filter((c) => c.type === 'log_sql')+ if (filter) {+ snippets = snippets.filter(filter)+ }+ return snippets.sort((a, b) => a.name.localeCompare(b.name))+ }// @ts-ignoreasync create(payload: any) {