mirror of
https://github.com/supabase/supabase.git
synced 2026-05-06 22:18:00 +08:00
studio: add sql provenance trackingot ai assistant + reports
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { acceptUntrustedSql } from '@supabase/pg-meta'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { useParams } from 'common'
|
||||
import { X } from 'lucide-react'
|
||||
@@ -104,7 +105,10 @@ export const ReportBlock = ({
|
||||
return executeSql({
|
||||
projectRef,
|
||||
connectionString,
|
||||
sql,
|
||||
// acceptUntrustedSql is usually not allowed in an auto-run position,
|
||||
// but in this case we are explicitly allowing it because adding a block
|
||||
// to a report is an explicit user action.
|
||||
sql: acceptUntrustedSql(sql),
|
||||
})
|
||||
},
|
||||
enabled: !isLoadingContent && contentError == null,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { acceptUntrustedSql, type UntrustedSqlFragment } from '@supabase/pg-meta'
|
||||
import { PermissionAction } from '@supabase/shared-types/out/constants'
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
import { useParams } from 'common'
|
||||
@@ -22,7 +23,7 @@ interface DisplayBlockRendererProps {
|
||||
messageId: string
|
||||
toolCallId: string
|
||||
initialArgs: {
|
||||
sql: string
|
||||
sql: UntrustedSqlFragment
|
||||
label?: string
|
||||
isWriteQuery?: boolean
|
||||
view?: 'table' | 'chart'
|
||||
@@ -163,7 +164,7 @@ export const DisplayBlockRenderer = ({
|
||||
setIsWriteQuery(true)
|
||||
}
|
||||
executeSql(
|
||||
{ projectRef: ref, connectionString, sql: sqlQuery },
|
||||
{ projectRef: ref, connectionString, sql: acceptUntrustedSql(sqlQuery) },
|
||||
{
|
||||
onSuccess: (data) => {
|
||||
setRows(Array.isArray(data.result) ? data.result : undefined)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { untrustedSql } from '@supabase/pg-meta'
|
||||
import { z, type SafeParseReturnType } from 'zod'
|
||||
|
||||
// Splits markdown into alternating [plain, code, plain, code, ...] segments.
|
||||
@@ -81,7 +82,7 @@ const executeSqlChartResultSchema = z
|
||||
const chartArgs = chartConfig ?? config
|
||||
|
||||
return {
|
||||
sql: sql ?? '',
|
||||
sql: untrustedSql(sql ?? ''),
|
||||
label,
|
||||
isWriteQuery,
|
||||
view: chartArgs?.view,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { untrustedSql } from '@supabase/pg-meta'
|
||||
import dynamic from 'next/dynamic'
|
||||
import Link from 'next/link'
|
||||
import {
|
||||
@@ -265,7 +266,7 @@ export const MarkdownPre = ({
|
||||
messageId={id}
|
||||
toolCallId={toolCallId}
|
||||
initialArgs={{
|
||||
sql: cleanContent,
|
||||
sql: untrustedSql(cleanContent),
|
||||
label: title,
|
||||
isWriteQuery: false,
|
||||
view: isChart ? 'chart' : 'table',
|
||||
|
||||
Reference in New Issue
Block a user