Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions .github/workflows/docs-js-libs-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ on:
workflow_dispatch:
inputs:
version:
description: "Version that was released (e.g., patch, minor, major, or v2.1.0)"
description: 'Version that was released (e.g., patch, minor, major, or v2.1.0)'
required: true
type: string
source:
description: "Source of the documentation update"
description: 'Source of the documentation update'
required: false
type: string
default: "manual"
default: 'manual'

permissions:
pull-requests: write
Expand All @@ -25,8 +25,6 @@ jobs:
- uses: actions/checkout@v4
with:
ref: master
sparse-checkout: |
apps/docs

- uses: pnpm/action-setup@v4
name: Install pnpm
Expand All @@ -36,8 +34,8 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "pnpm"
node-version-file: '.nvmrc'
cache: 'pnpm'

- name: Install deps
run: pnpm i
Expand All @@ -50,12 +48,18 @@ jobs:
echo "Version: ${{ github.event.inputs.version }}"
make

- name: Generate new typespec snapshot
working-directory: apps/docs
run: |
echo "Generating new typespec snapshot for review..."
npx vitest run --update ./features/docs/Reference.typeSpec.test.ts

- name: Create pull request
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "docs: update js client libraries (${{ github.event.inputs.version }})"
title: "docs: update js client libraries (${{ github.event.inputs.version }})"
commit-message: 'docs: update js client libraries (${{ github.event.inputs.version }})'
title: 'docs: update js client libraries (${{ github.event.inputs.version }})'
body: |
Updates JS client libraries documentation following stable release.
Ran `make` in apps/docs/spec to regenerate tsdoc files.
Expand All @@ -66,5 +70,5 @@ jobs:
- **Changes:** Regenerated tsdoc files from latest spec files

🤖 Auto-generated from supabase-js-libs stable release.
branch: "gha/update-js-libs-docs-${{ github.run_number }}"
base: "master"
branch: 'gha/update-js-libs-docs-${{ github.run_number }}'
base: 'master'
14 changes: 7 additions & 7 deletions .github/workflows/update-js-libs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ jobs:
- name: Update @supabase/*-js packages in pnpm-workspace.yaml
run: |
# Update @supabase/supabase-js
sed -i "s/'@supabase\/supabase-js': .*/'@supabase\/supabase-js': ^${{ github.event.inputs.version }}/" pnpm-workspace.yaml
sed -i "s/'@supabase\/supabase-js': .*/'@supabase\/supabase-js': ${{ github.event.inputs.version }}/" pnpm-workspace.yaml

# Update @supabase/auth-js
sed -i "s/'@supabase\/auth-js': .*/'@supabase\/auth-js': ^${{ github.event.inputs.version }}/" pnpm-workspace.yaml
sed -i "s/'@supabase\/auth-js': .*/'@supabase\/auth-js': ${{ github.event.inputs.version }}/" pnpm-workspace.yaml

# Update @supabase/realtime-js
sed -i "s/'@supabase\/realtime-js': .*/'@supabase\/realtime-js': ^${{ github.event.inputs.version }}/" pnpm-workspace.yaml
sed -i "s/'@supabase\/realtime-js': .*/'@supabase\/realtime-js': ${{ github.event.inputs.version }}/" pnpm-workspace.yaml

echo "Updated pnpm-workspace.yaml:"
cat pnpm-workspace.yaml

- name: Install dependencies
run: pnpm i
run: pnpm i --no-frozen-lockfile

- name: Create pull request
uses: peter-evans/create-pull-request@v6
Expand All @@ -66,9 +66,9 @@ jobs:
**Source**: ${{ github.event.inputs.source }}

**Changes**:
- Updated @supabase/supabase-js to ^${{ github.event.inputs.version }}
- Updated @supabase/auth-js to ^${{ github.event.inputs.version }}
- Updated @supabase/realtime-js to ^${{ github.event.inputs.version }}
- Updated @supabase/supabase-js to ${{ github.event.inputs.version }}
- Updated @supabase/auth-js to ${{ github.event.inputs.version }}
- Updated @supabase/realtime-js to ${{ github.event.inputs.version }}
- Refreshed pnpm-lock.yaml

This PR was created automatically.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2450,8 +2450,6 @@ export const platform: NavMenuConstant = {
name: 'Manage your usage',
url: '/guides/platform/manage-your-usage' as `/${string}`,
items: [
{ name: 'Usage limits', url: '/guides/platform/usage-limits' as `/${string}` },
{ name: 'Overages', url: '/guides/platform/overages' as `/${string}` },
{
name: 'Compute',
url: '/guides/platform/manage-your-usage/compute' as `/${string}`,
Expand Down
144 changes: 118 additions & 26 deletions apps/docs/features/docs/Reference.typeSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ const KIND_MODULE = 2
const KIND_CLASS = 128
const KIND_INTERFACE = 256
const KIND_CONSTRUCTOR = 512
const KIND_PROPERTY = 1024
const KIND_METHOD = 2048
const KIND_TYPE_LITERAL = 65536

Expand Down Expand Up @@ -303,6 +304,15 @@ function parseModInternal(
parseConstructor(node, map, currentPath, res)
} else if (node.kind === KIND_METHOD) {
return parseMethod(node, map, currentPath, res)
} else if (node.kind === KIND_PROPERTY) {
if (node.type?.type === 'reference') {
const referent = map.get(node.type.target)
if (referent?.variant === 'declaration' && referent?.kind === KIND_INTERFACE) {
const children = referent?.children ?? []
updatedPath = [...currentPath, node.name]
children.forEach((child: any) => parseModInternal(child, map, updatedPath, res))
}
}
}
return
case 'property':
Expand Down Expand Up @@ -439,24 +449,26 @@ function parseSignature(
//
// with additional properties depending on the type.

function parseType(type: any, map: Map<number, any>) {
function parseType(type: any, map: Map<number, any>, typeArguments?: any, debug = false) {
switch (type.type) {
case 'literal':
return type
case 'intrinsic':
return type
case 'reference':
return parseReferenceType(type, map)
return parseReferenceType(type, map, typeArguments, debug)
case 'array':
return parseArrayType(type, map)
return parseArrayType(type, map, typeArguments, debug)
case 'union':
return parseUnionType(type, map)
return parseUnionType(type, map, typeArguments, debug)
case 'reflection':
return parseReflectionType(type, map)
return parseReflectionType(type, map, typeArguments, debug)
case 'indexedAccess':
return parseIndexedAccessType(type, map)
return parseIndexedAccessType(type, map, typeArguments, debug)
case 'typeOperator':
return parseTypeOperatorType(type, map)
return parseTypeOperatorType(type, map, typeArguments, debug)
case 'conditional':
return parseConditionalType(type, map, typeArguments, debug)
default:
break
}
Expand All @@ -481,8 +493,13 @@ function parseType(type: any, map: Map<number, any>) {
* parsing to the referenced node, but use the name and comment from the
* original type.
*/
function delegateParsing(original: any, referenced: any, map: Map<number, any>) {
const dereferencedType = parseType(referenced, map)
function delegateParsing(
original: any,
referenced: any,
map: Map<number, any>,
typeArguments?: any
) {
const dereferencedType = parseType(referenced, map, typeArguments)

if (dereferencedType) {
dereferencedType.name = nameOrAnonymous([original, dereferencedType])
Expand All @@ -498,7 +515,44 @@ function delegateParsing(original: any, referenced: any, map: Map<number, any>)
return dereferencedType
}

function parseReferenceType(type: any, map: Map<number, any>) {
function parseConditionalType(
type: any,
map: Map<number, any>,
typeArguments?: any,
_debug = false
) {
if (type.extendsType?.type === 'intrinsic' && type.extendsType?.name === 'object') {
let properties = []

if (
type.trueType?.type === 'mapped' &&
type.trueType?.parameterType?.target?.refersToTypeParameter &&
typeArguments?.[0]
) {
const propertyNames = parseType(typeArguments?.[0], map).properties?.map((p) => p.name)
properties = (propertyNames ?? [])
.map((p: string) => {
if (!type.trueType?.templateType) return undefined

const mappedType = parseType(type.trueType.templateType, map)
if (mappedType) {
return {
name: p,
type: mappedType,
}
}
})
.filter(Boolean)
}

return {
type: 'object',
properties,
}
}
}

function parseReferenceType(type: any, map: Map<number, any>, typeArguments?: any, debug = false) {
if (type.dereferenced?.type) {
return delegateParsing(type, type.dereferenced.type, map)
}
Expand All @@ -507,6 +561,10 @@ function parseReferenceType(type: any, map: Map<number, any>) {
return delegateParsing(type, type.dereferenced, map)
}

if (type.refersToTypeParameter === true && typeArguments?.[0]) {
return delegateParsing(type, typeArguments?.[0], map)
}

if (
type.package === 'typescript' &&
(type.name === 'Record' || type.qualifiedName === 'Record')
Expand Down Expand Up @@ -537,8 +595,13 @@ function parseReferenceType(type: any, map: Map<number, any>) {
if (referenced) {
const maybeType =
typeof referenced.type === 'object' && 'type' in referenced.type
? /* need to go down a level */ delegateParsing(type, referenced.type, map)
: delegateParsing(type, referenced, map)
? /* need to go down a level */ delegateParsing(
type,
referenced.type,
map,
type.typeArguments
)
: delegateParsing(type, referenced, map, type.typeArguments)

if (maybeType) {
return maybeType
Expand Down Expand Up @@ -580,7 +643,12 @@ function parseReferenceType(type: any, map: Map<number, any>) {
return undefined
}

function parseArrayType(type: any, map: Map<number, any>): ArrayType {
function parseArrayType(
type: any,
map: Map<number, any>,
_typeArguments?: any,
debug = false
): ArrayType {
const elemType = parseType(type.elementType, map)

return {
Expand All @@ -590,9 +658,14 @@ function parseArrayType(type: any, map: Map<number, any>): ArrayType {
}
}

function parseUnionType(type: any, map: Map<number, any>): CustomUnionType {
function parseUnionType(
type: any,
map: Map<number, any>,
typeArguments?: any,
_debug = false
): CustomUnionType {
// Need the Boolean filter because there are nulls in some of the nodes
const subTypes = type.types.filter(Boolean).map((type) => parseType(type, map))
const subTypes = type.types.filter(Boolean).map((type) => parseType(type, map, typeArguments))

return {
type: 'union',
Expand Down Expand Up @@ -654,17 +727,22 @@ function parsePickType(type: any, map: Map<number, any>) {
return undefined
}

function parseReflectionType(type: any, map: Map<number, any>): TypeDetails | undefined {
function parseReflectionType(
type: any,
map: Map<number, any>,
typeArguments?: any,
_debug = false
): TypeDetails | undefined {
if (!type.declaration) return undefined

let res: TypeDetails | undefined
switch ((type.declaration.kindString ?? type.declaration.variant).toLowerCase()) {
case 'type literal':
res = parseTypeLiteral(type, map)
res = parseTypeLiteral(type, map, typeArguments)
break
case 'declaration':
if (type.declaration.kind === KIND_TYPE_LITERAL) {
res = parseTypeLiteral(type, map)
res = parseTypeLiteral(type, map, typeArguments)
}
default:
break
Expand All @@ -673,12 +751,16 @@ function parseReflectionType(type: any, map: Map<number, any>): TypeDetails | un
return res
}

function parseTypeLiteral(type: any, map: Map<number, any>): TypeDetails | undefined {
function parseTypeLiteral(
type: any,
map: Map<number, any>,
typeArguments?: any
): TypeDetails | undefined {
const name = nameOrAnonymous(type)

if ('children' in type.declaration) {
const properties = type.declaration.children
.map((child: any) => parseTypeInternals(child, map))
.map((child: any) => parseTypeInternals(child, map, typeArguments))
.filter(Boolean)
return {
name,
Expand Down Expand Up @@ -714,14 +796,24 @@ function parseTypeLiteral(type: any, map: Map<number, any>): TypeDetails | undef
return undefined
}

function parseIndexedAccessType(type: any, map: Map<number, any>) {
function parseIndexedAccessType(
type: any,
map: Map<number, any>,
_typeArguments?: any,
_debug = false
) {
return {
type: 'nameOnly',
name: `${type.objectType?.name ?? ''}['${type.indexType.value ?? type.indexType.name ?? ''}']`,
}
}

function parseTypeOperatorType(type: any, map: Map<number, any>) {
function parseTypeOperatorType(
type: any,
map: Map<number, any>,
_typeArguments?: any,
_debug = false
) {
switch (type.operator) {
case 'readonly':
return parseType(type.target, map)
Expand All @@ -745,11 +837,11 @@ function parseInterface(type: any, map: Map<number, any>): CustomObjectType {
// This layer is for the sub-types that define a custom type, for example, the
// properties of an interface.

function parseTypeInternals(elem: any, map: Map<number, any>) {
function parseTypeInternals(elem: any, map: Map<number, any>, typeArguments?: any) {
switch ((elem.kindString || elem.variant).toLowerCase()) {
case 'property':
case 'declaration':
return parseInternalProperty(elem, map)
return parseInternalProperty(elem, map, typeArguments)
case 'method':
if (elem.signatures?.[0]) {
const { params, ret, comment } = parseSignature(elem.signatures?.[0], map)
Expand All @@ -772,13 +864,13 @@ function parseTypeInternals(elem: any, map: Map<number, any>) {
}
}

function parseInternalProperty(elem: any, map: Map<number, any>) {
function parseInternalProperty(elem: any, map: Map<number, any>, typeArguments?: any) {
const name = nameOrAnonymous(elem)
if (!elem.type) {
return undefined
}

const type = parseType(elem.type, map)
const type = parseType(elem.type, map, typeArguments)

const res = {
name,
Expand Down
Loading
Loading