mirror of
https://github.com/supabase/supabase.git
synced 2026-05-06 08:56:46 -04:00
chore(studio}: enforce import order, remove bare import specifiers (#44585)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
import { useIsQueueOperationsEnabled } from 'components/interfaces/Account/Preferences/useDashboardSettings'
|
||||
|
||||
import { useOperationQueueActions } from './useOperationQueueActions'
|
||||
import { useIsQueueOperationsEnabled } from '@/components/interfaces/Account/Preferences/useDashboardSettings'
|
||||
import { tableRowKeys } from '@/data/table-rows/keys'
|
||||
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
||||
import { useHotKey } from '@/hooks/ui/useHotKey'
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { zodResolver } from '@hookform/resolvers/zod'
|
||||
import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
|
||||
import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
|
||||
import { useForm } from 'react-hook-form'
|
||||
import { toast } from 'sonner'
|
||||
import { Card, Form_Shadcn_ } from 'ui'
|
||||
@@ -8,6 +6,8 @@ import * as z from 'zod'
|
||||
|
||||
import { DashboardToggle } from './DashboardToggle'
|
||||
import { useIsInlineEditorSetting, useIsQueueOperationsSetting } from './useDashboardSettings'
|
||||
import { useSendEventMutation } from '@/data/telemetry/send-event-mutation'
|
||||
import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
|
||||
|
||||
const DashboardSettingsSchema = z.object({
|
||||
inlineEditorEnabled: z.boolean(),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { LOCAL_STORAGE_KEYS } from 'common'
|
||||
import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage'
|
||||
|
||||
import { useLocalStorageQuery } from '@/hooks/misc/useLocalStorage'
|
||||
|
||||
export const useIsInlineEditorSetting = () => {
|
||||
const [inlineEditorEnabled, setInlineEditorEnabled] = useLocalStorageQuery(
|
||||
|
||||
@@ -3,20 +3,6 @@ import { loadStripe, StripeAddressElement, StripeElementsOptions } from '@stripe
|
||||
import { PermissionAction } from '@supabase/shared-types/out/constants'
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
import { useFlag } from 'common'
|
||||
import {
|
||||
getAddressElementAppearanceOptions,
|
||||
STRIPE_ELEMENT_FONTS,
|
||||
} from 'components/interfaces/Billing/Payment/Payment.utils'
|
||||
import { BillingCustomerDataForm } from 'components/interfaces/Organization/BillingSettings/BillingCustomerData/BillingCustomerDataForm'
|
||||
import { useBillingCustomerDataForm } from 'components/interfaces/Organization/BillingSettings/BillingCustomerData/useBillingCustomerDataForm'
|
||||
import { useOrganizationCustomerProfileQuery } from 'data/organizations/organization-customer-profile-query'
|
||||
import { useOrganizationCustomerProfileUpdateMutation } from 'data/organizations/organization-customer-profile-update-mutation'
|
||||
import { useOrganizationTaxIdQuery } from 'data/organizations/organization-tax-id-query'
|
||||
import { useOrganizationTaxIdUpdateMutation } from 'data/organizations/organization-tax-id-update-mutation'
|
||||
import { invalidateOrganizationsQuery } from 'data/organizations/organizations-query'
|
||||
import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions'
|
||||
import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
|
||||
import { IS_PLATFORM, STRIPE_PUBLIC_KEY } from 'lib/constants'
|
||||
import { useTheme } from 'next-themes'
|
||||
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { toast } from 'sonner'
|
||||
@@ -33,6 +19,21 @@ import {
|
||||
} from 'ui'
|
||||
import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
|
||||
|
||||
import {
|
||||
getAddressElementAppearanceOptions,
|
||||
STRIPE_ELEMENT_FONTS,
|
||||
} from '@/components/interfaces/Billing/Payment/Payment.utils'
|
||||
import { BillingCustomerDataForm } from '@/components/interfaces/Organization/BillingSettings/BillingCustomerData/BillingCustomerDataForm'
|
||||
import { useBillingCustomerDataForm } from '@/components/interfaces/Organization/BillingSettings/BillingCustomerData/useBillingCustomerDataForm'
|
||||
import { useOrganizationCustomerProfileQuery } from '@/data/organizations/organization-customer-profile-query'
|
||||
import { useOrganizationCustomerProfileUpdateMutation } from '@/data/organizations/organization-customer-profile-update-mutation'
|
||||
import { useOrganizationTaxIdQuery } from '@/data/organizations/organization-tax-id-query'
|
||||
import { useOrganizationTaxIdUpdateMutation } from '@/data/organizations/organization-tax-id-update-mutation'
|
||||
import { invalidateOrganizationsQuery } from '@/data/organizations/organizations-query'
|
||||
import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
|
||||
import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
|
||||
import { IS_PLATFORM, STRIPE_PUBLIC_KEY } from '@/lib/constants'
|
||||
|
||||
const stripePromise = loadStripe(STRIPE_PUBLIC_KEY)
|
||||
|
||||
export function UpdateBillingAddressModal() {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { fireEvent, screen, waitFor } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import { toast } from 'sonner'
|
||||
import { render } from 'tests/helpers'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import { AddNewURLModal } from './AddNewURLModal'
|
||||
import { render } from '@/tests/helpers'
|
||||
|
||||
const { mutateMock, useAuthConfigUpdateMutationMock } = vi.hoisted(() => ({
|
||||
mutateMock: vi.fn(),
|
||||
@@ -20,7 +20,7 @@ vi.mock(import('common'), async (importOriginal) => {
|
||||
}
|
||||
})
|
||||
|
||||
vi.mock('data/auth/auth-config-update-mutation', () => ({
|
||||
vi.mock('@/data/auth/auth-config-update-mutation', () => ({
|
||||
useAuthConfigUpdateMutation: useAuthConfigUpdateMutationMock,
|
||||
}))
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { Appearance, CustomFontSource } from '@stripe/stripe-js'
|
||||
import { CUSTOM_FONT_BOOK_DATA_URL } from 'fonts/stripe-fonts'
|
||||
|
||||
import { CUSTOM_FONT_BOOK_DATA_URL } from '@/fonts/stripe-fonts'
|
||||
|
||||
/**
|
||||
* Custom font for Stripe Elements iframes.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { zodResolver } from '@hookform/resolvers/zod'
|
||||
import { type DatabaseExtension } from 'data/database-extensions/database-extensions-query'
|
||||
import { useForm } from 'react-hook-form'
|
||||
import { toast } from 'sonner'
|
||||
import {
|
||||
@@ -31,6 +30,7 @@ import * as z from 'zod'
|
||||
import { extensionsWithRecommendedSchemas } from './Extensions.constants'
|
||||
import { DocsButton } from '@/components/ui/DocsButton'
|
||||
import { useDatabaseExtensionEnableMutation } from '@/data/database-extensions/database-extension-enable-mutation'
|
||||
import { type DatabaseExtension } from '@/data/database-extensions/database-extensions-query'
|
||||
import { useSchemasQuery } from '@/data/database/schemas-query'
|
||||
import { useIsOrioleDb, useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
||||
import { useProtectedSchemas } from '@/hooks/useProtectedSchemas'
|
||||
|
||||
@@ -1,15 +1,5 @@
|
||||
import { SupportCategories } from '@supabase/shared-types/out/constants'
|
||||
import { useParams } from 'common'
|
||||
import { SupportLink } from 'components/interfaces/Support/SupportLink'
|
||||
import { DocsButton } from 'components/ui/DocsButton'
|
||||
import { InlineLink } from 'components/ui/InlineLink'
|
||||
import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query'
|
||||
import { useCheckEntitlements } from 'hooks/misc/useCheckEntitlements'
|
||||
import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'
|
||||
import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
|
||||
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
|
||||
import { getCloudProviderArchitecture } from 'lib/cloudprovider-utils'
|
||||
import { DOCS_URL } from 'lib/constants'
|
||||
import { ChevronRight, CpuIcon, Lock, Microchip } from 'lucide-react'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { UseFormReturn } from 'react-hook-form'
|
||||
@@ -37,6 +27,16 @@ import {
|
||||
import { BillingChangeBadge } from '../ui/BillingChangeBadge'
|
||||
import FormMessage from '../ui/FormMessage'
|
||||
import { NoticeBar } from '../ui/NoticeBar'
|
||||
import { SupportLink } from '@/components/interfaces/Support/SupportLink'
|
||||
import { DocsButton } from '@/components/ui/DocsButton'
|
||||
import { InlineLink } from '@/components/ui/InlineLink'
|
||||
import { useProjectAddonsQuery } from '@/data/subscriptions/project-addons-query'
|
||||
import { useCheckEntitlements } from '@/hooks/misc/useCheckEntitlements'
|
||||
import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
|
||||
import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
|
||||
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
||||
import { getCloudProviderArchitecture } from '@/lib/cloudprovider-utils'
|
||||
import { DOCS_URL } from '@/lib/constants'
|
||||
|
||||
const INITIALLY_VISIBLE_COUNT = 6
|
||||
|
||||
|
||||
@@ -5,14 +5,14 @@ import { ErrorMatcher } from './ErrorMatcher'
|
||||
import { ConnectionTimeoutError } from '@/types/api-errors'
|
||||
import { ResponseError } from '@/types/base'
|
||||
|
||||
vi.mock('lib/telemetry/track', () => ({ useTrack: () => vi.fn() }))
|
||||
vi.mock('state/ai-assistant-state', () => ({
|
||||
vi.mock('@/lib/telemetry/track', () => ({ useTrack: () => vi.fn() }))
|
||||
vi.mock('@/state/ai-assistant-state', () => ({
|
||||
useAiAssistantStateSnapshot: () => ({ newChat: vi.fn() }),
|
||||
}))
|
||||
vi.mock('state/sidebar-manager-state', () => ({
|
||||
vi.mock('@/state/sidebar-manager-state', () => ({
|
||||
useSidebarManagerSnapshot: () => ({ openSidebar: vi.fn() }),
|
||||
}))
|
||||
vi.mock('components/layouts/ProjectLayout/LayoutSidebar/LayoutSidebarProvider', () => ({
|
||||
vi.mock('@/components/layouts/ProjectLayout/LayoutSidebar/LayoutSidebarProvider', () => ({
|
||||
SIDEBAR_KEYS: { AI_ASSISTANT: 'ai-assistant' },
|
||||
}))
|
||||
vi.mock('./RestartProjectDialog', () => ({
|
||||
|
||||
+2
-2
@@ -1,7 +1,5 @@
|
||||
import AlertError from 'components/ui/AlertError'
|
||||
import type { ComponentProps } from 'react'
|
||||
import { useMemo } from 'react'
|
||||
import type { ChartIntervals } from 'types'
|
||||
import { Button } from 'ui'
|
||||
import { Chart, ChartActions, ChartLoadingState, ChartMetric } from 'ui-patterns/Chart'
|
||||
import { PageContainer } from 'ui-patterns/PageContainer'
|
||||
@@ -24,6 +22,8 @@ import {
|
||||
} from './EdgeFunctionOverview.utils'
|
||||
import type { InvocationChartDatum, InvocationUpdateAnnotation } from './EdgeFunctionOverview.utils'
|
||||
import { toAlertError } from './EdgeFunctionRecentErrors.utils'
|
||||
import AlertError from '@/components/ui/AlertError'
|
||||
import type { ChartIntervals } from '@/types'
|
||||
|
||||
interface EdgeFunctionInvocationsSectionProps {
|
||||
interval: string
|
||||
|
||||
+9
-9
@@ -1,14 +1,5 @@
|
||||
import { PermissionAction } from '@supabase/shared-types/out/constants'
|
||||
import { IS_PLATFORM, useParams } from 'common'
|
||||
import { useUnifiedLogsPreview } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'
|
||||
import NoPermission from 'components/ui/NoPermission'
|
||||
import {
|
||||
FunctionsCombinedStatsVariables,
|
||||
useFunctionsCombinedStatsQuery,
|
||||
} from 'data/analytics/functions-combined-stats-query'
|
||||
import { useEdgeFunctionQuery } from 'data/edge-functions/edge-function-query'
|
||||
import { useFillTimeseriesSorted } from 'hooks/analytics/useFillTimeseriesSorted'
|
||||
import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions'
|
||||
import { ExternalLink } from 'lucide-react'
|
||||
import { useRouter } from 'next/router'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
@@ -29,6 +20,15 @@ import type { EdgeFunctionChartRawDatum } from './EdgeFunctionOverview.utils'
|
||||
import { EdgeFunctionPerformanceSection } from './EdgeFunctionPerformanceSection'
|
||||
import { EdgeFunctionRecentErrors } from './EdgeFunctionRecentErrors'
|
||||
import { EdgeFunctionUsageSection } from './EdgeFunctionUsageSection'
|
||||
import { useUnifiedLogsPreview } from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext'
|
||||
import NoPermission from '@/components/ui/NoPermission'
|
||||
import {
|
||||
FunctionsCombinedStatsVariables,
|
||||
useFunctionsCombinedStatsQuery,
|
||||
} from '@/data/analytics/functions-combined-stats-query'
|
||||
import { useEdgeFunctionQuery } from '@/data/edge-functions/edge-function-query'
|
||||
import { useFillTimeseriesSorted } from '@/hooks/analytics/useFillTimeseriesSorted'
|
||||
import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
|
||||
|
||||
export const EdgeFunctionOverview = () => {
|
||||
const router = useRouter()
|
||||
|
||||
+2
-1
@@ -2,9 +2,10 @@ import dayjs from 'dayjs'
|
||||
import maxBy from 'lodash/maxBy'
|
||||
import meanBy from 'lodash/meanBy'
|
||||
import sumBy from 'lodash/sumBy'
|
||||
import type { ChartIntervals } from 'types'
|
||||
import type { ChartConfig } from 'ui'
|
||||
|
||||
import type { ChartIntervals } from '@/types'
|
||||
|
||||
export type EdgeFunctionChartRawDatum = {
|
||||
timestamp: string | number
|
||||
success_count?: string | number
|
||||
|
||||
+4
-4
@@ -1,7 +1,3 @@
|
||||
import { SIDEBAR_KEYS } from 'components/layouts/ProjectLayout/LayoutSidebar/LayoutSidebarProvider'
|
||||
import { AiAssistantDropdown } from 'components/ui/AiAssistantDropdown'
|
||||
import AlertError from 'components/ui/AlertError'
|
||||
import useLogsQuery from 'hooks/analytics/useLogsQuery'
|
||||
import { ExternalLink } from 'lucide-react'
|
||||
import { useRouter } from 'next/router'
|
||||
import { Fragment, useMemo } from 'react'
|
||||
@@ -41,6 +37,10 @@ import {
|
||||
toAlertError,
|
||||
type RecentErrorGroup,
|
||||
} from './EdgeFunctionRecentErrors.utils'
|
||||
import { SIDEBAR_KEYS } from '@/components/layouts/ProjectLayout/LayoutSidebar/LayoutSidebarProvider'
|
||||
import { AiAssistantDropdown } from '@/components/ui/AiAssistantDropdown'
|
||||
import AlertError from '@/components/ui/AlertError'
|
||||
import useLogsQuery from '@/hooks/analytics/useLogsQuery'
|
||||
import { useAiAssistantStateSnapshot } from '@/state/ai-assistant-state'
|
||||
import { useSidebarManagerSnapshot } from '@/state/sidebar-manager-state'
|
||||
|
||||
|
||||
+8
-8
@@ -1,15 +1,15 @@
|
||||
import { LOGS_TABLES } from 'components/interfaces/Settings/Logs/Logs.constants'
|
||||
import type { LogData } from 'components/interfaces/Settings/Logs/Logs.types'
|
||||
import {
|
||||
genDefaultQuery,
|
||||
isUnixMicro,
|
||||
unixMicroToIsoTimestamp,
|
||||
} from 'components/interfaces/Settings/Logs/Logs.utils'
|
||||
import type { AlertErrorProps } from 'components/ui/AlertError'
|
||||
import dayjs from 'dayjs'
|
||||
import relativeTime from 'dayjs/plugin/relativeTime'
|
||||
|
||||
import { parseEdgeFunctionEventMessage } from '../EdgeFunctionRecentInvocations.utils'
|
||||
import { LOGS_TABLES } from '@/components/interfaces/Settings/Logs/Logs.constants'
|
||||
import type { LogData } from '@/components/interfaces/Settings/Logs/Logs.types'
|
||||
import {
|
||||
genDefaultQuery,
|
||||
isUnixMicro,
|
||||
unixMicroToIsoTimestamp,
|
||||
} from '@/components/interfaces/Settings/Logs/Logs.utils'
|
||||
import type { AlertErrorProps } from '@/components/ui/AlertError'
|
||||
|
||||
dayjs.extend(relativeTime)
|
||||
|
||||
|
||||
+3
-3
@@ -1,10 +1,10 @@
|
||||
import { screen } from '@testing-library/dom'
|
||||
import { mockAnimationsApi } from 'jsdom-testing-mocks'
|
||||
import { customRender } from 'tests/lib/custom-render'
|
||||
import { routerMock } from 'tests/lib/route-mock'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import { IntegrationOverviewTab } from './IntegrationOverviewTab'
|
||||
import { customRender } from '@/tests/lib/custom-render'
|
||||
import { routerMock } from '@/tests/lib/route-mock'
|
||||
|
||||
mockAnimationsApi()
|
||||
|
||||
@@ -31,7 +31,7 @@ vi.mock('framer-motion', async (importOriginal) => {
|
||||
|
||||
const mockExtensions = vi.fn()
|
||||
|
||||
vi.mock('data/database-extensions/database-extensions-query', () => ({
|
||||
vi.mock('@/data/database-extensions/database-extensions-query', () => ({
|
||||
useDatabaseExtensionsQuery: () => ({ data: mockExtensions() }),
|
||||
}))
|
||||
|
||||
|
||||
+2
-2
@@ -1,12 +1,12 @@
|
||||
import { fireEvent, screen, waitFor } from '@testing-library/dom'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import { mockAnimationsApi } from 'jsdom-testing-mocks'
|
||||
import { customRender } from 'tests/lib/custom-render'
|
||||
import { routerMock } from 'tests/lib/route-mock'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import { IntegrationDefinition } from '../../Landing/Integrations.constants'
|
||||
import { InstallIntegrationSheet } from './InstallIntegrationSheet/InstallIntegrationSheet'
|
||||
import { customRender } from '@/tests/lib/custom-render'
|
||||
import { routerMock } from '@/tests/lib/route-mock'
|
||||
|
||||
mockAnimationsApi()
|
||||
|
||||
|
||||
+5
-5
@@ -1,8 +1,3 @@
|
||||
import { extensionsWithRecommendedSchemas } from 'components/interfaces/Database/Extensions/Extensions.constants'
|
||||
import { useDatabaseExtensionsQuery } from 'data/database-extensions/database-extensions-query'
|
||||
import { useSchemasQuery } from 'data/database/schemas-query'
|
||||
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
|
||||
import { useProtectedSchemas } from 'hooks/useProtectedSchemas'
|
||||
import { type Dispatch, type SetStateAction } from 'react'
|
||||
import {
|
||||
Accordion_Shadcn_,
|
||||
@@ -23,6 +18,11 @@ import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
|
||||
|
||||
import { getExtensionDefaultSchema } from '../IntegrationOverviewTabV2.utils'
|
||||
import { type ExtensionsSchema, type InstallIntegrationSheetProps } from './InstallIntegrationSheet'
|
||||
import { extensionsWithRecommendedSchemas } from '@/components/interfaces/Database/Extensions/Extensions.constants'
|
||||
import { useDatabaseExtensionsQuery } from '@/data/database-extensions/database-extensions-query'
|
||||
import { useSchemasQuery } from '@/data/database/schemas-query'
|
||||
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
||||
import { useProtectedSchemas } from '@/hooks/useProtectedSchemas'
|
||||
|
||||
type AdvancedSettingsProps = InstallIntegrationSheetProps & {
|
||||
extensionsSchema: ExtensionsSchema
|
||||
|
||||
+2
-2
@@ -1,6 +1,4 @@
|
||||
import { zodResolver } from '@hookform/resolvers/zod'
|
||||
import { type IntegrationDefinition } from 'components/interfaces/Integrations/Landing/Integrations.constants'
|
||||
import { useTrack } from 'lib/telemetry/track'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { SubmitHandler, useForm } from 'react-hook-form'
|
||||
import { toast } from 'sonner'
|
||||
@@ -23,12 +21,14 @@ import { getExtensionDefaultSchema } from '../IntegrationOverviewTabV2.utils'
|
||||
import { AdvancedSettings } from './AdvancedSettings'
|
||||
import { InstallationOverview } from './InstallationOverview'
|
||||
import { InstallationSettings } from './InstallationSettings'
|
||||
import { type IntegrationDefinition } from '@/components/interfaces/Integrations/Landing/Integrations.constants'
|
||||
import { useDatabaseExtensionEnableMutation } from '@/data/database-extensions/database-extension-enable-mutation'
|
||||
import {
|
||||
DatabaseExtension,
|
||||
useDatabaseExtensionsQuery,
|
||||
} from '@/data/database-extensions/database-extensions-query'
|
||||
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
||||
import { useTrack } from '@/lib/telemetry/track'
|
||||
import { ResponseError } from '@/types'
|
||||
|
||||
export interface InstallIntegrationSheetProps {
|
||||
|
||||
+3
-3
@@ -1,6 +1,3 @@
|
||||
import { Markdown } from 'components/interfaces/Markdown'
|
||||
import { useDatabaseExtensionsQuery } from 'data/database-extensions/database-extensions-query'
|
||||
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
|
||||
import {
|
||||
Badge,
|
||||
Card,
|
||||
@@ -16,6 +13,9 @@ import { CodeBlock } from 'ui-patterns/CodeBlock'
|
||||
|
||||
import { getEnableExtensionsSQL } from '../IntegrationOverviewTabV2.utils'
|
||||
import { type ExtensionsSchema, type InstallIntegrationSheetProps } from './InstallIntegrationSheet'
|
||||
import { Markdown } from '@/components/interfaces/Markdown'
|
||||
import { useDatabaseExtensionsQuery } from '@/data/database-extensions/database-extensions-query'
|
||||
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
||||
|
||||
export const InstallationOverview = ({
|
||||
integration,
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ export const MarkdownContent = ({
|
||||
|
||||
useEffect(() => {
|
||||
if (!!integrationId && !content) {
|
||||
import(`static-data/integrations/${integrationId}/overview.md`)
|
||||
import(`@/static-data/integrations/${integrationId}/overview.md`)
|
||||
.then((module) => setLocalContent(String(module.default)))
|
||||
.catch((error) => console.error('Error loading markdown:', error))
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ export const MarkdownContent = ({
|
||||
const [isExpanded, setIsExpanded] = useState(initiallyExpanded ?? false)
|
||||
|
||||
useEffect(() => {
|
||||
import(`static-data/integrations/${integrationId}/overview.md`)
|
||||
import(`@/static-data/integrations/${integrationId}/overview.md`)
|
||||
.then((module) => setContent(String(module.default)))
|
||||
.catch((error) => console.error('Error loading markdown:', error))
|
||||
}, [integrationId])
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
import { getEnableWebhooksSQL } from '@supabase/pg-meta'
|
||||
import { stripeSyncKeys } from 'data/database-integrations/stripe/keys'
|
||||
import { installStripeSync } from 'data/database-integrations/stripe/stripe-sync-install-mutation'
|
||||
import { databaseKeys } from 'data/database/keys'
|
||||
import { useTrack } from 'lib/telemetry/track'
|
||||
import { Clock5, Code2, Layers, Timer, Vault, Webhook } from 'lucide-react'
|
||||
import dynamic from 'next/dynamic'
|
||||
import Image from 'next/image'
|
||||
@@ -14,10 +10,14 @@ import { UpgradeDatabaseAlert } from '../Queues/UpgradeDatabaseAlert'
|
||||
import { getStripeSyncSchemaComment } from '../templates/StripeSyncEngine/useStripeSyncStatus'
|
||||
import { WRAPPERS } from '../Wrappers/Wrappers.constants'
|
||||
import { WrapperMeta } from '../Wrappers/Wrappers.types'
|
||||
import { stripeSyncKeys } from '@/data/database-integrations/stripe/keys'
|
||||
import { installStripeSync } from '@/data/database-integrations/stripe/stripe-sync-install-mutation'
|
||||
import { enableDatabaseWebhooks } from '@/data/database/hooks-enable-mutation'
|
||||
import { databaseKeys } from '@/data/database/keys'
|
||||
import { getSchemas, invalidateSchemasQuery } from '@/data/database/schemas-query'
|
||||
import { getQueryClient } from '@/data/query-client'
|
||||
import { BASE_PATH, DOCS_URL } from '@/lib/constants'
|
||||
import { useTrack } from '@/lib/telemetry/track'
|
||||
|
||||
export type Navigation = {
|
||||
route: string
|
||||
@@ -528,7 +528,7 @@ const TEMPLATE_INTEGRATIONS: Array<IntegrationDefinition> = [
|
||||
case 'overview':
|
||||
return dynamic(
|
||||
() =>
|
||||
import('components/interfaces/Integrations/templates/StripeSyncEngine/OverviewTab').then(
|
||||
import('@/components/interfaces/Integrations/templates/StripeSyncEngine/OverviewTab').then(
|
||||
(mod) => mod.StripeSyncEngineOverviewTab
|
||||
),
|
||||
{ loading: Loading }
|
||||
|
||||
+1
-1
@@ -1,4 +1,3 @@
|
||||
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
|
||||
import { useEffect } from 'react'
|
||||
import { getCurrentVersion, parseSchemaComment } from 'stripe-experiment-sync/supabase'
|
||||
|
||||
@@ -10,6 +9,7 @@ import {
|
||||
} from '@/components/interfaces/Integrations/templates/StripeSyncEngine/stripe-sync-status'
|
||||
import { useStripeSyncingState } from '@/data/database-integrations/stripe/sync-state-query'
|
||||
import { Schema, useSchemasQuery } from '@/data/database/schemas-query'
|
||||
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
||||
|
||||
// Maximum time allowed for installation or uninstallation operations before the UI times out
|
||||
const OPERATION_TIME_OUT_MS: number = 5 * 60 * 1000 // 5 minutes
|
||||
|
||||
@@ -44,13 +44,13 @@ vi.mock('next-themes', () => ({
|
||||
}),
|
||||
}))
|
||||
|
||||
vi.mock('state/app-state', () => ({
|
||||
vi.mock('@/state/app-state', () => ({
|
||||
useAppStateSnapshot: () => ({
|
||||
setLastRouteBeforeVisitingAccountPage: mockSetLastRoute,
|
||||
}),
|
||||
}))
|
||||
|
||||
vi.mock('components/ui/ProfileImage', () => ({
|
||||
vi.mock('@/components/ui/ProfileImage', () => ({
|
||||
ProfileImage: () => <div>Avatar</div>,
|
||||
}))
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ import { FlaskConical, Settings } from 'lucide-react'
|
||||
import { useTheme } from 'next-themes'
|
||||
import Link from 'next/link'
|
||||
import { useRouter } from 'next/router'
|
||||
import { useAppStateSnapshot } from 'state/app-state'
|
||||
import {
|
||||
Button,
|
||||
cn,
|
||||
@@ -22,6 +21,7 @@ import {
|
||||
import { ButtonTooltip } from '../ui/ButtonTooltip'
|
||||
import { useFeaturePreviewModal } from './App/FeaturePreview/FeaturePreviewContext'
|
||||
import { ProfileImage } from '@/components/ui/ProfileImage'
|
||||
import { useAppStateSnapshot } from '@/state/app-state'
|
||||
|
||||
export const LocalDropdown = ({
|
||||
triggerClassName,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { fireEvent, screen, waitFor } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import type { ComponentProps } from 'react'
|
||||
import { render } from 'tests/helpers'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import { LogDrainDestinationSheetForm } from './LogDrainDestinationSheetForm'
|
||||
import { render } from '@/tests/helpers'
|
||||
|
||||
const { trackMock, useFlagMock, useLogDrainsQueryMock, useParamsMock, useTrackMock } = vi.hoisted(
|
||||
() => ({
|
||||
@@ -27,7 +27,7 @@ vi.mock(import('common'), async (importOriginal) => {
|
||||
}
|
||||
})
|
||||
|
||||
vi.mock(import('data/log-drains/log-drains-query'), async (importOriginal) => {
|
||||
vi.mock(import('@/data/log-drains/log-drains-query'), async (importOriginal) => {
|
||||
const actual = await importOriginal()
|
||||
|
||||
return {
|
||||
@@ -36,7 +36,7 @@ vi.mock(import('data/log-drains/log-drains-query'), async (importOriginal) => {
|
||||
}
|
||||
})
|
||||
|
||||
vi.mock('lib/telemetry/track', () => ({
|
||||
vi.mock('@/lib/telemetry/track', () => ({
|
||||
useTrack: useTrackMock,
|
||||
}))
|
||||
|
||||
|
||||
+20
-20
@@ -3,26 +3,6 @@ import { loadStripe, StripeAddressElement, StripeElementsOptions } from '@stripe
|
||||
import { PermissionAction } from '@supabase/shared-types/out/constants'
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
import { useParams } from 'common'
|
||||
import {
|
||||
getAddressElementAppearanceOptions,
|
||||
STRIPE_ELEMENT_FONTS,
|
||||
} from 'components/interfaces/Billing/Payment/Payment.utils'
|
||||
import {
|
||||
ScaffoldSection,
|
||||
ScaffoldSectionContent,
|
||||
ScaffoldSectionDetail,
|
||||
} from 'components/layouts/Scaffold'
|
||||
import AlertError from 'components/ui/AlertError'
|
||||
import NoPermission from 'components/ui/NoPermission'
|
||||
import PartnerManagedResource from 'components/ui/PartnerManagedResource'
|
||||
import { organizationKeys } from 'data/organizations/keys'
|
||||
import { useOrganizationCustomerProfileQuery } from 'data/organizations/organization-customer-profile-query'
|
||||
import { useOrganizationCustomerProfileUpdateMutation } from 'data/organizations/organization-customer-profile-update-mutation'
|
||||
import { useOrganizationTaxIdQuery } from 'data/organizations/organization-tax-id-query'
|
||||
import { useOrganizationTaxIdUpdateMutation } from 'data/organizations/organization-tax-id-update-mutation'
|
||||
import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions'
|
||||
import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
|
||||
import { STRIPE_PUBLIC_KEY } from 'lib/constants'
|
||||
import { useTheme } from 'next-themes'
|
||||
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { toast } from 'sonner'
|
||||
@@ -31,6 +11,26 @@ import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
|
||||
|
||||
import { BillingCustomerDataForm } from './BillingCustomerDataForm'
|
||||
import { useBillingCustomerDataForm } from './useBillingCustomerDataForm'
|
||||
import {
|
||||
getAddressElementAppearanceOptions,
|
||||
STRIPE_ELEMENT_FONTS,
|
||||
} from '@/components/interfaces/Billing/Payment/Payment.utils'
|
||||
import {
|
||||
ScaffoldSection,
|
||||
ScaffoldSectionContent,
|
||||
ScaffoldSectionDetail,
|
||||
} from '@/components/layouts/Scaffold'
|
||||
import AlertError from '@/components/ui/AlertError'
|
||||
import NoPermission from '@/components/ui/NoPermission'
|
||||
import PartnerManagedResource from '@/components/ui/PartnerManagedResource'
|
||||
import { organizationKeys } from '@/data/organizations/keys'
|
||||
import { useOrganizationCustomerProfileQuery } from '@/data/organizations/organization-customer-profile-query'
|
||||
import { useOrganizationCustomerProfileUpdateMutation } from '@/data/organizations/organization-customer-profile-update-mutation'
|
||||
import { useOrganizationTaxIdQuery } from '@/data/organizations/organization-tax-id-query'
|
||||
import { useOrganizationTaxIdUpdateMutation } from '@/data/organizations/organization-tax-id-update-mutation'
|
||||
import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
|
||||
import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
|
||||
import { STRIPE_PUBLIC_KEY } from '@/lib/constants'
|
||||
|
||||
const stripePromise = loadStripe(STRIPE_PUBLIC_KEY)
|
||||
|
||||
|
||||
+1
-1
@@ -4,13 +4,13 @@ import type {
|
||||
StripeAddressElementChangeEvent,
|
||||
StripeAddressElementOptions,
|
||||
} from '@stripe/stripe-js'
|
||||
import type { CustomerAddress, CustomerTaxId } from 'data/organizations/types'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { useForm } from 'react-hook-form'
|
||||
|
||||
import { TaxIdFormValues, TaxIdSchema } from './BillingCustomerDataForm'
|
||||
import { TAX_IDS } from './TaxID.constants'
|
||||
import { getEffectiveTaxCountry, resolveStoredTaxId, sanitizeTaxIdValue } from './TaxID.utils'
|
||||
import type { CustomerAddress, CustomerTaxId } from '@/data/organizations/types'
|
||||
|
||||
type StripeAddressValue = StripeAddressElementChangeEvent['value']
|
||||
type StripeAddressValidationState = 'unknown' | 'complete' | 'incomplete'
|
||||
|
||||
+3
-2
@@ -1,7 +1,8 @@
|
||||
import { getComputeSize } from 'data/projects/org-projects-infinite-query'
|
||||
import type { OrgProject } from 'data/projects/org-projects-infinite-query'
|
||||
import { Checkbox_Shadcn_ } from 'ui'
|
||||
|
||||
import { getComputeSize } from '@/data/projects/org-projects-infinite-query'
|
||||
import type { OrgProject } from '@/data/projects/org-projects-infinite-query'
|
||||
|
||||
type Props = {
|
||||
projects: OrgProject[]
|
||||
checkedProjects: Record<string, boolean>
|
||||
|
||||
+2
-2
@@ -6,11 +6,11 @@ import { describe, expect, it, vi } from 'vitest'
|
||||
import { PLATFORM_WEBHOOKS_MOCK_DATA } from './PlatformWebhooks.mock'
|
||||
import { PlatformWebhooksEndpointDetails } from './PlatformWebhooksEndpointDetails'
|
||||
|
||||
vi.mock('components/ui/DataTable/DataTableColumn/DataTableColumnStatusCode', () => ({
|
||||
vi.mock('@/components/ui/DataTable/DataTableColumn/DataTableColumnStatusCode', () => ({
|
||||
DataTableColumnStatusCode: ({ value }: { value: number }) => <span>{value}</span>,
|
||||
}))
|
||||
|
||||
vi.mock('components/ui/ButtonTooltip', () => ({
|
||||
vi.mock('@/components/ui/ButtonTooltip', () => ({
|
||||
ButtonTooltip: ({
|
||||
icon,
|
||||
children,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { DOCS_URL } from 'lib/constants'
|
||||
import { ArrowRight } from 'lucide-react'
|
||||
import Link from 'next/link'
|
||||
import { cn, HoverCard, HoverCardContent, HoverCardTrigger, Separator } from 'ui'
|
||||
|
||||
import { ServerLightGrid } from './ServerLightGrid'
|
||||
import { DOCS_URL } from '@/lib/constants'
|
||||
|
||||
interface HighAvailabilityBadgeProps {
|
||||
size?: 'default' | 'small'
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
import { ReactFlowProvider } from '@xyflow/react'
|
||||
import { ActivityStats } from 'components/interfaces/ProjectHome/ActivityStats'
|
||||
import { ProjectConnectionPopover } from 'components/interfaces/ProjectHome/ProjectConnectionPopover'
|
||||
import { ProjectPausedState } from 'components/layouts/ProjectLayout/PausedState/ProjectPausedState'
|
||||
import { ComputeBadgeWrapper } from 'components/ui/ComputeBadgeWrapper'
|
||||
import { InlineLink } from 'components/ui/InlineLink'
|
||||
import { ProjectUpgradeFailedBanner } from 'components/ui/ProjectUpgradeFailedBanner'
|
||||
import { useBranchesQuery } from 'data/branches/branches-query'
|
||||
import { useProjectDetailQuery } from 'data/projects/project-detail-query'
|
||||
import { useResourceWarningsQuery } from 'data/usage/resource-warnings-query'
|
||||
import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
|
||||
import { useIsOrioleDb, useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
|
||||
import { DOCS_URL, PROJECT_STATUS } from 'lib/constants'
|
||||
import Link from 'next/link'
|
||||
import { Badge, cn, Tooltip, TooltipContent, TooltipTrigger } from 'ui'
|
||||
|
||||
import { InstanceConfiguration } from '../Settings/Infrastructure/InfrastructureConfiguration/InstanceConfiguration'
|
||||
import { HighAvailabilityBadge } from './HighAvailabilityBadge'
|
||||
import { ActivityStats } from '@/components/interfaces/ProjectHome/ActivityStats'
|
||||
import { ProjectConnectionPopover } from '@/components/interfaces/ProjectHome/ProjectConnectionPopover'
|
||||
import { ProjectPausedState } from '@/components/layouts/ProjectLayout/PausedState/ProjectPausedState'
|
||||
import { ComputeBadgeWrapper } from '@/components/ui/ComputeBadgeWrapper'
|
||||
import { InlineLink } from '@/components/ui/InlineLink'
|
||||
import { ProjectUpgradeFailedBanner } from '@/components/ui/ProjectUpgradeFailedBanner'
|
||||
import { useBranchesQuery } from '@/data/branches/branches-query'
|
||||
import { useProjectDetailQuery } from '@/data/projects/project-detail-query'
|
||||
import { useResourceWarningsQuery } from '@/data/usage/resource-warnings-query'
|
||||
import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
|
||||
import { useIsOrioleDb, useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
||||
import { DOCS_URL, PROJECT_STATUS } from '@/lib/constants'
|
||||
|
||||
export const TopSection = () => {
|
||||
const isOrioleDb = useIsOrioleDb()
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { ident } from '@supabase/pg-meta/src/pg-format'
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
||||
import { databasePoliciesKeys } from 'data/database-policies/keys'
|
||||
import { storageKeys } from 'data/storage/keys'
|
||||
import { useState, type ReactNode } from 'react'
|
||||
import { toast } from 'sonner'
|
||||
import { Button } from 'ui'
|
||||
@@ -9,7 +7,9 @@ import { Admonition } from 'ui-patterns/admonition'
|
||||
import { CodeBlock } from 'ui-patterns/CodeBlock'
|
||||
import { ConfirmationModal } from 'ui-patterns/Dialogs/ConfirmationModal'
|
||||
|
||||
import { databasePoliciesKeys } from '@/data/database-policies/keys'
|
||||
import { executeSql } from '@/data/sql/execute-sql-query'
|
||||
import { storageKeys } from '@/data/storage/keys'
|
||||
import { usePublicBucketsWithSelectPoliciesQuery } from '@/data/storage/public-buckets-with-select-policies-query'
|
||||
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
||||
|
||||
|
||||
+5
-5
@@ -20,17 +20,17 @@ const {
|
||||
mockUseStoragePreference: vi.fn(),
|
||||
}))
|
||||
|
||||
vi.mock('lib/telemetry/track', () => ({ useTrack: () => mockTrack }))
|
||||
vi.mock('state/storage-explorer', () => ({
|
||||
vi.mock('@/lib/telemetry/track', () => ({ useTrack: () => mockTrack }))
|
||||
vi.mock('@/state/storage-explorer', () => ({
|
||||
useStorageExplorerStateSnapshot: () => mockUseStorageExplorerStateSnapshot(),
|
||||
}))
|
||||
vi.mock('hooks/misc/useCheckPermissions', () => ({
|
||||
vi.mock('@/hooks/misc/useCheckPermissions', () => ({
|
||||
useAsyncCheckPermissions: () => mockUseAsyncCheckPermissions(),
|
||||
}))
|
||||
vi.mock('components/interfaces/App/FeaturePreview/FeaturePreviewContext', () => ({
|
||||
vi.mock('@/components/interfaces/App/FeaturePreview/FeaturePreviewContext', () => ({
|
||||
useIsAPIDocsSidePanelEnabled: () => mockIsAPIDocsSidePanelEnabled(),
|
||||
}))
|
||||
vi.mock('components/ui/APIDocsButton', () => ({
|
||||
vi.mock('@/components/ui/APIDocsButton', () => ({
|
||||
APIDocsButton: () => null,
|
||||
}))
|
||||
vi.mock('./useStoragePreference', () => ({
|
||||
|
||||
@@ -118,7 +118,7 @@ vi.mock('sonner', () => ({
|
||||
},
|
||||
}))
|
||||
|
||||
vi.mock('data/utils/deployment-commit-query', () => ({
|
||||
vi.mock('@/data/utils/deployment-commit-query', () => ({
|
||||
useDeploymentCommitQuery: mockUseDeploymentCommitQuery,
|
||||
}))
|
||||
|
||||
|
||||
+6
-6
@@ -16,26 +16,26 @@ const mockToastError = vi.fn()
|
||||
const mockFetchQuery = vi.fn()
|
||||
|
||||
// Setup mocks before imports
|
||||
vi.mock('data/query-client', () => ({
|
||||
vi.mock('@/data/query-client', () => ({
|
||||
getQueryClient: () => ({
|
||||
fetchQuery: mockFetchQuery,
|
||||
}),
|
||||
}))
|
||||
|
||||
vi.mock('data/sql/execute-sql-query', () => ({
|
||||
vi.mock('@/data/sql/execute-sql-query', () => ({
|
||||
executeSql: (...args: unknown[]) => mockExecuteSql(...args),
|
||||
}))
|
||||
|
||||
vi.mock('data/tables/table-retrieve-query', () => ({
|
||||
vi.mock('@/data/tables/table-retrieve-query', () => ({
|
||||
getTable: (...args: unknown[]) => mockGetTable(...args),
|
||||
getTableQuery: (...args: unknown[]) => mockGetTable(...args),
|
||||
}))
|
||||
|
||||
vi.mock('data/telemetry/send-event-mutation', () => ({
|
||||
vi.mock('@/data/telemetry/send-event-mutation', () => ({
|
||||
sendEvent: (...args: unknown[]) => mockSendEvent(...args),
|
||||
}))
|
||||
|
||||
vi.mock('data/prefetchers/project.$ref.editor.$id', () => ({
|
||||
vi.mock('@/data/prefetchers/project.$ref.editor.$id', () => ({
|
||||
prefetchEditorTablePage: (...args: unknown[]) => mockPrefetchEditorTablePage(...args),
|
||||
}))
|
||||
|
||||
@@ -48,7 +48,7 @@ vi.mock('sonner', () => ({
|
||||
}))
|
||||
|
||||
// Mock SparkBar component used in toast
|
||||
vi.mock('components/ui/SparkBar', () => ({
|
||||
vi.mock('@/components/ui/SparkBar', () => ({
|
||||
default: () => null,
|
||||
}))
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ const { mockRouter, mockRegisterOpenMenu, mockSetMobileSheetContent } = vi.hoist
|
||||
mockSetMobileSheetContent: vi.fn(),
|
||||
}))
|
||||
|
||||
vi.mock('lib/constants', async () => {
|
||||
const actual = await vi.importActual<Record<string, unknown>>('lib/constants')
|
||||
vi.mock('@/lib/constants', async () => {
|
||||
const actual = await vi.importActual<Record<string, unknown>>('@/lib/constants')
|
||||
return {
|
||||
...actual,
|
||||
IS_PLATFORM: false,
|
||||
@@ -46,23 +46,23 @@ vi.mock('next/head', async () => {
|
||||
return { default: Head }
|
||||
})
|
||||
|
||||
vi.mock('hooks/custom-content/useCustomContent', () => ({
|
||||
vi.mock('@/hooks/custom-content/useCustomContent', () => ({
|
||||
useCustomContent: () => ({ appTitle: 'Supabase' }),
|
||||
}))
|
||||
|
||||
vi.mock('hooks/misc/useIsFeatureEnabled', () => ({
|
||||
vi.mock('@/hooks/misc/useIsFeatureEnabled', () => ({
|
||||
useIsFeatureEnabled: () => false,
|
||||
}))
|
||||
|
||||
vi.mock('hooks/misc/useLocalStorage', () => ({
|
||||
vi.mock('@/hooks/misc/useLocalStorage', () => ({
|
||||
useLocalStorageQuery: () => [''],
|
||||
}))
|
||||
|
||||
vi.mock('hooks/misc/withAuth', () => ({
|
||||
vi.mock('@/hooks/misc/withAuth', () => ({
|
||||
withAuth: <T,>(Component: T) => Component,
|
||||
}))
|
||||
|
||||
vi.mock('state/app-state', () => ({
|
||||
vi.mock('@/state/app-state', () => ({
|
||||
useAppStateSnapshot: () => ({
|
||||
lastRouteBeforeVisitingAccountPage: '',
|
||||
}),
|
||||
|
||||
@@ -9,15 +9,15 @@ import { sidebarManagerState } from '@/state/sidebar-manager-state'
|
||||
import { render } from '@/tests/helpers'
|
||||
import { routerMock } from '@/tests/lib/route-mock'
|
||||
|
||||
vi.mock('components/ui/AIAssistantPanel/AIAssistant', () => ({
|
||||
vi.mock('@/components/ui/AIAssistantPanel/AIAssistant', () => ({
|
||||
AIAssistant: () => <div data-testid="ai-assistant-sidebar">AI Assistant</div>,
|
||||
}))
|
||||
|
||||
vi.mock('components/ui/EditorPanel/EditorPanel', () => ({
|
||||
vi.mock('@/components/ui/EditorPanel/EditorPanel', () => ({
|
||||
EditorPanel: () => <div data-testid="editor-panel-sidebar">Editor Panel</div>,
|
||||
}))
|
||||
|
||||
vi.mock('components/ui/AdvisorPanel/AdvisorPanel', () => ({
|
||||
vi.mock('@/components/ui/AdvisorPanel/AdvisorPanel', () => ({
|
||||
AdvisorPanel: () => <div data-testid="advisor-panel-sidebar">Advisor Panel</div>,
|
||||
}))
|
||||
|
||||
@@ -47,7 +47,7 @@ const mockProject = {
|
||||
|
||||
let mockProjectData: typeof mockProject | undefined = mockProject
|
||||
|
||||
vi.mock('hooks/misc/useSelectedProject', () => ({
|
||||
vi.mock('@/hooks/misc/useSelectedProject', () => ({
|
||||
useSelectedProjectQuery: () => {
|
||||
// Access the variable at runtime when the function is called
|
||||
return {
|
||||
@@ -56,7 +56,7 @@ vi.mock('hooks/misc/useSelectedProject', () => ({
|
||||
},
|
||||
}))
|
||||
|
||||
vi.mock('hooks/misc/useSelectedOrganization', () => ({
|
||||
vi.mock('@/hooks/misc/useSelectedOrganization', () => ({
|
||||
useSelectedOrganizationQuery: () => ({
|
||||
data: {
|
||||
id: 1,
|
||||
@@ -79,7 +79,7 @@ vi.mock('hooks/misc/useSelectedOrganization', () => ({
|
||||
}),
|
||||
}))
|
||||
|
||||
vi.mock('data/telemetry/send-event-mutation', () => ({
|
||||
vi.mock('@/data/telemetry/send-event-mutation', () => ({
|
||||
useSendEventMutation: () => ({
|
||||
mutate: vi.fn(),
|
||||
}),
|
||||
|
||||
@@ -166,7 +166,7 @@ vi.mock('@/components/ui/BannerStack/Banners/BannerFreeMicroUpgrade', () => ({
|
||||
BannerFreeMicroUpgrade: () => null,
|
||||
}))
|
||||
|
||||
vi.mock('data/usage/resource-warnings-query', () => ({
|
||||
vi.mock('@/data/usage/resource-warnings-query', () => ({
|
||||
useResourceWarningsQuery: () => ({ data: mockResourceWarningsState.current }),
|
||||
}))
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { LOCAL_STORAGE_KEYS, mergeRefs, useParams } from 'common'
|
||||
import { useResourceWarningsQuery } from 'data/usage/resource-warnings-query'
|
||||
import { AnimatePresence, motion } from 'framer-motion'
|
||||
import Head from 'next/head'
|
||||
import { useRouter } from 'next/router'
|
||||
@@ -42,6 +41,7 @@ import { ProjectAPIDocs } from '@/components/interfaces/ProjectAPIDocs/ProjectAP
|
||||
import { BannerFreeMicroUpgrade } from '@/components/ui/BannerStack/Banners/BannerFreeMicroUpgrade'
|
||||
import { BANNER_ID, useBannerStack } from '@/components/ui/BannerStack/BannerStackProvider'
|
||||
import { ResourceExhaustionWarningBanner } from '@/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner'
|
||||
import { useResourceWarningsQuery } from '@/data/usage/resource-warnings-query'
|
||||
import { useCustomContent } from '@/hooks/custom-content/useCustomContent'
|
||||
import { useLocalStorageQuery } from '@/hooks/misc/useLocalStorage'
|
||||
import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
|
||||
|
||||
+2
-2
@@ -3,8 +3,8 @@ import { describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import { useGenerateSettingsMenu } from './SettingsMenu.utils'
|
||||
|
||||
vi.mock('lib/constants', async () => {
|
||||
const actual = await vi.importActual<Record<string, unknown>>('lib/constants')
|
||||
vi.mock('@/lib/constants', async () => {
|
||||
const actual = await vi.importActual<Record<string, unknown>>('@/lib/constants')
|
||||
return {
|
||||
...actual,
|
||||
IS_PLATFORM: false,
|
||||
|
||||
@@ -5,8 +5,8 @@ import { describe, expect, it, vi } from 'vitest'
|
||||
import { useGenerateSettingsMenu } from './SettingsMenu.utils'
|
||||
import { useIsPlatformWebhooksEnabled } from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext'
|
||||
|
||||
vi.mock('lib/constants', async () => {
|
||||
const actual = await vi.importActual<Record<string, unknown>>('lib/constants')
|
||||
vi.mock('@/lib/constants', async () => {
|
||||
const actual = await vi.importActual<Record<string, unknown>>('@/lib/constants')
|
||||
return {
|
||||
...actual,
|
||||
IS_PLATFORM: true,
|
||||
|
||||
@@ -32,7 +32,7 @@ vi.mock('next/navigation', () => ({
|
||||
usePathname: () => '/project/default/editor/1',
|
||||
}))
|
||||
|
||||
vi.mock('state/tabs', () => ({
|
||||
vi.mock('@/state/tabs', () => ({
|
||||
useTabsStateSnapshot: () => mockTabsState,
|
||||
}))
|
||||
|
||||
|
||||
@@ -207,14 +207,14 @@ export const AIEditor = ({
|
||||
if (language === 'javascript' || language === 'typescript') {
|
||||
// The Deno libs are loaded as a raw text via raw-loader in next.config.js. They're passed as raw text to the
|
||||
// Monaco editor.
|
||||
import('public/deno/edge-runtime.d.ts' as string)
|
||||
import('@/public/deno/edge-runtime.d.ts' as string)
|
||||
.then((module) => {
|
||||
monaco.languages.typescript.typescriptDefaults.addExtraLib(module.default)
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Failed to load Deno edge-runtime typings:', error)
|
||||
})
|
||||
import('public/deno/lib.deno.d.ts' as string)
|
||||
import('@/public/deno/lib.deno.d.ts' as string)
|
||||
.then((module) => {
|
||||
monaco.languages.typescript.typescriptDefaults.addExtraLib(module.default)
|
||||
})
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { LOCAL_STORAGE_KEYS } from 'common'
|
||||
import { useParams } from 'common/hooks'
|
||||
import { ChevronsUpAnimated } from 'components/ui/ComputeBadgeWrapper'
|
||||
import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage'
|
||||
import { useTrack } from 'lib/telemetry/track'
|
||||
import Link from 'next/link'
|
||||
import { Button } from 'ui'
|
||||
import { ComputeBadge } from 'ui-patterns/ComputeBadge'
|
||||
|
||||
import { BannerCard } from '../BannerCard'
|
||||
import { BANNER_ID, useBannerStack } from '../BannerStackProvider'
|
||||
import { ChevronsUpAnimated } from '@/components/ui/ComputeBadgeWrapper'
|
||||
import { useLocalStorageQuery } from '@/hooks/misc/useLocalStorage'
|
||||
import { useTrack } from '@/lib/telemetry/track'
|
||||
|
||||
export const BannerFreeMicroUpgrade = () => {
|
||||
const { ref } = useParams()
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
import { getAddons } from 'components/interfaces/Billing/Subscription/Subscription.utils'
|
||||
import { ProjectDetail } from 'data/projects/project-detail-query'
|
||||
import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'
|
||||
import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query'
|
||||
import { ProjectAddonVariantMeta } from 'data/subscriptions/types'
|
||||
import { ResourceWarning } from 'data/usage/resource-warnings-query'
|
||||
import { getCloudProviderArchitecture } from 'lib/cloudprovider-utils'
|
||||
import { INSTANCE_MICRO_SPECS } from 'lib/constants'
|
||||
import { useTrack } from 'lib/telemetry/track'
|
||||
import Link from 'next/link'
|
||||
import { useState } from 'react'
|
||||
import { Button, cn, HoverCard, HoverCardContent, HoverCardTrigger, Separator } from 'ui'
|
||||
import { ComputeBadge } from 'ui-patterns/ComputeBadge'
|
||||
import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
|
||||
|
||||
import { getAddons } from '@/components/interfaces/Billing/Subscription/Subscription.utils'
|
||||
import { ProjectDetail } from '@/data/projects/project-detail-query'
|
||||
import { useOrgSubscriptionQuery } from '@/data/subscriptions/org-subscription-query'
|
||||
import { useProjectAddonsQuery } from '@/data/subscriptions/project-addons-query'
|
||||
import { ProjectAddonVariantMeta } from '@/data/subscriptions/types'
|
||||
import { ResourceWarning } from '@/data/usage/resource-warnings-query'
|
||||
import { getCloudProviderArchitecture } from '@/lib/cloudprovider-utils'
|
||||
import { INSTANCE_MICRO_SPECS } from '@/lib/constants'
|
||||
import { useTrack } from '@/lib/telemetry/track'
|
||||
|
||||
export const ChevronsUpAnimated = () => (
|
||||
<svg
|
||||
width={10}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import { getOrgDailyStats } from './org-daily-stats-query'
|
||||
|
||||
vi.mock('data/fetchers', () => ({
|
||||
vi.mock('@/data/fetchers', () => ({
|
||||
get: vi.fn(),
|
||||
handleError: vi.fn((error) => {
|
||||
throw error
|
||||
@@ -46,7 +46,7 @@ describe('org-daily-stats-query', () => {
|
||||
})
|
||||
|
||||
it('calls API with correct parameters including project_ref', async () => {
|
||||
const { get } = await import('data/fetchers')
|
||||
const { get } = await import('@/data/fetchers')
|
||||
const mockGet = get as unknown as ReturnType<typeof vi.fn>
|
||||
|
||||
const mockResponse = { usages: [] }
|
||||
@@ -76,7 +76,7 @@ describe('org-daily-stats-query', () => {
|
||||
})
|
||||
|
||||
it('calls API without project_ref when not provided', async () => {
|
||||
const { get } = await import('data/fetchers')
|
||||
const { get } = await import('@/data/fetchers')
|
||||
const mockGet = get as unknown as ReturnType<typeof vi.fn>
|
||||
|
||||
const mockResponse = { usages: [] }
|
||||
@@ -104,7 +104,7 @@ describe('org-daily-stats-query', () => {
|
||||
})
|
||||
|
||||
it('handles API errors correctly', async () => {
|
||||
const { get, handleError } = await import('data/fetchers')
|
||||
const { get, handleError } = await import('@/data/fetchers')
|
||||
const mockGet = get as unknown as ReturnType<typeof vi.fn>
|
||||
const mockHandleError = handleError as unknown as ReturnType<typeof vi.fn>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { getEdgeFunctionsLastHourStats } from './edge-functions-last-hour-stats-query'
|
||||
import { post } from '@/data/fetchers'
|
||||
|
||||
vi.mock('data/fetchers', () => ({
|
||||
vi.mock('@/data/fetchers', () => ({
|
||||
post: vi.fn(),
|
||||
handleError: vi.fn(),
|
||||
}))
|
||||
|
||||
@@ -5,8 +5,8 @@ import { ResponseError } from '@/types/base'
|
||||
|
||||
vi.mock('@sentry/nextjs', () => ({ captureException: vi.fn() }))
|
||||
vi.mock('common', () => ({ IS_PLATFORM: false, getAccessToken: vi.fn() }))
|
||||
vi.mock('lib/constants', () => ({ API_URL: 'http://localhost' }))
|
||||
vi.mock('lib/helpers', () => ({ uuidv4: () => 'test-uuid' }))
|
||||
vi.mock('@/lib/constants', () => ({ API_URL: 'http://localhost' }))
|
||||
vi.mock('@/lib/helpers', () => ({ uuidv4: () => 'test-uuid' }))
|
||||
|
||||
// Import after mocks are set up
|
||||
const { handleError } = await import('./fetchers')
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { components } from 'api-types'
|
||||
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
|
||||
|
||||
import { lintKeys } from './keys'
|
||||
import { get, handleError } from '@/data/fetchers'
|
||||
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
||||
import { PROJECT_STATUS } from '@/lib/constants'
|
||||
import type { ResponseError, UseCustomQueryOptions } from '@/types'
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
|
||||
|
||||
import { orgSSOKeys } from './keys'
|
||||
import { get, handleError } from '@/data/fetchers'
|
||||
import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
|
||||
import { IS_PLATFORM } from '@/lib/constants'
|
||||
import type { ResponseError, UseCustomQueryOptions } from '@/types'
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { literal } from '@supabase/pg-meta/src/pg-format'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { executeSql } from 'data/sql/execute-sql-query'
|
||||
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
|
||||
import { PROJECT_STATUS } from 'lib/constants'
|
||||
import type { ResponseError, UseCustomQueryOptions } from 'types'
|
||||
|
||||
import { storageKeys } from './keys'
|
||||
import { executeSql } from '@/data/sql/execute-sql-query'
|
||||
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
||||
import { PROJECT_STATUS } from '@/lib/constants'
|
||||
import type { ResponseError, UseCustomQueryOptions } from '@/types'
|
||||
|
||||
export type PublicBucketsWithSelectPoliciesVariables = {
|
||||
projectRef?: string
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import type { UseCustomQueryOptions } from 'types'
|
||||
|
||||
import { executeSql, ExecuteSqlError } from '../sql/execute-sql-query'
|
||||
import { tableKeys } from './keys'
|
||||
import type { UseCustomQueryOptions } from '@/types'
|
||||
|
||||
export type TableName = {
|
||||
id: number
|
||||
|
||||
@@ -2,7 +2,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import { getOrgUsage } from './org-usage-query'
|
||||
|
||||
vi.mock('data/fetchers', () => ({
|
||||
vi.mock('@/data/fetchers', () => ({
|
||||
get: vi.fn(),
|
||||
handleError: vi.fn((error) => {
|
||||
throw error
|
||||
@@ -20,7 +20,7 @@ describe('org-usage-query', () => {
|
||||
})
|
||||
|
||||
it('calls API with correct parameters including project_ref', async () => {
|
||||
const { get } = await import('data/fetchers')
|
||||
const { get } = await import('@/data/fetchers')
|
||||
const mockGet = get as unknown as ReturnType<typeof vi.fn>
|
||||
|
||||
const mockResponse = { usages: [] }
|
||||
@@ -53,7 +53,7 @@ describe('org-usage-query', () => {
|
||||
})
|
||||
|
||||
it('calls API without project_ref when projectRef is null', async () => {
|
||||
const { get } = await import('data/fetchers')
|
||||
const { get } = await import('@/data/fetchers')
|
||||
const mockGet = get as unknown as ReturnType<typeof vi.fn>
|
||||
|
||||
const mockResponse = { usages: [] }
|
||||
@@ -80,7 +80,7 @@ describe('org-usage-query', () => {
|
||||
})
|
||||
|
||||
it('calls API without date params when start and end are undefined', async () => {
|
||||
const { get } = await import('data/fetchers')
|
||||
const { get } = await import('@/data/fetchers')
|
||||
const mockGet = get as unknown as ReturnType<typeof vi.fn>
|
||||
|
||||
const mockResponse = { usages: [] }
|
||||
@@ -106,7 +106,7 @@ describe('org-usage-query', () => {
|
||||
})
|
||||
|
||||
it('handles API errors correctly', async () => {
|
||||
const { get, handleError } = await import('data/fetchers')
|
||||
const { get, handleError } = await import('@/data/fetchers')
|
||||
const mockGet = get as unknown as ReturnType<typeof vi.fn>
|
||||
const mockHandleError = handleError as unknown as ReturnType<typeof vi.fn>
|
||||
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
import assert from 'node:assert'
|
||||
import { Eval } from 'braintrust'
|
||||
import { getModel } from 'lib/ai/model'
|
||||
import { DEFAULT_ASSISTANT_BASE_MODEL_ID, getAssistantModelEntry } from 'lib/ai/model.utils'
|
||||
import { generateAssistantResponse } from 'lib/ai/generate-assistant-response'
|
||||
import { getMockTools } from 'lib/ai/tools/mock-tools'
|
||||
|
||||
import { dataset } from './dataset'
|
||||
import { buildAssistantEvalOutput } from './output'
|
||||
@@ -18,6 +14,10 @@ import {
|
||||
urlValidityScorer,
|
||||
} from './scorer'
|
||||
import { sqlIdentifierQuotingScorer, sqlSyntaxScorer } from './scorer-wasm'
|
||||
import { generateAssistantResponse } from '@/lib/ai/generate-assistant-response'
|
||||
import { getModel } from '@/lib/ai/model'
|
||||
import { DEFAULT_ASSISTANT_BASE_MODEL_ID, getAssistantModelEntry } from '@/lib/ai/model.utils'
|
||||
import { getMockTools } from '@/lib/ai/tools/mock-tools'
|
||||
|
||||
assert(process.env.BRAINTRUST_PROJECT_ID, 'BRAINTRUST_PROJECT_ID is not set')
|
||||
assert(process.env.OPENAI_API_KEY, 'OPENAI_API_KEY is not set')
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { type ToolSet, type TypedToolCall, type TypedToolResult } from 'ai'
|
||||
|
||||
import { type AssistantEvalOutput } from './scorer'
|
||||
|
||||
type Step = {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { EvalScorer } from 'braintrust'
|
||||
import { extractIdentifiers, isQuotedInSql, needsQuoting } from 'lib/sql-identifier-quoting'
|
||||
import { parse } from 'libpg-query'
|
||||
|
||||
import { AssistantEvalInput, AssistantEvalOutput, Expected } from './scorer'
|
||||
import { extractIdentifiers, isQuotedInSql, needsQuoting } from '@/lib/sql-identifier-quoting'
|
||||
|
||||
export const sqlSyntaxScorer: EvalScorer<
|
||||
AssistantEvalInput,
|
||||
|
||||
@@ -2,7 +2,8 @@ import { FinishReason } from 'ai'
|
||||
import { LLMClassifierFromTemplate } from 'autoevals'
|
||||
import { EvalCase, EvalScorer } from 'braintrust'
|
||||
import { stripIndent } from 'common-tags'
|
||||
import { extractUrls } from 'lib/helpers'
|
||||
|
||||
import { extractUrls } from '@/lib/helpers'
|
||||
|
||||
const LLM_AS_A_JUDGE_MODEL = 'gpt-5.2' // NOTE: `gpt-5.2-2025-12-11` snapshot not yet working with online scorers
|
||||
|
||||
|
||||
@@ -5,8 +5,9 @@
|
||||
import * as Sentry from '@sentry/nextjs'
|
||||
import { hasConsented } from 'common'
|
||||
import { IS_PLATFORM } from 'common/constants/environment'
|
||||
import { MIRRORED_BREADCRUMBS } from 'lib/breadcrumbs'
|
||||
import { sanitizeArrayOfObjects, sanitizeUrlHashParams } from 'lib/sanitize'
|
||||
|
||||
import { MIRRORED_BREADCRUMBS } from '@/lib/breadcrumbs'
|
||||
import { sanitizeArrayOfObjects, sanitizeUrlHashParams } from '@/lib/sanitize'
|
||||
|
||||
const DEFAULT_ERROR_SAMPLE_RATE = 1.0
|
||||
const LOW_PRIORITY_ERROR_SAMPLE_RATE = 0.01
|
||||
|
||||
@@ -2,35 +2,35 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import { getOrgAIDetails, getProjectAIDetails } from './ai-details'
|
||||
|
||||
vi.mock('data/organizations/organizations-query', () => ({
|
||||
vi.mock('@/data/organizations/organizations-query', () => ({
|
||||
getOrganizations: vi.fn(),
|
||||
}))
|
||||
|
||||
vi.mock('data/projects/project-detail-query', () => ({
|
||||
vi.mock('@/data/projects/project-detail-query', () => ({
|
||||
getProjectDetail: vi.fn(),
|
||||
}))
|
||||
|
||||
vi.mock('data/subscriptions/org-subscription-query', () => ({
|
||||
vi.mock('@/data/subscriptions/org-subscription-query', () => ({
|
||||
getOrgSubscription: vi.fn(),
|
||||
}))
|
||||
|
||||
vi.mock('data/config/project-settings-v2-query', () => ({
|
||||
vi.mock('@/data/config/project-settings-v2-query', () => ({
|
||||
getProjectSettings: vi.fn(),
|
||||
}))
|
||||
|
||||
vi.mock('hooks/misc/useOrgOptedIntoAi', () => ({
|
||||
vi.mock('@/hooks/misc/useOrgOptedIntoAi', () => ({
|
||||
getAiOptInLevel: vi.fn(),
|
||||
}))
|
||||
|
||||
vi.mock('components/interfaces/Billing/Subscription/Subscription.utils', () => ({
|
||||
vi.mock('@/components/interfaces/Billing/Subscription/Subscription.utils', () => ({
|
||||
subscriptionHasHipaaAddon: vi.fn(),
|
||||
}))
|
||||
|
||||
vi.mock('data/entitlements/entitlements-query', () => ({
|
||||
vi.mock('@/data/entitlements/entitlements-query', () => ({
|
||||
checkEntitlement: vi.fn(),
|
||||
}))
|
||||
|
||||
vi.mock('data/fetchers', () => ({
|
||||
vi.mock('@/data/fetchers', () => ({
|
||||
get: vi.fn(),
|
||||
}))
|
||||
|
||||
@@ -48,13 +48,13 @@ describe('getOrgAIDetails', () => {
|
||||
beforeEach(async () => {
|
||||
vi.clearAllMocks()
|
||||
|
||||
const orgsQuery = await import('data/organizations/organizations-query')
|
||||
const subscriptionQuery = await import('data/subscriptions/org-subscription-query')
|
||||
const aiHook = await import('hooks/misc/useOrgOptedIntoAi')
|
||||
const orgsQuery = await import('@/data/organizations/organizations-query')
|
||||
const subscriptionQuery = await import('@/data/subscriptions/org-subscription-query')
|
||||
const aiHook = await import('@/hooks/misc/useOrgOptedIntoAi')
|
||||
const subscriptionUtils =
|
||||
await import('components/interfaces/Billing/Subscription/Subscription.utils')
|
||||
const entitlementsQuery = await import('data/entitlements/entitlements-query')
|
||||
const fetchers = await import('data/fetchers')
|
||||
await import('@/components/interfaces/Billing/Subscription/Subscription.utils')
|
||||
const entitlementsQuery = await import('@/data/entitlements/entitlements-query')
|
||||
const fetchers = await import('@/data/fetchers')
|
||||
|
||||
mockGetOrganizations = vi.mocked(orgsQuery.getOrganizations)
|
||||
mockGetOrgSubscription = vi.mocked(subscriptionQuery.getOrgSubscription)
|
||||
@@ -180,8 +180,8 @@ describe('getProjectAIDetails', () => {
|
||||
beforeEach(async () => {
|
||||
vi.clearAllMocks()
|
||||
|
||||
const projectQuery = await import('data/projects/project-detail-query')
|
||||
const settingsQuery = await import('data/config/project-settings-v2-query')
|
||||
const projectQuery = await import('@/data/projects/project-detail-query')
|
||||
const settingsQuery = await import('@/data/config/project-settings-v2-query')
|
||||
|
||||
mockGetProjectDetail = vi.mocked(projectQuery.getProjectDetail)
|
||||
mockGetProjectSettings = vi.mocked(settingsQuery.getProjectSettings)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { subscriptionHasHipaaAddon } from 'components/interfaces/Billing/Subscription/Subscription.utils'
|
||||
import { getProjectSettings } from 'data/config/project-settings-v2-query'
|
||||
import { checkEntitlement } from 'data/entitlements/entitlements-query'
|
||||
import { get } from 'data/fetchers'
|
||||
import { getOrganizations } from 'data/organizations/organizations-query'
|
||||
import { getProjectDetail } from 'data/projects/project-detail-query'
|
||||
import { getOrgSubscription } from 'data/subscriptions/org-subscription-query'
|
||||
import { getAiOptInLevel } from 'hooks/misc/useOrgOptedIntoAi'
|
||||
import { subscriptionHasHipaaAddon } from '@/components/interfaces/Billing/Subscription/Subscription.utils'
|
||||
import { getProjectSettings } from '@/data/config/project-settings-v2-query'
|
||||
import { checkEntitlement } from '@/data/entitlements/entitlements-query'
|
||||
import { get } from '@/data/fetchers'
|
||||
import { getOrganizations } from '@/data/organizations/organizations-query'
|
||||
import { getProjectDetail } from '@/data/projects/project-detail-query'
|
||||
import { getOrgSubscription } from '@/data/subscriptions/org-subscription-query'
|
||||
import { getAiOptInLevel } from '@/hooks/misc/useOrgOptedIntoAi'
|
||||
|
||||
export const getOrgAIDetails = async ({
|
||||
orgSlug,
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { createAmazonBedrock } from '@ai-sdk/amazon-bedrock'
|
||||
import { LanguageModel } from 'ai'
|
||||
import { createCredentialChain, fromNodeProviderChain } from '@aws-sdk/credential-providers'
|
||||
import { CredentialsProviderError } from '@smithy/property-provider'
|
||||
import { awsCredentialsProvider } from '@vercel/functions/oidc'
|
||||
import { selectWeightedKey } from './util'
|
||||
import { LanguageModel } from 'ai'
|
||||
|
||||
import { BedrockModel } from './model.utils'
|
||||
import { selectWeightedKey } from './util'
|
||||
|
||||
const credentialProvider = createCredentialChain(
|
||||
// Vercel OIDC provider will be used for staging/production
|
||||
|
||||
@@ -10,12 +10,13 @@ import {
|
||||
} from 'ai'
|
||||
import { startSpan, traced, withCurrent, wrapAISDK, type Span } from 'braintrust'
|
||||
import { source } from 'common-tags'
|
||||
import { buildAssistantEvalOutput } from 'evals/output'
|
||||
import type { AssistantEvalInput, AssistantEvalOutput } from 'evals/scorer'
|
||||
import type { AiOptInLevel } from 'hooks/misc/useOrgOptedIntoAi'
|
||||
import { IS_TRACING_ENABLED } from 'lib/ai/braintrust-logger'
|
||||
import { CHAT_PROMPT, GENERAL_PROMPT, LIMITATIONS_PROMPT, SECURITY_PROMPT } from 'lib/ai/prompts'
|
||||
import { sanitizeMessagePart } from 'lib/ai/tools/tool-sanitizer'
|
||||
|
||||
import { buildAssistantEvalOutput } from '@/evals/output'
|
||||
import type { AssistantEvalInput, AssistantEvalOutput } from '@/evals/scorer'
|
||||
import type { AiOptInLevel } from '@/hooks/misc/useOrgOptedIntoAi'
|
||||
import { IS_TRACING_ENABLED } from '@/lib/ai/braintrust-logger'
|
||||
import { CHAT_PROMPT, GENERAL_PROMPT, LIMITATIONS_PROMPT, SECURITY_PROMPT } from '@/lib/ai/prompts'
|
||||
import { sanitizeMessagePart } from '@/lib/ai/tools/tool-sanitizer'
|
||||
|
||||
const { streamText: tracedStreamText } = wrapAISDK(ai)
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { openai } from '@ai-sdk/openai'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import * as bedrockModule from './bedrock'
|
||||
import { getModel } from './model'
|
||||
import { DEFAULT_COMPLETION_MODEL, openaiModelEntry } from './model.utils'
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { createMCPClient } from '@ai-sdk/mcp'
|
||||
import { createSupabaseMcpServer } from '@supabase/mcp-server-supabase'
|
||||
import { createSupabaseApiPlatform } from '@supabase/mcp-server-supabase/platform/api'
|
||||
import { StreamTransport } from '@supabase/mcp-utils'
|
||||
import { createMCPClient } from '@ai-sdk/mcp'
|
||||
|
||||
import { API_URL } from 'lib/constants'
|
||||
import { API_URL } from '@/lib/constants'
|
||||
|
||||
export async function createSupabaseMCPClient({
|
||||
accessToken,
|
||||
|
||||
@@ -3,10 +3,10 @@ import { describe, expect, it, vitest } from 'vitest'
|
||||
import { z } from 'zod'
|
||||
|
||||
import {
|
||||
createPrivacyMessageTool,
|
||||
filterToolsByOptInLevel,
|
||||
TOOL_CATEGORIES,
|
||||
TOOL_CATEGORY_MAP,
|
||||
filterToolsByOptInLevel,
|
||||
createPrivacyMessageTool,
|
||||
toolSetValidationSchema,
|
||||
} from './tool-filter'
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import type { Tool, ToolSet } from 'ai'
|
||||
import { z } from 'zod'
|
||||
// End of third-party imports
|
||||
|
||||
import type { AiOptInLevel } from 'hooks/misc/useOrgOptedIntoAi'
|
||||
import type { AiOptInLevel } from '@/hooks/misc/useOrgOptedIntoAi'
|
||||
|
||||
// Add the DatabaseExtension type import
|
||||
export type DatabaseExtension = {
|
||||
|
||||
@@ -3,12 +3,13 @@ import { tool } from 'ai'
|
||||
// import { processSql, renderSupabaseJs } from '@supabase/sql-to-rest'
|
||||
import { IS_PLATFORM } from 'common'
|
||||
import { stripIndent } from 'common-tags'
|
||||
import { getDatabaseFunctions } from 'data/database-functions/database-functions-query'
|
||||
import { getDatabasePolicies } from 'data/database-policies/database-policies-query'
|
||||
import { executeSql } from 'data/sql/execute-sql-query'
|
||||
import { executeQuery } from 'lib/api/self-hosted/query'
|
||||
import { z } from 'zod'
|
||||
|
||||
import { getDatabaseFunctions } from '@/data/database-functions/database-functions-query'
|
||||
import { getDatabasePolicies } from '@/data/database-policies/database-policies-query'
|
||||
import { executeSql } from '@/data/sql/execute-sql-query'
|
||||
import { executeQuery } from '@/lib/api/self-hosted/query'
|
||||
|
||||
export const getFallbackTools = ({
|
||||
projectRef,
|
||||
connectionString,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { tool } from 'ai'
|
||||
import { IS_PLATFORM } from 'common'
|
||||
import { z } from 'zod'
|
||||
|
||||
import { IS_PLATFORM } from 'common'
|
||||
import type { IncidentInfo } from 'lib/api/incident-status'
|
||||
import type { IncidentInfo } from '@/lib/api/incident-status'
|
||||
|
||||
/**
|
||||
* Creates incident-related tools for the AI assistant.
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { AiOptInLevel } from 'hooks/misc/useOrgOptedIntoAi'
|
||||
import { filterToolsByOptInLevel } from '../tool-filter'
|
||||
import { getFallbackTools } from './fallback-tools'
|
||||
import { ToolSet } from 'ai'
|
||||
import { IS_PLATFORM } from 'common'
|
||||
|
||||
import { filterToolsByOptInLevel } from '../tool-filter'
|
||||
import { getFallbackTools } from './fallback-tools'
|
||||
import { getIncidentTools } from './incident-tools'
|
||||
import { getMcpTools } from './mcp-tools'
|
||||
import { getSchemaTools } from './schema-tools'
|
||||
import { getStudioTools } from './studio-tools'
|
||||
import { AiOptInLevel } from '@/hooks/misc/useOrgOptedIntoAi'
|
||||
|
||||
export const getTools = async ({
|
||||
projectRef,
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import type { ToolSet } from 'ai'
|
||||
// End of third-party imports
|
||||
|
||||
import type { AiOptInLevel } from 'hooks/misc/useOrgOptedIntoAi'
|
||||
import { createSupabaseMCPClient } from '../supabase-mcp'
|
||||
import { filterToolsByOptInLevel, toolSetValidationSchema } from '../tool-filter'
|
||||
import type { AiOptInLevel } from '@/hooks/misc/useOrgOptedIntoAi'
|
||||
|
||||
const UI_EXECUTED_TOOLS = ['execute_sql', 'deploy_edge_function']
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { tool, type ToolSet } from 'ai'
|
||||
import { getStudioTools } from '../tools/studio-tools'
|
||||
import { z } from 'zod'
|
||||
import { getMcpTools } from 'lib/ai/tools/mcp-tools'
|
||||
import assert from 'node:assert'
|
||||
import { tool, type ToolSet } from 'ai'
|
||||
import { z } from 'zod'
|
||||
|
||||
import { getStudioTools } from '../tools/studio-tools'
|
||||
import { getMcpTools } from '@/lib/ai/tools/mcp-tools'
|
||||
|
||||
const listTablesInputSchema = z.object({
|
||||
schemas: z.array(z.string()).describe('The schema names to list.'),
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { tool } from 'ai'
|
||||
import { getDatabasePolicies } from 'data/database-policies/database-policies-query'
|
||||
import { z } from 'zod'
|
||||
|
||||
import { getDatabasePolicies } from '@/data/database-policies/database-policies-query'
|
||||
|
||||
export const getSchemaTools = ({
|
||||
projectRef,
|
||||
connectionString,
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { tool } from 'ai'
|
||||
import { z } from 'zod'
|
||||
|
||||
import {
|
||||
EDGE_FUNCTION_PROMPT,
|
||||
PG_BEST_PRACTICES,
|
||||
REALTIME_PROMPT,
|
||||
RLS_PROMPT,
|
||||
} from 'lib/ai/prompts'
|
||||
import { fixSqlBackslashEscapes } from 'lib/ai/util'
|
||||
import { z } from 'zod'
|
||||
} from '@/lib/ai/prompts'
|
||||
import { fixSqlBackslashEscapes } from '@/lib/ai/util'
|
||||
|
||||
const KNOWLEDGE = {
|
||||
pg_best_practices: PG_BEST_PRACTICES,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { ToolUIPart } from 'ai'
|
||||
import { describe, expect, test } from 'vitest'
|
||||
|
||||
// End of third-party imports
|
||||
|
||||
import { prepareMessagesForAPI } from '../message-utils'
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import type { ToolUIPart, UIMessage } from 'ai'
|
||||
// End of third-party imports
|
||||
|
||||
import type { AiOptInLevel } from 'hooks/misc/useOrgOptedIntoAi'
|
||||
import type { ToolName } from '../tool-filter'
|
||||
import type { AiOptInLevel } from '@/hooks/misc/useOrgOptedIntoAi'
|
||||
|
||||
interface ToolSanitizer {
|
||||
toolName: ToolName
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { fixSqlBackslashEscapes, selectWeightedKey } from './util'
|
||||
|
||||
describe('fixSqlBackslashEscapes', () => {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import { apiAuthenticate } from './apiAuthenticate'
|
||||
|
||||
const mocks = vi.hoisted(() => {
|
||||
@@ -13,7 +14,7 @@ const mocks = vi.hoisted(() => {
|
||||
}
|
||||
})
|
||||
|
||||
vi.mock('lib/gotrue', () => ({
|
||||
vi.mock('@/lib/gotrue', () => ({
|
||||
getUserClaims: mocks.getUserClaims,
|
||||
}))
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import type { JwtPayload } from '@supabase/supabase-js'
|
||||
import { getUserClaims } from 'lib/gotrue'
|
||||
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||
import type { ResponseError } from 'types'
|
||||
|
||||
import { getUserClaims } from '@/lib/gotrue'
|
||||
import type { ResponseError } from '@/types'
|
||||
|
||||
/**
|
||||
* Use this method on api routes to check if user is authenticated and having required permissions.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { IncomingHttpHeaders } from 'node:http'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import {
|
||||
commaSeparatedStringIntoArray,
|
||||
constructHeaders,
|
||||
@@ -8,7 +9,7 @@ import {
|
||||
zBooleanString,
|
||||
} from './apiHelpers'
|
||||
|
||||
vi.mock('lib/constants', () => ({
|
||||
vi.mock('@/lib/constants', () => ({
|
||||
IS_PLATFORM: false,
|
||||
}))
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { IS_PLATFORM } from 'lib/constants'
|
||||
import { snakeCase } from 'lodash'
|
||||
import type { IncomingHttpHeaders } from 'node:http'
|
||||
import { snakeCase } from 'lodash'
|
||||
import z from 'zod'
|
||||
|
||||
import { IS_PLATFORM } from '@/lib/constants'
|
||||
|
||||
/**
|
||||
* Construct headers for api request.
|
||||
* For platform, it will include apiKey into the provided headers.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { JwtPayload } from '@supabase/supabase-js'
|
||||
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { ResponseError, ResponseFailure } from 'types'
|
||||
|
||||
import { IS_PLATFORM } from '../constants'
|
||||
import { apiAuthenticate } from './apiAuthenticate'
|
||||
import { ResponseError, ResponseFailure } from '@/types'
|
||||
|
||||
export function isResponseOk<T>(response: T | ResponseFailure | undefined): response is T {
|
||||
if (response === undefined || response === null) {
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import type { JwtPayload } from '@supabase/supabase-js'
|
||||
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
import { ResponseError } from 'types'
|
||||
import apiWrapper from './apiWrapper'
|
||||
import { apiAuthenticate } from './apiAuthenticate'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
vi.mock('lib/constants', () => ({
|
||||
import { apiAuthenticate } from './apiAuthenticate'
|
||||
import apiWrapper from './apiWrapper'
|
||||
import { ResponseError } from '@/types'
|
||||
|
||||
vi.mock('@/lib/constants', () => ({
|
||||
IS_PLATFORM: true,
|
||||
API_URL: 'https://api.example.com',
|
||||
}))
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import { UIMessage } from 'ai'
|
||||
import { sanitizeMessagePart } from 'lib/ai/tools/tool-sanitizer'
|
||||
import { expect, test, vi } from 'vitest'
|
||||
|
||||
// End of third-party imports
|
||||
|
||||
import generateV4 from '../../pages/api/ai/sql/generate-v4'
|
||||
import { sanitizeMessagePart } from '@/lib/ai/tools/tool-sanitizer'
|
||||
|
||||
vi.mock('lib/ai/tools/tool-sanitizer', () => ({
|
||||
vi.mock('@/lib/ai/tools/tool-sanitizer', () => ({
|
||||
sanitizeMessagePart: vi.fn((part) => part),
|
||||
}))
|
||||
|
||||
@@ -45,7 +43,7 @@ test('generateV4 calls the tool sanitizer', async () => {
|
||||
setHeader: vi.fn(() => mockRes),
|
||||
}
|
||||
|
||||
vi.mock('lib/ai/ai-details', () => ({
|
||||
vi.mock('@/lib/ai/ai-details', () => ({
|
||||
getOrgAIDetails: vi.fn().mockResolvedValue({
|
||||
aiOptInLevel: 'schema_and_log_and_data',
|
||||
hasAccessToAdvanceModel: true,
|
||||
@@ -57,18 +55,18 @@ test('generateV4 calls the tool sanitizer', async () => {
|
||||
}),
|
||||
}))
|
||||
|
||||
vi.mock('lib/ai/model', () => ({
|
||||
vi.mock('@/lib/ai/model', () => ({
|
||||
getModel: vi.fn().mockResolvedValue({
|
||||
modelParams: { model: {} },
|
||||
promptProviderOptions: {},
|
||||
}),
|
||||
}))
|
||||
|
||||
vi.mock('data/sql/execute-sql-query', () => ({
|
||||
vi.mock('@/data/sql/execute-sql-query', () => ({
|
||||
executeSql: vi.fn().mockResolvedValue({ result: [] }),
|
||||
}))
|
||||
|
||||
vi.mock('lib/ai/tools', () => ({
|
||||
vi.mock('@/lib/ai/tools', () => ({
|
||||
getTools: vi.fn().mockResolvedValue({}),
|
||||
}))
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { IS_PROD } from 'common'
|
||||
import { createHash } from 'crypto'
|
||||
import { IS_PROD } from 'common'
|
||||
import z from 'zod'
|
||||
|
||||
import { InternalServerError } from 'lib/api/apiHelpers'
|
||||
import { InternalServerError } from '@/lib/api/apiHelpers'
|
||||
|
||||
const INCIDENT_IO_BASE_URL = 'https://api.incident.io/v2'
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { IS_PLATFORM } from 'common'
|
||||
import { InternalServerError } from 'lib/api/apiHelpers'
|
||||
import z from 'zod'
|
||||
|
||||
import { InternalServerError } from '@/lib/api/apiHelpers'
|
||||
|
||||
export type IncidentCache = {
|
||||
affected_regions: Array<string> | null
|
||||
affects_project_creation: boolean
|
||||
|
||||
@@ -43,7 +43,7 @@ test('rate calls the tool sanitizer', async () => {
|
||||
setHeader: vi.fn(() => mockRes),
|
||||
}
|
||||
|
||||
vi.mock('lib/ai/ai-details', () => ({
|
||||
vi.mock('@/lib/ai/ai-details', () => ({
|
||||
getOrgAIDetails: vi.fn().mockResolvedValue({
|
||||
aiOptInLevel: 'schema_and_log_and_data',
|
||||
hasAccessToAdvanceModel: true,
|
||||
@@ -55,7 +55,7 @@ test('rate calls the tool sanitizer', async () => {
|
||||
}),
|
||||
}))
|
||||
|
||||
vi.mock('lib/ai/model', () => ({
|
||||
vi.mock('@/lib/ai/model', () => ({
|
||||
getModel: vi.fn().mockResolvedValue({
|
||||
modelParams: { model: {} },
|
||||
}),
|
||||
@@ -70,7 +70,7 @@ test('rate calls the tool sanitizer', async () => {
|
||||
Output: { object: vi.fn() },
|
||||
}))
|
||||
|
||||
vi.mock('components/ui/AIAssistantPanel/Message.utils', () => ({
|
||||
vi.mock('@/components/ui/AIAssistantPanel/Message.utils', () => ({
|
||||
rateMessageResponseSchema: {},
|
||||
}))
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import assert from 'node:assert'
|
||||
|
||||
import { FileSystemFunctionsArtifactStore } from './fileSystemStore'
|
||||
import { assertSelfHosted } from '../util'
|
||||
import { FileSystemFunctionsArtifactStore } from './fileSystemStore'
|
||||
|
||||
export function getFunctionsArtifactStore() {
|
||||
assertSelfHosted()
|
||||
|
||||
@@ -2,11 +2,11 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import { generateTypescriptTypes } from './generate-types'
|
||||
|
||||
vi.mock('data/fetchers', () => ({
|
||||
vi.mock('@/data/fetchers', () => ({
|
||||
fetchGet: vi.fn(),
|
||||
}))
|
||||
|
||||
vi.mock('lib/constants', () => ({
|
||||
vi.mock('@/lib/constants', () => ({
|
||||
PG_META_URL: 'http://localhost:8080',
|
||||
}))
|
||||
|
||||
@@ -21,7 +21,7 @@ describe('api/self-hosted/generate-types', () => {
|
||||
beforeEach(async () => {
|
||||
vi.clearAllMocks()
|
||||
|
||||
const fetchers = await import('data/fetchers')
|
||||
const fetchers = await import('@/data/fetchers')
|
||||
const util = await import('./util')
|
||||
|
||||
mockFetchGet = vi.mocked(fetchers.fetchGet)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { fetchGet } from 'data/fetchers'
|
||||
import { PG_META_URL } from 'lib/constants'
|
||||
import type { ResponseError } from 'types'
|
||||
import { assertSelfHosted } from './util'
|
||||
import { fetchGet } from '@/data/fetchers'
|
||||
import { PG_META_URL } from '@/lib/constants'
|
||||
import type { ResponseError } from '@/types'
|
||||
|
||||
export type GenerateTypescriptTypesOptions = {
|
||||
headers?: HeadersInit
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { enrichLintsQuery, getLintsSQL } from '@supabase/pg-meta'
|
||||
import { paths } from 'api-types'
|
||||
import { DOCS_URL } from 'lib/constants'
|
||||
|
||||
import { executeQuery } from './query'
|
||||
import { DOCS_URL } from '@/lib/constants'
|
||||
|
||||
interface GetLintsOptions {
|
||||
headers?: HeadersInit
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { PROJECT_ANALYTICS_URL } from 'lib/constants/api'
|
||||
import { WrappedResult } from './types'
|
||||
import { assertSelfHosted } from './util'
|
||||
import assert from 'node:assert'
|
||||
import { LogsService } from '@supabase/mcp-server-supabase/platform'
|
||||
import { stripIndent } from 'common-tags'
|
||||
|
||||
import { WrappedResult } from './types'
|
||||
import { assertSelfHosted } from './util'
|
||||
import { PROJECT_ANALYTICS_URL } from '@/lib/constants/api'
|
||||
|
||||
export type RetrieveAnalyticsDataOptions = {
|
||||
name: string
|
||||
projectRef: string
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
ExecuteSqlOptions,
|
||||
GetLogsOptions,
|
||||
} from '@supabase/mcp-server-supabase/platform'
|
||||
import { ResponseError } from 'types'
|
||||
|
||||
import { DEFAULT_EXPOSED_SCHEMAS } from './constants'
|
||||
import { generateTypescriptTypes } from './generate-types'
|
||||
import { getLints } from './lints'
|
||||
@@ -16,6 +16,7 @@ import { getLogQuery, retrieveAnalyticsData } from './logs'
|
||||
import { applyAndTrackMigrations, listMigrationVersions } from './migrations'
|
||||
import { executeQuery } from './query'
|
||||
import { getProjectSettings } from './settings'
|
||||
import { ResponseError } from '@/types'
|
||||
|
||||
export type GetDatabaseOperationsOptions = {
|
||||
headers?: HeadersInit
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { source } from 'common-tags'
|
||||
import { makeRandomString } from 'lib/helpers'
|
||||
|
||||
import { executeQuery } from './query'
|
||||
import { PgMetaDatabaseError, WrappedResult } from './types'
|
||||
import { assertSelfHosted } from './util'
|
||||
import { makeRandomString } from '@/lib/helpers'
|
||||
|
||||
export type ListMigrationsResult = {
|
||||
version: string
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import * as Sentry from '@sentry/nextjs'
|
||||
import { PG_META_URL } from 'lib/constants/index'
|
||||
|
||||
import { constructHeaders } from '../apiHelpers'
|
||||
import { PgMetaDatabaseError, databaseErrorSchema, WrappedResult } from './types'
|
||||
import { databaseErrorSchema, PgMetaDatabaseError, WrappedResult } from './types'
|
||||
import { assertSelfHosted, encryptString, getConnectionString } from './util'
|
||||
import { PG_META_URL } from '@/lib/constants/index'
|
||||
|
||||
export type QueryOptions = {
|
||||
query: string
|
||||
|
||||
@@ -6,7 +6,7 @@ vi.mock('./util', () => ({
|
||||
assertSelfHosted: vi.fn(),
|
||||
}))
|
||||
|
||||
vi.mock('lib/constants/api', () => ({
|
||||
vi.mock('@/lib/constants/api', () => ({
|
||||
PROJECT_ENDPOINT: 'localhost:8000',
|
||||
PROJECT_ENDPOINT_PROTOCOL: 'http',
|
||||
}))
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { components } from 'api-types'
|
||||
import { PROJECT_ENDPOINT, PROJECT_ENDPOINT_PROTOCOL } from 'lib/constants/api'
|
||||
|
||||
import { assertSelfHosted } from './util'
|
||||
import { PROJECT_ENDPOINT, PROJECT_ENDPOINT_PROTOCOL } from '@/lib/constants/api'
|
||||
|
||||
type ProjectAppConfig = components['schemas']['ProjectSettingsResponse']['app_config'] & {
|
||||
protocol?: string
|
||||
|
||||
@@ -2,7 +2,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import { assertSelfHosted, encryptString, getConnectionString } from './util'
|
||||
|
||||
vi.mock('lib/constants', () => ({
|
||||
vi.mock('@/lib/constants', () => ({
|
||||
IS_PLATFORM: false,
|
||||
}))
|
||||
|
||||
@@ -27,14 +27,14 @@ describe('api/self-hosted/util', () => {
|
||||
|
||||
describe('assertSelfHosted', () => {
|
||||
it('should not throw when IS_PLATFORM is false', async () => {
|
||||
const constants = await import('lib/constants')
|
||||
const constants = await import('@/lib/constants')
|
||||
vi.spyOn(constants, 'IS_PLATFORM', 'get').mockReturnValue(false)
|
||||
|
||||
expect(() => assertSelfHosted()).not.toThrow()
|
||||
})
|
||||
|
||||
it('should throw error when IS_PLATFORM is true', async () => {
|
||||
const constants = await import('lib/constants')
|
||||
const constants = await import('@/lib/constants')
|
||||
vi.spyOn(constants, 'IS_PLATFORM', 'get').mockReturnValue(true)
|
||||
|
||||
expect(() => assertSelfHosted()).toThrow(
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
import crypto from 'crypto-js'
|
||||
import { IS_PLATFORM } from 'lib/constants'
|
||||
|
||||
import {
|
||||
ENCRYPTION_KEY,
|
||||
POSTGRES_DATABASE,
|
||||
POSTGRES_HOST,
|
||||
POSTGRES_PASSWORD,
|
||||
POSTGRES_PORT,
|
||||
POSTGRES_USER_READ_WRITE,
|
||||
POSTGRES_USER_READ_ONLY,
|
||||
POSTGRES_USER_READ_WRITE,
|
||||
} from './constants'
|
||||
import { IS_PLATFORM } from '@/lib/constants'
|
||||
|
||||
/**
|
||||
* Asserts that the current environment is self-hosted.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import { generateDeterministicUuid } from './snippets.browser'
|
||||
|
||||
describe('snippets.utils', () => {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user