chore: type imports / avoid barrel file (#28100)

This commit is contained in:
Kevin Grüneberg
2024-07-23 09:55:41 +08:00
committed by GitHub
parent 16856af11e
commit 33142c2340
17 changed files with 70 additions and 105 deletions

View File

@@ -1,7 +1,7 @@
import Param from '~/components/Params'
import { genGuideMeta } from '~/features/docs/GuidesMdx.utils'
import { GuideTemplate, MDXRemoteGuides, newEditLink } from '~/features/docs/GuidesMdx.template'
import { getAnalyticsConfigV0 } from '~/lib/mdx/getConfig'
import specAnalyticsV0 from '~/spec/analytics_v0_config.yaml' assert { type: 'yml' }
const meta = {
title: 'Analytics Self-hosting Config',
@@ -14,8 +14,7 @@ const generateMetadata = genGuideMeta(() => ({
}))
const AnalyticsConfigPage = async () => {
const spec = getAnalyticsConfigV0()
const descriptionMdx = spec.info.description
const descriptionMdx = specAnalyticsV0.info.description
return (
<GuideTemplate
@@ -27,33 +26,35 @@ const AnalyticsConfigPage = async () => {
<MDXRemoteGuides source={descriptionMdx} />
<div>
{spec.info.tags.map((tag: ReturnType<typeof getAnalyticsConfigV0>['info']['tags']) => {
return (
<>
<h2 className="text-foreground">{tag.title}</h2>
<p className="text-foreground-lighter">{tag.description}</p>
<div className="not-prose">
<h5 className="text-base text-foreground mb-3">Parameters</h5>
<ul>
{spec.parameters
.filter((param: ReturnType<typeof getAnalyticsConfigV0>['parameters']) =>
param.tags.includes(tag.id)
)
.map((param: ReturnType<typeof getAnalyticsConfigV0>['parameters']) => {
return (
<Param
name={param.title}
type={param.type}
description={param.description}
required={param.required}
/>
{specAnalyticsV0.info.tags.map(
(tag: ReturnType<typeof specAnalyticsV0>['info']['tags']) => {
return (
<>
<h2 className="text-foreground">{tag.title}</h2>
<p className="text-foreground-lighter">{tag.description}</p>
<div className="not-prose">
<h5 className="text-base text-foreground mb-3">Parameters</h5>
<ul>
{specAnalyticsV0.parameters
.filter((param: ReturnType<typeof specAnalyticsV0>['parameters']) =>
param.tags.includes(tag.id)
)
})}
</ul>
</div>
</>
)
})}
.map((param: ReturnType<typeof specAnalyticsV0>['parameters']) => {
return (
<Param
name={param.title}
type={param.type}
description={param.description}
required={param.required}
/>
)
})}
</ul>
</div>
</>
)
}
)}
</div>
</GuideTemplate>
)

View File

@@ -1,7 +1,7 @@
import Param from '~/components/Params'
import { genGuideMeta } from '~/features/docs/GuidesMdx.utils'
import { GuideTemplate, MDXRemoteGuides, newEditLink } from '~/features/docs/GuidesMdx.template'
import { getAuthConfigV1 } from '~/lib/mdx/getConfig'
import specAuthV1 from '~/spec/gotrue_v1_config.yaml' assert { type: 'yml' }
const meta = {
title: 'Auth Self-hosting Config',
@@ -14,8 +14,7 @@ const generateMetadata = genGuideMeta(() => ({
}))
const AuthConfigPage = async () => {
const spec = getAuthConfigV1()
const descriptionMdx = spec.info.description
const descriptionMdx = specAuthV1.info.description
return (
<GuideTemplate
@@ -27,7 +26,7 @@ const AuthConfigPage = async () => {
<MDXRemoteGuides source={descriptionMdx} />
<div>
{spec.info.tags.map((tag: ReturnType<typeof getAuthConfigV1>['info']['tags']) => {
{specAuthV1.info.tags.map((tag: ReturnType<typeof specAuthV1>['info']['tags']) => {
return (
<>
<h2 className="text-foreground">{tag.title}</h2>
@@ -35,11 +34,11 @@ const AuthConfigPage = async () => {
<div className="not-prose">
<h5 className="text-base text-foreground mb-3">Parameters</h5>
<ul>
{spec.parameters
.filter((param: ReturnType<typeof getAuthConfigV1>['parameters']) =>
{specAuthV1.parameters
.filter((param: ReturnType<typeof specAuthV1>['parameters']) =>
param.tags.includes(tag.id)
)
.map((param: ReturnType<typeof getAuthConfigV1>['parameters']) => {
.map((param: ReturnType<typeof specAuthV1>['parameters']) => {
return (
<Param
name={param.title}

View File

@@ -1,7 +1,7 @@
import Param from '~/components/Params'
import { genGuideMeta } from '~/features/docs/GuidesMdx.utils'
import { GuideTemplate, MDXRemoteGuides, newEditLink } from '~/features/docs/GuidesMdx.template'
import { getRealtimeConfigV0 } from '~/lib/mdx/getConfig'
import specRealtimeV0 from '~/spec/realtime_v0_config.yaml' assert { type: 'yml' }
const meta = {
title: 'Realtime Self-hosting Config',
@@ -14,8 +14,7 @@ const generateMetadata = genGuideMeta(() => ({
}))
const RealtimeConfigPage = async () => {
const spec = getRealtimeConfigV0()
const descriptionMdx = spec.info.description
const descriptionMdx = specRealtimeV0.info.description
return (
<GuideTemplate
@@ -27,7 +26,7 @@ const RealtimeConfigPage = async () => {
<MDXRemoteGuides source={descriptionMdx} />
<div>
{spec.info.tags.map((tag: ReturnType<typeof getRealtimeConfigV0>['info']['tags']) => {
{specRealtimeV0.info.tags.map((tag: ReturnType<typeof specRealtimeV0>['info']['tags']) => {
return (
<>
<h2 className="text-foreground">{tag.title}</h2>
@@ -35,11 +34,11 @@ const RealtimeConfigPage = async () => {
<div className="not-prose">
<h5 className="text-base text-foreground mb-3">Parameters</h5>
<ul>
{spec.parameters
.filter((param: ReturnType<typeof getRealtimeConfigV0>['parameters']) =>
{specRealtimeV0.parameters
.filter((param: ReturnType<typeof specRealtimeV0>['parameters']) =>
param.tags.includes(tag.id)
)
.map((param: ReturnType<typeof getRealtimeConfigV0>['parameters']) => {
.map((param: ReturnType<typeof specRealtimeV0>['parameters']) => {
return (
<Param
name={param.title}

View File

@@ -1,7 +1,7 @@
import Param from '~/components/Params'
import { genGuideMeta } from '~/features/docs/GuidesMdx.utils'
import { GuideTemplate, MDXRemoteGuides, newEditLink } from '~/features/docs/GuidesMdx.template'
import { getStorageConfigV0 } from '~/lib/mdx/getConfig'
import specStorageV0 from '~/spec/storage_v0_config.yaml' assert { type: 'yml' }
const meta = {
title: 'Storage Self-hosting Config',
@@ -14,8 +14,7 @@ const generateMetadata = genGuideMeta(() => ({
}))
const StorageConfigPage = async () => {
const spec = getStorageConfigV0()
const descriptionMdx = spec.info.description
const descriptionMdx = specStorageV0.info.description
return (
<GuideTemplate
@@ -27,7 +26,7 @@ const StorageConfigPage = async () => {
<MDXRemoteGuides source={descriptionMdx} />
<div>
{spec.info.tags.map((tag: ReturnType<typeof getStorageConfigV0>['info']['tags']) => {
{specStorageV0.info.tags.map((tag: ReturnType<typeof specStorageV0>['info']['tags']) => {
return (
<>
<h2 className="text-foreground">{tag.title}</h2>
@@ -35,11 +34,11 @@ const StorageConfigPage = async () => {
<div className="not-prose">
<h5 className="text-base text-foreground mb-3">Parameters</h5>
<ul>
{spec.parameters
.filter((param: ReturnType<typeof getStorageConfigV0>['parameters']) =>
{specStorageV0.parameters
.filter((param: ReturnType<typeof specStorageV0>['parameters']) =>
param.tags.includes(tag.id)
)
.map((param: ReturnType<typeof getStorageConfigV0>['parameters']) => {
.map((param: ReturnType<typeof specStorageV0>['parameters']) => {
return (
<Param
name={param.title}

View File

@@ -1,33 +0,0 @@
import specStorageV0 from '~/spec/storage_v0_config.yaml' assert { type: 'yml' }
import specRealtimeV0 from '~/spec/realtime_v0_config.yaml' assert { type: 'yml' }
import specAuthV1 from '~/spec/gotrue_v1_config.yaml' assert { type: 'yml' }
import specAnalyticsV0 from '~/spec/analytics_v0_config.yaml' assert { type: 'yml' }
import specFunctionsV0 from '~/spec/functions_v0_config.yaml' assert { type: 'yml' }
function getStorageConfigV0() {
return { ...specStorageV0 }
}
function getRealtimeConfigV0() {
return { ...specRealtimeV0 }
}
function getAuthConfigV1() {
return { ...specAuthV1 }
}
function getAnalyticsConfigV0() {
return { ...specAnalyticsV0 }
}
function getFunctionsConfigV0() {
return { ...specFunctionsV0 }
}
export {
getStorageConfigV0,
getRealtimeConfigV0,
getAuthConfigV1,
getAnalyticsConfigV0,
getFunctionsConfigV0,
}

View File

@@ -1,6 +1,6 @@
import { Element } from 'hast'
import type { Element } from 'hast'
import { hasProperty } from 'hast-util-has-property'
import { Node } from 'unist'
import type { Node } from 'unist'
import { visit } from 'unist-util-visit'
export type UrlTransformFunction = (url: string, node: Element) => string

View File

@@ -1,7 +1,7 @@
import { Content, Paragraph, Parent } from 'mdast'
import { MdxJsxFlowElement } from 'mdast-util-mdx'
import { AdmonitionProps } from 'ui'
import { Node } from 'unist'
import type { Content, Paragraph, Parent } from 'mdast'
import type { MdxJsxFlowElement } from 'mdast-util-mdx'
import type { AdmonitionProps } from 'ui'
import type { Node } from 'unist'
import { visit } from 'unist-util-visit'
/**

View File

@@ -1,4 +1,4 @@
import { Parent } from 'mdast'
import type { Parent } from 'mdast'
/**
* Removes the top heading from a MD file if

View File

@@ -1,6 +1,6 @@
import { Content, Paragraph, Parent } from 'mdast'
import { MdxJsxFlowElement } from 'mdast-util-mdx'
import { Node } from 'unist'
import type { Content, Paragraph, Parent } from 'mdast'
import type { MdxJsxFlowElement } from 'mdast-util-mdx'
import type { Node } from 'unist'
import { visit } from 'unist-util-visit'
/**

View File

@@ -1,4 +1,4 @@
import { TsDoc } from '../../generator/legacy/definitions'
import type { TsDoc } from '../../generator/legacy/definitions'
import { values, mapValues } from 'lodash'
import type { OpenAPIV3 } from 'openapi-types'

View File

@@ -1,9 +1,9 @@
import { SupabaseClient } from '@supabase/supabase-js'
import type { SupabaseClient } from '@supabase/supabase-js'
import { codeBlock, oneLine } from 'common-tags'
import OpenAI from 'openai'
import type OpenAI from 'openai'
import { ApplicationError, UserError } from './errors'
import { getChatRequestTokenCount, getMaxTokenCount, tokenizer } from './tokenizer'
import { Message } from './types'
import type { Message } from './types'
export async function clippy(
openai: OpenAI,

View File

@@ -1,8 +1,8 @@
import { OpenAIStream } from 'ai'
import { codeBlock, oneLine, stripIndent } from 'common-tags'
import OpenAI from 'openai'
import type OpenAI from 'openai'
import { ContextLengthError } from '../errors'
import { Message } from '../types'
import type { Message } from '../types'
/**
* Responds to a conversation about writing a SQL query.

View File

@@ -1,7 +1,7 @@
import { SchemaBuilder } from '@serafin/schema-builder'
import { codeBlock, stripIndent } from 'common-tags'
import { jsonrepair } from 'jsonrepair'
import OpenAI from 'openai'
import type OpenAI from 'openai'
import { ContextLengthError, EmptyResponseError, EmptySqlError } from '../errors'
const debugSqlSchema = SchemaBuilder.emptySchema()

View File

@@ -1,8 +1,8 @@
import { OpenAIStream } from 'ai'
import { codeBlock, oneLine, stripIndent } from 'common-tags'
import OpenAI from 'openai'
import type OpenAI from 'openai'
import { ContextLengthError } from '../errors'
import { Message } from '../types'
import type { Message } from '../types'
/**
* Responds to a conversation about building an RLS policy.

View File

@@ -1,5 +1,5 @@
import { getEncoding } from 'js-tiktoken'
import OpenAI from 'openai'
import type OpenAI from 'openai'
export const tokenizer = getEncoding('cl100k_base')

View File

@@ -1,5 +1,5 @@
import { EmbeddedTarget, flattenTargets } from '@supabase/sql-to-rest'
import { ResultBundle } from './util'
import type { ResultBundle } from './util'
export type Assumption = {
id: string

View File

@@ -1,4 +1,4 @@
import { HttpRequest, Statement, SupabaseJsQuery } from '@supabase/sql-to-rest'
import type { HttpRequest, Statement, SupabaseJsQuery } from '@supabase/sql-to-rest'
export type BaseResult = {
statement: Statement