chore: update dependencies and improve database schema handling
- Updated @supabase/ssr to version 0.8.0 and @supabase/supabase-js to version 2.86.0. - Upgraded various @tanstack packages to their latest versions for improved functionality. - Refactored database schema exports in schema.ts for consistency and clarity. - Modified drizzle integration to utilize createServerOnlyFn for database connection. - Enhanced server functions for drones and places to use updated validation schemas. - Changed validation schemas to improve naming conventions and clarity. - Adjusted TypeScript configuration to disable verbatim module syntax for better compatibility.
This commit is contained in:
parent
f951fe6629
commit
bababbeabb
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -30,6 +30,6 @@
|
|||||||
"editor.defaultFormatter": "biomejs.biome"
|
"editor.defaultFormatter": "biomejs.biome"
|
||||||
},
|
},
|
||||||
"editor.codeActionsOnSave": {
|
"editor.codeActionsOnSave": {
|
||||||
"source.organizeImports.biome": "explicit"
|
"source.organizeImports.biome": "always"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { defineConfig } from 'drizzle-kit';
|
import { defineConfig } from 'drizzle-kit'
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
schema: './src/integrations/drizzle/db/schema.ts',
|
schema: './src/integrations/drizzle/db/schema.ts',
|
||||||
|
|||||||
632
package-lock.json
generated
632
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
28
package.json
28
package.json
@ -13,16 +13,16 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@heroui/react": "^2.8.5",
|
"@heroui/react": "^2.8.5",
|
||||||
"@supabase/ssr": "^0.7.0",
|
"@supabase/ssr": "^0.8.0",
|
||||||
"@supabase/supabase-js": "^2.81.1",
|
"@supabase/supabase-js": "^2.86.0",
|
||||||
"@tailwindcss/vite": "^4.1.17",
|
"@tailwindcss/vite": "^4.1.17",
|
||||||
"@tanstack/react-query": "^5.90.8",
|
"@tanstack/react-query": "^5.90.11",
|
||||||
"@tanstack/react-query-devtools": "^5.90.2",
|
"@tanstack/react-query-devtools": "^5.91.1",
|
||||||
"@tanstack/react-router": "^1.135.2",
|
"@tanstack/react-router": "^1.139.7",
|
||||||
"@tanstack/react-router-devtools": "^1.135.2",
|
"@tanstack/react-router-devtools": "^1.139.7",
|
||||||
"@tanstack/react-router-with-query": "^1.130.17",
|
"@tanstack/react-router-with-query": "^1.130.17",
|
||||||
"@tanstack/react-start": "^1.135.2",
|
"@tanstack/react-start": "^1.139.8",
|
||||||
"@tanstack/router-plugin": "^1.135.2",
|
"@tanstack/router-plugin": "^1.139.7",
|
||||||
"@vis.gl/react-google-maps": "^1.7.1",
|
"@vis.gl/react-google-maps": "^1.7.1",
|
||||||
"drizzle-orm": "^0.44.7",
|
"drizzle-orm": "^0.44.7",
|
||||||
"framer-motion": "^12.23.12",
|
"framer-motion": "^12.23.12",
|
||||||
@ -30,21 +30,21 @@
|
|||||||
"react": "^19.2.0",
|
"react": "^19.2.0",
|
||||||
"react-dom": "^19.2.0",
|
"react-dom": "^19.2.0",
|
||||||
"sonner": "^2.0.7",
|
"sonner": "^2.0.7",
|
||||||
"zod": "^4.1.12"
|
"zod": "^4.1.13"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@biomejs/biome": "^2.3.5",
|
"@biomejs/biome": "^2.3.8",
|
||||||
"vite-tsconfig-paths": "^5.1.4",
|
"vite-tsconfig-paths": "^5.1.4",
|
||||||
"@tanstack/react-router-ssr-query": "^1.135.2",
|
"@tanstack/react-router-ssr-query": "^1.139.7",
|
||||||
"tailwindcss": "^4.1.17",
|
"tailwindcss": "^4.1.17",
|
||||||
"@types/google.maps": "^3.58.1",
|
"@types/google.maps": "^3.58.1",
|
||||||
"@types/react": "^19.2.4",
|
"@types/react": "^19.2.7",
|
||||||
"@types/react-dom": "^19.2.3",
|
"@types/react-dom": "^19.2.3",
|
||||||
"@vitejs/plugin-react": "^5.1.1",
|
"@vitejs/plugin-react": "^5.1.1",
|
||||||
"drizzle-kit": "^0.31.6",
|
"drizzle-kit": "^0.31.7",
|
||||||
"jsdom": "^27.2.0",
|
"jsdom": "^27.2.0",
|
||||||
"typescript": "^5.9.3",
|
"typescript": "^5.9.3",
|
||||||
"vite": "^7.2.2",
|
"vite": "^7.2.4",
|
||||||
"web-vitals": "^5.1.0"
|
"web-vitals": "^5.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,22 +13,22 @@ import {
|
|||||||
import { authenticatedRole, authUsers } from "drizzle-orm/supabase"
|
import { authenticatedRole, authUsers } from "drizzle-orm/supabase"
|
||||||
|
|
||||||
// === drones ===
|
// === drones ===
|
||||||
export const drones = pgTable("drones", {
|
export const dronesSchema = pgTable("drones", {
|
||||||
id: serial("id").primaryKey().notNull(),
|
id: serial("id").primaryKey().notNull(),
|
||||||
model: varchar("model", { length: 100 }),
|
model: varchar("model", { length: 100 }),
|
||||||
brand: varchar("brand", { length: 100 }),
|
brand: varchar("brand", { length: 100 })
|
||||||
// type: jsonb("type")
|
// type: jsonb("type")
|
||||||
}).enableRLS()
|
}).enableRLS()
|
||||||
|
|
||||||
// === certs ===
|
// === certs ===
|
||||||
export const certs = pgTable("certs", {
|
export const certsSchema = pgTable("certs", {
|
||||||
id: serial("id").primaryKey().notNull(),
|
id: serial("id").primaryKey().notNull(),
|
||||||
name: varchar("name", { length: 100 }),
|
name: varchar("name", { length: 100 }),
|
||||||
link: text("link")
|
link: text("link")
|
||||||
}).enableRLS()
|
}).enableRLS()
|
||||||
|
|
||||||
// === places ===
|
// === places ===
|
||||||
export const places = pgTable(
|
export const placesSchema = pgTable(
|
||||||
"places",
|
"places",
|
||||||
{
|
{
|
||||||
id: serial("id").primaryKey().notNull(),
|
id: serial("id").primaryKey().notNull(),
|
||||||
@ -62,11 +62,11 @@ export const places = pgTable(
|
|||||||
).enableRLS()
|
).enableRLS()
|
||||||
|
|
||||||
// === users_drones ===
|
// === users_drones ===
|
||||||
export const usersDrones = pgTable(
|
export const usersDronesSchema = pgTable(
|
||||||
"users_drones",
|
"users_drones",
|
||||||
{
|
{
|
||||||
id: serial("id").primaryKey().notNull(),
|
id: serial("id").primaryKey().notNull(),
|
||||||
id_drone: integer("id_drone").references(() => drones.id),
|
id_drone: integer("id_drone").references(() => dronesSchema.id),
|
||||||
id_user: uuid("id_user").references(() => authUsers.id)
|
id_user: uuid("id_user").references(() => authUsers.id)
|
||||||
},
|
},
|
||||||
(table) => [
|
(table) => [
|
||||||
@ -84,11 +84,11 @@ export const usersDrones = pgTable(
|
|||||||
).enableRLS()
|
).enableRLS()
|
||||||
|
|
||||||
// === users_certs ===
|
// === users_certs ===
|
||||||
export const usersCerts = pgTable(
|
export const usersCertsSchema = pgTable(
|
||||||
"users_certs",
|
"users_certs",
|
||||||
{
|
{
|
||||||
id: serial("id").primaryKey().notNull(),
|
id: serial("id").primaryKey().notNull(),
|
||||||
id_cert: integer("id_cert").references(() => certs.id),
|
id_cert: integer("id_cert").references(() => certsSchema.id),
|
||||||
id_user: uuid("id_user").references(() => authUsers.id)
|
id_user: uuid("id_user").references(() => authUsers.id)
|
||||||
},
|
},
|
||||||
(table) => [
|
(table) => [
|
||||||
@ -106,11 +106,11 @@ export const usersCerts = pgTable(
|
|||||||
).enableRLS()
|
).enableRLS()
|
||||||
|
|
||||||
// === users_places ===
|
// === users_places ===
|
||||||
export const usersPlaces = pgTable(
|
export const usersPlacesSchema = pgTable(
|
||||||
"users_places",
|
"users_places",
|
||||||
{
|
{
|
||||||
id: serial("id").primaryKey().notNull(),
|
id: serial("id").primaryKey().notNull(),
|
||||||
id_place: integer("id_place").references(() => places.id),
|
id_place: integer("id_place").references(() => placesSchema.id),
|
||||||
id_user: uuid("id_user").references(() => authUsers.id)
|
id_user: uuid("id_user").references(() => authUsers.id)
|
||||||
},
|
},
|
||||||
(table) => [
|
(table) => [
|
||||||
@ -128,6 +128,6 @@ export const usersPlaces = pgTable(
|
|||||||
).enableRLS()
|
).enableRLS()
|
||||||
|
|
||||||
// === equipment ===
|
// === equipment ===
|
||||||
export const equipment = pgTable("equipment", {
|
export const equipmentSchema = pgTable("equipment", {
|
||||||
id: serial("id").primaryKey().notNull()
|
id: serial("id").primaryKey().notNull()
|
||||||
}).enableRLS()
|
}).enableRLS()
|
||||||
|
|||||||
@ -1,8 +1,12 @@
|
|||||||
|
import { createServerOnlyFn } from "@tanstack/react-start"
|
||||||
import { drizzle } from "drizzle-orm/postgres-js"
|
import { drizzle } from "drizzle-orm/postgres-js"
|
||||||
import postgres from "postgres"
|
import postgres from "postgres"
|
||||||
|
|
||||||
const connectionString = process.env.DATABASE_URL ?? ""
|
export const db = createServerOnlyFn(() => {
|
||||||
|
const connectionString = process.env.DATABASE_URL ?? ""
|
||||||
|
const client = postgres(connectionString, { prepare: false })
|
||||||
|
|
||||||
// Disable prefetch as it is not supported for "Transaction" pool mode
|
// Disable prefetch as it is not supported for "Transaction" pool mode
|
||||||
const client = postgres(connectionString, { prepare: false })
|
|
||||||
export const db = drizzle(client)
|
return drizzle(client)
|
||||||
|
})
|
||||||
|
|||||||
@ -1,14 +1,17 @@
|
|||||||
import { createServerFn } from "@tanstack/react-start"
|
import { createServerFn } from "@tanstack/react-start"
|
||||||
import { asc, eq } from "drizzle-orm"
|
import { eq } from "drizzle-orm"
|
||||||
import { db } from "@/integrations/drizzle"
|
import { db } from "@/integrations/drizzle"
|
||||||
import { drones } from "@/integrations/drizzle/db/schema"
|
import { dronesSchema } from "@/integrations/drizzle/db/schema"
|
||||||
import { dronesSchema, paginatedDronesSchema } from "../validation/drones"
|
import {
|
||||||
|
droneValidationSchema,
|
||||||
|
paginatedDronesValidationSchema
|
||||||
|
} from "../validation/drones"
|
||||||
|
|
||||||
const insertDrones = createServerFn()
|
const insertDrones = createServerFn()
|
||||||
.inputValidator(dronesSchema)
|
.inputValidator(droneValidationSchema)
|
||||||
.handler(async ({ data }) => {
|
.handler(async ({ data }) => {
|
||||||
await db
|
await db()
|
||||||
.insert(drones)
|
.insert(dronesSchema)
|
||||||
.values({
|
.values({
|
||||||
model: data.model,
|
model: data.model,
|
||||||
brand: data.brand
|
brand: data.brand
|
||||||
@ -18,50 +21,49 @@ const insertDrones = createServerFn()
|
|||||||
|
|
||||||
const editDrone = createServerFn()
|
const editDrone = createServerFn()
|
||||||
.inputValidator(
|
.inputValidator(
|
||||||
dronesSchema.pick({
|
droneValidationSchema.pick({
|
||||||
model: true,
|
model: true,
|
||||||
brand: true,
|
brand: true,
|
||||||
id: true
|
id: true
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.handler(async ({ data }) => {
|
.handler(async ({ data }) => {
|
||||||
await db
|
await db()
|
||||||
.update(drones)
|
.update(dronesSchema)
|
||||||
.set({
|
.set({
|
||||||
model: data.model,
|
model: data.model,
|
||||||
brand: data.brand
|
brand: data.brand
|
||||||
})
|
})
|
||||||
.where(eq(drones.id, data.id))
|
.where(eq(dronesSchema.id, data.id))
|
||||||
})
|
})
|
||||||
|
|
||||||
const deleteDrones = createServerFn({
|
const deleteDrones = createServerFn({
|
||||||
method: "POST"
|
method: "POST"
|
||||||
})
|
})
|
||||||
.inputValidator(
|
.inputValidator(
|
||||||
dronesSchema.pick({
|
droneValidationSchema.pick({
|
||||||
id: true
|
id: true
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.handler(async ({ data }) => {
|
.handler(async ({ data }) => {
|
||||||
return await db.delete(drones).where(eq(drones.id, data.id))
|
return await db().delete(dronesSchema).where(eq(dronesSchema.id, data.id))
|
||||||
})
|
})
|
||||||
|
|
||||||
const getAllDrones = createServerFn({
|
const getAllDrones = createServerFn({
|
||||||
method: "POST"
|
method: "POST"
|
||||||
})
|
})
|
||||||
.inputValidator(paginatedDronesSchema)
|
.inputValidator(paginatedDronesValidationSchema)
|
||||||
.handler(async ({ data }) => {
|
.handler(async ({ data }) => {
|
||||||
return db
|
return db()
|
||||||
.select()
|
.select()
|
||||||
.from(drones)
|
.from(dronesSchema)
|
||||||
.limit(data.limit)
|
.limit(data.limit)
|
||||||
.offset((data.page - 1) * data.limit)
|
.offset((data.page - 1) * data.limit)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
export const serverDrones = {
|
export const serverDrones = {
|
||||||
insertDrones,
|
insertDrones,
|
||||||
editDrone,
|
editDrone,
|
||||||
getAllDrones,
|
getAllDrones,
|
||||||
deleteDrones
|
deleteDrones
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,18 +1,21 @@
|
|||||||
import { createServerFn } from "@tanstack/react-start"
|
import { createServerFn } from "@tanstack/react-start"
|
||||||
import { eq } from "drizzle-orm"
|
import { eq } from "drizzle-orm"
|
||||||
import { db } from "@/integrations/drizzle"
|
import { db } from "@/integrations/drizzle"
|
||||||
import { places as placesSchema } from "@/integrations/drizzle/db/schema"
|
import { placesSchema } from "@/integrations/drizzle/db/schema"
|
||||||
import { paginatedPlacesSchema, placeSchema } from "../validation/places"
|
import {
|
||||||
|
paginatedPlacesValidationSchema,
|
||||||
|
placeValidationSchema
|
||||||
|
} from "../validation/places"
|
||||||
|
|
||||||
export const insertUserPlace = createServerFn()
|
export const insertUserPlace = createServerFn()
|
||||||
.inputValidator(placeSchema)
|
.inputValidator(placeValidationSchema)
|
||||||
.handler(async ({ data }) => {
|
.handler(async ({ data }) => {
|
||||||
await db.insert(placesSchema).values(data).returning()
|
await db().insert(placesSchema).values(data).returning()
|
||||||
})
|
})
|
||||||
|
|
||||||
export const editUserPlace = createServerFn()
|
export const editUserPlace = createServerFn()
|
||||||
.inputValidator(
|
.inputValidator(
|
||||||
placeSchema.pick({
|
placeValidationSchema.pick({
|
||||||
hidden_place: true,
|
hidden_place: true,
|
||||||
name: true,
|
name: true,
|
||||||
description: true,
|
description: true,
|
||||||
@ -20,16 +23,16 @@ export const editUserPlace = createServerFn()
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
.handler(async ({ data }) => {
|
.handler(async ({ data }) => {
|
||||||
await db
|
await db()
|
||||||
.update(placesSchema)
|
.update(placesSchema)
|
||||||
.set(data)
|
.set(data)
|
||||||
.where(eq(placesSchema.id_user, data.id_user))
|
.where(eq(placesSchema.id_user, data.id_user))
|
||||||
})
|
})
|
||||||
|
|
||||||
export const getUserPlacesById = createServerFn()
|
export const getUserPlacesById = createServerFn()
|
||||||
.inputValidator(paginatedPlacesSchema)
|
.inputValidator(paginatedPlacesValidationSchema)
|
||||||
.handler(async ({ data }) => {
|
.handler(async ({ data }) => {
|
||||||
return await db
|
return await db()
|
||||||
.select()
|
.select()
|
||||||
.from(placesSchema)
|
.from(placesSchema)
|
||||||
.where(eq(placesSchema.id_user, data.id_user))
|
.where(eq(placesSchema.id_user, data.id_user))
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
import z from "zod"
|
import * as z from "zod"
|
||||||
|
|
||||||
export const dronesSchema = z.object({
|
export const droneValidationSchema = z.object({
|
||||||
model: z.string(),
|
model: z.string(),
|
||||||
brand: z.string(),
|
brand: z.string(),
|
||||||
id: z.number()
|
id: z.number()
|
||||||
})
|
})
|
||||||
|
|
||||||
export const paginatedDronesSchema = z.object({
|
export const paginatedDronesValidationSchema = z.object({
|
||||||
page: z.number().min(1).default(1),
|
page: z.number().min(1).default(1),
|
||||||
limit: z.number().min(1).max(100).default(10)
|
limit: z.number().min(1).max(100).default(10)
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import z from "zod"
|
import * as z from "zod"
|
||||||
|
|
||||||
export const placeSchema = z.object({
|
export const placeValidationSchema = z.object({
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
description: z.string(),
|
description: z.string(),
|
||||||
coord_x: z.string(),
|
coord_x: z.string(),
|
||||||
@ -9,10 +9,8 @@ export const placeSchema = z.object({
|
|||||||
hidden_place: z.boolean()
|
hidden_place: z.boolean()
|
||||||
})
|
})
|
||||||
|
|
||||||
export const paginatedPlacesSchema = z.object({
|
export const paginatedPlacesValidationSchema = z.object({
|
||||||
page: z.number(),
|
page: z.number(),
|
||||||
limit: z.number(),
|
limit: z.number(),
|
||||||
id_user: z.string(),
|
id_user: z.string()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import z from "zod"
|
import * as z from "zod"
|
||||||
|
|
||||||
export const loginFormSchema = z.object({
|
export const loginFormSchema = z.object({
|
||||||
email: z.email("Invalid email address"),
|
email: z.email("Invalid email address"),
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
/* Bundler mode */
|
/* Bundler mode */
|
||||||
"moduleResolution": "bundler",
|
"moduleResolution": "bundler",
|
||||||
"allowImportingTsExtensions": true,
|
"allowImportingTsExtensions": true,
|
||||||
"verbatimModuleSyntax": true,
|
"verbatimModuleSyntax": false,
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
|
|
||||||
/* Linting */
|
/* Linting */
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user