diff --git a/bun.lockb b/bun.lockb index 82530bdc..4317a501 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 70fd79a6..5d178a31 100644 --- a/package.json +++ b/package.json @@ -10,52 +10,52 @@ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", "lint": "prettier --plugin-search-dir . --check . && eslint .", "format": "prettier --plugin-search-dir . --write .", - "generate": "drizzle-kit generate:mysql", "push": "drizzle-kit push:mysql", "studio": "drizzle-kit studio" }, "devDependencies": { - "@skeletonlabs/skeleton": "^2.0.0", - "@skeletonlabs/tw-plugin": "^0.1.0", - "@types/node": "^20.5.1", - "@typescript-eslint/eslint-plugin": "^6.4.0", - "@typescript-eslint/parser": "^6.4.0", + "@skeletonlabs/skeleton": "^2.7.1", + "@skeletonlabs/tw-plugin": "^0.3.1", + "@types/node": "^20.11.4", + "@typescript-eslint/eslint-plugin": "^6.19.0", + "@typescript-eslint/parser": "^6.19.0", "dotenv": "^16.3.1", - "drizzle-kit": "^0.19.13", - "eslint": "^8.47.0", - "eslint-config-prettier": "^9.0.0", + "drizzle-kit": "^0.20.13", + "eslint": "^8.56.0", + "eslint-config-prettier": "^9.1.0", "eslint-plugin-svelte3": "^4.0.0", - "prettier": "^3.0.2", - "prettier-plugin-organize-imports": "^3.2.3", - "prettier-plugin-svelte": "^3.0.3", - "prettier-plugin-tailwindcss": "^0.5.3", - "vite-plugin-tailwind-purgecss": "^0.1.3" + "mysql2": "^3.7.0", + "prettier": "^3.2.2", + "prettier-plugin-organize-imports": "^3.2.4", + "prettier-plugin-svelte": "^3.1.2", + "prettier-plugin-tailwindcss": "^0.5.11", + "vite-plugin-tailwind-purgecss": "^0.2.0" }, "dependencies": { "@dicebear/collection": "^6.0.4", "@dicebear/core": "^6.0.4", - "@floating-ui/dom": "^1.5.1", - "@google-cloud/storage": "^7.0.1", - "@lucia-auth/adapter-mysql": "^2.0.0", - "@planetscale/database": "^1.10.0", - "@sveltejs/adapter-vercel": "^3.0.3", - "@sveltejs/kit": "^1.22.6", - "@tailwindcss/forms": "^0.5.4", - "autoprefixer": "^10.4.15", + "@floating-ui/dom": "^1.5.4", + "@google-cloud/storage": "^7.7.0", + "@lucia-auth/adapter-mysql": "^2.1.0", + "@planetscale/database": "^1.13.0", + "@sveltejs/adapter-vercel": "^4.0.5", + "@sveltejs/kit": "^2.3.3", + "@tailwindcss/forms": "^0.5.7", + "autoprefixer": "^10.4.16", "chalk": "^5.3.0", "cheerio": "1.0.0-rc.12", - "classnames": "^2.3.2", - "dayjs": "^1.11.9", - "drizzle-orm": "^0.28.2", - "lucia": "^2.3.0", - "sharp": "^0.32.5", - "svelte": "^4.2.0", - "svelte-check": "^3.5.0", - "sveltekit-api-fetch": "^3.2.0", - "sveltekit-superforms": "^1.6.0", - "tailwindcss": "^3.3.3", - "vite": "^4.4.9", - "zod": "^3.22.2" + "classnames": "^2.5.1", + "dayjs": "^1.11.10", + "drizzle-orm": "^0.29.3", + "lucia": "^2.7.6", + "sharp": "^0.33.2", + "svelte": "^4.2.8", + "svelte-check": "^3.6.3", + "sveltekit-api-fetch": "^3.3.0", + "sveltekit-superforms": "^1.13.3", + "tailwindcss": "^3.4.1", + "vite": "^5.0.11", + "zod": "^3.22.4" }, "trustedDependencies": [ "sharp" diff --git a/src/lib/components/Carousel.svelte b/src/lib/components/Carousel.svelte index 4764bd3d..693b3f3b 100644 --- a/src/lib/components/Carousel.svelte +++ b/src/lib/components/Carousel.svelte @@ -40,7 +40,7 @@ // Function to read image files and update the images and files arrays function readImages(filelist: FileList) { - for (let file of filelist) { + for (let file of Array.from(filelist)) { if (file.type !== "image/png" && file.type !== "image/jpeg") return; if (images.length >= maxImagesCount) return; let reader = new FileReader(); diff --git a/src/lib/server/lucia.ts b/src/lib/server/lucia.ts index 42a4cd27..26d87717 100644 --- a/src/lib/server/lucia.ts +++ b/src/lib/server/lucia.ts @@ -12,6 +12,7 @@ const conn = connect({ }); export const auth = lucia({ + //@ts-expect-error Lucia's planetscale version doesn't match adapter: planetscale(conn, { user: "users", key: "user_key", diff --git a/src/lib/types.ts b/src/lib/types.ts index b228e7a1..2d56461b 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -1,5 +1,4 @@ import type { Dayjs } from "dayjs"; -import type { InferModel } from "drizzle-orm"; import type { User } from "lucia"; import type { booksTable } from "./server/schemas/books"; @@ -15,7 +14,7 @@ export interface Group { /** * Represents a book to be sold */ -export type Book = InferModel; +export type Book = typeof booksTable.$inferSelect; /** * Represents a user's schedule diff --git a/src/lib/zod_schemas.ts b/src/lib/zod_schemas.ts index 85d4d7fb..ab758d9e 100644 --- a/src/lib/zod_schemas.ts +++ b/src/lib/zod_schemas.ts @@ -76,7 +76,7 @@ export const omnivoxLoginSchema = z.object({ */ export const imageSchema = z .instanceof(File) - .refine((file: File) => file?.length !== 0, "Il faut un fichier") + .refine((file: File) => file?.size !== 0, "Il faut un fichier") .refine((file) => file.size < 5000000, "Le fichier doit ĂȘtre plus petit que 5MB") .refine((file) => { if (!file?.name) return false; diff --git a/src/routes/(app)/livres/(acheter)/+layout.server.ts b/src/routes/(app)/livres/(acheter)/+layout.server.ts index 8e7238cd..7182387a 100644 --- a/src/routes/(app)/livres/(acheter)/+layout.server.ts +++ b/src/routes/(app)/livres/(acheter)/+layout.server.ts @@ -3,6 +3,6 @@ import type { LayoutServerLoad } from "./$types"; export const load = (async ({ locals }) => { return { - bookCodes: db.getBookCodes(locals.user), + bookCodes: await db.getBookCodes(locals.user), }; }) satisfies LayoutServerLoad; diff --git a/src/routes/(app)/livres/(acheter)/[...bookId]/+page.server.ts b/src/routes/(app)/livres/(acheter)/[...bookId]/+page.server.ts index 680099e2..00414a8e 100644 --- a/src/routes/(app)/livres/(acheter)/[...bookId]/+page.server.ts +++ b/src/routes/(app)/livres/(acheter)/[...bookId]/+page.server.ts @@ -13,7 +13,7 @@ export const load = (async ({ params }) => { return { book: book, - bookUser, + bookUser: await bookUser, school: await bookUser.then((u) => (u ? getSchool(u) : null)), }; }) satisfies PageServerLoad; diff --git a/src/service-worker.js b/src/service-worker.js index f07da86e..dd289133 100644 --- a/src/service-worker.js +++ b/src/service-worker.js @@ -1,6 +1,11 @@ /// +/// +/// +/// import { build, files, prerendered, version } from "$service-worker"; +const sw = /** @type {ServiceWorkerGlobalScope} */ (/** @type {unknown} */ (self)); + // Create a unique cache name for this deployment const CACHE = `cache-${version}`; @@ -10,7 +15,7 @@ const ASSETS = [ ...prerendered, ]; -self.addEventListener("install", (event) => { +sw.addEventListener("install", (event) => { // Create a new cache and add all files to it async function addFilesToCache() { const cache = await caches.open(CACHE); @@ -20,7 +25,7 @@ self.addEventListener("install", (event) => { event.waitUntil(addFilesToCache()); }); -self.addEventListener("activate", (event) => { +sw.addEventListener("activate", (event) => { // Remove previous cached data from disk async function deleteOldCaches() { for (const key of await caches.keys()) { @@ -31,7 +36,7 @@ self.addEventListener("activate", (event) => { event.waitUntil(deleteOldCaches()); }); -self.addEventListener("fetch", (event) => { +sw.addEventListener("fetch", (event) => { // ignore POST requests etc if (event.request.method !== "GET") return; @@ -55,10 +60,11 @@ self.addEventListener("fetch", (event) => { return response; } catch { - return cache.match("/offline"); // return cache.match(event.request); + return cache.match("/offline"); } } + // @ts-expect-error Might be undefined but its expected if there is no cache and no network event.respondWith(respond()); }); diff --git a/svelte.config.js b/svelte.config.js index 2d6d273a..ec547b9c 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -1,9 +1,9 @@ import adapter from "@sveltejs/adapter-vercel"; -import { vitePreprocess } from "@sveltejs/kit/vite"; +import { vitePreprocess } from "@sveltejs/vite-plugin-svelte"; /** @type {import('@sveltejs/kit').Config} */ const config = { - preprocess: vitePreprocess(), + preprocess: [vitePreprocess()], kit: { adapter: adapter(), alias: {