The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
ref(studio): converge notebook UI types with canonical content schema (#48905)
Charis0111aa371b25
diff --git a/apps/studio/components/interfaces/Explorer/__tests__/NotebookEditor.test.tsx b/apps/studio/components/interfaces/Explorer/__tests__/NotebookEditor.test.tsxindex de62d78c980..24e63f419a5 100644--- a/apps/studio/components/interfaces/Explorer/__tests__/NotebookEditor.test.tsx+++ b/apps/studio/components/interfaces/Explorer/__tests__/NotebookEditor.test.tsx@@ -36,7 +36,7 @@ function makeNotebook(id: string, overrides: Partial<Notebook> = {}): Notebook {favorite: false,owner_id: 7,project_id: 42,- content: { schema_version: '1.0', cells: [] },+ content: { schema_version: 1, cells: [] },...overrides,}}diff --git a/apps/studio/components/interfaces/Explorer/hooks.ts b/apps/studio/components/interfaces/Explorer/hooks.tsindex 5c23c31eee1..f3883d21961 100644--- a/apps/studio/components/interfaces/Explorer/hooks.ts+++ b/apps/studio/components/interfaces/Explorer/hooks.ts@@ -26,7 +26,7 @@ export const useCreateNotebook = () => {visibility: 'project',favorite: false,content: {- schema_version: '1.0',+ schema_version: 1,cells: [],},owner_id: profile.id,diff --git a/apps/studio/state/notebooks/notebooks-state.test.ts b/apps/studio/state/notebooks/notebooks-state.test.tsindex 6c0de761ebf..c7316c8aa7d 100644--- a/apps/studio/state/notebooks/notebooks-state.test.ts+++ b/apps/studio/state/notebooks/notebooks-state.test.ts@@ -13,7 +13,7 @@ function makeNotebook(id: string, overrides: Partial<Notebook> = {}): Notebook {favorite: false,owner_id: 7,project_id: 42,- content: { schema_version: '1.0', cells: [] },+ content: { schema_version: 1, cells: [] },...overrides,}}@@ -44,7 +44,7 @@ describe('notebooksState', () => {notebooksState.updateCells({id: 'notebook-1',- cells: [{ type: 'markdown', content: 'hello' }],+ cells: [{ _tag: 'markdown_cell', id: 'cell-1', text: 'hello' }],})expect(notebooksState.notebooks['notebook-1'].status).toBe('unsaved')@@ -56,7 +56,7 @@ describe('notebooksState', () => {notebooksState.updateCells({id: 'notebook-1',- cells: [{ type: 'markdown', content: 'hello' }],+ cells: [{ _tag: 'markdown_cell', id: 'cell-1', text: 'hello' }],})expect(notebooksState.notebooks['notebook-1'].status).toBe('new')@@ -66,7 +66,7 @@ describe('notebooksState', () => {notebooksState.setNotebook({ projectRef: 'ref', notebook: makeNotebook('notebook-1') })notebooksState.updateCells({id: 'notebook-1',- cells: [{ type: 'markdown', content: 'hello' }],+ cells: [{ _tag: 'markdown_cell', id: 'cell-1', text: 'hello' }],})expect(notebooksState.notebooks['notebook-1'].status).toBe('unsaved')diff --git a/apps/studio/state/notebooks/notebooks-state.ts b/apps/studio/state/notebooks/notebooks-state.tsindex 4cca4f9e95e..faf55794eff 100644--- a/apps/studio/state/notebooks/notebooks-state.ts+++ b/apps/studio/state/notebooks/notebooks-state.ts@@ -2,8 +2,9 @@ import { useMemo } from 'react'import { proxy, snapshot, useSnapshot } from 'valtio'import { proxyMap } from 'valtio/utils'-import type { Notebook, NotebookCell, StateNotebook } from './types'+import type { Notebook, StateNotebook } from './types'import type { SnippetStatus } from '@/data/content/snippet-status'+import type { Notebooks } from '@/types'// [Joshen] Deliberately copied from sql-editor-lifecycle cause we might deprecate// that in favor of notebooks in the long run@@ -80,7 +81,7 @@ export const notebooksState = proxy({skipSave,}: {id: string- cells: NotebookCell[]+ cells: Notebooks.Cell[]skipSave?: boolean}) => {const stateNotebook = notebooksState.notebooks[id]diff --git a/apps/studio/state/notebooks/types.ts b/apps/studio/state/notebooks/types.tsindex 69ee18a1ea1..ca3fe7eb4e6 100644--- a/apps/studio/state/notebooks/types.ts+++ b/apps/studio/state/notebooks/types.ts@@ -1,19 +1,5 @@import { SnippetStatus } from '@/data/content/snippet-status'--/** Start and end follows ISO8601 convention */-type AbsoluteTimeRange = { start: string; end: string }-type RelativeTimeRange = { unit: 'm' | 'h' | 'd' | 'w' | 'M' | 'y'; amount: number }-type TimeRange = AbsoluteTimeRange | RelativeTimeRange--type DatabaseQueryCell = { type: 'sql'; sql: string }-type LogsQueryCell = { type: 'logs'; sql: string; range: TimeRange }-type MarkdownCell = { type: 'markdown'; content: string }-export type NotebookCell = DatabaseQueryCell | LogsQueryCell | MarkdownCell--interface NotebookContent {- schema_version: string- cells: NotebookCell[]-}+import type { Notebooks } from '@/types'export interface Notebook {id: string@@ -24,7 +10,7 @@ export interface Notebook {favorite: booleanowner_id: numberproject_id: number- content?: NotebookContent // Undefined until loaded+ content?: Notebooks.Content // Undefined until loaded}export interface StateNotebook {