From ad2c43cde28c33099e2d8175dabcd81b7cd3e506 Mon Sep 17 00:00:00 2001 From: raja Date: Mon, 25 Nov 2024 21:56:01 +0300 Subject: [PATCH] apply biome on codebase --- drizzle.config.ts | 16 +-- drizzle/query.ts | 27 +++-- drizzle/schema.ts | 38 +++---- drizzle/types.d.ts | 38 +++---- gruntfile.cjs | 2 +- package.json | 232 +++++++++++++++++++++--------------------- src/@types/index.d.ts | 22 ++-- src/api/index.ts | 2 +- 8 files changed, 194 insertions(+), 183 deletions(-) diff --git a/drizzle.config.ts b/drizzle.config.ts index c047c48..7d493f3 100644 --- a/drizzle.config.ts +++ b/drizzle.config.ts @@ -3,12 +3,12 @@ import { defineConfig } from "drizzle-kit"; //Configured for SQLite with Bun sqlite export default defineConfig({ - dialect: "sqlite", - schema: "./drizzle/schema.ts", - out: "./drizzle/migrations", - dbCredentials: { - url: process.env.DATABASE_URL as string, - }, - strict: true, - verbose: true, + dialect: "sqlite", + schema: "./drizzle/schema.ts", + out: "./drizzle/migrations", + dbCredentials: { + url: process.env.DATABASE_URL as string, + }, + strict: true, + verbose: true, }); diff --git a/drizzle/query.ts b/drizzle/query.ts index 72ca434..5d17615 100644 --- a/drizzle/query.ts +++ b/drizzle/query.ts @@ -7,22 +7,35 @@ import { tGemini, tGeminiUsage } from "./schema"; /* types */ import type { - I_Gemini, - I_GeminiUsage, - T_qInsertTable, - T_qInsertValues, + I_Gemini, + I_GeminiUsage, + T_qInsertTable, + T_qInsertValues, + T_tGeminiSchema, + T_tGeminiUsageSchema, } from "./types"; // =============================== export const rGemini: I_Gemini = ( - await db.select().from(tGemini).where(eq(tGemini.geminiId, 1)) + await db.select().from(tGemini).where(eq(tGemini.geminiId, 1)) )[0]; export const rGeminiUsage: I_GeminiUsage = ( - await db.select().from(tGeminiUsage).where(eq(tGeminiUsage.geminiUsageId, 1)) + await db.select().from(tGeminiUsage).where(eq(tGeminiUsage.geminiUsageId, 1)) )[0]; export async function qInsert(table: T_qInsertTable, values: T_qInsertValues) { - await db.insert(table).values(values); + await db.insert(table).values(values); +} + +export async function qUpdateGemini(values: T_tGeminiSchema) { + await db.update(tGemini).set(values).where(eq(tGemini.geminiId, 1)); +} + +export async function qUpdateGeminiUsage(values: T_tGeminiUsageSchema) { + await db + .update(tGeminiUsage) + .set(values) + .where(eq(tGeminiUsage.geminiUsageId, 1)); } diff --git a/drizzle/schema.ts b/drizzle/schema.ts index 0ba2d4c..d72afe6 100644 --- a/drizzle/schema.ts +++ b/drizzle/schema.ts @@ -4,26 +4,26 @@ import { sqliteTable, integer, numeric } from "drizzle-orm/sqlite-core"; // ============================== export const tGemini = sqliteTable("t_gemini", { - geminiId: integer("gemini_id").primaryKey({ autoIncrement: true }), - apiKey: numeric("api_key"), - model: numeric("model").notNull(), - prompt: numeric("prompt").notNull(), + geminiId: integer("gemini_id").primaryKey({ autoIncrement: true }), + apiKey: numeric("api_key"), + model: numeric("model").notNull(), + prompt: numeric("prompt").notNull(), }); export const tGeminiUsage = sqliteTable("t_gemini_usage", { - geminiUsageId: integer("gemini_usage_id").primaryKey({ autoIncrement: true }), - rpmLimit: integer("rpm_limit").notNull(), - rpdLimit: integer("rpd_limit").notNull(), - tpmLimit: integer("tpm_limit").notNull(), - rpmStart: numeric("rpm_start"), - rpdStart: numeric("rpd_start"), - tpmStart: numeric("tpm_start"), - rpmEnd: numeric("rpm_end"), - rpdEnd: numeric("rpd_end"), - tpmEnd: numeric("tpm_end"), - rpmCounter: integer("rpm_counter"), - rpdCounter: integer("rpd_counter"), - tpmCounter: integer("tpm_counter"), - intervalDelay: integer("interval_delay"), - breakDelay: integer("breakDelay"), + geminiUsageId: integer("gemini_usage_id").primaryKey({ autoIncrement: true }), + rpmLimit: integer("rpm_limit").notNull(), + rpdLimit: integer("rpd_limit").notNull(), + tpmLimit: integer("tpm_limit").notNull(), + rpmStart: numeric("rpm_start"), + rpdStart: numeric("rpd_start"), + tpmStart: numeric("tpm_start"), + rpmEnd: numeric("rpm_end"), + rpdEnd: numeric("rpd_end"), + tpmEnd: numeric("tpm_end"), + rpmCounter: integer("rpm_counter"), + rpdCounter: integer("rpd_counter"), + tpmCounter: integer("tpm_counter"), + intervalDelay: integer("interval_delay"), + breakDelay: integer("breakDelay"), }); diff --git a/drizzle/types.d.ts b/drizzle/types.d.ts index 3ecafcd..5567e93 100644 --- a/drizzle/types.d.ts +++ b/drizzle/types.d.ts @@ -10,26 +10,26 @@ export type T_qInsertTable = T_tGemini | T_tGeminiUsage; export type T_qInsertValues = T_tGeminiSchema | T_tGeminiUsageSchema; export interface I_Gemini { - geminiId: number; - apiKey: string | null; - model: string; - prompt: string; + geminiId: number; + apiKey: string | null; + model: string; + prompt: string; } export interface I_GeminiUsage { - geminiUsageId: number; - rpmLimit: number; - rpdLimit: number; - tpmLimit: number; - rpmStart: string | null; - rpdStart: string | null; - tpmStart: string | null; - rpmEnd: string | null; - rpdEnd: string | null; - tpmEnd: string | null; - rpmCounter: number | null; - rpdCounter: number | null; - tpmCounter: number | null; - intervalDelay: number | null; - breakDelay: number | null; + geminiUsageId: number; + rpmLimit: number; + rpdLimit: number; + tpmLimit: number; + rpmStart: string | null; + rpdStart: string | null; + tpmStart: string | null; + rpmEnd: string | null; + rpdEnd: string | null; + tpmEnd: string | null; + rpmCounter: number | null; + rpdCounter: number | null; + tpmCounter: number | null; + intervalDelay: number | null; + breakDelay: number | null; } diff --git a/gruntfile.cjs b/gruntfile.cjs index 37f93a3..2a71f2f 100644 --- a/gruntfile.cjs +++ b/gruntfile.cjs @@ -45,7 +45,7 @@ module.exports = (grunt) => { src: includeAllFiles, dest: "bin", }, - drizzle: { + drizzle: { options: { archive: `${backupsDestination}drizzle.tar.gz`, }, diff --git a/package.json b/package.json index 6e09d15..2b8d874 100644 --- a/package.json +++ b/package.json @@ -1,119 +1,117 @@ { - "name": "lucy", - "version": "1.0.0", - "description": "Personal hacking assistant 💀", - "author": "Raja Rakotonirina ", - "license": "MIT", - "type": "module", - "module": "index.ts", - "main": "./dist/index.js", - "types": "./dist/index.d.ts", - "bin": { - "lucy": "./dist/index.js" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/RajaRakoto/lucy.git" - }, - "homepage": "https://github.com/RajaRakoto/lucy#readme", - "bugs": "https://github.com/RajaRakoto/lucy/issues", - "files": [ - "dist" - ], - "keywords": [ - "bun", - "bunjs", - "cli", - "typescript", - "tool", - "hacking", - "assistant" - ], - "engines": { - "bun": ">= 1.1.34" - }, - "scripts": { - "start": "bun dist/index.js", - "start:smol": "bun --smol dist/index.js", - "start:bin": "./dist/lucy", - "clean": "rimraf build dist coverage", - "dev": "bun run src/index.ts", - "dev:watch": "bun --watch run src/index.ts", - "dev:hot": "bun --hot run src/index.ts", - "dev:smol:watch": "bun --smol --watch run src/index.ts", - "dev:smol:hot": "bun --smol --hot run src/index.ts", - "build": "bun run clean && bun run build.js && grunt copy", - "build:watch": "bun build src/index.ts --outdir dist --watch", - "build:bin": "bun build --compile --minify --sourcemap src/index.ts --outfile dist/lucy", - "test": "bun test", - "test:watch": "bun test --watch", - "biome:start": "biome start", - "biome:stop": "biome stop", - "biome:fix": "biome check --fix .", - "biome:unsafe": "biome check --fix --unsafe .", - "backup": "grunt backup", - "pkg-check": "depcheck", - "pkg-upgrade": "ncu --interactive --format group --packageManager bun", - "versioning": "ungit", - "npm-version:major": "npm version major", - "npm-version:minor": "npm version minor", - "npm-version:patch": "npm version patch", - "npm-login": "npm login", - "npm-publish": "npm publish --access public", - "npm-unpublish": "npm unpublish --force lucy", - "npm-reset:registry": "npm config delete registry", - "npm-check:registry": "npm config get registry", - "npm-proxy-set:registry": "npm set registry http://localhost:4873/", - "npm-proxy:start": "bun run npm-proxy-set:registry && verdaccio", - "npm-proxy:publish": "npm publish --registry http://localhost:4873/", - "npm-proxy:unpublish": "npm unpublish --force --registry http://localhost:4873/ lucy", - "npm-proxy:republish": "bun run npm-proxy:unpublish && bun run npm-proxy:publish", - "nvm": "nvm use", - "db:pull": "drizzle-kit introspect", - "db:push": "drizzle-kit push", - "db:migrate": "drizzle-kit migrate", - "db:generate": "drizzle-kit generate", - "db:drop": "drizzle-kit drop", - "db:up": "drizzle-kit up", - "db:check": "drizzle-kit check", - "db:studio": "drizzle-kit studio" - }, - "dependencies": { - "@google/generative-ai": "^0.21.0", - "better-sqlite3": "^11.5.0", - "commander": "^12.1.0", - "drizzle-orm": "^0.36.3", - "execa": "^9.5.1", - "figlet": "^1.8.0", - "inquirer": "^9.2.15", - "node-emoji": "^2.1.3", - "ora": "^8.1.1" - }, - "devDependencies": { - "@biomejs/biome": "1.9.4", - "@types/better-sqlite3": "^7.6.12", - "@types/bun": "latest", - "@types/commander": "^2.12.5", - "@types/execa": "^2.0.2", - "@types/figlet": "^1.7.0", - "@types/inquirer": "^9.0.7", - "@types/jest": "^29.5.14", - "@types/node-emoji": "^2.1.0", - "@types/ora": "^3.2.0", - "bun-plugin-dts": "^0.3.0", - "depcheck": "^1.4.7", - "drizzle-kit": "^0.28.1", - "grunt": "^1.6.1", - "grunt-contrib-compress": "^2.0.0", - "grunt-shell": "^4.0.0", - "jest": "^29.7.0", - "load-grunt-tasks": "^5.1.0", - "npm-check-updates": "^17.1.11", - "rimraf": "^6.0.1", - "ts-jest": "^29.2.5", - "ungit": "^1.5.28" - }, - "peerDependencies": { - "typescript": "^5.0.0" - } + "name": "lucy", + "version": "1.0.0", + "description": "Personal hacking assistant 💀", + "author": "Raja Rakotonirina ", + "license": "MIT", + "type": "module", + "module": "index.ts", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "bin": { + "lucy": "./dist/index.js" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/RajaRakoto/lucy.git" + }, + "homepage": "https://github.com/RajaRakoto/lucy#readme", + "bugs": "https://github.com/RajaRakoto/lucy/issues", + "files": ["dist"], + "keywords": [ + "bun", + "bunjs", + "cli", + "typescript", + "tool", + "hacking", + "assistant" + ], + "engines": { + "bun": ">= 1.1.34" + }, + "scripts": { + "start": "bun dist/index.js", + "start:smol": "bun --smol dist/index.js", + "start:bin": "./dist/lucy", + "clean": "rimraf build dist coverage", + "dev": "bun run src/index.ts", + "dev:watch": "bun --watch run src/index.ts", + "dev:hot": "bun --hot run src/index.ts", + "dev:smol:watch": "bun --smol --watch run src/index.ts", + "dev:smol:hot": "bun --smol --hot run src/index.ts", + "build": "bun run clean && bun run build.js && grunt copy", + "build:watch": "bun build src/index.ts --outdir dist --watch", + "build:bin": "bun build --compile --minify --sourcemap src/index.ts --outfile dist/lucy", + "test": "bun test", + "test:watch": "bun test --watch", + "biome:start": "biome start", + "biome:stop": "biome stop", + "biome:fix": "biome check --fix .", + "biome:unsafe": "biome check --fix --unsafe .", + "backup": "grunt backup", + "pkg-check": "depcheck", + "pkg-upgrade": "ncu --interactive --format group --packageManager bun", + "versioning": "ungit", + "npm-version:major": "npm version major", + "npm-version:minor": "npm version minor", + "npm-version:patch": "npm version patch", + "npm-login": "npm login", + "npm-publish": "npm publish --access public", + "npm-unpublish": "npm unpublish --force lucy", + "npm-reset:registry": "npm config delete registry", + "npm-check:registry": "npm config get registry", + "npm-proxy-set:registry": "npm set registry http://localhost:4873/", + "npm-proxy:start": "bun run npm-proxy-set:registry && verdaccio", + "npm-proxy:publish": "npm publish --registry http://localhost:4873/", + "npm-proxy:unpublish": "npm unpublish --force --registry http://localhost:4873/ lucy", + "npm-proxy:republish": "bun run npm-proxy:unpublish && bun run npm-proxy:publish", + "nvm": "nvm use", + "db:pull": "drizzle-kit introspect", + "db:push": "drizzle-kit push", + "db:migrate": "drizzle-kit migrate", + "db:generate": "drizzle-kit generate", + "db:drop": "drizzle-kit drop", + "db:up": "drizzle-kit up", + "db:check": "drizzle-kit check", + "db:studio": "drizzle-kit studio" + }, + "dependencies": { + "@google/generative-ai": "^0.21.0", + "better-sqlite3": "^11.5.0", + "commander": "^12.1.0", + "drizzle-orm": "^0.36.3", + "execa": "^9.5.1", + "figlet": "^1.8.0", + "inquirer": "^9.2.15", + "node-emoji": "^2.1.3", + "ora": "^8.1.1" + }, + "devDependencies": { + "@biomejs/biome": "1.9.4", + "@types/better-sqlite3": "^7.6.12", + "@types/bun": "latest", + "@types/commander": "^2.12.5", + "@types/execa": "^2.0.2", + "@types/figlet": "^1.7.0", + "@types/inquirer": "^9.0.7", + "@types/jest": "^29.5.14", + "@types/node-emoji": "^2.1.0", + "@types/ora": "^3.2.0", + "bun-plugin-dts": "^0.3.0", + "depcheck": "^1.4.7", + "drizzle-kit": "^0.28.1", + "grunt": "^1.6.1", + "grunt-contrib-compress": "^2.0.0", + "grunt-shell": "^4.0.0", + "jest": "^29.7.0", + "load-grunt-tasks": "^5.1.0", + "npm-check-updates": "^17.1.11", + "rimraf": "^6.0.1", + "ts-jest": "^29.2.5", + "ungit": "^1.5.28" + }, + "peerDependencies": { + "typescript": "^5.0.0" + } } diff --git a/src/@types/index.d.ts b/src/@types/index.d.ts index 6bdd86c..e1bbf37 100644 --- a/src/@types/index.d.ts +++ b/src/@types/index.d.ts @@ -1,16 +1,16 @@ export interface I_UploadResult { - displayName: string; - mimeType: string; - uri: string; + displayName: string; + mimeType: string; + uri: string; } export interface I_Display { - model: boolean; - prompt: boolean; - rpmCounter: boolean; - rpdCounter: boolean; - tpmCounter: boolean; - intervalDelay: boolean; - breakDelay: boolean; - totalPDF: boolean; + model: boolean; + prompt: boolean; + rpmCounter: boolean; + rpdCounter: boolean; + tpmCounter: boolean; + intervalDelay: boolean; + breakDelay: boolean; + totalPDF: boolean; } diff --git a/src/api/index.ts b/src/api/index.ts index 754f190..05faa75 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -11,5 +11,5 @@ export const genAI = new GoogleGenerativeAI(rGemini.apiKey || ""); export const fileManager = new GoogleAIFileManager(rGemini.apiKey || ""); export const geminiModel = genAI.getGenerativeModel({ - model: rGemini.model, + model: rGemini.model, });