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.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({
|
||||
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": {
|
||||
"@heroui/react": "^2.8.5",
|
||||
"@supabase/ssr": "^0.7.0",
|
||||
"@supabase/supabase-js": "^2.81.1",
|
||||
"@supabase/ssr": "^0.8.0",
|
||||
"@supabase/supabase-js": "^2.86.0",
|
||||
"@tailwindcss/vite": "^4.1.17",
|
||||
"@tanstack/react-query": "^5.90.8",
|
||||
"@tanstack/react-query-devtools": "^5.90.2",
|
||||
"@tanstack/react-router": "^1.135.2",
|
||||
"@tanstack/react-router-devtools": "^1.135.2",
|
||||
"@tanstack/react-query": "^5.90.11",
|
||||
"@tanstack/react-query-devtools": "^5.91.1",
|
||||
"@tanstack/react-router": "^1.139.7",
|
||||
"@tanstack/react-router-devtools": "^1.139.7",
|
||||
"@tanstack/react-router-with-query": "^1.130.17",
|
||||
"@tanstack/react-start": "^1.135.2",
|
||||
"@tanstack/router-plugin": "^1.135.2",
|
||||
"@tanstack/react-start": "^1.139.8",
|
||||
"@tanstack/router-plugin": "^1.139.7",
|
||||
"@vis.gl/react-google-maps": "^1.7.1",
|
||||
"drizzle-orm": "^0.44.7",
|
||||
"framer-motion": "^12.23.12",
|
||||
@ -30,21 +30,21 @@
|
||||
"react": "^19.2.0",
|
||||
"react-dom": "^19.2.0",
|
||||
"sonner": "^2.0.7",
|
||||
"zod": "^4.1.12"
|
||||
"zod": "^4.1.13"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "^2.3.5",
|
||||
"@biomejs/biome": "^2.3.8",
|
||||
"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",
|
||||
"@types/google.maps": "^3.58.1",
|
||||
"@types/react": "^19.2.4",
|
||||
"@types/react": "^19.2.7",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@vitejs/plugin-react": "^5.1.1",
|
||||
"drizzle-kit": "^0.31.6",
|
||||
"drizzle-kit": "^0.31.7",
|
||||
"jsdom": "^27.2.0",
|
||||
"typescript": "^5.9.3",
|
||||
"vite": "^7.2.2",
|
||||
"vite": "^7.2.4",
|
||||
"web-vitals": "^5.1.0"
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,22 +13,22 @@ import {
|
||||
import { authenticatedRole, authUsers } from "drizzle-orm/supabase"
|
||||
|
||||
// === drones ===
|
||||
export const drones = pgTable("drones", {
|
||||
export const dronesSchema = pgTable("drones", {
|
||||
id: serial("id").primaryKey().notNull(),
|
||||
model: varchar("model", { length: 100 }),
|
||||
brand: varchar("brand", { length: 100 }),
|
||||
brand: varchar("brand", { length: 100 })
|
||||
// type: jsonb("type")
|
||||
}).enableRLS()
|
||||
|
||||
// === certs ===
|
||||
export const certs = pgTable("certs", {
|
||||
export const certsSchema = pgTable("certs", {
|
||||
id: serial("id").primaryKey().notNull(),
|
||||
name: varchar("name", { length: 100 }),
|
||||
link: text("link")
|
||||
}).enableRLS()
|
||||
|
||||
// === places ===
|
||||
export const places = pgTable(
|
||||
export const placesSchema = pgTable(
|
||||
"places",
|
||||
{
|
||||
id: serial("id").primaryKey().notNull(),
|
||||
@ -62,11 +62,11 @@ export const places = pgTable(
|
||||
).enableRLS()
|
||||
|
||||
// === users_drones ===
|
||||
export const usersDrones = pgTable(
|
||||
export const usersDronesSchema = pgTable(
|
||||
"users_drones",
|
||||
{
|
||||
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)
|
||||
},
|
||||
(table) => [
|
||||
@ -84,11 +84,11 @@ export const usersDrones = pgTable(
|
||||
).enableRLS()
|
||||
|
||||
// === users_certs ===
|
||||
export const usersCerts = pgTable(
|
||||
export const usersCertsSchema = pgTable(
|
||||
"users_certs",
|
||||
{
|
||||
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)
|
||||
},
|
||||
(table) => [
|
||||
@ -106,11 +106,11 @@ export const usersCerts = pgTable(
|
||||
).enableRLS()
|
||||
|
||||
// === users_places ===
|
||||
export const usersPlaces = pgTable(
|
||||
export const usersPlacesSchema = pgTable(
|
||||
"users_places",
|
||||
{
|
||||
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)
|
||||
},
|
||||
(table) => [
|
||||
@ -128,6 +128,6 @@ export const usersPlaces = pgTable(
|
||||
).enableRLS()
|
||||
|
||||
// === equipment ===
|
||||
export const equipment = pgTable("equipment", {
|
||||
export const equipmentSchema = pgTable("equipment", {
|
||||
id: serial("id").primaryKey().notNull()
|
||||
}).enableRLS()
|
||||
|
||||
@ -1,8 +1,12 @@
|
||||
import { createServerOnlyFn } from "@tanstack/react-start"
|
||||
import { drizzle } from "drizzle-orm/postgres-js"
|
||||
import postgres from "postgres"
|
||||
|
||||
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
|
||||
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 { asc, eq } from "drizzle-orm"
|
||||
import { eq } from "drizzle-orm"
|
||||
import { db } from "@/integrations/drizzle"
|
||||
import { drones } from "@/integrations/drizzle/db/schema"
|
||||
import { dronesSchema, paginatedDronesSchema } from "../validation/drones"
|
||||
import { dronesSchema } from "@/integrations/drizzle/db/schema"
|
||||
import {
|
||||
droneValidationSchema,
|
||||
paginatedDronesValidationSchema
|
||||
} from "../validation/drones"
|
||||
|
||||
const insertDrones = createServerFn()
|
||||
.inputValidator(dronesSchema)
|
||||
.inputValidator(droneValidationSchema)
|
||||
.handler(async ({ data }) => {
|
||||
await db
|
||||
.insert(drones)
|
||||
await db()
|
||||
.insert(dronesSchema)
|
||||
.values({
|
||||
model: data.model,
|
||||
brand: data.brand
|
||||
@ -18,47 +21,46 @@ const insertDrones = createServerFn()
|
||||
|
||||
const editDrone = createServerFn()
|
||||
.inputValidator(
|
||||
dronesSchema.pick({
|
||||
droneValidationSchema.pick({
|
||||
model: true,
|
||||
brand: true,
|
||||
id: true
|
||||
})
|
||||
)
|
||||
.handler(async ({ data }) => {
|
||||
await db
|
||||
.update(drones)
|
||||
await db()
|
||||
.update(dronesSchema)
|
||||
.set({
|
||||
model: data.model,
|
||||
brand: data.brand
|
||||
})
|
||||
.where(eq(drones.id, data.id))
|
||||
.where(eq(dronesSchema.id, data.id))
|
||||
})
|
||||
|
||||
const deleteDrones = createServerFn({
|
||||
method: "POST"
|
||||
})
|
||||
.inputValidator(
|
||||
dronesSchema.pick({
|
||||
droneValidationSchema.pick({
|
||||
id: true
|
||||
})
|
||||
)
|
||||
.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({
|
||||
method: "POST"
|
||||
})
|
||||
.inputValidator(paginatedDronesSchema)
|
||||
.inputValidator(paginatedDronesValidationSchema)
|
||||
.handler(async ({ data }) => {
|
||||
return db
|
||||
return db()
|
||||
.select()
|
||||
.from(drones)
|
||||
.from(dronesSchema)
|
||||
.limit(data.limit)
|
||||
.offset((data.page - 1) * data.limit)
|
||||
})
|
||||
|
||||
|
||||
export const serverDrones = {
|
||||
insertDrones,
|
||||
editDrone,
|
||||
|
||||
@ -1,18 +1,21 @@
|
||||
import { createServerFn } from "@tanstack/react-start"
|
||||
import { eq } from "drizzle-orm"
|
||||
import { db } from "@/integrations/drizzle"
|
||||
import { places as placesSchema } from "@/integrations/drizzle/db/schema"
|
||||
import { paginatedPlacesSchema, placeSchema } from "../validation/places"
|
||||
import { placesSchema } from "@/integrations/drizzle/db/schema"
|
||||
import {
|
||||
paginatedPlacesValidationSchema,
|
||||
placeValidationSchema
|
||||
} from "../validation/places"
|
||||
|
||||
export const insertUserPlace = createServerFn()
|
||||
.inputValidator(placeSchema)
|
||||
.inputValidator(placeValidationSchema)
|
||||
.handler(async ({ data }) => {
|
||||
await db.insert(placesSchema).values(data).returning()
|
||||
await db().insert(placesSchema).values(data).returning()
|
||||
})
|
||||
|
||||
export const editUserPlace = createServerFn()
|
||||
.inputValidator(
|
||||
placeSchema.pick({
|
||||
placeValidationSchema.pick({
|
||||
hidden_place: true,
|
||||
name: true,
|
||||
description: true,
|
||||
@ -20,16 +23,16 @@ export const editUserPlace = createServerFn()
|
||||
})
|
||||
)
|
||||
.handler(async ({ data }) => {
|
||||
await db
|
||||
await db()
|
||||
.update(placesSchema)
|
||||
.set(data)
|
||||
.where(eq(placesSchema.id_user, data.id_user))
|
||||
})
|
||||
|
||||
export const getUserPlacesById = createServerFn()
|
||||
.inputValidator(paginatedPlacesSchema)
|
||||
.inputValidator(paginatedPlacesValidationSchema)
|
||||
.handler(async ({ data }) => {
|
||||
return await db
|
||||
return await db()
|
||||
.select()
|
||||
.from(placesSchema)
|
||||
.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(),
|
||||
brand: z.string(),
|
||||
id: z.number()
|
||||
})
|
||||
|
||||
export const paginatedDronesSchema = z.object({
|
||||
export const paginatedDronesValidationSchema = z.object({
|
||||
page: z.number().min(1).default(1),
|
||||
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(),
|
||||
description: z.string(),
|
||||
coord_x: z.string(),
|
||||
@ -9,10 +9,8 @@ export const placeSchema = z.object({
|
||||
hidden_place: z.boolean()
|
||||
})
|
||||
|
||||
export const paginatedPlacesSchema = z.object({
|
||||
export const paginatedPlacesValidationSchema = z.object({
|
||||
page: 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({
|
||||
email: z.email("Invalid email address"),
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"verbatimModuleSyntax": false,
|
||||
"noEmit": true,
|
||||
|
||||
/* Linting */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user