Skip to content

Commit 720c00e

Browse files
supabase-supabase-autofixer[bot]supabase-releaser[bot]mandarini
authored
docs: update js sdk docs (2.95.3) (supabase#42557)
Updates JS sdk documentation following stable release. Ran `make` in apps/docs/spec to regenerate tsdoc files. **Details:** - **Version:** `2.95.3` - **Source:** `supabase-js-stable-release` - **Changes:** Regenerated tsdoc files from latest spec files 🤖 Auto-generated from @supabase/supabase-js stable release. --------- Co-authored-by: supabase-releaser[bot] <223506987+supabase-releaser[bot]@users.noreply.github.com> Co-authored-by: Katerina Skroumpelou <sk.katherine@gmail.com>
1 parent ff52f2f commit 720c00e

21 files changed

Lines changed: 158491 additions & 157447 deletions

apps/docs/app/api/crawlers/route.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
getTypeSpec,
1414
} from '~/features/docs/Reference.generated.singleton'
1515
import { getRefMarkdown } from '~/features/docs/Reference.mdx'
16-
import type { MethodTypes } from '~/features/docs/Reference.typeSpec'
16+
import type { MethodTypes, VariableTypes } from '~/features/docs/Reference.typeSpec'
1717
import type { AbbrevApiReferenceSection } from '~/features/docs/Reference.utils'
1818
import { BASE_PATH } from '~/lib/constants'
1919

@@ -136,7 +136,7 @@ async function functionDetails(
136136
const fn = fns!.find((fn) => fn.id === section.id)
137137
if (!fn) return ''
138138

139-
let types: MethodTypes | undefined
139+
let types: MethodTypes | VariableTypes | undefined
140140
if (libraryMeta.typeSpec && '$ref' in fn) {
141141
types = await getTypeSpec(fn['$ref'] as string)
142142
}
@@ -176,7 +176,7 @@ function mdxToHtml(markdown: string): string {
176176
return html
177177
}
178178

179-
function parametersToHtml(fn: any, types: MethodTypes | undefined) {
179+
function parametersToHtml(fn: any, types: MethodTypes | VariableTypes | undefined) {
180180
let result = '<h2 id="parameters">Parameters</h2>'
181181

182182
if ('overwriteParams' in fn || 'params' in fn) {
@@ -200,7 +200,7 @@ function parametersToHtml(fn: any, types: MethodTypes | undefined) {
200200
return result
201201
}
202202

203-
if (!types?.params || types.params.length === 0) return ''
203+
if (!types || !('params' in types) || !types.params || types.params.length === 0) return ''
204204

205205
result +=
206206
'<ul>' +

apps/docs/features/docs/Reference.generated.script.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ async function writeTypes() {
161161
await writeFile(
162162
join(GENERATED_DIRECTORY, 'typeSpec.json'),
163163
JSON.stringify(types, (key, value) => {
164-
if (key === 'methods') {
164+
if (key === 'methods' || key === 'variables') {
165165
return Object.fromEntries(value.entries())
166166
} else {
167167
return value

apps/docs/features/docs/Reference.generated.singleton.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ async function _typeSpecSingleton() {
1616
'utf-8'
1717
)
1818
typeSpec = JSON.parse(rawJson, (key, value) => {
19-
if (key === 'methods') {
19+
if (key === 'methods' || key === 'variables') {
2020
return new Map(Object.entries(value))
2121
} else {
2222
return value
@@ -39,7 +39,8 @@ export async function getTypeSpec(ref: string) {
3939
const refMod = normalizedRef.substring(0, delimiter)
4040

4141
const mod = modules.find((mod) => mod.name === refMod)
42-
return mod?.methods.get(normalizedRef)
42+
// Check methods first, then variables
43+
return mod?.methods.get(normalizedRef) ?? mod?.variables.get(normalizedRef)
4344
}
4445

4546
let cliSpec: Json

apps/docs/features/docs/Reference.sections.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
getTypeSpec,
1010
} from '~/features/docs/Reference.generated.singleton'
1111
import { getRefMarkdown, MDXRemoteRefs } from '~/features/docs/Reference.mdx'
12-
import type { MethodTypes } from '~/features/docs/Reference.typeSpec'
12+
import type { MethodTypes, VariableTypes } from '~/features/docs/Reference.typeSpec'
1313
import { formatMethodSignature } from '~/features/docs/Reference.typeSpec'
1414
import {
1515
ApiOperationRequestBodyDetails,
@@ -460,7 +460,7 @@ async function FunctionSection({
460460
const fn = fns?.find((fn) => fn.id === section.id)
461461
if (!fn) return null
462462

463-
let types: MethodTypes | undefined
463+
let types: MethodTypes | VariableTypes | undefined
464464
if (useTypeSpec && '$ref' in fn) {
465465
types = await getTypeSpec(fn['$ref'] as string)
466466
}
@@ -479,7 +479,7 @@ async function FunctionSection({
479479
<StickyHeader {...section} className="col-[1_/_-1]" />
480480

481481
{/* Display method signature below title */}
482-
{types && formatMethodSignature(types) && (
482+
{types && 'params' in types && formatMethodSignature(types) && (
483483
<div className="col-[1_/_-1] -mt-2 mb-4">
484484
<code className="text-sm text-foreground-muted font-mono">
485485
{formatMethodSignature(types)}
@@ -500,12 +500,18 @@ async function FunctionSection({
500500
}))
501501
: 'params' in fn
502502
? (fn.params as Array<object>).map((param) => ({ ...param, __overwritten: true }))
503-
: types?.params
503+
: types && 'params' in types
504+
? types.params
505+
: undefined
506+
}
507+
altParameters={
508+
types && 'altSignatures' in types
509+
? types.altSignatures?.map(({ params }) => params)
510+
: undefined
504511
}
505-
altParameters={types?.altSignatures?.map(({ params }) => params)}
506512
className="max-w-[80ch]"
507513
/>
508-
{!!types?.ret && <ReturnTypeDetails returnType={types.ret} />}
514+
{types && 'ret' in types && !!types.ret && <ReturnTypeDetails returnType={types.ret} />}
509515
</div>
510516
<div className="overflow-auto">
511517
{(() => {

apps/docs/features/docs/Reference.typeSpec.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export const TYPESPEC_NODE_ANONYMOUS = Symbol('anonymous')
2525
export interface ModuleTypes {
2626
name: string
2727
methods: Map<string, MethodTypes>
28+
variables: Map<string, VariableTypes>
2829
}
2930

3031
/**
@@ -43,6 +44,16 @@ export interface MethodTypes {
4344
]
4445
}
4546

47+
/**
48+
* Type definitions for a variable or constant.
49+
*/
50+
export interface VariableTypes {
51+
name: string | typeof TYPESPEC_NODE_ANONYMOUS
52+
comment?: Comment
53+
type: TypeDetails | undefined
54+
isConst?: boolean
55+
}
56+
4657
interface Comment {
4758
shortText?: string
4859
text?: string
@@ -160,6 +171,7 @@ export interface CustomTypePropertyType {
160171
// The meaning of kind flags from `typedoc`:
161172
// https://github.com/TypeStrong/typedoc/blob/2953b0148253589448176881a7acb46090f941bd/src/lib/output/themes/default/assets/typedoc/Application.ts#L36
162173
const KIND_MODULE = 2
174+
const KIND_VARIABLE = 32
163175
const KIND_CLASS = 128
164176
const KIND_INTERFACE = 256
165177
const KIND_CONSTRUCTOR = 512
@@ -285,6 +297,7 @@ function parseMod(mod: (typeof typeSpec)['children'][number]) {
285297
const res: ModuleTypes = {
286298
name: mod.name,
287299
methods: new Map(),
300+
variables: new Map(),
288301
}
289302

290303
// Build a map of nodes by their IDs for easy cross-referencing.
@@ -365,6 +378,8 @@ function parseModInternal(
365378
parseConstructor(node, map, currentPath, res)
366379
} else if (node.kind === KIND_METHOD) {
367380
return parseMethod(node, map, currentPath, res)
381+
} else if (node.kind === KIND_VARIABLE) {
382+
return parseVariable(node, map, currentPath, res)
368383
} else if (node.kind === KIND_PROPERTY) {
369384
parsePropertyReference(node, map, currentPath, res, processingRefs)
370385
}
@@ -490,6 +505,27 @@ function parseMethod(
490505
res.methods.set($ref, types)
491506
}
492507

508+
function parseVariable(
509+
node: any,
510+
map: Map<number, any>,
511+
currentPath: Array<string>,
512+
res: ModuleTypes
513+
) {
514+
const $ref = buildRefPath([...currentPath, node.name])
515+
516+
const type = parseType(node.type, map)
517+
const comment = node.comment ? normalizeComment(node.comment) : undefined
518+
519+
const types: VariableTypes = {
520+
name: $ref,
521+
type,
522+
comment,
523+
isConst: node.flags?.isConst ?? false,
524+
}
525+
526+
res.variables.set($ref, types)
527+
}
528+
493529
function parseSignature(
494530
signature: any,
495531
map: Map<number, any>

0 commit comments

Comments
 (0)