mirror of
https://github.com/supabase/supabase.git
synced 2026-07-05 17:04:33 +08:00
* fix * fix type issues * fix type err * fix type error 2 the return of the type * fix type error 3 tokyo drift
26 lines
745 B
TypeScript
26 lines
745 B
TypeScript
import { UseQueryOptions } from '@tanstack/react-query'
|
|
import { Content, ContentData, ContentError, useContentQuery } from 'data/content/content-query'
|
|
|
|
export type SqlSnippet = Extract<Content, { type: 'sql' | 'log_sql' | 'report' }>
|
|
|
|
export type SqlSnippets = {
|
|
snippets: SqlSnippet[]
|
|
}
|
|
|
|
function filterSqlContent(content: Content): content is Extract<Content, { type: 'sql' }> {
|
|
return content.type === 'sql'
|
|
}
|
|
|
|
export const useSqlSnippetsQuery = (
|
|
projectRef: string | undefined,
|
|
options: UseQueryOptions<ContentData, ContentError, SqlSnippets> = {}
|
|
) =>
|
|
useContentQuery<SqlSnippets>(projectRef, {
|
|
select: (data) => {
|
|
return {
|
|
snippets: data.content.filter(filterSqlContent),
|
|
}
|
|
},
|
|
...options,
|
|
})
|