Files
supabase/apps/studio/package.json
Drake Costa af5e591b84 Refactor NewAccessTokenButton to use shadcn components (#36972)
* chore: Refactor `NewAccessTokenButton` to use shadcn components

This brings `NewAccessTokenButton` into conformance with the latest UI patterns of using shadcn based components, zod schemas, and react-hook-form for form submission.

I based this refactor on the implementation of `CreateSecretAPIKeyDialog`, which already made use of the above.

* add success and failure toasts

* add smoke test for `NewAccessTokenButton`, fix vitest config

This adds a minimal test for `NewAccessTokenButton` but more importantly fixes a critical bug in the vitest configuration for `studio`.

Because `restoreMocks: true` was set in the config, this meant that the mock implementation for `window.matchMedia` defined in the `tests/vitestSetup.ts` file was being **reset** to an empty function before each test suite was run. While this didn't appear to be a problem before, that appears to be because none of the existing tests had `motion.div` in their component trees. Since `motion.div` calls `addListener` on a media query as part of it's lifecycle, that meant that any test which included it would fail as `addListener` would be undefined in this situation. Removing `restoreMocks: true` from the config results in the desired mocking behavior.

This change is necessary in order to test any component that has the `FormItemLayout` component, as it uses `framer-motion` to animate in error messages for input elements.

* add warning comment in case of future config regression

* update test cases, reset form on dialog close, testing setup fixes

This fixes an issue with the polyfills for the testing environment, where a call to `useMutation` would fail as a result of `TransformStream` being set to `null`.

Basic tests for access token creation and form resetting added. Adds `@faker-js/faker` to the studio app devDependencies to generate mock data for `msw` endpoint response.

Adds `shx` to the docs app devDependencies to ensure that the `codegen:examples` script runs cross-platform.

* ensure mocked date is a string

* update testing setup, pollyfills and add rich type support to addAPIMock

* Update studio testing setup files

Improves API mocking type safety and polyfills browser APIs necessary to run tests with framer-motion components

* chore: Refactor `NewAccessTokenButton` to use shadcn components

This brings `NewAccessTokenButton` into conformance with the latest UI patterns of using shadcn based components, zod schemas, and react-hook-form for form submission.

I based this refactor on the implementation of `CreateSecretAPIKeyDialog`, which already made use of the above.

* add success and failure toasts

* add smoke test for `NewAccessTokenButton`, fix vitest config

This adds a minimal test for `NewAccessTokenButton` but more importantly fixes a critical bug in the vitest configuration for `studio`.

Because `restoreMocks: true` was set in the config, this meant that the mock implementation for `window.matchMedia` defined in the `tests/vitestSetup.ts` file was being **reset** to an empty function before each test suite was run. While this didn't appear to be a problem before, that appears to be because none of the existing tests had `motion.div` in their component trees. Since `motion.div` calls `addListener` on a media query as part of it's lifecycle, that meant that any test which included it would fail as `addListener` would be undefined in this situation. Removing `restoreMocks: true` from the config results in the desired mocking behavior.

This change is necessary in order to test any component that has the `FormItemLayout` component, as it uses `framer-motion` to animate in error messages for input elements.

* update test cases, reset form on dialog close, testing setup fixes

This fixes an issue with the polyfills for the testing environment, where a call to `useMutation` would fail as a result of `TransformStream` being set to `null`.

Basic tests for access token creation and form resetting added. Adds `@faker-js/faker` to the studio app devDependencies to generate mock data for `msw` endpoint response.

Adds `shx` to the docs app devDependencies to ensure that the `codegen:examples` script runs cross-platform.

* ensure mocked date is a string

* update testing setup, pollyfills and add rich type support to addAPIMock

* fix imports

* fix missing listen call for msw, resolve test type error

* fix imports

* Update studio testing setup files

Improves API mocking type safety and polyfills browser APIs necessary to run tests with framer-motion components

* fix missing listen call for msw, resolve test type error

* fix imports

* Shift test file

* Smol fix

* Nit

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2025-07-23 16:54:31 +08:00

208 lines
7.2 KiB
JSON

{
"name": "studio",
"version": "0.0.9",
"private": true,
"scripts": {
"preinstall": "npx only-allow pnpm",
"dev": "next dev --turbopack -p 8082",
"dev:secrets:pull": "AWS_PROFILE=supabase-dev node ../../scripts/getSecrets.js -n local/studio",
"build": "next build && ./../../scripts/upload-static-assets.sh",
"start": "next start",
"lint": "next lint",
"clean": "rimraf node_modules tsconfig.tsbuildinfo .next .turbo",
"test": "vitest --run --coverage",
"test:watch": "vitest watch",
"test:ui": "vitest --ui",
"test:update": "vitest --run --update",
"test:ci": "vitest --run --coverage",
"test:report": "open coverage/lcov-report/index.html",
"deploy:staging": "VERCEL_ORG_ID=team_E6KJ1W561hMTjon1QSwOh0WO VERCEL_PROJECT_ID=QmcmhbiAtCMFTAHCuGgQscNbke4TzgWULECctNcKmxWCoT vercel --prod -A .vercel/staging.json",
"typecheck": "tsc --noEmit",
"prettier:check": "prettier --cache --check .",
"prettier:write": "prettier --cache --write .",
"build:deno-types": "tsx scripts/deno-types.ts",
"build:graphql-types": "tsx scripts/download-graphql-schema.mts && pnpm graphql-codegen --config scripts/codegen.ts",
"build:graphql-types:watch": "pnpm graphql-codegen --config scripts/codegen.ts --watch"
},
"dependencies": {
"@ai-sdk/amazon-bedrock": "^2.2.10",
"@ai-sdk/openai": "^1.3.22",
"@ai-sdk/react": "^1.2.12",
"@aws-sdk/credential-providers": "^3.804.0",
"@dagrejs/dagre": "^1.0.4",
"@deno/eszip": "0.83.0",
"@dnd-kit/core": "^6.1.0",
"@dnd-kit/modifiers": "^9.0.0",
"@dnd-kit/sortable": "^8.0.0",
"@dnd-kit/utilities": "^3.2.2",
"@electric-sql/pglite": "^0.2.15",
"@graphiql/react": "^0.19.4",
"@graphiql/toolkit": "^0.9.1",
"@gregnr/postgres-meta": "^0.82.0-dev.2",
"@hcaptcha/react-hcaptcha": "^1.12.0",
"@headlessui/react": "^1.7.17",
"@heroicons/react": "^2.1.3",
"@hookform/resolvers": "^3.1.1",
"@monaco-editor/react": "^4.6.0",
"@next/bundle-analyzer": "15.3.1",
"@number-flow/react": "^0.3.2",
"@radix-ui/react-slider": "^1.1.2",
"@radix-ui/react-slot": "^1.2.0",
"@radix-ui/react-visually-hidden": "^1.1.3",
"@sentry/nextjs": "^8.52.1",
"@std/path": "npm:@jsr/std__path@^1.0.8",
"@stripe/react-stripe-js": "^3.1.1",
"@stripe/stripe-js": "^5.5.0",
"@supabase/auth-js": "catalog:",
"@supabase/mcp-server-supabase": "^0.4.4",
"@supabase/mcp-utils": "^0.2.0",
"@supabase/pg-meta": "workspace:*",
"@supabase/realtime-js": "catalog:",
"@supabase/shared-types": "0.1.80",
"@supabase/sql-to-rest": "^0.1.6",
"@supabase/supabase-js": "catalog:",
"@tanstack/react-query": "4.35.7",
"@tanstack/react-query-devtools": "4.35.7",
"@tanstack/react-table": "^8.21.3",
"@uidotdev/usehooks": "^2.4.1",
"@vercel/flags": "^2.6.0",
"@vercel/functions": "^2.1.0",
"@vitejs/plugin-react": "^4.3.4",
"@zip.js/zip.js": "^2.7.29",
"ai": "^4.3.16",
"ai-commands": "workspace:*",
"awesome-debounce-promise": "^2.1.0",
"common": "workspace:*",
"common-tags": "^1.8.2",
"config": "workspace:*",
"configcat-js": "^9.5.1",
"cron-parser": "^4.9.0",
"cronstrue": "^2.50.0",
"dayjs": "^1.11.10",
"dnd-core": "^16.0.1",
"file-saver": "^2.0.5",
"framer-motion": "^11.11.17",
"generate-password-browser": "^1.1.0",
"html-to-image": "^1.10.8",
"http-status": "^2.1.0",
"icons": "workspace:*",
"idb": "^8.0.2",
"immutability-helper": "^3.1.1",
"ip-num": "^1.5.1",
"json-logic-js": "^2.0.2",
"lodash": "^4.17.21",
"lucide-react": "^0.436.0",
"markdown-table": "^3.0.3",
"memoize-one": "^5.0.1",
"mime-db": "^1.53.0",
"monaco-editor": "0.52.2",
"next": "catalog:",
"next-themes": "^0.3.0",
"nuqs": "^2.4.1",
"openai": "^4.20.1",
"openapi-fetch": "0.12.4",
"papaparse": "^5.3.1",
"path-to-regexp": "^8.0.0",
"pg-minify": "^1.6.3",
"randombytes": "^2.1.0",
"react": "catalog:",
"react-beautiful-dnd": "^13.1.0",
"react-contexify": "^5.0.0",
"react-copy-to-clipboard": "^5.1.0",
"react-data-grid": "7.0.0-beta.41",
"react-datepicker": "^4.18.0",
"react-day-picker": "^8.8.0",
"react-dnd": "^16.0.1",
"react-dnd-html5-backend": "^16.0.1",
"react-dom": "catalog:",
"react-error-boundary": "^4.0.13",
"react-grid-layout": "^1.4.2",
"react-hook-form": "^7.45.0",
"react-inlinesvg": "^4.0.4",
"react-intersection-observer": "^9.5.3",
"react-markdown": "^8.0.3",
"react-resizable": "3.0.5",
"react-simple-maps": "4.0.0-beta.6",
"react-use": "^17.5.0",
"react-virtualized-auto-sizer": "^1.0.20",
"react-window": "^1.8.6",
"react-window-infinite-loader": "^1.0.7",
"reactflow": "^11.10.1",
"recharts": "^2.8.0",
"remark-gfm": "^3.0.1",
"shared-data": "workspace:*",
"sonner": "^1.5.0",
"sql-formatter": "^15.0.0",
"sqlstring": "^2.3.2",
"tus-js-client": "^4.1.0",
"ui": "workspace:*",
"ui-patterns": "workspace:*",
"use-debounce": "^7.0.1",
"uuid": "^9.0.1",
"valtio": "catalog:",
"yup": "^1.4.0",
"yup-password": "^0.3.0",
"zod": "^3.22.4",
"zxcvbn": "^4.4.2"
},
"devDependencies": {
"@faker-js/faker": "^9.9.0",
"@graphql-codegen/cli": "5.0.5",
"@graphql-typed-document-node/core": "^3.2.0",
"@radix-ui/react-use-escape-keydown": "^1.0.3",
"@smithy/property-provider": "^4.0.4",
"@supabase/postgres-meta": "^0.64.4",
"@tailwindcss/container-queries": "^0.1.1",
"@testing-library/dom": "^10.0.0",
"@testing-library/jest-dom": "^6.6.0",
"@testing-library/react": "^16.0.0",
"@testing-library/user-event": "^14.0.0",
"@types/common-tags": "^1.8.1",
"@types/file-saver": "^2.0.2",
"@types/json-logic-js": "^1.2.1",
"@types/lodash": "^4.14.172",
"@types/markdown-table": "^3.0.0",
"@types/mime-db": "^1.43.5",
"@types/node": "catalog:",
"@types/papaparse": "^5.3.1",
"@types/randombytes": "^2.0.3",
"@types/react": "catalog:",
"@types/react-beautiful-dnd": "^13.1.2",
"@types/react-copy-to-clipboard": "^5.0.4",
"@types/react-datepicker": "^4.3.4",
"@types/react-dom": "catalog:",
"@types/react-grid-layout": "^1.3.0",
"@types/react-simple-maps": "^3.0.1",
"@types/react-virtualized-auto-sizer": "^1.0.1",
"@types/react-window": "^1.8.5",
"@types/react-window-infinite-loader": "^1.0.5",
"@types/recharts": "^1.8.23",
"@types/sqlstring": "^2.3.0",
"@types/uuid": "^8.3.4",
"@types/zxcvbn": "^4.4.1",
"@vitest/coverage-v8": "^3.0.9",
"@vitest/ui": "^3.0.0",
"api-types": "workspace:*",
"common": "workspace:*",
"config": "workspace:*",
"date-fns": "^2.30.0",
"eslint-config-supabase": "workspace:*",
"eslint-plugin-barrel-files": "^2.0.7",
"graphql-ws": "5.14.1",
"import-in-the-middle": "^1.13.1",
"jsdom-testing-mocks": "^1.13.1",
"msw": "^2.3.0",
"next-router-mock": "^0.9.13",
"postcss": "^8.5.3",
"prettier": "3.2.4",
"raw-loader": "^4.0.2",
"require-in-the-middle": "^7.5.2",
"tailwindcss": "^3.4.1",
"tsx": "^4.19.3",
"typescript": "~5.5.0",
"vite": "catalog:",
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^3.0.5"
}
}