mirror of
https://github.com/supabase/supabase.git
synced 2026-12-03 23:18:57 +00:00
[FE-3107] chore(studio): remove remaining Next.js references (#54426)
Removes the remaining Next.js dependencies, compatibility shims, test
mocks, ESLint/TypeScript presets, and webpack/Next workarounds from
Studio following the TanStack Start migration.
Addresses FE-3107.
**Removed:**
- `next` and `next-router-mock` from `apps/studio/package.json` (and
updated `pnpm-lock.yaml`)
- Orphaned `apps/studio/compat/next/script.tsx` shim, `script.test.tsx`,
`compat/**` knip entry, and `nextCompat()` / `ssr.noExternal` `/^next/`
plumbing from `apps/studio/vite.config.ts`
- `apps/studio/tests/lib/route-mock.ts` and all `next-router-mock`
setup/imports across `tests/vitestSetup.ts`,
`tests/lib/custom-render.tsx`, and 12 test files
- `apps/studio/tests/pages/` directory (moved the 3 remaining tests to
`components/interfaces/Organization/Organization.utils.test.ts` and
`apps/studio/tests/routes/`)
- Unused `'use client'` directives across 23 Studio files
- Next.js/webpack workarounds: `graphiqlViteWorkers()` in
`vite.config.ts`, webpack `import.meta.glob` `try/catch` fallback in
`ConnectStepsSection.tsx`, shell `NODE_ENV=test` override in
`vite.config.ts` / root `package.json` / `studio-e2e-test.yml`, Next
`getPathMatch` and `_next` passthrough in `redirects.shared.*`,
`window.next?.router` check in `monaco-graphiql-coexistence.spec.ts`,
and unused `ANALYZE` env var in `apps/studio/turbo.jsonc`
- Next-only Sentry/chunk-load filters (`NEXT_NOT_FOUND`,
`NEXT_REDIRECT`, Next `/org/[slug]/` regex, `/app:\/\//`, dead
`includeThirdPartyErrorFilter` plumbing, webpack chunk error regex) and
stale Next/Pages Router comments, docs, and `#__next` CSS selector
**Changed:**
- `apps/studio/eslint.config.cjs`: switched from
`eslint-config-supabase/next` to the new `eslint-config-supabase/react`
preset (dropping `@next/next/no-img-element: off`, keeping `.next` /
`next-env.d.ts` ignored for local checkouts with stale pre-migration
build artifacts)
- `apps/studio/tsconfig.json`: extends `tsconfig/base.json` directly
instead of `tsconfig/nextjs.json` (identical resolved compiler options)
- `apps/studio/.github/eslint-rule-baselines.json`: pruned 33 stale
`pages/...` and `types/next.ts` entries without changing any rule
thresholds
- `apps/studio/tests/lib/custom-render.tsx`: backed
`TestFrameworkProvider` with TanStack Router instead of
`next-router-mock`
-
`apps/studio/components/interfaces/Integrations/GraphQL/GraphiQLTab.tsx`:
imports `graphiql/setup-workers/vite` directly
- `apps/studio/styles/globals.css`: replaced `@source
'../pages/**/*.{js,ts,jsx,tsx}'` with `@source
'../routes/**/*.{js,ts,jsx,tsx}'`
- `apps/studio/turbo.jsonc`: declared `"NEXT_PUBLIC_*"` in
`tasks.build.env` now that Turborepo infers `nitro` instead of `nextjs`
-
`apps/studio/components/interfaces/Organization/Organization.utils.ts`:
narrowed `buildOrgUrl`'s `slug` parameter to `string[] | undefined`
**Added:**
- `packages/eslint-config-supabase/shared.js` and
`packages/eslint-config-supabase/react.js` (plus `presets.test.ts`),
decoupling non-Next React apps from `eslint-config-next` with verified
zero non-`@next/*` rule drift while keeping
`eslint-config-supabase/next` unchanged for the Next.js apps
## To test
- Run `pnpm --filter eslint-config-supabase run test` and confirm preset
parity tests pass
- Run `pnpm --filter studio run lint`, `pnpm --filter studio run
lint:ratchet`, `pnpm --filter studio run typecheck`, `pnpm knip
--workspace apps/studio`, and `pnpm --filter studio run test`
- Run `pnpm --filter studio run build` and verify the production build,
prerendered routes, chunk-cycle check, and GraphiQL web workers succeed
- Smoke-test Studio locally (`pnpm dev:studio`): verify GraphiQL loads
cleanly, ConnectSheet framework steps render, and Tailwind styles on
route pages are intact
---------
Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
This commit is contained in:
1 parent
c2ff38bb40
commit
0c97b9789b
93 files changed
+827
-1248
No files matched your search
@@ -94,7 +94,7 @@ server-side telemetry. Uses exponential backoff on connection errors.
|
||||
|
||||
**Provider + toolbar panel** (`DevToolbarProvider`, `DevToolbar`):
|
||||
|
||||
- `apps/studio/pages/_app.tsx`
|
||||
- `apps/studio/routes/__root.tsx`
|
||||
- `apps/www/pages/_app.tsx`, `apps/www/app/providers.tsx`
|
||||
- `apps/docs/features/app.providers.tsx`
|
||||
|
||||
|
||||
@@ -149,11 +149,17 @@ customRender(<MyComponent />, { profileContext: PROFILE_CONTEXT })
|
||||
|
||||
### 5. `useParams` is globally mocked to `{ ref: 'default' }`
|
||||
|
||||
You don't need to mock the Next router for project-scoped components.
|
||||
You don't need to configure a router for project-scoped components.
|
||||
Just use `'default'` as the project ref in your mock paths:
|
||||
`/v1/projects/default/secrets`, `/platform/projects/default/...`. If
|
||||
you need a different ref, override with `routerMock.setCurrentUrl(...)`
|
||||
(see `apps/studio/tests/lib/route-mock.ts`).
|
||||
you need a different ref or dynamic route params read via `useParams`
|
||||
from `'common'`, render the route with `renderRoute`
|
||||
(`apps/studio/tests/lib/route-render.tsx`), which provides
|
||||
`RenderedRouteContext` so the global `useParams` mock delegates to the
|
||||
real hook. Passing `initialUrl` or `router` to `customRender` alone
|
||||
still returns `{ ref: 'default' }` from `common`'s `useParams` (it only
|
||||
drives TanStack Router hooks and `useFramework()`, unless the test also
|
||||
restores the real `useParams` implementation).
|
||||
|
||||
### 6. Unhandled requests fail loudly — mock every endpoint a render triggers
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@ verification evidence without changing source or introducing mutations.
|
||||
| Component test examples | `apps/studio/tests/features/logs/LogsFilterPopover.test.tsx`, `apps/studio/tests/components/CopyButton.test.tsx` |
|
||||
| Fake timers (polling) | `apps/studio/components/layouts/ProjectLayout/RestoringState.test.tsx` |
|
||||
| Fake timers (debounce) | `apps/studio/hooks/misc/__tests__/useTableEditorFiltersSort.navigation.test.tsx` |
|
||||
| Scoped listbox queries | `apps/studio/tests/pages/new/[slug].test.tsx`, `apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/ResourceAccessStep.test.tsx` |
|
||||
| Scoped listbox queries | `apps/studio/tests/routes/new/$slug.test.tsx`, `apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/ResourceAccessStep.test.tsx` |
|
||||
| E2E test example | `e2e/studio/features/filter-bar.spec.ts` |
|
||||
| E2E helpers pattern | `e2e/studio/utils/filter-bar-helpers.ts` |
|
||||
| Custom render | `apps/studio/tests/lib/custom-render.tsx` |
|
||||
|
||||
@@ -119,15 +119,13 @@ jobs:
|
||||
# the API URL, fixed by e2e/studio/supabase/config.toml. So build
|
||||
# against that URL and check it against the real value once supabase is up.
|
||||
#
|
||||
# `MODE=test` so the Vite build loads `.env.test` for env resolution.
|
||||
# `vite.config.ts` overrides the bundle NODE_ENV to 'production'
|
||||
# regardless of input, so vitest-only constants (e.g. `API_URL`)
|
||||
# don't bleed in here.
|
||||
# `MODE=test` so the Vite build loads `.env.test` for env resolution
|
||||
# while Vite keeps `NODE_ENV=production` for the bundle.
|
||||
run: |
|
||||
echo '{"API_URL":"http://127.0.0.1:54321"}' > keys.json
|
||||
node scripts/generateLocalEnv.js
|
||||
grep '^NEXT_PUBLIC_' apps/studio/.env.test | sort > "$RUNNER_TEMP/build-public-env"
|
||||
SKIP_ASSET_UPLOAD=1 NODE_ENV=test MODE=test NODE_OPTIONS="--max-old-space-size=4096" pnpm run build:studio
|
||||
SKIP_ASSET_UPLOAD=1 MODE=test NODE_OPTIONS="--max-old-space-size=4096" pnpm run build:studio
|
||||
|
||||
- name: Wait for supabase and Playwright browsers
|
||||
wait: [supabase, playwright-install]
|
||||
|
||||
@@ -19,7 +19,6 @@ LOGFLARE_URL=http://localhost:4000
|
||||
LOGFLARE_PRIVATE_ACCESS_TOKEN=your-super-secret-and-long-logflare-key-private
|
||||
|
||||
# TODO: evaluate these variables at runtime instead
|
||||
# https://nextjs.org/docs/basic-features/environment-variables#loading-environment-variables
|
||||
NEXT_PUBLIC_SITE_URL=http://localhost:3000
|
||||
NEXT_PUBLIC_GOTRUE_URL=$SUPABASE_PUBLIC_URL/auth/v1
|
||||
NEXT_PUBLIC_HCAPTCHA_SITE_KEY=10000000-ffff-ffff-ffff-000000000001
|
||||
|
||||
+2
-35
@@ -118,14 +118,7 @@
|
||||
"hooks/misc/useSchemaQueryState.ts": 1,
|
||||
"hooks/misc/useUpgradePrompt.tsx": 1,
|
||||
"lib/telemetry/track.ts": 1,
|
||||
"pages/forgot-password-mfa.tsx": 1,
|
||||
"pages/logout.tsx": 1,
|
||||
"routes/project/$ref/database/policies.tsx": 2,
|
||||
"pages/project/[ref]/editor/[id].tsx": 1,
|
||||
"pages/project/[ref]/integrations/[id]/index.tsx": 1,
|
||||
"pages/project/[ref]/settings/jwt/legacy.tsx": 1,
|
||||
"pages/project/[ref]/sql/examples.tsx": 1,
|
||||
"pages/project/[ref]/sql/templates.tsx": 1,
|
||||
"routes/_app/new/index.tsx": 1,
|
||||
"state/role-impersonation-state.tsx": 1,
|
||||
"state/sidebar-manager-state.tsx": 1,
|
||||
@@ -476,18 +469,6 @@
|
||||
"lib/profile.tsx": 1,
|
||||
"lib/role-impersonation.ts": 1,
|
||||
"lib/telemetry/track.ts": 1,
|
||||
"pages/_app.tsx": 1,
|
||||
"pages/api/ai/feedback/rate.ts": 2,
|
||||
"pages/api/check-cname.ts": 1,
|
||||
"pages/api/edge-functions/test.ts": 1,
|
||||
"pages/api/platform/auth/[ref]/users/[id]/factors.ts": 1,
|
||||
"pages/api/platform/database/[ref]/pooling.ts": 1,
|
||||
"pages/api/platform/integrations/github/authorization.ts": 1,
|
||||
"pages/api/platform/projects/[ref]/analytics/log-drains.ts": 1,
|
||||
"pages/api/platform/projects/[ref]/content/count.ts": 1,
|
||||
"pages/api/platform/projects/[ref]/content/index.ts": 1,
|
||||
"pages/api/platform/projects/[ref]/databases.ts": 1,
|
||||
"pages/project/[ref]/settings/log-drains.tsx": 1,
|
||||
"state/ai-assistant-state.tsx": 4,
|
||||
"state/sql-editor/sql-editor-session-state.ts": 4,
|
||||
"state/storage-explorer.tsx": 15,
|
||||
@@ -495,7 +476,6 @@
|
||||
"state/table-editor.tsx": 5,
|
||||
"tests/setup/polyfills.ts": 3,
|
||||
"tests/vitestSetup.ts": 1,
|
||||
"types/next.ts": 2,
|
||||
"types/ui.ts": 2
|
||||
},
|
||||
"no-restricted-exports": {
|
||||
@@ -666,7 +646,6 @@
|
||||
"hooks/analytics/useSingleLog.tsx": 1,
|
||||
"hooks/analytics/useTimeseriesUnixToIso.ts": 1,
|
||||
"lib/pingPostgrest.ts": 1,
|
||||
"pages/_error.jsx": 1,
|
||||
"scripts/codegen.ts": 1
|
||||
},
|
||||
"react/no-unstable-nested-components": {
|
||||
@@ -811,13 +790,7 @@
|
||||
"components/ui/Charts/ReportSettings.tsx": 2,
|
||||
"components/ui/Logs/LogsExplorerHeader.tsx": 1,
|
||||
"components/ui/PasswordStrengthBar.tsx": 1,
|
||||
"components/ui/Resource/ResourceItem.tsx": 1,
|
||||
"pages/project/[ref]/auth/templates/[templateId].tsx": 1,
|
||||
"pages/project/[ref]/observability/auth.tsx": 1,
|
||||
"pages/project/[ref]/observability/edge-functions.tsx": 1,
|
||||
"pages/project/[ref]/observability/postgrest.tsx": 1,
|
||||
"pages/project/[ref]/observability/realtime.tsx": 1,
|
||||
"pages/project/[ref]/observability/storage.tsx": 1
|
||||
"components/ui/Resource/ResourceItem.tsx": 1
|
||||
},
|
||||
"jsx-a11y/label-has-associated-control": {
|
||||
"components/interfaces/Auth/EmailTemplates/TemplateEditor.tsx": 1,
|
||||
@@ -951,8 +924,6 @@
|
||||
"components/ui/GlobalShortcuts/ShortcutsReferenceSheet.tsx": 1,
|
||||
"components/ui/ShortcutBadge.tsx": 1,
|
||||
"components/ui/ShortcutTooltip.tsx": 1,
|
||||
"pages/project/[ref]/settings/infrastructure/replica/[replicaId].tsx": 1,
|
||||
"pages/project/[ref]/settings/log-drains.tsx": 2,
|
||||
"state/shortcuts/useDynamicShortcut.tsx": 1,
|
||||
"state/shortcuts/useShortcut.tsx": 1
|
||||
},
|
||||
@@ -1049,9 +1020,7 @@
|
||||
"components/ui/Forms/FormSection.tsx": 2,
|
||||
"components/ui/QueryBlock/QueryBlock.tsx": 3,
|
||||
"components/ui/ShimmerLine.tsx": 1,
|
||||
"components/ui/Shimmers.tsx": 3,
|
||||
"pages/project/[ref]/functions/[functionSlug]/code.tsx": 1,
|
||||
"pages/project/[ref]/storage/vectors/buckets/[bucketId].tsx": 1
|
||||
"components/ui/Shimmers.tsx": 3
|
||||
},
|
||||
"shadcn/no-raw-colors": {
|
||||
"components/interfaces/Advisors/AdvisorRuleItem.tsx": 1,
|
||||
@@ -1354,8 +1323,6 @@
|
||||
"lib/ai/tools/execute-sql.server.ts": 1,
|
||||
"lib/ai/tools/run-notebook.server.ts": 1,
|
||||
"lib/ai/tools/tool-sql.server.ts": 1,
|
||||
"pages/api/ai/code/complete.ts": 2,
|
||||
"pages/api/ai/sql/generate-v4.ts": 1,
|
||||
"state/role-impersonation-state.tsx": 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ Load the skills matching the task; stack them when a task spans areas:
|
||||
|
||||
Routes live in `routes/**` (TanStack Start file routes); `routeTree.gen.ts` is generated by the Vite plugin — never hand-edit it.
|
||||
|
||||
- New code uses native TanStack APIs (`Link`, `useNavigate`, `Route.useParams()`, `useSearch`) — no `next/*` imports. Only `next/script` is still shimmed: older components import it and `vite.config.ts` aliases it to `compat/next/`; any other `next/*` import fails the build. Switch a component to native APIs when you touch its routing.
|
||||
- Use native TanStack APIs (`Link`, `useNavigate`, `Route.useParams()`, `useSearch`) — no `next/*` imports.
|
||||
- Layouts are pathless (`routes/_app.tsx`, `routes/_auth.tsx`) or sibling-file shells (`routes/project/$ref/database.tsx` wraps `routes/project/$ref/database/**`), configured per leaf through `staticData`.
|
||||
- Route files export only `Route`; shared components belong in `components/**`.
|
||||
|
||||
|
||||
@@ -1,191 +0,0 @@
|
||||
import { act, render } from '@testing-library/react'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import Script from './script'
|
||||
|
||||
// The shim's load caches are module-level (like Next's), so each test uses
|
||||
// its own id/src.
|
||||
//
|
||||
// jsdom runs scripts against its own window, which vitest's test-side
|
||||
// `window` doesn't share, so inline scripts record runs on the shared
|
||||
// document instead of a window global.
|
||||
const inlineCounter = (key: string) =>
|
||||
`var el = document.documentElement; el.dataset['run_${key}'] = String(Number(el.dataset['run_${key}'] || 0) + 1);`
|
||||
|
||||
const runs = (key: string) => Number(document.documentElement.dataset[`run_${key}`] ?? 0)
|
||||
|
||||
afterEach(() => {
|
||||
document.body.querySelectorAll('script[data-nscript]').forEach((el) => el.remove())
|
||||
})
|
||||
|
||||
describe('next/script compat shim', () => {
|
||||
it('executes an inline dangerouslySetInnerHTML script and renders nothing in place', () => {
|
||||
const onReady = vi.fn()
|
||||
const { container } = render(
|
||||
<Script
|
||||
id="inlineHtml"
|
||||
dangerouslySetInnerHTML={{ __html: inlineCounter('inlineHtml') }}
|
||||
onReady={onReady}
|
||||
/>
|
||||
)
|
||||
|
||||
expect(runs('inlineHtml')).toBe(1)
|
||||
expect(onReady).toHaveBeenCalledTimes(1)
|
||||
expect(container.innerHTML).toBe('')
|
||||
|
||||
const el = document.getElementById('inlineHtml')
|
||||
expect(el?.parentElement).toBe(document.body)
|
||||
expect(el?.getAttribute('data-nscript')).toBe('afterInteractive')
|
||||
})
|
||||
|
||||
it('executes an inline script passed as children', () => {
|
||||
render(<Script id="inlineChildren">{inlineCounter('inlineChildren')}</Script>)
|
||||
expect(runs('inlineChildren')).toBe(1)
|
||||
})
|
||||
|
||||
it('executes a script with the same id only once across instances and remounts', () => {
|
||||
const body = { __html: inlineCounter('dedupe') }
|
||||
const first = render(
|
||||
<>
|
||||
<Script id="dedupe" dangerouslySetInnerHTML={body} />
|
||||
<Script id="dedupe" dangerouslySetInnerHTML={body} />
|
||||
</>
|
||||
)
|
||||
first.unmount()
|
||||
render(<Script id="dedupe" dangerouslySetInnerHTML={body} />)
|
||||
|
||||
expect(runs('dedupe')).toBe(1)
|
||||
expect(document.querySelectorAll('script#dedupe')).toHaveLength(1)
|
||||
})
|
||||
|
||||
it('appends a src script as a real element and wires onLoad/onReady to its load event', () => {
|
||||
const onLoad = vi.fn()
|
||||
const onReady = vi.fn()
|
||||
render(
|
||||
<Script
|
||||
src="https://example.com/a.js"
|
||||
crossOrigin="anonymous"
|
||||
data-foo="bar"
|
||||
onLoad={onLoad}
|
||||
onReady={onReady}
|
||||
/>
|
||||
)
|
||||
|
||||
const el = document.querySelector<HTMLScriptElement>('script[src="https://example.com/a.js"]')
|
||||
expect(el).not.toBeNull()
|
||||
expect(el?.parentElement).toBe(document.body)
|
||||
expect(el?.getAttribute('crossorigin')).toBe('anonymous')
|
||||
expect(el?.getAttribute('data-foo')).toBe('bar')
|
||||
expect(onLoad).not.toHaveBeenCalled()
|
||||
expect(onReady).not.toHaveBeenCalled()
|
||||
|
||||
act(() => {
|
||||
el?.dispatchEvent(new Event('load'))
|
||||
})
|
||||
|
||||
expect(onLoad).toHaveBeenCalledTimes(1)
|
||||
expect(onReady).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('calls onError when a src script fails to load', async () => {
|
||||
const onError = vi.fn()
|
||||
render(<Script src="https://example.com/broken.js" onError={onError} />)
|
||||
|
||||
const el = document.querySelector('script[src="https://example.com/broken.js"]')
|
||||
await act(async () => {
|
||||
el?.dispatchEvent(new Event('error'))
|
||||
})
|
||||
|
||||
expect(onError).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('retries a src script on a later mount after it failed to load', async () => {
|
||||
const src = 'https://example.com/flaky.js'
|
||||
const first = render(<Script src={src} />)
|
||||
await act(async () => {
|
||||
document.querySelector(`script[src="${src}"]`)?.dispatchEvent(new Event('error'))
|
||||
})
|
||||
first.unmount()
|
||||
|
||||
const onLoad = vi.fn()
|
||||
const onReady = vi.fn()
|
||||
render(<Script src={src} onLoad={onLoad} onReady={onReady} />)
|
||||
|
||||
// Not treated as loaded: no onReady until the retried script loads.
|
||||
expect(onReady).not.toHaveBeenCalled()
|
||||
const retried = document.querySelectorAll(`script[src="${src}"]`)
|
||||
expect(retried).toHaveLength(1)
|
||||
act(() => {
|
||||
retried[0].dispatchEvent(new Event('load'))
|
||||
})
|
||||
expect(onLoad).toHaveBeenCalledTimes(1)
|
||||
expect(onReady).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('runs onLoad, onReady and onError for every instance sharing an in-flight src', async () => {
|
||||
const loaded = 'https://example.com/shared.js'
|
||||
const firstReady = vi.fn()
|
||||
const secondLoad = vi.fn()
|
||||
const secondReady = vi.fn()
|
||||
render(<Script src={loaded} onReady={firstReady} />)
|
||||
render(<Script src={loaded} onLoad={secondLoad} onReady={secondReady} />)
|
||||
expect(document.querySelectorAll(`script[src="${loaded}"]`)).toHaveLength(1)
|
||||
await act(async () => {
|
||||
document.querySelector(`script[src="${loaded}"]`)?.dispatchEvent(new Event('load'))
|
||||
})
|
||||
expect(firstReady).toHaveBeenCalledTimes(1)
|
||||
expect(secondLoad).toHaveBeenCalledTimes(1)
|
||||
expect(secondReady).toHaveBeenCalledTimes(1)
|
||||
|
||||
const failed = 'https://example.com/shared-broken.js'
|
||||
const firstError = vi.fn()
|
||||
const secondError = vi.fn()
|
||||
render(<Script src={failed} onError={firstError} />)
|
||||
render(<Script src={failed} onError={secondError} />)
|
||||
await act(async () => {
|
||||
document.querySelector(`script[src="${failed}"]`)?.dispatchEvent(new Event('error'))
|
||||
})
|
||||
expect(firstError).toHaveBeenCalledTimes(1)
|
||||
expect(secondError).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('fires onReady on remount without re-injecting an already loaded script', () => {
|
||||
const src = 'https://example.com/b.js'
|
||||
const first = render(<Script src={src} />)
|
||||
act(() => {
|
||||
document.querySelector(`script[src="${src}"]`)?.dispatchEvent(new Event('load'))
|
||||
})
|
||||
first.unmount()
|
||||
|
||||
const onLoad = vi.fn()
|
||||
const onReady = vi.fn()
|
||||
render(<Script src={src} onLoad={onLoad} onReady={onReady} />)
|
||||
|
||||
expect(onReady).toHaveBeenCalledTimes(1)
|
||||
expect(onLoad).not.toHaveBeenCalled()
|
||||
expect(document.querySelectorAll(`script[src="${src}"]`)).toHaveLength(1)
|
||||
})
|
||||
|
||||
it('defers lazyOnload scripts until the browser is idle', async () => {
|
||||
vi.useFakeTimers()
|
||||
try {
|
||||
render(
|
||||
<Script
|
||||
id="lazy"
|
||||
strategy="lazyOnload"
|
||||
dangerouslySetInnerHTML={{ __html: inlineCounter('lazy') }}
|
||||
/>
|
||||
)
|
||||
expect(runs('lazy')).toBe(0)
|
||||
|
||||
await act(async () => {
|
||||
await vi.runAllTimersAsync()
|
||||
})
|
||||
|
||||
expect(runs('lazy')).toBe(1)
|
||||
expect(document.getElementById('lazy')?.getAttribute('data-nscript')).toBe('lazyOnload')
|
||||
} finally {
|
||||
vi.useRealTimers()
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -1,181 +0,0 @@
|
||||
import { useEffect, useRef, type ComponentPropsWithoutRef, type ReactNode } from 'react'
|
||||
|
||||
// Client-only port of next/script (next/dist/client/script.js) for the
|
||||
// TanStack build. React never executes <script> elements it renders on the
|
||||
// client, so, like Next, we inject the script imperatively in an effect and
|
||||
// render nothing. Scripts are deduped by `id` (or `src`) at module level, so
|
||||
// remounts and duplicate instances don't execute the same script twice.
|
||||
|
||||
type Strategy = 'beforeInteractive' | 'afterInteractive' | 'lazyOnload' | 'worker'
|
||||
|
||||
interface ScriptProps extends Omit<
|
||||
ComponentPropsWithoutRef<'script'>,
|
||||
'children' | 'onLoad' | 'onError'
|
||||
> {
|
||||
strategy?: Strategy
|
||||
// Inline body, as an alternative to dangerouslySetInnerHTML.
|
||||
children?: ReactNode
|
||||
onLoad?: (e: Event) => void
|
||||
onReady?: () => void
|
||||
onError?: (e: Event | string) => void
|
||||
}
|
||||
|
||||
// src -> promise settled when that remote script loads.
|
||||
const ScriptCache = new Map<string, Promise<void>>()
|
||||
// Keys (id || src) of scripts that have finished loading.
|
||||
const LoadCache = new Set<string>()
|
||||
|
||||
const DOMAttributeNames: Record<string, string> = {
|
||||
acceptCharset: 'accept-charset',
|
||||
className: 'class',
|
||||
htmlFor: 'for',
|
||||
httpEquiv: 'http-equiv',
|
||||
noModule: 'noModule',
|
||||
}
|
||||
|
||||
const ignoreProps = [
|
||||
'onLoad',
|
||||
'onReady',
|
||||
'dangerouslySetInnerHTML',
|
||||
'children',
|
||||
'onError',
|
||||
'strategy',
|
||||
'stylesheets',
|
||||
]
|
||||
|
||||
const isBooleanScriptAttribute = (attr: string) => ['async', 'defer', 'noModule'].includes(attr)
|
||||
|
||||
function setAttributesFromProps(el: HTMLScriptElement, props: ScriptProps) {
|
||||
for (const [p, value] of Object.entries(props)) {
|
||||
if (ignoreProps.includes(p) || value === undefined) continue
|
||||
const attr = DOMAttributeNames[p] || p.toLowerCase()
|
||||
if (isBooleanScriptAttribute(attr)) {
|
||||
Reflect.set(el, attr, !!value)
|
||||
} else {
|
||||
el.setAttribute(attr, String(value))
|
||||
}
|
||||
// Setting then removing clears falsy booleans, including the implicit
|
||||
// force-async on dynamically inserted scripts.
|
||||
if (value === false || (isBooleanScriptAttribute(attr) && (!value || value === 'false'))) {
|
||||
el.setAttribute(attr, '')
|
||||
el.removeAttribute(attr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const requestIdleCallback = (cb: () => void) => {
|
||||
if (typeof window.requestIdleCallback === 'function') window.requestIdleCallback(cb)
|
||||
else window.setTimeout(cb, 1)
|
||||
}
|
||||
|
||||
function loadScript(props: ScriptProps) {
|
||||
const {
|
||||
src,
|
||||
id,
|
||||
onLoad,
|
||||
onReady,
|
||||
dangerouslySetInnerHTML,
|
||||
children,
|
||||
strategy = 'afterInteractive',
|
||||
onError,
|
||||
} = props
|
||||
const cacheKey = id || src
|
||||
|
||||
if (cacheKey && LoadCache.has(cacheKey)) return
|
||||
|
||||
// Same remote script already loading: don't inject again, but still run
|
||||
// this instance's callbacks once it settles.
|
||||
const pending = src ? ScriptCache.get(src) : undefined
|
||||
if (pending) {
|
||||
pending.then(
|
||||
() => {
|
||||
if (cacheKey) LoadCache.add(cacheKey)
|
||||
onLoad?.(new Event('load'))
|
||||
onReady?.()
|
||||
},
|
||||
(e) => onError?.(e)
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
const afterLoad = () => {
|
||||
onReady?.()
|
||||
if (cacheKey) LoadCache.add(cacheKey)
|
||||
}
|
||||
|
||||
const el = document.createElement('script')
|
||||
const loadPromise = new Promise<void>((resolve, reject) => {
|
||||
el.addEventListener('load', (e) => {
|
||||
resolve()
|
||||
onLoad?.(e)
|
||||
afterLoad()
|
||||
})
|
||||
el.addEventListener('error', (e) => reject(e))
|
||||
})
|
||||
// Stays rejected for instances waiting on it. Dropping the failed entry
|
||||
// lets a later mount retry the script instead of treating it as loaded.
|
||||
loadPromise.catch((e) => {
|
||||
if (src) ScriptCache.delete(src)
|
||||
el.remove()
|
||||
onError?.(e)
|
||||
})
|
||||
|
||||
if (dangerouslySetInnerHTML) {
|
||||
el.innerHTML = String(dangerouslySetInnerHTML.__html || '')
|
||||
afterLoad()
|
||||
} else if (children) {
|
||||
el.textContent =
|
||||
typeof children === 'string' ? children : Array.isArray(children) ? children.join('') : ''
|
||||
afterLoad()
|
||||
} else if (src) {
|
||||
el.src = src
|
||||
// Added to LoadCache only once the load event fires.
|
||||
ScriptCache.set(src, loadPromise)
|
||||
}
|
||||
|
||||
setAttributesFromProps(el, props)
|
||||
el.setAttribute('data-nscript', strategy)
|
||||
document.body.appendChild(el)
|
||||
}
|
||||
|
||||
function loadLazyScript(props: ScriptProps) {
|
||||
if (document.readyState === 'complete') {
|
||||
requestIdleCallback(() => loadScript(props))
|
||||
} else {
|
||||
window.addEventListener('load', () => requestIdleCallback(() => loadScript(props)), {
|
||||
once: true,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-restricted-exports
|
||||
export default function Script(props: ScriptProps) {
|
||||
const { id, src = '', onReady, strategy = 'afterInteractive' } = props
|
||||
|
||||
// Fire onReady on a remount when the script already loaded. The ref guards
|
||||
// against StrictMode's double effect run, as in Next.
|
||||
const hasOnReadyEffectCalled = useRef(false)
|
||||
useEffect(() => {
|
||||
const cacheKey = id || src
|
||||
if (!hasOnReadyEffectCalled.current) {
|
||||
if (onReady && cacheKey && LoadCache.has(cacheKey)) onReady()
|
||||
hasOnReadyEffectCalled.current = true
|
||||
}
|
||||
}, [onReady, id, src])
|
||||
|
||||
const hasLoadScriptEffectCalled = useRef(false)
|
||||
useEffect(() => {
|
||||
if (hasLoadScriptEffectCalled.current) return
|
||||
hasLoadScriptEffectCalled.current = true
|
||||
if (strategy === 'lazyOnload') {
|
||||
loadLazyScript(props)
|
||||
} else {
|
||||
// Studio is a client-rendered SPA with no Next document to inject into
|
||||
// or Partytown worker, so beforeInteractive and worker scripts load
|
||||
// after mount like afterInteractive.
|
||||
loadScript(props)
|
||||
}
|
||||
}, [props, strategy])
|
||||
|
||||
return null
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
'use client'
|
||||
|
||||
import { useDebounce } from '@uidotdev/usehooks'
|
||||
import { IS_PLATFORM } from 'common'
|
||||
import { Auth, EdgeFunctions, Storage } from 'icons'
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
'use client'
|
||||
|
||||
import { Auth, EdgeFunctions, Storage } from 'icons'
|
||||
import { DatabaseIcon } from 'lucide-react'
|
||||
import { lazy, Suspense } from 'react'
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
'use client'
|
||||
|
||||
import { IS_PLATFORM } from 'common'
|
||||
import { AnalyticsBucket, EdgeFunctions, FilesBucket, VectorBucket } from 'icons'
|
||||
import {
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
'use client'
|
||||
|
||||
import { useParams } from 'common'
|
||||
import { EdgeFunctions } from 'icons'
|
||||
import { Loader2Icon } from 'lucide-react'
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
'use client'
|
||||
|
||||
import { useParams } from 'common'
|
||||
import { Auth } from 'icons'
|
||||
import { Loader2Icon } from 'lucide-react'
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
'use client'
|
||||
|
||||
import { useDebounce } from '@uidotdev/usehooks'
|
||||
import { useParams } from 'common'
|
||||
import { AnalyticsBucket as AnalyticsBucketIcon, FilesBucket, Storage, VectorBucket } from 'icons'
|
||||
|
||||
@@ -4,10 +4,8 @@ import userEvent from '@testing-library/user-event'
|
||||
import type { platformComponents } from 'api-types'
|
||||
import { FeatureFlagContext, LOCAL_STORAGE_KEYS } from 'common'
|
||||
import { HttpResponse } from 'msw'
|
||||
import routerMock from 'next-router-mock'
|
||||
import { createDynamicRouteParser } from 'next-router-mock/dynamic-routes'
|
||||
import { ResizablePanelGroup } from 'ui'
|
||||
import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import { UserPanel } from './UserPanel'
|
||||
import { FeaturePreviewContextProvider } from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext'
|
||||
@@ -28,12 +26,6 @@ const mockUser: User = {
|
||||
raw_app_meta_data: { providers: ['email'] },
|
||||
}
|
||||
|
||||
vi.unmock('common')
|
||||
const removeRouteParser = routerMock.useParser(
|
||||
createDynamicRouteParser(['/project/[ref]/auth/users'])
|
||||
)
|
||||
afterAll(removeRouteParser)
|
||||
|
||||
vi.mock('./UserLogs', () => ({
|
||||
UserLogs: () => <div data-testid="user-logs" />,
|
||||
}))
|
||||
@@ -97,6 +89,7 @@ const renderPanel = (
|
||||
)
|
||||
const rendered = customRender(content(), {
|
||||
queryClient,
|
||||
initialUrl: '/project/default/auth/users',
|
||||
nuqs: { searchParams: `?show=${mockUser.id}` },
|
||||
profileContext: createMockProfileContext({
|
||||
profile: createMockProfile({ disabled_features: disabledFeatures }),
|
||||
@@ -123,7 +116,6 @@ function setIsHoverDevice(isHoverDevice: boolean) {
|
||||
}
|
||||
|
||||
describe('UserPanel', () => {
|
||||
beforeEach(() => routerMock.setCurrentUrl('/project/default/auth/users'))
|
||||
afterEach(() => {
|
||||
localStorage.removeItem(LOCAL_STORAGE_KEYS.UI_PREVIEW_UNIFIED_LOGS)
|
||||
setIsHoverDevice(false)
|
||||
|
||||
@@ -149,19 +149,15 @@ function useConnectionStringPooler(deploymentMode: DeploymentMode): ConnectionSt
|
||||
// — Vite replaces `import.meta.env.SSR` at build time and tree-shakes the
|
||||
// call so the 37 content modules stay out of the server graph (pulling them
|
||||
// in reshuffles chunks enough to surface latent circular-dep bugs in
|
||||
// unrelated modules). Next/webpack doesn't know about `import.meta.glob`
|
||||
// either; the try/catch lets that branch fall through to the webpack-friendly
|
||||
// `import()` below.
|
||||
let contentModules: Record<string, () => Promise<unknown>> = {}
|
||||
// unrelated modules).
|
||||
type StepContentModule = { default: ComponentType<StepContentProps> }
|
||||
|
||||
let contentModules: Record<string, () => Promise<StepContentModule>> = {}
|
||||
if (!import.meta.env?.SSR) {
|
||||
try {
|
||||
contentModules = import.meta.glob('./content/**/content.{tsx,ts}')
|
||||
} catch {
|
||||
// webpack build: import.meta.glob is undefined, keep empty map
|
||||
}
|
||||
contentModules = import.meta.glob<StepContentModule>('./content/**/content.{tsx,ts}')
|
||||
}
|
||||
|
||||
type StepContentModule = { default: ComponentType<StepContentProps> }
|
||||
const EmptyStepContent = () => null
|
||||
|
||||
const stepContentComponents = new Map<
|
||||
string,
|
||||
@@ -174,13 +170,12 @@ function getStepContentComponent(
|
||||
const cached = stepContentComponents.get(filePath)
|
||||
if (cached) return cached
|
||||
|
||||
const viteLoader =
|
||||
const loader =
|
||||
contentModules[`./content/${filePath}/content.tsx`] ??
|
||||
contentModules[`./content/${filePath}/content.ts`]
|
||||
|
||||
const loader = viteLoader
|
||||
? (viteLoader as () => Promise<StepContentModule>)
|
||||
: () => import(/* @vite-ignore */ `./content/${filePath}/content`) as Promise<StepContentModule>
|
||||
contentModules[`./content/${filePath}/content.ts`] ??
|
||||
(import.meta.env?.SSR
|
||||
? () => Promise.resolve({ default: EmptyStepContent })
|
||||
: () => Promise.reject(new Error(`Connect step content not found: ${filePath}`)))
|
||||
|
||||
const Component = lazy(loader)
|
||||
stepContentComponents.set(filePath, Component)
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { FileData } from '@/components/ui/FileExplorerAndEditor/FileExplorerAndEditor.types'
|
||||
import { EdgeFunctionBodyData } from '@/data/edge-functions/edge-function-body-query'
|
||||
|
||||
// This file is bundled for both the browser (Next.js/webpack) and the TanStack Start (Vite) client,
|
||||
// which handle Node.js builtins differently — Vite stubs `path` out entirely for the browser, so
|
||||
// `path.posix` is undefined at runtime there even though it type-checks and builds fine under webpack.
|
||||
// These are self-contained posix path helpers (no `path` import) so behavior is identical everywhere.
|
||||
// Vite stubs Node.js builtins like `path` out for browser bundles, so `path.posix` would be
|
||||
// undefined at runtime in the client even though it type-checks. These are self-contained POSIX
|
||||
// path helpers (no `path` import) so behavior is identical on client and server.
|
||||
// Ported from the POSIX implementations in @std/path (JSR), which this file used to depend on directly.
|
||||
|
||||
function isPosixSeparator(code: number | undefined): boolean {
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
'use client'
|
||||
|
||||
import { ReactNode } from 'react'
|
||||
import { ErrorDisplay, SupportFormParams } from 'ui-patterns/ErrorDisplay/ErrorDisplay'
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
'use client'
|
||||
|
||||
import { useNavigate } from '@tanstack/react-router'
|
||||
import { toast } from 'sonner'
|
||||
import { ConfirmationModal } from 'ui-patterns/Dialogs/ConfirmationModal'
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
'use client'
|
||||
|
||||
import { ReactNode } from 'react'
|
||||
import { Accordion, cn } from 'ui'
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
'use client'
|
||||
|
||||
import { ExternalLinkIcon } from 'lucide-react'
|
||||
import { useState } from 'react'
|
||||
import { AccordionContent, AccordionItem, AccordionTrigger, Button } from 'ui'
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { QueryClient } from '@tanstack/react-query'
|
||||
import { createRootRoute, createRoute } from '@tanstack/react-router'
|
||||
import { screen } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import type { components } from 'api-types'
|
||||
@@ -12,9 +13,8 @@ import { edgeFunctionsKeys } from '@/data/edge-functions/keys'
|
||||
import { projectKeys } from '@/data/projects/keys'
|
||||
import { subscriptionKeys } from '@/data/subscriptions/keys'
|
||||
import { createMockProject } from '@/tests/helpers'
|
||||
import { customRender } from '@/tests/lib/custom-render'
|
||||
import { createTestRouter, customRender } from '@/tests/lib/custom-render'
|
||||
import { addAPIMock } from '@/tests/lib/msw'
|
||||
import { routerMock } from '@/tests/lib/route-mock'
|
||||
|
||||
type FunctionResponse = components['schemas']['FunctionResponse_Output']
|
||||
type ProjectSettingsResponse = components['schemas']['ProjectSettingsResponse_Output']
|
||||
@@ -69,7 +69,15 @@ const mockProjectSettings = () => {
|
||||
|
||||
it('shows a loader instead of an undefined function URL until the project endpoint loads', async () => {
|
||||
const user = userEvent.setup()
|
||||
routerMock.setCurrentUrl('/projects/default')
|
||||
const rootRoute = createRootRoute()
|
||||
const functionsRoute = createRoute({
|
||||
getParentRoute: () => rootRoute,
|
||||
path: '/project/$ref/functions',
|
||||
})
|
||||
const router = createTestRouter(
|
||||
'/project/default/functions',
|
||||
rootRoute.addChildren([functionsRoute])
|
||||
)
|
||||
mockProjectSettings()
|
||||
|
||||
const { container } = customRender(
|
||||
@@ -78,7 +86,7 @@ it('shows a loader instead of an undefined function URL until the project endpoi
|
||||
<EdgeFunctionsListItem function={edgeFunction} />
|
||||
</TableBody>
|
||||
</Table>,
|
||||
{ queryClient: createQueryClient() }
|
||||
{ queryClient: createQueryClient(), router }
|
||||
)
|
||||
|
||||
expect(screen.queryByText(/undefined\/functions\/v1/)).not.toBeInTheDocument()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'graphiql/setup-workers/webpack'
|
||||
import 'graphiql/setup-workers/vite'
|
||||
import './graphiql-styles.css'
|
||||
|
||||
import { useMonaco, type GraphiQLPlugin } from '@graphiql/react'
|
||||
|
||||
-2
@@ -1,5 +1,3 @@
|
||||
'use client'
|
||||
|
||||
import 'swiper/css'
|
||||
|
||||
import { Swiper, SwiperSlide } from 'swiper/react'
|
||||
|
||||
+1
-15
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, test } from 'vitest'
|
||||
|
||||
import { buildOrgUrl } from '@/components/interfaces/Organization/Organization.utils'
|
||||
import { buildOrgUrl } from './Organization.utils'
|
||||
|
||||
describe('buildOrgUrl', () => {
|
||||
describe('when slug is undefined (bare /org/_ route)', () => {
|
||||
@@ -23,20 +23,6 @@ describe('buildOrgUrl', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when slug is a string (next.js router quirk — single segment)', () => {
|
||||
test('returns the org project list url, ignoring the string slug', () => {
|
||||
expect(buildOrgUrl({ slug: 'general', orgSlug: 'my-org', queryString: '' })).toBe(
|
||||
'/org/my-org'
|
||||
)
|
||||
})
|
||||
|
||||
test('appends query string when present', () => {
|
||||
expect(buildOrgUrl({ slug: 'general', orgSlug: 'my-org', queryString: 'ref=abc' })).toBe(
|
||||
'/org/my-org?ref=abc'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('when slug is an array (sub-path route)', () => {
|
||||
test('preserves a single-segment sub-path', () => {
|
||||
expect(buildOrgUrl({ slug: ['general'], orgSlug: 'my-org', queryString: '' })).toBe(
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* Builds an org-scoped URL for the wildcard org route (/org/_).
|
||||
*
|
||||
* When `slug` is undefined the destination is the org project list at
|
||||
* /org/<orgSlug>. When `slug` is an array the sub-path is preserved so the
|
||||
* When `slug` is undefined or empty, the destination is the org project list at
|
||||
* /org/<orgSlug>. When `slug` has segments, the sub-path is preserved so the
|
||||
* user lands on the equivalent page for the chosen org.
|
||||
*/
|
||||
export function buildOrgUrl({
|
||||
@@ -10,16 +10,15 @@ export function buildOrgUrl({
|
||||
orgSlug,
|
||||
queryString,
|
||||
}: {
|
||||
slug: string | string[] | undefined
|
||||
slug: string[] | undefined
|
||||
orgSlug: string
|
||||
queryString: string
|
||||
}): string {
|
||||
const qs = queryString ? `?${queryString}` : ''
|
||||
if (!Array.isArray(slug)) {
|
||||
if (!slug?.length) {
|
||||
return `/org/${orgSlug}${qs}`
|
||||
}
|
||||
const slugPath = slug.reduce((a: string, b: string) => `${a}/${b}`, '').slice(1)
|
||||
return `/org/${orgSlug}/${slugPath}${qs}`
|
||||
return `/org/${orgSlug}/${slug.join('/')}${qs}`
|
||||
}
|
||||
|
||||
// Invite is expired if older than 24hrs
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { createRootRoute, createRoute } from '@tanstack/react-router'
|
||||
import { act, screen, waitFor } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import type { platformComponents as components } from 'api-types'
|
||||
@@ -9,12 +10,11 @@ import { Usage } from './Usage'
|
||||
import type { Branch } from '@/data/branches/branches-query'
|
||||
import { createMockOrganizationResponse, createMockProject } from '@/tests/helpers'
|
||||
import { createTestBranch } from '@/tests/lib/branch-test-utils'
|
||||
import { customRender } from '@/tests/lib/custom-render'
|
||||
import { createTestRouter, customRender } from '@/tests/lib/custom-render'
|
||||
import { addAPIMock, type APIErrorBody } from '@/tests/lib/msw'
|
||||
import { mockPermissions } from '@/tests/lib/msw-permissions'
|
||||
import { ALL_FGA_PERMISSIONS, allPermissionsFor } from '@/tests/lib/permissions-fixtures'
|
||||
import { createMockProfileContext } from '@/tests/lib/profile-helpers'
|
||||
import { routerMock } from '@/tests/lib/route-mock'
|
||||
|
||||
vi.mock('common', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof import('common')>()),
|
||||
@@ -53,12 +53,18 @@ function renderUsage(branchRef: string | null = branch.project_ref, projectRef =
|
||||
const onUrlUpdate = vi.fn<(event: UrlUpdateEvent) => void>()
|
||||
const searchParams: Record<string, string> = { projectRef }
|
||||
if (branchRef !== null) searchParams.branchRef = branchRef
|
||||
routerMock.setCurrentUrl({
|
||||
pathname: '/org/test-org/usage',
|
||||
query: { slug: 'test-org', ...searchParams },
|
||||
const rootRoute = createRootRoute()
|
||||
const usageRoute = createRoute({
|
||||
getParentRoute: () => rootRoute,
|
||||
path: '/org/$slug/usage',
|
||||
})
|
||||
const query = new URLSearchParams(searchParams).toString()
|
||||
const router = createTestRouter(
|
||||
`/org/test-org/usage${query ? `?${query}` : ''}`,
|
||||
rootRoute.addChildren([usageRoute])
|
||||
)
|
||||
customRender(<Usage />, {
|
||||
initialUrl: '/org/test-org/usage',
|
||||
router,
|
||||
profileContext: createMockProfileContext(),
|
||||
nuqs: { searchParams, hasMemory: true, onUrlUpdate },
|
||||
})
|
||||
|
||||
@@ -10,7 +10,7 @@ Quick run-through of the different building blocks that make up the SQL Editor,
|
||||
|
||||
- The Tabs interface is powered by a separate state [`tabs.ts`](https://github.com/supabase/supabase/blob/master/apps/studio/state/tabs.ts). (Also used by the Table Editor)
|
||||
|
||||
- Route validation to check for snippet validity + last visited snippet lies in the page level on [`[id].tsx`](https://github.com/supabase/supabase/blob/master/apps/studio/pages/project/%5Bref%5D/sql/%5Bid%5D.tsx)
|
||||
- Route validation to check for snippet validity + last visited snippet lies in the page level on [`$id.tsx`](https://github.com/supabase/supabase/blob/master/apps/studio/routes/project/$ref/sql/$id.tsx)
|
||||
|
||||
- When searching for snippets, we're deliberately opting to render the results as a flat list in [`SearchList`](https://github.com/supabase/supabase/blob/master/apps/studio/components/layouts/SQLEditorLayout/SQLEditorNavV2/SearchList.tsx) for ease of finding (rather than keeping the 3 separate sections / having folders)
|
||||
|
||||
@@ -37,10 +37,10 @@ Quick run-through of the different building blocks that make up the SQL Editor,
|
||||
- Snippets and folders are all initially loaded via React Query in [`SQLEditorNav`](https://github.com/supabase/supabase/blob/master/apps/studio/components/layouts/SQLEditorLayout/SQLEditorNavV2/SQLEditorNav.tsx), which are then initialized into the Valtio store via [`snapV2.addSnippet`](https://github.com/supabase/supabase/blob/master/apps/studio/components/layouts/SQLEditorLayout/SQLEditorNavV2/SQLEditorNav.tsx#L415) calls in the `useEffects`
|
||||
|
||||
- On `/editor/sql`
|
||||
- We'll redirect users to the last visited snippet if there's one (`/editor/sql/[id]`), otherwise will redirect to `/editor/sql/new` (within [`[id].tsx`](https://github.com/supabase/supabase/blob/master/apps/studio/pages/project/%5Bref%5D/sql/%5Bid%5D.tsx) )
|
||||
- We'll redirect users to the last visited snippet if there's one (`/editor/sql/[id]`), otherwise will redirect to `/editor/sql/new` (within [`$id.tsx`](https://github.com/supabase/supabase/blob/master/apps/studio/routes/project/$ref/sql/$id.tsx))
|
||||
|
||||
- On `/editor/sql/[id]`
|
||||
- We'll load the content of the snippet via `useContentQuery` and update the Valtio store via [`snapV2.setSnippet`](https://github.com/supabase/supabase/blob/master/apps/studio/pages/project/%5Bref%5D/sql/%5Bid%5D.tsx#L69)
|
||||
- We'll load the content of the snippet via `useContentQuery` and update the Valtio store via [`snapV2.setSnippet`](https://github.com/supabase/supabase/blob/master/apps/studio/routes/project/$ref/sql/$id.tsx#L70)
|
||||
|
||||
### Writing a snippet
|
||||
|
||||
|
||||
+18
-12
@@ -1,40 +1,46 @@
|
||||
import { createRootRoute, createRoute } from '@tanstack/react-router'
|
||||
import { act, waitFor } from '@testing-library/react'
|
||||
import mockRouter from 'next-router-mock'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import { useSnippetIdentity } from './useSnippetIdentity'
|
||||
import {
|
||||
renderSqlEditorHook,
|
||||
resetSqlEditorStores,
|
||||
seedSnippet,
|
||||
} from '@/tests/lib/sql-editor-test-utils'
|
||||
import { createTestRouter, customRenderHook } from '@/tests/lib/custom-render'
|
||||
import { resetSqlEditorStores, seedSnippet } from '@/tests/lib/sql-editor-test-utils'
|
||||
|
||||
// `common`'s `useParams` is globally stubbed (see tests/vitestSetup.ts) to a
|
||||
// constant `{ ref: 'default' }` so most tests don't have to think about
|
||||
// routing. This suite is specifically about behavior across route changes, so
|
||||
// it swaps in the real implementation, which the test `FrameworkProvider` in
|
||||
// tests/lib/custom-render.tsx feeds from `next-router-mock`.
|
||||
// tests/lib/custom-render.tsx feeds from the TanStack test router.
|
||||
vi.mock('common', async (importOriginal) => {
|
||||
const actual = (await importOriginal()) as object
|
||||
return { ...actual }
|
||||
})
|
||||
|
||||
const createSqlRouter = (initialUrl: string) => {
|
||||
const rootRoute = createRootRoute()
|
||||
const sqlRoute = createRoute({
|
||||
getParentRoute: () => rootRoute,
|
||||
path: '/project/$ref/sql/$id',
|
||||
})
|
||||
return createTestRouter(initialUrl, rootRoute.addChildren([sqlRoute]))
|
||||
}
|
||||
|
||||
describe('useSnippetIdentity across route changes', () => {
|
||||
beforeEach(() => {
|
||||
resetSqlEditorStores()
|
||||
mockRouter.setCurrentUrl('/project/default/sql/existing-tab')
|
||||
})
|
||||
|
||||
it('generates a fresh id for each new tab, never reusing the previous one', async () => {
|
||||
seedSnippet({ id: 'existing-tab', sql: 'select existing;' })
|
||||
const router = createSqlRouter('/project/default/sql/existing-tab')
|
||||
|
||||
const { result } = renderSqlEditorHook(useSnippetIdentity)
|
||||
const { result } = customRenderHook(useSnippetIdentity, { router })
|
||||
|
||||
await waitFor(() => expect(result.current.id).toEqual('existing-tab'))
|
||||
|
||||
// Click "+" to open a new tab.
|
||||
await act(async () => {
|
||||
await mockRouter.push('/project/default/sql/new?skip=true')
|
||||
await router.navigate({ href: '/project/default/sql/new?skip=true' })
|
||||
})
|
||||
const firstNewTabId = result.current.id
|
||||
expect(firstNewTabId).not.toEqual('existing-tab')
|
||||
@@ -43,13 +49,13 @@ describe('useSnippetIdentity across route changes', () => {
|
||||
// (mirrors the `navigateToUrl` call inside `useSnippetEditor.handleEditorChange`).
|
||||
seedSnippet({ id: firstNewTabId, sql: 'select typed content;' })
|
||||
await act(async () => {
|
||||
await mockRouter.push(`/project/default/sql/${firstNewTabId}`)
|
||||
await router.navigate({ href: `/project/default/sql/${firstNewTabId}` })
|
||||
})
|
||||
await waitFor(() => expect(result.current.id).toEqual(firstNewTabId))
|
||||
|
||||
// Click "+" again to open a second new tab.
|
||||
await act(async () => {
|
||||
await mockRouter.push('/project/default/sql/new?skip=true')
|
||||
await router.navigate({ href: '/project/default/sql/new?skip=true' })
|
||||
})
|
||||
const secondNewTabId = result.current.id
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { faker } from '@faker-js/faker'
|
||||
import { createRootRoute, createRoute } from '@tanstack/react-router'
|
||||
import { fireEvent, screen, waitFor } from '@testing-library/dom'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import { useState } from 'react'
|
||||
@@ -7,14 +8,26 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { DeleteBucketModal } from './DeleteBucketModal'
|
||||
import { ProjectContextProvider } from '@/components/layouts/ProjectLayout/ProjectContext'
|
||||
import { Bucket } from '@/data/storage/buckets-query'
|
||||
import { customRender } from '@/tests/lib/custom-render'
|
||||
import { createTestRouter, customRender } from '@/tests/lib/custom-render'
|
||||
import { addAPIMock } from '@/tests/lib/msw'
|
||||
import { routerMock } from '@/tests/lib/route-mock'
|
||||
|
||||
// Use the real `useParams` (backed by the router mock) instead of the global stub, so the
|
||||
// Use the real `useParams` (backed by the TanStack test router) instead of the global stub, so the
|
||||
// modal sees the `bucketId` of the current URL.
|
||||
vi.mock('common', async (importOriginal) => importOriginal<typeof import('common')>())
|
||||
|
||||
const createStorageRouter = (initialUrl: string) => {
|
||||
const rootRoute = createRootRoute()
|
||||
const filesRoute = createRoute({
|
||||
getParentRoute: () => rootRoute,
|
||||
path: '/project/$ref/storage/files',
|
||||
})
|
||||
const bucketRoute = createRoute({
|
||||
getParentRoute: () => rootRoute,
|
||||
path: '/project/$ref/storage/files/buckets/$bucketId',
|
||||
})
|
||||
return createTestRouter(initialUrl, rootRoute.addChildren([filesRoute, bucketRoute]))
|
||||
}
|
||||
|
||||
const bucket: Bucket = {
|
||||
id: 'test',
|
||||
name: 'test',
|
||||
@@ -51,8 +64,6 @@ const Page = ({ onClose }: { onClose: () => void }) => {
|
||||
|
||||
describe(`DeleteBucketModal`, () => {
|
||||
beforeEach(() => {
|
||||
// useParams
|
||||
routerMock.setCurrentUrl(`/project/default/storage/files`)
|
||||
// useProjectContext
|
||||
addAPIMock({
|
||||
method: `get`,
|
||||
@@ -117,7 +128,7 @@ describe(`DeleteBucketModal`, () => {
|
||||
it(`renders a confirmation dialog`, async () => {
|
||||
const onClose = vi.fn()
|
||||
const { router } = customRender(<Page onClose={onClose} />, {
|
||||
initialUrl: `/project/default/storage/files`,
|
||||
router: createStorageRouter(`/project/default/storage/files`),
|
||||
})
|
||||
|
||||
const openButton = screen.getByRole(`button`, { name: `Open` })
|
||||
@@ -136,9 +147,10 @@ describe(`DeleteBucketModal`, () => {
|
||||
|
||||
it(`navigates from the deleted bucket's page to the buckets list`, async () => {
|
||||
const bucketUrl = `/project/default/storage/files/buckets/${bucket.id}?action=delete`
|
||||
routerMock.setCurrentUrl(bucketUrl)
|
||||
const onClose = vi.fn()
|
||||
const { router } = customRender(<Page onClose={onClose} />, { initialUrl: bucketUrl })
|
||||
const { router } = customRender(<Page onClose={onClose} />, {
|
||||
router: createStorageRouter(bucketUrl),
|
||||
})
|
||||
|
||||
await userEvent.click(screen.getByRole(`button`, { name: `Open` }))
|
||||
await screen.findByRole(`dialog`)
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import { fireEvent, screen, waitFor } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import { http, HttpResponse, type JsonBodyType } from 'msw'
|
||||
import { beforeEach, describe, expect, test, vi } from 'vitest'
|
||||
import { describe, expect, test, vi } from 'vitest'
|
||||
|
||||
import { CsatSurvey } from './CsatSurvey'
|
||||
import { API_URL } from '@/lib/constants'
|
||||
import { customRender } from '@/tests/lib/custom-render'
|
||||
import { mswServer } from '@/tests/lib/msw'
|
||||
import { routerMock } from '@/tests/lib/route-mock'
|
||||
|
||||
// The global test setup stubs useParams; restore the real one so the URL query drives the page.
|
||||
vi.mock('common', async (importOriginal) => {
|
||||
@@ -35,15 +34,11 @@ const submitForm = () => {
|
||||
fireEvent.submit(form)
|
||||
}
|
||||
|
||||
const DEFAULT_CSAT_URL = '/support/csat?conversation_id=cnv_1abc2&helpful=yes'
|
||||
|
||||
describe('CsatSurvey', () => {
|
||||
beforeEach(() => {
|
||||
routerMock.setCurrentUrl('/support/csat?conversation_id=cnv_1abc2&helpful=yes')
|
||||
})
|
||||
|
||||
test('shows the ticket error when the link has no ticket reference', () => {
|
||||
routerMock.setCurrentUrl('/support/csat')
|
||||
|
||||
customRender(<CsatSurvey />)
|
||||
customRender(<CsatSurvey />, { initialUrl: '/support/csat' })
|
||||
|
||||
expect(screen.getByText('Invalid or mismatched ticket')).toBeInTheDocument()
|
||||
})
|
||||
@@ -51,7 +46,7 @@ describe('CsatSurvey', () => {
|
||||
test('preselects the answer from the link and submits it with a comment', async () => {
|
||||
const requests = mockSubmit(200)
|
||||
|
||||
customRender(<CsatSurvey />)
|
||||
customRender(<CsatSurvey />, { initialUrl: DEFAULT_CSAT_URL })
|
||||
|
||||
expect(screen.getByRole('button', { name: 'Yes' })).toHaveAttribute('aria-pressed', 'true')
|
||||
await userEvent.type(screen.getByLabelText(/add a comment/i), 'Quick and helpful')
|
||||
@@ -68,7 +63,7 @@ describe('CsatSurvey', () => {
|
||||
test('lets the customer change the answer before submitting', async () => {
|
||||
const requests = mockSubmit(200)
|
||||
|
||||
customRender(<CsatSurvey />)
|
||||
customRender(<CsatSurvey />, { initialUrl: DEFAULT_CSAT_URL })
|
||||
|
||||
await userEvent.click(screen.getByRole('button', { name: 'No' }))
|
||||
submitForm()
|
||||
@@ -80,7 +75,7 @@ describe('CsatSurvey', () => {
|
||||
test('shows the already-submitted error on a 409', async () => {
|
||||
mockSubmit(409, { message: 'This survey has already been answered' })
|
||||
|
||||
customRender(<CsatSurvey />)
|
||||
customRender(<CsatSurvey />, { initialUrl: DEFAULT_CSAT_URL })
|
||||
|
||||
submitForm()
|
||||
|
||||
@@ -90,7 +85,7 @@ describe('CsatSurvey', () => {
|
||||
test('shows the ticket error on a 404', async () => {
|
||||
mockSubmit(404, { message: 'No survey was sent for this conversation' })
|
||||
|
||||
customRender(<CsatSurvey />)
|
||||
customRender(<CsatSurvey />, { initialUrl: DEFAULT_CSAT_URL })
|
||||
|
||||
submitForm()
|
||||
|
||||
@@ -100,7 +95,7 @@ describe('CsatSurvey', () => {
|
||||
test('keeps the form and shows the error on other failures', async () => {
|
||||
mockSubmit(500, { message: 'Failed to record survey response' })
|
||||
|
||||
customRender(<CsatSurvey />)
|
||||
customRender(<CsatSurvey />, { initialUrl: DEFAULT_CSAT_URL })
|
||||
|
||||
submitForm()
|
||||
|
||||
|
||||
+2
-9
@@ -4,9 +4,7 @@ import { fireEvent, screen } from '@testing-library/react'
|
||||
import type { platformComponents } from 'api-types'
|
||||
import { FeatureFlagContext } from 'common'
|
||||
import { HttpResponse } from 'msw'
|
||||
import routerMock from 'next-router-mock'
|
||||
import { createDynamicRouteParser } from 'next-router-mock/dynamic-routes'
|
||||
import { afterAll, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { columnSchema, querySearchParamsSchema } from '../UnifiedLogs.schema'
|
||||
import { LogDetail } from './LogDetail'
|
||||
@@ -17,9 +15,6 @@ import { customRender } from '@/tests/lib/custom-render'
|
||||
import { addAPIMock, type APIErrorBody } from '@/tests/lib/msw'
|
||||
|
||||
type AnalyticsResponse = platformComponents['schemas']['AnalyticsResponse_Output']
|
||||
vi.unmock('common')
|
||||
const removeRouteParser = routerMock.useParser(createDynamicRouteParser(['/project/[ref]/logs']))
|
||||
afterAll(removeRouteParser)
|
||||
|
||||
const row = columnSchema.parse({
|
||||
id: 'realtime-log',
|
||||
@@ -104,13 +99,11 @@ const renderDetail = (tab: 'overview' | 'raw-json') => {
|
||||
<Harness tab={tab} />
|
||||
</FeaturePreviewContextProvider>
|
||||
</FeatureFlagContext.Provider>,
|
||||
{ queryClient }
|
||||
{ queryClient, initialUrl: '/project/default/logs' }
|
||||
)
|
||||
}
|
||||
|
||||
describe('log detail attributes', () => {
|
||||
beforeEach(() => routerMock.setCurrentUrl('/project/default/logs'))
|
||||
|
||||
it.each(['overview', 'raw-json'] as const)(
|
||||
'shows retrieval failures in the %s tab',
|
||||
async (tab) => {
|
||||
|
||||
@@ -4,9 +4,7 @@ import userEvent from '@testing-library/user-event'
|
||||
import type { platformComponents } from 'api-types'
|
||||
import { FeatureFlagContext } from 'common'
|
||||
import { HttpResponse } from 'msw'
|
||||
import routerMock from 'next-router-mock'
|
||||
import { createDynamicRouteParser } from 'next-router-mock/dynamic-routes'
|
||||
import { afterAll, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { z } from 'zod'
|
||||
|
||||
import { ColumnSchema } from '../UnifiedLogs.schema'
|
||||
@@ -30,9 +28,6 @@ vi.mock('@/lib/constants', async (importOriginal) => ({
|
||||
},
|
||||
}))
|
||||
|
||||
vi.unmock('common')
|
||||
const removeRouteParser = routerMock.useParser(createDynamicRouteParser(['/project/[ref]/logs']))
|
||||
afterAll(removeRouteParser)
|
||||
const requestSchema = z.object({ sql: z.string() })
|
||||
|
||||
const USER_ID = '6f1c1a8e-4a0b-4c1e-9b1e-2f3a4b5c6d7e'
|
||||
@@ -155,6 +150,7 @@ function renderUser(
|
||||
</FeatureFlagContext.Provider>,
|
||||
{
|
||||
queryClient,
|
||||
initialUrl: '/project/default/logs',
|
||||
nuqs: { onUrlUpdate: ({ queryString }) => urlUpdates.push(queryString) },
|
||||
}
|
||||
)
|
||||
@@ -171,7 +167,6 @@ const user: User = {
|
||||
describe('LogUser', () => {
|
||||
beforeEach(() => {
|
||||
deployment.basePath = ''
|
||||
routerMock.setCurrentUrl('/project/default/logs')
|
||||
})
|
||||
it("shows the log's own user without looking up the rest of the request", async () => {
|
||||
const { logQueries } = renderUser({ ...baseLog, auth_user: USER_ID }, { users: [user] })
|
||||
|
||||
+2
-8
@@ -5,11 +5,9 @@ import userEvent from '@testing-library/user-event'
|
||||
import type { platformComponents } from 'api-types'
|
||||
import { FeatureFlagContext, LOCAL_STORAGE_KEYS } from 'common'
|
||||
import { HttpResponse } from 'msw'
|
||||
import routerMock from 'next-router-mock'
|
||||
import { createDynamicRouteParser } from 'next-router-mock/dynamic-routes'
|
||||
import { useQueryStates } from 'nuqs'
|
||||
import { ResizablePanelGroup } from 'ui'
|
||||
import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { z } from 'zod'
|
||||
|
||||
import { ServiceFlowPanel } from '../ServiceFlowPanel'
|
||||
@@ -29,9 +27,6 @@ import { addAPIMock } from '@/tests/lib/msw'
|
||||
|
||||
type LogsResponse = platformComponents['schemas']['AnalyticsResponse_Output']
|
||||
|
||||
vi.unmock('common')
|
||||
const removeRouteParser = routerMock.useParser(createDynamicRouteParser(['/project/[ref]/logs']))
|
||||
afterAll(removeRouteParser)
|
||||
const requestSchema = z.object({ sql: z.string() })
|
||||
|
||||
const RAY_ID = '8f00aa11bb22cc33-IAD'
|
||||
@@ -204,13 +199,12 @@ function renderPanel(
|
||||
</TimezoneProvider>
|
||||
</FeaturePreviewContextProvider>
|
||||
</FeatureFlagContext.Provider>,
|
||||
{ queryClient }
|
||||
{ queryClient, initialUrl: '/project/default/logs' }
|
||||
)
|
||||
return { queries, queryClient }
|
||||
}
|
||||
|
||||
describe('request timeline tab', () => {
|
||||
beforeEach(() => routerMock.setCurrentUrl('/project/default/logs'))
|
||||
afterEach(() => localStorage.removeItem(LOCAL_STORAGE_KEYS.UI_TIMEZONE))
|
||||
const openTimeline = async (user: ReturnType<typeof userEvent.setup>) => {
|
||||
await user.click(screen.getByRole('tab', { name: 'Timeline' }))
|
||||
|
||||
+1
-7
@@ -4,9 +4,7 @@ import userEvent from '@testing-library/user-event'
|
||||
import type { platformComponents } from 'api-types'
|
||||
import { FeatureFlagContext } from 'common'
|
||||
import { HttpResponse } from 'msw'
|
||||
import routerMock from 'next-router-mock'
|
||||
import { createDynamicRouteParser } from 'next-router-mock/dynamic-routes'
|
||||
import { afterAll, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { z } from 'zod'
|
||||
|
||||
import { UserRecentLogs } from './UserRecentLogs'
|
||||
@@ -18,9 +16,6 @@ import { addAPIMock } from '@/tests/lib/msw'
|
||||
|
||||
type LogsResponse = platformComponents['schemas']['AnalyticsResponse_Output']
|
||||
|
||||
vi.unmock('common')
|
||||
const removeRouteParser = routerMock.useParser(createDynamicRouteParser(['/project/[ref]/logs']))
|
||||
afterAll(removeRouteParser)
|
||||
const requestSchema = z.object({ sql: z.string() })
|
||||
|
||||
const USER_ID = '6f1c1a8e-4a0b-4c1e-9b1e-2f3a4b5c6d7e'
|
||||
@@ -80,7 +75,6 @@ function renderRecentLogs(
|
||||
}
|
||||
|
||||
describe('UserRecentLogs', () => {
|
||||
beforeEach(() => routerMock.setCurrentUrl('/project/default/logs'))
|
||||
it("lists the user's recent logs and opens one on the logs page", async () => {
|
||||
const { queries, router } = renderRecentLogs([
|
||||
listRow('log-2', '2026-01-02T09:30:00.000000', '/rest/v1/todos'),
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
'use client'
|
||||
|
||||
import type { SidebarSection } from './AccountLayout.types'
|
||||
import { getActiveKey, toSubMenuSections } from './AccountLayout.utils'
|
||||
import { SubMenu } from '@/components/ui/ProductMenu/SubMenu'
|
||||
|
||||
+18
-11
@@ -9,7 +9,6 @@ import { StudioMobileSheetNav } from './StudioMobileSheetNav'
|
||||
import { SIDEBAR_KEYS } from '@/components/layouts/ProjectLayout/LayoutSidebar/LayoutSidebarProvider'
|
||||
import { sidebarManagerState } from '@/state/sidebar-manager-state'
|
||||
import { customRender } from '@/tests/lib/custom-render'
|
||||
import { routerMock } from '@/tests/lib/route-mock'
|
||||
|
||||
mockAnimationsApi()
|
||||
|
||||
@@ -54,43 +53,51 @@ describe('StudioMobileSheetNav', () => {
|
||||
'closes %s content for query navigation while Issues menu filtering is preserved',
|
||||
async (namedContent) => {
|
||||
vi.stubGlobal('innerWidth', 390)
|
||||
routerMock.setCurrentUrl('/project/default/issues?q=function')
|
||||
sidebarManagerState.registerSidebar(SIDEBAR_KEYS.HELP_PANEL, () => (
|
||||
<SheetTitle>Help</SheetTitle>
|
||||
))
|
||||
const user = userEvent.setup()
|
||||
customRender(
|
||||
const { router } = customRender(
|
||||
<MobileSheetProvider>
|
||||
<IssuesMobileMenu namedContent={namedContent} />
|
||||
</MobileSheetProvider>
|
||||
</MobileSheetProvider>,
|
||||
{ initialUrl: '/project/default/issues?q=function' }
|
||||
)
|
||||
await user.click(screen.getByRole('button', { name: 'Open issues menu' }))
|
||||
expect(await screen.findByRole('dialog')).toBeInTheDocument()
|
||||
|
||||
await act(async () => routerMock.push('/project/default/issues?category=security'))
|
||||
await act(async () => {
|
||||
await router.navigate({ href: '/project/default/issues?category=security' })
|
||||
})
|
||||
await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument())
|
||||
}
|
||||
)
|
||||
|
||||
it('keeps the Issues menu open for filter updates and closes for an issue link', async () => {
|
||||
vi.stubGlobal('innerWidth', 390)
|
||||
routerMock.setCurrentUrl('/project/default/issues')
|
||||
const user = userEvent.setup()
|
||||
customRender(
|
||||
const { router } = customRender(
|
||||
<MobileSheetProvider>
|
||||
<IssuesMobileMenu />
|
||||
</MobileSheetProvider>
|
||||
</MobileSheetProvider>,
|
||||
{ initialUrl: '/project/default/issues' }
|
||||
)
|
||||
await user.click(screen.getByRole('button', { name: 'Open issues menu' }))
|
||||
expect(await screen.findByRole('dialog', { name: 'Issues menu' })).toBeInTheDocument()
|
||||
|
||||
await act(async () => routerMock.push('/project/default/issues?q=function'))
|
||||
await act(async () => {
|
||||
await router.navigate({ href: '/project/default/issues?q=function' })
|
||||
})
|
||||
expect(screen.getByRole('dialog', { name: 'Issues menu' })).toBeInTheDocument()
|
||||
|
||||
await act(async () => routerMock.push('/project/default/issues'))
|
||||
await act(async () => {
|
||||
await router.navigate({ href: '/project/default/issues' })
|
||||
})
|
||||
expect(screen.getByRole('dialog', { name: 'Issues menu' })).toBeInTheDocument()
|
||||
|
||||
await act(async () => routerMock.push('/project/default/issues/function_search_path_mutable'))
|
||||
await act(async () => {
|
||||
await router.navigate({ href: '/project/default/issues/function_search_path_mutable' })
|
||||
})
|
||||
await waitFor(() =>
|
||||
expect(screen.queryByRole('dialog', { name: 'Issues menu' })).not.toBeInTheDocument()
|
||||
)
|
||||
|
||||
@@ -94,7 +94,7 @@ const OrganizationLayoutContent = ({
|
||||
false
|
||||
)
|
||||
|
||||
// Keep title intent close to each page (getLayout) to avoid route-to-title drift in this layout.
|
||||
// Keep title intent close to each route to avoid route-to-title drift in this layout.
|
||||
const isSettingsSurface = ORG_SETTINGS_ROUTES.some((x) => routePattern.endsWith(`/${x}`))
|
||||
const pageTitle = buildStudioPageTitle({
|
||||
section: title,
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
'use client'
|
||||
|
||||
import { useLocation } from '@tanstack/react-router'
|
||||
import { useLayoutEffect } from 'react'
|
||||
|
||||
|
||||
-2
@@ -1,5 +1,3 @@
|
||||
'use client'
|
||||
|
||||
import { useLocation } from '@tanstack/react-router'
|
||||
import { useFlag, useParams } from 'common'
|
||||
import { Home } from 'icons'
|
||||
|
||||
-2
@@ -1,5 +1,3 @@
|
||||
'use client'
|
||||
|
||||
import { useLocation } from '@tanstack/react-router'
|
||||
import { useIsMFAEnabled, useParams } from 'common'
|
||||
import {
|
||||
|
||||
-2
@@ -1,5 +1,3 @@
|
||||
'use client'
|
||||
|
||||
import { useNavigate } from '@tanstack/react-router'
|
||||
import { useCallback, useState } from 'react'
|
||||
|
||||
|
||||
-2
@@ -1,5 +1,3 @@
|
||||
'use client'
|
||||
|
||||
import { useCallback, useState } from 'react'
|
||||
|
||||
import { getOrgMenuComponent } from './mobileOrgMenuRegistry'
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
'use client'
|
||||
|
||||
import { useCallback, useEffect, useRef, type ReactNode } from 'react'
|
||||
import {
|
||||
AlertDialog,
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
'use client'
|
||||
|
||||
import { useState } from 'react'
|
||||
import { cn, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from 'ui'
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
'use client'
|
||||
|
||||
import { useParams } from 'common'
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from 'ui'
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
'use client'
|
||||
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
import { useParams } from 'common'
|
||||
import { useEffect, useState } from 'react'
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
'use client'
|
||||
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
import { useParams } from 'common'
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
+2
-4
@@ -121,10 +121,8 @@ export function getCSP() {
|
||||
STAPE_URL,
|
||||
...(isDevOrStaging ? [POSTHOG_URL] : []),
|
||||
]
|
||||
// The TanStack build renders remote images as plain <img> tags (no image
|
||||
// optimizer proxy), so every remote image origin must be listed here
|
||||
// explicitly — unlike the Next.js build, where the optimizer serves them
|
||||
// from same-origin /_next/image URLs covered by 'self'.
|
||||
// Remote images are rendered as plain <img> tags (no image optimizer proxy),
|
||||
// so every remote image origin must be listed here explicitly.
|
||||
const IMG_SRC_URLS = [
|
||||
SUPABASE_URL,
|
||||
SUPABASE_COM_URL,
|
||||
|
||||
@@ -7,7 +7,7 @@ const reactGoogleTranslate = require('eslint-plugin-react-google-translate')
|
||||
// `context.getScope()`, which ESLint 9 removed. fixupPluginRules shims the
|
||||
// deprecated context methods so the rules run under flat config.
|
||||
const reactHookForm = require('eslint-plugin-react-hook-form')
|
||||
const supabaseConfig = require('eslint-config-supabase/next')
|
||||
const supabaseConfig = require('eslint-config-supabase/react')
|
||||
const fga = require('./scripts/eslint-rules/fga.cjs')
|
||||
|
||||
// Analytics SQL wire boundary — see the block below for context. Shared so the
|
||||
@@ -92,6 +92,9 @@ const TOOL_MODULE_RESTRICTED_IMPORT_PATTERNS = [
|
||||
]
|
||||
|
||||
module.exports = defineConfig([
|
||||
// Keep `.next` and `next-env.d.ts` ignored so dev checkouts with stale pre-migration Next output
|
||||
// don't trip local lint runs.
|
||||
{ ignores: ['.next', 'next-env.d.ts', '.output', '.vercel'] },
|
||||
{ files: ['**/*.ts', '**/*.tsx'] },
|
||||
supabaseConfig,
|
||||
{
|
||||
@@ -107,7 +110,6 @@ module.exports = defineConfig([
|
||||
'react-google-translate': reactGoogleTranslate,
|
||||
},
|
||||
rules: {
|
||||
'@next/next/no-img-element': 'off',
|
||||
'react/no-unescaped-entities': 'off',
|
||||
'react/display-name': 'warn',
|
||||
'react/no-unstable-nested-components': 'warn',
|
||||
|
||||
@@ -16,7 +16,9 @@ const tsparser = require('@typescript-eslint/parser')
|
||||
const fga = require('./scripts/eslint-rules/fga.cjs')
|
||||
|
||||
module.exports = defineConfig([
|
||||
{ ignores: ['.next', 'dist', 'public', '.contentlayer', '**/*.mts', '**/*.cts', '**/*.d.ts'] },
|
||||
{
|
||||
ignores: ['.next', 'dist', 'public', '.output', '.vercel', '**/*.mts', '**/*.cts', '**/*.d.ts'],
|
||||
},
|
||||
{
|
||||
files: ['**/*.ts', '**/*.tsx'],
|
||||
// Tests and scripts don't build query options for components, and the test fixtures live in
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// @vitest-environment jsdom
|
||||
import mockRouter from 'next-router-mock'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import { useInboundBranding } from '../useInboundBranding'
|
||||
@@ -11,7 +10,7 @@ import { customRenderHook } from '@/tests/lib/custom-render'
|
||||
|
||||
// The global mock in vitestSetup.ts stubs `useParams` to always return `{ ref: 'default' }`, which
|
||||
// doesn't reflect the `method`/`destination` query params this hook relies on — restore the real
|
||||
// implementation here so it reads them from the mocked router.
|
||||
// implementation here so it reads them from the TanStack test router.
|
||||
vi.mock('common', async (importOriginal) => {
|
||||
const actual = (await importOriginal()) as object
|
||||
return { ...actual }
|
||||
@@ -27,50 +26,49 @@ const enabledProvider: ExternalIdentityProviderConfig = GITHUB_IDENTITY_PROVIDER
|
||||
|
||||
describe('useInboundBranding', () => {
|
||||
beforeEach(() => {
|
||||
mockRouter.setCurrentUrl('/sign-in')
|
||||
mockEnabledProviders.mockReturnValue([enabledProvider])
|
||||
})
|
||||
|
||||
it('focuses an enabled provider without deriving a destination', () => {
|
||||
mockRouter.setCurrentUrl('/sign-in?method=github')
|
||||
|
||||
const { result } = customRenderHook(() => useInboundBranding('sign-in'))
|
||||
const { result } = customRenderHook(() => useInboundBranding('sign-in'), {
|
||||
initialUrl: '/sign-in?method=github',
|
||||
})
|
||||
|
||||
expect(result.current.focusProvider?.authProvider).toBe('github')
|
||||
expect(result.current.destination).toBeUndefined()
|
||||
})
|
||||
|
||||
it('does not focus on a destination id passed as the method param', () => {
|
||||
mockRouter.setCurrentUrl('/sign-in?method=cli')
|
||||
|
||||
const { result } = customRenderHook(() => useInboundBranding('sign-in'))
|
||||
const { result } = customRenderHook(() => useInboundBranding('sign-in'), {
|
||||
initialUrl: '/sign-in?method=cli',
|
||||
})
|
||||
|
||||
expect(result.current.focusProvider).toBeUndefined()
|
||||
expect(result.current.destination).toBeUndefined()
|
||||
})
|
||||
|
||||
it('derives the destination from the destination param without a focused provider', () => {
|
||||
mockRouter.setCurrentUrl('/sign-in?destination=cli')
|
||||
|
||||
const { result } = customRenderHook(() => useInboundBranding('sign-in'))
|
||||
const { result } = customRenderHook(() => useInboundBranding('sign-in'), {
|
||||
initialUrl: '/sign-in?destination=cli',
|
||||
})
|
||||
|
||||
expect(result.current.destination?.id).toBe('cli')
|
||||
expect(result.current.focusProvider).toBeUndefined()
|
||||
})
|
||||
|
||||
it('keeps the destination when a provider is focused', () => {
|
||||
mockRouter.setCurrentUrl('/sign-in?destination=cli&method=github')
|
||||
|
||||
const { result } = customRenderHook(() => useInboundBranding('sign-in'))
|
||||
const { result } = customRenderHook(() => useInboundBranding('sign-in'), {
|
||||
initialUrl: '/sign-in?destination=cli&method=github',
|
||||
})
|
||||
|
||||
expect(result.current.destination?.id).toBe('cli')
|
||||
expect(result.current.focusProvider?.authProvider).toBe('github')
|
||||
})
|
||||
|
||||
it('ignores an unknown destination param', () => {
|
||||
mockRouter.setCurrentUrl('/sign-in?destination=not-a-real-destination')
|
||||
|
||||
const { result } = customRenderHook(() => useInboundBranding('sign-in'))
|
||||
const { result } = customRenderHook(() => useInboundBranding('sign-in'), {
|
||||
initialUrl: '/sign-in?destination=not-a-real-destination',
|
||||
})
|
||||
|
||||
expect(result.current.destination).toBeUndefined()
|
||||
expect(result.current.focusProvider).toBeUndefined()
|
||||
@@ -78,9 +76,10 @@ describe('useInboundBranding', () => {
|
||||
|
||||
it('does not focus a provider that is hidden from the current flow', () => {
|
||||
mockEnabledProviders.mockReturnValue([{ ...enabledProvider, showOnSignUp: false }])
|
||||
mockRouter.setCurrentUrl('/sign-up?method=github')
|
||||
|
||||
const { result } = customRenderHook(() => useInboundBranding('sign-up'))
|
||||
const { result } = customRenderHook(() => useInboundBranding('sign-up'), {
|
||||
initialUrl: '/sign-up?method=github',
|
||||
})
|
||||
|
||||
expect(result.current.focusProvider).toBeUndefined()
|
||||
expect(result.current.destination).toBeUndefined()
|
||||
@@ -88,9 +87,10 @@ describe('useInboundBranding', () => {
|
||||
|
||||
it('does not focus a provider that is not enabled', () => {
|
||||
mockEnabledProviders.mockReturnValue([])
|
||||
mockRouter.setCurrentUrl('/sign-in?method=github')
|
||||
|
||||
const { result } = customRenderHook(() => useInboundBranding('sign-in'))
|
||||
const { result } = customRenderHook(() => useInboundBranding('sign-in'), {
|
||||
initialUrl: '/sign-in?method=github',
|
||||
})
|
||||
|
||||
expect(result.current.focusProvider).toBeUndefined()
|
||||
expect(result.current.destination).toBeUndefined()
|
||||
|
||||
@@ -2,11 +2,11 @@ import { createMCPClient } from '@ai-sdk/mcp'
|
||||
|
||||
/**
|
||||
* Default MCP server URL used when `NEXT_PUBLIC_MCP_URL` is not configured (local
|
||||
* development). Mirrors `DEFAULT_MCP_URL_PLATFORM` in `ui-patterns/McpUrlBuilder`
|
||||
* so the assistant resolves the same endpoint as the Connect sheet. It's
|
||||
* duplicated here (rather than imported) to keep
|
||||
* `ui-patterns/McpUrlBuilder/constants` — which pulls in `next/image` and image
|
||||
* assets — out of this server-side bundle.
|
||||
* development). Mirrors `DEFAULT_MCP_URL_PLATFORM` in
|
||||
* `ui-patterns/McpUrlBuilder/clients.data` so the assistant resolves the same
|
||||
* endpoint as the Connect sheet. It's duplicated here (rather than imported) to
|
||||
* keep `ui-patterns/McpUrlBuilder` (UI components and image assets) out of this
|
||||
* server-side bundle.
|
||||
*/
|
||||
const DEFAULT_MCP_URL = 'http://localhost:8080/mcp'
|
||||
|
||||
|
||||
@@ -52,8 +52,6 @@ describe('isChunkLoadError', () => {
|
||||
new TypeError('Cross-origin script load denied by Cross-Origin Resource Sharing policy.'),
|
||||
],
|
||||
['Vite CSS preload', new Error('Unable to preload CSS for /dashboard/assets/a.css')],
|
||||
['webpack JS chunk', new Error('Loading chunk 1234 failed.\n(error: https://x/1234.js)')],
|
||||
['webpack CSS chunk', new Error('Loading CSS chunk 5678 failed.\n(/_next/a.css)')],
|
||||
['ChunkLoadError name', Object.assign(new Error('something else'), { name: 'ChunkLoadError' })],
|
||||
['plain object', { message: 'Importing a module script failed.' }],
|
||||
])('detects %s', (_label, error) => {
|
||||
|
||||
@@ -48,8 +48,6 @@ const CHUNK_LOAD_ERROR_PATTERNS = [
|
||||
/Cross-origin script load denied by Cross-Origin Resource Sharing policy/i,
|
||||
// Vite's dynamic-import dependency preloader
|
||||
/Unable to preload CSS/i,
|
||||
// Next.js / webpack (JS and CSS chunks)
|
||||
/Loading (CSS )?chunk [^\s]+ failed/i,
|
||||
]
|
||||
|
||||
export function isChunkLoadError(error: unknown): boolean {
|
||||
|
||||
@@ -206,7 +206,7 @@ describe('validateReturnTo', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it('should handle nextjs dynamic path js', () => {
|
||||
it('should reject encoded bracketed javascript: scheme payloads', () => {
|
||||
expect(
|
||||
validateReturnTo(
|
||||
'%2F%5B%5Bx%5D%5Djavascript%3Aalert(%22H4CK3D%22)%2F%5By%5D%2F%5B%5Bx%5D%5D%2F%5By%5D%3Fx%26y'
|
||||
|
||||
@@ -23,9 +23,9 @@ export const HOSTED_SUPPORTED_API_URLS = [
|
||||
'/scoped-access-token-permissions',
|
||||
]
|
||||
|
||||
// `pathname` must be basePath-relative — Next's `nextUrl.pathname` already is,
|
||||
// and the TanStack guard strips BASE_PATH before calling. Entries are path
|
||||
// suffixes, so `endsWith` stays correct regardless.
|
||||
// `pathname` must be basePath-relative (the request middleware in start.ts
|
||||
// strips BASE_PATH before calling). Entries are path suffixes, so `endsWith`
|
||||
// stays correct regardless.
|
||||
export function isHostedSupportedApiPath(pathname: string): boolean {
|
||||
return HOSTED_SUPPORTED_API_URLS.some((url) => pathname.endsWith(url))
|
||||
}
|
||||
@@ -42,8 +42,12 @@ describe('Sentry beforeSend filtering functions', () => {
|
||||
value: 'Regular error',
|
||||
stacktrace: {
|
||||
frames: [
|
||||
{ filename: 'app:///_next/static/chunks/main.js' } as StackFrame,
|
||||
{ filename: 'app:///_next/static/chunks/pages/index.js' } as StackFrame,
|
||||
{
|
||||
filename: 'https://supabase.com/dashboard/assets/main-abc123.js',
|
||||
} as StackFrame,
|
||||
{
|
||||
filename: 'https://supabase.com/dashboard/assets/index-def456.js',
|
||||
} as StackFrame,
|
||||
],
|
||||
},
|
||||
},
|
||||
@@ -330,7 +334,11 @@ describe('Sentry beforeSend filtering functions', () => {
|
||||
type: 'TypeError',
|
||||
value: 'Cannot read property "foo" of undefined',
|
||||
stacktrace: {
|
||||
frames: [{ filename: 'app:///_next/static/chunks/pages/index.js' } as StackFrame],
|
||||
frames: [
|
||||
{
|
||||
filename: 'https://supabase.com/dashboard/assets/index-def456.js',
|
||||
} as StackFrame,
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
@@ -451,44 +459,24 @@ describe('buildSentryClientOptions', () => {
|
||||
}
|
||||
|
||||
it('preserves the default integrations passed in by Sentry.init', () => {
|
||||
for (const includeThirdPartyErrorFilter of [true, false]) {
|
||||
const names = getIntegrationNames(buildSentryClientOptions({ includeThirdPartyErrorFilter }))
|
||||
// browserSessionIntegration is what sends the session envelope on every
|
||||
// page load; globalHandlers is window.onerror / unhandledrejection.
|
||||
expect(names).toContain('BrowserSession')
|
||||
expect(names).toContain('GlobalHandlers')
|
||||
}
|
||||
const names = getIntegrationNames(buildSentryClientOptions())
|
||||
// browserSessionIntegration is what sends the session envelope on every
|
||||
// page load; globalHandlers is window.onerror / unhandledrejection.
|
||||
expect(names).toContain('BrowserSession')
|
||||
expect(names).toContain('GlobalHandlers')
|
||||
})
|
||||
|
||||
it('sets the release only when one is provided', () => {
|
||||
const withRelease = buildSentryClientOptions({
|
||||
includeThirdPartyErrorFilter: false,
|
||||
release: 'abc123',
|
||||
})
|
||||
const withRelease = buildSentryClientOptions({ release: 'abc123' })
|
||||
expect(withRelease.release).toBe('abc123')
|
||||
|
||||
// The key is absent when no release is passed.
|
||||
const withoutRelease = buildSentryClientOptions({ includeThirdPartyErrorFilter: true })
|
||||
const withoutRelease = buildSentryClientOptions()
|
||||
expect('release' in withoutRelease).toBe(false)
|
||||
})
|
||||
|
||||
it('includes the third-party error filter only when the build annotates frames', () => {
|
||||
// Builds whose bundler annotates frames with the applicationKey.
|
||||
expect(
|
||||
getIntegrationNames(buildSentryClientOptions({ includeThirdPartyErrorFilter: true }))
|
||||
).toContain('ThirdPartyErrorsFilter')
|
||||
|
||||
// TanStack/Vite build: no bundler metadata — including the integration
|
||||
// would tag every event third_party_code=true and beforeSend would drop
|
||||
// them all.
|
||||
expect(
|
||||
getIntegrationNames(buildSentryClientOptions({ includeThirdPartyErrorFilter: false }))
|
||||
).not.toContain('ThirdPartyErrorsFilter')
|
||||
})
|
||||
|
||||
it('appends build-specific extra integrations', () => {
|
||||
const options = buildSentryClientOptions({
|
||||
includeThirdPartyErrorFilter: false,
|
||||
extraIntegrations: [{ name: 'FakeRouterTracing' }],
|
||||
})
|
||||
|
||||
@@ -496,25 +484,11 @@ describe('buildSentryClientOptions', () => {
|
||||
})
|
||||
|
||||
it('no longer ignores insert/remove node errors, so beforeSend can sample them', () => {
|
||||
const { ignoreErrors = [] } = buildSentryClientOptions({ includeThirdPartyErrorFilter: true })
|
||||
const { ignoreErrors = [] } = buildSentryClientOptions()
|
||||
expect(ignoreErrors).not.toContain("NotFoundError: Failed to execute 'removeChild' on 'Node'")
|
||||
expect(ignoreErrors).not.toContain('NotFoundError: The object can not be found here.')
|
||||
expect(ignoreErrors).toContain("Cannot read properties of null (reading 'parentNode')")
|
||||
})
|
||||
|
||||
it('builds the same shared options for both builds (parity)', () => {
|
||||
const nextOptions = buildSentryClientOptions({ includeThirdPartyErrorFilter: true })
|
||||
const tanstackOptions = buildSentryClientOptions({ includeThirdPartyErrorFilter: false })
|
||||
|
||||
// Everything except the integrations array must be identical between the
|
||||
// two runtimes.
|
||||
const { integrations: _next, ...nextRest } = nextOptions
|
||||
const { integrations: _tanstack, ...tanstackRest } = tanstackOptions
|
||||
expect(Object.keys(nextRest)).toEqual(Object.keys(tanstackRest))
|
||||
expect(nextRest.tracesSampleRate).toBe(tanstackRest.tracesSampleRate)
|
||||
expect(nextRest.allowUrls).toEqual(tanstackRest.allowUrls)
|
||||
expect(nextRest.ignoreErrors).toEqual(tanstackRest.ignoreErrors)
|
||||
})
|
||||
})
|
||||
|
||||
describe('which errors Studio sends to Sentry', () => {
|
||||
@@ -532,7 +506,7 @@ describe('which errors Studio sends to Sentry', () => {
|
||||
consentState.hasConsented = previousConsent
|
||||
}
|
||||
const { buildSentryClientOptions } = await import('./sentry-client-options')
|
||||
const options = buildSentryClientOptions({ includeThirdPartyErrorFilter: true })
|
||||
const options = buildSentryClientOptions()
|
||||
if (!options.beforeSend) throw new Error('Missing Sentry beforeSend')
|
||||
beforeSend = options.beforeSend
|
||||
})
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Sentry client-side configuration. `sentry.tanstack.ts` calls `Sentry.init`
|
||||
// with these options from `getRouter()` (router.tsx).
|
||||
import * as Sentry from '@sentry/react'
|
||||
import { thirdPartyErrorFilterIntegration } from '@sentry/react'
|
||||
import { hasConsented } from 'common'
|
||||
import { IS_PLATFORM } from 'common/constants/environment'
|
||||
import {
|
||||
@@ -79,29 +78,7 @@ export function isChallengeExpiredError(error: unknown, event: Sentry.Event): bo
|
||||
return message.includes('challenge-expired')
|
||||
}
|
||||
|
||||
// Tag errors whose stack trace only contains third-party frames (browser extensions,
|
||||
// injected scripts, etc.). This relies on build-time code annotation via the
|
||||
// `supabase-studio` applicationKey to reliably distinguish our code from third-party code.
|
||||
// We use 'apply-tag' instead of 'drop' so that beforeSend can exempt error boundary
|
||||
// crashes — these may originate in third-party code but are caused by first-party bugs.
|
||||
function buildThirdPartyErrorFilterIntegration(): Integration {
|
||||
return thirdPartyErrorFilterIntegration({
|
||||
filterKeys: ['supabase-studio'],
|
||||
behaviour: 'apply-tag-if-exclusively-contains-third-party-frames',
|
||||
})
|
||||
}
|
||||
|
||||
export interface SentryClientOptionsParams {
|
||||
/**
|
||||
* Whether to include `thirdPartyErrorFilterIntegration`.
|
||||
*
|
||||
* Only enable this on builds whose bundler annotates stack frames with the
|
||||
* `supabase-studio` applicationKey. On a build WITHOUT the annotation
|
||||
* no frame carries first-party metadata, so the integration tags EVERY
|
||||
* event `third_party_code: true` and `beforeSend` would then drop all
|
||||
* non-error-boundary events.
|
||||
*/
|
||||
includeThirdPartyErrorFilter: boolean
|
||||
/** Build-specific integrations (e.g. TanStack Router browser tracing). */
|
||||
extraIntegrations?: Integration[]
|
||||
/**
|
||||
@@ -148,10 +125,9 @@ export function tagBrowserTranslationError(event: Sentry.Event, pageTranslated?:
|
||||
}
|
||||
|
||||
export function buildSentryClientOptions({
|
||||
includeThirdPartyErrorFilter,
|
||||
extraIntegrations = [],
|
||||
release,
|
||||
}: SentryClientOptionsParams): Sentry.BrowserOptions {
|
||||
}: SentryClientOptionsParams = {}): Sentry.BrowserOptions {
|
||||
return {
|
||||
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
|
||||
...(process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT && {
|
||||
@@ -171,19 +147,12 @@ export function buildSentryClientOptions({
|
||||
// globalHandlers, breadcrumbs, dedupe, …) are explicitly preserved — this
|
||||
// is the documented way to extend the defaults, and it can never be
|
||||
// misread as replacing them.
|
||||
integrations: (defaultIntegrations) => [
|
||||
...defaultIntegrations,
|
||||
...(includeThirdPartyErrorFilter ? [buildThirdPartyErrorFilterIntegration()] : []),
|
||||
...extraIntegrations,
|
||||
],
|
||||
integrations: (defaultIntegrations) => [...defaultIntegrations, ...extraIntegrations],
|
||||
|
||||
// Only capture errors originating from our own code.
|
||||
// This is a whitelist on the source URL in stack frames — it drops errors from
|
||||
// browser extensions, injected scripts, third-party widgets, etc. (FE-2094)
|
||||
allowUrls: [
|
||||
/https?:\/\/(.*\.)?supabase\.(com|co|green|io)/,
|
||||
/app:\/\//, // Next.js rewrites source URLs to app:// with source maps
|
||||
],
|
||||
allowUrls: [/https?:\/\/(.*\.)?supabase\.(com|co|green|io)/],
|
||||
beforeBreadcrumb(breadcrumb, _hint) {
|
||||
const cleanedBreadcrumb = { ...breadcrumb }
|
||||
|
||||
@@ -281,13 +250,6 @@ export function buildSentryClientOptions({
|
||||
"undefined is not an object (evaluating 'n.chat.setReady')",
|
||||
"undefined is not an object (evaluating 'i.chat.setReady')",
|
||||
|
||||
// === Next.js internals ===
|
||||
// Ref: https://github.com/supabase/supabase/pull/9729
|
||||
/The provided `href` \(\/org\/\[slug\]\/.*\) value is missing query values/,
|
||||
// Next.js throws these during navigation, not actual errors
|
||||
'NEXT_NOT_FOUND',
|
||||
'NEXT_REDIRECT',
|
||||
|
||||
// === User input errors (not bugs) ===
|
||||
// sql-formatter lexer on invalid SQL input
|
||||
/^Parse error: Unexpected ".+" at line \d+ column \d+$/,
|
||||
|
||||
@@ -34,17 +34,11 @@ export function buildSentryServerOptions({
|
||||
ignoreErrors: [
|
||||
'ResizeObserver',
|
||||
'Failed to load Stripe.js',
|
||||
// Next.js internals, not actual errors (harmless on TanStack)
|
||||
'NEXT_NOT_FOUND',
|
||||
'NEXT_REDIRECT',
|
||||
// Network / infrastructure
|
||||
/504 Gateway Time-out/,
|
||||
'Network request failed',
|
||||
'Failed to fetch',
|
||||
'AbortError',
|
||||
// Code-split loading failures
|
||||
'ChunkLoadError',
|
||||
/Loading chunk [\d]+ failed/,
|
||||
// React hydration mismatches caused by extensions modifying DOM before hydration
|
||||
/text content does not match/i,
|
||||
/There was an error while hydrating/i,
|
||||
|
||||
@@ -136,7 +136,7 @@ describe('maskReplayAttribute', () => {
|
||||
})
|
||||
|
||||
it('keeps stylesheet URLs, which replay needs for sheets rrweb could not inline', () => {
|
||||
const href = 'https://supabase.com/dashboard/_next/static/css/main.css'
|
||||
const href = 'https://supabase.com/dashboard/assets/main-abc123.css'
|
||||
const link = document.createElement('link')
|
||||
link.setAttribute('rel', 'stylesheet')
|
||||
expect(maskReplayAttribute('href', href, link)).toBe(href)
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
'use client'
|
||||
|
||||
import { useTheme } from 'next-themes'
|
||||
import { SonnerToaster } from 'ui'
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
"lint": "maybe-turbo eslint .",
|
||||
"lint:type-checks": "eslint --no-inline-config --config eslint.type-checks.config.cjs .",
|
||||
"lint:ratchet": "tsx node_modules/eslint-config-supabase/ratchet-eslint-rules.ts --rules-file scripts/ratchet-rules.json --rules-file node_modules/eslint-config-supabase/ratchet-rules.json",
|
||||
"clean": "rimraf .next .output .vercel/output .turbo tsconfig.tsbuildinfo",
|
||||
"clean": "rimraf .output .vercel/output .turbo tsconfig.tsbuildinfo",
|
||||
"test": "vitest --run --coverage",
|
||||
"test:watch": "vitest watch",
|
||||
"test:ui": "vitest --ui",
|
||||
@@ -121,7 +121,6 @@
|
||||
"mime-db": "^1.53.0",
|
||||
"monaco-editor": "catalog:",
|
||||
"motion": "catalog:",
|
||||
"next": "catalog:",
|
||||
"next-themes": "catalog:",
|
||||
"nuqs": "2.7.1",
|
||||
"openai": "^4.104.0",
|
||||
@@ -207,7 +206,6 @@
|
||||
"jsdom-testing-mocks": "^1.13.1",
|
||||
"maybe-turbo": "workspace:*",
|
||||
"msw": "^2.3.0",
|
||||
"next-router-mock": "^0.9.13",
|
||||
"nitro": "3.0.260903-beta",
|
||||
"require-in-the-middle": "^8.0.0",
|
||||
"tsconfig": "workspace:*",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { readdirSync } from 'node:fs'
|
||||
import { createRequire } from 'node:module'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import type { VercelConfig } from '@vercel/config/v1'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import {
|
||||
@@ -10,13 +11,14 @@ import {
|
||||
preserveQueryAndHash,
|
||||
} from './redirects.shared'
|
||||
|
||||
// Next's own redirect matcher, so the declarative rule is tested as Next runs it.
|
||||
// Vercel's redirect compiler, so the declarative rule is tested as Vercel runs it.
|
||||
const require = createRequire(import.meta.url)
|
||||
const { getPathMatch } = require('next/dist/shared/lib/router/utils/path-match') as {
|
||||
getPathMatch: (
|
||||
path: string,
|
||||
options: { strict: boolean; removeUnnamedParams: boolean }
|
||||
) => (pathname: string) => false | Record<string, string>
|
||||
const vercelRequire = createRequire(require.resolve('@vercel/config/v1'))
|
||||
const { getTransformedRoutes } = vercelRequire('@vercel/routing-utils') as {
|
||||
getTransformedRoutes: (config: Pick<VercelConfig, 'redirects'>) => {
|
||||
error: unknown
|
||||
routes: { src?: string; headers?: Record<string, string>; status?: number }[] | null
|
||||
}
|
||||
}
|
||||
|
||||
describe('preserveQueryAndHash', () => {
|
||||
@@ -350,7 +352,6 @@ describe('matchRedirect maintenance mode', () => {
|
||||
'/assets/main-abc123.js',
|
||||
'/_vercel/immutable/salt/nitro/main-abc123.js',
|
||||
'/_vercel/immutable/salt/nitro/styles-abc123.css',
|
||||
'/_next/static/chunks/main-abc123.js',
|
||||
'/monaco-editor/vs/loader.js',
|
||||
'/supabase-logo.svg',
|
||||
]
|
||||
@@ -379,23 +380,37 @@ describe('matchRedirect maintenance mode', () => {
|
||||
})
|
||||
|
||||
it.each(['', '/dashboard'])(
|
||||
'declarative rule agrees with the runtime matcher under Next with base path "%s"',
|
||||
'declarative rule agrees with the runtime matcher under Vercel with base path "%s"',
|
||||
(basePath) => {
|
||||
const [rule] = getMaintenanceRedirects(true)
|
||||
// Next prepends basePath to redirect sources.
|
||||
const match = getPathMatch(`${basePath}${rule.source}`, {
|
||||
strict: true,
|
||||
removeUnnamedParams: true,
|
||||
const compiled = getTransformedRoutes({
|
||||
redirects: [
|
||||
{
|
||||
...rule,
|
||||
source: `${basePath}${rule.source}`,
|
||||
destination: `${basePath}${rule.destination}`,
|
||||
},
|
||||
],
|
||||
})
|
||||
expect(compiled.error).toBeNull()
|
||||
expect(compiled.routes).not.toBeNull()
|
||||
const redirectFor = (pathname: string) =>
|
||||
compiled.routes!.find(({ src }) => src && new RegExp(src).test(pathname))?.headers?.Location
|
||||
for (const pathname of assetPaths) {
|
||||
expect(match(`${basePath}${pathname}`), pathname).toBe(false)
|
||||
expect(redirectFor(`${basePath}${pathname}`), pathname).toBeUndefined()
|
||||
}
|
||||
for (const pathname of pagePaths) {
|
||||
expect(match(`${basePath}${pathname}`), pathname).not.toBe(false)
|
||||
expect(redirectFor(`${basePath}${pathname}`), pathname).toBe(`${basePath}/maintenance`)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
it('returns the reverse redirect rule when maintenance mode is disabled', () => {
|
||||
expect(getMaintenanceRedirects(false)).toEqual([
|
||||
{ source: '/maintenance', destination: '/', permanent: false },
|
||||
])
|
||||
})
|
||||
|
||||
it('keeps every top-level public/ entry reachable', () => {
|
||||
const publicDir = fileURLToPath(new URL('./public', import.meta.url))
|
||||
for (const entry of readdirSync(publicDir)) {
|
||||
|
||||
@@ -402,10 +402,8 @@ export const SHARED_REDIRECTS: StudioRedirect[] = [
|
||||
// page doesn't depend on either.
|
||||
export const MAINTENANCE_PASSTHROUGH_SEGMENTS = [
|
||||
'maintenance',
|
||||
// Build output. Next chunks are under `/_next` (which Next also never
|
||||
// redirects itself). Vite's chunks are under `/assets`, or
|
||||
// Build output. Vite's chunks are under `/assets`, or
|
||||
// `/_vercel/immutable/<salt>/nitro` on Vercel.
|
||||
'_next',
|
||||
'_vercel',
|
||||
'assets',
|
||||
// Top-level entries of `public/` (kept in sync by a unit test).
|
||||
@@ -422,8 +420,8 @@ export const MAINTENANCE_PASSTHROUGH_SEGMENTS = [
|
||||
const escapeRegex = (value: string) => value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
||||
|
||||
// The two maintenance-mode rules are mutually exclusive; pick by env at
|
||||
// build time. Same shape for Next and Vercel. The lookahead matches whole
|
||||
// segments only, so `/maintenance-foo` or `/images` still redirect.
|
||||
// build time. The lookahead matches whole segments only, so
|
||||
// `/maintenance-foo` or `/images` still redirect.
|
||||
export function getMaintenanceRedirects(maintenanceMode: boolean): StudioRedirect[] {
|
||||
const passthrough = MAINTENANCE_PASSTHROUGH_SEGMENTS.map(escapeRegex).join('|')
|
||||
return maintenanceMode
|
||||
@@ -439,13 +437,13 @@ export function getMaintenanceRedirects(maintenanceMode: boolean): StudioRedirec
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Runtime matcher — used by TanStack's `__root` beforeLoad so self-hosted
|
||||
// (and any request Vercel's edge didn't already intercept) still gets the
|
||||
// same redirect behaviour as the Next.js / Vercel deploys.
|
||||
// (and any request Vercel's edge didn't already intercept) gets the same
|
||||
// redirect behavior as Vercel's edge redirects.
|
||||
//
|
||||
// The patterns above are written in Next/Vercel-flavoured syntax: `:name`
|
||||
// for a single segment, `:name*` for a trailing catch-all, literals
|
||||
// otherwise. That's all the redirect rules use, so a hand-rolled matcher
|
||||
// is simpler (and dependency-free) than pulling in path-to-regexp here.
|
||||
// The patterns above are written in Vercel redirect syntax: `:name` for a
|
||||
// single segment, `:name*` for a trailing catch-all, literals otherwise.
|
||||
// That's all the redirect rules use, so a hand-rolled matcher is simpler
|
||||
// (and dependency-free) than pulling in path-to-regexp here.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
type RedirectMatch = { destination: string; permanent: boolean }
|
||||
@@ -491,7 +489,7 @@ function hasQueryMatches(
|
||||
}
|
||||
|
||||
// Merge the incoming request's query params (and hash) onto a redirect
|
||||
// destination, mirroring Next.js `redirects()` semantics: the query string is
|
||||
// destination, matching Vercel redirect semantics: the query string is
|
||||
// carried through to the destination; params the destination already sets
|
||||
// win; params consumed by the matched rule (its `has` query keys) are
|
||||
// dropped; a hash on the destination wins over the incoming one. `hash` is
|
||||
@@ -566,8 +564,8 @@ export function matchRedirect(input: {
|
||||
if (!params) continue
|
||||
if (!hasQueryMatches(rule.has, search)) continue
|
||||
return {
|
||||
// Next.js carries the incoming query and hash through to the
|
||||
// destination; keys the rule matched on (`has`) are consumed.
|
||||
// Carry the incoming query and hash through to the destination;
|
||||
// keys the rule matched on (`has`) are consumed.
|
||||
destination: preserveQueryAndHash(substituteDestination(rule.destination, params), search, {
|
||||
consumedKeys: rule.has?.map((h) => h.key) ?? [],
|
||||
hash,
|
||||
|
||||
@@ -4,11 +4,10 @@ export const Route = createFileRoute('/_auth')({
|
||||
component: AuthShell,
|
||||
})
|
||||
|
||||
// No shared layout here. In Next only pages/sign-in.tsx wraps itself in
|
||||
// AuthenticationLayout via getLayout; every other auth page renders just its
|
||||
// inner layout (SignInLayout / ForgotPasswordLayout / InterstitialLayout) with
|
||||
// no AuthenticationLayout. The sign-in route wraps AuthenticationLayout at the
|
||||
// leaf to match.
|
||||
// No shared layout here. Only the sign-in route wraps itself in
|
||||
// AuthenticationLayout at the leaf; every other auth route renders just its
|
||||
// own inner layout (SignInLayout / ForgotPasswordLayout / InterstitialLayout)
|
||||
// without AuthenticationLayout.
|
||||
function AuthShell() {
|
||||
return <Outlet />
|
||||
}
|
||||
@@ -6,7 +6,7 @@ export const Route = createFileRoute('/integrations/vercel')({
|
||||
|
||||
// No shared layout here. Since #47623, the Vercel install, marketplace
|
||||
// choose-project, and deploy-button/new-project pages each render their own
|
||||
// InterstitialLayout and have no Next getLayout / window chrome.
|
||||
// InterstitialLayout without a shared layout wrapper or window chrome.
|
||||
function VercelIntegrationPassthrough() {
|
||||
return <Outlet />
|
||||
}
|
||||
@@ -7,9 +7,6 @@ const sentryMocks = vi.hoisted(() => ({
|
||||
tanstackRouterBrowserTracingIntegration: vi.fn(() => ({
|
||||
name: 'TanStackRouterBrowserTracing',
|
||||
})),
|
||||
// Imported at module scope by lib/sentry-client-options.ts, so the mock
|
||||
// must provide it even though the TanStack init never enables it.
|
||||
thirdPartyErrorFilterIntegration: vi.fn(() => ({ name: 'ThirdPartyErrorsFilter' })),
|
||||
}))
|
||||
|
||||
vi.mock('@sentry/react', () => sentryMocks)
|
||||
@@ -112,11 +109,6 @@ describe('initSentryTanStackClient', () => {
|
||||
expect(integrations).toContainEqual({ name: 'BrowserSession' })
|
||||
expect(integrations).toContainEqual({ name: 'GlobalHandlers' })
|
||||
expect(integrations).toContainEqual({ name: 'TanStackRouterBrowserTracing' })
|
||||
// The Vite build runs no Sentry bundler plugin, so frames carry no
|
||||
// applicationKey metadata — the third-party filter must stay off or every
|
||||
// event would be tagged third_party_code=true and dropped by beforeSend.
|
||||
expect(sentryMocks.thirdPartyErrorFilterIntegration).not.toHaveBeenCalled()
|
||||
expect(integrations).not.toContainEqual({ name: 'ThirdPartyErrorsFilter' })
|
||||
})
|
||||
|
||||
it('opts out of per-asset resource spans', async () => {
|
||||
|
||||
@@ -38,12 +38,6 @@ export function initSentryTanStackClient(router: AnyRouter) {
|
||||
// everything when !IS_PLATFORM regardless.
|
||||
Sentry.init(
|
||||
buildSentryClientOptions({
|
||||
// The Vite build doesn't run a Sentry bundler plugin, so stack frames
|
||||
// carry no `supabase-studio` applicationKey metadata. Without the
|
||||
// metadata the integration would tag EVERY event third_party_code=true
|
||||
// and beforeSend would drop them all. Leave it off until the Vite build
|
||||
// annotates frames (@sentry/vite-plugin moduleMetadata).
|
||||
includeThirdPartyErrorFilter: false,
|
||||
extraIntegrations: [
|
||||
Sentry.tanstackRouterBrowserTracingIntegration(router, {
|
||||
// Skip the per-asset resource-timing spans. The Vite/Rolldown build
|
||||
|
||||
@@ -2,13 +2,12 @@
|
||||
* Registry of integration overview markdown, keyed by integration id
|
||||
* (= directory name under `static-data/integrations/`).
|
||||
*
|
||||
* The import specifiers must stay as string literals: the bundler can only
|
||||
* The import specifiers must stay as string literals: Vite/Rolldown can only
|
||||
* code-split and apply its md-as-string loader (`rawTextLoader` plugin in
|
||||
* vite.config.ts) to imports it can statically analyze. A template-literal specifier like
|
||||
* ``import(`@/static-data/integrations/${id}/overview.md`)`` happens to work
|
||||
* under webpack/turbopack (context modules) but is left untouched by
|
||||
* Vite/Rolldown and throws `TypeError: Failed to resolve module specifier`
|
||||
* at runtime in the TanStack build.
|
||||
* vite.config.ts) to imports it can statically analyze. A template-literal
|
||||
* specifier like ``import(`@/static-data/integrations/${id}/overview.md`)`` is
|
||||
* left untouched by Vite/Rolldown and throws
|
||||
* `TypeError: Failed to resolve module specifier` at runtime.
|
||||
*
|
||||
* `overviews.test.ts` asserts this map stays in sync with the files on disk —
|
||||
* when adding a new `overview.md`, add its entry here.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
@import 'config/inline-code.css';
|
||||
@import 'config/typography.css';
|
||||
|
||||
@source '../pages/**/*.{js,ts,jsx,tsx}';
|
||||
@source '../routes/**/*.{js,ts,jsx,tsx}';
|
||||
@source '../components/**/*.{js,ts,jsx,tsx}';
|
||||
@source './../../../packages/ui/src/**/*.{tsx,ts,js}';
|
||||
@source './../../../packages/ui-patterns/src/**/*.{tsx,ts,js}';
|
||||
@@ -165,7 +165,6 @@
|
||||
|
||||
html,
|
||||
body,
|
||||
#__next,
|
||||
.main {
|
||||
@apply bg-dash-sidebar relative;
|
||||
@apply text-foreground;
|
||||
|
||||
@@ -3,25 +3,110 @@ import {
|
||||
createMemoryHistory,
|
||||
createRootRoute,
|
||||
createRouter,
|
||||
Link as TanStackLink,
|
||||
RouterContextProvider,
|
||||
useRouter as useTanStackRouter,
|
||||
useRouterState,
|
||||
type AnyRoute,
|
||||
type AnyRouter,
|
||||
} from '@tanstack/react-router'
|
||||
import { render, renderHook, type RenderOptions } from '@testing-library/react'
|
||||
import { AuthContext, AuthContext as AuthContextType, FrameworkProvider } from 'common'
|
||||
import { useRouter as useMockRouter } from 'next-router-mock'
|
||||
import {
|
||||
AuthContext,
|
||||
AuthContext as AuthContextType,
|
||||
DefaultFrameworkImage,
|
||||
DefaultFrameworkLink,
|
||||
FrameworkProvider,
|
||||
resolveStaticImageSrc,
|
||||
type FrameworkContextValue,
|
||||
type FrameworkImageProps,
|
||||
type FrameworkLinkProps,
|
||||
} from 'common'
|
||||
import { NuqsTestingAdapter } from 'nuqs/adapters/testing'
|
||||
import { useMemo } from 'react'
|
||||
import { forwardRef, useMemo, type ForwardedRef } from 'react'
|
||||
import { TooltipProvider } from 'ui'
|
||||
import { CommandProvider } from 'ui-patterns/CommandMenu'
|
||||
|
||||
// End of third-party imports
|
||||
|
||||
import { applyBasePath, isAbsoluteUrl, splitInternalUrl, toRoutePattern } from '@/lib/internal-url'
|
||||
import { navigateToUrl } from '@/lib/navigation'
|
||||
import { ProfileContext, type ProfileContextType } from '@/lib/profile'
|
||||
import { parseSearch, stringifySearch } from '@/lib/router-search-params'
|
||||
|
||||
type AdapterProps = Partial<Parameters<typeof NuqsTestingAdapter>[0]>
|
||||
|
||||
function normalizeParams(
|
||||
search: Record<string, unknown> | undefined,
|
||||
params: Record<string, unknown> | undefined
|
||||
): Record<string, string | string[] | undefined> {
|
||||
const merged = { ...search, ...params }
|
||||
const normalized: Record<string, string | string[] | undefined> = {}
|
||||
for (const [key, value] of Object.entries(merged)) {
|
||||
if (typeof value === 'string') {
|
||||
normalized[key] = value
|
||||
} else if (Array.isArray(value)) {
|
||||
normalized[key] = value.map(String)
|
||||
} else if (value !== undefined && value !== null) {
|
||||
normalized[key] = String(value)
|
||||
}
|
||||
}
|
||||
return normalized
|
||||
}
|
||||
|
||||
function resolveSearchOrHashOnlyTarget(
|
||||
target: string,
|
||||
currentPathname: string,
|
||||
currentSearch: string
|
||||
): string {
|
||||
if (target.startsWith('?')) {
|
||||
return `${currentPathname}${target}`
|
||||
}
|
||||
if (target.startsWith('#')) {
|
||||
return `${currentPathname}${currentSearch}${target}`
|
||||
}
|
||||
return target
|
||||
}
|
||||
|
||||
const TestFrameworkLink = forwardRef(function TestFrameworkLink(
|
||||
props: FrameworkLinkProps,
|
||||
ref: ForwardedRef<HTMLAnchorElement>
|
||||
) {
|
||||
const { href, prefetch, replace, scroll: _scroll, shallow: _shallow, children, ...rest } = props
|
||||
const currentPathname = useRouterState({
|
||||
select: (state) => (state.resolvedLocation ?? state.location).pathname,
|
||||
})
|
||||
const currentSearch = useRouterState({
|
||||
select: (state) => (state.resolvedLocation ?? state.location).searchStr,
|
||||
})
|
||||
const resolvedHref = resolveSearchOrHashOnlyTarget(href, currentPathname, currentSearch)
|
||||
const { to, search, hash } = splitInternalUrl(resolvedHref)
|
||||
|
||||
if (isAbsoluteUrl(to)) {
|
||||
return <DefaultFrameworkLink ref={ref} {...props} />
|
||||
}
|
||||
|
||||
const preload = prefetch === false ? false : prefetch ? 'intent' : undefined
|
||||
|
||||
return (
|
||||
<TanStackLink<AnyRouter, string>
|
||||
to={to}
|
||||
search={search as never}
|
||||
hash={hash}
|
||||
replace={replace}
|
||||
preload={preload}
|
||||
ref={ref}
|
||||
{...rest}
|
||||
>
|
||||
{children}
|
||||
</TanStackLink>
|
||||
)
|
||||
})
|
||||
|
||||
function TestFrameworkImage({ src, ...props }: FrameworkImageProps) {
|
||||
return <DefaultFrameworkImage {...props} src={applyBasePath(resolveStaticImageSrc(src))} />
|
||||
}
|
||||
|
||||
export const createTestRouter = (
|
||||
initialUrl = '/',
|
||||
routeTree: AnyRoute = createRootRoute()
|
||||
@@ -48,17 +133,42 @@ const TestRouterProvider = ({
|
||||
}
|
||||
|
||||
const TestFrameworkProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
const router = useMockRouter()
|
||||
const value = useMemo(
|
||||
() => ({
|
||||
pathname: router.pathname,
|
||||
asPath: router.asPath,
|
||||
isReady: router.isReady,
|
||||
params: router.query,
|
||||
push: (path: string) => router.push(path),
|
||||
}),
|
||||
[router]
|
||||
)
|
||||
const router = useTanStackRouter()
|
||||
const location = useRouterState({
|
||||
select: (state) => state.resolvedLocation ?? state.location,
|
||||
})
|
||||
const stateMatches = useRouterState({
|
||||
select: (state) => state.matches,
|
||||
})
|
||||
|
||||
const value = useMemo<FrameworkContextValue>(() => {
|
||||
const matches = stateMatches.length > 0 ? stateMatches : router.matchRoutes(location)
|
||||
const leafMatch = matches[matches.length - 1]
|
||||
const leafRouteId =
|
||||
leafMatch && leafMatch.routeId !== '__root__' ? leafMatch.routeId : location.pathname
|
||||
const pathname = toRoutePattern(leafRouteId)
|
||||
const asPath = location.href
|
||||
const routeParams = leafMatch?.params as Record<string, unknown> | undefined
|
||||
const searchParams =
|
||||
(leafMatch?.search as Record<string, unknown> | undefined) ??
|
||||
(location.search as Record<string, unknown> | undefined)
|
||||
const params = normalizeParams(searchParams, routeParams)
|
||||
|
||||
return {
|
||||
Link: TestFrameworkLink,
|
||||
Image: TestFrameworkImage,
|
||||
pathname,
|
||||
asPath,
|
||||
isReady: true,
|
||||
params,
|
||||
push: async (path: string) => {
|
||||
await navigateToUrl(
|
||||
router.navigate,
|
||||
resolveSearchOrHashOnlyTarget(path, location.pathname, location.searchStr)
|
||||
)
|
||||
},
|
||||
}
|
||||
}, [location, router, stateMatches])
|
||||
|
||||
return <FrameworkProvider value={value}>{children}</FrameworkProvider>
|
||||
}
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
import { glob } from 'fs/promises'
|
||||
import { join, posix, relative, sep } from 'path'
|
||||
import _routerMock from 'next-router-mock'
|
||||
import { createDynamicRouteParser } from 'next-router-mock/dynamic-routes'
|
||||
|
||||
export const routerMock = _routerMock
|
||||
|
||||
const routesRoot = join(process.cwd(), 'routes')
|
||||
|
||||
// `_app/org/$slug/general.tsx` → `/org/[slug]/general`, so `next-router-mock` parses
|
||||
// dynamic segments the way the app's routes define them.
|
||||
const toNextRoutePattern = (file: string) =>
|
||||
`/${relative(routesRoot, file)
|
||||
.replaceAll(sep, posix.sep)
|
||||
.replace(/\.tsx$/, '')
|
||||
.split('/')
|
||||
.filter((segment) => segment !== 'index' && !(segment.startsWith('_') && segment.length > 1))
|
||||
.map((segment) => (segment.startsWith('$') ? `[${segment.slice(1)}]` : segment))
|
||||
.join('/')}`
|
||||
|
||||
// Dynamic leaf routes (`$id.tsx`) and index routes under a dynamic segment.
|
||||
const isDynamicRouteFile = (file: string) => {
|
||||
const segments = relative(routesRoot, file).split(sep)
|
||||
const fileName = segments.at(-1) ?? ''
|
||||
const isDynamicLeaf = /^\$[a-zA-Z]/.test(fileName)
|
||||
const isIndexUnderDynamicSegment =
|
||||
fileName === 'index.tsx' && segments.some((segment) => segment.startsWith('$'))
|
||||
return segments[0] !== 'api' && (isDynamicLeaf || isIndexUnderDynamicSegment)
|
||||
}
|
||||
|
||||
const paths = (await Array.fromAsync(glob(`${routesRoot}/**/*.tsx`)))
|
||||
.filter(isDynamicRouteFile)
|
||||
.map(toNextRoutePattern)
|
||||
|
||||
routerMock.useParser(createDynamicRouteParser(paths))
|
||||
File renamed without changes.
File renamed without changes.
@@ -4,11 +4,9 @@ import dayjs from 'dayjs'
|
||||
import relativeTime from 'dayjs/plugin/relativeTime'
|
||||
import timezone from 'dayjs/plugin/timezone'
|
||||
import utc from 'dayjs/plugin/utc'
|
||||
import { createDynamicRouteParser } from 'next-router-mock/dist/dynamic-routes'
|
||||
import { afterAll, afterEach, beforeAll, vi } from 'vitest'
|
||||
|
||||
import { mswServer } from './lib/msw'
|
||||
import { routerMock } from './lib/route-mock'
|
||||
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(timezone)
|
||||
@@ -37,7 +35,6 @@ vi.mock('common', async (importOriginal) => {
|
||||
|
||||
beforeAll(() => {
|
||||
mswServer.listen({ onUnhandledRequest: `error` })
|
||||
routerMock.useParser(createDynamicRouteParser(['/projects/[ref]']))
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"extends": "tsconfig/nextjs.json",
|
||||
"extends": "tsconfig/base.json",
|
||||
"compilerOptions": {
|
||||
"allowJs": false,
|
||||
"declaration": false,
|
||||
"declarationMap": false,
|
||||
"noEmit": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
|
||||
+4
-33
@@ -16,27 +16,11 @@
|
||||
"build": {
|
||||
"dependsOn": ["^build"],
|
||||
"env": [
|
||||
"ANALYZE",
|
||||
"CI",
|
||||
"NEXT_PUBLIC_SUPPORT_API_URL",
|
||||
"NEXT_PUBLIC_CONTENT_API_URL",
|
||||
"NEXT_PUBLIC_BASE_PATH",
|
||||
"NEXT_PUBLIC_STRIPE_PUBLIC_KEY",
|
||||
"NEXT_PUBLIC_SUPPORT_ANON_KEY",
|
||||
"NEXT_PUBLIC_ENVIRONMENT",
|
||||
"NEXT_PUBLIC_IS_PLATFORM",
|
||||
"NEXT_PUBLIC_SITE_URL",
|
||||
"NEXT_PUBLIC_API_URL",
|
||||
"NEXT_PUBLIC_DOCS_URL",
|
||||
"NEXT_PUBLIC_CONFIGCAT_SDK_KEY",
|
||||
"NEXT_PUBLIC_CONFIGCAT_PROXY_URL",
|
||||
"NEXT_PUBLIC_HCAPTCHA_SITE_KEY",
|
||||
"NEXT_PUBLIC_SUPABASE_URL",
|
||||
"NEXT_PUBLIC_SUPABASE_ANON_KEY",
|
||||
"NEXT_PUBLIC_NODE_ENV",
|
||||
"NEXT_PUBLIC_GOTRUE_URL",
|
||||
"NEXT_PUBLIC_VERCEL_BRANCH_URL",
|
||||
"NEXT_PUBLIC_GOOGLE_MAPS_KEY",
|
||||
// vite.config.ts inlines every NEXT_PUBLIC_* var into the client bundle.
|
||||
// Without `next` in package.json, Turborepo's framework inference no
|
||||
// longer adds `NEXT_PUBLIC_*` automatically, so declare it explicitly.
|
||||
"NEXT_PUBLIC_*",
|
||||
"NIMBUS_PROD_PROJECTS_URL",
|
||||
"NIMBUS_PROD_PROJECTS_URL_WS",
|
||||
"NODE_ENV",
|
||||
@@ -52,18 +36,6 @@
|
||||
"VERCEL_IMMUTABLE_STATIC_FILES_ENABLED",
|
||||
"VERCEL_HASH_SALT",
|
||||
"MAINTENANCE_MODE",
|
||||
// These envs are used in the packages
|
||||
"NEXT_PUBLIC_STORAGE_KEY",
|
||||
"NEXT_PUBLIC_AUTH_DEBUG_KEY",
|
||||
"NEXT_PUBLIC_AUTH_PERSISTED_KEY",
|
||||
"NEXT_PUBLIC_AUTH_NAVIGATOR_LOCK_KEY",
|
||||
"NEXT_PUBLIC_AUTH_DETECT_SESSION_IN_URL",
|
||||
"NEXT_PUBLIC_GOOGLE_TAG_MANAGER_ID",
|
||||
"NEXT_PUBLIC_VERCEL_ENV",
|
||||
"NEXT_PUBLIC_USERCENTRICS_RULESET_ID",
|
||||
"NEXT_PUBLIC_MCP_URL",
|
||||
"NEXT_PUBLIC_IS_NIMBUS",
|
||||
"NEXT_PUBLIC_ONGOING_INCIDENT",
|
||||
// These envs are technically passthrough env vars because they're only used on the server side
|
||||
"PLATFORM_PG_META_URL",
|
||||
"STUDIO_PG_META_URL",
|
||||
@@ -98,7 +70,6 @@
|
||||
"SENTRY_PROJECT",
|
||||
"SENTRY_AUTH_TOKEN",
|
||||
"SKIP_ASSET_UPLOAD",
|
||||
"NEXT_PUBLIC_SENTRY_DSN",
|
||||
"AWS_BEDROCK_PROFILE",
|
||||
"AWS_BEDROCK_ROLE_ARN",
|
||||
"AWS_ACCESS_KEY_ID",
|
||||
|
||||
+8
-15
@@ -19,10 +19,8 @@ const basePath = process.env.NEXT_PUBLIC_BASE_PATH ?? ''
|
||||
// Run once per prefix and concatenated so no rule is hand-duplicated.
|
||||
function headersFor(prefix: string) {
|
||||
return [
|
||||
// Security headers for every response. The Next build sets these via
|
||||
// next.config.ts `headers()`; the TanStack build serves a static shell
|
||||
// from the CDN, so they live at the edge. Matches next.config's `/(.*?)`
|
||||
// block (CSP, X-Frame-Options, HSTS, etc.).
|
||||
// Security headers for every response (CSP, X-Frame-Options, HSTS, etc.).
|
||||
// Studio serves a static shell from the CDN, so these live at the edge.
|
||||
{ source: `${prefix}/(.*)`, headers: getSecurityHeaders() },
|
||||
// Deployment metadata sets its own cache policy based on lookup success.
|
||||
// All other API paths retain the private default, including nested paths.
|
||||
@@ -33,9 +31,7 @@ function headersFor(prefix: string) {
|
||||
routes.cacheControl(`${prefix}/_serverFn/(.*)`, { private: true, noStore: true }),
|
||||
// Hashed chunks are covered by Nitro (`/_vercel/immutable/*`, immutable).
|
||||
// Static images and favicons aren't content-hashed, so they can't be
|
||||
// `immutable`, but they change rarely — mirror next.config's
|
||||
// `cache-control` for these paths (img: max-age=2592000 = 30 days,
|
||||
// favicon: max-age=86400 = 1 day).
|
||||
// `immutable`, but they change rarely (img: 30 days, favicon: 1 day).
|
||||
routes.cacheControl(`${prefix}/img/(.*)`, { public: true, maxAge: '30days' }),
|
||||
routes.cacheControl(`${prefix}/favicon/(.*)`, { public: true, maxAge: '1day' }),
|
||||
// Deno declarations are public TypeScript assets. Keep this override
|
||||
@@ -45,9 +41,8 @@ function headersFor(prefix: string) {
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Redirects — entries live in `redirects.shared.ts`, consumed by both
|
||||
// `next.config.ts` and this file. Next auto-prepends `basePath` to its
|
||||
// redirects; Vercel doesn't, so we apply it here.
|
||||
// Redirects — entries live in `redirects.shared.ts`. Vercel doesn't
|
||||
// auto-prepend `basePath` to redirects, so we apply it here.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function applyBasePath(r: StudioRedirect): Redirect {
|
||||
@@ -78,11 +73,9 @@ function buildRedirects(): Redirect[] {
|
||||
|
||||
function buildConfig(): VercelConfig {
|
||||
// Vercel's Flags Explorer probes `/.well-known/vercel/flags` and expects
|
||||
// JSON. next.config.ts proxies it to supabase.com's endpoint and forces
|
||||
// `content-type: application/json`; mirror that here. It lives at the domain
|
||||
// root (once, NOT per prefix) because next.config's rewrite sets
|
||||
// `basePath: false` — well-known URLs are at the root regardless of the
|
||||
// app's basePath.
|
||||
// JSON. Proxy it to supabase.com's endpoint and force
|
||||
// `content-type: application/json`. Well-known URLs live at the domain root
|
||||
// (once, NOT per prefix) regardless of the app's basePath.
|
||||
const wellKnownFlags = '/.well-known/vercel/flags'
|
||||
|
||||
return {
|
||||
|
||||
+12
-111
@@ -17,7 +17,6 @@ import { vercelSpaRoutes } from './scripts/vercel-spa-routes'
|
||||
import { getSecurityHeaders } from './security-headers'
|
||||
|
||||
const rootDir = path.dirname(fileURLToPath(import.meta.url))
|
||||
const compatRoot = path.resolve(rootDir, 'compat/next')
|
||||
|
||||
// Absolute dir of lodash-es, for the SSR-only lodash alias below. Resolved
|
||||
// here (not left as a bare 'lodash-es' replacement) because rollup-alias
|
||||
@@ -26,37 +25,6 @@ const compatRoot = path.resolve(rootDir, 'compat/next')
|
||||
// lodash-es (ui, common) would fail to resolve the bare specifier.
|
||||
const lodashEsDir = path.dirname(createRequire(import.meta.url).resolve('lodash-es/package.json'))
|
||||
|
||||
// The remaining Next imports shimmed to a TanStack-backed replacement. New
|
||||
// code uses TanStack Router (or framework-agnostic) APIs instead of adding
|
||||
// shims here.
|
||||
const nextShims: Record<string, string> = {
|
||||
'next/script': path.join(compatRoot, 'script.tsx'),
|
||||
}
|
||||
|
||||
// Combined compat + migration guard:
|
||||
// - If app source imports a shimmed `next/*` id, resolve it to the local
|
||||
// shim (acts like resolve.alias).
|
||||
// - Otherwise, if app source imports from `next` or `next/*`, fail the
|
||||
// build so unshimmed usage is caught at build time.
|
||||
// - node_modules imports pass through untouched.
|
||||
function nextCompat(): Plugin {
|
||||
return {
|
||||
name: 'studio-next-compat',
|
||||
enforce: 'pre',
|
||||
resolveId(id, importer) {
|
||||
if (!importer || importer.includes('/node_modules/')) return
|
||||
if (nextShims[id]) return nextShims[id]
|
||||
if (id === 'next' || id.startsWith('next/')) {
|
||||
throw new Error(
|
||||
`[next-compat] "${id}" imported from ${importer}.\n` +
|
||||
`Use the TanStack Router (or framework-agnostic) equivalent instead; ` +
|
||||
`only next/script is shimmed.`
|
||||
)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Import specifiers (as they appear in app source) for files that import as
|
||||
// raw text but whose extension the bundler would otherwise treat as code —
|
||||
// the Deno typings that `components/ui/AIEditor` feeds to Monaco as extra
|
||||
@@ -109,33 +77,6 @@ function rawTextLoader(): Plugin {
|
||||
}
|
||||
}
|
||||
|
||||
// Swap graphiql's webpack worker setup for its Vite one in client builds.
|
||||
//
|
||||
// App source imports `graphiql/setup-workers/webpack` (GraphiQLTab.tsx),
|
||||
// which registers `MonacoEnvironment.getWorker` using
|
||||
// `new Worker(new URL('monaco-editor/...', import.meta.url))` — the URL form
|
||||
// webpack/turbopack rewrites at build time. Vite doesn't rewrite bare module
|
||||
// specifiers inside `new URL(..., import.meta.url)`, so under the TanStack
|
||||
// build the worker URLs 404 and Monaco falls back to running the json /
|
||||
// editorWorkerService / graphql workers on the main thread ("Could not
|
||||
// create web worker(s)..." console warning). graphiql also ships
|
||||
// `setup-workers/vite`, which imports the same three workers via Vite's
|
||||
// `?worker` suffix, but those imports don't belong in the server graph, so
|
||||
// the swap happens here (client builds only) instead of in app source.
|
||||
//
|
||||
// SSR resolution is left untouched: neither variant's `getWorker` ever runs
|
||||
// during SSR, and the webpack flavor is a plain global assignment.
|
||||
function graphiqlViteWorkers(): Plugin {
|
||||
return {
|
||||
name: 'studio-graphiql-vite-workers',
|
||||
enforce: 'pre',
|
||||
resolveId(id, importer, options) {
|
||||
if (id !== 'graphiql/setup-workers/webpack' || options.ssr) return
|
||||
return this.resolve('graphiql/setup-workers/vite', importer, { skipSelf: true })
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Short-circuit UMD wrappers' AMD branch by string-replacing the
|
||||
// `define.amd` check. Vite's `config.define` doesn't reach pre-bundled
|
||||
// deps (Vite 8's Rolldown-based optimizer doesn't honour member-
|
||||
@@ -407,51 +348,23 @@ export function sentryForFinalOutputs(
|
||||
}
|
||||
|
||||
export default defineConfig(({ command, mode }) => {
|
||||
// Match Next's "always production-NODE_ENV during build" behaviour.
|
||||
// `pnpm run e2e:setup:selfhosted` invokes the build with a shell
|
||||
// `NODE_ENV=test` so Next can pick up `.env.test` for env loading;
|
||||
// Next overrides NODE_ENV back to 'production' internally before
|
||||
// emitting code, so the bundle never sees 'test'. Vite respects the
|
||||
// user's NODE_ENV by default and would bake `process.env.NODE_ENV ===
|
||||
// 'test'` into the client bundle, which trips vitest-only code paths
|
||||
// (notably `API_URL` in `lib/constants/index.ts` pointing the browser
|
||||
// at the vitest MSW host on port 3000, breaking every API fetch in
|
||||
// e2e). Override here so `--mode test` still loads `.env.test` (via
|
||||
// Vite's mode-based env resolution) while the bundle stays at
|
||||
// `NODE_ENV='production'`, mirroring Next.
|
||||
if (command === 'build') {
|
||||
// Next's types declare NODE_ENV as read-only, so cast to assign it.
|
||||
;(process.env as Record<string, string>).NODE_ENV = 'production'
|
||||
} else if (process.env.NODE_ENV === 'test') {
|
||||
// `pnpm dev:studio-local` runs with a shell NODE_ENV=test (the Next
|
||||
// path needs it to load `.env.test`), and Vite's
|
||||
// define plugin inlines `process.env.NODE_ENV || mode` into the client —
|
||||
// which would bake 'test' in and trip the vitest-only API_URL path.
|
||||
// `next dev` always runs the bundle at 'development' regardless of the
|
||||
// shell NODE_ENV; mirror that. Env-file selection is unaffected — the
|
||||
// vite dev path selects `.env.test` via MODE=test (see envMode below),
|
||||
// not NODE_ENV.
|
||||
;(process.env as Record<string, string>).NODE_ENV = 'development'
|
||||
}
|
||||
|
||||
// `pnpm dev:studio-local` needs the `.env.test` cascade (self-hosted mode
|
||||
// plus the supabase-cli keys that generateLocalEnv.js writes) — the Next
|
||||
// path selects it via NODE_ENV=test, and the tanstack build via
|
||||
// `--mode test` (e2e:setup:selfhosted). But `vite dev --mode test` is not
|
||||
// an option: TanStack Start's dev-server plugin treats mode 'test' as
|
||||
// plus the supabase-cli keys that generateLocalEnv.js writes) — `build`
|
||||
// selects it via `--mode test` (`MODE=test`), but `vite dev --mode test` is
|
||||
// not an option: TanStack Start's dev-server plugin treats mode 'test' as
|
||||
// "running under vitest" and skips installing its SSR middleware entirely,
|
||||
// so every route 404s (see the `isTest` guard in devServerPlugin,
|
||||
// @tanstack/start-plugin-core). So dev keeps mode 'development' and
|
||||
// emulates the env cascade of the mode named by MODE instead: load it for
|
||||
// the NEXT_PUBLIC_* defines below, and seed process.env for the SSR
|
||||
// runtime. The seeding must not clobber shell-provided values (matching
|
||||
// serve.js), and survives TanStack's own load-env plugin: that plugin
|
||||
// Object.assigns loadEnv(mode) at configResolved — after this runs — and
|
||||
// loadEnv gives existing process.env values priority over env-file values.
|
||||
// runtime. The seeding must not clobber shell-provided values, and survives
|
||||
// TanStack's own load-env plugin: that plugin Object.assigns loadEnv(mode)
|
||||
// at configResolved — after this runs — and loadEnv gives existing
|
||||
// process.env values priority over env-file values.
|
||||
const envMode = command === 'serve' && process.env.MODE ? process.env.MODE : mode
|
||||
|
||||
// Inline NEXT_PUBLIC_* env vars at build time so `process.env.NEXT_PUBLIC_*`
|
||||
// works in the browser bundle (mirrors Next.js behaviour).
|
||||
// works in the browser bundle.
|
||||
const env = loadEnv(envMode, rootDir, '')
|
||||
|
||||
if (envMode !== mode) {
|
||||
@@ -508,8 +421,7 @@ export default defineConfig(({ command, mode }) => {
|
||||
// the browser. When a var is unset it gets no define
|
||||
// entry above, which would leave a literal `process.env.*` in the built
|
||||
// bundle — and an undeclared `process` throws in the browser. Inline
|
||||
// `undefined` as the fallback, mirroring how Next inlines unset
|
||||
// NEXT_PUBLIC_* vars.
|
||||
// `undefined` as the fallback for unset NEXT_PUBLIC_* vars.
|
||||
for (const key of [
|
||||
'NEXT_PUBLIC_SENTRY_DSN',
|
||||
'NEXT_PUBLIC_SENTRY_ENVIRONMENT',
|
||||
@@ -556,19 +468,14 @@ export default defineConfig(({ command, mode }) => {
|
||||
},
|
||||
...(basePath && { base: basePath }),
|
||||
optimizeDeps: {
|
||||
// graphiql's Vite worker setup (swapped in for the webpack one by the
|
||||
// `graphiqlViteWorkers` plugin above) imports Monaco's workers with
|
||||
// Vite's `?worker` suffix. The dep optimizer can't load `?worker` ids
|
||||
// graphiql's Vite worker setup imports Monaco's workers with Vite's
|
||||
// `?worker` suffix. The dep optimizer can't load `?worker` ids
|
||||
// (UNLOADABLE_DEPENDENCY: "No such file or directory" for
|
||||
// `json.worker.js?worker` etc.), so keep the whole chain out of
|
||||
// pre-bundling; the modules then go through the normal transform
|
||||
// pipeline where Vite's built-in worker plugin turns each `?worker`
|
||||
// import into a spawnable Worker constructor.
|
||||
exclude: [
|
||||
'graphiql/setup-workers/webpack',
|
||||
'graphiql/setup-workers/vite',
|
||||
'@graphiql/react/setup-workers/vite',
|
||||
],
|
||||
exclude: ['graphiql/setup-workers/vite', '@graphiql/react/setup-workers/vite'],
|
||||
},
|
||||
// NOTE: `define.amd` is deliberately NOT substituted here. The AMD
|
||||
// short-circuit is handled exclusively by the `umdAmdShortCircuit()`
|
||||
@@ -612,9 +519,6 @@ export default defineConfig(({ command, mode }) => {
|
||||
},
|
||||
|
||||
// `lodash` is CJS; its named-export interop fails in Node ESM unless bundled.
|
||||
// `next/*` must be bundled so our nextCompat shim wins — otherwise Vite's
|
||||
// SSR externalizer leaves `next/*` as a runtime package import and
|
||||
// Node resolves it to Next's real module.
|
||||
// `tslib`'s Node ESM entry (`modules/index.js`) destructures from a
|
||||
// default-imported CJS wrapper (`tslib.js`). When consumers like
|
||||
// `@ai-sdk/amazon-bedrock` / `configcat-common` `import … from "tslib"`
|
||||
@@ -638,16 +542,13 @@ export default defineConfig(({ command, mode }) => {
|
||||
// every SSR request would 500. Left external in dev, Node loads it.
|
||||
noExternal: [
|
||||
'lodash',
|
||||
/^next(\/|$)/,
|
||||
...(command === 'build' ? ['tslib'] : []),
|
||||
'react-use',
|
||||
'awesome-debounce-promise',
|
||||
],
|
||||
},
|
||||
plugins: [
|
||||
nextCompat(),
|
||||
rawTextLoader(),
|
||||
graphiqlViteWorkers(),
|
||||
ssrStubGraphiql(),
|
||||
ssrLodashEs(),
|
||||
umdAmdShortCircuit(),
|
||||
|
||||
@@ -27,8 +27,6 @@ export default defineConfig({
|
||||
resolve(dirname, './tests/setup/dom.ts'),
|
||||
resolve(dirname, './tests/vitestSetup.ts'),
|
||||
],
|
||||
// Don't look for tests in the nextjs output directory
|
||||
exclude: [...configDefaults.exclude, `.next/*`],
|
||||
// jsdom costs ~1s of setup per file, so pure-logic `.test.ts` files run in node.
|
||||
// A `.test.ts` file that needs the DOM (e.g. `renderHook`) opts in with a
|
||||
// `// @vitest-environment jsdom` docblock at the top of the file.
|
||||
@@ -40,7 +38,7 @@ export default defineConfig({
|
||||
name: 'jsdom',
|
||||
environment: 'jsdom',
|
||||
include: ['**/*.test.tsx'],
|
||||
exclude: [...configDefaults.exclude, '.next/*', '**/*.platform.test.tsx'],
|
||||
exclude: [...configDefaults.exclude, '**/*.platform.test.tsx'],
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -49,7 +47,6 @@ export default defineConfig({
|
||||
name: 'jsdom-platform',
|
||||
environment: 'jsdom',
|
||||
include: ['**/*.platform.test.tsx'],
|
||||
exclude: [...configDefaults.exclude, '.next/*'],
|
||||
env: { NEXT_PUBLIC_IS_PLATFORM: 'true' },
|
||||
},
|
||||
},
|
||||
|
||||
+4
-4
@@ -77,7 +77,7 @@ The image tags below are pinned in `docker-compose.yml` at the time of this docu
|
||||
|
||||
## Studio (Dashboard)
|
||||
|
||||
> Studio is a Next.js (Pages Router) app. `NEXT_PUBLIC_*` variables are inlined into the client bundle at build time and are visible in the browser - never store secrets in them.
|
||||
> Studio is a TanStack Start app. `NEXT_PUBLIC_*` variables are inlined into the client bundle at build time and are visible in the browser - never store secrets in them.
|
||||
|
||||
### Core (database, API gateway, public URL)
|
||||
|
||||
@@ -85,7 +85,7 @@ The image tags below are pinned in `docker-compose.yml` at the time of this docu
|
||||
|---|---|---|---|---|
|
||||
| `DEFAULT_ORGANIZATION_NAME` | string | Self-hosted | Name shown for the single default organization on the dashboard. | Mapped from `STUDIO_DEFAULT_ORGANIZATION` in `.env.example`. Default: `Default Organization`. |
|
||||
| `DEFAULT_PROJECT_NAME` | string | Self-hosted | Name shown for the single default project on the dashboard. | Mapped from `STUDIO_DEFAULT_PROJECT` in `.env.example`. Default: `Default Project`. |
|
||||
| `HOSTNAME` | string | Both | Network interface Next.js binds to inside the container. | Set to `0.0.0.0` so the container is reachable from outside. |
|
||||
| `HOSTNAME` | string | Both | Container hostname / legacy bind-address variable. | Set to `0.0.0.0` in compose; Nitro reads `NITRO_HOST` / `HOST` and listens on all interfaces by default when unset. |
|
||||
| `POSTGRES_DB` | string | Self-hosted | Postgres database name used for Studio's internal connections. | Default: `postgres`. |
|
||||
| `POSTGRES_HOST` | string | Self-hosted | Postgres host (service name in compose network). | Default: `db`. |
|
||||
| `POSTGRES_PASSWORD` | string | Both | Postgres password for the `POSTGRES_USER_READ_WRITE` role. | Supports `_FILE` suffix for Docker secrets. |
|
||||
@@ -160,10 +160,10 @@ Self-hosted Studio reads `ENABLED_FEATURES_*` env vars at container start time t
|
||||
|
||||
| Variable | Type | Set by | Description | Notes |
|
||||
|---|---|---|---|---|
|
||||
| `CURRENT_CLI_VERSION` | string | CLI | Version string set when Studio is started by the Supabase CLI. | Renames the default project to "Supabase Studio (CLI)" when set. Exposed to client via Next.js passthrough. |
|
||||
| `CURRENT_CLI_VERSION` | string | CLI | Version string set when Studio is started by the Supabase CLI. | Renames the default project to "Supabase Studio (CLI)" when set. Read server-side only; clients detect CLI mode via `/api/platform/deployment-mode`. |
|
||||
| `NEXT_PUBLIC_IS_PLATFORM` | boolean | | Master switch: `"true"` runs Studio in hosted (multi-project) mode, anything else runs in self-hosted single-project mode. | Self-hosted images are **built** with this unset/`false`. Exposed to client. Setting this to `true` in a self-hosted deployment will break the dashboard. |
|
||||
| `NEXT_PUBLIC_NODE_ENV` | string | | Marks the build as a test build (used by E2E setup). | Set to `test` only by `generateLocalEnv.js`. Exposed to client. |
|
||||
| `NODE_ENV` | enum | | Standard Node.js environment (`development` / `production` / `test`). | Set automatically by Next.js. |
|
||||
| `NODE_ENV` | enum | | Standard Node.js environment (`development` / `production` / `test`). | Set automatically by Vite / runtime scripts. |
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -13,23 +13,16 @@ import { toUrl } from '../utils/to-url.js'
|
||||
*
|
||||
* IMPORTANT: the bug only reproduces with *client-side* (SPA) navigation. A full `page.goto`
|
||||
* reload unloads GraphiQL's CSS chunk, which removes the offending injected rule — so these
|
||||
* tests navigate via the Next router to keep the chunk loaded, exactly like a real user.
|
||||
* tests navigate client-side to keep the chunk loaded, exactly like a real user.
|
||||
*/
|
||||
test.describe('Monaco / GraphiQL coexistence', () => {
|
||||
test.skip(env.IS_PLATFORM, 'Self-hosted mode only — GraphiQL + SQL editor on one local project')
|
||||
|
||||
// Client-side navigation (keeps already-loaded chunks/CSS in place). The Next
|
||||
// build exposes `window.next.router`; the TanStack build has no equivalent
|
||||
// global, but its router subscribes to popstate, so pushState + popstate
|
||||
// emulates the same SPA navigation without unloading chunks.
|
||||
// Client-side navigation (keeps already-loaded chunks/CSS in place). TanStack
|
||||
// Router subscribes to popstate, so pushState + popstate triggers SPA
|
||||
// navigation without unloading chunks.
|
||||
const routerPush = async (page: Page, path: string) => {
|
||||
await page.evaluate((p) => {
|
||||
const router = (window as unknown as { next?: { router?: { push: (p: string) => void } } })
|
||||
.next?.router
|
||||
if (router) {
|
||||
router.push(p)
|
||||
return
|
||||
}
|
||||
window.history.pushState({}, '', p)
|
||||
window.dispatchEvent(new PopStateEvent('popstate'))
|
||||
}, path)
|
||||
|
||||
@@ -9,7 +9,7 @@ const navigateToQueuesPage = async (page: Page, ref: string) => {
|
||||
await page.goto(toUrl(`/project/${ref}/integrations/queues/queues`))
|
||||
// Wait for a stable header signal rather than the grid — the grid only
|
||||
// renders when at least one queue exists, and an empty list shows an
|
||||
// empty-state placeholder instead. Under workers=3 the Next.js server
|
||||
// empty-state placeholder instead. Under workers=3 the Studio server
|
||||
// doesn't always populate the list fast enough before the assertion,
|
||||
// so the test would flake at navigation rather than at the actual
|
||||
// assertion. The "Create queue" button is part of the page header and
|
||||
@@ -56,13 +56,13 @@ const sendMessageViaAPI = async (
|
||||
})
|
||||
}
|
||||
|
||||
// Asserts a queue exists in the UI in a routing-agnostic way. After the
|
||||
// post-create flow, two end-states are valid:
|
||||
// - Next mode: `router.push` reliably navigates to the queue-detail page
|
||||
// so the URL ends with /queues/{queueName} and the heading appears.
|
||||
// - TanStack mode: `router.push` (via the next/router shim) races nuqs's
|
||||
// `?new=true` history update and the URL stays on the list, so the new
|
||||
// row is visible there instead.
|
||||
// Asserts a queue exists in the UI after creation. CreateQueueSheet calls
|
||||
// `navigateToUrl` to `/queues/{queueName}` and immediately invokes `onClose()`,
|
||||
// which clears `?new=true` via nuqs's TanStack adapter. Because both trigger
|
||||
// router navigations, two end-states are possible:
|
||||
// - Navigation wins: the URL ends with /queues/{queueName}.
|
||||
// - nuqs's `?new=true` cleanup runs against the list pathname first:
|
||||
// the URL stays on the list page, where the new row is visible instead.
|
||||
// Either signal counts as success — poll until one of them lands.
|
||||
const expectQueueCreated = async (page: Page, queueName: string) => {
|
||||
await expect
|
||||
|
||||
@@ -30,10 +30,6 @@
|
||||
"start.ts",
|
||||
// Route modules are real entry points.
|
||||
"routes/**/*.{ts,tsx}",
|
||||
// Next.js compat shims. Reached only through the `nextShims` aliases in
|
||||
// vite.config.ts (`next/script` -> compat/next/script.tsx), which knip
|
||||
// cannot resolve, so they need to be entries in their own right.
|
||||
"compat/**/*.{ts,tsx}",
|
||||
],
|
||||
"ignore": [
|
||||
"public/**",
|
||||
|
||||
+3
-3
@@ -16,7 +16,7 @@
|
||||
"clean": "turbo run clean && rimraf -G .turbo/cache && pnpm purge",
|
||||
"dev": "turbo run dev",
|
||||
"dev:studio": "turbo run dev --filter=studio",
|
||||
"dev:studio-local": "pnpm setup:cli && NODE_ENV=test MODE=test pnpm --prefix ./apps/studio dev",
|
||||
"dev:studio-local": "pnpm setup:cli && MODE=test pnpm --prefix ./apps/studio dev",
|
||||
"dev:docs": "turbo run dev --filter=docs",
|
||||
"dev:kb": "turbo run dev --filter=kb",
|
||||
"dev:www": "turbo run dev --filter=www",
|
||||
@@ -33,8 +33,8 @@
|
||||
"test:studio": "turbo run test --filter=studio",
|
||||
"test:studio:watch": "turbo run test --filter=studio -- watch",
|
||||
"e2e:setup:cli": "supabase stop --all --no-backup --workdir ./e2e/studio; supabase start --exclude studio,mailpit --workdir ./e2e/studio && supabase status --output json --workdir ./e2e/studio > keys.json && node scripts/generateLocalEnv.js",
|
||||
"e2e:setup:selfhosted": "SKIP_ASSET_UPLOAD=1 pnpm e2e:setup:cli && NODE_ENV=test MODE=test NODE_OPTIONS=\"--max-old-space-size=4096\" pnpm run build:studio && NODE_ENV=test MODE=test pnpm --prefix ./apps/studio start",
|
||||
"e2e:setup:selfhosted:start-studio": "SKIP_ASSET_UPLOAD=1 NODE_ENV=test MODE=test pnpm --prefix ./apps/studio start",
|
||||
"e2e:setup:selfhosted": "SKIP_ASSET_UPLOAD=1 pnpm e2e:setup:cli && MODE=test NODE_OPTIONS=\"--max-old-space-size=4096\" pnpm run build:studio && MODE=test pnpm --prefix ./apps/studio start",
|
||||
"e2e:setup:selfhosted:start-studio": "SKIP_ASSET_UPLOAD=1 MODE=test pnpm --prefix ./apps/studio start",
|
||||
"e2e:setup:platform": "SKIP_ASSET_UPLOAD=1 NODE_OPTIONS=\"--max-old-space-size=4096\" pnpm run build:studio && pnpm --prefix ./apps/studio start",
|
||||
"e2e": "pnpm --prefix e2e/studio run e2e",
|
||||
"e2e:ui": "pnpm --prefix e2e/studio run e2e:ui",
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
import { createRequire, Module } from 'node:module'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
const require = createRequire(import.meta.url)
|
||||
const { ESLint } = require('eslint')
|
||||
const reactConfig = require('../react')
|
||||
|
||||
// In sparse-checkout CI (e.g. ESLint Config Tests), no Next.js app is checked out so `next` is not
|
||||
// installed. `eslint-config-next/dist/parser.js` eagerly requires Next's bundled Babel parser even
|
||||
// when we only call `ESLint#calculateConfigForFile` (which never parses code). Stub only that
|
||||
// parser import when `next` is absent so the real `eslint-config-next` rules, plugins, settings,
|
||||
// and globals are still tested end-to-end.
|
||||
function loadNextConfig() {
|
||||
const internalModule = Module as typeof Module & {
|
||||
_load: (request: string, parent: NodeModule | null, isMain: boolean) => unknown
|
||||
}
|
||||
const originalLoad = internalModule._load
|
||||
internalModule._load = function patchedLoad(request, parent, isMain) {
|
||||
if (request === 'next/dist/compiled/babel/eslint-parser') {
|
||||
try {
|
||||
return originalLoad.call(this, request, parent, isMain)
|
||||
} catch (err) {
|
||||
if ((err as NodeJS.ErrnoException).code === 'MODULE_NOT_FOUND') {
|
||||
return { parse: () => ({}), parseForESLint: () => ({}) }
|
||||
}
|
||||
throw err
|
||||
}
|
||||
}
|
||||
return originalLoad.call(this, request, parent, isMain)
|
||||
}
|
||||
try {
|
||||
return require('../next')
|
||||
} finally {
|
||||
internalModule._load = originalLoad
|
||||
}
|
||||
}
|
||||
|
||||
const nextConfig = loadNextConfig()
|
||||
|
||||
function createLinter(overrideConfig: unknown[]) {
|
||||
return new ESLint({
|
||||
overrideConfigFile: true,
|
||||
overrideConfig,
|
||||
})
|
||||
}
|
||||
|
||||
function withoutNextRules(rules: Record<string, unknown> = {}) {
|
||||
return Object.fromEntries(
|
||||
Object.entries(rules).filter(([ruleId]) => !ruleId.startsWith('@next/next/'))
|
||||
)
|
||||
}
|
||||
|
||||
describe('eslint-config-supabase presets', () => {
|
||||
it.each(['src/example.tsx', 'src/example.ts', 'src/example.mjs'])(
|
||||
'matches next preset non-Next rules, settings, linterOptions, and globals for %s',
|
||||
async (filePath) => {
|
||||
const nextLinter = createLinter(nextConfig)
|
||||
const reactLinter = createLinter(reactConfig)
|
||||
|
||||
const [nextResolved, reactResolved] = await Promise.all([
|
||||
nextLinter.calculateConfigForFile(filePath),
|
||||
reactLinter.calculateConfigForFile(filePath),
|
||||
])
|
||||
|
||||
const reactRuleIds = Object.keys(reactResolved.rules ?? {})
|
||||
expect(reactRuleIds.filter((id) => id.startsWith('@next/next/'))).toEqual([])
|
||||
expect(Object.keys(reactResolved.plugins ?? {})).not.toContain('@next/next')
|
||||
|
||||
expect(reactResolved.rules).toEqual(withoutNextRules(nextResolved.rules))
|
||||
expect(reactResolved.settings).toEqual(nextResolved.settings)
|
||||
expect(reactResolved.linterOptions).toEqual(nextResolved.linterOptions)
|
||||
expect(reactResolved.languageOptions?.globals).toEqual(nextResolved.languageOptions?.globals)
|
||||
}
|
||||
)
|
||||
|
||||
it('omits Next Babel parser, Next ignores, and keeps React Compiler hook rules off in react preset', async () => {
|
||||
const reactLinter = createLinter(reactConfig)
|
||||
const [tsxResolved, mjsResolved] = await Promise.all([
|
||||
reactLinter.calculateConfigForFile('src/example.tsx'),
|
||||
reactLinter.calculateConfigForFile('src/example.mjs'),
|
||||
])
|
||||
|
||||
expect(tsxResolved.languageOptions?.parserOptions?.babelOptions).toBeUndefined()
|
||||
expect(mjsResolved.languageOptions?.parserOptions?.babelOptions).toBeUndefined()
|
||||
const mjsParserName =
|
||||
mjsResolved.languageOptions?.parser?.meta?.name ??
|
||||
mjsResolved.languageOptions?.parser?.name ??
|
||||
''
|
||||
expect(mjsParserName).not.toContain('eslint-config-next')
|
||||
|
||||
expect(reactResolvedIgnores(reactConfig)).not.toContain('.next')
|
||||
expect(reactResolvedIgnores(reactConfig)).not.toContain('.next/**')
|
||||
expect(reactResolvedIgnores(reactConfig)).not.toContain('.contentlayer')
|
||||
|
||||
const hookRules = Object.entries(tsxResolved.rules ?? {}).filter(([id]) =>
|
||||
id.startsWith('react-hooks/')
|
||||
)
|
||||
expect(hookRules.length).toBeGreaterThan(2)
|
||||
for (const [ruleId, setting] of hookRules) {
|
||||
const severity = Array.isArray(setting) ? setting[0] : setting
|
||||
if (ruleId === 'react-hooks/rules-of-hooks') {
|
||||
expect(severity).toBe(2)
|
||||
} else if (ruleId === 'react-hooks/exhaustive-deps') {
|
||||
expect(severity).toBe(1)
|
||||
} else {
|
||||
expect(severity).toBe(0)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
function reactResolvedIgnores(config: Array<{ ignores?: string[] }>) {
|
||||
return config.flatMap((block) => block.ignores ?? [])
|
||||
}
|
||||
@@ -1,129 +1,10 @@
|
||||
const { defineConfig } = require('eslint/config')
|
||||
const prettierConfig = require('eslint-config-prettier/flat')
|
||||
const { default: turboConfig } = require('eslint-config-turbo/flat')
|
||||
const tanstackQuery = require('@tanstack/eslint-plugin-query')
|
||||
const tsparser = require('@typescript-eslint/parser')
|
||||
const nextCoreWebVitals = require('eslint-config-next/core-web-vitals')
|
||||
const shadcnConfig = require('./shadcn')
|
||||
const { createSupabaseConfig } = require('./shared')
|
||||
|
||||
const NEXT_PLUGIN_FILES = ['**/*.{js,jsx,mjs,ts,tsx,mts,cts}']
|
||||
|
||||
// Custom Supabase rules
|
||||
const noAwaitBeforeCopyToClipboard = require('./rules/no-await-before-copy-to-clipboard')
|
||||
const requireExplicitTabIndex = require('./rules/require-explicit-tabindex')
|
||||
|
||||
// Transitional config that turns off all the React Compiler hook rules that come bundled
|
||||
// with core-web-vitals@16. We want to upgrade to get exhaustive-deps updates without
|
||||
// blowing up our error count.
|
||||
const compilerRulesOff = {}
|
||||
for (const cfg of nextCoreWebVitals) {
|
||||
for (const key of Object.keys(cfg.rules ?? {})) {
|
||||
if (
|
||||
key.startsWith('react-hooks/') &&
|
||||
key !== 'react-hooks/exhaustive-deps' &&
|
||||
key !== 'react-hooks/rules-of-hooks'
|
||||
) {
|
||||
compilerRulesOff[key] = 'off'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Custom Supabase ESLint plugin
|
||||
const supabasePlugin = {
|
||||
rules: {
|
||||
'no-await-before-copy-to-clipboard': noAwaitBeforeCopyToClipboard,
|
||||
'require-explicit-tabindex': requireExplicitTabIndex,
|
||||
module.exports = createSupabaseConfig({
|
||||
extraIgnores: ['.next', '.contentlayer'],
|
||||
frameworkConfigs: nextCoreWebVitals,
|
||||
extraRules: {
|
||||
'@next/next/no-html-link-for-pages': 'off',
|
||||
},
|
||||
}
|
||||
|
||||
// TypeScript ESLint config for TypeScript files
|
||||
const typescriptConfig = {
|
||||
name: 'typescript',
|
||||
files: ['**/*.ts', '**/*.tsx'],
|
||||
languageOptions: {
|
||||
parser: tsparser,
|
||||
parserOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
supabase: supabasePlugin,
|
||||
},
|
||||
rules: {
|
||||
'@typescript-eslint/no-explicit-any': 'warn',
|
||||
'supabase/no-await-before-copy-to-clipboard': 'error',
|
||||
'supabase/require-explicit-tabindex': 'error',
|
||||
},
|
||||
}
|
||||
|
||||
module.exports = defineConfig([
|
||||
// Global ignore for build output and static assets
|
||||
{ ignores: ['.next', 'dist', 'public', '.contentlayer'] },
|
||||
// eslint-config-next v16 registers its plugins for `.mts`/`.cts` (v15 didn't lint
|
||||
// them at all), which newly surfaces errors in build/tooling scripts. Keep the prior
|
||||
// lint surface and leave `.mts`/`.cts` unlinted; revisit as a separate change.
|
||||
{ ignores: ['**/*.mts', '**/*.cts'] },
|
||||
turboConfig,
|
||||
prettierConfig,
|
||||
shadcnConfig,
|
||||
tanstackQuery.configs['flat/recommended'],
|
||||
{
|
||||
rules: {
|
||||
// Grants (FGA permission tokens) and connection strings don't change the returned data,
|
||||
// so keeping them out of query keys avoids splitting the cache.
|
||||
'@tanstack/query/exhaustive-deps': [
|
||||
'warn',
|
||||
{ allowlist: { variables: ['grant', 'connectionString'] } },
|
||||
],
|
||||
},
|
||||
},
|
||||
typescriptConfig,
|
||||
...nextCoreWebVitals,
|
||||
{
|
||||
files: NEXT_PLUGIN_FILES,
|
||||
linterOptions: {
|
||||
reportUnusedDisableDirectives: 'warn',
|
||||
},
|
||||
rules: {
|
||||
...compilerRulesOff,
|
||||
'@next/next/no-html-link-for-pages': 'off',
|
||||
'react/jsx-key': 'off',
|
||||
'no-restricted-imports': [
|
||||
'warn',
|
||||
{
|
||||
name: 'react-data-grid',
|
||||
message: 'Please use @tanstack/react-table instead.',
|
||||
},
|
||||
{
|
||||
name: 'react-contexify',
|
||||
message: 'Please use ContextMenu from the ui package instead.',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
// check for default exports in all files except app and pages folders.
|
||||
ignores: [
|
||||
'pages/**/*.ts',
|
||||
'app/**/*.ts',
|
||||
'pages/**/*.tsx',
|
||||
'app/**/*.tsx',
|
||||
'components/interfaces/**/content/**/content.tsx',
|
||||
'vitest.config.ts',
|
||||
'postcss.config.js',
|
||||
'postcss.config.cjs',
|
||||
'velite.config.js',
|
||||
],
|
||||
rules: {
|
||||
'no-restricted-exports': [
|
||||
'warn',
|
||||
{
|
||||
restrictDefaultExports: {
|
||||
direct: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
])
|
||||
})
|
||||
@@ -17,8 +17,16 @@
|
||||
"eslint-config-next": "^16.0.0",
|
||||
"eslint-config-prettier": "^10.0.0",
|
||||
"eslint-config-turbo": "^2.5.0",
|
||||
"eslint-import-resolver-node": "^0.3.6",
|
||||
"eslint-import-resolver-typescript": "^3.5.2",
|
||||
"eslint-plugin-import": "^2.32.0",
|
||||
"eslint-plugin-jsx-a11y": "^6.10.0",
|
||||
"eslint-plugin-react": "^7.37.0",
|
||||
"eslint-plugin-react-hooks": "^7.0.0",
|
||||
"globals": "16.4.0",
|
||||
"tsx": "catalog:",
|
||||
"typescript": "catalog:",
|
||||
"typescript-eslint": "^8.46.0",
|
||||
"vitest": "catalog:"
|
||||
}
|
||||
}
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
const reactPlugin = require('eslint-plugin-react')
|
||||
const reactHooksPlugin = require('eslint-plugin-react-hooks')
|
||||
const importPlugin = require('eslint-plugin-import')
|
||||
const jsxA11yPlugin = require('eslint-plugin-jsx-a11y')
|
||||
const typescriptEslint = require('typescript-eslint')
|
||||
const globals = require('globals')
|
||||
const { PLUGIN_FILES, createSupabaseConfig } = require('./shared')
|
||||
|
||||
const reactFrameworkConfigs = [
|
||||
{
|
||||
name: 'supabase/react',
|
||||
files: PLUGIN_FILES,
|
||||
plugins: {
|
||||
react: reactPlugin,
|
||||
'react-hooks': reactHooksPlugin,
|
||||
import: importPlugin,
|
||||
'jsx-a11y': jsxA11yPlugin,
|
||||
},
|
||||
languageOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
globals: {
|
||||
...globals.browser,
|
||||
...globals.node,
|
||||
},
|
||||
},
|
||||
settings: {
|
||||
react: {
|
||||
version: 'detect',
|
||||
},
|
||||
'import/parsers': {
|
||||
'@typescript-eslint/parser': ['.ts', '.mts', '.cts', '.tsx', '.d.ts'],
|
||||
},
|
||||
'import/resolver': {
|
||||
node: {
|
||||
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
||||
},
|
||||
typescript: {
|
||||
alwaysTryTypes: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
...reactPlugin.configs.recommended.rules,
|
||||
...reactHooksPlugin.configs.recommended.rules,
|
||||
'import/no-anonymous-default-export': 'warn',
|
||||
'react/no-unknown-property': 'off',
|
||||
'react/react-in-jsx-scope': 'off',
|
||||
'react/prop-types': 'off',
|
||||
'jsx-a11y/alt-text': [
|
||||
'warn',
|
||||
{
|
||||
elements: ['img'],
|
||||
img: ['Image'],
|
||||
},
|
||||
],
|
||||
'jsx-a11y/aria-props': 'warn',
|
||||
'jsx-a11y/aria-proptypes': 'warn',
|
||||
'jsx-a11y/aria-unsupported-elements': 'warn',
|
||||
'jsx-a11y/role-has-required-aria-props': 'warn',
|
||||
'jsx-a11y/role-supports-aria-props': 'warn',
|
||||
'react/jsx-no-target-blank': 'off',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'supabase/react-js',
|
||||
files: ['**/*.{js,jsx,mjs}'],
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
ecmaFeatures: {
|
||||
jsx: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'supabase/react-typescript',
|
||||
files: ['**/*.ts', '**/*.tsx'],
|
||||
plugins: {
|
||||
'@typescript-eslint': typescriptEslint.plugin,
|
||||
},
|
||||
languageOptions: {
|
||||
parser: typescriptEslint.parser,
|
||||
parserOptions: {
|
||||
sourceType: 'module',
|
||||
},
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
module.exports = createSupabaseConfig({
|
||||
frameworkConfigs: reactFrameworkConfigs,
|
||||
})
|
||||
@@ -0,0 +1,140 @@
|
||||
const { defineConfig } = require('eslint/config')
|
||||
const prettierConfig = require('eslint-config-prettier/flat')
|
||||
const { default: turboConfig } = require('eslint-config-turbo/flat')
|
||||
const tanstackQuery = require('@tanstack/eslint-plugin-query')
|
||||
const tsparser = require('@typescript-eslint/parser')
|
||||
const shadcnConfig = require('./shadcn')
|
||||
|
||||
// Custom Supabase rules
|
||||
const noAwaitBeforeCopyToClipboard = require('./rules/no-await-before-copy-to-clipboard')
|
||||
const requireExplicitTabIndex = require('./rules/require-explicit-tabindex')
|
||||
|
||||
const PLUGIN_FILES = ['**/*.{js,jsx,mjs,ts,tsx,mts,cts}']
|
||||
|
||||
// Custom Supabase ESLint plugin
|
||||
const supabasePlugin = {
|
||||
rules: {
|
||||
'no-await-before-copy-to-clipboard': noAwaitBeforeCopyToClipboard,
|
||||
'require-explicit-tabindex': requireExplicitTabIndex,
|
||||
},
|
||||
}
|
||||
|
||||
// TypeScript ESLint config for TypeScript files
|
||||
const typescriptConfig = {
|
||||
name: 'typescript',
|
||||
files: ['**/*.ts', '**/*.tsx'],
|
||||
languageOptions: {
|
||||
parser: tsparser,
|
||||
parserOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
supabase: supabasePlugin,
|
||||
},
|
||||
rules: {
|
||||
'@typescript-eslint/no-explicit-any': 'warn',
|
||||
'supabase/no-await-before-copy-to-clipboard': 'error',
|
||||
'supabase/require-explicit-tabindex': 'error',
|
||||
},
|
||||
}
|
||||
|
||||
// Transitional helper that turns off all the React Compiler hook rules that come bundled
|
||||
// with eslint-plugin-react-hooks v7 (including via core-web-vitals@16). We want to upgrade
|
||||
// to get exhaustive-deps updates without blowing up our error count.
|
||||
function getCompilerRulesOff(configs) {
|
||||
const compilerRulesOff = {}
|
||||
for (const cfg of configs) {
|
||||
for (const key of Object.keys(cfg.rules ?? {})) {
|
||||
if (
|
||||
key.startsWith('react-hooks/') &&
|
||||
key !== 'react-hooks/exhaustive-deps' &&
|
||||
key !== 'react-hooks/rules-of-hooks'
|
||||
) {
|
||||
compilerRulesOff[key] = 'off'
|
||||
}
|
||||
}
|
||||
}
|
||||
return compilerRulesOff
|
||||
}
|
||||
|
||||
const noRestrictedExportsConfig = {
|
||||
// check for default exports in all files except app and pages folders.
|
||||
ignores: [
|
||||
'pages/**/*.ts',
|
||||
'app/**/*.ts',
|
||||
'pages/**/*.tsx',
|
||||
'app/**/*.tsx',
|
||||
'components/interfaces/**/content/**/content.tsx',
|
||||
'vitest.config.ts',
|
||||
'postcss.config.js',
|
||||
'postcss.config.cjs',
|
||||
'velite.config.js',
|
||||
],
|
||||
rules: {
|
||||
'no-restricted-exports': [
|
||||
'warn',
|
||||
{
|
||||
restrictDefaultExports: {
|
||||
direct: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
function createSupabaseConfig({ extraIgnores = [], frameworkConfigs = [], extraRules = {} }) {
|
||||
const compilerRulesOff = getCompilerRulesOff(frameworkConfigs)
|
||||
|
||||
return defineConfig([
|
||||
// Global ignore for build output and static assets
|
||||
{ ignores: ['dist', 'public', ...extraIgnores] },
|
||||
// Keep `.mts`/`.cts` unlinted so build/tooling scripts are excluded from the lint surface.
|
||||
{ ignores: ['**/*.mts', '**/*.cts'] },
|
||||
turboConfig,
|
||||
prettierConfig,
|
||||
shadcnConfig,
|
||||
tanstackQuery.configs['flat/recommended'],
|
||||
{
|
||||
rules: {
|
||||
// Grants (FGA permission tokens) and connection strings don't change the returned data,
|
||||
// so keeping them out of query keys avoids splitting the cache.
|
||||
'@tanstack/query/exhaustive-deps': [
|
||||
'warn',
|
||||
{ allowlist: { variables: ['grant', 'connectionString'] } },
|
||||
],
|
||||
},
|
||||
},
|
||||
typescriptConfig,
|
||||
...frameworkConfigs,
|
||||
{
|
||||
files: PLUGIN_FILES,
|
||||
linterOptions: {
|
||||
reportUnusedDisableDirectives: 'warn',
|
||||
},
|
||||
rules: {
|
||||
...compilerRulesOff,
|
||||
...extraRules,
|
||||
'react/jsx-key': 'off',
|
||||
'no-restricted-imports': [
|
||||
'warn',
|
||||
{
|
||||
name: 'react-data-grid',
|
||||
message: 'Please use @tanstack/react-table instead.',
|
||||
},
|
||||
{
|
||||
name: 'react-contexify',
|
||||
message: 'Please use ContextMenu from the ui package instead.',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
noRestrictedExportsConfig,
|
||||
])
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
PLUGIN_FILES,
|
||||
createSupabaseConfig,
|
||||
}
|
||||
Generated
+36
-74
@@ -1508,9 +1508,6 @@ importers:
|
||||
motion:
|
||||
specifier: 'catalog:'
|
||||
version: 11.18.2(@emotion/is-prop-valid@1.4.0)(react-dom@19.2.6(react@19.2.6))(react@19.2.6)
|
||||
next:
|
||||
specifier: 'catalog:'
|
||||
version: 16.4.6(@babel/core@7.29.7(supports-color@8.1.1))(@opentelemetry/api@1.9.1)(@playwright/test@1.65.1)(@types/node@26.6.6)(babel-plugin-macros@3.1.0)(react-dom@19.2.6(react@19.2.6))(react@19.2.6)(sass@1.77.4)
|
||||
next-themes:
|
||||
specifier: 'catalog:'
|
||||
version: 0.4.6(react-dom@19.2.6(react@19.2.6))(react@19.2.6)
|
||||
@@ -1761,9 +1758,6 @@ importers:
|
||||
msw:
|
||||
specifier: ^2.3.0
|
||||
version: 2.11.3(@types/node@26.6.6)(typescript@6.0.2)
|
||||
next-router-mock:
|
||||
specifier: ^0.9.13
|
||||
version: 0.9.13(next@16.4.6(@babel/core@7.29.7(supports-color@8.1.1))(@opentelemetry/api@1.9.1)(@playwright/test@1.65.1)(@types/node@26.6.6)(babel-plugin-macros@3.1.0)(react-dom@19.2.6(react@19.2.6))(react@19.2.6)(sass@1.77.4))(react@19.2.6)
|
||||
nitro:
|
||||
specifier: 3.0.260903-beta
|
||||
version: 3.0.260903-beta
|
||||
@@ -2854,12 +2848,36 @@ importers:
|
||||
eslint-config-turbo:
|
||||
specifier: ^2.5.0
|
||||
version: 2.5.8(eslint@9.37.0(jiti@2.7.0)(supports-color@8.1.1))(turbo@2.11.10)
|
||||
eslint-import-resolver-node:
|
||||
specifier: ^0.3.6
|
||||
version: 0.3.9(supports-color@8.1.1)
|
||||
eslint-import-resolver-typescript:
|
||||
specifier: ^3.5.2
|
||||
version: 3.6.1(@typescript-eslint/parser@8.65.0(eslint@9.37.0(jiti@2.7.0)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@6.0.2))(eslint-import-resolver-node@0.3.9(supports-color@8.1.1))(eslint-plugin-import@2.32.0)(eslint@9.37.0(jiti@2.7.0)(supports-color@8.1.1))(supports-color@8.1.1)
|
||||
eslint-plugin-import:
|
||||
specifier: ^2.32.0
|
||||
version: 2.32.0(@typescript-eslint/parser@8.65.0(eslint@9.37.0(jiti@2.7.0)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@6.0.2))(eslint-import-resolver-typescript@3.6.1)(eslint@9.37.0(jiti@2.7.0)(supports-color@8.1.1))(supports-color@8.1.1)
|
||||
eslint-plugin-jsx-a11y:
|
||||
specifier: ^6.10.0
|
||||
version: 6.10.2(eslint@9.37.0(jiti@2.7.0)(supports-color@8.1.1))
|
||||
eslint-plugin-react:
|
||||
specifier: ^7.37.0
|
||||
version: 7.37.5(eslint@9.37.0(jiti@2.7.0)(supports-color@8.1.1))
|
||||
eslint-plugin-react-hooks:
|
||||
specifier: ^7.0.0
|
||||
version: 7.1.1(eslint@9.37.0(jiti@2.7.0)(supports-color@8.1.1))(supports-color@8.1.1)
|
||||
globals:
|
||||
specifier: 16.4.0
|
||||
version: 16.4.0
|
||||
tsx:
|
||||
specifier: 'catalog:'
|
||||
version: 4.22.4
|
||||
typescript:
|
||||
specifier: 'catalog:'
|
||||
version: 6.0.2
|
||||
typescript-eslint:
|
||||
specifier: ^8.46.0
|
||||
version: 8.65.0(eslint@9.37.0(jiti@2.7.0)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@6.0.2)
|
||||
vitest:
|
||||
specifier: 'catalog:'
|
||||
version: 5.1.1(@opentelemetry/api@1.9.1)(@types/node@26.6.6)(@vitest/coverage-v8@5.1.1)(@vitest/ui@5.1.1)(happy-dom@20.14.5)(jsdom@28.1.0(@noble/hashes@1.8.0)(supports-color@8.1.1))(msw@2.11.3(@types/node@26.6.6)(typescript@6.0.2))(vite@8.3.8(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.77.4)(terser@5.51.2)(tsx@4.22.4)(yaml@2.9.1))
|
||||
@@ -11154,10 +11172,6 @@ packages:
|
||||
array-flatten@1.1.1:
|
||||
resolution: {integrity: sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==}
|
||||
|
||||
array-includes@3.1.8:
|
||||
resolution: {integrity: sha512-itaWrbYbqpGXkGhZPGUulwnhVf5Hpy1xiCFsGqyIGglbBxmG5vSjxQen3/WGOjPpNEv1RtBLKxbmVXm8HpJStQ==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
array-includes@3.1.9:
|
||||
resolution: {integrity: sha512-FmeCCAenzH0KH381SPT5FZmiA/TmpndpcaShhfgEN9eCVjnFBqq3l1xrI42y8+PPLI6hypzou4GXw00WHmPBLQ==}
|
||||
engines: {node: '>= 0.4'}
|
||||
@@ -11177,10 +11191,6 @@ packages:
|
||||
resolution: {integrity: sha512-F/TKATkzseUExPlfvmwQKGITM3DGTK+vkAsCZoDc5daVygbJBnjEUCbgkAvVFsgfXfX4YIqZ/27G3k3tdXrTxQ==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
array.prototype.flat@1.3.2:
|
||||
resolution: {integrity: sha512-djYB+Zx2vLewY8RWlNCUdHjDXs2XOgm602S9E7P/UpHgfeHL00cRiIF+IN/G/aUJ7kGPb6yO/ErDI5V2s8iycA==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
array.prototype.flat@1.3.3:
|
||||
resolution: {integrity: sha512-rwG/ja1neyLqCuGZ5YYrznA62D4mZXg0i1cIskIUKSiqF3Cje9/wXAls9B9s1Wa2fomMsIv8czB8jZcPmxCXFg==}
|
||||
engines: {node: '>= 0.4'}
|
||||
@@ -11289,10 +11299,6 @@ packages:
|
||||
aws4fetch@1.0.20:
|
||||
resolution: {integrity: sha512-/djoAN709iY65ETD6LKCtyyEI04XIBP5xVvfmNxsEP0uJB5tyaGBztSryRr4HqMStr9R06PisQE7m9zDTXKu6g==}
|
||||
|
||||
axe-core@4.10.3:
|
||||
resolution: {integrity: sha512-Xm7bpRXnDSX2YE2YFfBk2FnF0ep6tmG7xPh8iHee8MIcrgq762Nkce856dYtJYLkuIoYZvGfTs/PbZhideTcEg==}
|
||||
engines: {node: '>=4'}
|
||||
|
||||
axe-core@4.12.1:
|
||||
resolution: {integrity: sha512-s7iGf5GaVMxEG0ENN9x+xTr7GFZCb1ZP/1uATUpCEK2X78nDB3RwbtFCo9pGAf9ru+VwoQ464DkaLEeRM08wJA==}
|
||||
engines: {node: '>=4'}
|
||||
@@ -12685,9 +12691,6 @@ packages:
|
||||
resolution: {integrity: sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
es-shim-unscopables@1.0.2:
|
||||
resolution: {integrity: sha512-J3yBRXCzDu4ULnQwxyToo/OjdMx6akgVC7K6few0a7F/0wLtmKKN7I73AH5T2836UuXRqN7Qg+IIUw/+YJksRw==}
|
||||
|
||||
es-shim-unscopables@1.1.0:
|
||||
resolution: {integrity: sha512-d9T8ucsEhh8Bi1woXCf+TIKDIROLG5WCkxg8geBCbvk22kzwC5G2OnXVMO6FUsvQlgUUXQ2itephWDLqDzbeCw==}
|
||||
engines: {node: '>= 0.4'}
|
||||
@@ -13783,10 +13786,6 @@ packages:
|
||||
has-unicode@2.0.1:
|
||||
resolution: {integrity: sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ==}
|
||||
|
||||
hasown@2.0.2:
|
||||
resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
hasown@2.0.4:
|
||||
resolution: {integrity: sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==}
|
||||
engines: {node: '>= 0.4'}
|
||||
@@ -15757,12 +15756,6 @@ packages:
|
||||
next-plugin-yaml@1.0.1:
|
||||
resolution: {integrity: sha512-k13wbpN33wTgrgWUBiXPtObXO94JOEiwvYKJ3X0JrBz2yaW24EfNaVqHwA0dwhsn9PyPIKhPhgsu3bhJsNs+cQ==}
|
||||
|
||||
next-router-mock@0.9.13:
|
||||
resolution: {integrity: sha512-906n2RRaE6Y28PfYJbaz5XZeJ6Tw8Xz1S6E31GGwZ0sXB6/XjldD1/2azn1ZmBmRk5PQRkzjg+n+RHZe5xQzWA==}
|
||||
peerDependencies:
|
||||
next: '>=10.0.0'
|
||||
react: '>=17.0.0'
|
||||
|
||||
next-seo@6.5.0:
|
||||
resolution: {integrity: sha512-MfzUeWTN/x/rsKp/1n0213eojO97lIl0unxqbeCY+6pAucViHDA8GSLRRcXpgjsSmBxfCFdfpu7LXbt4ANQoNQ==}
|
||||
peerDependencies:
|
||||
@@ -28563,15 +28556,6 @@ snapshots:
|
||||
|
||||
array-flatten@1.1.1: {}
|
||||
|
||||
array-includes@3.1.8:
|
||||
dependencies:
|
||||
call-bind: 1.0.8
|
||||
define-properties: 1.2.1
|
||||
es-abstract: 1.24.0
|
||||
es-object-atoms: 1.1.1
|
||||
get-intrinsic: 1.3.0
|
||||
is-string: 1.1.1
|
||||
|
||||
array-includes@3.1.9:
|
||||
dependencies:
|
||||
call-bind: 1.0.8
|
||||
@@ -28594,7 +28578,7 @@ snapshots:
|
||||
es-abstract: 1.24.0
|
||||
es-errors: 1.3.0
|
||||
es-object-atoms: 1.1.1
|
||||
es-shim-unscopables: 1.0.2
|
||||
es-shim-unscopables: 1.1.0
|
||||
|
||||
array.prototype.findlastindex@1.2.6:
|
||||
dependencies:
|
||||
@@ -28606,26 +28590,19 @@ snapshots:
|
||||
es-object-atoms: 1.1.1
|
||||
es-shim-unscopables: 1.1.0
|
||||
|
||||
array.prototype.flat@1.3.2:
|
||||
dependencies:
|
||||
call-bind: 1.0.8
|
||||
define-properties: 1.2.1
|
||||
es-abstract: 1.24.0
|
||||
es-shim-unscopables: 1.0.2
|
||||
|
||||
array.prototype.flat@1.3.3:
|
||||
dependencies:
|
||||
call-bind: 1.0.8
|
||||
define-properties: 1.2.1
|
||||
es-abstract: 1.24.0
|
||||
es-shim-unscopables: 1.0.2
|
||||
es-shim-unscopables: 1.1.0
|
||||
|
||||
array.prototype.flatmap@1.3.3:
|
||||
dependencies:
|
||||
call-bind: 1.0.8
|
||||
define-properties: 1.2.1
|
||||
es-abstract: 1.24.0
|
||||
es-shim-unscopables: 1.0.2
|
||||
es-shim-unscopables: 1.1.0
|
||||
|
||||
array.prototype.tosorted@1.1.4:
|
||||
dependencies:
|
||||
@@ -28633,7 +28610,7 @@ snapshots:
|
||||
define-properties: 1.2.1
|
||||
es-abstract: 1.24.0
|
||||
es-errors: 1.3.0
|
||||
es-shim-unscopables: 1.0.2
|
||||
es-shim-unscopables: 1.1.0
|
||||
|
||||
arraybuffer.prototype.slice@1.0.4:
|
||||
dependencies:
|
||||
@@ -28840,8 +28817,6 @@ snapshots:
|
||||
|
||||
aws4fetch@1.0.20: {}
|
||||
|
||||
axe-core@4.10.3: {}
|
||||
|
||||
axe-core@4.12.1: {}
|
||||
|
||||
axios@1.20.0(debug@4.4.3(supports-color@8.1.1))(supports-color@8.1.1):
|
||||
@@ -30296,10 +30271,6 @@ snapshots:
|
||||
has-tostringtag: 1.0.2
|
||||
hasown: 2.0.4
|
||||
|
||||
es-shim-unscopables@1.0.2:
|
||||
dependencies:
|
||||
hasown: 2.0.4
|
||||
|
||||
es-shim-unscopables@1.1.0:
|
||||
dependencies:
|
||||
hasown: 2.0.4
|
||||
@@ -30601,15 +30572,15 @@ snapshots:
|
||||
eslint-plugin-jsx-a11y@6.10.2(eslint@9.37.0(jiti@2.7.0)(supports-color@8.1.1)):
|
||||
dependencies:
|
||||
aria-query: 5.3.2
|
||||
array-includes: 3.1.8
|
||||
array-includes: 3.1.9
|
||||
array.prototype.flatmap: 1.3.3
|
||||
ast-types-flow: 0.0.8
|
||||
axe-core: 4.10.3
|
||||
axe-core: 4.12.1
|
||||
axobject-query: 4.1.0
|
||||
damerau-levenshtein: 1.0.8
|
||||
emoji-regex: 9.2.2
|
||||
eslint: 9.37.0(jiti@2.7.0)(supports-color@8.1.1)
|
||||
hasown: 2.0.2
|
||||
hasown: 2.0.4
|
||||
jsx-ast-utils: 3.3.5
|
||||
language-tags: 1.0.9
|
||||
minimatch: 3.1.4
|
||||
@@ -30632,7 +30603,7 @@ snapshots:
|
||||
eslint-plugin-react-hooks@7.1.1(eslint@9.37.0(jiti@2.7.0)(supports-color@8.1.1))(supports-color@8.1.1):
|
||||
dependencies:
|
||||
'@babel/core': 7.29.7(supports-color@8.1.1)
|
||||
'@babel/parser': 7.29.8
|
||||
'@babel/parser': 7.29.12
|
||||
eslint: 9.37.0(jiti@2.7.0)(supports-color@8.1.1)
|
||||
hermes-parser: 0.25.1
|
||||
zod: 4.6.7
|
||||
@@ -30642,7 +30613,7 @@ snapshots:
|
||||
|
||||
eslint-plugin-react@7.37.5(eslint@9.37.0(jiti@2.7.0)(supports-color@8.1.1)):
|
||||
dependencies:
|
||||
array-includes: 3.1.8
|
||||
array-includes: 3.1.9
|
||||
array.prototype.findlast: 1.2.5
|
||||
array.prototype.flatmap: 1.3.3
|
||||
array.prototype.tosorted: 1.1.4
|
||||
@@ -31654,10 +31625,6 @@ snapshots:
|
||||
|
||||
has-unicode@2.0.1: {}
|
||||
|
||||
hasown@2.0.2:
|
||||
dependencies:
|
||||
function-bind: 1.1.2
|
||||
|
||||
hasown@2.0.4:
|
||||
dependencies:
|
||||
function-bind: 1.1.2
|
||||
@@ -32537,8 +32504,8 @@ snapshots:
|
||||
|
||||
jsx-ast-utils@3.3.5:
|
||||
dependencies:
|
||||
array-includes: 3.1.8
|
||||
array.prototype.flat: 1.3.2
|
||||
array-includes: 3.1.9
|
||||
array.prototype.flat: 1.3.3
|
||||
object.assign: 4.1.7
|
||||
object.values: 1.2.1
|
||||
|
||||
@@ -34253,11 +34220,6 @@ snapshots:
|
||||
dependencies:
|
||||
js-yaml-loader: 1.2.2
|
||||
|
||||
next-router-mock@0.9.13(next@16.4.6(@babel/core@7.29.7(supports-color@8.1.1))(@opentelemetry/api@1.9.1)(@playwright/test@1.65.1)(@types/node@26.6.6)(babel-plugin-macros@3.1.0)(react-dom@19.2.6(react@19.2.6))(react@19.2.6)(sass@1.77.4))(react@19.2.6):
|
||||
dependencies:
|
||||
next: 16.4.6(@babel/core@7.29.7(supports-color@8.1.1))(@opentelemetry/api@1.9.1)(@playwright/test@1.65.1)(@types/node@26.6.6)(babel-plugin-macros@3.1.0)(react-dom@19.2.6(react@19.2.6))(react@19.2.6)(sass@1.77.4)
|
||||
react: 19.2.6
|
||||
|
||||
next-seo@6.5.0(next@16.4.6(@babel/core@7.29.7(supports-color@8.1.1))(@opentelemetry/api@1.9.1)(@playwright/test@1.65.1)(@types/node@26.6.6)(babel-plugin-macros@3.1.0)(react-dom@19.2.6(react@19.2.6))(react@19.2.6)(sass@1.77.4))(react-dom@19.2.6(react@19.2.6))(react@19.2.6):
|
||||
dependencies:
|
||||
next: 16.4.6(@babel/core@7.29.7(supports-color@8.1.1))(@opentelemetry/api@1.9.1)(@playwright/test@1.65.1)(@types/node@26.6.6)(babel-plugin-macros@3.1.0)(react-dom@19.2.6(react@19.2.6))(react@19.2.6)(sass@1.77.4)
|
||||
@@ -37187,7 +37149,7 @@ snapshots:
|
||||
internal-slot: 1.1.0
|
||||
regexp.prototype.flags: 1.5.4
|
||||
set-function-name: 2.0.2
|
||||
side-channel: 1.1.0
|
||||
side-channel: 1.1.1
|
||||
|
||||
string.prototype.padend@3.1.5:
|
||||
dependencies:
|
||||
|
||||
Reference in new issue
Block a user