From 7026435cd3779a56f5764f476361625b5e26ed1d Mon Sep 17 00:00:00 2001 From: Atridad Lahiji Date: Fri, 16 Jan 2026 18:45:28 -0700 Subject: [PATCH] Changed DB driver --- astro.config.mjs | 19 +- drizzle/0000_mixed_morlocks.sql | 140 ----- drizzle/meta/0000_snapshot.json | 980 -------------------------------- drizzle/meta/_journal.json | 13 - package.json | 3 +- pnpm-lock.yaml | 333 ++++++++++- src/db/index.ts | 43 +- 7 files changed, 352 insertions(+), 1179 deletions(-) delete mode 100644 drizzle/0000_mixed_morlocks.sql delete mode 100644 drizzle/meta/0000_snapshot.json delete mode 100644 drizzle/meta/_journal.json diff --git a/astro.config.mjs b/astro.config.mjs index a7dafbd..c3e8a11 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -1,24 +1,21 @@ // @ts-check -import { defineConfig } from 'astro/config'; -import vue from '@astrojs/vue'; -import tailwindcss from '@tailwindcss/vite'; -import icon from 'astro-icon'; +import { defineConfig } from "astro/config"; +import vue from "@astrojs/vue"; +import tailwindcss from "@tailwindcss/vite"; +import icon from "astro-icon"; -import node from '@astrojs/node'; +import node from "@astrojs/node"; // https://astro.build/config export default defineConfig({ - output: 'server', + output: "server", integrations: [vue(), icon()], vite: { plugins: [tailwindcss()], - ssr: { - external: ['better-sqlite3'], - }, }, adapter: node({ - mode: 'standalone', + mode: "standalone", }), -}); \ No newline at end of file +}); diff --git a/drizzle/0000_mixed_morlocks.sql b/drizzle/0000_mixed_morlocks.sql deleted file mode 100644 index 9c6a1d9..0000000 --- a/drizzle/0000_mixed_morlocks.sql +++ /dev/null @@ -1,140 +0,0 @@ -CREATE TABLE `api_tokens` ( - `id` text PRIMARY KEY NOT NULL, - `user_id` text NOT NULL, - `name` text NOT NULL, - `token` text NOT NULL, - `scopes` text DEFAULT '*' NOT NULL, - `last_used_at` integer, - `created_at` integer, - FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action -); ---> statement-breakpoint -CREATE UNIQUE INDEX `api_tokens_token_unique` ON `api_tokens` (`token`);--> statement-breakpoint -CREATE TABLE `categories` ( - `id` text PRIMARY KEY NOT NULL, - `organization_id` text NOT NULL, - `name` text NOT NULL, - `color` text, - `created_at` integer, - FOREIGN KEY (`organization_id`) REFERENCES `organizations`(`id`) ON UPDATE no action ON DELETE no action -); ---> statement-breakpoint -CREATE TABLE `clients` ( - `id` text PRIMARY KEY NOT NULL, - `organization_id` text NOT NULL, - `name` text NOT NULL, - `email` text, - `created_at` integer, - FOREIGN KEY (`organization_id`) REFERENCES `organizations`(`id`) ON UPDATE no action ON DELETE no action -); ---> statement-breakpoint -CREATE TABLE `invoice_items` ( - `id` text PRIMARY KEY NOT NULL, - `invoice_id` text NOT NULL, - `description` text NOT NULL, - `quantity` real DEFAULT 1 NOT NULL, - `unit_price` integer DEFAULT 0 NOT NULL, - `amount` integer DEFAULT 0 NOT NULL, - FOREIGN KEY (`invoice_id`) REFERENCES `invoices`(`id`) ON UPDATE no action ON DELETE no action -); ---> statement-breakpoint -CREATE TABLE `invoices` ( - `id` text PRIMARY KEY NOT NULL, - `organization_id` text NOT NULL, - `client_id` text NOT NULL, - `number` text NOT NULL, - `type` text DEFAULT 'invoice' NOT NULL, - `status` text DEFAULT 'draft' NOT NULL, - `issue_date` integer NOT NULL, - `due_date` integer NOT NULL, - `notes` text, - `currency` text DEFAULT 'USD' NOT NULL, - `subtotal` integer DEFAULT 0 NOT NULL, - `tax_rate` real DEFAULT 0, - `tax_amount` integer DEFAULT 0 NOT NULL, - `total` integer DEFAULT 0 NOT NULL, - `created_at` integer, - FOREIGN KEY (`organization_id`) REFERENCES `organizations`(`id`) ON UPDATE no action ON DELETE no action, - FOREIGN KEY (`client_id`) REFERENCES `clients`(`id`) ON UPDATE no action ON DELETE no action -); ---> statement-breakpoint -CREATE TABLE `members` ( - `user_id` text NOT NULL, - `organization_id` text NOT NULL, - `role` text DEFAULT 'member' NOT NULL, - `joined_at` integer, - PRIMARY KEY(`user_id`, `organization_id`), - FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action, - FOREIGN KEY (`organization_id`) REFERENCES `organizations`(`id`) ON UPDATE no action ON DELETE no action -); ---> statement-breakpoint -CREATE TABLE `organizations` ( - `id` text PRIMARY KEY NOT NULL, - `name` text NOT NULL, - `street` text, - `city` text, - `state` text, - `zip` text, - `country` text, - `created_at` integer -); ---> statement-breakpoint -CREATE TABLE `sessions` ( - `id` text PRIMARY KEY NOT NULL, - `user_id` text NOT NULL, - `expires_at` integer NOT NULL, - FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action -); ---> statement-breakpoint -CREATE TABLE `site_settings` ( - `id` text PRIMARY KEY NOT NULL, - `key` text NOT NULL, - `value` text NOT NULL, - `updated_at` integer -); ---> statement-breakpoint -CREATE UNIQUE INDEX `site_settings_key_unique` ON `site_settings` (`key`);--> statement-breakpoint -CREATE TABLE `tags` ( - `id` text PRIMARY KEY NOT NULL, - `organization_id` text NOT NULL, - `name` text NOT NULL, - `color` text, - `created_at` integer, - FOREIGN KEY (`organization_id`) REFERENCES `organizations`(`id`) ON UPDATE no action ON DELETE no action -); ---> statement-breakpoint -CREATE TABLE `time_entries` ( - `id` text PRIMARY KEY NOT NULL, - `user_id` text NOT NULL, - `organization_id` text NOT NULL, - `client_id` text NOT NULL, - `category_id` text NOT NULL, - `start_time` integer NOT NULL, - `end_time` integer, - `description` text, - `is_manual` integer DEFAULT false, - `created_at` integer, - FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action, - FOREIGN KEY (`organization_id`) REFERENCES `organizations`(`id`) ON UPDATE no action ON DELETE no action, - FOREIGN KEY (`client_id`) REFERENCES `clients`(`id`) ON UPDATE no action ON DELETE no action, - FOREIGN KEY (`category_id`) REFERENCES `categories`(`id`) ON UPDATE no action ON DELETE no action -); ---> statement-breakpoint -CREATE TABLE `time_entry_tags` ( - `time_entry_id` text NOT NULL, - `tag_id` text NOT NULL, - PRIMARY KEY(`time_entry_id`, `tag_id`), - FOREIGN KEY (`time_entry_id`) REFERENCES `time_entries`(`id`) ON UPDATE no action ON DELETE no action, - FOREIGN KEY (`tag_id`) REFERENCES `tags`(`id`) ON UPDATE no action ON DELETE no action -); ---> statement-breakpoint -CREATE TABLE `users` ( - `id` text PRIMARY KEY NOT NULL, - `email` text NOT NULL, - `password_hash` text NOT NULL, - `name` text NOT NULL, - `is_site_admin` integer DEFAULT false, - `created_at` integer -); ---> statement-breakpoint -CREATE UNIQUE INDEX `users_email_unique` ON `users` (`email`); \ No newline at end of file diff --git a/drizzle/meta/0000_snapshot.json b/drizzle/meta/0000_snapshot.json deleted file mode 100644 index f67b7bb..0000000 --- a/drizzle/meta/0000_snapshot.json +++ /dev/null @@ -1,980 +0,0 @@ -{ - "version": "6", - "dialect": "sqlite", - "id": "cfa98c92-215e-4dbc-b8d4-23a655684d1b", - "prevId": "00000000-0000-0000-0000-000000000000", - "tables": { - "api_tokens": { - "name": "api_tokens", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "token": { - "name": "token", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "scopes": { - "name": "scopes", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "'*'" - }, - "last_used_at": { - "name": "last_used_at", - "type": "integer", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "created_at": { - "name": "created_at", - "type": "integer", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "api_tokens_token_unique": { - "name": "api_tokens_token_unique", - "columns": [ - "token" - ], - "isUnique": true - } - }, - "foreignKeys": { - "api_tokens_user_id_users_id_fk": { - "name": "api_tokens_user_id_users_id_fk", - "tableFrom": "api_tokens", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraints": {} - }, - "categories": { - "name": "categories", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "color": { - "name": "color", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "created_at": { - "name": "created_at", - "type": "integer", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": { - "categories_organization_id_organizations_id_fk": { - "name": "categories_organization_id_organizations_id_fk", - "tableFrom": "categories", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraints": {} - }, - "clients": { - "name": "clients", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "created_at": { - "name": "created_at", - "type": "integer", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": { - "clients_organization_id_organizations_id_fk": { - "name": "clients_organization_id_organizations_id_fk", - "tableFrom": "clients", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraints": {} - }, - "invoice_items": { - "name": "invoice_items", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "invoice_id": { - "name": "invoice_id", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "quantity": { - "name": "quantity", - "type": "real", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": 1 - }, - "unit_price": { - "name": "unit_price", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": 0 - }, - "amount": { - "name": "amount", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": 0 - } - }, - "indexes": {}, - "foreignKeys": { - "invoice_items_invoice_id_invoices_id_fk": { - "name": "invoice_items_invoice_id_invoices_id_fk", - "tableFrom": "invoice_items", - "tableTo": "invoices", - "columnsFrom": [ - "invoice_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraints": {} - }, - "invoices": { - "name": "invoices", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "client_id": { - "name": "client_id", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "number": { - "name": "number", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "type": { - "name": "type", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "'invoice'" - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "'draft'" - }, - "issue_date": { - "name": "issue_date", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "due_date": { - "name": "due_date", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "currency": { - "name": "currency", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "'USD'" - }, - "subtotal": { - "name": "subtotal", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": 0 - }, - "tax_rate": { - "name": "tax_rate", - "type": "real", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": 0 - }, - "tax_amount": { - "name": "tax_amount", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": 0 - }, - "total": { - "name": "total", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "integer", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": { - "invoices_organization_id_organizations_id_fk": { - "name": "invoices_organization_id_organizations_id_fk", - "tableFrom": "invoices", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "invoices_client_id_clients_id_fk": { - "name": "invoices_client_id_clients_id_fk", - "tableFrom": "invoices", - "tableTo": "clients", - "columnsFrom": [ - "client_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraints": {} - }, - "members": { - "name": "members", - "columns": { - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "'member'" - }, - "joined_at": { - "name": "joined_at", - "type": "integer", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": { - "members_user_id_users_id_fk": { - "name": "members_user_id_users_id_fk", - "tableFrom": "members", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "members_organization_id_organizations_id_fk": { - "name": "members_organization_id_organizations_id_fk", - "tableFrom": "members", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "members_user_id_organization_id_pk": { - "columns": [ - "user_id", - "organization_id" - ], - "name": "members_user_id_organization_id_pk" - } - }, - "uniqueConstraints": {}, - "checkConstraints": {} - }, - "organizations": { - "name": "organizations", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "street": { - "name": "street", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "city": { - "name": "city", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "state": { - "name": "state", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "zip": { - "name": "zip", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "country": { - "name": "country", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "created_at": { - "name": "created_at", - "type": "integer", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraints": {} - }, - "sessions": { - "name": "sessions", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "expires_at": { - "name": "expires_at", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": { - "sessions_user_id_users_id_fk": { - "name": "sessions_user_id_users_id_fk", - "tableFrom": "sessions", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraints": {} - }, - "site_settings": { - "name": "site_settings", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "key": { - "name": "key", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "value": { - "name": "value", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "updated_at": { - "name": "updated_at", - "type": "integer", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "site_settings_key_unique": { - "name": "site_settings_key_unique", - "columns": [ - "key" - ], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraints": {} - }, - "tags": { - "name": "tags", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "color": { - "name": "color", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "created_at": { - "name": "created_at", - "type": "integer", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": { - "tags_organization_id_organizations_id_fk": { - "name": "tags_organization_id_organizations_id_fk", - "tableFrom": "tags", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraints": {} - }, - "time_entries": { - "name": "time_entries", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "client_id": { - "name": "client_id", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "category_id": { - "name": "category_id", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "start_time": { - "name": "start_time", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "end_time": { - "name": "end_time", - "type": "integer", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "is_manual": { - "name": "is_manual", - "type": "integer", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "integer", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": { - "time_entries_user_id_users_id_fk": { - "name": "time_entries_user_id_users_id_fk", - "tableFrom": "time_entries", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "time_entries_organization_id_organizations_id_fk": { - "name": "time_entries_organization_id_organizations_id_fk", - "tableFrom": "time_entries", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "time_entries_client_id_clients_id_fk": { - "name": "time_entries_client_id_clients_id_fk", - "tableFrom": "time_entries", - "tableTo": "clients", - "columnsFrom": [ - "client_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "time_entries_category_id_categories_id_fk": { - "name": "time_entries_category_id_categories_id_fk", - "tableFrom": "time_entries", - "tableTo": "categories", - "columnsFrom": [ - "category_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraints": {} - }, - "time_entry_tags": { - "name": "time_entry_tags", - "columns": { - "time_entry_id": { - "name": "time_entry_id", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "tag_id": { - "name": "tag_id", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": { - "time_entry_tags_time_entry_id_time_entries_id_fk": { - "name": "time_entry_tags_time_entry_id_time_entries_id_fk", - "tableFrom": "time_entry_tags", - "tableTo": "time_entries", - "columnsFrom": [ - "time_entry_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "time_entry_tags_tag_id_tags_id_fk": { - "name": "time_entry_tags_tag_id_tags_id_fk", - "tableFrom": "time_entry_tags", - "tableTo": "tags", - "columnsFrom": [ - "tag_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "time_entry_tags_time_entry_id_tag_id_pk": { - "columns": [ - "time_entry_id", - "tag_id" - ], - "name": "time_entry_tags_time_entry_id_tag_id_pk" - } - }, - "uniqueConstraints": {}, - "checkConstraints": {} - }, - "users": { - "name": "users", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "password_hash": { - "name": "password_hash", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "is_site_admin": { - "name": "is_site_admin", - "type": "integer", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "integer", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "users_email_unique": { - "name": "users_email_unique", - "columns": [ - "email" - ], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraints": {} - } - }, - "views": {}, - "enums": {}, - "_meta": { - "schemas": {}, - "tables": {}, - "columns": {} - }, - "internal": { - "indexes": {} - } -} \ No newline at end of file diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json deleted file mode 100644 index 802283f..0000000 --- a/drizzle/meta/_journal.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "version": "7", - "dialect": "sqlite", - "entries": [ - { - "idx": 0, - "version": "6", - "when": 1768609277648, - "tag": "0000_mixed_morlocks", - "breakpoints": true - } - ] -} \ No newline at end of file diff --git a/package.json b/package.json index 686a23d..3cecd22 100644 --- a/package.json +++ b/package.json @@ -16,11 +16,11 @@ "@astrojs/node": "^9.5.2", "@astrojs/vue": "^5.1.4", "@ceereals/vue-pdf": "^0.2.1", + "@libsql/client": "^0.17.0", "@tailwindcss/vite": "^4.1.18", "astro": "^5.16.11", "astro-icon": "^1.1.5", "bcryptjs": "^3.0.3", - "better-sqlite3": "^12.6.0", "chart.js": "^4.5.1", "daisyui": "^5.5.14", "drizzle-orm": "0.45.1", @@ -34,7 +34,6 @@ "@catppuccin/daisyui": "^2.1.1", "@iconify-json/heroicons": "^1.2.3", "@react-pdf/types": "^2.9.2", - "@types/better-sqlite3": "^7.6.13", "drizzle-kit": "0.31.8" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0c55e57..04272c5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,6 +20,9 @@ importers: '@ceereals/vue-pdf': specifier: ^0.2.1 version: 0.2.1(vue@3.5.26(typescript@5.9.3)) + '@libsql/client': + specifier: ^0.17.0 + version: 0.17.0 '@tailwindcss/vite': specifier: ^4.1.18 version: 4.1.18(vite@6.4.1(@types/node@25.0.9)(jiti@2.6.1)(lightningcss@1.30.2)(yaml@2.8.2)) @@ -32,9 +35,6 @@ importers: bcryptjs: specifier: ^3.0.3 version: 3.0.3 - better-sqlite3: - specifier: ^12.6.0 - version: 12.6.0 chart.js: specifier: ^4.5.1 version: 4.5.1 @@ -43,7 +43,7 @@ importers: version: 5.5.14 drizzle-orm: specifier: 0.45.1 - version: 0.45.1(@types/better-sqlite3@7.6.13)(better-sqlite3@12.6.0) + version: 0.45.1(@libsql/client@0.17.0)(@types/better-sqlite3@7.6.13)(better-sqlite3@12.6.0) nanoid: specifier: ^5.1.6 version: 5.1.6 @@ -69,9 +69,6 @@ importers: '@react-pdf/types': specifier: ^2.9.2 version: 2.9.2 - '@types/better-sqlite3': - specifier: ^7.6.13 - version: 7.6.13 drizzle-kit: specifier: 0.31.8 version: 0.31.8 @@ -793,6 +790,66 @@ packages: '@kurkle/color@0.3.4': resolution: {integrity: sha512-M5UknZPHRu3DEDWoipU6sE8PdkZ6Z/S+v4dD+Ke8IaNlpdSQah50lz1KtcFBa2vsdOnwbbnxJwVM4wty6udA5w==} + '@libsql/client@0.17.0': + resolution: {integrity: sha512-TLjSU9Otdpq0SpKHl1tD1Nc9MKhrsZbCFGot3EbCxRa8m1E5R1mMwoOjKMMM31IyF7fr+hPNHLpYfwbMKNusmg==} + + '@libsql/core@0.17.0': + resolution: {integrity: sha512-hnZRnJHiS+nrhHKLGYPoJbc78FE903MSDrFJTbftxo+e52X+E0Y0fHOCVYsKWcg6XgB7BbJYUrz/xEkVTSaipw==} + + '@libsql/darwin-arm64@0.5.22': + resolution: {integrity: sha512-4B8ZlX3nIDPndfct7GNe0nI3Yw6ibocEicWdC4fvQbSs/jdq/RC2oCsoJxJ4NzXkvktX70C1J4FcmmoBy069UA==} + cpu: [arm64] + os: [darwin] + + '@libsql/darwin-x64@0.5.22': + resolution: {integrity: sha512-ny2HYWt6lFSIdNFzUFIJ04uiW6finXfMNJ7wypkAD8Pqdm6nAByO+Fdqu8t7sD0sqJGeUCiOg480icjyQ2/8VA==} + cpu: [x64] + os: [darwin] + + '@libsql/hrana-client@0.9.0': + resolution: {integrity: sha512-pxQ1986AuWfPX4oXzBvLwBnfgKDE5OMhAdR/5cZmRaB4Ygz5MecQybvwZupnRz341r2CtFmbk/BhSu7k2Lm+Jw==} + + '@libsql/isomorphic-ws@0.1.5': + resolution: {integrity: sha512-DtLWIH29onUYR00i0GlQ3UdcTRC6EP4u9w/h9LxpUZJWRMARk6dQwZ6Jkd+QdwVpuAOrdxt18v0K2uIYR3fwFg==} + + '@libsql/linux-arm-gnueabihf@0.5.22': + resolution: {integrity: sha512-3Uo3SoDPJe/zBnyZKosziRGtszXaEtv57raWrZIahtQDsjxBVjuzYQinCm9LRCJCUT5t2r5Z5nLDPJi2CwZVoA==} + cpu: [arm] + os: [linux] + + '@libsql/linux-arm-musleabihf@0.5.22': + resolution: {integrity: sha512-LCsXh07jvSojTNJptT9CowOzwITznD+YFGGW+1XxUr7fS+7/ydUrpDfsMX7UqTqjm7xG17eq86VkWJgHJfvpNg==} + cpu: [arm] + os: [linux] + + '@libsql/linux-arm64-gnu@0.5.22': + resolution: {integrity: sha512-KSdnOMy88c9mpOFKUEzPskSaF3VLflfSUCBwas/pn1/sV3pEhtMF6H8VUCd2rsedwoukeeCSEONqX7LLnQwRMA==} + cpu: [arm64] + os: [linux] + + '@libsql/linux-arm64-musl@0.5.22': + resolution: {integrity: sha512-mCHSMAsDTLK5YH//lcV3eFEgiR23Ym0U9oEvgZA0667gqRZg/2px+7LshDvErEKv2XZ8ixzw3p1IrBzLQHGSsw==} + cpu: [arm64] + os: [linux] + + '@libsql/linux-x64-gnu@0.5.22': + resolution: {integrity: sha512-kNBHaIkSg78Y4BqAdgjcR2mBilZXs4HYkAmi58J+4GRwDQZh5fIUWbnQvB9f95DkWUIGVeenqLRFY2pcTmlsew==} + cpu: [x64] + os: [linux] + + '@libsql/linux-x64-musl@0.5.22': + resolution: {integrity: sha512-UZ4Xdxm4pu3pQXjvfJiyCzZop/9j/eA2JjmhMaAhe3EVLH2g11Fy4fwyUp9sT1QJYR1kpc2JLuybPM0kuXv/Tg==} + cpu: [x64] + os: [linux] + + '@libsql/win32-x64-msvc@0.5.22': + resolution: {integrity: sha512-Fj0j8RnBpo43tVZUVoNK6BV/9AtDUM5S7DF3LB4qTYg1LMSZqi3yeCneUTLJD6XomQJlZzbI4mst89yspVSAnA==} + cpu: [x64] + os: [win32] + + '@neon-rs/load@0.0.4': + resolution: {integrity: sha512-kTPhdZyTQxB+2wpiRcFWrDcejc4JI6tkPuS7UZCG4l6Zvc5kU/gGQ/ozvHTh1XR5tS+UlfAfGuPajjzQjCiHCw==} + '@oslojs/encoding@1.1.0': resolution: {integrity: sha512-70wQhgYmndg4GCPxPPxPGevRKqTIJ2Nh4OkiMWmDAVYsTQ+Ta7Sq+rPevXyXGdzr30/qZBnyOalCszoMxlyldQ==} @@ -1124,6 +1181,9 @@ packages: '@types/web-bluetooth@0.0.21': resolution: {integrity: sha512-oIQLCGWtcFZy2JW77j9k8nHzAOpqMHLQejDA48XXMWH6tjCQHz5RCFz1bzsmROyL6PUm+LLnUiI4BCn221inxA==} + '@types/ws@8.18.1': + resolution: {integrity: sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==} + '@types/yauzl@2.10.3': resolution: {integrity: sha512-oJoftv0LSuaDZE3Le4DbKX+KS9G36NzOeSap90UIK0yMA/NhKJhqlSGtNDORNRaIbQfzjXDrQa0ytJ6mNRGz/Q==} @@ -1520,6 +1580,9 @@ packages: resolution: {integrity: sha512-7Vv6asjS4gMOuILabD3l739tsaxFQmC+a7pLZm02zyvs8p977bL3zEgq3yDk5rn9B0PbYgIv++jmHcuUab4RhA==} engines: {node: '>=18'} + cross-fetch@4.1.0: + resolution: {integrity: sha512-uKm5PU+MHTootlWEY+mZ4vvXoCn4fLQxT9dSc1sXVMSFkINTJVN8cAQROpwcKm8bJ/c7rgZVIBWzH5T78sNZZw==} + cross-spawn@7.0.6: resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==} engines: {node: '>= 8'} @@ -1564,6 +1627,10 @@ packages: daisyui@5.5.14: resolution: {integrity: sha512-L47rvw7I7hK68TA97VB8Ee0woHew+/ohR6Lx6Ah/krfISOqcG4My7poNpX5Mo5/ytMxiR40fEaz6njzDi7cuSg==} + data-uri-to-buffer@4.0.1: + resolution: {integrity: sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==} + engines: {node: '>= 12'} + debug@4.4.3: resolution: {integrity: sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==} engines: {node: '>=6.0'} @@ -1614,6 +1681,10 @@ packages: destr@2.0.5: resolution: {integrity: sha512-ugFTXCtDZunbzasqBxrK93Ik/DRYsO6S/fedkWEMKqt04xZ4csmnmwGDBAb07QWNaGMAmnTIemsYZCksjATwsA==} + detect-libc@2.0.2: + resolution: {integrity: sha512-UX6sGumvvqSaXgdKGUsgZWqcUyIXZ/vZTrlRT/iobiKhGL0zL4d3osHj3uqllWJK+i+sixDS/3COVEOFbupFyw==} + engines: {node: '>=8'} + detect-libc@2.1.2: resolution: {integrity: sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==} engines: {node: '>=8'} @@ -1893,6 +1964,10 @@ packages: picomatch: optional: true + fetch-blob@3.2.0: + resolution: {integrity: sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==} + engines: {node: ^12.20 || >= 14.13} + figures@6.1.0: resolution: {integrity: sha512-d+l3qxjSesT4V7v2fh+QnmFnUWv9lSpjarhShNTgBOfA0ttejbQUAlHLitbjkoRiDulW0OPoQPYIGhIC8ohejg==} engines: {node: '>=18'} @@ -1921,6 +1996,10 @@ packages: resolution: {integrity: sha512-piJxbLnkD9Xcyi7dWJRnqszEURixe7CrF/efBfbffe2DPyabmuIuqraruY8cXTs19QoM8VJzx47BDRVNXETM7Q==} engines: {node: '>=20'} + formdata-polyfill@4.0.10: + resolution: {integrity: sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==} + engines: {node: '>=12.20.0'} + fresh@2.0.0: resolution: {integrity: sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==} engines: {node: '>= 0.8'} @@ -2157,6 +2236,9 @@ packages: resolution: {integrity: sha512-ekilCSN1jwRvIbgeg/57YFh8qQDNbwDb9xT/qu2DAHbFFZUicIl4ygVaAvzveMhMVr3LnpSKTNnwt8PoOfmKhQ==} hasBin: true + js-base64@3.7.8: + resolution: {integrity: sha512-hNngCeKxIUQiEUN3GPJOkz4wF/YvdUdbNL9hsBcMQTkKzboD7T/q3OYOuuPZLUE6dBxSGpwhk5mwuDud7JVAow==} + js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} @@ -2207,6 +2289,10 @@ packages: kolorist@1.8.0: resolution: {integrity: sha512-Y+60/zizpJ3HRH8DCss+q95yr6145JXZo46OTpFvDZWLfRCE4qChOyk1b26nMaNpfHHgxagk9dXT5OP0Tfe+dQ==} + libsql@0.5.22: + resolution: {integrity: sha512-NscWthMQt7fpU8lqd7LXMvT9pi+KhhmTHAJWUB/Lj6MWa0MKFv0F2V4C6WKKpjCVZl0VwcDz4nOI3CyaT1DDiA==} + os: [darwin, linux, win32] + lightningcss-android-arm64@1.30.2: resolution: {integrity: sha512-BH9sEdOCahSgmkVhBLeU7Hc9DWeZ1Eb6wNS6Da8igvUwAe0sqROHddIlvU06q3WyXVEOYDZ6ykBZQnjTbmo4+A==} engines: {node: '>= 12.0.0'} @@ -2515,9 +2601,27 @@ packages: resolution: {integrity: sha512-sn9Et4N3ynsetj3spsZR729DVlGH6iBG4RiDMV7HEp3guyOW6W3S0unGpLDxT50mXortGUMax/ykUNQXdqc/Xg==} engines: {node: '>=10'} + node-domexception@1.0.0: + resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==} + engines: {node: '>=10.5.0'} + deprecated: Use your platform's native DOMException instead + node-fetch-native@1.6.7: resolution: {integrity: sha512-g9yhqoedzIUm0nTnTqAQvueMPVOuIY16bqgAJJC8XOOubYFNwz6IER9qs0Gq2Xd0+CecCKFjtdDTMA4u4xG06Q==} + node-fetch@2.7.0: + resolution: {integrity: sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==} + engines: {node: 4.x || >=6.0.0} + peerDependencies: + encoding: ^0.1.0 + peerDependenciesMeta: + encoding: + optional: true + + node-fetch@3.3.2: + resolution: {integrity: sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + node-mock-http@1.0.4: resolution: {integrity: sha512-8DY+kFsDkNXy1sJglUfuODx1/opAGJGyrTuFqEoN90oRc2Vk0ZbD4K2qmKXBBEhZQzdKHIVfEJpDU8Ak2NJEvQ==} @@ -2682,6 +2786,9 @@ packages: resolution: {integrity: sha512-DEvV2ZF2r2/63V+tK8hQvrR2ZGn10srHbXviTlcv7Kpzw8jWiNTqbVgjO3IY8RxrrOUF8VPMQQFysYYYv0YZxw==} engines: {node: '>=6'} + promise-limit@2.7.0: + resolution: {integrity: sha512-7nJ6v5lnJsXwGprnGXga4wx6d1POjvi5Qmf1ivTRxTjH4Z/9Czja/UCMLVmB9N93GeWOU93XaFaEt6jbuoagNw==} + prompts@2.4.2: resolution: {integrity: sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==} engines: {node: '>= 6'} @@ -2996,6 +3103,9 @@ packages: resolution: {integrity: sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==} engines: {node: '>=6'} + tr46@0.0.3: + resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} + trim-lines@3.0.1: resolution: {integrity: sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg==} @@ -3363,6 +3473,13 @@ packages: web-namespaces@2.0.1: resolution: {integrity: sha512-bKr1DkiNa2krS7qxNtdrtHAmzuYGFQLiQ13TsorsdT6ULTkPLKuu5+GsFpDlg6JFjUTwX2DyhMPG2be8uPrqsQ==} + web-streams-polyfill@3.3.3: + resolution: {integrity: sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==} + engines: {node: '>= 8'} + + webidl-conversions@3.0.1: + resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} + whatwg-encoding@3.1.1: resolution: {integrity: sha512-6qN4hJdMwfYBtE3YBTTHhoeuUrDBPZmbQaxWAqSALV/MeEnR5z1xd8UKud2RAkFoPkmB+hli1TZSnyi84xz1vQ==} engines: {node: '>=18'} @@ -3372,6 +3489,9 @@ packages: resolution: {integrity: sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==} engines: {node: '>=18'} + whatwg-url@5.0.0: + resolution: {integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==} + which-pm-runs@1.1.0: resolution: {integrity: sha512-n1brCuqClxfFfq/Rb0ICg9giSZqCS+pLtccdag6C2HyufBrh3fBOiy9nb6ggRMvWOVH5GrdJskj5iGTZNxd7SA==} engines: {node: '>=4'} @@ -3396,6 +3516,18 @@ packages: wrappy@1.0.2: resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} + ws@8.19.0: + resolution: {integrity: sha512-blAT2mjOEIi0ZzruJfIhb3nps74PRWTCz1IjglWEEpQl5XS/UNama6u2/rjFkDDouqr4L67ry+1aGIALViWjDg==} + engines: {node: '>=10.0.0'} + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: '>=5.0.2' + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + wsl-utils@0.1.0: resolution: {integrity: sha512-h3Fbisa2nKGPxCpm89Hk33lBLsnaGBvctQopaBSOW/uIs6FTe1ATyAnKFJrzVs9vpGdsTe73WF3V4lIsk4Gacw==} engines: {node: '>=18'} @@ -4161,6 +4293,70 @@ snapshots: '@kurkle/color@0.3.4': {} + '@libsql/client@0.17.0': + dependencies: + '@libsql/core': 0.17.0 + '@libsql/hrana-client': 0.9.0 + js-base64: 3.7.8 + libsql: 0.5.22 + promise-limit: 2.7.0 + transitivePeerDependencies: + - bufferutil + - encoding + - utf-8-validate + + '@libsql/core@0.17.0': + dependencies: + js-base64: 3.7.8 + + '@libsql/darwin-arm64@0.5.22': + optional: true + + '@libsql/darwin-x64@0.5.22': + optional: true + + '@libsql/hrana-client@0.9.0': + dependencies: + '@libsql/isomorphic-ws': 0.1.5 + cross-fetch: 4.1.0 + js-base64: 3.7.8 + node-fetch: 3.3.2 + transitivePeerDependencies: + - bufferutil + - encoding + - utf-8-validate + + '@libsql/isomorphic-ws@0.1.5': + dependencies: + '@types/ws': 8.18.1 + ws: 8.19.0 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + + '@libsql/linux-arm-gnueabihf@0.5.22': + optional: true + + '@libsql/linux-arm-musleabihf@0.5.22': + optional: true + + '@libsql/linux-arm64-gnu@0.5.22': + optional: true + + '@libsql/linux-arm64-musl@0.5.22': + optional: true + + '@libsql/linux-x64-gnu@0.5.22': + optional: true + + '@libsql/linux-x64-musl@0.5.22': + optional: true + + '@libsql/win32-x64-msvc@0.5.22': + optional: true + + '@neon-rs/load@0.0.4': {} + '@oslojs/encoding@1.1.0': {} '@polka/url@1.0.0-next.29': {} @@ -4442,6 +4638,7 @@ snapshots: '@types/better-sqlite3@7.6.13': dependencies: '@types/node': 25.0.9 + optional: true '@types/debug@4.1.12': dependencies: @@ -4471,6 +4668,10 @@ snapshots: '@types/web-bluetooth@0.0.21': {} + '@types/ws@8.18.1': + dependencies: + '@types/node': 25.0.9 + '@types/yauzl@2.10.3': dependencies: '@types/node': 25.0.9 @@ -4854,6 +5055,7 @@ snapshots: dependencies: bindings: 1.5.0 prebuild-install: 7.1.3 + optional: true bidi-js@1.0.3: dependencies: @@ -4862,6 +5064,7 @@ snapshots: bindings@1.5.0: dependencies: file-uri-to-path: 1.0.0 + optional: true birpc@2.9.0: {} @@ -4870,6 +5073,7 @@ snapshots: buffer: 5.7.1 inherits: 2.0.4 readable-stream: 3.6.2 + optional: true boolbase@1.0.0: {} @@ -4912,6 +5116,7 @@ snapshots: dependencies: base64-js: 1.5.1 ieee754: 1.2.1 + optional: true bundle-name@4.1.0: dependencies: @@ -4988,7 +5193,8 @@ snapshots: dependencies: readdirp: 5.0.0 - chownr@1.1.4: {} + chownr@1.1.4: + optional: true chownr@3.0.0: {} @@ -5041,6 +5247,12 @@ snapshots: dependencies: is-what: 5.5.0 + cross-fetch@4.1.0: + dependencies: + node-fetch: 2.7.0 + transitivePeerDependencies: + - encoding + cross-spawn@7.0.6: dependencies: path-key: 3.1.1 @@ -5088,6 +5300,8 @@ snapshots: daisyui@5.5.14: {} + data-uri-to-buffer@4.0.1: {} + debug@4.4.3: dependencies: ms: 2.1.3 @@ -5099,8 +5313,10 @@ snapshots: decompress-response@6.0.0: dependencies: mimic-response: 3.1.0 + optional: true - deep-extend@0.6.0: {} + deep-extend@0.6.0: + optional: true default-browser-id@5.0.1: {} @@ -5125,6 +5341,8 @@ snapshots: destr@2.0.5: {} + detect-libc@2.0.2: {} + detect-libc@2.1.2: {} deterministic-object-hash@2.0.2: @@ -5170,8 +5388,9 @@ snapshots: transitivePeerDependencies: - supports-color - drizzle-orm@0.45.1(@types/better-sqlite3@7.6.13)(better-sqlite3@12.6.0): + drizzle-orm@0.45.1(@libsql/client@0.17.0)(@types/better-sqlite3@7.6.13)(better-sqlite3@12.6.0): optionalDependencies: + '@libsql/client': 0.17.0 '@types/better-sqlite3': 7.6.13 better-sqlite3: 12.6.0 @@ -5324,7 +5543,8 @@ snapshots: strip-final-newline: 4.0.0 yoctocolors: 2.1.2 - expand-template@2.0.3: {} + expand-template@2.0.3: + optional: true exsolve@1.0.8: {} @@ -5352,11 +5572,17 @@ snapshots: optionalDependencies: picomatch: 4.0.3 + fetch-blob@3.2.0: + dependencies: + node-domexception: 1.0.0 + web-streams-polyfill: 3.3.3 + figures@6.1.0: dependencies: is-unicode-supported: 2.1.0 - file-uri-to-path@1.0.0: {} + file-uri-to-path@1.0.0: + optional: true fill-range@7.1.1: dependencies: @@ -5388,9 +5614,14 @@ snapshots: dependencies: tiny-inflate: 1.0.3 + formdata-polyfill@4.0.10: + dependencies: + fetch-blob: 3.2.0 + fresh@2.0.0: {} - fs-constants@1.0.0: {} + fs-constants@1.0.0: + optional: true fs-extra@10.1.0: dependencies: @@ -5446,7 +5677,8 @@ snapshots: dependencies: resolve-pkg-maps: 1.0.0 - github-from-package@0.0.0: {} + github-from-package@0.0.0: + optional: true github-slugger@2.0.0: {} @@ -5604,13 +5836,15 @@ snapshots: dependencies: safer-buffer: 2.1.2 - ieee754@1.2.1: {} + ieee754@1.2.1: + optional: true import-meta-resolve@4.2.0: {} inherits@2.0.4: {} - ini@1.3.8: {} + ini@1.3.8: + optional: true iron-webcrypto@1.2.1: {} @@ -5656,6 +5890,8 @@ snapshots: jiti@2.6.1: {} + js-base64@3.7.8: {} + js-tokens@4.0.0: {} js-yaml@4.1.1: @@ -5698,6 +5934,21 @@ snapshots: kolorist@1.8.0: {} + libsql@0.5.22: + dependencies: + '@neon-rs/load': 0.0.4 + detect-libc: 2.0.2 + optionalDependencies: + '@libsql/darwin-arm64': 0.5.22 + '@libsql/darwin-x64': 0.5.22 + '@libsql/linux-arm-gnueabihf': 0.5.22 + '@libsql/linux-arm-musleabihf': 0.5.22 + '@libsql/linux-arm64-gnu': 0.5.22 + '@libsql/linux-arm64-musl': 0.5.22 + '@libsql/linux-x64-gnu': 0.5.22 + '@libsql/linux-x64-musl': 0.5.22 + '@libsql/win32-x64-msvc': 0.5.22 + lightningcss-android-arm64@1.30.2: optional: true @@ -6112,7 +6363,8 @@ snapshots: dependencies: mime-db: 1.54.0 - mimic-response@3.1.0: {} + mimic-response@3.1.0: + optional: true minimist@1.2.8: {} @@ -6124,7 +6376,8 @@ snapshots: mitt@3.0.1: {} - mkdirp-classic@0.5.3: {} + mkdirp-classic@0.5.3: + optional: true mlly@1.8.0: dependencies: @@ -6143,7 +6396,8 @@ snapshots: nanoid@5.1.6: {} - napi-build-utils@2.0.0: {} + napi-build-utils@2.0.0: + optional: true neotraverse@0.6.18: {} @@ -6154,9 +6408,22 @@ snapshots: node-abi@3.86.0: dependencies: semver: 7.7.3 + optional: true + + node-domexception@1.0.0: {} node-fetch-native@1.6.7: {} + node-fetch@2.7.0: + dependencies: + whatwg-url: 5.0.0 + + node-fetch@3.3.2: + dependencies: + data-uri-to-buffer: 4.0.1 + fetch-blob: 3.2.0 + formdata-polyfill: 4.0.10 + node-mock-http@1.0.4: {} node-releases@2.0.27: {} @@ -6330,6 +6597,7 @@ snapshots: simple-get: 4.0.1 tar-fs: 2.1.4 tunnel-agent: 0.6.0 + optional: true prettier@3.8.0: {} @@ -6339,6 +6607,8 @@ snapshots: prismjs@1.30.0: {} + promise-limit@2.7.0: {} + prompts@2.4.2: dependencies: kleur: 3.0.3 @@ -6367,12 +6637,14 @@ snapshots: ini: 1.3.8 minimist: 1.2.8 strip-json-comments: 2.0.1 + optional: true readable-stream@3.6.2: dependencies: inherits: 2.0.4 string_decoder: 1.3.0 util-deprecate: 1.0.2 + optional: true readdirp@4.1.2: {} @@ -6616,13 +6888,15 @@ snapshots: signal-exit@4.1.0: {} - simple-concat@1.0.1: {} + simple-concat@1.0.1: + optional: true simple-get@4.0.1: dependencies: decompress-response: 6.0.0 once: 1.4.0 simple-concat: 1.0.1 + optional: true simple-swizzle@0.2.4: dependencies: @@ -6686,7 +6960,8 @@ snapshots: strip-final-newline@4.0.0: {} - strip-json-comments@2.0.1: {} + strip-json-comments@2.0.1: + optional: true superjson@2.2.6: dependencies: @@ -6728,6 +7003,7 @@ snapshots: mkdirp-classic: 0.5.3 pump: 3.0.3 tar-stream: 2.2.0 + optional: true tar-stream@2.2.0: dependencies: @@ -6736,6 +7012,7 @@ snapshots: fs-constants: 1.0.0 inherits: 2.0.4 readable-stream: 3.6.2 + optional: true tar@7.5.3: dependencies: @@ -6764,6 +7041,8 @@ snapshots: totalist@3.0.1: {} + tr46@0.0.3: {} + trim-lines@3.0.1: {} trough@2.2.0: {} @@ -6777,6 +7056,7 @@ snapshots: tunnel-agent@0.6.0: dependencies: safe-buffer: 5.2.1 + optional: true type-fest@4.41.0: {} @@ -7094,12 +7374,21 @@ snapshots: web-namespaces@2.0.1: {} + web-streams-polyfill@3.3.3: {} + + webidl-conversions@3.0.1: {} + whatwg-encoding@3.1.1: dependencies: iconv-lite: 0.6.3 whatwg-mimetype@4.0.0: {} + whatwg-url@5.0.0: + dependencies: + tr46: 0.0.3 + webidl-conversions: 3.0.1 + which-pm-runs@1.1.0: {} which@2.0.2: @@ -7124,6 +7413,8 @@ snapshots: wrappy@1.0.2: {} + ws@8.19.0: {} + wsl-utils@0.1.0: dependencies: is-wsl: 3.1.0 diff --git a/src/db/index.ts b/src/db/index.ts index 3980e2e..a4977bc 100644 --- a/src/db/index.ts +++ b/src/db/index.ts @@ -1,22 +1,41 @@ -import Database from 'better-sqlite3'; -import { drizzle } from 'drizzle-orm/better-sqlite3'; -import * as schema from './schema'; -import path from 'path'; +import { drizzle } from "drizzle-orm/libsql"; +import { createClient } from "@libsql/client"; +import * as schema from "./schema"; +import path from "path"; -let _db: ReturnType | null = null; +// Define the database type based on the schema +type Database = ReturnType>; -function initDb() { +let _db: Database | null = null; + +function initDb(): Database { if (!_db) { - const dbUrl = process.env.DATABASE_URL || path.resolve(process.cwd(), 'chronus.db'); - const sqlite = new Database(dbUrl, { readonly: false }); - _db = drizzle(sqlite, { schema }); + let url = process.env.DATABASE_URL; + if (!url) { + url = `file:${path.resolve(process.cwd(), "chronus.db")}`; + } else if ( + !url.startsWith("file:") && + !url.startsWith("libsql:") && + !url.startsWith("http:") && + !url.startsWith("https:") + ) { + url = `file:${url}`; + } + const authToken = process.env.DATABASE_AUTH_TOKEN; + + const client = createClient({ + url, + authToken, + }); + + _db = drizzle(client, { schema }); } return _db; } -export const db = new Proxy({} as ReturnType, { +export const db = new Proxy({} as Database, { get(_target, prop) { const database = initDb(); - return database[prop as keyof typeof database]; - } + return database[prop as keyof Database]; + }, });