chore(docs): setup docs for overrideTypes (#33705)

* chore(docs): setup docs for overrideTypes

* fix: add overrideTypes to docs section

* chore: regen specs

* chore: update snapshot

* chore: regenerate all specs

* revert realtime spec changes

---------

Co-authored-by: Charis Lam <26616127+charislam@users.noreply.github.com>
This commit is contained in:
Andrew ValleteauandCharis Lam authored and Joshen Lim committed 2025-03-05 15:39:02 +01:00
1 parent c86ee6a6dc
commit 41a58dae95
15 files changed
+22041 -14160

No files matched your search

@@ -144,7 +144,15 @@ To use `MergeDeep`, set `compilerOptions.strictNullChecks` to `true` in your `ts
You can also override the type of an individual successful response if needed:
```ts
const { data } = await supabase.from('countries').select().returns<MyType>()
// Partial type override allows you to only override some of the properties in your results
const { data } = await supabase.from('countries').select().overrideTypes<Array<{ id: string }>>()
// For a full replacement of the original return type use the `{ merge: false }` property as second argument
const { data } = await supabase
.from('countries')
.select()
.overrideTypes<Array<{ id: string }>, { merge: false }>()
// Use it with `maybeSingle` or `single`
const { data } = await supabase.from('countries').select().single().overrideTypes<{ id: string }>()
```
### Type shorthands
@@ -149,7 +149,15 @@ You can also override the type of an individual successful response if needed:
<RefSubLayout.Examples>
```ts
const { data } = await supabase.from('countries').select().returns<MyType>()
// Partial type override allows you to only override some of the properties in your results
const { data } = await supabase.from('countries').select().overrideTypes<Array<{ id: string }>>()
// For a full replacement of the original return type use the `{ merge: false }` property as second argument
const { data } = await supabase
.from('countries')
.select()
.overrideTypes<Array<{ id: string }>, { merge: false }>()
// Use it with `maybeSingle` or `single`
const { data } = await supabase.from('countries').select().single().overrideTypes<{ id: string }>()
```
</RefSubLayout.Examples>
@@ -909,6 +909,24 @@ exports[`TS type spec parsing > matches snapshot 1`] = `
}
}
},
"@supabase/auth-js.AuthInvalidJwtError.constructor": {
"name": "@supabase/auth-js.AuthInvalidJwtError.constructor",
"params": [
{
"name": "message",
"type": {
"type": "intrinsic",
"name": "string"
}
}
],
"ret": {
"type": {
"type": "nameOnly",
"name": "AuthInvalidJwtError"
}
}
},
"@supabase/auth-js.AuthInvalidTokenResponseError.constructor": {
"name": "@supabase/auth-js.AuthInvalidTokenResponseError.constructor",
"params": [],
@@ -5735,6 +5753,223 @@ exports[`TS type spec parsing > matches snapshot 1`] = `
"shortText": "Log in an existing user by exchanging an Auth Code issued during the PKCE flow."
}
},
"@supabase/auth-js.GoTrueClient.getClaims": {
"name": "@supabase/auth-js.GoTrueClient.getClaims",
"params": [
{
"name": "jwt",
"type": {
"type": "intrinsic",
"name": "string"
},
"isOptional": true
},
{
"name": "jwks",
"type": {
"type": "object",
"properties": [
{
"name": "keys",
"type": {
"type": "array",
"elemType": {
"type": "object",
"name": "JWK",
"properties": [
{
"name": "alg",
"type": {
"type": "intrinsic",
"name": "string"
},
"isOptional": true
},
{
"name": "key_ops",
"type": {
"type": "array",
"elemType": {
"type": "intrinsic",
"name": "string"
}
}
},
{
"name": "kid",
"type": {
"type": "intrinsic",
"name": "string"
},
"isOptional": true
},
{
"name": "kty",
"type": {
"type": "union",
"subTypes": [
{
"type": "literal",
"value": "RSA"
},
{
"type": "literal",
"value": "EC"
},
{
"type": "literal",
"value": "oct"
}
]
}
}
]
}
}
}
]
}
}
],
"ret": {
"type": {
"type": "promise",
"name": "Promise",
"awaited": {
"type": "union",
"subTypes": [
{
"type": "object",
"properties": [
{
"name": "data",
"type": {
"type": "object",
"properties": [
{
"name": "claims",
"type": {
"type": "nameOnly",
"name": "JwtPayload"
}
},
{
"name": "header",
"type": {
"name": "JwtHeader",
"type": "object",
"properties": [
{
"name": "alg",
"type": {
"type": "union",
"subTypes": [
{
"type": "literal",
"value": "RS256"
},
{
"type": "literal",
"value": "ES256"
},
{
"type": "literal",
"value": "HS256"
}
]
}
},
{
"name": "kid",
"type": {
"type": "intrinsic",
"name": "string"
}
},
{
"name": "typ",
"type": {
"type": "intrinsic",
"name": "string"
}
}
]
}
},
{
"name": "signature",
"type": {
"type": "nameOnly",
"name": "Uint8Array"
}
}
]
}
},
{
"name": "error",
"type": {
"type": "literal",
"value": null
}
}
]
},
{
"type": "object",
"properties": [
{
"name": "data",
"type": {
"type": "literal",
"value": null
}
},
{
"name": "error",
"type": {
"type": "nameOnly",
"name": "AuthError"
}
}
]
},
{
"type": "object",
"properties": [
{
"name": "data",
"type": {
"type": "literal",
"value": null
}
},
{
"name": "error",
"type": {
"type": "literal",
"value": null
}
}
]
}
]
}
}
},
"comment": {
"tags": [
{
"tag": "experimental",
"text": "This method may change in future versions."
},
{
"tag": "description",
"text": "Gets the claims from a JWT. If the JWT is symmetric JWTs, it will call getUser() to verify against the server. If the JWT is asymmetric, it will be verified against the JWKS using the WebCrypto API.\\n"
}
]
}
},
"@supabase/auth-js.GoTrueClient.getSession": {
"name": "@supabase/auth-js.GoTrueClient.getSession",
"params": [],
@@ -21308,6 +21543,39 @@ exports[`TS type spec parsing > matches snapshot 1`] = `
}
}
},
"@supabase/postgrest-js.PostgrestBuilder.overrideTypes": {
"name": "@supabase/postgrest-js.PostgrestBuilder.overrideTypes",
"params": [],
"comment": {
"shortText": "Override the type of the returned \`data\` field in the response.",
"returns": "A PostgrestBuilder instance with the new type\\n",
"tags": [
{
"tag": "example",
"text": "\\n\`\`\`typescript\\n// Merge with existing types (default behavior)\\nconst query = supabase\\n .from('users')\\n .select()\\n .overrideTypes<{ custom_field: string }>()\\n\\n// Replace existing types completely\\nconst replaceQuery = supabase\\n .from('users')\\n .select()\\n .overrideTypes<{ id: number; name: string }, { merge: false }>()\\n\`\`\`"
}
]
}
},
"@supabase/postgrest-js.PostgrestBuilder.returns": {
"name": "@supabase/postgrest-js.PostgrestBuilder.returns",
"params": [],
"ret": {
"type": {
"type": "nameOnly",
"name": "CheckMatchingArrayTypes"
}
},
"comment": {
"shortText": "Override the type of the returned \`data\`.",
"tags": [
{
"tag": "deprecated",
"text": "Use overrideTypes<yourType, { merge: false }>() method at the end of your call chain instead\\n"
}
]
}
},
"@supabase/postgrest-js.PostgrestBuilder.setHeader": {
"name": "@supabase/postgrest-js.PostgrestBuilder.setHeader",
"params": [
@@ -23903,6 +24171,20 @@ exports[`TS type spec parsing > matches snapshot 1`] = `
}
]
},
"@supabase/postgrest-js.PostgrestFilterBuilder.overrideTypes": {
"name": "@supabase/postgrest-js.PostgrestFilterBuilder.overrideTypes",
"params": [],
"comment": {
"shortText": "Override the type of the returned \`data\` field in the response.",
"returns": "A PostgrestBuilder instance with the new type\\n",
"tags": [
{
"tag": "example",
"text": "\\n\`\`\`typescript\\n// Merge with existing types (default behavior)\\nconst query = supabase\\n .from('users')\\n .select()\\n .overrideTypes<{ custom_field: string }>()\\n\\n// Replace existing types completely\\nconst replaceQuery = supabase\\n .from('users')\\n .select()\\n .overrideTypes<{ id: number; name: string }, { merge: false }>()\\n\`\`\`"
}
]
}
},
"@supabase/postgrest-js.PostgrestFilterBuilder.range": {
"name": "@supabase/postgrest-js.PostgrestFilterBuilder.range",
"params": [
@@ -24325,7 +24607,13 @@ exports[`TS type spec parsing > matches snapshot 1`] = `
}
},
"comment": {
"shortText": "Override the type of the returned \`data\`."
"shortText": "Override the type of the returned \`data\`.",
"tags": [
{
"tag": "deprecated",
"text": "Use overrideTypes<yourType, { merge: false }>() method at the end of your call chain instead\\n"
}
]
}
},
"@supabase/postgrest-js.PostgrestFilterBuilder.rollback": {
@@ -25898,6 +26186,20 @@ exports[`TS type spec parsing > matches snapshot 1`] = `
}
]
},
"@supabase/postgrest-js.PostgrestTransformBuilder.overrideTypes": {
"name": "@supabase/postgrest-js.PostgrestTransformBuilder.overrideTypes",
"params": [],
"comment": {
"shortText": "Override the type of the returned \`data\` field in the response.",
"returns": "A PostgrestBuilder instance with the new type\\n",
"tags": [
{
"tag": "example",
"text": "\\n\`\`\`typescript\\n// Merge with existing types (default behavior)\\nconst query = supabase\\n .from('users')\\n .select()\\n .overrideTypes<{ custom_field: string }>()\\n\\n// Replace existing types completely\\nconst replaceQuery = supabase\\n .from('users')\\n .select()\\n .overrideTypes<{ id: number; name: string }, { merge: false }>()\\n\`\`\`"
}
]
}
},
"@supabase/postgrest-js.PostgrestTransformBuilder.range": {
"name": "@supabase/postgrest-js.PostgrestTransformBuilder.range",
"params": [
@@ -25975,7 +26277,13 @@ exports[`TS type spec parsing > matches snapshot 1`] = `
}
},
"comment": {
"shortText": "Override the type of the returned \`data\`."
"shortText": "Override the type of the returned \`data\`.",
"tags": [
{
"tag": "deprecated",
"text": "Use overrideTypes<yourType, { merge: false }>() method at the end of your call chain instead\\n"
}
]
}
},
"@supabase/postgrest-js.PostgrestTransformBuilder.rollback": {
+5 -1
View File
@@ -3569,7 +3569,11 @@
},
"SecretResponse": {
"type": "object",
"properties": { "name": { "type": "string" }, "value": { "type": "string" } },
"properties": {
"name": { "type": "string" },
"value": { "type": "string" },
"updated_at": { "type": "string" }
},
"required": ["name", "value"]
},
"CreateSecretBody": {
@@ -376,6 +376,14 @@
"parent": "modifiers",
"type": "function"
},
{
"id": "overrideTypes",
"title": "Partially override or replace type of successful response",
"slug": "db-overrideTypes",
"product": "database",
"parent": "modifiers",
"type": "function"
},
{
"id": "explain",
"title": "Using explain",
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+25
View File
@@ -1219,6 +1219,31 @@
}
}
},
"/object/list-v2/{bucketName}": {
"post": {
"summary": "Search for objects under a prefix",
"tags": ["object"],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"prefix": { "type": "string", "examples": ["folder/subfolder"] },
"limit": { "type": "integer", "minimum": 1, "examples": [10] },
"cursor": { "type": "string" },
"with_delimiter": { "type": "boolean" }
}
}
}
}
},
"parameters": [
{ "schema": { "type": "string" }, "in": "path", "name": "bucketName", "required": true }
],
"responses": { "200": { "description": "Default Response" } }
}
},
"/object/list/{bucketName}": {
"post": {
"summary": "Search for objects under a prefix",
+85
View File
@@ -6593,6 +6593,8 @@ functions:
- id: returns
$ref: '@supabase/postgrest-js.PostgrestTransformBuilder.returns'
notes: |
- Deprecated: use overrideTypes method instead
title: returns()
examples:
- id: override-type-of-successful-response
@@ -6602,6 +6604,22 @@ functions:
const { data } = await supabase
.from('countries')
.select()
.returns<Array<MyType>>()
```
response: |
```
let x: typeof data // MyType[]
```
hideCodeBlock: true
isSpotlight: true
- id: override-type-of-object-response
name: Override type of object response
code: |
```ts
const { data } = await supabase
.from('countries')
.select()
.maybeSingle()
.returns<MyType>()
```
response: |
@@ -6611,6 +6629,73 @@ functions:
hideCodeBlock: true
isSpotlight: true
- id: overrideTypes
$ref: '@supabase/postgrest-js.PostgrestBuilder.overrideTypes'
title: overrideTypes()
examples:
- id: complete-override-type-of-successful-response
name: Complete Override type of successful response
code: |
```ts
const { data } = await supabase
.from('countries')
.select()
.overrideTypes<Array<MyType>, { merge: false }>()
```
response: |
```ts
let x: typeof data // MyType[]
```
hideCodeBlock: true
isSpotlight: true
- id: complete-override-type-of-object-response
name: Complete Override type of object response
code: |
```ts
const { data } = await supabase
.from('countries')
.select()
.maybeSingle()
.overrideTypes<MyType, { merge: false }>()
```
response: |
```ts
let x: typeof data // MyType | null
```
hideCodeBlock: true
isSpotlight: true
- id: partial-override-type-of-successful-response
name: Partial Override type of successful response
code: |
```ts
const { data } = await supabase
.from('countries')
.select()
.overrideTypes<Array<{ status: "A" | "B" }>>()
```
response: |
```ts
let x: typeof data // Array<CountryRowProperties & { status: "A" | "B" }>
```
hideCodeBlock: true
isSpotlight: true
- id: partial-override-type-of-object-response
name: Partial Override type of object response
code: |
```ts
const { data } = await supabase
.from('countries')
.select()
.maybeSingle()
.overrideTypes<{ status: "A" | "B" }>()
```
response: |
```ts
let x: typeof data // CountryRowProperties & { status: "A" | "B" } | null
```
hideCodeBlock: true
isSpotlight: true
- id: explain
$ref: '@supabase/postgrest-js.PostgrestTransformBuilder.explain'
title: Using Explain
+4 -4
View File
@@ -26,7 +26,7 @@ functions:
code: |
```swift
import Supabase
let client = SupabaseClient(supabaseURL: URL(string: "https://xyzcompany.supabase.co")!, supabaseKey: "public-anon-key")
```
- id: initialize-client-custom-options
@@ -34,7 +34,7 @@ functions:
code: |
```swift
import Supabase
let client = SupabaseClient(
supabaseURL: URL(string: "https://xyzcompany.supabase.co")!,
supabaseKey: "public-anon-key",
@@ -58,7 +58,7 @@ functions:
code: |
```swift
import Supabase
struct AppLogger: SupabaseLogger {
func log(message: SupabaseLogMessage) {
print(message.description)
@@ -80,7 +80,7 @@ functions:
code: |
```swift
import Supabase
let supabase = SupabaseClient(
supabaseURL: URL(string: "https://xyzcompany.supabase.co")!,
supabaseKey: "public-anon-key",
@@ -3592,6 +3592,9 @@
},
"value": {
"type": "string"
},
"updated_at": {
"type": "string"
}
},
"required": ["name", "value"]
@@ -12284,6 +12287,9 @@
},
"value": {
"type": "string"
},
"updated_at": {
"type": "string"
}
},
"required": ["name", "value"]
@@ -1874,6 +1874,53 @@
}
}
},
"/object/list-v2/{bucketName}": {
"post": {
"summary": "Search for objects under a prefix",
"tags": ["object"],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"prefix": {
"type": "string",
"examples": ["folder/subfolder"]
},
"limit": {
"type": "integer",
"minimum": 1,
"examples": [10]
},
"cursor": {
"type": "string"
},
"with_delimiter": {
"type": "boolean"
}
}
}
}
}
},
"parameters": [
{
"schema": {
"type": "string"
},
"in": "path",
"name": "bucketName",
"required": true
}
],
"responses": {
"200": {
"description": "Default Response"
}
}
}
},
"/object/list/{bucketName}": {
"post": {
"summary": "Search for objects under a prefix",