mirror of
https://github.com/soconnor0919/hristudio.git
synced 2026-03-23 19:27:51 -04:00
migrate: replace NextAuth.js with Better Auth
- Install better-auth and @better-auth/drizzle-adapter - Create src/lib/auth.ts with Better Auth configuration using bcrypt - Update database schema: change auth table IDs from uuid to text - Update route handler from /api/auth/[...nextauth] to /api/auth/[...all] - Update tRPC context and middleware for Better Auth session handling - Update client components to use Better Auth APIs (signIn, signOut) - Update seed script with text-based IDs and correct account schema - Fix type errors in wizard components (robotId, optional chaining) - Fix API paths: api.robots.initialize -> api.robots.plugins.initialize - Update auth router to use text IDs for Better Auth compatibility Note: Auth tables were reset - users will need to re-register.
This commit is contained in:
67
bun.lock
67
bun.lock
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
|
"configVersion": 0,
|
||||||
"workspaces": {
|
"workspaces": {
|
||||||
"": {
|
"": {
|
||||||
"name": "hristudio",
|
"name": "hristudio",
|
||||||
@@ -7,6 +8,7 @@
|
|||||||
"@auth/drizzle-adapter": "^1.11.1",
|
"@auth/drizzle-adapter": "^1.11.1",
|
||||||
"@aws-sdk/client-s3": "^3.989.0",
|
"@aws-sdk/client-s3": "^3.989.0",
|
||||||
"@aws-sdk/s3-request-presigner": "^3.989.0",
|
"@aws-sdk/s3-request-presigner": "^3.989.0",
|
||||||
|
"@better-auth/drizzle-adapter": "^1.5.5",
|
||||||
"@dnd-kit/core": "^6.3.1",
|
"@dnd-kit/core": "^6.3.1",
|
||||||
"@dnd-kit/sortable": "^10.0.0",
|
"@dnd-kit/sortable": "^10.0.0",
|
||||||
"@dnd-kit/utilities": "^3.2.2",
|
"@dnd-kit/utilities": "^3.2.2",
|
||||||
@@ -48,6 +50,7 @@
|
|||||||
"@types/js-cookie": "^3.0.6",
|
"@types/js-cookie": "^3.0.6",
|
||||||
"@types/ws": "^8.18.1",
|
"@types/ws": "^8.18.1",
|
||||||
"bcryptjs": "^3.0.3",
|
"bcryptjs": "^3.0.3",
|
||||||
|
"better-auth": "^1.5.5",
|
||||||
"class-variance-authority": "^0.7.1",
|
"class-variance-authority": "^0.7.1",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"cmdk": "^1.1.1",
|
"cmdk": "^1.1.1",
|
||||||
@@ -207,6 +210,24 @@
|
|||||||
|
|
||||||
"@babel/runtime": ["@babel/runtime@7.28.6", "", {}, "sha512-05WQkdpL9COIMz4LjTxGpPNCdlpyimKppYNoJ5Di5EUObifl8t4tuLuUBBZEpoLYOmfvIWrsp9fCl0HoPRVTdA=="],
|
"@babel/runtime": ["@babel/runtime@7.28.6", "", {}, "sha512-05WQkdpL9COIMz4LjTxGpPNCdlpyimKppYNoJ5Di5EUObifl8t4tuLuUBBZEpoLYOmfvIWrsp9fCl0HoPRVTdA=="],
|
||||||
|
|
||||||
|
"@better-auth/core": ["@better-auth/core@1.5.5", "", { "dependencies": { "@standard-schema/spec": "^1.1.0", "zod": "^4.3.6" }, "peerDependencies": { "@better-auth/utils": "0.3.1", "@better-fetch/fetch": "1.1.21", "@cloudflare/workers-types": ">=4", "better-call": "1.3.2", "jose": "^6.1.0", "kysely": "^0.28.5", "nanostores": "^1.0.1" }, "optionalPeers": ["@cloudflare/workers-types"] }, "sha512-1oR/2jAp821Dcf67kQYHUoyNcdc1TcShfw4QMK0YTVntuRES5mUOyvEJql5T6eIuLfaqaN4LOF78l0FtF66HXA=="],
|
||||||
|
|
||||||
|
"@better-auth/drizzle-adapter": ["@better-auth/drizzle-adapter@1.5.5", "", { "peerDependencies": { "@better-auth/core": "1.5.5", "@better-auth/utils": "^0.3.0", "drizzle-orm": ">=0.41.0" }, "optionalPeers": ["drizzle-orm"] }, "sha512-HAi9xAP40oDt48QZeYBFTcmg3vt1Jik90GwoRIfangd7VGbxesIIDBJSnvwMbZ52GBIc6+V4FRw9lasNiNrPfw=="],
|
||||||
|
|
||||||
|
"@better-auth/kysely-adapter": ["@better-auth/kysely-adapter@1.5.5", "", { "peerDependencies": { "@better-auth/core": "1.5.5", "@better-auth/utils": "^0.3.0", "kysely": "^0.27.0 || ^0.28.0" } }, "sha512-LmHffIVnqbfsxcxckMOoE8MwibWrbVFch+kwPKJ5OFDFv6lin75ufN7ZZ7twH0IMPLT/FcgzaRjP8jRrXRef9g=="],
|
||||||
|
|
||||||
|
"@better-auth/memory-adapter": ["@better-auth/memory-adapter@1.5.5", "", { "peerDependencies": { "@better-auth/core": "1.5.5", "@better-auth/utils": "^0.3.0" } }, "sha512-4X0j1/2L+nsgmObjmy9xEGUFWUv38Qjthp558fwS3DAp6ueWWyCaxaD6VJZ7m5qPNMrsBStO5WGP8CmJTEWm7g=="],
|
||||||
|
|
||||||
|
"@better-auth/mongo-adapter": ["@better-auth/mongo-adapter@1.5.5", "", { "peerDependencies": { "@better-auth/core": "1.5.5", "@better-auth/utils": "^0.3.0", "mongodb": "^6.0.0 || ^7.0.0" } }, "sha512-P1J9ljL5X5k740I8Rx1esPWNgWYPdJR5hf2CY7BwDSrQFPUHuzeCg0YhtEEP55niNateTXhBqGAcy0fVOeamZg=="],
|
||||||
|
|
||||||
|
"@better-auth/prisma-adapter": ["@better-auth/prisma-adapter@1.5.5", "", { "peerDependencies": { "@better-auth/core": "1.5.5", "@better-auth/utils": "^0.3.0", "@prisma/client": "^5.0.0 || ^6.0.0 || ^7.0.0", "prisma": "^5.0.0 || ^6.0.0 || ^7.0.0" }, "optionalPeers": ["@prisma/client", "prisma"] }, "sha512-CliDd78CXHzzwQIXhCdwGr5Ml53i6JdCHWV7PYwTIJz9EAm6qb2RVBdpP3nqEfNjINGM22A6gfleCgCdZkTIZg=="],
|
||||||
|
|
||||||
|
"@better-auth/telemetry": ["@better-auth/telemetry@1.5.5", "", { "dependencies": { "@better-auth/utils": "0.3.1", "@better-fetch/fetch": "1.1.21" }, "peerDependencies": { "@better-auth/core": "1.5.5" } }, "sha512-1+lklxArn4IMHuU503RcPdXrSG2tlXt4jnGG3omolmspQ7tktg/Y9XO/yAkYDurtvMn1xJ8X1Ov01Ji/r5s9BQ=="],
|
||||||
|
|
||||||
|
"@better-auth/utils": ["@better-auth/utils@0.3.1", "", {}, "sha512-+CGp4UmZSUrHHnpHhLPYu6cV+wSUSvVbZbNykxhUDocpVNTo9uFFxw/NqJlh1iC4wQ9HKKWGCKuZ5wUgS0v6Kg=="],
|
||||||
|
|
||||||
|
"@better-fetch/fetch": ["@better-fetch/fetch@1.1.21", "", {}, "sha512-/ImESw0sskqlVR94jB+5+Pxjf+xBwDZF/N5+y2/q4EqD7IARUTSpPfIo8uf39SYpCxyOCtbyYpUrZ3F/k0zT4A=="],
|
||||||
|
|
||||||
"@date-fns/tz": ["@date-fns/tz@1.4.1", "", {}, "sha512-P5LUNhtbj6YfI3iJjw5EL9eUAG6OitD0W3fWQcpQjDRc/QIsL0tRNuO1PcDvPccWL1fSTXXdE1ds+l95DV/OFA=="],
|
"@date-fns/tz": ["@date-fns/tz@1.4.1", "", {}, "sha512-P5LUNhtbj6YfI3iJjw5EL9eUAG6OitD0W3fWQcpQjDRc/QIsL0tRNuO1PcDvPccWL1fSTXXdE1ds+l95DV/OFA=="],
|
||||||
|
|
||||||
"@dnd-kit/accessibility": ["@dnd-kit/accessibility@3.1.1", "", { "dependencies": { "tslib": "^2.0.0" }, "peerDependencies": { "react": ">=16.8.0" } }, "sha512-2P+YgaXF+gRsIihwwY1gCsQSYnu9Zyj2py8kY5fFvUM1qm2WA2u639R6YNVfU4GWr+ZM5mqEsfHZZLoRONbemw=="],
|
"@dnd-kit/accessibility": ["@dnd-kit/accessibility@3.1.1", "", { "dependencies": { "tslib": "^2.0.0" }, "peerDependencies": { "react": ">=16.8.0" } }, "sha512-2P+YgaXF+gRsIihwwY1gCsQSYnu9Zyj2py8kY5fFvUM1qm2WA2u639R6YNVfU4GWr+ZM5mqEsfHZZLoRONbemw=="],
|
||||||
@@ -377,6 +398,8 @@
|
|||||||
|
|
||||||
"@jridgewell/trace-mapping": ["@jridgewell/trace-mapping@0.3.29", "", { "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", "@jridgewell/sourcemap-codec": "^1.4.14" } }, "sha512-uw6guiW/gcAGPDhLmd77/6lW8QLeiV5RUTsAX46Db6oLhGaVj4lhnPwb184s1bkc8kdVg/+h988dro8GRDpmYQ=="],
|
"@jridgewell/trace-mapping": ["@jridgewell/trace-mapping@0.3.29", "", { "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", "@jridgewell/sourcemap-codec": "^1.4.14" } }, "sha512-uw6guiW/gcAGPDhLmd77/6lW8QLeiV5RUTsAX46Db6oLhGaVj4lhnPwb184s1bkc8kdVg/+h988dro8GRDpmYQ=="],
|
||||||
|
|
||||||
|
"@mongodb-js/saslprep": ["@mongodb-js/saslprep@1.4.6", "", { "dependencies": { "sparse-bitfield": "^3.0.3" } }, "sha512-y+x3H1xBZd38n10NZF/rEBlvDOOMQ6LKUTHqr8R9VkJ+mmQOYtJFxIlkkK8fZrtOiL6VixbOBWMbZGBdal3Z1g=="],
|
||||||
|
|
||||||
"@napi-rs/wasm-runtime": ["@napi-rs/wasm-runtime@0.2.12", "", { "dependencies": { "@emnapi/core": "^1.4.3", "@emnapi/runtime": "^1.4.3", "@tybys/wasm-util": "^0.10.0" } }, "sha512-ZVWUcfwY4E/yPitQJl481FjFo3K22D6qF0DuFH6Y/nbnE11GY5uguDxZMGXPQ8WQ0128MXQD7TnfHyK4oWoIJQ=="],
|
"@napi-rs/wasm-runtime": ["@napi-rs/wasm-runtime@0.2.12", "", { "dependencies": { "@emnapi/core": "^1.4.3", "@emnapi/runtime": "^1.4.3", "@tybys/wasm-util": "^0.10.0" } }, "sha512-ZVWUcfwY4E/yPitQJl481FjFo3K22D6qF0DuFH6Y/nbnE11GY5uguDxZMGXPQ8WQ0128MXQD7TnfHyK4oWoIJQ=="],
|
||||||
|
|
||||||
"@next/env": ["@next/env@16.1.6", "", {}, "sha512-N1ySLuZjnAtN3kFnwhAwPvZah8RJxKasD7x1f8shFqhncnWZn4JMfg37diLNuoHsLAlrDfM3g4mawVdtAG8XLQ=="],
|
"@next/env": ["@next/env@16.1.6", "", {}, "sha512-N1ySLuZjnAtN3kFnwhAwPvZah8RJxKasD7x1f8shFqhncnWZn4JMfg37diLNuoHsLAlrDfM3g4mawVdtAG8XLQ=="],
|
||||||
@@ -399,6 +422,10 @@
|
|||||||
|
|
||||||
"@next/swc-win32-x64-msvc": ["@next/swc-win32-x64-msvc@16.1.6", "", { "os": "win32", "cpu": "x64" }, "sha512-NRfO39AIrzBnixKbjuo2YiYhB6o9d8v/ymU9m/Xk8cyVk+k7XylniXkHwjs4s70wedVffc6bQNbufk5v0xEm0A=="],
|
"@next/swc-win32-x64-msvc": ["@next/swc-win32-x64-msvc@16.1.6", "", { "os": "win32", "cpu": "x64" }, "sha512-NRfO39AIrzBnixKbjuo2YiYhB6o9d8v/ymU9m/Xk8cyVk+k7XylniXkHwjs4s70wedVffc6bQNbufk5v0xEm0A=="],
|
||||||
|
|
||||||
|
"@noble/ciphers": ["@noble/ciphers@2.1.1", "", {}, "sha512-bysYuiVfhxNJuldNXlFEitTVdNnYUc+XNJZd7Qm2a5j1vZHgY+fazadNFWFaMK/2vye0JVlxV3gHmC0WDfAOQw=="],
|
||||||
|
|
||||||
|
"@noble/hashes": ["@noble/hashes@2.0.1", "", {}, "sha512-XlOlEbQcE9fmuXxrVTXCTlG2nlRXa9Rj3rr5Ue/+tX+nmkgbX720YHh0VR3hBF9xDvwnb8D2shVGOwNx+ulArw=="],
|
||||||
|
|
||||||
"@nodelib/fs.scandir": ["@nodelib/fs.scandir@2.1.5", "", { "dependencies": { "@nodelib/fs.stat": "2.0.5", "run-parallel": "^1.1.9" } }, "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g=="],
|
"@nodelib/fs.scandir": ["@nodelib/fs.scandir@2.1.5", "", { "dependencies": { "@nodelib/fs.stat": "2.0.5", "run-parallel": "^1.1.9" } }, "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g=="],
|
||||||
|
|
||||||
"@nodelib/fs.stat": ["@nodelib/fs.stat@2.0.5", "", {}, "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A=="],
|
"@nodelib/fs.stat": ["@nodelib/fs.stat@2.0.5", "", {}, "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A=="],
|
||||||
@@ -855,6 +882,10 @@
|
|||||||
|
|
||||||
"@types/uuid": ["@types/uuid@11.0.0", "", { "dependencies": { "uuid": "*" } }, "sha512-HVyk8nj2m+jcFRNazzqyVKiZezyhDKrGUA3jlEcg/nZ6Ms+qHwocba1Y/AaVaznJTAM9xpdFSh+ptbNrhOGvZA=="],
|
"@types/uuid": ["@types/uuid@11.0.0", "", { "dependencies": { "uuid": "*" } }, "sha512-HVyk8nj2m+jcFRNazzqyVKiZezyhDKrGUA3jlEcg/nZ6Ms+qHwocba1Y/AaVaznJTAM9xpdFSh+ptbNrhOGvZA=="],
|
||||||
|
|
||||||
|
"@types/webidl-conversions": ["@types/webidl-conversions@7.0.3", "", {}, "sha512-CiJJvcRtIgzadHCYXw7dqEnMNRjhGZlYK05Mj9OyktqV8uVT8fD2BFOB7S1uwBE3Kj2Z+4UyPmFw/Ixgw/LAlA=="],
|
||||||
|
|
||||||
|
"@types/whatwg-url": ["@types/whatwg-url@13.0.0", "", { "dependencies": { "@types/webidl-conversions": "*" } }, "sha512-N8WXpbE6Wgri7KUSvrmQcqrMllKZ9uxkYWMt+mCSGwNc0Hsw9VQTW7ApqI4XNrx6/SaM2QQJCzMPDEXE058s+Q=="],
|
||||||
|
|
||||||
"@types/ws": ["@types/ws@8.18.1", "", { "dependencies": { "@types/node": "*" } }, "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg=="],
|
"@types/ws": ["@types/ws@8.18.1", "", { "dependencies": { "@types/node": "*" } }, "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg=="],
|
||||||
|
|
||||||
"@typescript-eslint/eslint-plugin": ["@typescript-eslint/eslint-plugin@8.55.0", "", { "dependencies": { "@eslint-community/regexpp": "^4.12.2", "@typescript-eslint/scope-manager": "8.55.0", "@typescript-eslint/type-utils": "8.55.0", "@typescript-eslint/utils": "8.55.0", "@typescript-eslint/visitor-keys": "8.55.0", "ignore": "^7.0.5", "natural-compare": "^1.4.0", "ts-api-utils": "^2.4.0" }, "peerDependencies": { "@typescript-eslint/parser": "^8.55.0", "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <6.0.0" } }, "sha512-1y/MVSz0NglV1ijHC8OT49mPJ4qhPYjiK08YUQVbIOyu+5k862LKUHFkpKHWu//zmr7hDR2rhwUm6gnCGNmGBQ=="],
|
"@typescript-eslint/eslint-plugin": ["@typescript-eslint/eslint-plugin@8.55.0", "", { "dependencies": { "@eslint-community/regexpp": "^4.12.2", "@typescript-eslint/scope-manager": "8.55.0", "@typescript-eslint/type-utils": "8.55.0", "@typescript-eslint/utils": "8.55.0", "@typescript-eslint/visitor-keys": "8.55.0", "ignore": "^7.0.5", "natural-compare": "^1.4.0", "ts-api-utils": "^2.4.0" }, "peerDependencies": { "@typescript-eslint/parser": "^8.55.0", "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <6.0.0" } }, "sha512-1y/MVSz0NglV1ijHC8OT49mPJ4qhPYjiK08YUQVbIOyu+5k862LKUHFkpKHWu//zmr7hDR2rhwUm6gnCGNmGBQ=="],
|
||||||
@@ -987,6 +1018,10 @@
|
|||||||
|
|
||||||
"bcryptjs": ["bcryptjs@3.0.3", "", { "bin": { "bcrypt": "bin/bcrypt" } }, "sha512-GlF5wPWnSa/X5LKM1o0wz0suXIINz1iHRLvTS+sLyi7XPbe5ycmYI3DlZqVGZZtDgl4DmasFg7gOB3JYbphV5g=="],
|
"bcryptjs": ["bcryptjs@3.0.3", "", { "bin": { "bcrypt": "bin/bcrypt" } }, "sha512-GlF5wPWnSa/X5LKM1o0wz0suXIINz1iHRLvTS+sLyi7XPbe5ycmYI3DlZqVGZZtDgl4DmasFg7gOB3JYbphV5g=="],
|
||||||
|
|
||||||
|
"better-auth": ["better-auth@1.5.5", "", { "dependencies": { "@better-auth/core": "1.5.5", "@better-auth/drizzle-adapter": "1.5.5", "@better-auth/kysely-adapter": "1.5.5", "@better-auth/memory-adapter": "1.5.5", "@better-auth/mongo-adapter": "1.5.5", "@better-auth/prisma-adapter": "1.5.5", "@better-auth/telemetry": "1.5.5", "@better-auth/utils": "0.3.1", "@better-fetch/fetch": "1.1.21", "@noble/ciphers": "^2.1.1", "@noble/hashes": "^2.0.1", "better-call": "1.3.2", "defu": "^6.1.4", "jose": "^6.1.3", "kysely": "^0.28.11", "nanostores": "^1.1.1", "zod": "^4.3.6" }, "peerDependencies": { "@lynx-js/react": "*", "@prisma/client": "^5.0.0 || ^6.0.0 || ^7.0.0", "@sveltejs/kit": "^2.0.0", "@tanstack/react-start": "^1.0.0", "@tanstack/solid-start": "^1.0.0", "better-sqlite3": "^12.0.0", "drizzle-kit": ">=0.31.4", "drizzle-orm": ">=0.41.0", "mongodb": "^6.0.0 || ^7.0.0", "mysql2": "^3.0.0", "next": "^14.0.0 || ^15.0.0 || ^16.0.0", "pg": "^8.0.0", "prisma": "^5.0.0 || ^6.0.0 || ^7.0.0", "react": "^18.0.0 || ^19.0.0", "react-dom": "^18.0.0 || ^19.0.0", "solid-js": "^1.0.0", "svelte": "^4.0.0 || ^5.0.0", "vitest": "^2.0.0 || ^3.0.0 || ^4.0.0", "vue": "^3.0.0" }, "optionalPeers": ["@lynx-js/react", "@prisma/client", "@sveltejs/kit", "@tanstack/react-start", "@tanstack/solid-start", "better-sqlite3", "drizzle-kit", "drizzle-orm", "mongodb", "mysql2", "next", "pg", "prisma", "react", "react-dom", "solid-js", "svelte", "vitest", "vue"] }, "sha512-GpVPaV1eqr3mOovKfghJXXk6QvlcVeFbS3z+n+FPDid5rK/2PchnDtiaVCzWyXA9jH2KkirOfl+JhAUvnja0Eg=="],
|
||||||
|
|
||||||
|
"better-call": ["better-call@1.3.2", "", { "dependencies": { "@better-auth/utils": "^0.3.1", "@better-fetch/fetch": "^1.1.21", "rou3": "^0.7.12", "set-cookie-parser": "^3.0.1" }, "peerDependencies": { "zod": "^4.0.0" }, "optionalPeers": ["zod"] }, "sha512-4cZIfrerDsNTn3cm+MhLbUePN0gdwkhSXEuG7r/zuQ8c/H7iU0/jSK5TD3FW7U0MgKHce/8jGpPYNO4Ve+4NBw=="],
|
||||||
|
|
||||||
"bl": ["bl@5.1.0", "", { "dependencies": { "buffer": "^6.0.3", "inherits": "^2.0.4", "readable-stream": "^3.4.0" } }, "sha512-tv1ZJHLfTDnXE6tMHv73YgSJaWR2AFuPwMntBe7XL/GBFHnT0CLnsHMogfk5+GzCDC5ZWarSCYaIGATZt9dNsQ=="],
|
"bl": ["bl@5.1.0", "", { "dependencies": { "buffer": "^6.0.3", "inherits": "^2.0.4", "readable-stream": "^3.4.0" } }, "sha512-tv1ZJHLfTDnXE6tMHv73YgSJaWR2AFuPwMntBe7XL/GBFHnT0CLnsHMogfk5+GzCDC5ZWarSCYaIGATZt9dNsQ=="],
|
||||||
|
|
||||||
"block-stream2": ["block-stream2@2.1.0", "", { "dependencies": { "readable-stream": "^3.4.0" } }, "sha512-suhjmLI57Ewpmq00qaygS8UgEq2ly2PCItenIyhMqVjo4t4pGzqMvfgJuX8iWTeSDdfSSqS6j38fL4ToNL7Pfg=="],
|
"block-stream2": ["block-stream2@2.1.0", "", { "dependencies": { "readable-stream": "^3.4.0" } }, "sha512-suhjmLI57Ewpmq00qaygS8UgEq2ly2PCItenIyhMqVjo4t4pGzqMvfgJuX8iWTeSDdfSSqS6j38fL4ToNL7Pfg=="],
|
||||||
@@ -999,6 +1034,8 @@
|
|||||||
|
|
||||||
"browser-or-node": ["browser-or-node@2.1.1", "", {}, "sha512-8CVjaLJGuSKMVTxJ2DpBl5XnlNDiT4cQFeuCJJrvJmts9YrTZDizTX7PjC2s6W4x+MBGZeEY6dGMrF04/6Hgqg=="],
|
"browser-or-node": ["browser-or-node@2.1.1", "", {}, "sha512-8CVjaLJGuSKMVTxJ2DpBl5XnlNDiT4cQFeuCJJrvJmts9YrTZDizTX7PjC2s6W4x+MBGZeEY6dGMrF04/6Hgqg=="],
|
||||||
|
|
||||||
|
"bson": ["bson@7.2.0", "", {}, "sha512-YCEo7KjMlbNlyHhz7zAZNDpIpQbd+wOEHJYezv0nMYTn4x31eIUM2yomNNubclAt63dObUzKHWsBLJ9QcZNSnQ=="],
|
||||||
|
|
||||||
"buffer": ["buffer@6.0.3", "", { "dependencies": { "base64-js": "^1.3.1", "ieee754": "^1.2.1" } }, "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA=="],
|
"buffer": ["buffer@6.0.3", "", { "dependencies": { "base64-js": "^1.3.1", "ieee754": "^1.2.1" } }, "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA=="],
|
||||||
|
|
||||||
"buffer-crc32": ["buffer-crc32@1.0.0", "", {}, "sha512-Db1SbgBS/fg/392AblrMJk97KggmvYhr4pB5ZIMTWtaivCPMWLkmb7m21cJvpvgK+J3nsU2CmmixNBZx4vFj/w=="],
|
"buffer-crc32": ["buffer-crc32@1.0.0", "", {}, "sha512-Db1SbgBS/fg/392AblrMJk97KggmvYhr4pB5ZIMTWtaivCPMWLkmb7m21cJvpvgK+J3nsU2CmmixNBZx4vFj/w=="],
|
||||||
@@ -1085,6 +1122,8 @@
|
|||||||
|
|
||||||
"define-properties": ["define-properties@1.2.1", "", { "dependencies": { "define-data-property": "^1.0.1", "has-property-descriptors": "^1.0.0", "object-keys": "^1.1.1" } }, "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg=="],
|
"define-properties": ["define-properties@1.2.1", "", { "dependencies": { "define-data-property": "^1.0.1", "has-property-descriptors": "^1.0.0", "object-keys": "^1.1.1" } }, "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg=="],
|
||||||
|
|
||||||
|
"defu": ["defu@6.1.4", "", {}, "sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg=="],
|
||||||
|
|
||||||
"detect-libc": ["detect-libc@2.1.2", "", {}, "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ=="],
|
"detect-libc": ["detect-libc@2.1.2", "", {}, "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ=="],
|
||||||
|
|
||||||
"detect-node-es": ["detect-node-es@1.1.0", "", {}, "sha512-ypdmJU/TbBby2Dxibuv7ZLW3Bs1QEmM7nHjEANfohJLvE0XVujisn1qPJcZxg+qDucsr+bP6fLD1rPS3AhJ7EQ=="],
|
"detect-node-es": ["detect-node-es@1.1.0", "", {}, "sha512-ypdmJU/TbBby2Dxibuv7ZLW3Bs1QEmM7nHjEANfohJLvE0XVujisn1qPJcZxg+qDucsr+bP6fLD1rPS3AhJ7EQ=="],
|
||||||
@@ -1353,7 +1392,7 @@
|
|||||||
|
|
||||||
"jiti": ["jiti@2.6.1", "", { "bin": { "jiti": "lib/jiti-cli.mjs" } }, "sha512-ekilCSN1jwRvIbgeg/57YFh8qQDNbwDb9xT/qu2DAHbFFZUicIl4ygVaAvzveMhMVr3LnpSKTNnwt8PoOfmKhQ=="],
|
"jiti": ["jiti@2.6.1", "", { "bin": { "jiti": "lib/jiti-cli.mjs" } }, "sha512-ekilCSN1jwRvIbgeg/57YFh8qQDNbwDb9xT/qu2DAHbFFZUicIl4ygVaAvzveMhMVr3LnpSKTNnwt8PoOfmKhQ=="],
|
||||||
|
|
||||||
"jose": ["jose@6.0.12", "", {}, "sha512-T8xypXs8CpmiIi78k0E+Lk7T2zlK4zDyg+o1CZ4AkOHgDg98ogdP2BeZ61lTFKFyoEwJ9RgAgN+SdM3iPgNonQ=="],
|
"jose": ["jose@6.2.2", "", {}, "sha512-d7kPDd34KO/YnzaDOlikGpOurfF0ByC2sEV4cANCtdqLlTfBlw2p14O/5d/zv40gJPbIQxfES3nSx1/oYNyuZQ=="],
|
||||||
|
|
||||||
"js-cookie": ["js-cookie@3.0.5", "", {}, "sha512-cEiJEAEoIbWfCZYKWhVwFuvPX1gETRYPw6LlaTKoxD3s2AkXzkCjnp6h0V77ozyqj0jakteJ4YqDJT830+lVGw=="],
|
"js-cookie": ["js-cookie@3.0.5", "", {}, "sha512-cEiJEAEoIbWfCZYKWhVwFuvPX1gETRYPw6LlaTKoxD3s2AkXzkCjnp6h0V77ozyqj0jakteJ4YqDJT830+lVGw=="],
|
||||||
|
|
||||||
@@ -1379,6 +1418,8 @@
|
|||||||
|
|
||||||
"kleur": ["kleur@3.0.3", "", {}, "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w=="],
|
"kleur": ["kleur@3.0.3", "", {}, "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w=="],
|
||||||
|
|
||||||
|
"kysely": ["kysely@0.28.14", "", {}, "sha512-SU3lgh0rPvq7upc6vvdVrCsSMUG1h3ChvHVOY7wJ2fw4C9QEB7X3d5eyYEyULUX7UQtxZJtZXGuT6U2US72UYA=="],
|
||||||
|
|
||||||
"language-subtag-registry": ["language-subtag-registry@0.3.23", "", {}, "sha512-0K65Lea881pHotoGEa5gDlMxt3pctLi2RplBb7Ezh4rRdLEOtgi7n4EwK9lamnUCkKBqaeKRVebTq6BAxSkpXQ=="],
|
"language-subtag-registry": ["language-subtag-registry@0.3.23", "", {}, "sha512-0K65Lea881pHotoGEa5gDlMxt3pctLi2RplBb7Ezh4rRdLEOtgi7n4EwK9lamnUCkKBqaeKRVebTq6BAxSkpXQ=="],
|
||||||
|
|
||||||
"language-tags": ["language-tags@1.0.9", "", { "dependencies": { "language-subtag-registry": "^0.3.20" } }, "sha512-MbjN408fEndfiQXbFQ1vnd+1NoLDsnQW41410oQBXiyXDMYH5z505juWa4KUE1LqxRC7DgOgZDbKLxHIwm27hA=="],
|
"language-tags": ["language-tags@1.0.9", "", { "dependencies": { "language-subtag-registry": "^0.3.20" } }, "sha512-MbjN408fEndfiQXbFQ1vnd+1NoLDsnQW41410oQBXiyXDMYH5z505juWa4KUE1LqxRC7DgOgZDbKLxHIwm27hA=="],
|
||||||
@@ -1435,6 +1476,8 @@
|
|||||||
|
|
||||||
"mdurl": ["mdurl@2.0.0", "", {}, "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w=="],
|
"mdurl": ["mdurl@2.0.0", "", {}, "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w=="],
|
||||||
|
|
||||||
|
"memory-pager": ["memory-pager@1.5.0", "", {}, "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg=="],
|
||||||
|
|
||||||
"merge-stream": ["merge-stream@2.0.0", "", {}, "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w=="],
|
"merge-stream": ["merge-stream@2.0.0", "", {}, "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w=="],
|
||||||
|
|
||||||
"merge2": ["merge2@1.4.1", "", {}, "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg=="],
|
"merge2": ["merge2@1.4.1", "", {}, "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg=="],
|
||||||
@@ -1453,10 +1496,16 @@
|
|||||||
|
|
||||||
"minio": ["minio@8.0.6", "", { "dependencies": { "async": "^3.2.4", "block-stream2": "^2.1.0", "browser-or-node": "^2.1.1", "buffer-crc32": "^1.0.0", "eventemitter3": "^5.0.1", "fast-xml-parser": "^4.4.1", "ipaddr.js": "^2.0.1", "lodash": "^4.17.21", "mime-types": "^2.1.35", "query-string": "^7.1.3", "stream-json": "^1.8.0", "through2": "^4.0.2", "web-encoding": "^1.1.5", "xml2js": "^0.5.0 || ^0.6.2" } }, "sha512-sOeh2/b/XprRmEtYsnNRFtOqNRTPDvYtMWh+spWlfsuCV/+IdxNeKVUMKLqI7b5Dr07ZqCPuaRGU/rB9pZYVdQ=="],
|
"minio": ["minio@8.0.6", "", { "dependencies": { "async": "^3.2.4", "block-stream2": "^2.1.0", "browser-or-node": "^2.1.1", "buffer-crc32": "^1.0.0", "eventemitter3": "^5.0.1", "fast-xml-parser": "^4.4.1", "ipaddr.js": "^2.0.1", "lodash": "^4.17.21", "mime-types": "^2.1.35", "query-string": "^7.1.3", "stream-json": "^1.8.0", "through2": "^4.0.2", "web-encoding": "^1.1.5", "xml2js": "^0.5.0 || ^0.6.2" } }, "sha512-sOeh2/b/XprRmEtYsnNRFtOqNRTPDvYtMWh+spWlfsuCV/+IdxNeKVUMKLqI7b5Dr07ZqCPuaRGU/rB9pZYVdQ=="],
|
||||||
|
|
||||||
|
"mongodb": ["mongodb@7.1.0", "", { "dependencies": { "@mongodb-js/saslprep": "^1.3.0", "bson": "^7.1.1", "mongodb-connection-string-url": "^7.0.0" }, "peerDependencies": { "@aws-sdk/credential-providers": "^3.806.0", "@mongodb-js/zstd": "^7.0.0", "gcp-metadata": "^7.0.1", "kerberos": "^7.0.0", "mongodb-client-encryption": ">=7.0.0 <7.1.0", "snappy": "^7.3.2", "socks": "^2.8.6" }, "optionalPeers": ["@aws-sdk/credential-providers", "@mongodb-js/zstd", "gcp-metadata", "kerberos", "mongodb-client-encryption", "snappy", "socks"] }, "sha512-kMfnKunbolQYwCIyrkxNJFB4Ypy91pYqua5NargS/f8ODNSJxT03ZU3n1JqL4mCzbSih8tvmMEMLpKTT7x5gCg=="],
|
||||||
|
|
||||||
|
"mongodb-connection-string-url": ["mongodb-connection-string-url@7.0.1", "", { "dependencies": { "@types/whatwg-url": "^13.0.0", "whatwg-url": "^14.1.0" } }, "sha512-h0AZ9A7IDVwwHyMxmdMXKy+9oNlF0zFoahHiX3vQ8e3KFcSP3VmsmfvtRSuLPxmyv2vjIDxqty8smTgie/SNRQ=="],
|
||||||
|
|
||||||
"ms": ["ms@2.1.3", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="],
|
"ms": ["ms@2.1.3", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="],
|
||||||
|
|
||||||
"nanoid": ["nanoid@3.3.11", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w=="],
|
"nanoid": ["nanoid@3.3.11", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w=="],
|
||||||
|
|
||||||
|
"nanostores": ["nanostores@1.2.0", "", {}, "sha512-F0wCzbsH80G7XXo0Jd9/AVQC7ouWY6idUCTnMwW5t/Rv9W8qmO6endavDwg7TNp5GbugwSukFMVZqzPSrSMndg=="],
|
||||||
|
|
||||||
"napi-postinstall": ["napi-postinstall@0.3.2", "", { "bin": { "napi-postinstall": "lib/cli.js" } }, "sha512-tWVJxJHmBWLy69PvO96TZMZDrzmw5KeiZBz3RHmiM2XZ9grBJ2WgMAFVVg25nqp3ZjTFUs2Ftw1JhscL3Teliw=="],
|
"napi-postinstall": ["napi-postinstall@0.3.2", "", { "bin": { "napi-postinstall": "lib/cli.js" } }, "sha512-tWVJxJHmBWLy69PvO96TZMZDrzmw5KeiZBz3RHmiM2XZ9grBJ2WgMAFVVg25nqp3ZjTFUs2Ftw1JhscL3Teliw=="],
|
||||||
|
|
||||||
"natural-compare": ["natural-compare@1.4.0", "", {}, "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw=="],
|
"natural-compare": ["natural-compare@1.4.0", "", {}, "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw=="],
|
||||||
@@ -1641,6 +1690,8 @@
|
|||||||
|
|
||||||
"rope-sequence": ["rope-sequence@1.3.4", "", {}, "sha512-UT5EDe2cu2E/6O4igUr5PSFs23nvvukicWHx6GnOPlHAiiYbzNuCRQCuiUdHJQcqKalLKlrYJnjY0ySGsXNQXQ=="],
|
"rope-sequence": ["rope-sequence@1.3.4", "", {}, "sha512-UT5EDe2cu2E/6O4igUr5PSFs23nvvukicWHx6GnOPlHAiiYbzNuCRQCuiUdHJQcqKalLKlrYJnjY0ySGsXNQXQ=="],
|
||||||
|
|
||||||
|
"rou3": ["rou3@0.7.12", "", {}, "sha512-iFE4hLDuloSWcD7mjdCDhx2bKcIsYbtOTpfH5MHHLSKMOUyjqQXTeZVa289uuwEGEKFoE/BAPbhaU4B774nceg=="],
|
||||||
|
|
||||||
"run-parallel": ["run-parallel@1.2.0", "", { "dependencies": { "queue-microtask": "^1.2.2" } }, "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA=="],
|
"run-parallel": ["run-parallel@1.2.0", "", { "dependencies": { "queue-microtask": "^1.2.2" } }, "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA=="],
|
||||||
|
|
||||||
"safe-array-concat": ["safe-array-concat@1.1.3", "", { "dependencies": { "call-bind": "^1.0.8", "call-bound": "^1.0.2", "get-intrinsic": "^1.2.6", "has-symbols": "^1.1.0", "isarray": "^2.0.5" } }, "sha512-AURm5f0jYEOydBj7VQlVvDrjeFgthDdEF5H1dP+6mNpoXOMo1quQqJ4wvJDyRZ9+pO3kGWoOdmV08cSv2aJV6Q=="],
|
"safe-array-concat": ["safe-array-concat@1.1.3", "", { "dependencies": { "call-bind": "^1.0.8", "call-bound": "^1.0.2", "get-intrinsic": "^1.2.6", "has-symbols": "^1.1.0", "isarray": "^2.0.5" } }, "sha512-AURm5f0jYEOydBj7VQlVvDrjeFgthDdEF5H1dP+6mNpoXOMo1quQqJ4wvJDyRZ9+pO3kGWoOdmV08cSv2aJV6Q=="],
|
||||||
@@ -1659,6 +1710,8 @@
|
|||||||
|
|
||||||
"server-only": ["server-only@0.0.1", "", {}, "sha512-qepMx2JxAa5jjfzxG79yPPq+8BuFToHd1hm7kI+Z4zAq1ftQiP7HcxMhDDItrbtwVeLg/cY2JnKnrcFkmiswNA=="],
|
"server-only": ["server-only@0.0.1", "", {}, "sha512-qepMx2JxAa5jjfzxG79yPPq+8BuFToHd1hm7kI+Z4zAq1ftQiP7HcxMhDDItrbtwVeLg/cY2JnKnrcFkmiswNA=="],
|
||||||
|
|
||||||
|
"set-cookie-parser": ["set-cookie-parser@3.1.0", "", {}, "sha512-kjnC1DXBHcxaOaOXBHBeRtltsDG2nUiUni+jP92M9gYdW12rsmx92UsfpH7o5tDRs7I1ZZPSQJQGv3UaRfCiuw=="],
|
||||||
|
|
||||||
"set-function-length": ["set-function-length@1.2.2", "", { "dependencies": { "define-data-property": "^1.1.4", "es-errors": "^1.3.0", "function-bind": "^1.1.2", "get-intrinsic": "^1.2.4", "gopd": "^1.0.1", "has-property-descriptors": "^1.0.2" } }, "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg=="],
|
"set-function-length": ["set-function-length@1.2.2", "", { "dependencies": { "define-data-property": "^1.1.4", "es-errors": "^1.3.0", "function-bind": "^1.1.2", "get-intrinsic": "^1.2.4", "gopd": "^1.0.1", "has-property-descriptors": "^1.0.2" } }, "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg=="],
|
||||||
|
|
||||||
"set-function-name": ["set-function-name@2.0.2", "", { "dependencies": { "define-data-property": "^1.1.4", "es-errors": "^1.3.0", "functions-have-names": "^1.2.3", "has-property-descriptors": "^1.0.2" } }, "sha512-7PGFlmtwsEADb0WYyvCMa1t+yke6daIG4Wirafur5kcf+MhUnPms1UeR0CKQdTZD81yESwMHbtn+TR+dMviakQ=="],
|
"set-function-name": ["set-function-name@2.0.2", "", { "dependencies": { "define-data-property": "^1.1.4", "es-errors": "^1.3.0", "functions-have-names": "^1.2.3", "has-property-descriptors": "^1.0.2" } }, "sha512-7PGFlmtwsEADb0WYyvCMa1t+yke6daIG4Wirafur5kcf+MhUnPms1UeR0CKQdTZD81yESwMHbtn+TR+dMviakQ=="],
|
||||||
@@ -1697,6 +1750,8 @@
|
|||||||
|
|
||||||
"source-map-support": ["source-map-support@0.5.21", "", { "dependencies": { "buffer-from": "^1.0.0", "source-map": "^0.6.0" } }, "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w=="],
|
"source-map-support": ["source-map-support@0.5.21", "", { "dependencies": { "buffer-from": "^1.0.0", "source-map": "^0.6.0" } }, "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w=="],
|
||||||
|
|
||||||
|
"sparse-bitfield": ["sparse-bitfield@3.0.3", "", { "dependencies": { "memory-pager": "^1.0.2" } }, "sha512-kvzhi7vqKTfkh0PZU+2D2PIllw2ymqJKujUcyPMd9Y75Nv4nPbGJZXNhxsgdQab2BmlDct1YnfQCguEvHr7VsQ=="],
|
||||||
|
|
||||||
"split-on-first": ["split-on-first@1.1.0", "", {}, "sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw=="],
|
"split-on-first": ["split-on-first@1.1.0", "", {}, "sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw=="],
|
||||||
|
|
||||||
"stable-hash": ["stable-hash@0.0.5", "", {}, "sha512-+L3ccpzibovGXFK+Ap/f8LOS0ahMrHTf3xu7mMLSpEGU0EO9ucaysSylKo9eRDFNhWve/y275iPmIZ4z39a9iA=="],
|
"stable-hash": ["stable-hash@0.0.5", "", {}, "sha512-+L3ccpzibovGXFK+Ap/f8LOS0ahMrHTf3xu7mMLSpEGU0EO9ucaysSylKo9eRDFNhWve/y275iPmIZ4z39a9iA=="],
|
||||||
@@ -1773,6 +1828,8 @@
|
|||||||
|
|
||||||
"to-regex-range": ["to-regex-range@5.0.1", "", { "dependencies": { "is-number": "^7.0.0" } }, "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ=="],
|
"to-regex-range": ["to-regex-range@5.0.1", "", { "dependencies": { "is-number": "^7.0.0" } }, "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ=="],
|
||||||
|
|
||||||
|
"tr46": ["tr46@5.1.1", "", { "dependencies": { "punycode": "^2.3.1" } }, "sha512-hdF5ZgjTqgAntKkklYw0R03MG2x/bSzTtkxmIRw/sTNV8YXsCJ1tfLAX23lhxhHJlEf3CRCOCGGWw3vI3GaSPw=="],
|
||||||
|
|
||||||
"trim-canvas": ["trim-canvas@0.1.2", "", {}, "sha512-nd4Ga3iLFV94mdhW9JFMLpQbHUyCQuhFOD71PEAt1NjtMD5wbZctzhX8c3agHNybMR5zXD1XTGoIEWk995E6pQ=="],
|
"trim-canvas": ["trim-canvas@0.1.2", "", {}, "sha512-nd4Ga3iLFV94mdhW9JFMLpQbHUyCQuhFOD71PEAt1NjtMD5wbZctzhX8c3agHNybMR5zXD1XTGoIEWk995E6pQ=="],
|
||||||
|
|
||||||
"ts-api-utils": ["ts-api-utils@2.4.0", "", { "peerDependencies": { "typescript": ">=4.8.4" } }, "sha512-3TaVTaAv2gTiMB35i3FiGJaRfwb3Pyn/j3m/bfAvGe8FB7CF6u+LMYqYlDh7reQf7UNvoTvdfAqHGmPGOSsPmA=="],
|
"ts-api-utils": ["ts-api-utils@2.4.0", "", { "peerDependencies": { "typescript": ">=4.8.4" } }, "sha512-3TaVTaAv2gTiMB35i3FiGJaRfwb3Pyn/j3m/bfAvGe8FB7CF6u+LMYqYlDh7reQf7UNvoTvdfAqHGmPGOSsPmA=="],
|
||||||
@@ -1837,6 +1894,10 @@
|
|||||||
|
|
||||||
"web-streams-polyfill": ["web-streams-polyfill@3.3.3", "", {}, "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw=="],
|
"web-streams-polyfill": ["web-streams-polyfill@3.3.3", "", {}, "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw=="],
|
||||||
|
|
||||||
|
"webidl-conversions": ["webidl-conversions@7.0.0", "", {}, "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g=="],
|
||||||
|
|
||||||
|
"whatwg-url": ["whatwg-url@14.2.0", "", { "dependencies": { "tr46": "^5.1.0", "webidl-conversions": "^7.0.0" } }, "sha512-De72GdQZzNTUBBChsXueQUnPKDkg/5A5zp7pFDuQAj5UFoENpiACU0wlCvzpAGnTkj++ihpKwKyYewn/XNUbKw=="],
|
||||||
|
|
||||||
"which": ["which@4.0.0", "", { "dependencies": { "isexe": "^3.1.1" }, "bin": { "node-which": "bin/which.js" } }, "sha512-GlaYyEb07DPxYCKhKzplCWBJtvxZcZMrL+4UkrTSJHHPyZU4mYYTv3qaOe77H7EODLSSopAUFAc6W8U4yqvscg=="],
|
"which": ["which@4.0.0", "", { "dependencies": { "isexe": "^3.1.1" }, "bin": { "node-which": "bin/which.js" } }, "sha512-GlaYyEb07DPxYCKhKzplCWBJtvxZcZMrL+4UkrTSJHHPyZU4mYYTv3qaOe77H7EODLSSopAUFAc6W8U4yqvscg=="],
|
||||||
|
|
||||||
"which-boxed-primitive": ["which-boxed-primitive@1.1.1", "", { "dependencies": { "is-bigint": "^1.1.0", "is-boolean-object": "^1.2.1", "is-number-object": "^1.1.1", "is-string": "^1.1.1", "is-symbol": "^1.1.1" } }, "sha512-TbX3mj8n0odCBFVlY8AxkqcHASw3L60jIuF8jFP78az3C2YhmGvqbHBpAjTRH2/xqYunrJ9g1jSyjCjpoWzIAA=="],
|
"which-boxed-primitive": ["which-boxed-primitive@1.1.1", "", { "dependencies": { "is-bigint": "^1.1.0", "is-boolean-object": "^1.2.1", "is-number-object": "^1.1.1", "is-string": "^1.1.1", "is-symbol": "^1.1.1" } }, "sha512-TbX3mj8n0odCBFVlY8AxkqcHASw3L60jIuF8jFP78az3C2YhmGvqbHBpAjTRH2/xqYunrJ9g1jSyjCjpoWzIAA=="],
|
||||||
@@ -1863,6 +1924,8 @@
|
|||||||
|
|
||||||
"zustand": ["zustand@4.5.7", "", { "dependencies": { "use-sync-external-store": "^1.2.2" }, "peerDependencies": { "@types/react": ">=16.8", "immer": ">=9.0.6", "react": ">=16.8" }, "optionalPeers": ["@types/react", "immer", "react"] }, "sha512-CHOUy7mu3lbD6o6LJLfllpjkzhHXSBlX8B9+qPddUsIfeF5S/UZ5q0kmCsnRqT1UHFQZchNFDDzMbQsuesHWlw=="],
|
"zustand": ["zustand@4.5.7", "", { "dependencies": { "use-sync-external-store": "^1.2.2" }, "peerDependencies": { "@types/react": ">=16.8", "immer": ">=9.0.6", "react": ">=16.8" }, "optionalPeers": ["@types/react", "immer", "react"] }, "sha512-CHOUy7mu3lbD6o6LJLfllpjkzhHXSBlX8B9+qPddUsIfeF5S/UZ5q0kmCsnRqT1UHFQZchNFDDzMbQsuesHWlw=="],
|
||||||
|
|
||||||
|
"@auth/core/jose": ["jose@6.0.12", "", {}, "sha512-T8xypXs8CpmiIi78k0E+Lk7T2zlK4zDyg+o1CZ4AkOHgDg98ogdP2BeZ61lTFKFyoEwJ9RgAgN+SdM3iPgNonQ=="],
|
||||||
|
|
||||||
"@aws-crypto/crc32/@aws-sdk/types": ["@aws-sdk/types@3.840.0", "", { "dependencies": { "@smithy/types": "^4.3.1", "tslib": "^2.6.2" } }, "sha512-xliuHaUFZxEx1NSXeLLZ9Dyu6+EJVQKEoD+yM+zqUo3YDZ7medKJWY6fIOKiPX/N7XbLdBYwajb15Q7IL8KkeA=="],
|
"@aws-crypto/crc32/@aws-sdk/types": ["@aws-sdk/types@3.840.0", "", { "dependencies": { "@smithy/types": "^4.3.1", "tslib": "^2.6.2" } }, "sha512-xliuHaUFZxEx1NSXeLLZ9Dyu6+EJVQKEoD+yM+zqUo3YDZ7medKJWY6fIOKiPX/N7XbLdBYwajb15Q7IL8KkeA=="],
|
||||||
|
|
||||||
"@aws-crypto/crc32c/@aws-sdk/types": ["@aws-sdk/types@3.840.0", "", { "dependencies": { "@smithy/types": "^4.3.1", "tslib": "^2.6.2" } }, "sha512-xliuHaUFZxEx1NSXeLLZ9Dyu6+EJVQKEoD+yM+zqUo3YDZ7medKJWY6fIOKiPX/N7XbLdBYwajb15Q7IL8KkeA=="],
|
"@aws-crypto/crc32c/@aws-sdk/types": ["@aws-sdk/types@3.840.0", "", { "dependencies": { "@smithy/types": "^4.3.1", "tslib": "^2.6.2" } }, "sha512-xliuHaUFZxEx1NSXeLLZ9Dyu6+EJVQKEoD+yM+zqUo3YDZ7medKJWY6fIOKiPX/N7XbLdBYwajb15Q7IL8KkeA=="],
|
||||||
@@ -2097,6 +2160,8 @@
|
|||||||
|
|
||||||
"eslint-import-resolver-typescript/tinyglobby/fdir": ["fdir@6.4.6", "", { "peerDependencies": { "picomatch": "^3 || ^4" }, "optionalPeers": ["picomatch"] }, "sha512-hiFoqpyZcfNm1yc4u8oWCf9A2c4D3QjCrks3zmoVKVxpQRzmPNar1hUJcBG2RQHvEVGDN+Jm81ZheVLAQMK6+w=="],
|
"eslint-import-resolver-typescript/tinyglobby/fdir": ["fdir@6.4.6", "", { "peerDependencies": { "picomatch": "^3 || ^4" }, "optionalPeers": ["picomatch"] }, "sha512-hiFoqpyZcfNm1yc4u8oWCf9A2c4D3QjCrks3zmoVKVxpQRzmPNar1hUJcBG2RQHvEVGDN+Jm81ZheVLAQMK6+w=="],
|
||||||
|
|
||||||
|
"next-auth/@auth/core/jose": ["jose@6.0.12", "", {}, "sha512-T8xypXs8CpmiIi78k0E+Lk7T2zlK4zDyg+o1CZ4AkOHgDg98ogdP2BeZ61lTFKFyoEwJ9RgAgN+SdM3iPgNonQ=="],
|
||||||
|
|
||||||
"prosemirror-markdown/@types/markdown-it/@types/linkify-it": ["@types/linkify-it@5.0.0", "", {}, "sha512-sVDA58zAw4eWAffKOaQH5/5j3XeayukzDk+ewSsnv3p4yJEZHCCzMDiZM8e0OUrRvmpGZ85jf4yDHkHsgBNr9Q=="],
|
"prosemirror-markdown/@types/markdown-it/@types/linkify-it": ["@types/linkify-it@5.0.0", "", {}, "sha512-sVDA58zAw4eWAffKOaQH5/5j3XeayukzDk+ewSsnv3p4yJEZHCCzMDiZM8e0OUrRvmpGZ85jf4yDHkHsgBNr9Q=="],
|
||||||
|
|
||||||
"prosemirror-markdown/@types/markdown-it/@types/mdurl": ["@types/mdurl@2.0.0", "", {}, "sha512-RGdgjQUZba5p6QEFAVx2OGb8rQDL/cPRG7GiedRzMcJ1tYnUANBncjbSB1NRGwbvjcPeikRABz2nshyPk1bhWg=="],
|
"prosemirror-markdown/@types/markdown-it/@types/mdurl": ["@types/mdurl@2.0.0", "", {}, "sha512-RGdgjQUZba5p6QEFAVx2OGb8rQDL/cPRG7GiedRzMcJ1tYnUANBncjbSB1NRGwbvjcPeikRABz2nshyPk1bhWg=="],
|
||||||
|
|||||||
@@ -1,553 +0,0 @@
|
|||||||
CREATE TYPE "public"."block_category" AS ENUM('wizard', 'robot', 'control', 'sensor', 'logic', 'event');--> statement-breakpoint
|
|
||||||
CREATE TYPE "public"."block_shape" AS ENUM('action', 'control', 'value', 'boolean', 'hat', 'cap');--> statement-breakpoint
|
|
||||||
CREATE TYPE "public"."communication_protocol" AS ENUM('rest', 'ros2', 'custom');--> statement-breakpoint
|
|
||||||
CREATE TYPE "public"."experiment_status" AS ENUM('draft', 'testing', 'ready', 'deprecated');--> statement-breakpoint
|
|
||||||
CREATE TYPE "public"."export_status" AS ENUM('pending', 'processing', 'completed', 'failed');--> statement-breakpoint
|
|
||||||
CREATE TYPE "public"."media_type" AS ENUM('video', 'audio', 'image');--> statement-breakpoint
|
|
||||||
CREATE TYPE "public"."plugin_status" AS ENUM('active', 'deprecated', 'disabled');--> statement-breakpoint
|
|
||||||
CREATE TYPE "public"."step_type" AS ENUM('wizard', 'robot', 'parallel', 'conditional');--> statement-breakpoint
|
|
||||||
CREATE TYPE "public"."study_member_role" AS ENUM('owner', 'researcher', 'wizard', 'observer');--> statement-breakpoint
|
|
||||||
CREATE TYPE "public"."study_status" AS ENUM('draft', 'active', 'completed', 'archived');--> statement-breakpoint
|
|
||||||
CREATE TYPE "public"."system_role" AS ENUM('administrator', 'researcher', 'wizard', 'observer');--> statement-breakpoint
|
|
||||||
CREATE TYPE "public"."trial_status" AS ENUM('scheduled', 'in_progress', 'completed', 'aborted', 'failed');--> statement-breakpoint
|
|
||||||
CREATE TYPE "public"."trust_level" AS ENUM('official', 'verified', 'community');--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_account" (
|
|
||||||
"user_id" uuid NOT NULL,
|
|
||||||
"type" varchar(255) NOT NULL,
|
|
||||||
"provider" varchar(255) NOT NULL,
|
|
||||||
"provider_account_id" varchar(255) NOT NULL,
|
|
||||||
"refresh_token" text,
|
|
||||||
"access_token" text,
|
|
||||||
"expires_at" integer,
|
|
||||||
"token_type" varchar(255),
|
|
||||||
"scope" varchar(255),
|
|
||||||
"id_token" text,
|
|
||||||
"session_state" varchar(255),
|
|
||||||
"created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
"updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
CONSTRAINT "hs_account_provider_provider_account_id_pk" PRIMARY KEY("provider","provider_account_id")
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_action" (
|
|
||||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
||||||
"step_id" uuid NOT NULL,
|
|
||||||
"name" varchar(255) NOT NULL,
|
|
||||||
"description" text,
|
|
||||||
"type" varchar(100) NOT NULL,
|
|
||||||
"order_index" integer NOT NULL,
|
|
||||||
"parameters" jsonb DEFAULT '{}'::jsonb,
|
|
||||||
"validation_schema" jsonb,
|
|
||||||
"timeout" integer,
|
|
||||||
"retry_count" integer DEFAULT 0 NOT NULL,
|
|
||||||
"source_kind" varchar(20),
|
|
||||||
"plugin_id" varchar(255),
|
|
||||||
"plugin_version" varchar(50),
|
|
||||||
"robot_id" varchar(255),
|
|
||||||
"base_action_id" varchar(255),
|
|
||||||
"category" varchar(50),
|
|
||||||
"transport" varchar(20),
|
|
||||||
"ros2_config" jsonb,
|
|
||||||
"rest_config" jsonb,
|
|
||||||
"retryable" boolean,
|
|
||||||
"parameter_schema_raw" jsonb,
|
|
||||||
"created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
"updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
CONSTRAINT "hs_action_step_id_order_index_unique" UNIQUE("step_id","order_index")
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_activity_log" (
|
|
||||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
||||||
"study_id" uuid,
|
|
||||||
"user_id" uuid,
|
|
||||||
"action" varchar(100) NOT NULL,
|
|
||||||
"resource_type" varchar(50),
|
|
||||||
"resource_id" uuid,
|
|
||||||
"description" text,
|
|
||||||
"ip_address" "inet",
|
|
||||||
"user_agent" text,
|
|
||||||
"metadata" jsonb DEFAULT '{}'::jsonb,
|
|
||||||
"created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_annotation" (
|
|
||||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
||||||
"trial_id" uuid NOT NULL,
|
|
||||||
"annotator_id" uuid NOT NULL,
|
|
||||||
"timestamp_start" timestamp with time zone NOT NULL,
|
|
||||||
"timestamp_end" timestamp with time zone,
|
|
||||||
"category" varchar(100),
|
|
||||||
"label" varchar(100),
|
|
||||||
"description" text,
|
|
||||||
"tags" jsonb DEFAULT '[]'::jsonb,
|
|
||||||
"metadata" jsonb DEFAULT '{}'::jsonb,
|
|
||||||
"created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
"updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_attachment" (
|
|
||||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
||||||
"resource_type" varchar(50) NOT NULL,
|
|
||||||
"resource_id" uuid NOT NULL,
|
|
||||||
"file_name" varchar(255) NOT NULL,
|
|
||||||
"file_size" bigint NOT NULL,
|
|
||||||
"file_path" text NOT NULL,
|
|
||||||
"content_type" varchar(100),
|
|
||||||
"description" text,
|
|
||||||
"uploaded_by" uuid NOT NULL,
|
|
||||||
"created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_audit_log" (
|
|
||||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
||||||
"user_id" uuid,
|
|
||||||
"action" varchar(100) NOT NULL,
|
|
||||||
"resource_type" varchar(50),
|
|
||||||
"resource_id" uuid,
|
|
||||||
"changes" jsonb DEFAULT '{}'::jsonb,
|
|
||||||
"ip_address" "inet",
|
|
||||||
"user_agent" text,
|
|
||||||
"created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_block_registry" (
|
|
||||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
||||||
"block_type" varchar(100) NOT NULL,
|
|
||||||
"plugin_id" uuid,
|
|
||||||
"shape" "block_shape" NOT NULL,
|
|
||||||
"category" "block_category" NOT NULL,
|
|
||||||
"display_name" varchar(255) NOT NULL,
|
|
||||||
"description" text,
|
|
||||||
"icon" varchar(100),
|
|
||||||
"color" varchar(50),
|
|
||||||
"config" jsonb NOT NULL,
|
|
||||||
"parameter_schema" jsonb NOT NULL,
|
|
||||||
"execution_handler" varchar(100),
|
|
||||||
"timeout" integer,
|
|
||||||
"retry_policy" jsonb,
|
|
||||||
"requires_connection" boolean DEFAULT false,
|
|
||||||
"preview_mode" boolean DEFAULT true,
|
|
||||||
"created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
"updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
CONSTRAINT "hs_block_registry_block_type_plugin_id_unique" UNIQUE("block_type","plugin_id")
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_comment" (
|
|
||||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
||||||
"parent_id" uuid,
|
|
||||||
"resource_type" varchar(50) NOT NULL,
|
|
||||||
"resource_id" uuid NOT NULL,
|
|
||||||
"author_id" uuid NOT NULL,
|
|
||||||
"content" text NOT NULL,
|
|
||||||
"metadata" jsonb,
|
|
||||||
"created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
"updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_consent_form" (
|
|
||||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
||||||
"study_id" uuid NOT NULL,
|
|
||||||
"version" integer DEFAULT 1 NOT NULL,
|
|
||||||
"title" varchar(255) NOT NULL,
|
|
||||||
"content" text NOT NULL,
|
|
||||||
"active" boolean DEFAULT true NOT NULL,
|
|
||||||
"created_by" uuid NOT NULL,
|
|
||||||
"created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
"storage_path" text,
|
|
||||||
CONSTRAINT "hs_consent_form_study_id_version_unique" UNIQUE("study_id","version")
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_experiment" (
|
|
||||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
||||||
"study_id" uuid NOT NULL,
|
|
||||||
"name" varchar(255) NOT NULL,
|
|
||||||
"description" text,
|
|
||||||
"version" integer DEFAULT 1 NOT NULL,
|
|
||||||
"robot_id" uuid,
|
|
||||||
"status" "experiment_status" DEFAULT 'draft' NOT NULL,
|
|
||||||
"estimated_duration" integer,
|
|
||||||
"created_by" uuid NOT NULL,
|
|
||||||
"created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
"updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
"metadata" jsonb DEFAULT '{}'::jsonb,
|
|
||||||
"visual_design" jsonb,
|
|
||||||
"execution_graph" jsonb,
|
|
||||||
"plugin_dependencies" text[],
|
|
||||||
"integrity_hash" varchar(128),
|
|
||||||
"deleted_at" timestamp with time zone,
|
|
||||||
CONSTRAINT "hs_experiment_study_id_name_version_unique" UNIQUE("study_id","name","version")
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_export_job" (
|
|
||||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
||||||
"study_id" uuid NOT NULL,
|
|
||||||
"requested_by" uuid NOT NULL,
|
|
||||||
"export_type" varchar(50) NOT NULL,
|
|
||||||
"format" varchar(20) NOT NULL,
|
|
||||||
"filters" jsonb DEFAULT '{}'::jsonb,
|
|
||||||
"status" "export_status" DEFAULT 'pending' NOT NULL,
|
|
||||||
"storage_path" text,
|
|
||||||
"expires_at" timestamp with time zone,
|
|
||||||
"created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
"completed_at" timestamp with time zone,
|
|
||||||
"error_message" text
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_media_capture" (
|
|
||||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
||||||
"trial_id" uuid NOT NULL,
|
|
||||||
"media_type" "media_type",
|
|
||||||
"storage_path" text NOT NULL,
|
|
||||||
"file_size" bigint,
|
|
||||||
"duration" integer,
|
|
||||||
"format" varchar(20),
|
|
||||||
"resolution" varchar(20),
|
|
||||||
"start_timestamp" timestamp with time zone,
|
|
||||||
"end_timestamp" timestamp with time zone,
|
|
||||||
"metadata" jsonb DEFAULT '{}'::jsonb,
|
|
||||||
"created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_participant_consent" (
|
|
||||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
||||||
"participant_id" uuid NOT NULL,
|
|
||||||
"consent_form_id" uuid NOT NULL,
|
|
||||||
"signed_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
"signature_data" text,
|
|
||||||
"ip_address" "inet",
|
|
||||||
"storage_path" text,
|
|
||||||
CONSTRAINT "hs_participant_consent_participant_id_consent_form_id_unique" UNIQUE("participant_id","consent_form_id")
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_participant_document" (
|
|
||||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
||||||
"participant_id" uuid NOT NULL,
|
|
||||||
"name" varchar(255) NOT NULL,
|
|
||||||
"type" varchar(100),
|
|
||||||
"storage_path" text NOT NULL,
|
|
||||||
"file_size" integer,
|
|
||||||
"uploaded_by" uuid,
|
|
||||||
"created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_participant" (
|
|
||||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
||||||
"study_id" uuid NOT NULL,
|
|
||||||
"participant_code" varchar(50) NOT NULL,
|
|
||||||
"email" varchar(255),
|
|
||||||
"name" varchar(255),
|
|
||||||
"demographics" jsonb DEFAULT '{}'::jsonb,
|
|
||||||
"consent_given" boolean DEFAULT false NOT NULL,
|
|
||||||
"consent_date" timestamp with time zone,
|
|
||||||
"notes" text,
|
|
||||||
"created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
"updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
CONSTRAINT "hs_participant_study_id_participant_code_unique" UNIQUE("study_id","participant_code")
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_permission" (
|
|
||||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
||||||
"name" varchar(100) NOT NULL,
|
|
||||||
"description" text,
|
|
||||||
"resource" varchar(50) NOT NULL,
|
|
||||||
"action" varchar(50) NOT NULL,
|
|
||||||
"created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
CONSTRAINT "hs_permission_name_unique" UNIQUE("name")
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_plugin_repository" (
|
|
||||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
||||||
"name" varchar(255) NOT NULL,
|
|
||||||
"url" text NOT NULL,
|
|
||||||
"description" text,
|
|
||||||
"trust_level" "trust_level" DEFAULT 'community' NOT NULL,
|
|
||||||
"is_enabled" boolean DEFAULT true NOT NULL,
|
|
||||||
"is_official" boolean DEFAULT false NOT NULL,
|
|
||||||
"last_sync_at" timestamp with time zone,
|
|
||||||
"sync_status" varchar(50) DEFAULT 'pending',
|
|
||||||
"sync_error" text,
|
|
||||||
"metadata" jsonb DEFAULT '{}'::jsonb,
|
|
||||||
"created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
"updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
"created_by" uuid NOT NULL,
|
|
||||||
CONSTRAINT "hs_plugin_repository_url_unique" UNIQUE("url")
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_plugin" (
|
|
||||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
||||||
"robot_id" uuid,
|
|
||||||
"identifier" varchar(100) NOT NULL,
|
|
||||||
"name" varchar(255) NOT NULL,
|
|
||||||
"version" varchar(50) NOT NULL,
|
|
||||||
"description" text,
|
|
||||||
"author" varchar(255),
|
|
||||||
"repository_url" text,
|
|
||||||
"trust_level" "trust_level",
|
|
||||||
"status" "plugin_status" DEFAULT 'active' NOT NULL,
|
|
||||||
"configuration_schema" jsonb,
|
|
||||||
"action_definitions" jsonb DEFAULT '[]'::jsonb,
|
|
||||||
"created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
"updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
"metadata" jsonb DEFAULT '{}'::jsonb,
|
|
||||||
CONSTRAINT "hs_plugin_identifier_unique" UNIQUE("identifier"),
|
|
||||||
CONSTRAINT "hs_plugin_name_version_unique" UNIQUE("name","version")
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_robot_plugin" (
|
|
||||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
||||||
"name" varchar(255) NOT NULL,
|
|
||||||
"version" varchar(50) NOT NULL,
|
|
||||||
"manufacturer" varchar(255),
|
|
||||||
"description" text,
|
|
||||||
"robot_id" uuid,
|
|
||||||
"communication_protocol" "communication_protocol",
|
|
||||||
"status" "plugin_status" DEFAULT 'active' NOT NULL,
|
|
||||||
"config_schema" jsonb,
|
|
||||||
"capabilities" jsonb DEFAULT '[]'::jsonb,
|
|
||||||
"trust_level" "trust_level" DEFAULT 'community' NOT NULL,
|
|
||||||
"created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
"updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_robot" (
|
|
||||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
||||||
"name" varchar(255) NOT NULL,
|
|
||||||
"manufacturer" varchar(255),
|
|
||||||
"model" varchar(255),
|
|
||||||
"description" text,
|
|
||||||
"capabilities" jsonb DEFAULT '[]'::jsonb,
|
|
||||||
"communication_protocol" "communication_protocol",
|
|
||||||
"created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
"updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_role_permission" (
|
|
||||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
||||||
"role" "system_role" NOT NULL,
|
|
||||||
"permission_id" uuid NOT NULL,
|
|
||||||
CONSTRAINT "hs_role_permission_role_permission_id_unique" UNIQUE("role","permission_id")
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_sensor_data" (
|
|
||||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
||||||
"trial_id" uuid NOT NULL,
|
|
||||||
"sensor_type" varchar(50) NOT NULL,
|
|
||||||
"timestamp" timestamp with time zone NOT NULL,
|
|
||||||
"data" jsonb NOT NULL,
|
|
||||||
"robot_state" jsonb DEFAULT '{}'::jsonb,
|
|
||||||
"created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_session" (
|
|
||||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
||||||
"session_token" varchar(255) NOT NULL,
|
|
||||||
"user_id" uuid NOT NULL,
|
|
||||||
"expires" timestamp with time zone NOT NULL,
|
|
||||||
"created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
"updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
CONSTRAINT "hs_session_session_token_unique" UNIQUE("session_token")
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_shared_resource" (
|
|
||||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
||||||
"study_id" uuid NOT NULL,
|
|
||||||
"resource_type" varchar(50) NOT NULL,
|
|
||||||
"resource_id" uuid NOT NULL,
|
|
||||||
"shared_by" uuid NOT NULL,
|
|
||||||
"share_token" varchar(255),
|
|
||||||
"permissions" jsonb DEFAULT '["read"]'::jsonb,
|
|
||||||
"expires_at" timestamp with time zone,
|
|
||||||
"access_count" integer DEFAULT 0 NOT NULL,
|
|
||||||
"created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
CONSTRAINT "hs_shared_resource_share_token_unique" UNIQUE("share_token")
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_step" (
|
|
||||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
||||||
"experiment_id" uuid NOT NULL,
|
|
||||||
"name" varchar(255) NOT NULL,
|
|
||||||
"description" text,
|
|
||||||
"type" "step_type" NOT NULL,
|
|
||||||
"order_index" integer NOT NULL,
|
|
||||||
"duration_estimate" integer,
|
|
||||||
"required" boolean DEFAULT true NOT NULL,
|
|
||||||
"conditions" jsonb DEFAULT '{}'::jsonb,
|
|
||||||
"created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
"updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
CONSTRAINT "hs_step_experiment_id_order_index_unique" UNIQUE("experiment_id","order_index")
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_study" (
|
|
||||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
||||||
"name" varchar(255) NOT NULL,
|
|
||||||
"description" text,
|
|
||||||
"institution" varchar(255),
|
|
||||||
"irb_protocol" varchar(100),
|
|
||||||
"status" "study_status" DEFAULT 'draft' NOT NULL,
|
|
||||||
"created_by" uuid NOT NULL,
|
|
||||||
"created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
"updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
"metadata" jsonb DEFAULT '{}'::jsonb,
|
|
||||||
"settings" jsonb DEFAULT '{}'::jsonb,
|
|
||||||
"deleted_at" timestamp with time zone
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_study_member" (
|
|
||||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
||||||
"study_id" uuid NOT NULL,
|
|
||||||
"user_id" uuid NOT NULL,
|
|
||||||
"role" "study_member_role" NOT NULL,
|
|
||||||
"permissions" jsonb DEFAULT '[]'::jsonb,
|
|
||||||
"joined_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
"invited_by" uuid,
|
|
||||||
CONSTRAINT "hs_study_member_study_id_user_id_unique" UNIQUE("study_id","user_id")
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_study_plugin" (
|
|
||||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
||||||
"study_id" uuid NOT NULL,
|
|
||||||
"plugin_id" uuid NOT NULL,
|
|
||||||
"configuration" jsonb DEFAULT '{}'::jsonb,
|
|
||||||
"installed_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
"installed_by" uuid NOT NULL,
|
|
||||||
CONSTRAINT "hs_study_plugin_study_id_plugin_id_unique" UNIQUE("study_id","plugin_id")
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_system_setting" (
|
|
||||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
||||||
"key" varchar(100) NOT NULL,
|
|
||||||
"value" jsonb NOT NULL,
|
|
||||||
"description" text,
|
|
||||||
"updated_by" uuid,
|
|
||||||
"updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
CONSTRAINT "hs_system_setting_key_unique" UNIQUE("key")
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_trial_event" (
|
|
||||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
||||||
"trial_id" uuid NOT NULL,
|
|
||||||
"event_type" varchar(50) NOT NULL,
|
|
||||||
"action_id" uuid,
|
|
||||||
"timestamp" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
"data" jsonb DEFAULT '{}'::jsonb,
|
|
||||||
"created_by" uuid
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_trial" (
|
|
||||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
||||||
"experiment_id" uuid NOT NULL,
|
|
||||||
"participant_id" uuid,
|
|
||||||
"wizard_id" uuid,
|
|
||||||
"session_number" integer DEFAULT 1 NOT NULL,
|
|
||||||
"status" "trial_status" DEFAULT 'scheduled' NOT NULL,
|
|
||||||
"scheduled_at" timestamp with time zone,
|
|
||||||
"started_at" timestamp with time zone,
|
|
||||||
"completed_at" timestamp with time zone,
|
|
||||||
"duration" integer,
|
|
||||||
"notes" text,
|
|
||||||
"parameters" jsonb DEFAULT '{}'::jsonb,
|
|
||||||
"created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
"updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
"metadata" jsonb DEFAULT '{}'::jsonb
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_user_system_role" (
|
|
||||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
||||||
"user_id" uuid NOT NULL,
|
|
||||||
"role" "system_role" NOT NULL,
|
|
||||||
"granted_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
"granted_by" uuid,
|
|
||||||
CONSTRAINT "hs_user_system_role_user_id_role_unique" UNIQUE("user_id","role")
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_user" (
|
|
||||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
||||||
"email" varchar(255) NOT NULL,
|
|
||||||
"email_verified" timestamp with time zone,
|
|
||||||
"name" varchar(255),
|
|
||||||
"image" text,
|
|
||||||
"password" varchar(255),
|
|
||||||
"created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
"updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
"deleted_at" timestamp with time zone,
|
|
||||||
CONSTRAINT "hs_user_email_unique" UNIQUE("email")
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_verification_token" (
|
|
||||||
"identifier" varchar(255) NOT NULL,
|
|
||||||
"token" varchar(255) NOT NULL,
|
|
||||||
"expires" timestamp with time zone NOT NULL,
|
|
||||||
"created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
CONSTRAINT "hs_verification_token_identifier_token_pk" PRIMARY KEY("identifier","token"),
|
|
||||||
CONSTRAINT "hs_verification_token_token_unique" UNIQUE("token")
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
CREATE TABLE "hs_wizard_intervention" (
|
|
||||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
||||||
"trial_id" uuid NOT NULL,
|
|
||||||
"wizard_id" uuid NOT NULL,
|
|
||||||
"intervention_type" varchar(100) NOT NULL,
|
|
||||||
"description" text,
|
|
||||||
"timestamp" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
"parameters" jsonb DEFAULT '{}'::jsonb,
|
|
||||||
"reason" text
|
|
||||||
);
|
|
||||||
--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_account" ADD CONSTRAINT "hs_account_user_id_hs_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."hs_user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_action" ADD CONSTRAINT "hs_action_step_id_hs_step_id_fk" FOREIGN KEY ("step_id") REFERENCES "public"."hs_step"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_activity_log" ADD CONSTRAINT "hs_activity_log_study_id_hs_study_id_fk" FOREIGN KEY ("study_id") REFERENCES "public"."hs_study"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_activity_log" ADD CONSTRAINT "hs_activity_log_user_id_hs_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_annotation" ADD CONSTRAINT "hs_annotation_trial_id_hs_trial_id_fk" FOREIGN KEY ("trial_id") REFERENCES "public"."hs_trial"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_annotation" ADD CONSTRAINT "hs_annotation_annotator_id_hs_user_id_fk" FOREIGN KEY ("annotator_id") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_attachment" ADD CONSTRAINT "hs_attachment_uploaded_by_hs_user_id_fk" FOREIGN KEY ("uploaded_by") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_audit_log" ADD CONSTRAINT "hs_audit_log_user_id_hs_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_block_registry" ADD CONSTRAINT "hs_block_registry_plugin_id_hs_robot_plugin_id_fk" FOREIGN KEY ("plugin_id") REFERENCES "public"."hs_robot_plugin"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_comment" ADD CONSTRAINT "hs_comment_author_id_hs_user_id_fk" FOREIGN KEY ("author_id") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_consent_form" ADD CONSTRAINT "hs_consent_form_study_id_hs_study_id_fk" FOREIGN KEY ("study_id") REFERENCES "public"."hs_study"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_consent_form" ADD CONSTRAINT "hs_consent_form_created_by_hs_user_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_experiment" ADD CONSTRAINT "hs_experiment_study_id_hs_study_id_fk" FOREIGN KEY ("study_id") REFERENCES "public"."hs_study"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_experiment" ADD CONSTRAINT "hs_experiment_robot_id_hs_robot_id_fk" FOREIGN KEY ("robot_id") REFERENCES "public"."hs_robot"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_experiment" ADD CONSTRAINT "hs_experiment_created_by_hs_user_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_export_job" ADD CONSTRAINT "hs_export_job_study_id_hs_study_id_fk" FOREIGN KEY ("study_id") REFERENCES "public"."hs_study"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_export_job" ADD CONSTRAINT "hs_export_job_requested_by_hs_user_id_fk" FOREIGN KEY ("requested_by") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_media_capture" ADD CONSTRAINT "hs_media_capture_trial_id_hs_trial_id_fk" FOREIGN KEY ("trial_id") REFERENCES "public"."hs_trial"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_participant_consent" ADD CONSTRAINT "hs_participant_consent_participant_id_hs_participant_id_fk" FOREIGN KEY ("participant_id") REFERENCES "public"."hs_participant"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_participant_consent" ADD CONSTRAINT "hs_participant_consent_consent_form_id_hs_consent_form_id_fk" FOREIGN KEY ("consent_form_id") REFERENCES "public"."hs_consent_form"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_participant_document" ADD CONSTRAINT "hs_participant_document_participant_id_hs_participant_id_fk" FOREIGN KEY ("participant_id") REFERENCES "public"."hs_participant"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_participant_document" ADD CONSTRAINT "hs_participant_document_uploaded_by_hs_user_id_fk" FOREIGN KEY ("uploaded_by") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_participant" ADD CONSTRAINT "hs_participant_study_id_hs_study_id_fk" FOREIGN KEY ("study_id") REFERENCES "public"."hs_study"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_plugin_repository" ADD CONSTRAINT "hs_plugin_repository_created_by_hs_user_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_plugin" ADD CONSTRAINT "hs_plugin_robot_id_hs_robot_id_fk" FOREIGN KEY ("robot_id") REFERENCES "public"."hs_robot"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_robot_plugin" ADD CONSTRAINT "hs_robot_plugin_robot_id_hs_robot_id_fk" FOREIGN KEY ("robot_id") REFERENCES "public"."hs_robot"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_role_permission" ADD CONSTRAINT "hs_role_permission_permission_id_hs_permission_id_fk" FOREIGN KEY ("permission_id") REFERENCES "public"."hs_permission"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_sensor_data" ADD CONSTRAINT "hs_sensor_data_trial_id_hs_trial_id_fk" FOREIGN KEY ("trial_id") REFERENCES "public"."hs_trial"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_session" ADD CONSTRAINT "hs_session_user_id_hs_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."hs_user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_shared_resource" ADD CONSTRAINT "hs_shared_resource_study_id_hs_study_id_fk" FOREIGN KEY ("study_id") REFERENCES "public"."hs_study"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_shared_resource" ADD CONSTRAINT "hs_shared_resource_shared_by_hs_user_id_fk" FOREIGN KEY ("shared_by") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_step" ADD CONSTRAINT "hs_step_experiment_id_hs_experiment_id_fk" FOREIGN KEY ("experiment_id") REFERENCES "public"."hs_experiment"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_study" ADD CONSTRAINT "hs_study_created_by_hs_user_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_study_member" ADD CONSTRAINT "hs_study_member_study_id_hs_study_id_fk" FOREIGN KEY ("study_id") REFERENCES "public"."hs_study"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_study_member" ADD CONSTRAINT "hs_study_member_user_id_hs_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."hs_user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_study_member" ADD CONSTRAINT "hs_study_member_invited_by_hs_user_id_fk" FOREIGN KEY ("invited_by") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_study_plugin" ADD CONSTRAINT "hs_study_plugin_study_id_hs_study_id_fk" FOREIGN KEY ("study_id") REFERENCES "public"."hs_study"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_study_plugin" ADD CONSTRAINT "hs_study_plugin_plugin_id_hs_plugin_id_fk" FOREIGN KEY ("plugin_id") REFERENCES "public"."hs_plugin"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_study_plugin" ADD CONSTRAINT "hs_study_plugin_installed_by_hs_user_id_fk" FOREIGN KEY ("installed_by") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_system_setting" ADD CONSTRAINT "hs_system_setting_updated_by_hs_user_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_trial_event" ADD CONSTRAINT "hs_trial_event_trial_id_hs_trial_id_fk" FOREIGN KEY ("trial_id") REFERENCES "public"."hs_trial"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_trial_event" ADD CONSTRAINT "hs_trial_event_action_id_hs_action_id_fk" FOREIGN KEY ("action_id") REFERENCES "public"."hs_action"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_trial_event" ADD CONSTRAINT "hs_trial_event_created_by_hs_user_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_trial" ADD CONSTRAINT "hs_trial_experiment_id_hs_experiment_id_fk" FOREIGN KEY ("experiment_id") REFERENCES "public"."hs_experiment"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_trial" ADD CONSTRAINT "hs_trial_participant_id_hs_participant_id_fk" FOREIGN KEY ("participant_id") REFERENCES "public"."hs_participant"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_trial" ADD CONSTRAINT "hs_trial_wizard_id_hs_user_id_fk" FOREIGN KEY ("wizard_id") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_user_system_role" ADD CONSTRAINT "hs_user_system_role_user_id_hs_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."hs_user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_user_system_role" ADD CONSTRAINT "hs_user_system_role_granted_by_hs_user_id_fk" FOREIGN KEY ("granted_by") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_wizard_intervention" ADD CONSTRAINT "hs_wizard_intervention_trial_id_hs_trial_id_fk" FOREIGN KEY ("trial_id") REFERENCES "public"."hs_trial"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "hs_wizard_intervention" ADD CONSTRAINT "hs_wizard_intervention_wizard_id_hs_user_id_fk" FOREIGN KEY ("wizard_id") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
||||||
CREATE INDEX "account_user_id_idx" ON "hs_account" USING btree ("user_id");--> statement-breakpoint
|
|
||||||
CREATE INDEX "activity_logs_study_created_idx" ON "hs_activity_log" USING btree ("study_id","created_at");--> statement-breakpoint
|
|
||||||
CREATE INDEX "audit_logs_created_idx" ON "hs_audit_log" USING btree ("created_at");--> statement-breakpoint
|
|
||||||
CREATE INDEX "block_registry_category_idx" ON "hs_block_registry" USING btree ("category");--> statement-breakpoint
|
|
||||||
CREATE INDEX "experiment_visual_design_idx" ON "hs_experiment" USING gin ("visual_design");--> statement-breakpoint
|
|
||||||
CREATE INDEX "participant_document_participant_idx" ON "hs_participant_document" USING btree ("participant_id");--> statement-breakpoint
|
|
||||||
CREATE INDEX "sensor_data_trial_timestamp_idx" ON "hs_sensor_data" USING btree ("trial_id","timestamp");--> statement-breakpoint
|
|
||||||
CREATE INDEX "session_user_id_idx" ON "hs_session" USING btree ("user_id");--> statement-breakpoint
|
|
||||||
CREATE INDEX "trial_events_trial_timestamp_idx" ON "hs_trial_event" USING btree ("trial_id","timestamp");
|
|
||||||
@@ -1,55 +1,27 @@
|
|||||||
import type { Session } from "next-auth";
|
|
||||||
import type { NextRequest } from "next/server";
|
import type { NextRequest } from "next/server";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { auth } from "./src/server/auth";
|
|
||||||
|
|
||||||
export default auth((req: NextRequest & { auth: Session | null }) => {
|
export default async function middleware(request: NextRequest) {
|
||||||
const { nextUrl } = req;
|
const { nextUrl } = request;
|
||||||
const isLoggedIn = !!req.auth;
|
|
||||||
|
|
||||||
// Define route patterns
|
// Skip session checks for now to debug the auth issue
|
||||||
const isApiAuthRoute = nextUrl.pathname.startsWith("/api/auth");
|
const isApiRoute = nextUrl.pathname.startsWith("/api");
|
||||||
const isPublicRoute = ["/", "/auth/signin", "/auth/signup"].includes(
|
|
||||||
nextUrl.pathname,
|
|
||||||
);
|
|
||||||
const isAuthRoute = nextUrl.pathname.startsWith("/auth");
|
const isAuthRoute = nextUrl.pathname.startsWith("/auth");
|
||||||
|
|
||||||
// Allow API auth routes to pass through
|
if (isApiRoute) {
|
||||||
if (isApiAuthRoute) {
|
|
||||||
return NextResponse.next();
|
return NextResponse.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If user is on auth pages and already logged in, redirect to dashboard
|
// Allow auth routes through for now
|
||||||
if (isAuthRoute && isLoggedIn) {
|
if (isAuthRoute) {
|
||||||
return NextResponse.redirect(new URL("/", nextUrl));
|
return NextResponse.next();
|
||||||
}
|
|
||||||
|
|
||||||
// If user is not logged in and trying to access protected routes
|
|
||||||
if (!isLoggedIn && !isPublicRoute && !isAuthRoute) {
|
|
||||||
let callbackUrl = nextUrl.pathname;
|
|
||||||
if (nextUrl.search) {
|
|
||||||
callbackUrl += nextUrl.search;
|
|
||||||
}
|
|
||||||
|
|
||||||
const encodedCallbackUrl = encodeURIComponent(callbackUrl);
|
|
||||||
return NextResponse.redirect(
|
|
||||||
new URL(`/auth/signin?callbackUrl=${encodedCallbackUrl}`, nextUrl),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NextResponse.next();
|
return NextResponse.next();
|
||||||
});
|
}
|
||||||
|
|
||||||
// Configure which routes the middleware should run on
|
|
||||||
export const config = {
|
export const config = {
|
||||||
matcher: [
|
matcher: [
|
||||||
/*
|
|
||||||
* Match all request paths except for the ones starting with:
|
|
||||||
* - _next/static (static files)
|
|
||||||
* - _next/image (image optimization files)
|
|
||||||
* - favicon.ico (favicon file)
|
|
||||||
* - public files (images, etc.)
|
|
||||||
*/
|
|
||||||
"/((?!_next/static|_next/image|favicon.ico|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)",
|
"/((?!_next/static|_next/image|favicon.ico|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)",
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
"@auth/drizzle-adapter": "^1.11.1",
|
"@auth/drizzle-adapter": "^1.11.1",
|
||||||
"@aws-sdk/client-s3": "^3.989.0",
|
"@aws-sdk/client-s3": "^3.989.0",
|
||||||
"@aws-sdk/s3-request-presigner": "^3.989.0",
|
"@aws-sdk/s3-request-presigner": "^3.989.0",
|
||||||
|
"@better-auth/drizzle-adapter": "^1.5.5",
|
||||||
"@dnd-kit/core": "^6.3.1",
|
"@dnd-kit/core": "^6.3.1",
|
||||||
"@dnd-kit/sortable": "^10.0.0",
|
"@dnd-kit/sortable": "^10.0.0",
|
||||||
"@dnd-kit/utilities": "^3.2.2",
|
"@dnd-kit/utilities": "^3.2.2",
|
||||||
@@ -67,6 +68,7 @@
|
|||||||
"@types/js-cookie": "^3.0.6",
|
"@types/js-cookie": "^3.0.6",
|
||||||
"@types/ws": "^8.18.1",
|
"@types/ws": "^8.18.1",
|
||||||
"bcryptjs": "^3.0.3",
|
"bcryptjs": "^3.0.3",
|
||||||
|
"better-auth": "^1.5.5",
|
||||||
"class-variance-authority": "^0.7.1",
|
"class-variance-authority": "^0.7.1",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"cmdk": "^1.1.1",
|
"cmdk": "^1.1.1",
|
||||||
|
|||||||
Submodule robot-plugins updated: d772aecc54...ff48567918
@@ -76,6 +76,9 @@ async function main() {
|
|||||||
|
|
||||||
// 1. Clean existing data (Full Wipe)
|
// 1. Clean existing data (Full Wipe)
|
||||||
console.log("🧹 Cleaning existing data...");
|
console.log("🧹 Cleaning existing data...");
|
||||||
|
await db.delete(schema.sessions).where(sql`1=1`);
|
||||||
|
await db.delete(schema.accounts).where(sql`1=1`);
|
||||||
|
await db.delete(schema.verificationTokens).where(sql`1=1`);
|
||||||
await db.delete(schema.mediaCaptures).where(sql`1=1`);
|
await db.delete(schema.mediaCaptures).where(sql`1=1`);
|
||||||
await db.delete(schema.trialEvents).where(sql`1=1`);
|
await db.delete(schema.trialEvents).where(sql`1=1`);
|
||||||
await db.delete(schema.trials).where(sql`1=1`);
|
await db.delete(schema.trials).where(sql`1=1`);
|
||||||
@@ -93,20 +96,24 @@ async function main() {
|
|||||||
await db.delete(schema.users).where(sql`1=1`);
|
await db.delete(schema.users).where(sql`1=1`);
|
||||||
await db.delete(schema.robots).where(sql`1=1`);
|
await db.delete(schema.robots).where(sql`1=1`);
|
||||||
|
|
||||||
// 2. Create Users
|
// 2. Create Users (Better Auth manages credentials)
|
||||||
console.log("👥 Creating users...");
|
console.log("👥 Creating users...");
|
||||||
const hashedPassword = await bcrypt.hash("password123", 12);
|
const hashedPassword = await bcrypt.hash("password123", 12);
|
||||||
|
|
||||||
const gravatarUrl = (email: string) =>
|
const gravatarUrl = (email: string) =>
|
||||||
`https://www.gravatar.com/avatar/${createHash("md5").update(email.toLowerCase().trim()).digest("hex")}?d=identicon`;
|
`https://www.gravatar.com/avatar/${createHash("md5").update(email.toLowerCase().trim()).digest("hex")}?d=identicon`;
|
||||||
|
|
||||||
|
// Generate text IDs (Better Auth uses text-based IDs)
|
||||||
|
const adminId = `admin_${randomUUID()}`;
|
||||||
|
const researcherId = `researcher_${randomUUID()}`;
|
||||||
|
|
||||||
const [adminUser] = await db
|
const [adminUser] = await db
|
||||||
.insert(schema.users)
|
.insert(schema.users)
|
||||||
.values({
|
.values({
|
||||||
|
id: adminId,
|
||||||
name: "Sean O'Connor",
|
name: "Sean O'Connor",
|
||||||
email: "sean@soconnor.dev",
|
email: "sean@soconnor.dev",
|
||||||
password: hashedPassword,
|
emailVerified: true,
|
||||||
emailVerified: new Date(),
|
|
||||||
image: gravatarUrl("sean@soconnor.dev"),
|
image: gravatarUrl("sean@soconnor.dev"),
|
||||||
})
|
})
|
||||||
.returning();
|
.returning();
|
||||||
@@ -114,16 +121,39 @@ async function main() {
|
|||||||
const [researcherUser] = await db
|
const [researcherUser] = await db
|
||||||
.insert(schema.users)
|
.insert(schema.users)
|
||||||
.values({
|
.values({
|
||||||
|
id: researcherId,
|
||||||
name: "Dr. Felipe Perrone",
|
name: "Dr. Felipe Perrone",
|
||||||
email: "felipe.perrone@bucknell.edu",
|
email: "felipe.perrone@bucknell.edu",
|
||||||
password: hashedPassword,
|
emailVerified: true,
|
||||||
emailVerified: new Date(),
|
|
||||||
image: "https://api.dicebear.com/7.x/avataaars/svg?seed=Felipe",
|
image: "https://api.dicebear.com/7.x/avataaars/svg?seed=Felipe",
|
||||||
})
|
})
|
||||||
.returning();
|
.returning();
|
||||||
|
|
||||||
if (!adminUser) throw new Error("Failed to create admin user");
|
if (!adminUser) throw new Error("Failed to create admin user");
|
||||||
|
|
||||||
|
// Create credential accounts for Better Auth (accountId = userId for credential provider)
|
||||||
|
await db.insert(schema.accounts).values({
|
||||||
|
id: `acc_${randomUUID()}`,
|
||||||
|
userId: adminUser.id,
|
||||||
|
providerId: "credential",
|
||||||
|
accountId: adminUser.id,
|
||||||
|
password: hashedPassword,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (researcherUser) {
|
||||||
|
await db.insert(schema.accounts).values({
|
||||||
|
id: `acc_${randomUUID()}`,
|
||||||
|
userId: researcherUser.id,
|
||||||
|
providerId: "credential",
|
||||||
|
accountId: researcherUser.id,
|
||||||
|
password: hashedPassword,
|
||||||
|
});
|
||||||
|
|
||||||
|
await db
|
||||||
|
.insert(schema.userSystemRoles)
|
||||||
|
.values({ userId: researcherUser.id, role: "researcher" });
|
||||||
|
}
|
||||||
|
|
||||||
await db
|
await db
|
||||||
.insert(schema.userSystemRoles)
|
.insert(schema.userSystemRoles)
|
||||||
.values({ userId: adminUser.id, role: "administrator" });
|
.values({ userId: adminUser.id, role: "administrator" });
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
import { cookies } from "next/headers";
|
import { cookies, headers } from "next/headers";
|
||||||
import {
|
import {
|
||||||
SidebarInset,
|
SidebarInset,
|
||||||
SidebarProvider,
|
SidebarProvider,
|
||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
} from "~/components/ui/sidebar";
|
} from "~/components/ui/sidebar";
|
||||||
import { Separator } from "~/components/ui/separator";
|
import { Separator } from "~/components/ui/separator";
|
||||||
import { AppSidebar } from "~/components/dashboard/app-sidebar";
|
import { AppSidebar } from "~/components/dashboard/app-sidebar";
|
||||||
import { auth } from "~/server/auth";
|
import { auth } from "~/lib/auth";
|
||||||
import {
|
import {
|
||||||
BreadcrumbProvider,
|
BreadcrumbProvider,
|
||||||
BreadcrumbDisplay,
|
BreadcrumbDisplay,
|
||||||
@@ -22,16 +22,15 @@ interface DashboardLayoutProps {
|
|||||||
export default async function DashboardLayout({
|
export default async function DashboardLayout({
|
||||||
children,
|
children,
|
||||||
}: DashboardLayoutProps) {
|
}: DashboardLayoutProps) {
|
||||||
const session = await auth();
|
const session = await auth.api.getSession({
|
||||||
|
headers: await headers(),
|
||||||
|
});
|
||||||
|
|
||||||
if (!session?.user) {
|
if (!session?.user) {
|
||||||
redirect("/auth/signin");
|
redirect("/auth/signin");
|
||||||
}
|
}
|
||||||
|
|
||||||
const userRole =
|
const userRole = "researcher"; // Default role for dashboard access
|
||||||
typeof session.user.roles?.[0] === "string"
|
|
||||||
? session.user.roles[0]
|
|
||||||
: (session.user.roles?.[0]?.role ?? "observer");
|
|
||||||
|
|
||||||
const cookieStore = await cookies();
|
const cookieStore = await cookies();
|
||||||
const defaultOpen = cookieStore.get("sidebar_state")?.value === "true";
|
const defaultOpen = cookieStore.get("sidebar_state")?.value === "true";
|
||||||
|
|||||||
@@ -16,19 +16,10 @@ import { Separator } from "~/components/ui/separator";
|
|||||||
import { PageHeader } from "~/components/ui/page-header";
|
import { PageHeader } from "~/components/ui/page-header";
|
||||||
import { useBreadcrumbsEffect } from "~/components/ui/breadcrumb-provider";
|
import { useBreadcrumbsEffect } from "~/components/ui/breadcrumb-provider";
|
||||||
import { formatRole, getRoleDescription } from "~/lib/auth-client";
|
import { formatRole, getRoleDescription } from "~/lib/auth-client";
|
||||||
import {
|
import { User, Shield, Download, Trash2, Lock, UserCog } from "lucide-react";
|
||||||
User,
|
import { useSession } from "~/lib/auth-client";
|
||||||
Shield,
|
|
||||||
Download,
|
|
||||||
Trash2,
|
|
||||||
ExternalLink,
|
|
||||||
Lock,
|
|
||||||
UserCog,
|
|
||||||
Mail,
|
|
||||||
Fingerprint,
|
|
||||||
} from "lucide-react";
|
|
||||||
import { useSession } from "next-auth/react";
|
|
||||||
import { cn } from "~/lib/utils";
|
import { cn } from "~/lib/utils";
|
||||||
|
import { api } from "~/trpc/react";
|
||||||
|
|
||||||
interface ProfileUser {
|
interface ProfileUser {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -37,7 +28,8 @@ interface ProfileUser {
|
|||||||
image: string | null;
|
image: string | null;
|
||||||
roles?: Array<{
|
roles?: Array<{
|
||||||
role: "administrator" | "researcher" | "wizard" | "observer";
|
role: "administrator" | "researcher" | "wizard" | "observer";
|
||||||
grantedAt: string | Date;
|
grantedAt: Date;
|
||||||
|
grantedBy: string | null;
|
||||||
}>;
|
}>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,14 +205,20 @@ function ProfileContent({ user }: { user: ProfileUser }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function ProfilePage() {
|
export default function ProfilePage() {
|
||||||
const { data: session, status } = useSession();
|
const { data: session, isPending } = useSession();
|
||||||
|
const { data: userData, isPending: isUserPending } = api.auth.me.useQuery(
|
||||||
|
undefined,
|
||||||
|
{
|
||||||
|
enabled: !!session?.user,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
useBreadcrumbsEffect([
|
useBreadcrumbsEffect([
|
||||||
{ label: "Dashboard", href: "/dashboard" },
|
{ label: "Dashboard", href: "/dashboard" },
|
||||||
{ label: "Profile" },
|
{ label: "Profile" },
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (status === "loading") {
|
if (isPending || isUserPending) {
|
||||||
return (
|
return (
|
||||||
<div className="text-muted-foreground animate-pulse p-8">
|
<div className="text-muted-foreground animate-pulse p-8">
|
||||||
Loading profile...
|
Loading profile...
|
||||||
@@ -232,7 +230,13 @@ export default function ProfilePage() {
|
|||||||
redirect("/auth/signin");
|
redirect("/auth/signin");
|
||||||
}
|
}
|
||||||
|
|
||||||
const user = session.user;
|
const user: ProfileUser = {
|
||||||
|
id: session.user.id,
|
||||||
|
name: userData?.name ?? session.user.name ?? null,
|
||||||
|
email: userData?.email ?? session.user.email,
|
||||||
|
image: userData?.image ?? session.user.image ?? null,
|
||||||
|
roles: userData?.systemRoles as ProfileUser["roles"],
|
||||||
|
};
|
||||||
|
|
||||||
return <ProfileContent user={user} />;
|
return <ProfileContent user={user} />;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import {
|
|||||||
} from "~/components/ui/entity-view";
|
} from "~/components/ui/entity-view";
|
||||||
import { useBreadcrumbsEffect } from "~/components/ui/breadcrumb-provider";
|
import { useBreadcrumbsEffect } from "~/components/ui/breadcrumb-provider";
|
||||||
import { api } from "~/trpc/react";
|
import { api } from "~/trpc/react";
|
||||||
import { useSession } from "next-auth/react";
|
import { useSession } from "~/lib/auth-client";
|
||||||
import { useStudyManagement } from "~/hooks/useStudyManagement";
|
import { useStudyManagement } from "~/hooks/useStudyManagement";
|
||||||
|
|
||||||
interface ExperimentDetailPageProps {
|
interface ExperimentDetailPageProps {
|
||||||
@@ -99,6 +99,9 @@ export default function ExperimentDetailPage({
|
|||||||
params,
|
params,
|
||||||
}: ExperimentDetailPageProps) {
|
}: ExperimentDetailPageProps) {
|
||||||
const { data: session } = useSession();
|
const { data: session } = useSession();
|
||||||
|
const { data: userData } = api.auth.me.useQuery(undefined, {
|
||||||
|
enabled: !!session?.user,
|
||||||
|
});
|
||||||
const [experiment, setExperiment] = useState<Experiment | null>(null);
|
const [experiment, setExperiment] = useState<Experiment | null>(null);
|
||||||
const [trials, setTrials] = useState<Trial[]>([]);
|
const [trials, setTrials] = useState<Trial[]>([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
@@ -181,7 +184,7 @@ export default function ExperimentDetailPage({
|
|||||||
const description = experiment.description;
|
const description = experiment.description;
|
||||||
|
|
||||||
// Check if user can edit this experiment
|
// Check if user can edit this experiment
|
||||||
const userRoles = session?.user?.roles?.map((r) => r.role) ?? [];
|
const userRoles = userData?.roles ?? [];
|
||||||
const canEdit =
|
const canEdit =
|
||||||
userRoles.includes("administrator") || userRoles.includes("researcher");
|
userRoles.includes("administrator") || userRoles.includes("researcher");
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useSession } from "next-auth/react";
|
import { useSession } from "~/lib/auth-client";
|
||||||
import { notFound } from "next/navigation";
|
import { notFound } from "next/navigation";
|
||||||
import {
|
import {
|
||||||
FileText,
|
FileText,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import {
|
|||||||
} from "~/components/ui/entity-view";
|
} from "~/components/ui/entity-view";
|
||||||
import { PageHeader } from "~/components/ui/page-header";
|
import { PageHeader } from "~/components/ui/page-header";
|
||||||
import { useBreadcrumbsEffect } from "~/components/ui/breadcrumb-provider";
|
import { useBreadcrumbsEffect } from "~/components/ui/breadcrumb-provider";
|
||||||
import { useSession } from "next-auth/react";
|
import { useSession } from "~/lib/auth-client";
|
||||||
import { api } from "~/trpc/react";
|
import { api } from "~/trpc/react";
|
||||||
|
|
||||||
interface StudyDetailPageProps {
|
interface StudyDetailPageProps {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { WizardView } from "~/components/trials/views/WizardView";
|
|||||||
import { ObserverView } from "~/components/trials/views/ObserverView";
|
import { ObserverView } from "~/components/trials/views/ObserverView";
|
||||||
import { ParticipantView } from "~/components/trials/views/ParticipantView";
|
import { ParticipantView } from "~/components/trials/views/ParticipantView";
|
||||||
import { api } from "~/trpc/react";
|
import { api } from "~/trpc/react";
|
||||||
import { useSession } from "next-auth/react";
|
import { useSession } from "~/lib/auth-client";
|
||||||
|
|
||||||
function WizardPageContent() {
|
function WizardPageContent() {
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
@@ -25,6 +25,11 @@ function WizardPageContent() {
|
|||||||
const { study } = useSelectedStudyDetails();
|
const { study } = useSelectedStudyDetails();
|
||||||
const { data: session } = useSession();
|
const { data: session } = useSession();
|
||||||
|
|
||||||
|
// Get user roles
|
||||||
|
const { data: userData } = api.auth.me.useQuery(undefined, {
|
||||||
|
enabled: !!session?.user,
|
||||||
|
});
|
||||||
|
|
||||||
// Get trial data
|
// Get trial data
|
||||||
const {
|
const {
|
||||||
data: trial,
|
data: trial,
|
||||||
@@ -67,7 +72,7 @@ function WizardPageContent() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Default role logic based on user
|
// Default role logic based on user
|
||||||
const userRole = session.user.roles?.[0]?.role ?? "observer";
|
const userRole = userData?.roles?.[0] ?? "observer";
|
||||||
if (userRole === "administrator" || userRole === "researcher") {
|
if (userRole === "administrator" || userRole === "researcher") {
|
||||||
return "wizard";
|
return "wizard";
|
||||||
}
|
}
|
||||||
@@ -188,6 +193,7 @@ function WizardPageContent() {
|
|||||||
name: trial.experiment.name,
|
name: trial.experiment.name,
|
||||||
description: trial.experiment.description,
|
description: trial.experiment.description,
|
||||||
studyId: trial.experiment.studyId,
|
studyId: trial.experiment.studyId,
|
||||||
|
robotId: trial.experiment.robotId,
|
||||||
},
|
},
|
||||||
participant: {
|
participant: {
|
||||||
id: trial.participant.id,
|
id: trial.participant.id,
|
||||||
|
|||||||
4
src/app/api/auth/[...all]/route.ts
Executable file
4
src/app/api/auth/[...all]/route.ts
Executable file
@@ -0,0 +1,4 @@
|
|||||||
|
import { auth } from "~/lib/auth";
|
||||||
|
import { toNextJsHandler } from "better-auth/next-js";
|
||||||
|
|
||||||
|
export const { GET, POST } = toNextJsHandler(auth);
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
import { handlers } from "~/server/auth";
|
|
||||||
|
|
||||||
export const { GET, POST } = handlers;
|
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import { and, eq } from "drizzle-orm";
|
import { and, eq } from "drizzle-orm";
|
||||||
import { NextResponse, type NextRequest } from "next/server";
|
import { NextResponse, type NextRequest } from "next/server";
|
||||||
|
import { headers } from "next/headers";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import {
|
import {
|
||||||
generateFileKey,
|
generateFileKey,
|
||||||
@@ -7,7 +8,7 @@ import {
|
|||||||
uploadFile,
|
uploadFile,
|
||||||
validateFile,
|
validateFile,
|
||||||
} from "~/lib/storage/minio";
|
} from "~/lib/storage/minio";
|
||||||
import { auth } from "~/server/auth";
|
import { auth } from "~/lib/auth";
|
||||||
import { db } from "~/server/db";
|
import { db } from "~/server/db";
|
||||||
import {
|
import {
|
||||||
experiments,
|
experiments,
|
||||||
@@ -28,7 +29,9 @@ const uploadSchema = z.object({
|
|||||||
export async function POST(request: NextRequest) {
|
export async function POST(request: NextRequest) {
|
||||||
try {
|
try {
|
||||||
// Check authentication
|
// Check authentication
|
||||||
const session = await auth();
|
const session = await auth.api.getSession({
|
||||||
|
headers: await headers(),
|
||||||
|
});
|
||||||
if (!session?.user) {
|
if (!session?.user) {
|
||||||
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
||||||
}
|
}
|
||||||
@@ -181,7 +184,9 @@ export async function POST(request: NextRequest) {
|
|||||||
// Generate presigned upload URL for direct client uploads
|
// Generate presigned upload URL for direct client uploads
|
||||||
export async function GET(request: NextRequest) {
|
export async function GET(request: NextRequest) {
|
||||||
try {
|
try {
|
||||||
const session = await auth();
|
const session = await auth.api.getSession({
|
||||||
|
headers: await headers(),
|
||||||
|
});
|
||||||
if (!session?.user) {
|
if (!session?.user) {
|
||||||
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { signIn } from "next-auth/react";
|
import { signIn } from "~/lib/auth-client";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
@@ -37,22 +37,21 @@ export default function SignInPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await signIn("credentials", {
|
const result = await signIn.email({
|
||||||
email,
|
email,
|
||||||
password,
|
password,
|
||||||
redirect: false,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (result?.error) {
|
if (result.error) {
|
||||||
setError("Invalid email or password");
|
setError(result.error.message || "Invalid email or password");
|
||||||
} else {
|
} else {
|
||||||
router.push("/");
|
router.push("/");
|
||||||
router.refresh();
|
router.refresh();
|
||||||
}
|
}
|
||||||
} catch (error: unknown) {
|
} catch (err: unknown) {
|
||||||
setError(
|
setError(
|
||||||
error instanceof Error
|
err instanceof Error
|
||||||
? error.message
|
? err.message
|
||||||
: "An error occurred. Please try again.",
|
: "An error occurred. Please try again.",
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { signOut, useSession } from "next-auth/react";
|
import { signOut, useSession } from "~/lib/auth-client";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
@@ -14,33 +14,29 @@ import {
|
|||||||
} from "~/components/ui/card";
|
} from "~/components/ui/card";
|
||||||
|
|
||||||
export default function SignOutPage() {
|
export default function SignOutPage() {
|
||||||
const { data: session, status } = useSession();
|
const { data: session, isPending } = useSession();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [isSigningOut, setIsSigningOut] = useState(false);
|
const [isSigningOut, setIsSigningOut] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// If user is not logged in, redirect to home
|
if (!isPending && !session) {
|
||||||
if (status === "loading") return; // Still loading
|
|
||||||
if (!session) {
|
|
||||||
router.push("/");
|
router.push("/");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}, [session, status, router]);
|
}, [session, isPending, router]);
|
||||||
|
|
||||||
const handleSignOut = async () => {
|
const handleSignOut = async () => {
|
||||||
setIsSigningOut(true);
|
setIsSigningOut(true);
|
||||||
try {
|
try {
|
||||||
await signOut({
|
await signOut();
|
||||||
callbackUrl: "/",
|
router.push("/");
|
||||||
redirect: true,
|
router.refresh();
|
||||||
});
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error signing out:", error);
|
console.error("Error signing out:", error);
|
||||||
setIsSigningOut(false);
|
setIsSigningOut(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (status === "loading") {
|
if (isPending) {
|
||||||
return (
|
return (
|
||||||
<div className="flex min-h-screen items-center justify-center bg-gradient-to-br from-slate-50 to-slate-100">
|
<div className="flex min-h-screen items-center justify-center bg-gradient-to-br from-slate-50 to-slate-100">
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
@@ -52,7 +48,7 @@ export default function SignOutPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!session) {
|
if (!session) {
|
||||||
return null; // Will redirect via useEffect
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -80,7 +76,7 @@ export default function SignOutPage() {
|
|||||||
<div className="rounded-md bg-blue-50 p-3 text-sm text-blue-700">
|
<div className="rounded-md bg-blue-50 p-3 text-sm text-blue-700">
|
||||||
<p className="font-medium">
|
<p className="font-medium">
|
||||||
Currently signed in as:{" "}
|
Currently signed in as:{" "}
|
||||||
{session.user.name ?? session.user.email}
|
{session.user?.name ?? session.user?.email}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -103,7 +99,8 @@ export default function SignOutPage() {
|
|||||||
{/* Footer */}
|
{/* Footer */}
|
||||||
<div className="mt-8 text-center text-xs text-slate-500">
|
<div className="mt-8 text-center text-xs text-slate-500">
|
||||||
<p>
|
<p>
|
||||||
© 2024 HRIStudio. A platform for Human-Robot Interaction research.
|
© {new Date().getFullYear()} HRIStudio. A platform for Human-Robot
|
||||||
|
Interaction research.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ import { Badge } from "~/components/ui/badge";
|
|||||||
import { ScrollArea } from "~/components/ui/scroll-area";
|
import { ScrollArea } from "~/components/ui/scroll-area";
|
||||||
import { api } from "~/trpc/react";
|
import { api } from "~/trpc/react";
|
||||||
import { useTour } from "~/components/onboarding/TourProvider";
|
import { useTour } from "~/components/onboarding/TourProvider";
|
||||||
import { useSession } from "next-auth/react";
|
import { useSession } from "~/lib/auth-client";
|
||||||
|
|
||||||
export default function DashboardPage() {
|
export default function DashboardPage() {
|
||||||
const { startTour } = useTour();
|
const { startTour } = useTour();
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import "~/styles/globals.css";
|
|||||||
import { type Metadata } from "next";
|
import { type Metadata } from "next";
|
||||||
import { Inter } from "next/font/google";
|
import { Inter } from "next/font/google";
|
||||||
|
|
||||||
import { SessionProvider } from "next-auth/react";
|
|
||||||
import { TRPCReactProvider } from "~/trpc/react";
|
import { TRPCReactProvider } from "~/trpc/react";
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
@@ -24,9 +23,7 @@ export default function RootLayout({
|
|||||||
return (
|
return (
|
||||||
<html lang="en" className={`${inter.variable}`}>
|
<html lang="en" className={`${inter.variable}`}>
|
||||||
<body>
|
<body>
|
||||||
<SessionProvider>
|
<TRPCReactProvider>{children}</TRPCReactProvider>
|
||||||
<TRPCReactProvider>{children}</TRPCReactProvider>
|
|
||||||
</SessionProvider>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
import { headers } from "next/headers";
|
||||||
import { Button } from "~/components/ui/button";
|
import { Button } from "~/components/ui/button";
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from "~/components/ui/card";
|
import { Card, CardContent, CardHeader, CardTitle } from "~/components/ui/card";
|
||||||
import { Badge } from "~/components/ui/badge";
|
import { Badge } from "~/components/ui/badge";
|
||||||
import { Logo } from "~/components/ui/logo";
|
import { Logo } from "~/components/ui/logo";
|
||||||
import { auth } from "~/server/auth";
|
import { auth } from "~/lib/auth";
|
||||||
import {
|
import {
|
||||||
ArrowRight,
|
ArrowRight,
|
||||||
Beaker,
|
Beaker,
|
||||||
@@ -20,7 +21,9 @@ import {
|
|||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
|
|
||||||
export default async function Home() {
|
export default async function Home() {
|
||||||
const session = await auth();
|
const session = await auth.api.getSession({
|
||||||
|
headers: await headers(),
|
||||||
|
});
|
||||||
|
|
||||||
if (session?.user) {
|
if (session?.user) {
|
||||||
redirect("/dashboard");
|
redirect("/dashboard");
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
import { headers } from "next/headers";
|
||||||
import { Button } from "~/components/ui/button";
|
import { Button } from "~/components/ui/button";
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
@@ -7,10 +8,12 @@ import {
|
|||||||
CardHeader,
|
CardHeader,
|
||||||
CardTitle,
|
CardTitle,
|
||||||
} from "~/components/ui/card";
|
} from "~/components/ui/card";
|
||||||
import { auth } from "~/server/auth";
|
import { auth } from "~/lib/auth";
|
||||||
|
|
||||||
export default async function UnauthorizedPage() {
|
export default async function UnauthorizedPage() {
|
||||||
const session = await auth();
|
const session = await auth.api.getSession({
|
||||||
|
headers: await headers(),
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex min-h-screen items-center justify-center bg-gradient-to-br from-slate-50 to-slate-100 px-4">
|
<div className="flex min-h-screen items-center justify-center bg-gradient-to-br from-slate-50 to-slate-100 px-4">
|
||||||
@@ -60,13 +63,6 @@ export default async function UnauthorizedPage() {
|
|||||||
<div className="rounded-md bg-blue-50 p-3 text-sm text-blue-700">
|
<div className="rounded-md bg-blue-50 p-3 text-sm text-blue-700">
|
||||||
<p className="font-medium">Current User:</p>
|
<p className="font-medium">Current User:</p>
|
||||||
<p>{session.user.name ?? session.user.email}</p>
|
<p>{session.user.name ?? session.user.email}</p>
|
||||||
{session.user.roles && session.user.roles.length > 0 ? (
|
|
||||||
<p className="mt-1">
|
|
||||||
Roles: {session.user.roles.map((r) => r.role).join(", ")}
|
|
||||||
</p>
|
|
||||||
) : (
|
|
||||||
<p className="mt-1">No roles assigned</p>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
import React, { useEffect, useRef } from "react";
|
import React, { useEffect, useRef } from "react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { usePathname } from "next/navigation";
|
import { usePathname } from "next/navigation";
|
||||||
import { signOut, useSession } from "next-auth/react";
|
import { signOut, useSession } from "~/lib/auth-client";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import {
|
import {
|
||||||
BarChart3,
|
BarChart3,
|
||||||
@@ -203,7 +203,8 @@ export function AppSidebar({
|
|||||||
: [];
|
: [];
|
||||||
|
|
||||||
const handleSignOut = async () => {
|
const handleSignOut = async () => {
|
||||||
await signOut({ callbackUrl: "/" });
|
await signOut();
|
||||||
|
window.location.href = "/";
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleStudySelect = async (studyId: string) => {
|
const handleStudySelect = async (studyId: string) => {
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ export const WizardInterface = React.memo(function WizardInterface({
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Robot initialization mutation (for startup routine)
|
// Robot initialization mutation (for startup routine)
|
||||||
const initializeRobotMutation = api.robots.initialize.useMutation({
|
const initializeRobotMutation = api.robots.plugins.initialize.useMutation({
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
toast.success("Robot initialized", {
|
toast.success("Robot initialized", {
|
||||||
description: "Autonomous Life disabled and robot awake.",
|
description: "Autonomous Life disabled and robot awake.",
|
||||||
@@ -188,7 +188,7 @@ export const WizardInterface = React.memo(function WizardInterface({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const executeSystemActionMutation =
|
const executeSystemActionMutation =
|
||||||
api.robots.executeSystemAction.useMutation();
|
api.robots.plugins.executeSystemAction.useMutation();
|
||||||
const [isCompleting, setIsCompleting] = useState(false);
|
const [isCompleting, setIsCompleting] = useState(false);
|
||||||
|
|
||||||
// Map database step types to component step types
|
// Map database step types to component step types
|
||||||
@@ -579,14 +579,20 @@ export const WizardInterface = React.memo(function WizardInterface({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleNextStep = (targetIndex?: number) => {
|
const handleNextStep = (targetIndex?: number) => {
|
||||||
console.log(`[DEBUG] handleNextStep called: targetIndex=${targetIndex}, currentStepIndex=${currentStepIndex}`);
|
console.log(
|
||||||
console.log(`[DEBUG] Steps: ${steps.map((s, i) => `${i}:${s.name}`).join(' | ')}`);
|
`[DEBUG] handleNextStep called: targetIndex=${targetIndex}, currentStepIndex=${currentStepIndex}`,
|
||||||
|
);
|
||||||
|
console.log(
|
||||||
|
`[DEBUG] Steps: ${steps.map((s, i) => `${i}:${s.name}`).join(" | ")}`,
|
||||||
|
);
|
||||||
|
|
||||||
// If explicit target provided (from branching choice), use it
|
// If explicit target provided (from branching choice), use it
|
||||||
if (typeof targetIndex === "number") {
|
if (typeof targetIndex === "number") {
|
||||||
// Find step by index to ensure safety
|
// Find step by index to ensure safety
|
||||||
if (targetIndex >= 0 && targetIndex < steps.length) {
|
if (targetIndex >= 0 && targetIndex < steps.length) {
|
||||||
console.log(`[WizardInterface] Manual jump to step ${targetIndex} (${steps[targetIndex]?.name})`);
|
console.log(
|
||||||
|
`[WizardInterface] Manual jump to step ${targetIndex} (${steps[targetIndex]?.name})`,
|
||||||
|
);
|
||||||
|
|
||||||
// Log manual jump
|
// Log manual jump
|
||||||
logEventMutation.mutate({
|
logEventMutation.mutate({
|
||||||
@@ -613,7 +619,9 @@ export const WizardInterface = React.memo(function WizardInterface({
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
console.warn(`[DEBUG] Invalid targetIndex: ${targetIndex}, steps.length=${steps.length}`);
|
console.warn(
|
||||||
|
`[DEBUG] Invalid targetIndex: ${targetIndex}, steps.length=${steps.length}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -868,10 +876,14 @@ export const WizardInterface = React.memo(function WizardInterface({
|
|||||||
if (parameters.nextStepId) {
|
if (parameters.nextStepId) {
|
||||||
const nextId = String(parameters.nextStepId);
|
const nextId = String(parameters.nextStepId);
|
||||||
const targetIndex = steps.findIndex((s) => s.id === nextId);
|
const targetIndex = steps.findIndex((s) => s.id === nextId);
|
||||||
console.log(`[DEBUG] Branch choice: value=${parameters.value}, label=${parameters.label}`);
|
console.log(
|
||||||
|
`[DEBUG] Branch choice: value=${parameters.value}, label=${parameters.label}`,
|
||||||
|
);
|
||||||
console.log(`[DEBUG] Target step ID: ${nextId}`);
|
console.log(`[DEBUG] Target step ID: ${nextId}`);
|
||||||
console.log(`[DEBUG] Target index in steps array: ${targetIndex}`);
|
console.log(`[DEBUG] Target index in steps array: ${targetIndex}`);
|
||||||
console.log(`[DEBUG] Available step IDs: ${steps.map(s => s.id).join(', ')}`);
|
console.log(
|
||||||
|
`[DEBUG] Available step IDs: ${steps.map((s) => s.id).join(", ")}`,
|
||||||
|
);
|
||||||
if (targetIndex !== -1) {
|
if (targetIndex !== -1) {
|
||||||
console.log(
|
console.log(
|
||||||
`[WizardInterface] Choice-based jump to step ${targetIndex} (${nextId})`,
|
`[WizardInterface] Choice-based jump to step ${targetIndex} (${nextId})`,
|
||||||
|
|||||||
@@ -403,8 +403,8 @@ export function WizardExecutionPanel({
|
|||||||
size="lg"
|
size="lg"
|
||||||
onClick={
|
onClick={
|
||||||
currentStepIndex === steps.length - 1
|
currentStepIndex === steps.length - 1
|
||||||
? onCompleteTrial
|
? (onCompleteTrial ?? (() => {}))
|
||||||
: () => onNextStep()
|
: () => onNextStep?.()
|
||||||
}
|
}
|
||||||
className={`w-full max-w-sm text-white shadow-lg transition-all hover:scale-[1.02] ${
|
className={`w-full max-w-sm text-white shadow-lg transition-all hover:scale-[1.02] ${
|
||||||
currentStepIndex === steps.length - 1
|
currentStepIndex === steps.length - 1
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
/* eslint-disable react-hooks/exhaustive-deps */
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
|
|
||||||
import { useSession } from "next-auth/react";
|
import { useSession } from "~/lib/auth-client";
|
||||||
import { useCallback, useEffect, useRef, useState } from "react";
|
import { useCallback, useEffect, useRef, useState } from "react";
|
||||||
|
|
||||||
export type TrialStatus =
|
export type TrialStatus =
|
||||||
|
|||||||
@@ -1,68 +1,15 @@
|
|||||||
// Client-side role utilities without database imports
|
import { createAuthClient } from "better-auth/react";
|
||||||
import type { Session } from "next-auth";
|
|
||||||
|
export const authClient = createAuthClient({
|
||||||
|
baseURL: process.env.NEXT_PUBLIC_APP_URL || "http://localhost:3000",
|
||||||
|
});
|
||||||
|
|
||||||
|
export const { signIn, signOut, useSession } = authClient;
|
||||||
|
|
||||||
// Role types from schema
|
// Role types from schema
|
||||||
export type SystemRole = "administrator" | "researcher" | "wizard" | "observer";
|
export type SystemRole = "administrator" | "researcher" | "wizard" | "observer";
|
||||||
export type StudyRole = "owner" | "researcher" | "wizard" | "observer";
|
export type StudyRole = "owner" | "researcher" | "wizard" | "observer";
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the current user has a specific system role
|
|
||||||
*/
|
|
||||||
export function hasRole(session: Session | null, role: SystemRole): boolean {
|
|
||||||
if (!session?.user?.roles) return false;
|
|
||||||
return session.user.roles.some((userRole) => userRole.role === role);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the current user is an administrator
|
|
||||||
*/
|
|
||||||
export function isAdmin(session: Session | null): boolean {
|
|
||||||
return hasRole(session, "administrator");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the current user is a researcher or admin
|
|
||||||
*/
|
|
||||||
export function isResearcher(session: Session | null): boolean {
|
|
||||||
return hasRole(session, "researcher") || isAdmin(session);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the current user is a wizard or admin
|
|
||||||
*/
|
|
||||||
export function isWizard(session: Session | null): boolean {
|
|
||||||
return hasRole(session, "wizard") || isAdmin(session);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the current user has any of the specified roles
|
|
||||||
*/
|
|
||||||
export function hasAnyRole(
|
|
||||||
session: Session | null,
|
|
||||||
roles: SystemRole[],
|
|
||||||
): boolean {
|
|
||||||
if (!session?.user?.roles) return false;
|
|
||||||
return session.user.roles.some((userRole) => roles.includes(userRole.role));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if a user owns or has admin access to a resource
|
|
||||||
*/
|
|
||||||
export function canAccessResource(
|
|
||||||
session: Session | null,
|
|
||||||
resourceOwnerId: string,
|
|
||||||
): boolean {
|
|
||||||
if (!session?.user) return false;
|
|
||||||
|
|
||||||
// Admin can access anything
|
|
||||||
if (isAdmin(session)) return true;
|
|
||||||
|
|
||||||
// Owner can access their own resources
|
|
||||||
if (session.user.id === resourceOwnerId) return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format role for display
|
* Format role for display
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { signOut } from "next-auth/react";
|
import { signOut } from "~/lib/auth-client";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { TRPCClientError } from "@trpc/client";
|
import { TRPCClientError } from "@trpc/client";
|
||||||
|
|
||||||
@@ -104,10 +104,8 @@ export async function handleAuthError(
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
void (async () => {
|
void (async () => {
|
||||||
try {
|
try {
|
||||||
await signOut({
|
await signOut();
|
||||||
callbackUrl: "/",
|
window.location.href = "/";
|
||||||
redirect: true,
|
|
||||||
});
|
|
||||||
} catch (signOutError) {
|
} catch (signOutError) {
|
||||||
console.error("Error during sign out:", signOutError);
|
console.error("Error during sign out:", signOutError);
|
||||||
// Force redirect if signOut fails
|
// Force redirect if signOut fails
|
||||||
|
|||||||
79
src/lib/auth.ts
Normal file
79
src/lib/auth.ts
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
import { betterAuth } from "better-auth";
|
||||||
|
import { drizzleAdapter } from "@better-auth/drizzle-adapter";
|
||||||
|
import { nextCookies } from "better-auth/next-js";
|
||||||
|
import { db } from "~/server/db";
|
||||||
|
import {
|
||||||
|
users,
|
||||||
|
accounts,
|
||||||
|
sessions,
|
||||||
|
verificationTokens,
|
||||||
|
} from "~/server/db/schema";
|
||||||
|
import bcrypt from "bcryptjs";
|
||||||
|
|
||||||
|
const baseURL =
|
||||||
|
process.env.NEXTAUTH_URL ||
|
||||||
|
process.env.BETTER_AUTH_URL ||
|
||||||
|
"http://localhost:3000";
|
||||||
|
|
||||||
|
export const auth = betterAuth({
|
||||||
|
baseURL,
|
||||||
|
database: drizzleAdapter(db, {
|
||||||
|
provider: "pg",
|
||||||
|
schema: {
|
||||||
|
user: users,
|
||||||
|
account: accounts,
|
||||||
|
session: sessions,
|
||||||
|
verification: verificationTokens,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
emailAndPassword: {
|
||||||
|
enabled: true,
|
||||||
|
password: {
|
||||||
|
hash: async (password: string) => {
|
||||||
|
return bcrypt.hash(password, 12);
|
||||||
|
},
|
||||||
|
verify: async ({
|
||||||
|
hash,
|
||||||
|
password,
|
||||||
|
}: {
|
||||||
|
hash: string;
|
||||||
|
password: string;
|
||||||
|
}) => {
|
||||||
|
return bcrypt.compare(password, hash);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
session: {
|
||||||
|
expiresIn: 60 * 60 * 24 * 30,
|
||||||
|
updateAge: 60 * 60 * 24,
|
||||||
|
modelName: "session",
|
||||||
|
fields: {
|
||||||
|
id: "id",
|
||||||
|
token: "token",
|
||||||
|
userId: "userId",
|
||||||
|
expiresAt: "expiresAt",
|
||||||
|
ipAddress: "ipAddress",
|
||||||
|
userAgent: "userAgent",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
account: {
|
||||||
|
modelName: "account",
|
||||||
|
fields: {
|
||||||
|
id: "id",
|
||||||
|
providerId: "providerId",
|
||||||
|
accountId: "accountId",
|
||||||
|
userId: "userId",
|
||||||
|
accessToken: "accessToken",
|
||||||
|
refreshToken: "refreshToken",
|
||||||
|
expiresAt: "expiresAt",
|
||||||
|
scope: "scope",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
pages: {
|
||||||
|
signIn: "/auth/signin",
|
||||||
|
error: "/auth/error",
|
||||||
|
},
|
||||||
|
plugins: [nextCookies()],
|
||||||
|
});
|
||||||
|
|
||||||
|
export type Session = typeof auth.$Infer.Session;
|
||||||
@@ -38,12 +38,15 @@ export const authRouter = createTRPCRouter({
|
|||||||
const hashedPassword = await bcrypt.hash(password, 12);
|
const hashedPassword = await bcrypt.hash(password, 12);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Create user
|
// Create user with text ID
|
||||||
|
const userId = `user_${crypto.randomUUID()}`;
|
||||||
const newUsers = await ctx.db
|
const newUsers = await ctx.db
|
||||||
.insert(users)
|
.insert(users)
|
||||||
.values({
|
.values({
|
||||||
|
id: userId,
|
||||||
name,
|
name,
|
||||||
email,
|
email,
|
||||||
|
emailVerified: false,
|
||||||
password: hashedPassword,
|
password: hashedPassword,
|
||||||
})
|
})
|
||||||
.returning({
|
.returning({
|
||||||
|
|||||||
@@ -428,7 +428,7 @@ export const dashboardRouter = createTRPCRouter({
|
|||||||
session: {
|
session: {
|
||||||
userId: ctx.session.user.id,
|
userId: ctx.session.user.id,
|
||||||
userEmail: ctx.session.user.email,
|
userEmail: ctx.session.user.email,
|
||||||
userRole: ctx.session.user.roles?.[0]?.role ?? null,
|
userRole: systemRoles[0]?.role ?? null,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ import superjson from "superjson";
|
|||||||
import { ZodError } from "zod";
|
import { ZodError } from "zod";
|
||||||
|
|
||||||
import { and, eq } from "drizzle-orm";
|
import { and, eq } from "drizzle-orm";
|
||||||
import { auth } from "~/server/auth";
|
import { headers } from "next/headers";
|
||||||
|
import { auth } from "~/lib/auth";
|
||||||
import { db } from "~/server/db";
|
import { db } from "~/server/db";
|
||||||
import { userSystemRoles } from "~/server/db/schema";
|
import { userSystemRoles } from "~/server/db/schema";
|
||||||
|
|
||||||
@@ -29,7 +30,9 @@ import { userSystemRoles } from "~/server/db/schema";
|
|||||||
* @see https://trpc.io/docs/server/context
|
* @see https://trpc.io/docs/server/context
|
||||||
*/
|
*/
|
||||||
export const createTRPCContext = async (opts: { headers: Headers }) => {
|
export const createTRPCContext = async (opts: { headers: Headers }) => {
|
||||||
const session = await auth();
|
const session = await auth.api.getSession({
|
||||||
|
headers: await headers(),
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
db,
|
db,
|
||||||
|
|||||||
@@ -1,134 +0,0 @@
|
|||||||
import bcrypt from "bcryptjs";
|
|
||||||
import { eq } from "drizzle-orm";
|
|
||||||
import { type DefaultSession, type NextAuthConfig } from "next-auth";
|
|
||||||
import Credentials from "next-auth/providers/credentials";
|
|
||||||
import { z } from "zod";
|
|
||||||
|
|
||||||
import { db } from "~/server/db";
|
|
||||||
import { users } from "~/server/db/schema";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Module augmentation for `next-auth` types. Allows us to add custom properties to the `session`
|
|
||||||
* object and keep type safety.
|
|
||||||
*
|
|
||||||
* @see https://next-auth.js.org/getting-started/typescript#module-augmentation
|
|
||||||
*/
|
|
||||||
declare module "next-auth" {
|
|
||||||
interface Session extends DefaultSession {
|
|
||||||
user: {
|
|
||||||
id: string;
|
|
||||||
roles: Array<{
|
|
||||||
role: "administrator" | "researcher" | "wizard" | "observer";
|
|
||||||
grantedAt: Date;
|
|
||||||
grantedBy: string | null;
|
|
||||||
}>;
|
|
||||||
} & DefaultSession["user"];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface User {
|
|
||||||
id: string;
|
|
||||||
email: string;
|
|
||||||
name: string | null;
|
|
||||||
image: string | null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Options for NextAuth.js used to configure adapters, providers, callbacks, etc.
|
|
||||||
*
|
|
||||||
* @see https://next-auth.js.org/configuration/options
|
|
||||||
*/
|
|
||||||
|
|
||||||
export const authConfig: NextAuthConfig = {
|
|
||||||
session: {
|
|
||||||
strategy: "jwt" as const,
|
|
||||||
maxAge: 30 * 24 * 60 * 60, // 30 days
|
|
||||||
},
|
|
||||||
pages: {
|
|
||||||
signIn: "/auth/signin",
|
|
||||||
error: "/auth/error",
|
|
||||||
},
|
|
||||||
providers: [
|
|
||||||
Credentials({
|
|
||||||
name: "credentials",
|
|
||||||
credentials: {
|
|
||||||
email: { label: "Email", type: "email" },
|
|
||||||
password: { label: "Password", type: "password" },
|
|
||||||
},
|
|
||||||
async authorize(credentials) {
|
|
||||||
const parsed = z
|
|
||||||
.object({
|
|
||||||
email: z.string().email(),
|
|
||||||
password: z.string().min(6),
|
|
||||||
})
|
|
||||||
.safeParse(credentials);
|
|
||||||
|
|
||||||
if (!parsed.success) return null;
|
|
||||||
|
|
||||||
const user = await db.query.users.findFirst({
|
|
||||||
where: eq(users.email, parsed.data.email),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!user?.password) return null;
|
|
||||||
|
|
||||||
const isValidPassword = await bcrypt.compare(
|
|
||||||
parsed.data.password,
|
|
||||||
user.password,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!isValidPassword) return null;
|
|
||||||
|
|
||||||
return {
|
|
||||||
id: user.id,
|
|
||||||
email: user.email,
|
|
||||||
name: user.name,
|
|
||||||
image: user.image,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
callbacks: {
|
|
||||||
jwt: async ({ token, user }) => {
|
|
||||||
if (user) {
|
|
||||||
token.id = user.id;
|
|
||||||
}
|
|
||||||
return token;
|
|
||||||
},
|
|
||||||
session: async ({ session, token }) => {
|
|
||||||
if (token.id && typeof token.id === "string") {
|
|
||||||
// Fetch user roles from database
|
|
||||||
const userWithRoles = await db.query.users.findFirst({
|
|
||||||
where: eq(users.id, token.id),
|
|
||||||
with: {
|
|
||||||
systemRoles: {
|
|
||||||
with: {
|
|
||||||
grantedByUser: {
|
|
||||||
columns: {
|
|
||||||
id: true,
|
|
||||||
name: true,
|
|
||||||
email: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
...session,
|
|
||||||
user: {
|
|
||||||
...session.user,
|
|
||||||
id: token.id,
|
|
||||||
roles:
|
|
||||||
userWithRoles?.systemRoles?.map((sr) => ({
|
|
||||||
role: sr.role,
|
|
||||||
grantedAt: sr.grantedAt,
|
|
||||||
grantedBy: sr.grantedBy,
|
|
||||||
})) ?? [],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return session;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
import NextAuth from "next-auth";
|
|
||||||
import { cache } from "react";
|
|
||||||
|
|
||||||
import { authConfig } from "./config";
|
|
||||||
|
|
||||||
const { auth: uncachedAuth, handlers, signIn, signOut } = NextAuth(authConfig);
|
|
||||||
|
|
||||||
const auth = cache(uncachedAuth);
|
|
||||||
|
|
||||||
export { auth, handlers, signIn, signOut };
|
|
||||||
@@ -1,233 +0,0 @@
|
|||||||
import { and, eq } from "drizzle-orm";
|
|
||||||
import type { Session } from "next-auth";
|
|
||||||
import { redirect } from "next/navigation";
|
|
||||||
import { db } from "~/server/db";
|
|
||||||
import { users, userSystemRoles } from "~/server/db/schema";
|
|
||||||
import { auth } from "./index";
|
|
||||||
|
|
||||||
// Role types from schema
|
|
||||||
export type SystemRole = "administrator" | "researcher" | "wizard" | "observer";
|
|
||||||
export type StudyRole = "owner" | "researcher" | "wizard" | "observer";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the current session or redirect to login
|
|
||||||
*/
|
|
||||||
export async function requireAuth() {
|
|
||||||
const session = await auth();
|
|
||||||
if (!session?.user) {
|
|
||||||
redirect("/auth/signin");
|
|
||||||
}
|
|
||||||
return session;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the current session without redirecting
|
|
||||||
*/
|
|
||||||
export async function getSession() {
|
|
||||||
return await auth();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the current user has a specific system role
|
|
||||||
*/
|
|
||||||
export function hasRole(session: Session | null, role: SystemRole): boolean {
|
|
||||||
if (!session?.user?.roles) return false;
|
|
||||||
return session.user.roles.some((userRole) => userRole.role === role);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the current user is an administrator
|
|
||||||
*/
|
|
||||||
export function isAdmin(session: Session | null): boolean {
|
|
||||||
return hasRole(session, "administrator");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the current user is a researcher or admin
|
|
||||||
*/
|
|
||||||
export function isResearcher(session: Session | null): boolean {
|
|
||||||
return hasRole(session, "researcher") || isAdmin(session);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the current user is a wizard or admin
|
|
||||||
*/
|
|
||||||
export function isWizard(session: Session | null): boolean {
|
|
||||||
return hasRole(session, "wizard") || isAdmin(session);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the current user has any of the specified roles
|
|
||||||
*/
|
|
||||||
export function hasAnyRole(
|
|
||||||
session: Session | null,
|
|
||||||
roles: SystemRole[],
|
|
||||||
): boolean {
|
|
||||||
if (!session?.user?.roles) return false;
|
|
||||||
return session.user.roles.some((userRole) => roles.includes(userRole.role));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Require admin role or redirect
|
|
||||||
*/
|
|
||||||
export async function requireAdmin() {
|
|
||||||
const session = await requireAuth();
|
|
||||||
if (!isAdmin(session)) {
|
|
||||||
redirect("/unauthorized");
|
|
||||||
}
|
|
||||||
return session;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Require researcher role or redirect
|
|
||||||
*/
|
|
||||||
export async function requireResearcher() {
|
|
||||||
const session = await requireAuth();
|
|
||||||
if (!isResearcher(session)) {
|
|
||||||
redirect("/unauthorized");
|
|
||||||
}
|
|
||||||
return session;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get user roles from database
|
|
||||||
*/
|
|
||||||
export async function getUserRoles(userId: string) {
|
|
||||||
const userWithRoles = await db.query.users.findFirst({
|
|
||||||
where: eq(users.id, userId),
|
|
||||||
with: {
|
|
||||||
systemRoles: {
|
|
||||||
with: {
|
|
||||||
grantedByUser: {
|
|
||||||
columns: {
|
|
||||||
id: true,
|
|
||||||
name: true,
|
|
||||||
email: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return userWithRoles?.systemRoles ?? [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Grant a system role to a user
|
|
||||||
*/
|
|
||||||
export async function grantRole(
|
|
||||||
userId: string,
|
|
||||||
role: SystemRole,
|
|
||||||
grantedBy: string,
|
|
||||||
) {
|
|
||||||
// Check if user already has this role
|
|
||||||
const existingRole = await db.query.userSystemRoles.findFirst({
|
|
||||||
where: and(
|
|
||||||
eq(userSystemRoles.userId, userId),
|
|
||||||
eq(userSystemRoles.role, role),
|
|
||||||
),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (existingRole) {
|
|
||||||
throw new Error(`User already has role: ${role}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Grant the role
|
|
||||||
const newRole = await db
|
|
||||||
.insert(userSystemRoles)
|
|
||||||
.values({
|
|
||||||
userId,
|
|
||||||
role,
|
|
||||||
grantedBy,
|
|
||||||
})
|
|
||||||
.returning();
|
|
||||||
|
|
||||||
return newRole[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Revoke a system role from a user
|
|
||||||
*/
|
|
||||||
export async function revokeRole(userId: string, role: SystemRole) {
|
|
||||||
const deletedRole = await db
|
|
||||||
.delete(userSystemRoles)
|
|
||||||
.where(
|
|
||||||
and(eq(userSystemRoles.userId, userId), eq(userSystemRoles.role, role)),
|
|
||||||
)
|
|
||||||
.returning();
|
|
||||||
|
|
||||||
if (deletedRole.length === 0) {
|
|
||||||
throw new Error(`User does not have role: ${role}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return deletedRole[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if a user owns or has admin access to a resource
|
|
||||||
*/
|
|
||||||
export function canAccessResource(
|
|
||||||
session: Session | null,
|
|
||||||
resourceOwnerId: string,
|
|
||||||
): boolean {
|
|
||||||
if (!session?.user) return false;
|
|
||||||
|
|
||||||
// Admin can access anything
|
|
||||||
if (isAdmin(session)) return true;
|
|
||||||
|
|
||||||
// Owner can access their own resources
|
|
||||||
if (session.user.id === resourceOwnerId) return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Format role for display
|
|
||||||
*/
|
|
||||||
export function formatRole(role: SystemRole): string {
|
|
||||||
const roleMap: Record<SystemRole, string> = {
|
|
||||||
administrator: "Administrator",
|
|
||||||
researcher: "Researcher",
|
|
||||||
wizard: "Wizard",
|
|
||||||
observer: "Observer",
|
|
||||||
};
|
|
||||||
|
|
||||||
return roleMap[role] || role;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get role description
|
|
||||||
*/
|
|
||||||
export function getRoleDescription(role: SystemRole): string {
|
|
||||||
const descriptions: Record<SystemRole, string> = {
|
|
||||||
administrator: "Full system access and user management",
|
|
||||||
researcher: "Can create and manage studies and experiments",
|
|
||||||
wizard: "Can control robots during trials and experiments",
|
|
||||||
observer: "Read-only access to studies and trial data",
|
|
||||||
};
|
|
||||||
|
|
||||||
return descriptions[role] || "Unknown role";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get available roles for assignment
|
|
||||||
*/
|
|
||||||
export function getAvailableRoles(): Array<{
|
|
||||||
value: SystemRole;
|
|
||||||
label: string;
|
|
||||||
description: string;
|
|
||||||
}> {
|
|
||||||
const roles: SystemRole[] = [
|
|
||||||
"administrator",
|
|
||||||
"researcher",
|
|
||||||
"wizard",
|
|
||||||
"observer",
|
|
||||||
];
|
|
||||||
|
|
||||||
return roles.map((role) => ({
|
|
||||||
value: role,
|
|
||||||
label: formatRole(role),
|
|
||||||
description: getRoleDescription(role),
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
@@ -15,7 +15,6 @@ import {
|
|||||||
uuid,
|
uuid,
|
||||||
varchar,
|
varchar,
|
||||||
} from "drizzle-orm/pg-core";
|
} from "drizzle-orm/pg-core";
|
||||||
import { type AdapterAccount } from "next-auth/adapters";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is an example of how to use the multi-project schema feature of Drizzle ORM. Use the same
|
* This is an example of how to use the multi-project schema feature of Drizzle ORM. Use the same
|
||||||
@@ -114,15 +113,12 @@ export const exportStatusEnum = pgEnum("export_status", [
|
|||||||
"failed",
|
"failed",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Users and Authentication
|
// Users and Authentication (Better Auth compatible)
|
||||||
export const users = createTable("user", {
|
export const users = createTable("user", {
|
||||||
id: uuid("id").notNull().primaryKey().defaultRandom(),
|
id: text("id").notNull().primaryKey(),
|
||||||
email: varchar("email", { length: 255 }).notNull().unique(),
|
|
||||||
emailVerified: timestamp("email_verified", {
|
|
||||||
mode: "date",
|
|
||||||
withTimezone: true,
|
|
||||||
}),
|
|
||||||
name: varchar("name", { length: 255 }),
|
name: varchar("name", { length: 255 }),
|
||||||
|
email: varchar("email", { length: 255 }).notNull().unique(),
|
||||||
|
emailVerified: boolean("email_verified").default(false).notNull(),
|
||||||
image: text("image"),
|
image: text("image"),
|
||||||
password: varchar("password", { length: 255 }),
|
password: varchar("password", { length: 255 }),
|
||||||
createdAt: timestamp("created_at", { withTimezone: true })
|
createdAt: timestamp("created_at", { withTimezone: true })
|
||||||
@@ -137,23 +133,20 @@ export const users = createTable("user", {
|
|||||||
export const accounts = createTable(
|
export const accounts = createTable(
|
||||||
"account",
|
"account",
|
||||||
{
|
{
|
||||||
userId: uuid("user_id")
|
id: text("id").notNull().primaryKey(),
|
||||||
|
userId: text("user_id")
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => users.id, { onDelete: "cascade" }),
|
.references(() => users.id, { onDelete: "cascade" }),
|
||||||
type: varchar("type", { length: 255 })
|
providerId: varchar("provider_id", { length: 255 }).notNull(),
|
||||||
.$type<AdapterAccount["type"]>()
|
accountId: varchar("account_id", { length: 255 }).notNull(),
|
||||||
.notNull(),
|
|
||||||
provider: varchar("provider", { length: 255 }).notNull(),
|
|
||||||
providerAccountId: varchar("provider_account_id", {
|
|
||||||
length: 255,
|
|
||||||
}).notNull(),
|
|
||||||
refreshToken: text("refresh_token"),
|
refreshToken: text("refresh_token"),
|
||||||
accessToken: text("access_token"),
|
accessToken: text("access_token"),
|
||||||
expiresAt: integer("expires_at"),
|
expiresAt: timestamp("expires_at", {
|
||||||
tokenType: varchar("token_type", { length: 255 }),
|
mode: "date",
|
||||||
|
withTimezone: true,
|
||||||
|
}),
|
||||||
scope: varchar("scope", { length: 255 }),
|
scope: varchar("scope", { length: 255 }),
|
||||||
idToken: text("id_token"),
|
password: text("password"),
|
||||||
sessionState: varchar("session_state", { length: 255 }),
|
|
||||||
createdAt: timestamp("created_at", { withTimezone: true })
|
createdAt: timestamp("created_at", { withTimezone: true })
|
||||||
.default(sql`CURRENT_TIMESTAMP`)
|
.default(sql`CURRENT_TIMESTAMP`)
|
||||||
.notNull(),
|
.notNull(),
|
||||||
@@ -162,25 +155,25 @@ export const accounts = createTable(
|
|||||||
.notNull(),
|
.notNull(),
|
||||||
},
|
},
|
||||||
(table) => ({
|
(table) => ({
|
||||||
compoundKey: primaryKey({
|
|
||||||
columns: [table.provider, table.providerAccountId],
|
|
||||||
}),
|
|
||||||
userIdIdx: index("account_user_id_idx").on(table.userId),
|
userIdIdx: index("account_user_id_idx").on(table.userId),
|
||||||
|
providerAccountIdx: unique().on(table.providerId, table.accountId),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
export const sessions = createTable(
|
export const sessions = createTable(
|
||||||
"session",
|
"session",
|
||||||
{
|
{
|
||||||
id: uuid("id").notNull().primaryKey().defaultRandom(),
|
id: text("id").notNull().primaryKey(),
|
||||||
sessionToken: varchar("session_token", { length: 255 }).notNull().unique(),
|
token: varchar("token", { length: 255 }).notNull().unique(),
|
||||||
userId: uuid("user_id")
|
userId: text("user_id")
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => users.id, { onDelete: "cascade" }),
|
.references(() => users.id, { onDelete: "cascade" }),
|
||||||
expires: timestamp("expires", {
|
expiresAt: timestamp("expires_at", {
|
||||||
mode: "date",
|
mode: "date",
|
||||||
withTimezone: true,
|
withTimezone: true,
|
||||||
}).notNull(),
|
}).notNull(),
|
||||||
|
ipAddress: text("ip_address"),
|
||||||
|
userAgent: text("user_agent"),
|
||||||
createdAt: timestamp("created_at", { withTimezone: true })
|
createdAt: timestamp("created_at", { withTimezone: true })
|
||||||
.default(sql`CURRENT_TIMESTAMP`)
|
.default(sql`CURRENT_TIMESTAMP`)
|
||||||
.notNull(),
|
.notNull(),
|
||||||
@@ -196,18 +189,25 @@ export const sessions = createTable(
|
|||||||
export const verificationTokens = createTable(
|
export const verificationTokens = createTable(
|
||||||
"verification_token",
|
"verification_token",
|
||||||
{
|
{
|
||||||
|
id: text("id").notNull().primaryKey(),
|
||||||
identifier: varchar("identifier", { length: 255 }).notNull(),
|
identifier: varchar("identifier", { length: 255 }).notNull(),
|
||||||
token: varchar("token", { length: 255 }).notNull().unique(),
|
value: varchar("value", { length: 255 }).notNull().unique(),
|
||||||
expires: timestamp("expires", {
|
expiresAt: timestamp("expires_at", {
|
||||||
mode: "date",
|
mode: "date",
|
||||||
withTimezone: true,
|
withTimezone: true,
|
||||||
}).notNull(),
|
}).notNull(),
|
||||||
createdAt: timestamp("created_at", { withTimezone: true })
|
createdAt: timestamp("created_at", { withTimezone: true })
|
||||||
.default(sql`CURRENT_TIMESTAMP`)
|
.default(sql`CURRENT_TIMESTAMP`)
|
||||||
.notNull(),
|
.notNull(),
|
||||||
|
updatedAt: timestamp("updated_at", { withTimezone: true })
|
||||||
|
.default(sql`CURRENT_TIMESTAMP`)
|
||||||
|
.notNull(),
|
||||||
},
|
},
|
||||||
(table) => ({
|
(table) => ({
|
||||||
compoundKey: primaryKey({ columns: [table.identifier, table.token] }),
|
identifierIdx: index("verification_token_identifier_idx").on(
|
||||||
|
table.identifier,
|
||||||
|
),
|
||||||
|
valueIdx: index("verification_token_value_idx").on(table.value),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -216,14 +216,14 @@ export const userSystemRoles = createTable(
|
|||||||
"user_system_role",
|
"user_system_role",
|
||||||
{
|
{
|
||||||
id: uuid("id").notNull().primaryKey().defaultRandom(),
|
id: uuid("id").notNull().primaryKey().defaultRandom(),
|
||||||
userId: uuid("user_id")
|
userId: text("user_id")
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => users.id, { onDelete: "cascade" }),
|
.references(() => users.id, { onDelete: "cascade" }),
|
||||||
role: systemRoleEnum("role").notNull(),
|
role: systemRoleEnum("role").notNull(),
|
||||||
grantedAt: timestamp("granted_at", { withTimezone: true })
|
grantedAt: timestamp("granted_at", { withTimezone: true })
|
||||||
.default(sql`CURRENT_TIMESTAMP`)
|
.default(sql`CURRENT_TIMESTAMP`)
|
||||||
.notNull(),
|
.notNull(),
|
||||||
grantedBy: uuid("granted_by").references(() => users.id),
|
grantedBy: text("granted_by").references(() => users.id),
|
||||||
},
|
},
|
||||||
(table) => ({
|
(table) => ({
|
||||||
userRoleUnique: unique().on(table.userId, table.role),
|
userRoleUnique: unique().on(table.userId, table.role),
|
||||||
@@ -263,7 +263,7 @@ export const studies = createTable("study", {
|
|||||||
institution: varchar("institution", { length: 255 }),
|
institution: varchar("institution", { length: 255 }),
|
||||||
irbProtocol: varchar("irb_protocol", { length: 100 }),
|
irbProtocol: varchar("irb_protocol", { length: 100 }),
|
||||||
status: studyStatusEnum("status").default("draft").notNull(),
|
status: studyStatusEnum("status").default("draft").notNull(),
|
||||||
createdBy: uuid("created_by")
|
createdBy: text("created_by")
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => users.id),
|
.references(() => users.id),
|
||||||
createdAt: timestamp("created_at", { withTimezone: true })
|
createdAt: timestamp("created_at", { withTimezone: true })
|
||||||
@@ -284,7 +284,7 @@ export const studyMembers = createTable(
|
|||||||
studyId: uuid("study_id")
|
studyId: uuid("study_id")
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => studies.id, { onDelete: "cascade" }),
|
.references(() => studies.id, { onDelete: "cascade" }),
|
||||||
userId: uuid("user_id")
|
userId: text("user_id")
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => users.id, { onDelete: "cascade" }),
|
.references(() => users.id, { onDelete: "cascade" }),
|
||||||
role: studyMemberRoleEnum("role").notNull(),
|
role: studyMemberRoleEnum("role").notNull(),
|
||||||
@@ -292,7 +292,7 @@ export const studyMembers = createTable(
|
|||||||
joinedAt: timestamp("joined_at", { withTimezone: true })
|
joinedAt: timestamp("joined_at", { withTimezone: true })
|
||||||
.default(sql`CURRENT_TIMESTAMP`)
|
.default(sql`CURRENT_TIMESTAMP`)
|
||||||
.notNull(),
|
.notNull(),
|
||||||
invitedBy: uuid("invited_by").references(() => users.id),
|
invitedBy: text("invited_by").references(() => users.id),
|
||||||
},
|
},
|
||||||
(table) => ({
|
(table) => ({
|
||||||
studyUserUnique: unique().on(table.studyId, table.userId),
|
studyUserUnique: unique().on(table.studyId, table.userId),
|
||||||
@@ -380,7 +380,7 @@ export const experiments = createTable(
|
|||||||
robotId: uuid("robot_id").references(() => robots.id),
|
robotId: uuid("robot_id").references(() => robots.id),
|
||||||
status: experimentStatusEnum("status").default("draft").notNull(),
|
status: experimentStatusEnum("status").default("draft").notNull(),
|
||||||
estimatedDuration: integer("estimated_duration"), // in minutes
|
estimatedDuration: integer("estimated_duration"), // in minutes
|
||||||
createdBy: uuid("created_by")
|
createdBy: text("created_by")
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => users.id),
|
.references(() => users.id),
|
||||||
createdAt: timestamp("created_at", { withTimezone: true })
|
createdAt: timestamp("created_at", { withTimezone: true })
|
||||||
@@ -449,7 +449,7 @@ export const participantDocuments = createTable(
|
|||||||
type: varchar("type", { length: 100 }), // MIME type or custom category
|
type: varchar("type", { length: 100 }), // MIME type or custom category
|
||||||
storagePath: text("storage_path").notNull(),
|
storagePath: text("storage_path").notNull(),
|
||||||
fileSize: integer("file_size"),
|
fileSize: integer("file_size"),
|
||||||
uploadedBy: uuid("uploaded_by").references(() => users.id),
|
uploadedBy: text("uploaded_by").references(() => users.id),
|
||||||
createdAt: timestamp("created_at", { withTimezone: true })
|
createdAt: timestamp("created_at", { withTimezone: true })
|
||||||
.default(sql`CURRENT_TIMESTAMP`)
|
.default(sql`CURRENT_TIMESTAMP`)
|
||||||
.notNull(),
|
.notNull(),
|
||||||
@@ -467,7 +467,7 @@ export const trials = createTable("trial", {
|
|||||||
.notNull()
|
.notNull()
|
||||||
.references(() => experiments.id),
|
.references(() => experiments.id),
|
||||||
participantId: uuid("participant_id").references(() => participants.id),
|
participantId: uuid("participant_id").references(() => participants.id),
|
||||||
wizardId: uuid("wizard_id").references(() => users.id),
|
wizardId: text("wizard_id").references(() => users.id),
|
||||||
sessionNumber: integer("session_number").default(1).notNull(),
|
sessionNumber: integer("session_number").default(1).notNull(),
|
||||||
status: trialStatusEnum("status").default("scheduled").notNull(),
|
status: trialStatusEnum("status").default("scheduled").notNull(),
|
||||||
scheduledAt: timestamp("scheduled_at", { withTimezone: true }),
|
scheduledAt: timestamp("scheduled_at", { withTimezone: true }),
|
||||||
@@ -562,7 +562,7 @@ export const consentForms = createTable(
|
|||||||
title: varchar("title", { length: 255 }).notNull(),
|
title: varchar("title", { length: 255 }).notNull(),
|
||||||
content: text("content").notNull(),
|
content: text("content").notNull(),
|
||||||
active: boolean("active").default(true).notNull(),
|
active: boolean("active").default(true).notNull(),
|
||||||
createdBy: uuid("created_by")
|
createdBy: text("created_by")
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => users.id),
|
.references(() => users.id),
|
||||||
createdAt: timestamp("created_at", { withTimezone: true })
|
createdAt: timestamp("created_at", { withTimezone: true })
|
||||||
@@ -645,7 +645,7 @@ export const studyPlugins = createTable(
|
|||||||
installedAt: timestamp("installed_at", { withTimezone: true })
|
installedAt: timestamp("installed_at", { withTimezone: true })
|
||||||
.default(sql`CURRENT_TIMESTAMP`)
|
.default(sql`CURRENT_TIMESTAMP`)
|
||||||
.notNull(),
|
.notNull(),
|
||||||
installedBy: uuid("installed_by")
|
installedBy: text("installed_by")
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => users.id),
|
.references(() => users.id),
|
||||||
},
|
},
|
||||||
@@ -674,7 +674,7 @@ export const pluginRepositories = createTable(
|
|||||||
updatedAt: timestamp("updated_at", { withTimezone: true })
|
updatedAt: timestamp("updated_at", { withTimezone: true })
|
||||||
.default(sql`CURRENT_TIMESTAMP`)
|
.default(sql`CURRENT_TIMESTAMP`)
|
||||||
.notNull(),
|
.notNull(),
|
||||||
createdBy: uuid("created_by")
|
createdBy: text("created_by")
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => users.id),
|
.references(() => users.id),
|
||||||
},
|
},
|
||||||
@@ -697,7 +697,7 @@ export const trialEvents = createTable(
|
|||||||
.default(sql`CURRENT_TIMESTAMP`)
|
.default(sql`CURRENT_TIMESTAMP`)
|
||||||
.notNull(),
|
.notNull(),
|
||||||
data: jsonb("data").default({}),
|
data: jsonb("data").default({}),
|
||||||
createdBy: uuid("created_by").references(() => users.id), // NULL for system events
|
createdBy: text("created_by").references(() => users.id), // NULL for system events
|
||||||
},
|
},
|
||||||
(table) => ({
|
(table) => ({
|
||||||
trialTimestampIdx: index("trial_events_trial_timestamp_idx").on(
|
trialTimestampIdx: index("trial_events_trial_timestamp_idx").on(
|
||||||
@@ -712,7 +712,7 @@ export const wizardInterventions = createTable("wizard_intervention", {
|
|||||||
trialId: uuid("trial_id")
|
trialId: uuid("trial_id")
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => trials.id, { onDelete: "cascade" }),
|
.references(() => trials.id, { onDelete: "cascade" }),
|
||||||
wizardId: uuid("wizard_id")
|
wizardId: text("wizard_id")
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => users.id),
|
.references(() => users.id),
|
||||||
interventionType: varchar("intervention_type", { length: 100 }).notNull(),
|
interventionType: varchar("intervention_type", { length: 100 }).notNull(),
|
||||||
@@ -771,7 +771,7 @@ export const annotations = createTable("annotation", {
|
|||||||
trialId: uuid("trial_id")
|
trialId: uuid("trial_id")
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => trials.id, { onDelete: "cascade" }),
|
.references(() => trials.id, { onDelete: "cascade" }),
|
||||||
annotatorId: uuid("annotator_id")
|
annotatorId: text("annotator_id")
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => users.id),
|
.references(() => users.id),
|
||||||
timestampStart: timestamp("timestamp_start", {
|
timestampStart: timestamp("timestamp_start", {
|
||||||
@@ -799,7 +799,7 @@ export const activityLogs = createTable(
|
|||||||
studyId: uuid("study_id").references(() => studies.id, {
|
studyId: uuid("study_id").references(() => studies.id, {
|
||||||
onDelete: "cascade",
|
onDelete: "cascade",
|
||||||
}),
|
}),
|
||||||
userId: uuid("user_id").references(() => users.id),
|
userId: text("user_id").references(() => users.id),
|
||||||
action: varchar("action", { length: 100 }).notNull(),
|
action: varchar("action", { length: 100 }).notNull(),
|
||||||
resourceType: varchar("resource_type", { length: 50 }),
|
resourceType: varchar("resource_type", { length: 50 }),
|
||||||
resourceId: uuid("resource_id"),
|
resourceId: uuid("resource_id"),
|
||||||
@@ -824,7 +824,7 @@ export const comments = createTable("comment", {
|
|||||||
parentId: uuid("parent_id"),
|
parentId: uuid("parent_id"),
|
||||||
resourceType: varchar("resource_type", { length: 50 }).notNull(), // 'experiment', 'trial', 'annotation'
|
resourceType: varchar("resource_type", { length: 50 }).notNull(), // 'experiment', 'trial', 'annotation'
|
||||||
resourceId: uuid("resource_id").notNull(),
|
resourceId: uuid("resource_id").notNull(),
|
||||||
authorId: uuid("author_id")
|
authorId: text("author_id")
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => users.id),
|
.references(() => users.id),
|
||||||
content: text("content").notNull(),
|
content: text("content").notNull(),
|
||||||
@@ -846,7 +846,7 @@ export const attachments = createTable("attachment", {
|
|||||||
filePath: text("file_path").notNull(),
|
filePath: text("file_path").notNull(),
|
||||||
contentType: varchar("content_type", { length: 100 }),
|
contentType: varchar("content_type", { length: 100 }),
|
||||||
description: text("description"),
|
description: text("description"),
|
||||||
uploadedBy: uuid("uploaded_by")
|
uploadedBy: text("uploaded_by")
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => users.id),
|
.references(() => users.id),
|
||||||
createdAt: timestamp("created_at", { withTimezone: true })
|
createdAt: timestamp("created_at", { withTimezone: true })
|
||||||
@@ -860,7 +860,7 @@ export const exportJobs = createTable("export_job", {
|
|||||||
studyId: uuid("study_id")
|
studyId: uuid("study_id")
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => studies.id, { onDelete: "cascade" }),
|
.references(() => studies.id, { onDelete: "cascade" }),
|
||||||
requestedBy: uuid("requested_by")
|
requestedBy: text("requested_by")
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => users.id),
|
.references(() => users.id),
|
||||||
exportType: varchar("export_type", { length: 50 }).notNull(), // 'full', 'trials', 'analysis', 'media'
|
exportType: varchar("export_type", { length: 50 }).notNull(), // 'full', 'trials', 'analysis', 'media'
|
||||||
@@ -883,7 +883,7 @@ export const sharedResources = createTable("shared_resource", {
|
|||||||
.references(() => studies.id, { onDelete: "cascade" }),
|
.references(() => studies.id, { onDelete: "cascade" }),
|
||||||
resourceType: varchar("resource_type", { length: 50 }).notNull(),
|
resourceType: varchar("resource_type", { length: 50 }).notNull(),
|
||||||
resourceId: uuid("resource_id").notNull(),
|
resourceId: uuid("resource_id").notNull(),
|
||||||
sharedBy: uuid("shared_by")
|
sharedBy: text("shared_by")
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => users.id),
|
.references(() => users.id),
|
||||||
shareToken: varchar("share_token", { length: 255 }).unique(),
|
shareToken: varchar("share_token", { length: 255 }).unique(),
|
||||||
@@ -901,7 +901,7 @@ export const systemSettings = createTable("system_setting", {
|
|||||||
key: varchar("key", { length: 100 }).notNull().unique(),
|
key: varchar("key", { length: 100 }).notNull().unique(),
|
||||||
value: jsonb("value").notNull(),
|
value: jsonb("value").notNull(),
|
||||||
description: text("description"),
|
description: text("description"),
|
||||||
updatedBy: uuid("updated_by").references(() => users.id),
|
updatedBy: text("updated_by").references(() => users.id),
|
||||||
updatedAt: timestamp("updated_at", { withTimezone: true })
|
updatedAt: timestamp("updated_at", { withTimezone: true })
|
||||||
.default(sql`CURRENT_TIMESTAMP`)
|
.default(sql`CURRENT_TIMESTAMP`)
|
||||||
.notNull(),
|
.notNull(),
|
||||||
@@ -911,7 +911,7 @@ export const auditLogs = createTable(
|
|||||||
"audit_log",
|
"audit_log",
|
||||||
{
|
{
|
||||||
id: uuid("id").notNull().primaryKey().defaultRandom(),
|
id: uuid("id").notNull().primaryKey().defaultRandom(),
|
||||||
userId: uuid("user_id").references(() => users.id),
|
userId: text("user_id").references(() => users.id),
|
||||||
action: varchar("action", { length: 100 }).notNull(),
|
action: varchar("action", { length: 100 }).notNull(),
|
||||||
resourceType: varchar("resource_type", { length: 50 }),
|
resourceType: varchar("resource_type", { length: 50 }),
|
||||||
resourceId: uuid("resource_id"),
|
resourceId: uuid("resource_id"),
|
||||||
|
|||||||
27
src/trpc/query-client.js
Normal file
27
src/trpc/query-client.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.createQueryClient = void 0;
|
||||||
|
var react_query_1 = require("@tanstack/react-query");
|
||||||
|
var superjson_1 = require("superjson");
|
||||||
|
var createQueryClient = function () {
|
||||||
|
return new react_query_1.QueryClient({
|
||||||
|
defaultOptions: {
|
||||||
|
queries: {
|
||||||
|
// With SSR, we usually want to set some default staleTime
|
||||||
|
// above 0 to avoid refetching immediately on the client
|
||||||
|
staleTime: 30 * 1000,
|
||||||
|
},
|
||||||
|
dehydrate: {
|
||||||
|
serializeData: superjson_1.default.serialize,
|
||||||
|
shouldDehydrateQuery: function (query) {
|
||||||
|
return (0, react_query_1.defaultShouldDehydrateQuery)(query) ||
|
||||||
|
query.state.status === "pending";
|
||||||
|
},
|
||||||
|
},
|
||||||
|
hydrate: {
|
||||||
|
deserializeData: superjson_1.default.deserialize,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
exports.createQueryClient = createQueryClient;
|
||||||
59
src/trpc/react.js
vendored
Normal file
59
src/trpc/react.js
vendored
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
"use client";
|
||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.api = void 0;
|
||||||
|
exports.TRPCReactProvider = TRPCReactProvider;
|
||||||
|
var react_query_1 = require("@tanstack/react-query");
|
||||||
|
var client_1 = require("@trpc/client");
|
||||||
|
var react_query_2 = require("@trpc/react-query");
|
||||||
|
var react_1 = require("react");
|
||||||
|
var superjson_1 = require("superjson");
|
||||||
|
var query_client_1 = require("./query-client");
|
||||||
|
var clientQueryClientSingleton = undefined;
|
||||||
|
var getQueryClient = function () {
|
||||||
|
if (typeof window === "undefined") {
|
||||||
|
// Server: always make a new query client
|
||||||
|
return (0, query_client_1.createQueryClient)();
|
||||||
|
}
|
||||||
|
// Browser: use singleton pattern to keep the same query client
|
||||||
|
clientQueryClientSingleton !== null && clientQueryClientSingleton !== void 0 ? clientQueryClientSingleton : (clientQueryClientSingleton = (0, query_client_1.createQueryClient)());
|
||||||
|
return clientQueryClientSingleton;
|
||||||
|
};
|
||||||
|
exports.api = (0, react_query_2.createTRPCReact)();
|
||||||
|
function TRPCReactProvider(props) {
|
||||||
|
var queryClient = getQueryClient();
|
||||||
|
var trpcClient = (0, react_1.useState)(function () {
|
||||||
|
return exports.api.createClient({
|
||||||
|
links: [
|
||||||
|
(0, client_1.loggerLink)({
|
||||||
|
enabled: function (op) {
|
||||||
|
return process.env.NODE_ENV === "development" ||
|
||||||
|
(op.direction === "down" && op.result instanceof Error);
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
(0, client_1.httpBatchStreamLink)({
|
||||||
|
transformer: superjson_1.default,
|
||||||
|
url: getBaseUrl() + "/api/trpc",
|
||||||
|
headers: function () {
|
||||||
|
var headers = new Headers();
|
||||||
|
headers.set("x-trpc-source", "nextjs-react");
|
||||||
|
return headers;
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
})[0];
|
||||||
|
return (<react_query_1.QueryClientProvider client={queryClient}>
|
||||||
|
<exports.api.Provider client={trpcClient} queryClient={queryClient}>
|
||||||
|
{props.children}
|
||||||
|
</exports.api.Provider>
|
||||||
|
</react_query_1.QueryClientProvider>);
|
||||||
|
}
|
||||||
|
function getBaseUrl() {
|
||||||
|
var _a;
|
||||||
|
if (typeof window !== "undefined")
|
||||||
|
return window.location.origin;
|
||||||
|
if (process.env.VERCEL_URL)
|
||||||
|
return "https://".concat(process.env.VERCEL_URL);
|
||||||
|
return "http://localhost:".concat((_a = process.env.PORT) !== null && _a !== void 0 ? _a : 3000);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user