Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Convert files to ts

Joshen Limd739228db5d1
diff --git a/studio/components/to-be-cleaned/Docs/CodeSnippet.js b/studio/components/to-be-cleaned/Docs/CodeSnippet.tsx
similarity index 59%
rename from studio/components/to-be-cleaned/Docs/CodeSnippet.js
rename to studio/components/to-be-cleaned/Docs/CodeSnippet.tsx
index 47acdeff5da..4c58fa3aeb8 100644
--- a/studio/components/to-be-cleaned/Docs/CodeSnippet.js
+++ b/studio/components/to-be-cleaned/Docs/CodeSnippet.tsx
@@ -1,6 +1,15 @@
import SimpleCodeBlock from 'components/to-be-cleaned/SimpleCodeBlock'
-const CodeSnippet = ({ selectedLang, snippet }) => {
+interface CodeSnippetProps {
+ selectedLang: 'bash' | 'js'
+ snippet: {
+ title?: string
+ bash: { language: string; code: string }
+ js: { language: string; code: string }
+ }
+}
+
+const CodeSnippet = ({ selectedLang, snippet }: CodeSnippetProps) => {
if (!snippet[selectedLang]) return null
return (
<div className="codeblock-container">
diff --git a/studio/components/to-be-cleaned/Docs/Description.js b/studio/components/to-be-cleaned/Docs/Description.tsx
similarity index 89%
rename from studio/components/to-be-cleaned/Docs/Description.js
rename to studio/components/to-be-cleaned/Docs/Description.tsx
index fc942ac6c50..8311ffce3bf 100644
--- a/studio/components/to-be-cleaned/Docs/Description.js
+++ b/studio/components/to-be-cleaned/Docs/Description.tsx
@@ -8,7 +8,7 @@ import { timeout } from 'lib/helpers'
// Removes some auto-generated Postgrest text
// Ideally PostgREST wouldn't add this if there is already a comment
-const temp_removePostgrestText = (content) => {
+const temp_removePostgrestText = (content: string) => {
const postgrestTextPk = `Note:\nThis is a Primary Key.<pk/>`
const postgrestTextFk = `Note:\nThis is a Foreign Key to`
const pkTextPos = content.lastIndexOf(postgrestTextPk)
@@ -20,7 +20,13 @@ const temp_removePostgrestText = (content) => {
return cleansed
}
-export default function Description({ content, metadata, onChange = () => {} }) {
+interface DescrptionProps {
+ content: string
+ metadata: { table: string; column: string; rpc: string }
+ onChange: (value: string) => void
+}
+
+const Description = ({ content, metadata, onChange = () => {} }: DescrptionProps) => {
const { meta, ui } = useStore()
const contentText = temp_removePostgrestText(content || '').trim()
@@ -81,7 +87,7 @@ export default function Description({ content, metadata, onChange = () => {} })
className="w-full"
placeholder="Click to edit."
value={value}
- onChange={(e) => setValue(e.target.value)}
+ onChange={(e: any) => setValue(e.target.value)}
/>
<div
className={`flex items-center gap-2 ${
@@ -109,3 +115,5 @@ export default function Description({ content, metadata, onChange = () => {} })
</div>
)
}
+
+export default Description
diff --git a/studio/components/to-be-cleaned/Docs/NoDescription.js b/studio/components/to-be-cleaned/Docs/NoDescription.tsx
similarity index 78%
rename from studio/components/to-be-cleaned/Docs/NoDescription.js
rename to studio/components/to-be-cleaned/Docs/NoDescription.tsx
index 359145a86a6..7ffb0f43a26 100644
--- a/studio/components/to-be-cleaned/Docs/NoDescription.js
+++ b/studio/components/to-be-cleaned/Docs/NoDescription.tsx
@@ -1,4 +1,4 @@
-export default function NoDescription() {
+const NoDescription = () => {
return (
<p className="text-gray-300 text-sm">
No description provided.
@@ -7,3 +7,5 @@ export default function NoDescription() {
</p>
)
}
+
+export default NoDescription
diff --git a/studio/components/to-be-cleaned/Docs/Pages/Authentication.tsx b/studio/components/to-be-cleaned/Docs/Pages/Authentication.tsx
index bf51409a8c4..29513f00540 100644
--- a/studio/components/to-be-cleaned/Docs/Pages/Authentication.tsx
+++ b/studio/components/to-be-cleaned/Docs/Pages/Authentication.tsx
@@ -1,10 +1,12 @@
import Link from 'next/link'
-import Snippets from '../Snippets'
+
+import { AutoApiService } from 'data/config/project-api-query'
import CodeSnippet from '../CodeSnippet'
+import Snippets from '../Snippets'
interface AuthenticationProps {
- autoApiService: any
- selectedLang: string
+ autoApiService: AutoApiService
+ selectedLang: 'bash' | 'js'
showApiKey: string
}
diff --git a/studio/components/to-be-cleaned/Docs/Pages/Rpc/Introduction.js b/studio/components/to-be-cleaned/Docs/Pages/Rpc/Introduction.tsx
similarity index 89%
rename from studio/components/to-be-cleaned/Docs/Pages/Rpc/Introduction.js
rename to studio/components/to-be-cleaned/Docs/Pages/Rpc/Introduction.tsx
index 72c333db8f0..c5e7d15d207 100644
--- a/studio/components/to-be-cleaned/Docs/Pages/Rpc/Introduction.js
+++ b/studio/components/to-be-cleaned/Docs/Pages/Rpc/Introduction.tsx
@@ -1,4 +1,4 @@
-export default function Introduction() {
+const Introduction = () => {
return (
<>
<h2 className="doc-heading">Introduction</h2>
@@ -14,3 +14,5 @@ export default function Introduction() {
</>
)
}
+
+export default Introduction
diff --git a/studio/components/to-be-cleaned/Docs/Pages/UserManagement.js b/studio/components/to-be-cleaned/Docs/Pages/UserManagement.tsx
similarity index 95%
rename from studio/components/to-be-cleaned/Docs/Pages/UserManagement.js
rename to studio/components/to-be-cleaned/Docs/Pages/UserManagement.tsx
index 83a82df7c94..9fc81b4f047 100644
--- a/studio/components/to-be-cleaned/Docs/Pages/UserManagement.js
+++ b/studio/components/to-be-cleaned/Docs/Pages/UserManagement.tsx
@@ -1,13 +1,24 @@
import Link from 'next/link'
import { useRouter } from 'next/router'
+import { AutoApiService } from 'data/config/project-api-query'
import { makeRandomString } from 'lib/helpers'
import CodeSnippet from '../CodeSnippet'
import Snippets from '../Snippets'
const randomPassword = makeRandomString(20)
-export default function UserManagement({ autoApiService, selectedLang, showApiKey }) {
+interface UserManagementProps {
+ autoApiService: AutoApiService
+ selectedLang: 'bash' | 'js'
+ showApiKey: string
+}
+
+export default function UserManagement({
+ autoApiService,
+ selectedLang,
+ showApiKey,
+}: UserManagementProps) {
const router = useRouter()
const keyToShow = showApiKey ? showApiKey : 'SUPABASE_KEY'
@@ -100,7 +111,7 @@ export default function UserManagement({ autoApiService, selectedLang, showApiKe
<article className="code">
<CodeSnippet
selectedLang={selectedLang}
- snippet={Snippets.authPhoneSignUp(autoApiService.endpoint, keyToShow, randomPassword)}
+ snippet={Snippets.authPhoneSignUp(autoApiService.endpoint, keyToShow)}
/>
</article>
</div>
@@ -120,11 +131,7 @@ export default function UserManagement({ autoApiService, selectedLang, showApiKe
<article className="code">
<CodeSnippet
selectedLang={selectedLang}
- snippet={Snippets.authMobileOTPLogin(
- autoApiService.endpoint,
- keyToShow,
- randomPassword
- )}
+ snippet={Snippets.authMobileOTPLogin(autoApiService.endpoint, keyToShow)}
/>
</article>
</div>
@@ -144,11 +151,7 @@ export default function UserManagement({ autoApiService, selectedLang, showApiKe
<article className="code">
<CodeSnippet
selectedLang={selectedLang}
- snippet={Snippets.authMobileOTPVerify(
- autoApiService.endpoint,
- keyToShow,
- randomPassword
- )}
+ snippet={Snippets.authMobileOTPVerify(autoApiService.endpoint, keyToShow)}
/>
</article>
</div>
diff --git a/studio/data/config/project-api-query.ts b/studio/data/config/project-api-query.ts
index 5fc7d414364..ac745d737ec 100644
--- a/studio/data/config/project-api-query.ts
+++ b/studio/data/config/project-api-query.ts
@@ -3,6 +3,7 @@ import { get } from 'lib/common/fetch'
import { API_URL } from 'lib/constants'
import { useCallback } from 'react'
import { configKeys } from './keys'
+import { ResponseError } from 'types'
export type ProjectApiVariables = {
projectRef?: string
@@ -77,7 +78,7 @@ export async function getProjectApi({ projectRef }: ProjectApiVariables, signal?
}
export type ProjectApiData = Awaited<ReturnType<typeof getProjectApi>>
-export type ProjectApiError = unknown
+export type ProjectApiError = ResponseError
export const useProjectApiQuery = <TData = ProjectApiData>(
{ projectRef }: ProjectApiVariables,