From 644cf9b8eabd8ee4bca5d1fade743f9befba2445 Mon Sep 17 00:00:00 2001 From: melvinchia3636 Date: Thu, 17 Jul 2025 21:23:51 +0800 Subject: [PATCH] 25w29 Former-commit-id: e3dd3b1fa9510cbaa4ff21deda9310f86583e99c [formerly d71f00314d37442771ad59cfd33de230df9ff2d6] [formerly d236ed1a6d2ef949f36387e84bcd50425d24e266 [formerly 89aec5e5c3e321e53e8cec93effa25c6cd44039e]] Former-commit-id: f0ab09ec99e37dbefa18d8b873149044ecac5ee7 [formerly 211e34db4b22b193e2da9a5a7af70458249ed8e2] Former-commit-id: 82c9b5a2300566822f787af1f9eed1ddafdf1696 --- .../components/DifficultySelector.tsx | 7 +- .../Achievements/components/EntryItem.tsx | 10 +- .../components/ModifyAchievementModal.tsx | 14 +- client/src/apps/Achievements/index.tsx | 6 +- client/src/apps/Blog/index.tsx | 5 +- .../apps/Blog/interfaces/blog_interfaces.ts | 15 +-- package.json | 5 + .../blog/controllers/entries.contorller.ts | 5 +- server/src/apps/blog/schema.ts | 36 ----- .../src/apps/blog/services/entries.service.ts | 9 +- .../controllers/collection.controller.ts | 14 +- .../controllers/entries.controller.ts | 12 +- .../controllers/fileTypes.controller.ts | 4 +- .../controllers/languages.controller.ts | 12 +- .../controllers/libgen.controller.ts | 9 +- server/src/apps/booksLibrary/schema.ts | 110 --------------- .../services/collections.service.ts | 39 +++--- .../booksLibrary/services/entries.service.ts | 27 ++-- .../services/fileTypes.service.ts | 7 +- .../services/languages.service.ts | 15 +-- .../services/libgen.service/api/search.ts | 15 +-- .../libgen.service/download/process.ts | 7 +- .../controllers/calendars.controller.ts | 14 +- .../controllers/categories.controller.ts | 14 +- .../calendar/controllers/events.controller.ts | 18 +-- server/src/apps/calendar/schema.ts | 70 ---------- .../calendar/services/calendars.service.ts | 31 +++-- .../calendar/services/categories.service.ts | 31 +++-- .../apps/calendar/services/events.service.ts | 52 +++---- .../controllers/codeTime.controller.ts | 12 +- server/src/apps/codeTime/schema.ts | 69 ---------- .../codeTime/services/codeTime.service.ts | 23 ++-- .../controllers/entries.controller.ts | 14 +- .../controllers/guitarWorld.controller.ts | 4 +- server/src/apps/guitarTabs/schema.ts | 66 --------- .../guitarTabs/services/entries.service.ts | 45 ++++--- .../services/guitarWorld.service.ts | 7 +- .../controllers/containers.controller.ts | 10 +- .../ideaBox/controllers/folders.controller.ts | 12 +- .../ideaBox/controllers/ideas.controller.ts | 20 +-- .../ideaBox/controllers/tags.controller.ts | 12 +- server/src/apps/ideaBox/schema.ts | 91 ------------- .../ideaBox/services/containers.service.ts | 25 ++-- .../apps/ideaBox/services/folders.service.ts | 55 ++++---- .../apps/ideaBox/services/ideas.service.ts | 53 ++++---- .../src/apps/ideaBox/services/misc.service.ts | 37 +++-- .../src/apps/ideaBox/services/tags.service.ts | 17 +-- .../controllers/entries.controller.ts | 8 +- server/src/apps/momentVault/schema.ts | 25 ---- .../momentVault/services/entries.service.ts | 26 ++-- .../services/transcription.service.ts | 13 +- .../movies/controllers/entries.controller.ts | 8 +- .../movies/controllers/ticket.controller.ts | 10 +- server/src/apps/movies/schema.ts | 38 ------ .../apps/movies/services/entries.service.ts | 23 ++-- .../apps/movies/services/ticket.service.ts | 25 ++-- .../src/apps/movies/services/tmdb.service.ts | 5 +- .../music/controllers/entries.controller.ts | 10 +- .../music/controllers/youtube.controller.ts | 4 +- server/src/apps/music/schema.ts | 41 ------ .../apps/music/services/entries.service.ts | 21 +-- .../apps/music/services/youtube.service.ts | 9 +- .../controllers/entries.controller.ts | 14 +- server/src/apps/passwords/schema.ts | 28 ---- .../passwords/services/entries.service.ts | 26 ++-- .../controllers/railwayMap.controller.ts | 8 +- server/src/apps/railwayMap/schema.ts | 41 ------ .../railwayMap/services/railwayMap.service.ts | 18 ++- .../controllers/entries.controller.ts | 18 +-- .../todoList/controllers/lists.controller.ts | 24 +++- .../controllers/priorities.controller.ts | 14 +- .../todoList/controllers/tags.controller.ts | 16 ++- server/src/apps/todoList/schema.ts | 100 -------------- .../apps/todoList/services/entries.service.ts | 39 +++--- .../apps/todoList/services/lists.service.ts | 23 ++-- .../todoList/services/priorities.service.ts | 23 ++-- .../apps/todoList/services/tags.service.ts | 23 ++-- .../controllers/entries.controller.ts | 15 +-- .../controllers/session.controller.ts | 4 +- server/src/apps/virtualWardrobe/schema.ts | 57 -------- .../services/entries.service.ts | 25 ++-- .../services/session.service.ts | 9 +- .../wallet/controllers/assets.controller.ts | 12 +- .../controllers/categories.controller.ts | 12 +- .../wallet/controllers/ledgers.controller.ts | 12 +- .../controllers/transactions.controller.ts | 13 +- .../wallet/controllers/utils.controller.ts | 4 +- server/src/apps/wallet/schema.ts | 127 ------------------ .../apps/wallet/services/assets.service.ts | 35 +++-- .../wallet/services/categories.service.ts | 23 ++-- .../apps/wallet/services/ledgers.service.ts | 21 +-- .../wallet/services/transactions.service.ts | 47 ++++--- .../src/apps/wallet/services/utils.service.ts | 18 +-- .../controllers/entries.controller.ts | 10 +- .../wishlist/controllers/lists.controller.ts | 23 +--- server/src/apps/wishlist/schema.ts | 52 ------- .../apps/wishlist/services/entries.service.ts | 36 ++--- .../apps/wishlist/services/lists.service.ts | 69 +++------- .../apiKeys/controllers/entries.controller.ts | 8 +- server/src/core/lib/apiKeys/schema.ts | 26 ---- .../lib/apiKeys/services/entries.service.ts | 14 +- server/src/core/lib/user/schema.ts | 47 ------- shared/src/index.ts | 40 +++--- shared/src/types/booksLibrary.schema.ts | 68 ++++++---- shared/src/types/codeTime.schema.ts | 58 +++++--- shared/src/types/guitarTabs.schema.ts | 30 ++++- shared/src/types/music.schema.ts | 33 +++-- shared/src/types/todoList.schema.ts | 66 +++++---- shared/src/types/virtualWardrobe.schema.ts | 42 +++--- shared/src/types/wallet.schema.ts | 90 ++++++++----- shared/src/utils/schemaWithPB.ts | 15 +++ shared/src/utils/schemaWithPB.types.ts | 7 - tsconfig.json | 32 +++-- 113 files changed, 1087 insertions(+), 1979 deletions(-) delete mode 100644 server/src/apps/blog/schema.ts delete mode 100644 server/src/apps/booksLibrary/schema.ts delete mode 100644 server/src/apps/calendar/schema.ts delete mode 100644 server/src/apps/codeTime/schema.ts delete mode 100644 server/src/apps/guitarTabs/schema.ts delete mode 100644 server/src/apps/ideaBox/schema.ts delete mode 100644 server/src/apps/momentVault/schema.ts delete mode 100644 server/src/apps/movies/schema.ts delete mode 100644 server/src/apps/music/schema.ts delete mode 100644 server/src/apps/passwords/schema.ts delete mode 100644 server/src/apps/railwayMap/schema.ts delete mode 100644 server/src/apps/todoList/schema.ts delete mode 100644 server/src/apps/virtualWardrobe/schema.ts delete mode 100644 server/src/apps/wallet/schema.ts delete mode 100644 server/src/apps/wishlist/schema.ts delete mode 100644 server/src/core/lib/apiKeys/schema.ts delete mode 100644 server/src/core/lib/user/schema.ts create mode 100644 shared/src/utils/schemaWithPB.ts delete mode 100644 shared/src/utils/schemaWithPB.types.ts diff --git a/client/src/apps/Achievements/components/DifficultySelector.tsx b/client/src/apps/Achievements/components/DifficultySelector.tsx index 33c7663b8..b84110233 100644 --- a/client/src/apps/Achievements/components/DifficultySelector.tsx +++ b/client/src/apps/Achievements/components/DifficultySelector.tsx @@ -1,15 +1,14 @@ import clsx from 'clsx' import { useTranslation } from 'react-i18next' - -import { IAchievementEntry } from '../interfaces/achievements_interfaces' +import { AchievementsSchemas } from 'shared' function DifficultySelector({ selectedDifficulty, setSelectedDifficulty }: { - selectedDifficulty: IAchievementEntry['difficulty'] + selectedDifficulty: AchievementsSchemas.IEntry['difficulty'] setSelectedDifficulty: React.Dispatch< - React.SetStateAction + React.SetStateAction > }) { const { t } = useTranslation('apps.achievements') diff --git a/client/src/apps/Achievements/components/EntryItem.tsx b/client/src/apps/Achievements/components/EntryItem.tsx index 896a7a5ce..fc2f7421b 100644 --- a/client/src/apps/Achievements/components/EntryItem.tsx +++ b/client/src/apps/Achievements/components/EntryItem.tsx @@ -1,14 +1,18 @@ import { Icon } from '@iconify/react/dist/iconify.js' import clsx from 'clsx' import { useCallback } from 'react' +import { AchievementsSchemas, ISchemaWithPB } from 'shared' import { DeleteConfirmationModal, HamburgerMenu, MenuItem } from '@lifeforge/ui' import { useModalStore } from '@lifeforge/ui' -import { type IAchievementEntry } from '../interfaces/achievements_interfaces' import ModifyAchievementModal from './ModifyAchievementModal' -function EntryItem({ entry }: { entry: IAchievementEntry }) { +function EntryItem({ + entry +}: { + entry: ISchemaWithPB +}) { const open = useModalStore(state => state.open) const handleDeleteEntry = useCallback(() => { @@ -16,7 +20,7 @@ function EntryItem({ entry }: { entry: IAchievementEntry }) { apiEndpoint: 'achievements/entries', data: entry, itemName: 'achievement', - nameKey: 'title', + nameKey: 'title' as const, queryKey: ['achievements/entries', entry.difficulty] }) }, [entry]) diff --git a/client/src/apps/Achievements/components/ModifyAchievementModal.tsx b/client/src/apps/Achievements/components/ModifyAchievementModal.tsx index 54889cb9d..b96212375 100644 --- a/client/src/apps/Achievements/components/ModifyAchievementModal.tsx +++ b/client/src/apps/Achievements/components/ModifyAchievementModal.tsx @@ -1,15 +1,11 @@ import { useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' +import { AchievementsSchemas, ISchemaWithPB } from 'shared' import COLOR from 'tailwindcss/colors' import { FormModal } from '@lifeforge/ui' import { type IFieldProps } from '@lifeforge/ui' -import { - type IAchievementEntry, - IAchievementEntryFormState -} from '../interfaces/achievements_interfaces' - const difficulties = [ ['easy', 'green'], ['medium', 'yellow'], @@ -23,19 +19,19 @@ function ModifyAchievementModal({ }: { data: { type: 'create' | 'update' | null - existedData: IAchievementEntry | null - currentDifficulty: IAchievementEntry['difficulty'] + existedData: ISchemaWithPB | null + currentDifficulty: AchievementsSchemas.IEntry['difficulty'] } onClose: () => void }) { const { t } = useTranslation('apps.achievements') - const [formState, setFormState] = useState({ + const [formState, setFormState] = useState({ title: '', thoughts: '', difficulty: 'easy' }) - const FIELDS: IFieldProps[] = [ + const FIELDS: IFieldProps[] = [ { id: 'title', required: true, diff --git a/client/src/apps/Achievements/index.tsx b/client/src/apps/Achievements/index.tsx index 70ebe7c1e..c69f9421c 100644 --- a/client/src/apps/Achievements/index.tsx +++ b/client/src/apps/Achievements/index.tsx @@ -1,6 +1,6 @@ import { useState } from 'react' import { useTranslation } from 'react-i18next' -import { IAchievementsEntry, SchemaWithPB } from 'shared' +import { AchievementsSchemas, ISchemaWithPB } from 'shared' import { Button, @@ -22,8 +22,8 @@ function Achievements() { const { t } = useTranslation('apps.achievements') const open = useModalStore(state => state.open) const [selectedDifficulty, setSelectedDifficulty] = - useState('impossible') - const entriesQuery = useAPIQuery[]>( + useState('impossible') + const entriesQuery = useAPIQuery[]>( `achievements/entries/${selectedDifficulty}`, ['achievements/entries', selectedDifficulty] ) diff --git a/client/src/apps/Blog/index.tsx b/client/src/apps/Blog/index.tsx index 9dddf0a3a..30aede495 100644 --- a/client/src/apps/Blog/index.tsx +++ b/client/src/apps/Blog/index.tsx @@ -1,5 +1,6 @@ import { useTranslation } from 'react-i18next' import { Link } from 'react-router' +import { BlogSchemas } from 'shared' import { Button, @@ -11,11 +12,9 @@ import { import useAPIQuery from '@hooks/useAPIQuery' -import { IBlogEntry } from './interfaces/blog_interfaces' - function Blog() { const { t } = useTranslation('apps.blog') - const entriesQuery = useAPIQuery('blog/entries', [ + const entriesQuery = useAPIQuery('blog/entries', [ 'blog', 'entries' ]) diff --git a/client/src/apps/Blog/interfaces/blog_interfaces.ts b/client/src/apps/Blog/interfaces/blog_interfaces.ts index 8e96f186e..f80caf9e9 100644 --- a/client/src/apps/Blog/interfaces/blog_interfaces.ts +++ b/client/src/apps/Blog/interfaces/blog_interfaces.ts @@ -1,16 +1,3 @@ -import { RecordModel } from 'pocketbase' - -interface IBlogEntry extends RecordModel { - title: string - content: string - media: string[] - excerpt: string - visibility: 'public' | 'private' | 'unlisted' - featured_image: string - labels: string[] - category: string -} - interface IBlogEntryFormState { title: string excerpt: string @@ -21,4 +8,4 @@ interface IBlogEntryFormState { labels: string[] } -export type { IBlogEntry, IBlogEntryFormState } +export type { IBlogEntryFormState } diff --git a/package.json b/package.json index fef2590ca..c1e7c2234 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,11 @@ "build:shared": "cd shared && bun run build", "build:server": "cd server && bun run build", "build": "bun run build:shared && bun run build:server && bun run build:client", + "types:client": "cd client && bun run tsc --noEmit", + "types:shared": "cd shared && bun run tsc --noEmit", + "types:server": "cd server && bun run tsc --noEmit", + "types": "bun run types:shared && bun run types:server && bun run types:client", + "lint:client": "cd client && bun run lint", "postinstall": "bun run build:shared && bun run build:server", "schema:generate": "bun run scripts/generateSchema.ts" }, diff --git a/server/src/apps/blog/controllers/entries.contorller.ts b/server/src/apps/blog/controllers/entries.contorller.ts index 5b0023290..e3a470bec 100644 --- a/server/src/apps/blog/controllers/entries.contorller.ts +++ b/server/src/apps/blog/controllers/entries.contorller.ts @@ -3,19 +3,18 @@ import { forgeController, } from "@functions/forgeController"; import express from "express"; +import { BlogSchemas } from "shared"; import z from "zod/v4"; import { WithPBSchema } from "@typescript/pocketbase_interfaces"; -import { BlogEntrySchema } from "../schema"; - const blogEntriesRouter = express.Router(); const getAllEntries = forgeController .route("GET /") .description("Get all blog entries") .schema({ - response: z.array(WithPBSchema(BlogEntrySchema)), + response: z.array(WithPBSchema(BlogSchemas.EntrySchema)), }) .callback(({ pb }) => pb.collection("blog__entries").getFullList()); diff --git a/server/src/apps/blog/schema.ts b/server/src/apps/blog/schema.ts deleted file mode 100644 index bcaf93362..000000000 --- a/server/src/apps/blog/schema.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * This file is auto-generated. DO NOT EDIT IT MANUALLY. - * If you want to add custom schemas, you will find a dedicated space at the end of this file. - * Generated for module: blog - * Generated at: 2025-07-09T12:50:41.283Z - * Contains: blog__entries, blog__categories - */ -import { z } from "zod/v4"; - -const BlogEntrySchema = z.object({ - content: z.string(), - title: z.string(), - media: z.array(z.string()), - excerpt: z.string(), - visibility: z.enum(["private", "public", "unlisted", ""]), - featured_image: z.string(), - labels: z.any(), - category: z.string(), -}); - -const BlogCategorySchema = z.object({ - name: z.string(), - color: z.string(), - icon: z.string(), -}); - -type IBlogEntry = z.infer; -type IBlogCategory = z.infer; - -export { BlogEntrySchema, BlogCategorySchema }; - -export type { IBlogEntry, IBlogCategory }; - -// -------------------- CUSTOM SCHEMAS -------------------- - -// Add your custom schemas here. They will not be overwritten by this script. diff --git a/server/src/apps/blog/services/entries.service.ts b/server/src/apps/blog/services/entries.service.ts index f8ecb3fc5..5befb5630 100644 --- a/server/src/apps/blog/services/entries.service.ts +++ b/server/src/apps/blog/services/entries.service.ts @@ -1,8 +1,9 @@ import PocketBase from "pocketbase"; +import { BlogSchemas } from "shared"; import { WithPB } from "@typescript/pocketbase_interfaces"; -import { IBlogEntry } from "../schema"; - -export const getAllEntries = (pb: PocketBase): Promise[]> => - pb.collection("blog__entries").getFullList>(); +export const getAllEntries = ( + pb: PocketBase, +): Promise[]> => + pb.collection("blog__entries").getFullList>(); diff --git a/server/src/apps/booksLibrary/controllers/collection.controller.ts b/server/src/apps/booksLibrary/controllers/collection.controller.ts index 636b7b887..7d9927f10 100644 --- a/server/src/apps/booksLibrary/controllers/collection.controller.ts +++ b/server/src/apps/booksLibrary/controllers/collection.controller.ts @@ -3,11 +3,11 @@ import { forgeController, } from "@functions/forgeController"; import express from "express"; +import { BooksLibrarySchemas } from "shared"; import { z } from "zod/v4"; import { WithPBSchema } from "@typescript/pocketbase_interfaces"; -import { BooksLibraryCollectionSchema } from "../schema"; import * as CollectionsService from "../services/collections.service"; const booksLibraryCollectionsRouter = express.Router(); @@ -16,7 +16,9 @@ const getAllCollections = forgeController .route("GET /") .description("Get all collections for the books library") .schema({ - response: z.array(WithPBSchema(BooksLibraryCollectionSchema)), + response: z.array( + WithPBSchema(BooksLibrarySchemas.CollectionAggregatedSchema), + ), }) .callback(({ pb }) => CollectionsService.getAllCollections(pb)); @@ -24,8 +26,8 @@ const createCollection = forgeController .route("POST /") .description("Create a new collection for the books library") .schema({ - body: BooksLibraryCollectionSchema, - response: WithPBSchema(BooksLibraryCollectionSchema), + body: BooksLibrarySchemas.CollectionSchema, + response: WithPBSchema(BooksLibrarySchemas.CollectionSchema), }) .statusCode(201) .callback(({ pb, body }) => CollectionsService.createCollection(pb, body)); @@ -37,8 +39,8 @@ const updateCollection = forgeController params: z.object({ id: z.string(), }), - body: BooksLibraryCollectionSchema, - response: WithPBSchema(BooksLibraryCollectionSchema), + body: BooksLibrarySchemas.CollectionSchema, + response: WithPBSchema(BooksLibrarySchemas.CollectionAggregatedSchema), }) .existenceCheck("params", { id: "books_library__collections", diff --git a/server/src/apps/booksLibrary/controllers/entries.controller.ts b/server/src/apps/booksLibrary/controllers/entries.controller.ts index b59e6608c..4764c8003 100644 --- a/server/src/apps/booksLibrary/controllers/entries.controller.ts +++ b/server/src/apps/booksLibrary/controllers/entries.controller.ts @@ -5,11 +5,11 @@ import { } from "@functions/forgeController"; import { getAPIKey } from "@functions/getAPIKey"; import express from "express"; +import { BooksLibrarySchemas } from "shared"; import { z } from "zod/v4"; import { WithPBSchema } from "@typescript/pocketbase_interfaces"; -import { BooksLibraryEntrySchema } from "../schema"; import * as EntriesService from "../services/entries.service"; const booksLibraryEntriesRouter = express.Router(); @@ -18,7 +18,7 @@ const getAllEntries = forgeController .route("GET /") .description("Get all entries in the books library") .schema({ - response: z.array(WithPBSchema(BooksLibraryEntrySchema)), + response: z.array(WithPBSchema(BooksLibrarySchemas.EntrySchema)), }) .callback(({ pb }) => EntriesService.getAllEntries(pb)); @@ -29,7 +29,7 @@ const updateEntry = forgeController params: z.object({ id: z.string(), }), - body: BooksLibraryEntrySchema.pick({ + body: BooksLibrarySchemas.EntrySchema.pick({ title: true, authors: true, collection: true, @@ -44,7 +44,7 @@ const updateEntry = forgeController return isNaN(year) ? 0 : year; }), }), - response: WithPBSchema(BooksLibraryEntrySchema), + response: WithPBSchema(BooksLibrarySchemas.EntrySchema), }) .existenceCheck("params", { id: "books_library__entries", @@ -64,7 +64,7 @@ const toggleFavouriteStatus = forgeController params: z.object({ id: z.string(), }), - response: WithPBSchema(BooksLibraryEntrySchema), + response: WithPBSchema(BooksLibrarySchemas.EntrySchema), }) .existenceCheck("params", { id: "books_library__entries", @@ -80,7 +80,7 @@ const toggleReadStatus = forgeController params: z.object({ id: z.string(), }), - response: WithPBSchema(BooksLibraryEntrySchema), + response: WithPBSchema(BooksLibrarySchemas.EntrySchema), }) .existenceCheck("params", { id: "books_library__entries", diff --git a/server/src/apps/booksLibrary/controllers/fileTypes.controller.ts b/server/src/apps/booksLibrary/controllers/fileTypes.controller.ts index 21ec94ddf..d8483297b 100644 --- a/server/src/apps/booksLibrary/controllers/fileTypes.controller.ts +++ b/server/src/apps/booksLibrary/controllers/fileTypes.controller.ts @@ -3,11 +3,11 @@ import { forgeController, } from "@functions/forgeController"; import express from "express"; +import { BooksLibrarySchemas } from "shared"; import { z } from "zod/v4"; import { WithPBSchema } from "@typescript/pocketbase_interfaces"; -import { BooksLibraryFileTypeSchema } from "../schema"; import * as FileTypesService from "../services/fileTypes.service"; const booksLibraryFileTypesRouter = express.Router(); @@ -16,7 +16,7 @@ const getAllFileTypes = forgeController .route("GET /") .description("Get all file types for the books library") .schema({ - response: z.array(WithPBSchema(BooksLibraryFileTypeSchema)), + response: z.array(WithPBSchema(BooksLibrarySchemas.FileTypeSchema)), }) .callback(async ({ pb }) => await FileTypesService.getAllFileTypes(pb)); diff --git a/server/src/apps/booksLibrary/controllers/languages.controller.ts b/server/src/apps/booksLibrary/controllers/languages.controller.ts index 3d8a9cfbc..a746b7b3b 100644 --- a/server/src/apps/booksLibrary/controllers/languages.controller.ts +++ b/server/src/apps/booksLibrary/controllers/languages.controller.ts @@ -3,11 +3,11 @@ import { forgeController, } from "@functions/forgeController"; import express from "express"; +import { BooksLibrarySchemas } from "shared"; import { z } from "zod/v4"; import { WithPBSchema } from "@typescript/pocketbase_interfaces"; -import { BooksLibraryLanguageSchema } from "../schema"; import * as LanguagesService from "../services/languages.service"; const booksLibraryLanguagesRouter = express.Router(); @@ -16,7 +16,7 @@ const getAllLanguages = forgeController .route("GET /") .description("Get all languages for the books library") .schema({ - response: z.array(BooksLibraryLanguageSchema), + response: z.array(BooksLibrarySchemas.LanguageSchema), }) .callback(({ pb }) => LanguagesService.getAllLanguages(pb)); @@ -24,8 +24,8 @@ const createLanguage = forgeController .route("POST /") .description("Create a new language for the books library") .schema({ - body: BooksLibraryLanguageSchema, - response: WithPBSchema(BooksLibraryLanguageSchema), + body: BooksLibrarySchemas.LanguageSchema, + response: WithPBSchema(BooksLibrarySchemas.LanguageSchema), }) .statusCode(201) .callback( @@ -39,8 +39,8 @@ const updateLanguage = forgeController params: z.object({ id: z.string(), }), - body: BooksLibraryLanguageSchema, - response: WithPBSchema(BooksLibraryLanguageSchema), + body: BooksLibrarySchemas.LanguageSchema, + response: WithPBSchema(BooksLibrarySchemas.LanguageSchema), }) .existenceCheck("params", { id: "books_library__languages", diff --git a/server/src/apps/booksLibrary/controllers/libgen.controller.ts b/server/src/apps/booksLibrary/controllers/libgen.controller.ts index fd9ad9b77..86d55e842 100644 --- a/server/src/apps/booksLibrary/controllers/libgen.controller.ts +++ b/server/src/apps/booksLibrary/controllers/libgen.controller.ts @@ -3,12 +3,9 @@ import { forgeController, } from "@functions/forgeController"; import express from "express"; +import { BooksLibrarySchemas } from "shared"; import { z } from "zod/v4"; -import { - BooksLibraryEntrySchema, - BooksLibraryLibgenSearchResultSchema, -} from "../schema"; import * as libgenService from "../services/libgen.service"; const booksLibraryLibgenRouter = express.Router(); @@ -30,7 +27,7 @@ const searchBooks = forgeController req: z.string(), page: z.string(), }), - response: BooksLibraryLibgenSearchResultSchema, + response: BooksLibrarySchemas.BooksLibraryLibgenSearchResultSchema, }) .callback(async ({ query }) => await libgenService.searchBooks(query)); @@ -55,7 +52,7 @@ const getLocalLibraryData = forgeController provider: z.string(), md5: z.string(), }), - response: BooksLibraryEntrySchema.omit({ + response: BooksLibrarySchemas.EntrySchema.omit({ collection: true, file: true, is_favourite: true, diff --git a/server/src/apps/booksLibrary/schema.ts b/server/src/apps/booksLibrary/schema.ts deleted file mode 100644 index dae3dd646..000000000 --- a/server/src/apps/booksLibrary/schema.ts +++ /dev/null @@ -1,110 +0,0 @@ -/** - * This file is auto-generated. DO NOT EDIT IT MANUALLY. - * If you want to add custom schemas, you will find a dedicated space at the end of this file. - * Generated for module: booksLibrary - * Generated at: 2025-07-09T12:50:41.285Z - * Contains: books_library__collections, books_library__languages, books_library__entries, books_library__file_types, books_library__file_types_aggregated, books_library__languages_aggregated, books_library__collections_aggregated - */ -import { z } from "zod/v4"; - -const BooksLibraryCollectionSchema = z.object({ - name: z.string(), - icon: z.string(), -}); - -const BooksLibraryLanguageSchema = z.object({ - name: z.string(), - icon: z.string(), -}); - -const BooksLibraryEntrySchema = z.object({ - title: z.string(), - authors: z.string(), - md5: z.string(), - year_published: z.number(), - publisher: z.string(), - languages: z.array(z.string()), - collection: z.string(), - extension: z.string(), - edition: z.string(), - size: z.number(), - isbn: z.string(), - file: z.string(), - thumbnail: z.string(), - is_favourite: z.boolean(), - is_read: z.boolean(), - time_finished: z.string(), -}); - -const BooksLibraryFileTypeSchema = z.object({ - name: z.string(), -}); - -const BooksLibraryFileTypeAggregatedSchema = z.object({ - name: z.string(), - amount: z.number(), -}); - -const BooksLibraryLanguageAggregatedSchema = z.object({ - name: z.string(), - icon: z.string(), - amount: z.number(), -}); - -const BooksLibraryCollectionAggregatedSchema = z.object({ - name: z.string(), - icon: z.string(), - amount: z.number(), -}); - -type IBooksLibraryCollection = z.infer; -type IBooksLibraryLanguage = z.infer; -type IBooksLibraryEntry = z.infer; -type IBooksLibraryFileType = z.infer; -type IBooksLibraryFileTypeAggregated = z.infer< - typeof BooksLibraryFileTypeAggregatedSchema ->; -type IBooksLibraryLanguageAggregated = z.infer< - typeof BooksLibraryLanguageAggregatedSchema ->; -type IBooksLibraryCollectionAggregated = z.infer< - typeof BooksLibraryCollectionAggregatedSchema ->; - -export { - BooksLibraryCollectionSchema, - BooksLibraryLanguageSchema, - BooksLibraryEntrySchema, - BooksLibraryFileTypeSchema, - BooksLibraryFileTypeAggregatedSchema, - BooksLibraryLanguageAggregatedSchema, - BooksLibraryCollectionAggregatedSchema, -}; - -export type { - IBooksLibraryCollection, - IBooksLibraryLanguage, - IBooksLibraryEntry, - IBooksLibraryFileType, - IBooksLibraryFileTypeAggregated, - IBooksLibraryLanguageAggregated, - IBooksLibraryCollectionAggregated, -}; - -// -------------------- CUSTOM SCHEMAS -------------------- - -const BooksLibraryLibgenSearchResultSchema = z.object({ - provider: z.string(), - query: z.string(), - resultsCount: z.string(), - data: z.record(z.string(), z.any()), - page: z.number(), -}); - -type IBooksLibraryLibgenSearchResult = z.infer< - typeof BooksLibraryLibgenSearchResultSchema ->; - -export { BooksLibraryLibgenSearchResultSchema }; - -export type { IBooksLibraryLibgenSearchResult }; diff --git a/server/src/apps/booksLibrary/services/collections.service.ts b/server/src/apps/booksLibrary/services/collections.service.ts index cf534ce49..2527f2160 100644 --- a/server/src/apps/booksLibrary/services/collections.service.ts +++ b/server/src/apps/booksLibrary/services/collections.service.ts @@ -1,34 +1,41 @@ import PocketBase from "pocketbase"; +import { BooksLibrarySchemas } from "shared"; import { WithPB } from "@typescript/pocketbase_interfaces"; -import { IBooksLibraryCollection } from "../schema"; - -export const getAllCollections = ( - pb: PocketBase, -): Promise[]> => +export const getAllCollections = (pb: PocketBase) => pb .collection("books_library__collections_aggregated") - .getFullList>({ + .getFullList>({ sort: "name", }); -export const createCollection = ( +export const createCollection = async ( pb: PocketBase, - data: Omit, -): Promise> => - pb + data: Omit, +) => { + const collection = await pb .collection("books_library__collections") - .create>(data); + .create>(data); -export const updateCollection = ( + return pb + .collection("books_library__collections_aggregated") + .getOne>(collection.id); +}; + +export const updateCollection = async ( pb: PocketBase, id: string, - data: Omit, -): Promise> => - pb + data: Omit, +) => { + const collection = await pb .collection("books_library__collections") - .update>(id, data); + .update>(id, data); + + return pb + .collection("books_library__collections_aggregated") + .getOne>(collection.id); +}; export const deleteCollection = async (pb: PocketBase, id: string) => { await pb.collection("books_library__collections").delete(id); diff --git a/server/src/apps/booksLibrary/services/entries.service.ts b/server/src/apps/booksLibrary/services/entries.service.ts index 9fc01e067..efb318c8b 100644 --- a/server/src/apps/booksLibrary/services/entries.service.ts +++ b/server/src/apps/booksLibrary/services/entries.service.ts @@ -1,17 +1,16 @@ import ClientError from "@functions/ClientError"; import mailer from "nodemailer"; import Pocketbase from "pocketbase"; +import { BooksLibrarySchemas } from "shared"; import { WithPB } from "@typescript/pocketbase_interfaces"; -import { IBooksLibraryEntry } from "../schema"; - export const getAllEntries = ( pb: Pocketbase, -): Promise[]> => +): Promise[]> => pb .collection("books_library__entries") - .getFullList>({ + .getFullList>({ sort: "-is_favourite,-created", }); @@ -19,7 +18,7 @@ export const updateEntry = ( pb: Pocketbase, id: string, data: Pick< - IBooksLibraryEntry, + BooksLibrarySchemas.IEntry, | "title" | "authors" | "collection" @@ -29,22 +28,22 @@ export const updateEntry = ( | "publisher" | "year_published" >, -): Promise> => +): Promise> => pb .collection("books_library__entries") - .update>(id, data); + .update>(id, data); export const toggleFavouriteStatus = async ( pb: Pocketbase, id: string, -): Promise> => { +): Promise> => { const book = await pb .collection("books_library__entries") - .getOne>(id); + .getOne>(id); return await pb .collection("books_library__entries") - .update>(id, { + .update>(id, { is_favourite: !book.is_favourite, }); }; @@ -52,14 +51,14 @@ export const toggleFavouriteStatus = async ( export const toggleReadStatus = async ( pb: Pocketbase, id: string, -): Promise> => { +): Promise> => { const book = await pb .collection("books_library__entries") - .getOne>(id); + .getOne>(id); return await pb .collection("books_library__entries") - .update>(id, { + .update>(id, { is_read: !book.is_read, time_finished: !book.is_read ? new Date().toISOString() : "", }); @@ -86,7 +85,7 @@ export const sendToKindle = async ( const entry = await pb .collection("books_library__entries") - .getOne(id); + .getOne(id); const fileLink = pb.files.getURL(entry, entry.file); const content = await fetch(fileLink).then((res) => res.arrayBuffer()); diff --git a/server/src/apps/booksLibrary/services/fileTypes.service.ts b/server/src/apps/booksLibrary/services/fileTypes.service.ts index 67277e9e6..0353c20d9 100644 --- a/server/src/apps/booksLibrary/services/fileTypes.service.ts +++ b/server/src/apps/booksLibrary/services/fileTypes.service.ts @@ -1,14 +1,13 @@ import PocketBase from "pocketbase"; +import { BooksLibrarySchemas } from "shared"; import { WithPB } from "@typescript/pocketbase_interfaces"; -import { IBooksLibraryFileType } from "../schema"; - export const getAllFileTypes = ( pb: PocketBase, -): Promise[]> => +): Promise[]> => pb .collection("books_library__file_types_aggregated") - .getFullList>({ + .getFullList>({ sort: "name", }); diff --git a/server/src/apps/booksLibrary/services/languages.service.ts b/server/src/apps/booksLibrary/services/languages.service.ts index 322b09672..c81d2eee6 100644 --- a/server/src/apps/booksLibrary/services/languages.service.ts +++ b/server/src/apps/booksLibrary/services/languages.service.ts @@ -1,32 +1,31 @@ import PocketBase from "pocketbase"; +import { BooksLibrarySchemas } from "shared"; import { WithPB } from "@typescript/pocketbase_interfaces"; -import { IBooksLibraryLanguage } from "../schema"; - export const getAllLanguages = ( pb: PocketBase, -): Promise[]> => +): Promise[]> => pb .collection("books_library__languages_aggregated") - .getFullList>(); + .getFullList>(); export const createLanguage = ( pb: PocketBase, languageData: { name: string; icon: string }, -): Promise> => +): Promise> => pb .collection("books_library__languages") - .create>(languageData); + .create>(languageData); export const updateLanguage = ( pb: PocketBase, id: string, languageData: { name: string; icon: string }, -): Promise> => +): Promise> => pb .collection("books_library__languages") - .update>(id, languageData); + .update>(id, languageData); export const deleteLanguage = async (pb: PocketBase, id: string) => { await pb.collection("books_library__languages").delete(id); diff --git a/server/src/apps/booksLibrary/services/libgen.service/api/search.ts b/server/src/apps/booksLibrary/services/libgen.service/api/search.ts index 3575a251b..06984b55b 100644 --- a/server/src/apps/booksLibrary/services/libgen.service/api/search.ts +++ b/server/src/apps/booksLibrary/services/libgen.service/api/search.ts @@ -1,12 +1,11 @@ import { JSDOM } from "jsdom"; - -import { IBooksLibraryLibgenSearchResult } from "../../../schema"; +import { BooksLibrarySchemas } from "shared"; export const searchBooks = async (queries: { provider: string; req: string; page: string; -}): Promise => { +}): Promise => { const target = new URL( queries.provider === "libgen.is" ? "http://libgen.is/search.php?lg_topic=libgen&open=0&view=detailed&res=25&column=def&phrase=0&sort=year&sortmode=DESC" @@ -19,7 +18,7 @@ export const searchBooks = async (queries: { const data = await fetch(target.href).then((res) => res.text()); const dom = new JSDOM(data); const document = dom.window.document; - let final: IBooksLibraryLibgenSearchResult["data"] = []; + let final: BooksLibrarySchemas.IBooksLibraryLibgenSearchResult["data"] = []; let resultsCount = ""; if (queries.provider === "libgen.is") { @@ -49,8 +48,8 @@ export const searchBooks = async (queries: { function parseLibgenIS( document: Document, ): [ - IBooksLibraryLibgenSearchResult["data"], - IBooksLibraryLibgenSearchResult["resultsCount"], + BooksLibrarySchemas.IBooksLibraryLibgenSearchResult["data"], + BooksLibrarySchemas.IBooksLibraryLibgenSearchResult["resultsCount"], ] { const table = Array.from( document.querySelectorAll('body > table[rules="cols"]'), @@ -98,8 +97,8 @@ function parseLibgenMirror( provider: string, document: Document, ): [ - IBooksLibraryLibgenSearchResult["data"], - IBooksLibraryLibgenSearchResult["resultsCount"], + BooksLibrarySchemas.IBooksLibraryLibgenSearchResult["data"], + BooksLibrarySchemas.IBooksLibraryLibgenSearchResult["resultsCount"], ] { return [ Array.from(document.querySelectorAll("#tablelibgen tbody tr")).map((e) => ({ diff --git a/server/src/apps/booksLibrary/services/libgen.service/download/process.ts b/server/src/apps/booksLibrary/services/libgen.service/download/process.ts index 1c2d5cc96..4c65b99df 100644 --- a/server/src/apps/booksLibrary/services/libgen.service/download/process.ts +++ b/server/src/apps/booksLibrary/services/libgen.service/download/process.ts @@ -1,6 +1,7 @@ import { spawn } from "child_process"; import fs from "fs"; import Pocketbase from "pocketbase"; +import { BooksLibrarySchemas } from "shared"; import { Server } from "socket.io"; import { @@ -8,14 +9,12 @@ import { updateTaskInPool, } from "@middlewares/taskPoolMiddleware"; -import { IBooksLibraryEntry } from "../../../schema"; - export const addToLibrary = async ( io: Server, pb: Pocketbase, md5: string, metadata: Omit< - IBooksLibraryEntry, + BooksLibrarySchemas.IEntry, "thumbnail" | "file" | "is_favourite" | "is_read" | "time_finished" > & { thumbnail: string; @@ -140,7 +139,7 @@ const processDownloadedFiles = async ( pb: Pocketbase, md5: string, metadata: Omit< - IBooksLibraryEntry, + BooksLibrarySchemas.IEntry, "thumbnail" | "file" | "is_favourite" | "is_read" | "time_finished" > & { thumbnail: string | File; diff --git a/server/src/apps/calendar/controllers/calendars.controller.ts b/server/src/apps/calendar/controllers/calendars.controller.ts index fd94df719..46c9a0bdf 100644 --- a/server/src/apps/calendar/controllers/calendars.controller.ts +++ b/server/src/apps/calendar/controllers/calendars.controller.ts @@ -4,11 +4,11 @@ import { forgeController, } from "@functions/forgeController"; import express from "express"; +import { CalendarSchemas } from "shared"; import { z } from "zod/v4"; import { WithPBSchema } from "@typescript/pocketbase_interfaces"; -import { CalendarCalendarSchema } from "../schema"; import * as CalendarsService from "../services/calendars.service"; const calendarCalendarsRouter = express.Router(); @@ -17,7 +17,7 @@ const getAllCalendars = forgeController .route("GET /") .description("Get all calendars") .schema({ - response: z.array(WithPBSchema(CalendarCalendarSchema)), + response: z.array(WithPBSchema(CalendarSchemas.CalendarSchema)), }) .callback(async ({ pb }) => await CalendarsService.getAllCalendars(pb)); @@ -28,7 +28,7 @@ const getCalendarById = forgeController params: z.object({ id: z.string(), }), - response: WithPBSchema(CalendarCalendarSchema), + response: WithPBSchema(CalendarSchemas.CalendarSchema), }) .existenceCheck("params", { id: "calendar__calendars", @@ -42,8 +42,8 @@ const createCalendar = forgeController .route("POST /") .description("Create a new calendar") .schema({ - body: CalendarCalendarSchema, - response: WithPBSchema(CalendarCalendarSchema), + body: CalendarSchemas.CalendarSchema, + response: WithPBSchema(CalendarSchemas.CalendarSchema), }) .statusCode(201) .callback(async ({ pb, body }) => { @@ -66,8 +66,8 @@ const updateCalendar = forgeController params: z.object({ id: z.string(), }), - body: CalendarCalendarSchema, - response: WithPBSchema(CalendarCalendarSchema), + body: CalendarSchemas.CalendarSchema, + response: WithPBSchema(CalendarSchemas.CalendarSchema), }) .existenceCheck("params", { id: "calendar__calendars", diff --git a/server/src/apps/calendar/controllers/categories.controller.ts b/server/src/apps/calendar/controllers/categories.controller.ts index 83e32c6c6..18210d5ce 100644 --- a/server/src/apps/calendar/controllers/categories.controller.ts +++ b/server/src/apps/calendar/controllers/categories.controller.ts @@ -4,11 +4,11 @@ import { forgeController, } from "@functions/forgeController"; import express from "express"; +import { CalendarSchemas } from "shared"; import { z } from "zod/v4"; import { WithPBSchema } from "@typescript/pocketbase_interfaces"; -import { CalendarCategorySchema } from "../schema"; import * as CategoriesService from "../services/categories.service"; const calendarCategoriesRouter = express.Router(); @@ -17,7 +17,7 @@ const getAllCategories = forgeController .route("GET /") .description("Get all calendar categories") .schema({ - response: z.array(WithPBSchema(CalendarCategorySchema)), + response: z.array(WithPBSchema(CalendarSchemas.CategorySchema)), }) .callback(async ({ pb }) => await CategoriesService.getAllCategories(pb)); @@ -28,7 +28,7 @@ const getCategoryById = forgeController params: z.object({ id: z.string(), }), - response: WithPBSchema(CalendarCategorySchema), + response: WithPBSchema(CalendarSchemas.CategorySchema), }) .existenceCheck("params", { id: "calendar__categories", @@ -42,8 +42,8 @@ const createCategory = forgeController .route("POST /") .description("Create a new calendar category") .schema({ - body: CalendarCategorySchema, - response: WithPBSchema(CalendarCategorySchema), + body: CalendarSchemas.CategorySchema, + response: WithPBSchema(CalendarSchemas.CategorySchema), }) .statusCode(201) .callback(async ({ pb, body }) => { @@ -70,8 +70,8 @@ const updateCategory = forgeController params: z.object({ id: z.string(), }), - body: CalendarCategorySchema, - response: WithPBSchema(CalendarCategorySchema), + body: CalendarSchemas.CategorySchema, + response: WithPBSchema(CalendarSchemas.CategorySchema), }) .existenceCheck("params", { id: "calendar__categories", diff --git a/server/src/apps/calendar/controllers/events.controller.ts b/server/src/apps/calendar/controllers/events.controller.ts index 14a28d4c8..0e4df730f 100644 --- a/server/src/apps/calendar/controllers/events.controller.ts +++ b/server/src/apps/calendar/controllers/events.controller.ts @@ -4,13 +4,13 @@ import { forgeController, } from "@functions/forgeController"; import express from "express"; +import { CalendarSchemas } from "shared"; import { z } from "zod/v4"; import { WithPBSchema } from "@typescript/pocketbase_interfaces"; import { singleUploadMiddleware } from "@middlewares/uploadMiddleware"; -import { CalendarEventSchema } from "../schema"; import * as EventsService from "../services/events.service"; const calendarEventsRouter = express.Router(); @@ -23,7 +23,7 @@ const getEventsByDateRange = forgeController start: z.string(), end: z.string(), }), - response: z.array(WithPBSchema(CalendarEventSchema.partial())), + response: z.array(WithPBSchema(CalendarSchemas.EventSchema.partial())), }) .callback( async ({ pb, query: { start, end } }) => @@ -34,7 +34,7 @@ const getEventsToday = forgeController .route("GET /today") .description("Get today's events") .schema({ - response: z.array(WithPBSchema(CalendarEventSchema.partial())), + response: z.array(WithPBSchema(CalendarSchemas.EventSchema.partial())), }) .callback(async ({ pb }) => await EventsService.getTodayEvents(pb)); @@ -45,7 +45,7 @@ const getEventById = forgeController params: z.object({ id: z.string(), }), - response: WithPBSchema(CalendarEventSchema), + response: WithPBSchema(CalendarSchemas.EventSchema), }) .existenceCheck("params", { id: "calendar__events", @@ -58,7 +58,7 @@ const createEvent = forgeController .route("POST /") .description("Create a new event") .schema({ - body: CalendarEventSchema.omit({ + body: CalendarSchemas.EventSchema.omit({ exceptions: true, }).extend({ location: z @@ -72,7 +72,7 @@ const createEvent = forgeController ]) .optional(), }), - response: WithPBSchema(CalendarEventSchema), + response: WithPBSchema(CalendarSchemas.EventSchema), }) .statusCode(201) .callback(async ({ pb, body }) => { @@ -88,7 +88,7 @@ const scanImage = forgeController .description("Scan an image to extract event data") .middlewares(singleUploadMiddleware) .schema({ - response: CalendarEventSchema.partial(), + response: CalendarSchemas.EventSchema.partial(), }) .callback(async ({ pb, req }) => { const { file } = req; @@ -133,10 +133,10 @@ const updateEvent = forgeController params: z.object({ id: z.string(), }), - body: CalendarEventSchema.partial().omit({ + body: CalendarSchemas.EventSchema.partial().omit({ exceptions: true, }), - response: WithPBSchema(CalendarEventSchema), + response: WithPBSchema(CalendarSchemas.EventSchema), }) .existenceCheck("params", { id: "calendar__events", diff --git a/server/src/apps/calendar/schema.ts b/server/src/apps/calendar/schema.ts deleted file mode 100644 index 224f6ea85..000000000 --- a/server/src/apps/calendar/schema.ts +++ /dev/null @@ -1,70 +0,0 @@ -/** - * This file is auto-generated. DO NOT EDIT IT MANUALLY. - * If you want to add custom schemas, you will find a dedicated space at the end of this file. - * Generated for module: calendar - * Generated at: 2025-07-09T12:50:41.282Z - * Contains: calendar__events, calendar__categories, calendar__categories_aggregated, calendar__calendars - */ -import { z } from "zod/v4"; - -const CalendarEventSchema = z.object({ - start: z.string(), - end: z.string(), - title: z.string(), - category: z.string(), - calendar: z.string(), - location: z.string(), - reference_link: z.string(), - description: z.string(), - is_striktethrough: z.boolean(), - is_recurring: z.boolean(), - use_google_map: z.boolean(), - type: z.enum(["single", "recurring", ""]), - recurring_rrule: z.string(), - recurring_duration_unit: z.string(), - recurring_duration_amount: z.number(), - exceptions: z.any(), -}); - -const CalendarCategorySchema = z.object({ - name: z.string(), - color: z.string(), - icon: z.string(), -}); - -const CalendarCategoryAggregatedSchema = z.object({ - name: z.string(), - icon: z.string(), - color: z.string(), - amount: z.number(), -}); - -const CalendarCalendarSchema = z.object({ - name: z.string(), - color: z.string(), -}); - -type ICalendarEvent = z.infer; -type ICalendarCategory = z.infer; -type ICalendarCategoryAggregated = z.infer< - typeof CalendarCategoryAggregatedSchema ->; -type ICalendarCalendar = z.infer; - -export { - CalendarEventSchema, - CalendarCategorySchema, - CalendarCategoryAggregatedSchema, - CalendarCalendarSchema, -}; - -export type { - ICalendarEvent, - ICalendarCategory, - ICalendarCategoryAggregated, - ICalendarCalendar, -}; - -// -------------------- CUSTOM SCHEMAS -------------------- - -// Add your custom schemas here. They will not be overwritten by this script. diff --git a/server/src/apps/calendar/services/calendars.service.ts b/server/src/apps/calendar/services/calendars.service.ts index ee2264646..9b8926b90 100644 --- a/server/src/apps/calendar/services/calendars.service.ts +++ b/server/src/apps/calendar/services/calendars.service.ts @@ -1,38 +1,41 @@ import PocketBase from "pocketbase"; +import { CalendarSchemas } from "shared"; import { WithPB } from "@typescript/pocketbase_interfaces"; -import { ICalendarCalendar } from "../schema"; - export const getAllCalendars = ( pb: PocketBase, -): Promise[]> => - pb.collection("calendar__calendars").getFullList>({ - sort: "+name", - }); +): Promise[]> => + pb + .collection("calendar__calendars") + .getFullList>({ + sort: "+name", + }); export const getCalendarById = ( pb: PocketBase, id: string, -): Promise> => - pb.collection("calendar__calendars").getOne>(id); +): Promise> => + pb + .collection("calendar__calendars") + .getOne>(id); export const createCalendar = ( pb: PocketBase, - calendarData: ICalendarCalendar, -): Promise> => + calendarData: CalendarSchemas.ICalendar, +): Promise> => pb .collection("calendar__calendars") - .create>(calendarData); + .create>(calendarData); export const updateCalendar = ( pb: PocketBase, id: string, - calendarData: ICalendarCalendar, -): Promise> => + calendarData: CalendarSchemas.ICalendar, +): Promise> => pb .collection("calendar__calendars") - .update>(id, calendarData); + .update>(id, calendarData); export const deleteCalendar = async (pb: PocketBase, id: string) => { await pb.collection("calendar__calendars").delete(id); diff --git a/server/src/apps/calendar/services/categories.service.ts b/server/src/apps/calendar/services/categories.service.ts index 632f5e301..c97ddcf39 100644 --- a/server/src/apps/calendar/services/categories.service.ts +++ b/server/src/apps/calendar/services/categories.service.ts @@ -1,43 +1,44 @@ import PocketBase from "pocketbase"; +import { CalendarSchemas } from "shared"; import { WithPB } from "@typescript/pocketbase_interfaces"; -import { ICalendarCategory } from "../schema"; - export const getAllCategories = ( pb: PocketBase, -): Promise[]> => +): Promise[]> => pb .collection("calendar__categories_aggregated") - .getFullList>({ + .getFullList>({ sort: "+name", }); export const createCategory = async ( pb: PocketBase, - categoryData: Omit, -): Promise> => { + categoryData: Omit, +): Promise> => { const createdEntry = await pb .collection("calendar__categories") - .create>>(categoryData); + .create>>(categoryData); return await pb .collection("calendar__categories_aggregated") - .getOne>(createdEntry.id); + .getOne>(createdEntry.id); }; export const updateCategory = async ( pb: PocketBase, id: string, - categoryData: Omit, -): Promise> => { + categoryData: Omit, +): Promise> => { const updatedEntry = await pb .collection("calendar__categories") - .update>>(id, categoryData); + .update< + WithPB> + >(id, categoryData); return await pb .collection("calendar__categories_aggregated") - .getOne>(updatedEntry.id); + .getOne>(updatedEntry.id); }; export const deleteCategory = async (pb: PocketBase, id: string) => { @@ -47,5 +48,7 @@ export const deleteCategory = async (pb: PocketBase, id: string) => { export const getCategoryById = ( pb: PocketBase, id: string, -): Promise> => - pb.collection("calendar__categories").getOne>(id); +): Promise> => + pb + .collection("calendar__categories") + .getOne>(id); diff --git a/server/src/apps/calendar/services/events.service.ts b/server/src/apps/calendar/services/events.service.ts index 4aabeac8a..4382b8c9b 100644 --- a/server/src/apps/calendar/services/events.service.ts +++ b/server/src/apps/calendar/services/events.service.ts @@ -3,19 +3,16 @@ import fs from "fs"; import moment from "moment"; import PocketBase from "pocketbase"; import rrule from "rrule"; +import { CalendarSchemas, MoviesSchemas, TodoListSchemas } from "shared"; import { z } from "zod"; import { WithPB } from "@typescript/pocketbase_interfaces"; -import { IMoviesEntry } from "../../movies/schema"; -import { ITodoListEntry } from "../../todoList/schema"; -import { ICalendarCategory, ICalendarEvent } from "../schema"; - export const getEventsByDateRange = async ( pb: PocketBase, startDate: string, endDate: string, -): Promise>[]> => { +): Promise>[]> => { const start = moment(startDate).startOf("day").toISOString(); const end = moment(endDate).endOf("day").toISOString(); @@ -23,7 +20,7 @@ export const getEventsByDateRange = async ( const singleCalendarEvents = await pb .collection("calendar__events") - .getFullList>({ + .getFullList>({ filter: `(start >= '${start}' || end >= '${start}') && (start <= '${end}' || end <= '${end}') && type="single"`, }); @@ -31,7 +28,7 @@ export const getEventsByDateRange = async ( const recurringCalendarEvents = await pb .collection("calendar__events") - .getFullList>({ + .getFullList>({ filter: "type='recurring'", }); @@ -85,7 +82,7 @@ export const getEventsByDateRange = async ( const todoEntries = ( await pb .collection("todo_list__entries") - .getFullList>({ + .getFullList>({ filter: `due_date >= '${start}' && due_date <= '${end}'`, }) .catch(() => []) @@ -99,7 +96,7 @@ export const getEventsByDateRange = async ( description: entry.notes, reference_link: `/todo-list?entry=${entry.id}`, is_strikethrough: entry.done, - } as Partial>; + } as Partial>; }); allEvents.push(...todoEntries); @@ -107,7 +104,7 @@ export const getEventsByDateRange = async ( const movieEntries = ( await pb .collection("movies__entries") - .getFullList>({ + .getFullList>({ filter: `theatre_showtime >= '${start}' && theatre_showtime <= '${end}'`, }) .catch(() => []) @@ -132,7 +129,7 @@ ${entry.theatre_number} ${entry.theatre_seat} `, reference_link: `/movies?show-ticket=${entry.id}`, - } as WithPB; + } as WithPB; }); allEvents.push(...movieEntries); @@ -142,7 +139,7 @@ ${entry.theatre_seat} export const getTodayEvents = async ( pb: PocketBase, -): Promise>[]> => { +): Promise>[]> => { const day = moment().format("YYYY-MM-DD"); const events = await getEventsByDateRange(pb, day, day); @@ -153,12 +150,12 @@ export const getTodayEvents = async ( export const createEvent = async ( pb: PocketBase, eventData: Omit< - ICalendarEvent, + CalendarSchemas.IEvent, "is_strikethrough" | "exceptions" | "location" > & { location?: string | { displayName: { text: string } }; }, -): Promise> => { +): Promise> => { if (eventData.type === "recurring") { eventData.end = ""; } else { @@ -173,16 +170,16 @@ export const createEvent = async ( return await pb .collection("calendar__events") - .create>(eventData); + .create>(eventData); }; export const scanImage = async ( pb: PocketBase, filePath: string, -): Promise | null> => { +): Promise | null> => { const categories = await pb .collection("calendar__categories") - .getFullList>(); + .getFullList>(); const categoryList = categories.map((category) => category.name); @@ -245,21 +242,24 @@ export const scanImage = async ( return null; } - (response as Partial).category = categories.find( + (response as Partial).category = categories.find( (category) => category.name === response.category, )?.id; - return response as Partial; + return response as Partial; }; export const updateEvent = ( pb: PocketBase, id: string, - eventData: Omit, "is_strikethrough" | "exceptions">, -): Promise> => + eventData: Omit< + Partial, + "is_strikethrough" | "exceptions" + >, +): Promise> => pb .collection("calendar__events") - .update>(id, eventData); + .update>(id, eventData); export const deleteEvent = async (pb: PocketBase, id: string) => { await pb.collection("calendar__events").delete(id); @@ -268,8 +268,8 @@ export const deleteEvent = async (pb: PocketBase, id: string) => { export const getEventById = async ( pb: PocketBase, id: string, -): Promise> => - pb.collection("calendar__events").getOne>(id); +): Promise> => + pb.collection("calendar__events").getOne>(id); export const addException = async ( pb: PocketBase, @@ -278,7 +278,7 @@ export const addException = async ( ): Promise => { const event = await pb .collection("calendar__events") - .getOne>(id); + .getOne>(id); const exceptions = event.exceptions || []; @@ -290,7 +290,7 @@ export const addException = async ( await pb .collection("calendar__events") - .update>(id, { exceptions }); + .update>(id, { exceptions }); return true; }; diff --git a/server/src/apps/codeTime/controllers/codeTime.controller.ts b/server/src/apps/codeTime/controllers/codeTime.controller.ts index 43557153a..f1c51e2e0 100644 --- a/server/src/apps/codeTime/controllers/codeTime.controller.ts +++ b/server/src/apps/codeTime/controllers/codeTime.controller.ts @@ -4,15 +4,11 @@ import { forgeController, } from "@functions/forgeController"; import express from "express"; +import { CodeTimeSchemas } from "shared"; import { z } from "zod/v4"; import { WithPBSchema } from "@typescript/pocketbase_interfaces"; -import { - CodeTimeActivitiesSchema, - CodeTimeDailyEntrySchema, - CodeTimeStatisticsSchema, -} from "../schema"; import * as CodeTimeService from "../services/codeTime.service"; const codeTimeRouter = express.Router(); @@ -29,7 +25,7 @@ const getActivities = forgeController val ? parseInt(val, 10) : new Date().getFullYear(), ), }), - response: CodeTimeActivitiesSchema, + response: CodeTimeSchemas.CodeTimeActivitiesSchema, }) .callback( async ({ pb, query: { year } }) => @@ -40,7 +36,7 @@ const getStatistics = forgeController .route("GET /statistics") .description("Get code time statistics") .schema({ - response: CodeTimeStatisticsSchema, + response: CodeTimeSchemas.CodeTimeStatisticsSchema, }) .callback(async ({ pb }) => await CodeTimeService.getStatistics(pb)); @@ -51,7 +47,7 @@ const getLastXDays = forgeController query: z.object({ days: z.string().transform((val) => parseInt(val, 10)), }), - response: z.array(WithPBSchema(CodeTimeDailyEntrySchema)), + response: z.array(WithPBSchema(CodeTimeSchemas.DailyEntrySchema)), }) .callback(async ({ pb, query: { days } }) => { if (days > 30) { diff --git a/server/src/apps/codeTime/schema.ts b/server/src/apps/codeTime/schema.ts deleted file mode 100644 index 7da06535d..000000000 --- a/server/src/apps/codeTime/schema.ts +++ /dev/null @@ -1,69 +0,0 @@ -/** - * This file is auto-generated. DO NOT EDIT IT MANUALLY. - * If you want to add custom schemas, you will find a dedicated space at the end of this file. - * Generated for module: codeTime - * Generated at: 2025-07-09T12:50:41.285Z - * Contains: code_time__projects, code_time__languages, code_time__daily_entries - */ -import { z } from "zod/v4"; - -const CodeTimeProjectSchema = z.object({ - name: z.string(), - duration: z.number(), -}); - -const CodeTimeLanguageSchema = z.object({ - name: z.string(), - icon: z.string(), - color: z.string(), - duration: z.number(), -}); - -const CodeTimeDailyEntrySchema = z.object({ - date: z.string(), - relative_files: z.any(), - projects: z.any(), - total_minutes: z.number(), - last_timestamp: z.number(), - languages: z.any(), -}); - -type ICodeTimeProject = z.infer; -type ICodeTimeLanguage = z.infer; -type ICodeTimeDailyEntry = z.infer; - -export { - CodeTimeProjectSchema, - CodeTimeLanguageSchema, - CodeTimeDailyEntrySchema, -}; - -export type { ICodeTimeProject, ICodeTimeLanguage, ICodeTimeDailyEntry }; - -// -------------------- CUSTOM SCHEMAS -------------------- - -const CodeTimeActivitiesSchema = z.object({ - data: z.array( - z.object({ - date: z.string(), - count: z.number(), - level: z.number(), - }), - ), - firstYear: z.number(), -}); - -const CodeTimeStatisticsSchema = z.object({ - "Most time spent": z.number(), - "Total time spent": z.number(), - "Average time spent": z.number(), - "Longest streak": z.number(), - "Current streak": z.number(), -}); - -type ICodeTimeActivities = z.infer; -type ICodeTimeStatistics = z.infer; - -export { CodeTimeActivitiesSchema, CodeTimeStatisticsSchema }; - -export type { ICodeTimeActivities, ICodeTimeStatistics }; diff --git a/server/src/apps/codeTime/services/codeTime.service.ts b/server/src/apps/codeTime/services/codeTime.service.ts index ccf734bd2..966589016 100644 --- a/server/src/apps/codeTime/services/codeTime.service.ts +++ b/server/src/apps/codeTime/services/codeTime.service.ts @@ -1,15 +1,10 @@ import moment from "moment"; import PocketBase from "pocketbase"; import puppeteer from "puppeteer-core"; +import { CodeTimeSchemas } from "shared"; import { WithPB } from "@typescript/pocketbase_interfaces"; -import { - ICodeTimeActivities, - ICodeTimeDailyEntry, - ICodeTimeStatistics, -} from "../schema"; - export const addDays = (date: Date, days: number): Date => { const newDate = new Date(date.valueOf()); newDate.setDate(newDate.getDate() + days); @@ -29,12 +24,12 @@ export const getDates = (startDate: Date, stopDate: Date): Date[] => { export const getActivities = async ( pb: PocketBase, year?: number, -): Promise => { +): Promise => { const yearValue = Number(year) || new Date().getFullYear(); const data = await pb .collection("code_time__daily_entries") - .getFullList>({ + .getFullList>({ filter: `date >= "${yearValue}-01-01 00:00:00.000Z" && date <= "${yearValue}-12-31 23:59:59.999Z"`, }); @@ -86,7 +81,7 @@ export const getActivities = async ( const firstRecordEver = await pb .collection("code_time__daily_entries") - .getList>(1, 1, { + .getList>(1, 1, { sort: "+date", }); @@ -98,7 +93,7 @@ export const getActivities = async ( export const getStatistics = async ( pb: PocketBase, -): Promise => { +): Promise => { const everything = await pb .collection("code_time__daily_entries") .getFullList({ @@ -198,12 +193,12 @@ export const getStatistics = async ( export const getLastXDays = async ( pb: PocketBase, days: number, -): Promise[]> => { +): Promise[]> => { const lastXDays = moment().subtract(days, "days").format("YYYY-MM-DD"); const data = await pb .collection("code_time__daily_entries") - .getFullList>({ + .getFullList>({ filter: `date >= "${lastXDays} 00:00:00.000Z"`, }); @@ -294,7 +289,7 @@ export const getEachDay = async ( const data = await pb .collection("code_time__daily_entries") - .getFullList>({ + .getFullList>({ filter: `date >= "${firstDay} 00:00:00.000Z" && date <= "${lastDay} 23:59:59.999Z"`, }); @@ -319,7 +314,7 @@ export const getUserMinutes = async ( const items = await pb .collection("code_time__daily_entries") - .getFullList>({ + .getFullList>({ filter: `date >= "${minTime}"`, }); diff --git a/server/src/apps/guitarTabs/controllers/entries.controller.ts b/server/src/apps/guitarTabs/controllers/entries.controller.ts index 03401b064..ffc4640a9 100644 --- a/server/src/apps/guitarTabs/controllers/entries.controller.ts +++ b/server/src/apps/guitarTabs/controllers/entries.controller.ts @@ -4,6 +4,7 @@ import { forgeController, } from "@functions/forgeController"; import express from "express"; +import { GuitarTabsSchemas } from "shared"; import { z } from "zod/v4"; import { @@ -13,7 +14,6 @@ import { import { uploadMiddleware } from "@middlewares/uploadMiddleware"; -import { GuitarTabsEntrySchema, GuitarTabsSidebarDataSchema } from "../schema"; import * as entriesService from "../services/entries.service"; const guitarTabsEntriesRouter = express.Router(); @@ -22,7 +22,7 @@ const getSidebarData = forgeController .route("GET /sidebar-data") .description("Get sidebar data for guitar tabs") .schema({ - response: GuitarTabsSidebarDataSchema, + response: GuitarTabsSchemas.GuitarTabsSidebarDataSchema, }) .callback(async ({ pb }) => await entriesService.getSidebarData(pb)); @@ -47,7 +47,7 @@ const getEntries = forgeController .optional() .default("newest"), }), - response: PBListResultSchema(WithPBSchema(GuitarTabsEntrySchema)), + response: PBListResultSchema(WithPBSchema(GuitarTabsSchemas.EntrySchema)), }) .callback( async ({ pb, query }) => await entriesService.getEntries(pb, query), @@ -57,7 +57,7 @@ const getRandomEntry = forgeController .route("GET /random") .description("Get a random guitar tab entry") .schema({ - response: WithPBSchema(GuitarTabsEntrySchema), + response: WithPBSchema(GuitarTabsSchemas.EntrySchema), }) .callback(async ({ pb }) => await entriesService.getRandomEntry(pb)); @@ -90,12 +90,12 @@ const updateEntry = forgeController params: z.object({ id: z.string(), }), - body: GuitarTabsEntrySchema.pick({ + body: GuitarTabsSchemas.EntrySchema.pick({ name: true, author: true, type: true, }), - response: WithPBSchema(GuitarTabsEntrySchema), + response: WithPBSchema(GuitarTabsSchemas.EntrySchema), }) .existenceCheck("params", { id: "guitar_tabs__entries", @@ -129,7 +129,7 @@ const toggleFavorite = forgeController params: z.object({ id: z.string(), }), - response: WithPBSchema(GuitarTabsEntrySchema), + response: WithPBSchema(GuitarTabsSchemas.EntrySchema), }) .existenceCheck("params", { id: "guitar_tabs__entries", diff --git a/server/src/apps/guitarTabs/controllers/guitarWorld.controller.ts b/server/src/apps/guitarTabs/controllers/guitarWorld.controller.ts index 6e6ef3b18..9bea815c3 100644 --- a/server/src/apps/guitarTabs/controllers/guitarWorld.controller.ts +++ b/server/src/apps/guitarTabs/controllers/guitarWorld.controller.ts @@ -3,9 +3,9 @@ import { forgeController, } from "@functions/forgeController"; import express from "express"; +import { GuitarTabsSchemas } from "shared"; import { z } from "zod/v4"; -import { GuitarTabsGuitarWorldEntrySchema } from "../schema"; import * as guitarWorldService from "../services/guitarWorld.service"; const guitarTabsGuitarWorldRouter = express.Router(); @@ -19,7 +19,7 @@ const getTabsList = forgeController page: z.number().optional().default(1), }), response: z.object({ - data: z.array(GuitarTabsGuitarWorldEntrySchema), + data: z.array(GuitarTabsSchemas.GuitarTabsGuitarWorldEntrySchema), totalItems: z.number(), perPage: z.number(), }), diff --git a/server/src/apps/guitarTabs/schema.ts b/server/src/apps/guitarTabs/schema.ts deleted file mode 100644 index 718897010..000000000 --- a/server/src/apps/guitarTabs/schema.ts +++ /dev/null @@ -1,66 +0,0 @@ -/** - * This file is auto-generated. DO NOT EDIT IT MANUALLY. - * If you want to add custom schemas, you will find a dedicated space at the end of this file. - * Generated for module: guitarTabs - * Generated at: 2025-07-09T12:50:41.283Z - * Contains: guitar_tabs__entries, guitar_tabs__authors_aggregated - */ -import { z } from "zod/v4"; - -const GuitarTabsEntrySchema = z.object({ - name: z.string(), - type: z.enum(["fingerstyle", "singalong", ""]), - pageCount: z.string(), - thumbnail: z.string(), - author: z.string(), - pdf: z.string(), - audio: z.string(), - musescore: z.string(), - isFavourite: z.boolean(), -}); - -const GuitarTabsAuthorAggregatedSchema = z.object({ - name: z.string(), - amount: z.number(), -}); - -type IGuitarTabsEntry = z.infer; -type IGuitarTabsAuthorAggregated = z.infer< - typeof GuitarTabsAuthorAggregatedSchema ->; - -export { GuitarTabsEntrySchema, GuitarTabsAuthorAggregatedSchema }; - -export type { IGuitarTabsEntry, IGuitarTabsAuthorAggregated }; - -// -------------------- CUSTOM SCHEMAS -------------------- - -const GuitarTabsSidebarDataSchema = z.object({ - total: z.number(), - favourites: z.number(), - categories: z.object({ - fingerstyle: z.number(), - singalong: z.number(), - uncategorized: z.number(), - }), - authors: z.record(z.string(), z.number()), -}); - -const GuitarTabsGuitarWorldEntrySchema = z.object({ - id: z.number(), - name: z.string(), - subtitle: z.string(), - category: z.string(), - mainArtist: z.string(), - uploader: z.string(), - audioUrl: z.string(), -}); - -type IGuitarTabsSidebarData = z.infer; -type IGuitarTabsGuitarWorldEntry = z.infer< - typeof GuitarTabsGuitarWorldEntrySchema ->; - -export { GuitarTabsSidebarDataSchema, GuitarTabsGuitarWorldEntrySchema }; - -export type { IGuitarTabsSidebarData, IGuitarTabsGuitarWorldEntry }; diff --git a/server/src/apps/guitarTabs/services/entries.service.ts b/server/src/apps/guitarTabs/services/entries.service.ts index 4521ccef8..b29950072 100644 --- a/server/src/apps/guitarTabs/services/entries.service.ts +++ b/server/src/apps/guitarTabs/services/entries.service.ts @@ -3,6 +3,7 @@ import fs from "fs"; import pdfPageCounter from "pdf-page-counter"; import pdfThumbnail from "pdf-thumbnail"; import PocketBase, { ListResult } from "pocketbase"; +import { GuitarTabsSchemas } from "shared"; import { Server } from "socket.io"; import { WithPB } from "@typescript/pocketbase_interfaces"; @@ -13,33 +14,27 @@ import { updateTaskInPool, } from "@middlewares/taskPoolMiddleware"; -import { - IGuitarTabsAuthorAggregated, - IGuitarTabsEntry, - IGuitarTabsSidebarData, -} from "../schema"; - let left = 0; export const getRandomEntry = async ( pb: PocketBase, -): Promise> => { +): Promise> => { const allScores = await pb .collection("guitar_tabs__entries") - .getFullList>(); + .getFullList>(); return allScores[Math.floor(Math.random() * allScores.length)]; }; export const getSidebarData = async ( pb: PocketBase, -): Promise => { +): Promise => { const allScores = await pb .collection("guitar_tabs__entries") - .getFullList>(); + .getFullList>(); const allAuthors = await pb .collection("guitar_tabs__authors_aggregated") - .getFullList>(); + .getFullList>(); return { total: allScores.length, @@ -53,7 +48,7 @@ export const getSidebarData = async ( authors: Object.fromEntries( allAuthors.map((author) => [author.name, author.amount]), ), - } satisfies IGuitarTabsSidebarData; + } satisfies GuitarTabsSchemas.IGuitarTabsSidebarData; }; export const getEntries = ( @@ -73,10 +68,10 @@ export const getEntries = ( starred: boolean; sort: "name" | "author" | "newest" | "oldest"; }, -): Promise>> => { +): Promise>> => { return pb .collection("guitar_tabs__entries") - .getList>(page, 20, { + .getList>(page, 20, { filter: `(name~"${query}" || author~"${query}") ${category ? `&& type="${category === "uncategorized" ? "" : category}"` : ""} ${author ? `&& ${author === "[na]" ? "author = ''" : `author~"${author}"`}` : ""} @@ -240,7 +235,7 @@ const processFiles = async ( await pb .collection("guitar_tabs__entries") - .create>( + .create>( { name, thumbnail: new File([thumbnailBuffer], `${decodedName}.jpeg`), @@ -322,13 +317,19 @@ const processFiles = async ( export const updateEntry = ( pb: PocketBase, id: string, - { name, author, type }: Pick, -): Promise> => - pb.collection("guitar_tabs__entries").update>(id, { + { name, author, type, - }); + }: Pick, +): Promise> => + pb + .collection("guitar_tabs__entries") + .update>(id, { + name, + author, + type, + }); export const deleteEntry = async (pb: PocketBase, id: string) => { await pb.collection("guitar_tabs__entries").delete(id); @@ -337,14 +338,14 @@ export const deleteEntry = async (pb: PocketBase, id: string) => { export const toggleFavorite = async ( pb: PocketBase, id: string, -): Promise> => { +): Promise> => { const entry = await pb .collection("guitar_tabs__entries") - .getOne>(id); + .getOne>(id); return await pb .collection("guitar_tabs__entries") - .update>(id, { + .update>(id, { isFavourite: !entry.isFavourite, }); }; diff --git a/server/src/apps/guitarTabs/services/guitarWorld.service.ts b/server/src/apps/guitarTabs/services/guitarWorld.service.ts index 8cf162bd9..050df1145 100644 --- a/server/src/apps/guitarTabs/services/guitarWorld.service.ts +++ b/server/src/apps/guitarTabs/services/guitarWorld.service.ts @@ -2,6 +2,7 @@ import fs from "fs"; import { JSDOM } from "jsdom"; import PDFDocument from "pdfkit"; import PocketBase from "pocketbase"; +import { GuitarTabsSchemas } from "shared"; import sharp from "sharp"; import { Server } from "socket.io"; @@ -12,13 +13,11 @@ import { updateTaskInPool, } from "@middlewares/taskPoolMiddleware"; -import { IGuitarTabsEntry, IGuitarTabsGuitarWorldEntry } from "../schema"; - export const getTabsList = async ( cookie: string, page: number, ): Promise<{ - data: IGuitarTabsGuitarWorldEntry[]; + data: GuitarTabsSchemas.IGuitarTabsGuitarWorldEntry[]; totalItems: number; perPage: number; }> => { @@ -163,7 +162,7 @@ export const downloadTab = async ( const newEntry = await pb .collection("guitar_tabs__entries") - .create>({ + .create>({ name, author: mainArtist, pageCount: images.length, diff --git a/server/src/apps/ideaBox/controllers/containers.controller.ts b/server/src/apps/ideaBox/controllers/containers.controller.ts index 7acaee382..64015da90 100644 --- a/server/src/apps/ideaBox/controllers/containers.controller.ts +++ b/server/src/apps/ideaBox/controllers/containers.controller.ts @@ -4,13 +4,13 @@ import { } from "@functions/forgeController"; import express from "express"; import fs from "fs"; +import { IdeaBoxSchemas } from "shared"; import { z } from "zod/v4"; import { WithPBSchema } from "@typescript/pocketbase_interfaces"; import { singleUploadMiddlewareOfKey } from "@middlewares/uploadMiddleware"; -import { IdeaBoxContainerSchema } from "../schema"; import * as containersService from "../services/containers.service"; const ideaBoxContainersRouter = express.Router(); @@ -33,7 +33,7 @@ const getContainers = forgeController .route("GET /") .description("Get all containers") .schema({ - response: z.array(WithPBSchema(IdeaBoxContainerSchema)), + response: z.array(WithPBSchema(IdeaBoxSchemas.ContainerSchema)), }) .callback(async ({ pb }) => await containersService.getContainers(pb)); @@ -41,8 +41,8 @@ const createContainer = forgeController .route("POST /") .description("Create a new container") .schema({ - body: IdeaBoxContainerSchema, - response: WithPBSchema(IdeaBoxContainerSchema), + body: IdeaBoxSchemas.ContainerSchema, + response: WithPBSchema(IdeaBoxSchemas.ContainerSchema), }) .middlewares(singleUploadMiddlewareOfKey("cover")) .callback(async ({ pb, body: { name, color, icon, cover }, req }) => { @@ -94,7 +94,7 @@ const updateContainer = forgeController icon: z.string(), cover: z.string().optional(), }), - response: WithPBSchema(IdeaBoxContainerSchema), + response: WithPBSchema(IdeaBoxSchemas.ContainerSchema), }) .middlewares(singleUploadMiddlewareOfKey("cover")) .existenceCheck("params", { diff --git a/server/src/apps/ideaBox/controllers/folders.controller.ts b/server/src/apps/ideaBox/controllers/folders.controller.ts index 2b5e38648..b2e63ee0c 100644 --- a/server/src/apps/ideaBox/controllers/folders.controller.ts +++ b/server/src/apps/ideaBox/controllers/folders.controller.ts @@ -4,11 +4,11 @@ import { forgeController, } from "@functions/forgeController"; import express from "express"; +import { IdeaBoxSchemas } from "shared"; import { z } from "zod/v4"; import { WithPBSchema } from "@typescript/pocketbase_interfaces"; -import { IdeaBoxFolderSchema } from "../schema"; import * as foldersService from "../services/folders.service"; const ideaBoxFoldersRouter = express.Router(); @@ -21,7 +21,7 @@ const getFolders = forgeController container: z.string(), "0": z.string(), }), - response: z.array(WithPBSchema(IdeaBoxFolderSchema)), + response: z.array(WithPBSchema(IdeaBoxSchemas.FolderSchema)), }) .existenceCheck("params", { container: "idea_box__containers", @@ -53,7 +53,7 @@ const createFolder = forgeController icon: z.string(), color: z.string(), }), - response: WithPBSchema(IdeaBoxFolderSchema), + response: WithPBSchema(IdeaBoxSchemas.FolderSchema), }) .existenceCheck("body", { container: "idea_box__containers", @@ -73,7 +73,7 @@ const updateFolder = forgeController icon: z.string(), color: z.string(), }), - response: WithPBSchema(IdeaBoxFolderSchema), + response: WithPBSchema(IdeaBoxSchemas.FolderSchema), }) .existenceCheck("params", { id: "idea_box__folders", @@ -93,7 +93,7 @@ const moveFolder = forgeController query: z.object({ target: z.string(), }), - response: WithPBSchema(IdeaBoxFolderSchema), + response: WithPBSchema(IdeaBoxSchemas.FolderSchema), }) .existenceCheck("params", { id: "idea_box__folders", @@ -113,7 +113,7 @@ const removeFromFolder = forgeController params: z.object({ id: z.string(), }), - response: WithPBSchema(IdeaBoxFolderSchema), + response: WithPBSchema(IdeaBoxSchemas.FolderSchema), }) .existenceCheck("params", { id: "idea_box__folders", diff --git a/server/src/apps/ideaBox/controllers/ideas.controller.ts b/server/src/apps/ideaBox/controllers/ideas.controller.ts index 855f19601..d22119c03 100644 --- a/server/src/apps/ideaBox/controllers/ideas.controller.ts +++ b/server/src/apps/ideaBox/controllers/ideas.controller.ts @@ -5,11 +5,11 @@ import { } from "@functions/forgeController"; import express from "express"; import multer from "multer"; +import { IdeaBoxSchemas } from "shared"; import { z } from "zod/v4"; import { WithPBSchema } from "@typescript/pocketbase_interfaces"; -import { IIdeaBoxEntry, IdeaBoxEntrySchema } from "../schema"; import * as ideasService from "../services/ideas.service"; const ideaBoxIdeasRouter = express.Router(); @@ -28,7 +28,7 @@ const getIdeas = forgeController .optional() .transform((val) => val === "true"), }), - response: z.array(WithPBSchema(IdeaBoxEntrySchema)), + response: z.array(WithPBSchema(IdeaBoxSchemas.EntrySchema)), }) .existenceCheck("params", { container: "idea_box__containers", @@ -58,7 +58,7 @@ const createIdea = forgeController .route("POST /") .description("Create a new idea") .schema({ - body: IdeaBoxEntrySchema.pick({ + body: IdeaBoxSchemas.EntrySchema.pick({ type: true, container: true, folder: true, @@ -69,7 +69,7 @@ const createIdea = forgeController imageLink: z.string().optional(), tags: z.string().transform((val) => JSON.parse(val)), }), - response: WithPBSchema(IdeaBoxEntrySchema), + response: WithPBSchema(IdeaBoxSchemas.EntrySchema), }) .middlewares(multer().single("image") as any) .existenceCheck("body", { @@ -83,7 +83,7 @@ const createIdea = forgeController }) => { const { file } = req; - let data: Omit & { + let data: Omit & { image?: File; } = { title: "", @@ -141,7 +141,7 @@ const updateIdea = forgeController type: z.enum(["text", "link", "image"]), tags: z.array(z.string()).optional(), }), - response: WithPBSchema(IdeaBoxEntrySchema), + response: WithPBSchema(IdeaBoxSchemas.EntrySchema), }) .existenceCheck("params", { id: "idea_box__entries", @@ -196,7 +196,7 @@ const pinIdea = forgeController params: z.object({ id: z.string(), }), - response: WithPBSchema(IdeaBoxEntrySchema), + response: WithPBSchema(IdeaBoxSchemas.EntrySchema), }) .existenceCheck("params", { id: "idea_box__entries", @@ -213,7 +213,7 @@ const archiveIdea = forgeController params: z.object({ id: z.string(), }), - response: WithPBSchema(IdeaBoxEntrySchema), + response: WithPBSchema(IdeaBoxSchemas.EntrySchema), }) .existenceCheck("params", { id: "idea_box__entries", @@ -233,7 +233,7 @@ const moveIdea = forgeController query: z.object({ target: z.string(), }), - response: WithPBSchema(IdeaBoxEntrySchema), + response: WithPBSchema(IdeaBoxSchemas.EntrySchema), }) .existenceCheck("params", { id: "idea_box__entries", @@ -253,7 +253,7 @@ const removeFromFolder = forgeController params: z.object({ id: z.string(), }), - response: WithPBSchema(IdeaBoxEntrySchema), + response: WithPBSchema(IdeaBoxSchemas.EntrySchema), }) .existenceCheck("params", { id: "idea_box__entries", diff --git a/server/src/apps/ideaBox/controllers/tags.controller.ts b/server/src/apps/ideaBox/controllers/tags.controller.ts index 1521fadaa..11bf4471e 100644 --- a/server/src/apps/ideaBox/controllers/tags.controller.ts +++ b/server/src/apps/ideaBox/controllers/tags.controller.ts @@ -3,11 +3,11 @@ import { forgeController, } from "@functions/forgeController"; import express from "express"; +import { IdeaBoxSchemas } from "shared"; import { z } from "zod/v4"; import { WithPBSchema } from "@typescript/pocketbase_interfaces"; -import { IdeaBoxTagSchema } from "../schema"; import * as tagsService from "../services/tags.service"; const ideaBoxTagsRouter = express.Router(); @@ -19,7 +19,7 @@ const getTags = forgeController params: z.object({ container: z.string(), }), - response: z.array(WithPBSchema(IdeaBoxTagSchema)), + response: z.array(WithPBSchema(IdeaBoxSchemas.TagSchema)), }) .existenceCheck("params", { container: "idea_box__containers", @@ -33,11 +33,11 @@ const createTag = forgeController .route("POST /:container") .description("Create a new tag") .schema({ - body: IdeaBoxTagSchema, + body: IdeaBoxSchemas.TagSchema, params: z.object({ container: z.string(), }), - response: WithPBSchema(IdeaBoxTagSchema), + response: WithPBSchema(IdeaBoxSchemas.TagSchema), }) .existenceCheck("params", { container: "idea_box__containers", @@ -52,11 +52,11 @@ const updateTag = forgeController .route("PATCH /:id") .description("Update a tag") .schema({ - body: IdeaBoxTagSchema, + body: IdeaBoxSchemas.TagSchema, params: z.object({ id: z.string(), }), - response: WithPBSchema(IdeaBoxTagSchema), + response: WithPBSchema(IdeaBoxSchemas.TagSchema), }) .existenceCheck("params", { id: "idea_box__tags", diff --git a/server/src/apps/ideaBox/schema.ts b/server/src/apps/ideaBox/schema.ts deleted file mode 100644 index 395f43b6f..000000000 --- a/server/src/apps/ideaBox/schema.ts +++ /dev/null @@ -1,91 +0,0 @@ -/** - * This file is auto-generated. DO NOT EDIT IT MANUALLY. - * If you want to add custom schemas, you will find a dedicated space at the end of this file. - * Generated for module: ideaBox - * Generated at: 2025-07-09T12:50:41.284Z - * Contains: idea_box__containers, idea_box__entries, idea_box__folders, idea_box__tags, idea_box__tags_aggregated, idea_box__containers_aggregated - */ -import { z } from "zod/v4"; - -const IdeaBoxContainerSchema = z.object({ - icon: z.string(), - color: z.string(), - name: z.string(), - cover: z.string(), -}); - -const IdeaBoxEntrySchema = z.object({ - type: z.enum(["text", "image", "link"]), - image: z.string(), - title: z.string(), - content: z.string(), - container: z.string(), - folder: z.string(), - pinned: z.boolean(), - archived: z.boolean(), - tags: z.any(), -}); - -const IdeaBoxFolderSchema = z.object({ - container: z.string(), - name: z.string(), - color: z.string(), - icon: z.string(), - parent: z.string(), -}); - -const IdeaBoxTagSchema = z.object({ - name: z.string(), - icon: z.string(), - color: z.string(), - container: z.string(), -}); - -const IdeaBoxTagAggregatedSchema = z.object({ - name: z.string(), - color: z.string(), - icon: z.string(), - container: z.string(), - amount: z.number(), -}); - -const IdeaBoxContainerAggregatedSchema = z.object({ - name: z.string(), - color: z.string(), - icon: z.string(), - cover: z.string(), - text_count: z.number(), - link_count: z.number(), - image_count: z.number(), -}); - -type IIdeaBoxContainer = z.infer; -type IIdeaBoxEntry = z.infer; -type IIdeaBoxFolder = z.infer; -type IIdeaBoxTag = z.infer; -type IIdeaBoxTagAggregated = z.infer; -type IIdeaBoxContainerAggregated = z.infer< - typeof IdeaBoxContainerAggregatedSchema ->; - -export { - IdeaBoxContainerSchema, - IdeaBoxEntrySchema, - IdeaBoxFolderSchema, - IdeaBoxTagSchema, - IdeaBoxTagAggregatedSchema, - IdeaBoxContainerAggregatedSchema, -}; - -export type { - IIdeaBoxContainer, - IIdeaBoxEntry, - IIdeaBoxFolder, - IIdeaBoxTag, - IIdeaBoxTagAggregated, - IIdeaBoxContainerAggregated, -}; - -// -------------------- CUSTOM SCHEMAS -------------------- - -// Add your custom schemas here. They will not be overwritten by this script. diff --git a/server/src/apps/ideaBox/services/containers.service.ts b/server/src/apps/ideaBox/services/containers.service.ts index 858f6e107..cd1e01025 100644 --- a/server/src/apps/ideaBox/services/containers.service.ts +++ b/server/src/apps/ideaBox/services/containers.service.ts @@ -1,9 +1,8 @@ import PocketBase from "pocketbase"; +import { IdeaBoxSchemas } from "shared"; import { WithPB } from "@typescript/pocketbase_interfaces"; -import { IIdeaBoxContainer } from "../schema"; - export const checkContainerExists = async ( pb: PocketBase, id: string, @@ -15,11 +14,11 @@ export const checkContainerExists = async ( export const getContainers = async ( pb: PocketBase, -): Promise[]> => +): Promise[]> => ( await pb.collection("idea_box__containers_aggregated").getFullList< WithPB< - IIdeaBoxContainer & { + IdeaBoxSchemas.IContainer & { text_count: number; link_count: number; image_count: number; @@ -43,8 +42,11 @@ export const createContainer = async ( color: string, icon: string, coverFile?: File, -): Promise> => { - const containerData: Pick & { +): Promise> => { + const containerData: Pick< + IdeaBoxSchemas.IContainer, + "name" | "color" | "icon" + > & { cover?: File | string; } = { name, @@ -60,7 +62,7 @@ export const createContainer = async ( return await pb .collection("idea_box__containers") - .create>(containerData); + .create>(containerData); }; export const updateContainer = async ( @@ -70,8 +72,11 @@ export const updateContainer = async ( color: string, icon: string, coverFile?: File | "keep", -): Promise> => { - const containerData: Pick & { +): Promise> => { + const containerData: Pick< + IdeaBoxSchemas.IContainer, + "name" | "color" | "icon" + > & { cover?: File | string; } = { name, @@ -85,7 +90,7 @@ export const updateContainer = async ( return await pb .collection("idea_box__containers") - .update>(id, containerData); + .update>(id, containerData); }; export const deleteContainer = async (pb: PocketBase, id: string) => { diff --git a/server/src/apps/ideaBox/services/folders.service.ts b/server/src/apps/ideaBox/services/folders.service.ts index a508119f4..003e842ba 100644 --- a/server/src/apps/ideaBox/services/folders.service.ts +++ b/server/src/apps/ideaBox/services/folders.service.ts @@ -1,18 +1,19 @@ import PocketBase from "pocketbase"; +import { IdeaBoxSchemas } from "shared"; import { WithPB } from "@typescript/pocketbase_interfaces"; -import { IIdeaBoxFolder } from "../schema"; - export const getFolders = ( pb: PocketBase, container: string, lastFolder: string, -): Promise[]> => - pb.collection("idea_box__folders").getFullList>({ - filter: `container = "${container}" && parent = "${lastFolder}"`, - sort: "name", - }); +): Promise[]> => + pb + .collection("idea_box__folders") + .getFullList>({ + filter: `container = "${container}" && parent = "${lastFolder}"`, + sort: "name", + }); export const createFolder = async ( pb: PocketBase, @@ -29,8 +30,8 @@ export const createFolder = async ( icon: string; color: string; }, -): Promise> => - pb.collection("idea_box__folders").create>({ +): Promise> => + pb.collection("idea_box__folders").create>({ name, container, parent, @@ -42,29 +43,35 @@ export const updateFolder = ( pb: PocketBase, id: string, { name, icon, color }: { name: string; icon: string; color: string }, -): Promise> => - pb.collection("idea_box__folders").update>(id, { - name, - icon, - color, - }); +): Promise> => + pb + .collection("idea_box__folders") + .update>(id, { + name, + icon, + color, + }); export const moveFolder = ( pb: PocketBase, id: string, target: string, -): Promise> => - pb.collection("idea_box__folders").update>(id, { - parent: target, - }); +): Promise> => + pb + .collection("idea_box__folders") + .update>(id, { + parent: target, + }); export const removeFromFolder = ( pb: PocketBase, id: string, -): Promise> => - pb.collection("idea_box__folders").update>(id, { - parent: "", - }); +): Promise> => + pb + .collection("idea_box__folders") + .update>(id, { + parent: "", + }); export const deleteFolder = async (pb: PocketBase, id: string) => { await pb.collection("idea_box__folders").delete(id); @@ -84,7 +91,7 @@ export const validateFolderPath = async ( try { const folderEntry = await pb .collection("idea_box__folders") - .getOne>(folder); + .getOne>(folder); if ( folderEntry.parent !== lastFolder || diff --git a/server/src/apps/ideaBox/services/ideas.service.ts b/server/src/apps/ideaBox/services/ideas.service.ts index 757ecd6f0..4ae4c0612 100644 --- a/server/src/apps/ideaBox/services/ideas.service.ts +++ b/server/src/apps/ideaBox/services/ideas.service.ts @@ -1,21 +1,22 @@ import PocketBase from "pocketbase"; +import { IdeaBoxSchemas } from "shared"; import { WithPB } from "@typescript/pocketbase_interfaces"; -import { IIdeaBoxEntry, IIdeaBoxFolder } from "../schema"; - export const getIdeas = ( pb: PocketBase, container: string, folder: string, archived: boolean, -): Promise[]> => - pb.collection("idea_box__entries").getFullList>({ - filter: `container = "${container}" && archived = ${archived} ${ - folder ? `&& folder = "${folder}"` : "&& folder=''" - }`, - sort: "-pinned,-created", - }); +): Promise[]> => + pb + .collection("idea_box__entries") + .getFullList>({ + filter: `container = "${container}" && archived = ${archived} ${ + folder ? `&& folder = "${folder}"` : "&& folder=''" + }`, + sort: "-pinned,-created", + }); export const validateFolderPath = async ( pb: PocketBase, @@ -32,7 +33,7 @@ export const validateFolderPath = async ( try { const folderEntry = await pb .collection("idea_box__folders") - .getOne(folder); + .getOne(folder); if ( folderEntry.parent !== lastFolder || @@ -54,18 +55,22 @@ export const validateFolderPath = async ( export const createIdea = ( pb: PocketBase, - data: Omit & { + data: Omit & { image?: File; }, -): Promise> => - pb.collection("idea_box__entries").create>(data); +): Promise> => + pb + .collection("idea_box__entries") + .create>(data); export const updateIdea = async ( pb: PocketBase, id: string, - data: Partial, -): Promise> => - pb.collection("idea_box__entries").update>(id, data); + data: Partial, +): Promise> => + pb + .collection("idea_box__entries") + .update>(id, data); export const deleteIdea = async (pb: PocketBase, id: string) => { await pb.collection("idea_box__entries").delete(id); @@ -74,11 +79,11 @@ export const deleteIdea = async (pb: PocketBase, id: string) => { export const updatePinStatus = async (pb: PocketBase, id: string) => { const idea = await pb .collection("idea_box__entries") - .getOne>(id); + .getOne>(id); const entry = await pb .collection("idea_box__entries") - .update>(id, { + .update>(id, { pinned: !idea.pinned, }); @@ -88,11 +93,11 @@ export const updatePinStatus = async (pb: PocketBase, id: string) => { export const updateArchiveStatus = async (pb: PocketBase, id: string) => { const idea = await pb .collection("idea_box__entries") - .getOne>(id); + .getOne>(id); const entry = await pb .collection("idea_box__entries") - .update>(id, { + .update>(id, { archived: !idea.archived, pinned: false, }); @@ -104,15 +109,15 @@ export const moveIdea = async ( pb: PocketBase, id: string, target: string, -): Promise> => - pb.collection("idea_box__entries").update>(id, { +): Promise> => + pb.collection("idea_box__entries").update>(id, { folder: target, }); export const removeFromFolder = ( pb: PocketBase, id: string, -): Promise> => - pb.collection("idea_box__entries").update>(id, { +): Promise> => + pb.collection("idea_box__entries").update>(id, { folder: "", }); diff --git a/server/src/apps/ideaBox/services/misc.service.ts b/server/src/apps/ideaBox/services/misc.service.ts index 3acd2dd12..58ed1e398 100644 --- a/server/src/apps/ideaBox/services/misc.service.ts +++ b/server/src/apps/ideaBox/services/misc.service.ts @@ -4,11 +4,10 @@ import { clientError } from "@functions/response"; import { Request, Response } from "express"; import ogs from "open-graph-scraper"; import PocketBase from "pocketbase"; +import { IdeaBoxSchemas } from "shared"; import { WithPB } from "@typescript/pocketbase_interfaces"; -import { IIdeaBoxContainer, IIdeaBoxEntry, IIdeaBoxFolder } from "../schema"; - const OGCache = new Map(); export const getPath = async ( @@ -18,8 +17,8 @@ export const getPath = async ( req: Request, res: Response, ): Promise<{ - container: WithPB; - path: WithPB[]; + container: WithPB; + path: WithPB[]; } | null> => { const containerExists = await checkExistence( req, @@ -32,14 +31,14 @@ export const getPath = async ( const containerEntry = await pb .collection("idea_box__containers") - .getOne>(container); + .getOne>(container); containerEntry.cover = pb.files .getURL(containerEntry, containerEntry.cover) .replace(`${pb.baseURL}/api/files`, ""); let lastFolder = ""; - const fullPath: WithPB[] = []; + const fullPath: WithPB[] = []; for (const folder of path) { if (!(await checkExistence(req, res, "idea_box__folders", folder))) { @@ -48,7 +47,7 @@ export const getPath = async ( const folderEntry = await pb .collection("idea_box__folders") - .getOne>(folder); + .getOne>(folder); if ( folderEntry.parent !== lastFolder || @@ -98,7 +97,7 @@ export const checkValid = async ( const folderEntry = await pb .collection("idea_box__folders") - .getOne(folder); + .getOne(folder); if ( folderEntry.parent !== lastFolder || @@ -120,7 +119,7 @@ export const getOgData = async ( ): Promise => { const data = await pb .collection("idea_box__entries") - .getOne(id); + .getOne(id); if (data.type !== "link") { throw new ClientError( @@ -159,26 +158,26 @@ async function recursivelySearchFolder( parents: string, pb: PocketBase, ): Promise< - (Omit, "folder"> & { - folder: WithPB; + (Omit, "folder"> & { + folder: WithPB; expand?: { - folder: WithPB; + folder: WithPB; }; fullPath: string; })[] > { const folderInsideFolder = await pb .collection("idea_box__folders") - .getFullList>({ + .getFullList>({ filter: `parent = "${folderId}"`, }); const allResults = ( await pb.collection("idea_box__entries").getFullList< - Omit, "folder"> & { - folder: WithPB; + Omit, "folder"> & { + folder: WithPB; expand?: { - folder: WithPB; + folder: WithPB; }; } >({ @@ -225,10 +224,10 @@ export const search = async ( req: Request, res: Response, ): Promise< - | (Omit, "folder"> & { - folder: WithPB; + | (Omit, "folder"> & { + folder: WithPB; expand?: { - folder: WithPB; + folder: WithPB; }; fullPath: string; })[] diff --git a/server/src/apps/ideaBox/services/tags.service.ts b/server/src/apps/ideaBox/services/tags.service.ts index 7210a0e4a..59df73805 100644 --- a/server/src/apps/ideaBox/services/tags.service.ts +++ b/server/src/apps/ideaBox/services/tags.service.ts @@ -1,16 +1,17 @@ import PocketBase from "pocketbase"; +import { IdeaBoxSchemas } from "shared"; import { WithPB } from "@typescript/pocketbase_interfaces"; -import { IIdeaBoxTag } from "../schema"; - export const getTags = ( pb: PocketBase, container: string, -): Promise[]> => - pb.collection("idea_box__tags_aggregated").getFullList>({ - filter: `container = "${container}"`, - }); +): Promise[]> => + pb + .collection("idea_box__tags_aggregated") + .getFullList>({ + filter: `container = "${container}"`, + }); export const createTag = ( pb: PocketBase, @@ -25,7 +26,7 @@ export const createTag = ( color: string; }, ) => - pb.collection("idea_box__tags").create>({ + pb.collection("idea_box__tags").create>({ name, icon, color, @@ -44,7 +45,7 @@ export const updateTag = ( icon: string; color: string; }, -): Promise> => +): Promise> => pb.collection("idea_box__tags").update(id, { name, icon, diff --git a/server/src/apps/momentVault/controllers/entries.controller.ts b/server/src/apps/momentVault/controllers/entries.controller.ts index dd9e3664d..70b90743c 100644 --- a/server/src/apps/momentVault/controllers/entries.controller.ts +++ b/server/src/apps/momentVault/controllers/entries.controller.ts @@ -4,6 +4,7 @@ import { forgeController, } from "@functions/forgeController"; import express from "express"; +import { MomentVaultSchemas } from "shared"; import { z } from "zod/v4"; import { @@ -13,7 +14,6 @@ import { import { uploadMiddleware } from "@middlewares/uploadMiddleware"; -import { MomentVaultEntrySchema } from "../schema"; import * as EntriesServices from "../services/entries.service"; const momentVaultEntriesRouter = express.Router(); @@ -28,7 +28,7 @@ const getEntries = forgeController .optional() .transform((val) => parseInt(val ?? "1", 10) || 1), }), - response: PBListResultSchema(WithPBSchema(MomentVaultEntrySchema)), + response: PBListResultSchema(WithPBSchema(MomentVaultSchemas.EntrySchema)), }) .callback( async ({ pb, query }) => @@ -44,7 +44,7 @@ const createEntry = forgeController content: z.string().optional(), transcription: z.string().optional(), }), - response: WithPBSchema(MomentVaultEntrySchema), + response: WithPBSchema(MomentVaultSchemas.EntrySchema), }) .middlewares(uploadMiddleware) .callback(async ({ pb, body: { type, content, transcription }, req }) => { @@ -101,7 +101,7 @@ const updateEntry = forgeController body: z.object({ content: z.string(), }), - response: WithPBSchema(MomentVaultEntrySchema), + response: WithPBSchema(MomentVaultSchemas.EntrySchema), }) .existenceCheck("params", { id: "moment_vault__entries", diff --git a/server/src/apps/momentVault/schema.ts b/server/src/apps/momentVault/schema.ts deleted file mode 100644 index 6e55e2943..000000000 --- a/server/src/apps/momentVault/schema.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * This file is auto-generated. DO NOT EDIT IT MANUALLY. - * If you want to add custom schemas, you will find a dedicated space at the end of this file. - * Generated for module: momentVault - * Generated at: 2025-07-09T12:50:41.283Z - * Contains: moment_vault__entries - */ -import { z } from "zod/v4"; - -const MomentVaultEntrySchema = z.object({ - type: z.enum(["text", "audio", "video", "photos", ""]), - file: z.array(z.string()), - content: z.string(), - transcription: z.string(), -}); - -type IMomentVaultEntry = z.infer; - -export { MomentVaultEntrySchema }; - -export type { IMomentVaultEntry }; - -// -------------------- CUSTOM SCHEMAS -------------------- - -// Add your custom schemas here. They will not be overwritten by this script. diff --git a/server/src/apps/momentVault/services/entries.service.ts b/server/src/apps/momentVault/services/entries.service.ts index eeb8f50df..a04b7b03f 100644 --- a/server/src/apps/momentVault/services/entries.service.ts +++ b/server/src/apps/momentVault/services/entries.service.ts @@ -1,28 +1,28 @@ import fs from "fs"; import { ListResult } from "pocketbase"; import Client from "pocketbase"; +import { MomentVaultSchemas } from "shared"; import { WithPB } from "@typescript/pocketbase_interfaces"; -import { IMomentVaultEntry } from "../schema"; import { convertToMp3 } from "../utils/convertToMP3"; export async function getEntryById( pb: Client, id: string, -): Promise { +): Promise { return await pb .collection("moment_vault__entries") - .getOne(id); + .getOne(id); } export const getAllEntries = async ( pb: Client, page: number = 1, -): Promise>> => { +): Promise>> => { const entries = await pb .collection("moment_vault__entries") - .getList>(page, 10, { + .getList>(page, 10, { sort: "-created", }); @@ -46,7 +46,7 @@ export const createAudioEntry = async ( file: Express.Multer.File; transcription?: string; }, -): Promise> => { +): Promise> => { if (file.mimetype !== "audio/mp3") { file.path = await convertToMp3(file.path); } @@ -55,7 +55,7 @@ export const createAudioEntry = async ( const entry = await pb .collection("moment_vault__entries") - .create>({ + .create>({ type: "audio", file: new File([fileBuffer], file.path.split("/").pop() || "audio.mp3"), transcription, @@ -75,10 +75,10 @@ export const createAudioEntry = async ( export const createTextEntry = async ( pb: Client, content: string, -): Promise> => { +): Promise> => { return await pb .collection("moment_vault__entries") - .create>({ + .create>({ type: "text", content, }); @@ -87,7 +87,7 @@ export const createTextEntry = async ( export const createPhotosEntry = async ( pb: Client, files: Express.Multer.File[], -): Promise> => { +): Promise> => { const allImages = files.map((file) => { const fileBuffer = fs.readFileSync(file.path); return new File([fileBuffer], file.path.split("/").pop() || "photo.jpg"); @@ -95,7 +95,7 @@ export const createPhotosEntry = async ( const entry = await pb .collection("moment_vault__entries") - .create>({ + .create>({ type: "photos", file: allImages, }); @@ -117,10 +117,10 @@ export const updateEntry = async ( pb: Client, id: string, content: string, -): Promise> => +): Promise> => await pb .collection("moment_vault__entries") - .update>(id, { + .update>(id, { content, }); diff --git a/server/src/apps/momentVault/services/transcription.service.ts b/server/src/apps/momentVault/services/transcription.service.ts index d23be77d6..8bcf93fd9 100644 --- a/server/src/apps/momentVault/services/transcription.service.ts +++ b/server/src/apps/momentVault/services/transcription.service.ts @@ -4,8 +4,7 @@ import fs from "fs"; import Groq from "groq-sdk"; import PocketBase from "pocketbase"; import request from "request"; - -import { IMomentVaultEntry } from "../schema"; +import { MomentVaultSchemas } from "shared"; const getTranscription = async ( filePath: string, @@ -35,7 +34,7 @@ export const transcribeExisted = async ( const entry = await pb .collection("moment_vault__entries") - .getOne(id); + .getOne(id); if (!entry.file) { throw new ClientError("No audio file found in entry"); @@ -61,9 +60,11 @@ export const transcribeExisted = async ( throw new Error("Transcription failed"); } - await pb.collection("moment_vault__entries").update(id, { - transcription: response, - }); + await pb + .collection("moment_vault__entries") + .update(id, { + transcription: response, + }); return response; } catch (err) { diff --git a/server/src/apps/movies/controllers/entries.controller.ts b/server/src/apps/movies/controllers/entries.controller.ts index 08dafec7c..b79153f3d 100644 --- a/server/src/apps/movies/controllers/entries.controller.ts +++ b/server/src/apps/movies/controllers/entries.controller.ts @@ -3,11 +3,11 @@ import { forgeController, } from "@functions/forgeController"; import express from "express"; +import { MoviesSchemas } from "shared"; import { z } from "zod/v4"; import { WithPBSchema } from "@typescript/pocketbase_interfaces"; -import { MoviesEntrySchema } from "../schema"; import * as entriesService from "../services/entries.service"; const moviesEntriesRouter = express.Router(); @@ -24,7 +24,7 @@ const getAllEntries = forgeController .transform((val) => (val === "true" ? true : false)), }), response: z.object({ - entries: z.array(WithPBSchema(MoviesEntrySchema)), + entries: z.array(WithPBSchema(MoviesSchemas.EntrySchema)), total: z.number(), }), }) @@ -39,7 +39,7 @@ const createEntryFromTMDB = forgeController params: z.object({ id: z.string(), }), - response: WithPBSchema(MoviesEntrySchema), + response: WithPBSchema(MoviesSchemas.EntrySchema), }) .callback(({ pb, params: { id } }) => entriesService.createEntryFromTMDB(pb, id), @@ -68,7 +68,7 @@ const toggleWatchStatus = forgeController params: z.object({ id: z.string(), }), - response: WithPBSchema(MoviesEntrySchema), + response: WithPBSchema(MoviesSchemas.EntrySchema), }) .existenceCheck("params", { id: "movies__entries", diff --git a/server/src/apps/movies/controllers/ticket.controller.ts b/server/src/apps/movies/controllers/ticket.controller.ts index a9466e86b..3b28e93a1 100644 --- a/server/src/apps/movies/controllers/ticket.controller.ts +++ b/server/src/apps/movies/controllers/ticket.controller.ts @@ -3,11 +3,11 @@ import { forgeController, } from "@functions/forgeController"; import express from "express"; +import { MoviesSchemas } from "shared"; import { z } from "zod/v4"; import { WithPBSchema } from "@typescript/pocketbase_interfaces"; -import { MoviesEntrySchema } from "../schema"; import * as TicketService from "../services/ticket.service"; const moviesTicketRouter = express.Router(); @@ -16,7 +16,7 @@ const updateTicket = forgeController .route("POST /") .description("Update ticket information for a movie entry") .schema({ - body: MoviesEntrySchema.pick({ + body: MoviesSchemas.EntrySchema.pick({ ticket_number: true, theatre_number: true, theatre_seat: true, @@ -34,7 +34,7 @@ const updateTicket = forgeController }), }), }), - response: WithPBSchema(MoviesEntrySchema), + response: WithPBSchema(MoviesSchemas.EntrySchema), }) .existenceCheck("body", { entry_id: "movies__entries", @@ -48,7 +48,7 @@ const updateTicketPatch = forgeController params: z.object({ id: z.string(), }), - body: MoviesEntrySchema.pick({ + body: MoviesSchemas.EntrySchema.pick({ ticket_number: true, theatre_number: true, theatre_seat: true, @@ -65,7 +65,7 @@ const updateTicketPatch = forgeController }), }), }), - response: WithPBSchema(MoviesEntrySchema), + response: WithPBSchema(MoviesSchemas.EntrySchema), }) .existenceCheck("params", { id: "movies__entries", diff --git a/server/src/apps/movies/schema.ts b/server/src/apps/movies/schema.ts deleted file mode 100644 index 9d19ce4e9..000000000 --- a/server/src/apps/movies/schema.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * This file is auto-generated. DO NOT EDIT IT MANUALLY. - * If you want to add custom schemas, you will find a dedicated space at the end of this file. - * Generated for module: movies - * Generated at: 2025-07-09T12:50:41.284Z - * Contains: movies__entries - */ -import { z } from "zod/v4"; - -const MoviesEntrySchema = z.object({ - tmdb_id: z.number(), - title: z.string(), - original_title: z.string(), - poster: z.string(), - genres: z.any(), - duration: z.number(), - overview: z.string(), - countries: z.any(), - language: z.string(), - release_date: z.string(), - watch_date: z.string(), - ticket_number: z.string(), - theatre_seat: z.string(), - theatre_showtime: z.string(), - theatre_location: z.string(), - theatre_number: z.string(), - is_watched: z.boolean(), -}); - -type IMoviesEntry = z.infer; - -export { MoviesEntrySchema }; - -export type { IMoviesEntry }; - -// -------------------- CUSTOM SCHEMAS -------------------- - -// Add your custom schemas here. They will not be overwritten by this script. diff --git a/server/src/apps/movies/services/entries.service.ts b/server/src/apps/movies/services/entries.service.ts index c341b2b79..1d6612887 100644 --- a/server/src/apps/movies/services/entries.service.ts +++ b/server/src/apps/movies/services/entries.service.ts @@ -1,25 +1,26 @@ import { getAPIKey } from "@functions/getAPIKey"; import PocketBase from "pocketbase"; +import { MoviesSchemas } from "shared"; import { WithPB } from "@typescript/pocketbase_interfaces"; -import { IMoviesEntry } from "../schema"; - export const getAllEntries = async ( pb: PocketBase, watched: boolean, ): Promise<{ - entries: WithPB[]; + entries: WithPB[]; total: number; }> => { const entries = await pb .collection("movies__entries") - .getFullList>({ + .getFullList>({ filter: `is_watched = ${watched}`, }); const total = ( - await pb.collection("movies__entries").getList>(1, 1) + await pb + .collection("movies__entries") + .getList>(1, 1) ).totalItems; return { @@ -44,7 +45,7 @@ export const getAllEntries = async ( export const createEntryFromTMDB = async ( pb: PocketBase, id: string, -): Promise> => { +): Promise> => { const apiKey = await getAPIKey("tmdb", pb); if (!apiKey) { throw new Error("API key not found"); @@ -52,7 +53,7 @@ export const createEntryFromTMDB = async ( const existedData = await pb .collection("movies__entries") - .getFirstListItem>(`tmdb_id = ${id}`) + .getFirstListItem>(`tmdb_id = ${id}`) .catch(() => null); if (existedData) { @@ -84,7 +85,7 @@ export const createEntryFromTMDB = async ( return await pb .collection("movies__entries") - .create>(entryData); + .create>(entryData); }; export const deleteEntry = async ( @@ -97,14 +98,14 @@ export const deleteEntry = async ( export const toggleWatchStatus = async ( pb: PocketBase, id: string, -): Promise> => { +): Promise> => { const entry = await pb .collection("movies__entries") - .getOne>(id); + .getOne>(id); const updatedEntry = await pb .collection("movies__entries") - .update>(id, { + .update>(id, { is_watched: !entry.is_watched, }); diff --git a/server/src/apps/movies/services/ticket.service.ts b/server/src/apps/movies/services/ticket.service.ts index 847fdbd95..2da2c6fb5 100644 --- a/server/src/apps/movies/services/ticket.service.ts +++ b/server/src/apps/movies/services/ticket.service.ts @@ -1,13 +1,12 @@ import PocketBase from "pocketbase"; +import { MoviesSchemas } from "shared"; import { WithPB } from "@typescript/pocketbase_interfaces"; -import { IMoviesEntry } from "../schema"; - export const updateTicket = ( pb: PocketBase, ticketData: Pick< - IMoviesEntry, + MoviesSchemas.IEntry, "ticket_number" | "theatre_number" | "theatre_seat" | "theatre_showtime" > & { entry_id: string; @@ -22,24 +21,26 @@ export const updateTicket = ( }; }; }, -): Promise> => { +): Promise> => { (ticketData as any).theatre_location = ticketData.theatre_location.displayName.text; return pb .collection("movies__entries") - .update>(ticketData.entry_id, ticketData); + .update>(ticketData.entry_id, ticketData); }; export const clearTicket = async ( pb: PocketBase, id: string, ): Promise => { - await pb.collection("movies__entries").update>(id, { - ticket_number: "", - theatre_location: "", - theatre_number: "", - theatre_seat: "", - theatre_showtime: "", - }); + await pb + .collection("movies__entries") + .update>(id, { + ticket_number: "", + theatre_location: "", + theatre_number: "", + theatre_seat: "", + theatre_showtime: "", + }); }; diff --git a/server/src/apps/movies/services/tmdb.service.ts b/server/src/apps/movies/services/tmdb.service.ts index c498edc63..11e1fff77 100644 --- a/server/src/apps/movies/services/tmdb.service.ts +++ b/server/src/apps/movies/services/tmdb.service.ts @@ -1,10 +1,9 @@ import { getAPIKey } from "@functions/getAPIKey"; import Pocketbase from "pocketbase"; +import { MoviesSchemas } from "shared"; import { WithPB } from "@typescript/pocketbase_interfaces"; -import { IMoviesEntry } from "../schema"; - export const searchMovies = async (pb: Pocketbase, q: string, page: number) => { const apiKey = await getAPIKey("tmdb", pb); @@ -24,7 +23,7 @@ export const searchMovies = async (pb: Pocketbase, q: string, page: number) => { const allIds = await pb .collection("movies__entries") - .getFullList>({ + .getFullList>({ filter: response.results .map((entry: { id: number }) => `tmdb_id = ${entry.id}`) .join(" || "), diff --git a/server/src/apps/music/controllers/entries.controller.ts b/server/src/apps/music/controllers/entries.controller.ts index c16547ffb..e208f386f 100644 --- a/server/src/apps/music/controllers/entries.controller.ts +++ b/server/src/apps/music/controllers/entries.controller.ts @@ -3,11 +3,11 @@ import { forgeController, } from "@functions/forgeController"; import express from "express"; +import { MusicSchemas } from "shared"; import { z } from "zod/v4"; import { WithPBSchema } from "@typescript/pocketbase_interfaces"; -import { MusicEntrySchema } from "../schema"; import * as EntriesService from "../services/entries.service"; const musicEntriesRouter = express.Router(); @@ -16,7 +16,7 @@ const getAllEntries = forgeController .route("GET /") .description("Get all music entries") .schema({ - response: z.array(WithPBSchema(MusicEntrySchema)), + response: z.array(WithPBSchema(MusicSchemas.EntrySchema)), }) .callback(async ({ pb }) => await EntriesService.getAllEntries(pb)); @@ -27,8 +27,8 @@ const updateEntry = forgeController params: z.object({ id: z.string(), }), - body: MusicEntrySchema.pick({ name: true, author: true }), - response: WithPBSchema(MusicEntrySchema), + body: MusicSchemas.EntrySchema.pick({ name: true, author: true }), + response: WithPBSchema(MusicSchemas.EntrySchema), }) .callback( async ({ pb, params: { id }, body }) => @@ -59,7 +59,7 @@ const toggleFavorite = forgeController params: z.object({ id: z.string(), }), - response: WithPBSchema(MusicEntrySchema), + response: WithPBSchema(MusicSchemas.EntrySchema), }) .existenceCheck("params", { id: "music__entries", diff --git a/server/src/apps/music/controllers/youtube.controller.ts b/server/src/apps/music/controllers/youtube.controller.ts index 190ee2450..2b63717b4 100644 --- a/server/src/apps/music/controllers/youtube.controller.ts +++ b/server/src/apps/music/controllers/youtube.controller.ts @@ -3,9 +3,9 @@ import { forgeController, } from "@functions/forgeController"; import express from "express"; +import { MusicSchemas } from "shared"; import { z } from "zod/v4"; -import { YoutubeDataSchema } from "../schema"; import * as YoutubeService from "../services/youtube.service"; const musicYoutubeRouter = express.Router(); @@ -17,7 +17,7 @@ const getVideoInfo = forgeController params: z.object({ id: z.string().regex(/^[a-zA-Z0-9_-]{11}$/, "Invalid YouTube video ID"), }), - response: YoutubeDataSchema, + response: MusicSchemas.YoutubeDataSchema, }) .callback( async ({ params: { id } }) => await YoutubeService.getVideoInfo(id), diff --git a/server/src/apps/music/schema.ts b/server/src/apps/music/schema.ts deleted file mode 100644 index 4066a6b7d..000000000 --- a/server/src/apps/music/schema.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * This file is auto-generated. DO NOT EDIT IT MANUALLY. - * If you want to add custom schemas, you will find a dedicated space at the end of this file. - * Generated for module: music - * Generated at: 2025-07-09T12:50:41.281Z - * Contains: music__entries - */ -import { z } from "zod/v4"; - -const MusicEntrySchema = z.object({ - name: z.string(), - duration: z.string(), - author: z.string(), - file: z.string(), - is_favourite: z.boolean(), -}); - -type IMusicEntry = z.infer; - -export { MusicEntrySchema }; - -export type { IMusicEntry }; - -// -------------------- CUSTOM SCHEMAS -------------------- - -const YoutubeDataSchema = z.object({ - title: z.string(), - uploadDate: z.string(), - uploader: z.string(), - uploaderUrl: z.string().optional(), - duration: z.string(), - viewCount: z.number(), - likeCount: z.number(), - thumbnail: z.string(), -}); - -type IYoutubeData = z.infer; - -export { YoutubeDataSchema }; - -export type { IYoutubeData }; diff --git a/server/src/apps/music/services/entries.service.ts b/server/src/apps/music/services/entries.service.ts index 5b5e4e2ee..1f8201605 100644 --- a/server/src/apps/music/services/entries.service.ts +++ b/server/src/apps/music/services/entries.service.ts @@ -1,9 +1,8 @@ import Pocketbase from "pocketbase"; +import { MusicSchemas } from "shared"; import { WithPB } from "@typescript/pocketbase_interfaces"; -import { IMusicEntry } from "../schema"; - let importProgress: "in_progress" | "completed" | "failed" | "empty" = "empty"; export const getImportProgress = (): @@ -22,17 +21,21 @@ export const setImportProgress = ( export const getAllEntries = async ( pb: Pocketbase, -): Promise[]> => - await pb.collection("music__entries").getFullList>({ - sort: "-is_favourite, name", - }); +): Promise[]> => + await pb + .collection("music__entries") + .getFullList>({ + sort: "-is_favourite, name", + }); export const updateEntry = async ( pb: Pocketbase, id: string, data: { name: string; author: string }, -): Promise> => - await pb.collection("music__entries").update>(id, data); +): Promise> => + await pb + .collection("music__entries") + .update>(id, data); export const deleteEntry = async (pb: Pocketbase, id: string) => { await pb.collection("music__entries").delete(id); @@ -41,7 +44,7 @@ export const deleteEntry = async (pb: Pocketbase, id: string) => { export const toggleFavorite = async ( pb: Pocketbase, id: string, -): Promise> => { +): Promise> => { const entry = await pb.collection("music__entries").getOne(id); return await pb.collection("music__entries").update(id, { is_favourite: !entry.is_favourite, diff --git a/server/src/apps/music/services/youtube.service.ts b/server/src/apps/music/services/youtube.service.ts index a724b9a87..07bccada3 100644 --- a/server/src/apps/music/services/youtube.service.ts +++ b/server/src/apps/music/services/youtube.service.ts @@ -1,10 +1,9 @@ import { exec } from "child_process"; import { readFileSync, readdirSync, unlinkSync } from "fs"; import Pocketbase from "pocketbase"; +import { MusicSchemas } from "shared"; import { v4 } from "uuid"; -import { IYoutubeData } from "../schema"; - let downloadStatus: "empty" | "in_progress" | "completed" | "failed" = "empty"; export const getDownloadStatus = () => ({ @@ -17,7 +16,9 @@ export const setDownloadStatus = ( downloadStatus = status; }; -export const getVideoInfo = (videoId: string): Promise => { +export const getVideoInfo = ( + videoId: string, +): Promise => { return new Promise((resolve, reject) => { exec( `${process.cwd()}/src/core/bin/yt-dlp --skip-download --print "title,upload_date,uploader,duration,view_count,like_count,thumbnail" "https://www.youtube.com/watch?v=${videoId}"`, @@ -37,7 +38,7 @@ export const getVideoInfo = (videoId: string): Promise => { thumbnail, ] = stdout.split("\n"); - const response: IYoutubeData = { + const response: MusicSchemas.IYoutubeData = { title, uploadDate, uploader, diff --git a/server/src/apps/passwords/controllers/entries.controller.ts b/server/src/apps/passwords/controllers/entries.controller.ts index 532744308..4929b7b5d 100644 --- a/server/src/apps/passwords/controllers/entries.controller.ts +++ b/server/src/apps/passwords/controllers/entries.controller.ts @@ -3,12 +3,12 @@ import { forgeController, } from "@functions/forgeController"; import express from "express"; +import { PasswordsSchemas } from "shared"; import { v4 } from "uuid"; import { z } from "zod/v4"; import { WithPBSchema } from "@typescript/pocketbase_interfaces"; -import { PasswordsEntrySchema } from "../schema"; import * as EntriesService from "../services/entries.service"; const passwordsEntriesRouter = express.Router(); @@ -31,7 +31,7 @@ const getAllEntries = forgeController .route("GET /") .description("Get all password entries") .schema({ - response: z.array(WithPBSchema(PasswordsEntrySchema)), + response: z.array(WithPBSchema(PasswordsSchemas.EntrySchema)), }) .callback(async ({ pb }) => await EntriesService.getAllEntries(pb)); @@ -39,12 +39,12 @@ const createEntry = forgeController .route("POST /") .description("Create a new password entry") .schema({ - body: PasswordsEntrySchema.omit({ + body: PasswordsSchemas.EntrySchema.omit({ pinned: true, }).extend({ master: z.string(), }), - response: WithPBSchema(PasswordsEntrySchema), + response: WithPBSchema(PasswordsSchemas.EntrySchema), }) .callback( async ({ pb, body }) => @@ -59,12 +59,12 @@ const updateEntry = forgeController params: z.object({ id: z.string(), }), - body: PasswordsEntrySchema.omit({ + body: PasswordsSchemas.EntrySchema.omit({ pinned: true, }).extend({ master: z.string(), }), - response: WithPBSchema(PasswordsEntrySchema), + response: WithPBSchema(PasswordsSchemas.EntrySchema), }) .existenceCheck("params", { id: "passwords__entries", @@ -118,7 +118,7 @@ const togglePin = forgeController params: z.object({ id: z.string(), }), - response: WithPBSchema(PasswordsEntrySchema), + response: WithPBSchema(PasswordsSchemas.EntrySchema), }) .existenceCheck("params", { id: "passwords__entries", diff --git a/server/src/apps/passwords/schema.ts b/server/src/apps/passwords/schema.ts deleted file mode 100644 index 44cd42d66..000000000 --- a/server/src/apps/passwords/schema.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * This file is auto-generated. DO NOT EDIT IT MANUALLY. - * If you want to add custom schemas, you will find a dedicated space at the end of this file. - * Generated for module: passwords - * Generated at: 2025-07-09T12:50:41.283Z - * Contains: passwords__entries - */ -import { z } from "zod/v4"; - -const PasswordsEntrySchema = z.object({ - name: z.string(), - website: z.string(), - username: z.string(), - password: z.string(), - icon: z.string(), - color: z.string(), - pinned: z.boolean(), -}); - -type IPasswordsEntry = z.infer; - -export { PasswordsEntrySchema }; - -export type { IPasswordsEntry }; - -// -------------------- CUSTOM SCHEMAS -------------------- - -// Add your custom schemas here. They will not be overwritten by this script. diff --git a/server/src/apps/passwords/services/entries.service.ts b/server/src/apps/passwords/services/entries.service.ts index bce66947b..296fd80cd 100644 --- a/server/src/apps/passwords/services/entries.service.ts +++ b/server/src/apps/passwords/services/entries.service.ts @@ -1,17 +1,17 @@ import { decrypt, decrypt2, encrypt, encrypt2 } from "@functions/encryption"; import PocketBase from "pocketbase"; +import { PasswordsSchemas } from "shared"; import { WithPB } from "@typescript/pocketbase_interfaces"; -import { IPasswordsEntry } from "../schema"; import { getDecryptedMaster } from "./master.service"; export const getAllEntries = async ( pb: PocketBase, -): Promise[]> => +): Promise[]> => await pb .collection("passwords__entries") - .getFullList>({ + .getFullList>({ sort: "-pinned, name", }); @@ -25,9 +25,9 @@ export const createEntry = async ( username, password, master, - }: Omit & { master: string }, + }: Omit & { master: string }, challenge: string, -): Promise> => { +): Promise> => { const decryptedMaster = await getDecryptedMaster(pb, master, challenge); const decryptedPassword = decrypt2(password, challenge); @@ -38,7 +38,7 @@ export const createEntry = async ( const entry = await pb .collection("passwords__entries") - .create>({ + .create>({ name, icon, color, @@ -61,9 +61,9 @@ export const updateEntry = async ( username, password, master, - }: Omit & { master: string }, + }: Omit & { master: string }, challenge: string, -): Promise> => { +): Promise> => { const decryptedMaster = await getDecryptedMaster(pb, master, challenge); const decryptedPassword = decrypt2(password, challenge); @@ -74,7 +74,7 @@ export const updateEntry = async ( const entry = await pb .collection("passwords__entries") - .update>(id, { + .update>(id, { name, icon, color, @@ -94,7 +94,7 @@ export const decryptEntry = async ( ): Promise => { const decryptedMaster = await getDecryptedMaster(pb, master, challenge); - const password: IPasswordsEntry = await pb + const password: PasswordsSchemas.IEntry = await pb .collection("passwords__entries") .getOne(id); @@ -113,14 +113,14 @@ export const deleteEntry = async (pb: PocketBase, id: string) => { export const togglePin = async ( pb: PocketBase, id: string, -): Promise> => { +): Promise> => { const entry = await pb .collection("passwords__entries") - .getOne>(id); + .getOne>(id); return await pb .collection("passwords__entries") - .update>(id, { + .update>(id, { pinned: !entry.pinned, }); }; diff --git a/server/src/apps/railwayMap/controllers/railwayMap.controller.ts b/server/src/apps/railwayMap/controllers/railwayMap.controller.ts index 187d74087..307a96d24 100644 --- a/server/src/apps/railwayMap/controllers/railwayMap.controller.ts +++ b/server/src/apps/railwayMap/controllers/railwayMap.controller.ts @@ -3,11 +3,11 @@ import { forgeController, } from "@functions/forgeController"; import express from "express"; +import { RailwayMapSchemas } from "shared"; import { z } from "zod/v4"; import { WithPBSchema } from "@typescript/pocketbase_interfaces"; -import { RailwayMapLineSchema, RailwayMapStationSchema } from "../schema"; import * as RailwayMapServices from "../services/railwayMap.service"; const railwayMapRouter = express.Router(); @@ -16,7 +16,7 @@ const getLines = forgeController .route("GET /lines") .description("Get all railway lines") .schema({ - response: z.array(WithPBSchema(RailwayMapLineSchema)), + response: z.array(WithPBSchema(RailwayMapSchemas.LineSchema)), }) .callback(async ({ pb }) => await RailwayMapServices.getLines(pb)); @@ -24,7 +24,7 @@ const getStations = forgeController .route("GET /stations") .description("Get all railway stations") .schema({ - response: z.array(WithPBSchema(RailwayMapStationSchema)), + response: z.array(WithPBSchema(RailwayMapSchemas.StationSchema)), }) .callback(async ({ pb }) => RailwayMapServices.getStations(pb)); @@ -36,7 +36,7 @@ const getShortestPath = forgeController start: z.string(), end: z.string(), }), - response: z.array(WithPBSchema(RailwayMapStationSchema)), + response: z.array(WithPBSchema(RailwayMapSchemas.StationSchema)), }) .callback( async ({ pb, query: { start, end } }) => diff --git a/server/src/apps/railwayMap/schema.ts b/server/src/apps/railwayMap/schema.ts deleted file mode 100644 index 28b5619f4..000000000 --- a/server/src/apps/railwayMap/schema.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * This file is auto-generated. DO NOT EDIT IT MANUALLY. - * If you want to add custom schemas, you will find a dedicated space at the end of this file. - * Generated for module: railwayMap - * Generated at: 2025-07-09T12:50:41.284Z - * Contains: railway_map__lines, railway_map__stations - */ -import { z } from "zod/v4"; - -const RailwayMapLineSchema = z.object({ - country: z.string(), - type: z.string(), - code: z.string(), - name: z.string(), - color: z.string(), - ways: z.any(), - map_paths: z.any(), -}); - -const RailwayMapStationSchema = z.object({ - name: z.string(), - desc: z.string(), - lines: z.array(z.string()), - codes: z.any(), - coords: z.any(), - map_data: z.any(), - type: z.string(), - distances: z.any(), - map_image: z.string(), -}); - -type IRailwayMapLine = z.infer; -type IRailwayMapStation = z.infer; - -export { RailwayMapLineSchema, RailwayMapStationSchema }; - -export type { IRailwayMapLine, IRailwayMapStation }; - -// -------------------- CUSTOM SCHEMAS -------------------- - -// Add your custom schemas here. They will not be overwritten by this script. diff --git a/server/src/apps/railwayMap/services/railwayMap.service.ts b/server/src/apps/railwayMap/services/railwayMap.service.ts index 540f4cfd5..2d6b0ce1f 100644 --- a/server/src/apps/railwayMap/services/railwayMap.service.ts +++ b/server/src/apps/railwayMap/services/railwayMap.service.ts @@ -1,29 +1,33 @@ import ClientError from "@functions/ClientError"; import PocketBase from "pocketbase"; +import { RailwayMapSchemas } from "shared"; import { WithPB } from "@typescript/pocketbase_interfaces"; -import { IRailwayMapLine, IRailwayMapStation } from "../schema"; import dijkstraWithTransfers from "../utils/pathFinding"; -export const getLines = (pb: PocketBase): Promise[]> => - pb.collection("railway_map__lines").getFullList>(); +export const getLines = ( + pb: PocketBase, +): Promise[]> => + pb + .collection("railway_map__lines") + .getFullList>(); export const getStations = ( pb: PocketBase, -): Promise[]> => +): Promise[]> => pb .collection("railway_map__stations") - .getFullList>(); + .getFullList>(); export const getShortestPath = async ( pb: PocketBase, start: string, end: string, -): Promise[]> => { +): Promise[]> => { const allStations = await pb .collection("railway_map__stations") - .getFullList>(); + .getFullList>(); if ( ![start, end].every((station) => allStations.some((s) => s.id === station)) diff --git a/server/src/apps/todoList/controllers/entries.controller.ts b/server/src/apps/todoList/controllers/entries.controller.ts index 1b73b5e63..b456d7d04 100644 --- a/server/src/apps/todoList/controllers/entries.controller.ts +++ b/server/src/apps/todoList/controllers/entries.controller.ts @@ -3,11 +3,11 @@ import { forgeController, } from "@functions/forgeController"; import express from "express"; +import { TodoListSchemas } from "shared"; import { z } from "zod/v4"; import { WithPBSchema } from "@typescript/pocketbase_interfaces"; -import { TodoListEntrySchema, TodoListStatusCounterSchema } from "../schema"; import * as entriesService from "../services/entries.service"; const todoListEntriesRouter = express.Router(); @@ -16,7 +16,7 @@ const getStatusCounter = forgeController .route("GET /utils/status-counter") .description("Get status counter for todo entries") .schema({ - response: TodoListStatusCounterSchema, + response: TodoListSchemas.TodoListStatusCounterSchema, }) .callback(async ({ pb }) => await entriesService.getStatusCounter(pb)); @@ -27,7 +27,7 @@ const getEntryById = forgeController params: z.object({ id: z.string(), }), - response: WithPBSchema(TodoListEntrySchema), + response: WithPBSchema(TodoListSchemas.EntrySchema), }) .existenceCheck("params", { id: "todo_list__entries", @@ -47,7 +47,7 @@ const getAllEntries = forgeController tag: z.string().optional(), query: z.string().optional(), }), - response: z.array(WithPBSchema(TodoListEntrySchema)), + response: z.array(WithPBSchema(TodoListSchemas.EntrySchema)), }) .existenceCheck("query", { tag: "[todo_list_tags]", @@ -63,11 +63,11 @@ const createEntry = forgeController .route("POST /") .description("Create a new todo entry") .schema({ - body: TodoListEntrySchema.omit({ + body: TodoListSchemas.EntrySchema.omit({ completed_at: true, done: true, }), - response: WithPBSchema(TodoListEntrySchema), + response: WithPBSchema(TodoListSchemas.EntrySchema), }) .existenceCheck("body", { list: "[todo_list_lists]", @@ -84,11 +84,11 @@ const updateEntry = forgeController params: z.object({ id: z.string(), }), - body: TodoListEntrySchema.omit({ + body: TodoListSchemas.EntrySchema.omit({ completed_at: true, done: true, }), - response: WithPBSchema(TodoListEntrySchema), + response: WithPBSchema(TodoListSchemas.EntrySchema), }) .existenceCheck("params", { id: "todo_list__entries", @@ -127,7 +127,7 @@ const toggleEntry = forgeController params: z.object({ id: z.string(), }), - response: WithPBSchema(TodoListEntrySchema), + response: WithPBSchema(TodoListSchemas.EntrySchema), }) .existenceCheck("params", { id: "todo_list__entries", diff --git a/server/src/apps/todoList/controllers/lists.controller.ts b/server/src/apps/todoList/controllers/lists.controller.ts index 19eed095f..6694ee0e7 100644 --- a/server/src/apps/todoList/controllers/lists.controller.ts +++ b/server/src/apps/todoList/controllers/lists.controller.ts @@ -3,11 +3,11 @@ import { forgeController, } from "@functions/forgeController"; import express from "express"; +import { TodoListSchemas } from "shared"; import { z } from "zod/v4"; import { WithPBSchema } from "@typescript/pocketbase_interfaces"; -import { TodoListListSchema } from "../schema"; import * as listsService from "../services/lists.service"; const todoListListsRouter = express.Router(); @@ -17,7 +17,7 @@ const getAllLists = forgeController .description("Get all todo lists") .schema({ response: z.array( - WithPBSchema(TodoListListSchema.extend({ amount: z.number() })), + WithPBSchema(TodoListSchemas.ListSchema.extend({ amount: z.number() })), ), }) .callback(({ pb }) => listsService.getAllLists(pb)); @@ -26,8 +26,14 @@ const createList = forgeController .route("POST /") .description("Create a new todo list") .schema({ - body: TodoListListSchema.pick({ name: true, icon: true, color: true }), - response: WithPBSchema(TodoListListSchema.extend({ amount: z.number() })), + body: TodoListSchemas.ListSchema.pick({ + name: true, + icon: true, + color: true, + }), + response: WithPBSchema( + TodoListSchemas.ListSchema.extend({ amount: z.number() }), + ), }) .statusCode(201) .callback(({ pb, body }) => listsService.createList(pb, body)); @@ -39,8 +45,14 @@ const updateList = forgeController params: z.object({ id: z.string(), }), - body: TodoListListSchema.pick({ name: true, icon: true, color: true }), - response: WithPBSchema(TodoListListSchema.extend({ amount: z.number() })), + body: TodoListSchemas.ListSchema.pick({ + name: true, + icon: true, + color: true, + }), + response: WithPBSchema( + TodoListSchemas.ListSchema.extend({ amount: z.number() }), + ), }) .existenceCheck("params", { id: "todo_list__lists", diff --git a/server/src/apps/todoList/controllers/priorities.controller.ts b/server/src/apps/todoList/controllers/priorities.controller.ts index b44d5ab0e..76c557373 100644 --- a/server/src/apps/todoList/controllers/priorities.controller.ts +++ b/server/src/apps/todoList/controllers/priorities.controller.ts @@ -3,11 +3,11 @@ import { forgeController, } from "@functions/forgeController"; import express from "express"; +import { TodoListSchemas } from "shared"; import { z } from "zod/v4"; import { WithPBSchema } from "@typescript/pocketbase_interfaces"; -import { TodoListPrioritySchema } from "../schema"; import * as prioritiesService from "../services/priorities.service"; const todoListPrioritiesRouter = express.Router(); @@ -17,7 +17,9 @@ const getAllPriorities = forgeController .description("Get all todo priorities") .schema({ response: z.array( - WithPBSchema(TodoListPrioritySchema.extend({ amount: z.number() })), + WithPBSchema( + TodoListSchemas.PrioritySchema.extend({ amount: z.number() }), + ), ), }) .callback(({ pb }) => prioritiesService.getAllPriorities(pb)); @@ -26,9 +28,9 @@ const createPriority = forgeController .route("POST /") .description("Create a new todo priority") .schema({ - body: TodoListPrioritySchema, + body: TodoListSchemas.PrioritySchema, response: WithPBSchema( - TodoListPrioritySchema.extend({ amount: z.number() }), + TodoListSchemas.PrioritySchema.extend({ amount: z.number() }), ), }) .statusCode(201) @@ -41,9 +43,9 @@ const updatePriority = forgeController params: z.object({ id: z.string(), }), - body: TodoListPrioritySchema.pick({ name: true, color: true }), + body: TodoListSchemas.PrioritySchema.pick({ name: true, color: true }), response: WithPBSchema( - TodoListPrioritySchema.extend({ amount: z.number() }), + TodoListSchemas.PrioritySchema.extend({ amount: z.number() }), ), }) .existenceCheck("params", { diff --git a/server/src/apps/todoList/controllers/tags.controller.ts b/server/src/apps/todoList/controllers/tags.controller.ts index dc3bcdb9a..ec6635804 100644 --- a/server/src/apps/todoList/controllers/tags.controller.ts +++ b/server/src/apps/todoList/controllers/tags.controller.ts @@ -3,11 +3,11 @@ import { forgeController, } from "@functions/forgeController"; import express from "express"; +import { TodoListSchemas } from "shared"; import { z } from "zod/v4"; import { WithPBSchema } from "@typescript/pocketbase_interfaces"; -import { TodoListTagSchema } from "../schema"; import * as tagsService from "../services/tags.service"; const todoListTagsRouter = express.Router(); @@ -17,7 +17,7 @@ const getAllTags = forgeController .description("Get all todo tags") .schema({ response: z.array( - WithPBSchema(TodoListTagSchema.extend({ amount: z.number() })), + WithPBSchema(TodoListSchemas.TagSchema.extend({ amount: z.number() })), ), }) .callback(({ pb }) => tagsService.getAllTags(pb)); @@ -26,8 +26,10 @@ const createTag = forgeController .route("POST /") .description("Create a new todo tag") .schema({ - body: TodoListTagSchema, - response: WithPBSchema(TodoListTagSchema.extend({ amount: z.number() })), + body: TodoListSchemas.TagSchema, + response: WithPBSchema( + TodoListSchemas.TagSchema.extend({ amount: z.number() }), + ), }) .statusCode(201) .callback(({ pb, body }) => tagsService.createTag(pb, body)); @@ -39,8 +41,10 @@ const updateTag = forgeController params: z.object({ id: z.string(), }), - body: TodoListTagSchema, - response: WithPBSchema(TodoListTagSchema.extend({ amount: z.number() })), + body: TodoListSchemas.TagSchema, + response: WithPBSchema( + TodoListSchemas.TagSchema.extend({ amount: z.number() }), + ), }) .existenceCheck("params", { id: "todo_list__tags", diff --git a/server/src/apps/todoList/schema.ts b/server/src/apps/todoList/schema.ts deleted file mode 100644 index d600b6053..000000000 --- a/server/src/apps/todoList/schema.ts +++ /dev/null @@ -1,100 +0,0 @@ -/** - * This file is auto-generated. DO NOT EDIT IT MANUALLY. - * If you want to add custom schemas, you will find a dedicated space at the end of this file. - * Generated for module: todoList - * Generated at: 2025-07-09T12:50:41.283Z - * Contains: todo_list__lists, todo_list__tags, todo_list__entries, todo_list__priorities, todo_list__lists_aggregated, todo_list__tags_aggregated, todo_list__priorities_aggregated - */ -import { z } from "zod/v4"; - -const TodoListListSchema = z.object({ - name: z.string(), - icon: z.string(), - color: z.string(), -}); - -const TodoListTagSchema = z.object({ - name: z.string(), -}); - -const TodoListEntrySchema = z.object({ - summary: z.string(), - notes: z.string(), - due_date: z.string(), - due_date_has_time: z.boolean(), - list: z.string(), - tags: z.array(z.string()), - priority: z.string(), - done: z.boolean(), - completed_at: z.string(), -}); - -const TodoListPrioritySchema = z.object({ - name: z.string(), - color: z.string(), - amount: z.number(), -}); - -const TodoListListAggregatedSchema = z.object({ - name: z.string(), - color: z.string(), - icon: z.string(), - amount: z.number(), -}); - -const TodoListTagAggregatedSchema = z.object({ - name: z.string(), - amount: z.number(), -}); - -const TodoListPriorityAggregatedSchema = z.object({ - name: z.string(), - color: z.string(), - amount: z.number(), -}); - -type ITodoListList = z.infer; -type ITodoListTag = z.infer; -type ITodoListEntry = z.infer; -type ITodoListPriority = z.infer; -type ITodoListListAggregated = z.infer; -type ITodoListTagAggregated = z.infer; -type ITodoListPriorityAggregated = z.infer< - typeof TodoListPriorityAggregatedSchema ->; - -export { - TodoListListSchema, - TodoListTagSchema, - TodoListEntrySchema, - TodoListPrioritySchema, - TodoListListAggregatedSchema, - TodoListTagAggregatedSchema, - TodoListPriorityAggregatedSchema, -}; - -export type { - ITodoListList, - ITodoListTag, - ITodoListEntry, - ITodoListPriority, - ITodoListListAggregated, - ITodoListTagAggregated, - ITodoListPriorityAggregated, -}; - -// -------------------- CUSTOM SCHEMAS -------------------- - -const TodoListStatusCounterSchema = z.object({ - all: z.number(), - today: z.number(), - scheduled: z.number(), - overdue: z.number(), - completed: z.number(), -}); - -type ITodoListStatusCounter = z.infer; - -export { TodoListStatusCounterSchema }; - -export type { ITodoListStatusCounter }; diff --git a/server/src/apps/todoList/services/entries.service.ts b/server/src/apps/todoList/services/entries.service.ts index 5f9656cde..ce532cd98 100644 --- a/server/src/apps/todoList/services/entries.service.ts +++ b/server/src/apps/todoList/services/entries.service.ts @@ -1,15 +1,16 @@ import moment from "moment"; import PocketBase from "pocketbase"; +import { TodoListSchemas } from "shared"; import { WithPB } from "@typescript/pocketbase_interfaces"; -import { ITodoListEntry, ITodoListStatusCounter } from "../schema"; - export const getEntryById = ( pb: PocketBase, id: string, -): Promise> => - pb.collection("todo_list__entries").getOne>(id); +): Promise> => + pb + .collection("todo_list__entries") + .getOne>(id); export const getAllEntries = async ( pb: PocketBase, @@ -17,7 +18,7 @@ export const getAllEntries = async ( tag?: string, list?: string, priority?: string, -): Promise[]> => { +): Promise[]> => { const filters = { all: "done = false", today: `done = false && due_date >= "${moment() @@ -45,7 +46,7 @@ export const getAllEntries = async ( return await pb .collection("todo_list__entries") - .getFullList>({ + .getFullList>({ filter: finalFilter, sort: "-created", }); @@ -53,7 +54,7 @@ export const getAllEntries = async ( export const getStatusCounter = async ( pb: PocketBase, -): Promise => { +): Promise => { const filters = { all: "done = false", today: `done = false && due_date >= "${moment() @@ -73,7 +74,7 @@ export const getStatusCounter = async ( completed: "done = true", }; - const counters: ITodoListStatusCounter = { + const counters: TodoListSchemas.ITodoListStatusCounter = { all: 0, today: 0, scheduled: 0, @@ -96,10 +97,13 @@ export const getStatusCounter = async ( export const createEntry = async ( pb: PocketBase, - data: Omit & { + data: Omit< + TodoListSchemas.IEntry, + "completed_at" | "done" | "due_date_has_time" + > & { due_date_has_time?: boolean; }, -): Promise> => { +): Promise> => { if (data.due_date && !data.due_date_has_time) { data.due_date = moment(data.due_date).endOf("day").toISOString(); } @@ -108,16 +112,19 @@ export const createEntry = async ( return await pb .collection("todo_list__entries") - .create>(data); + .create>(data); }; export const updateEntry = async ( pb: PocketBase, id: string, - data: Omit & { + data: Omit< + TodoListSchemas.IEntry, + "completed_at" | "done" | "due_date_has_time" + > & { due_date_has_time?: boolean; }, -): Promise> => { +): Promise> => { if (data.due_date && !data.due_date_has_time) { data.due_date = moment(data.due_date).endOf("day").toISOString(); } @@ -137,14 +144,14 @@ export const deleteEntry = async ( export const toggleEntry = async ( pb: PocketBase, id: string, -): Promise> => { +): Promise> => { const entry = await pb .collection("todo_list__entries") - .getOne>(id); + .getOne>(id); return await pb .collection("todo_list__entries") - .update>(id, { + .update>(id, { done: !entry.done, completed_at: entry.done ? null diff --git a/server/src/apps/todoList/services/lists.service.ts b/server/src/apps/todoList/services/lists.service.ts index b4f7551de..b5aa13930 100644 --- a/server/src/apps/todoList/services/lists.service.ts +++ b/server/src/apps/todoList/services/lists.service.ts @@ -1,40 +1,39 @@ import PocketBase from "pocketbase"; +import { TodoListSchemas } from "shared"; import { WithPB } from "@typescript/pocketbase_interfaces"; -import { ITodoListList } from "../schema"; - export const getAllLists = ( pb: PocketBase, ): Promise< WithPB< - ITodoListList & { + TodoListSchemas.IList & { amount: number; } >[] > => pb.collection("todo_list__lists_aggregated").getFullList< - WithPB & { + WithPB & { amount: number; } >(); export const createList = async ( pb: PocketBase, - data: ITodoListList, + data: TodoListSchemas.IList, ): Promise< WithPB< - ITodoListList & { + TodoListSchemas.IList & { amount: number; } > > => { const created = await pb .collection("todo_list__lists") - .create>(data); + .create>(data); return pb.collection("todo_list__lists_aggregated").getOne< - WithPB & { + WithPB & { amount: number; } >(created.id); @@ -43,21 +42,21 @@ export const createList = async ( export const updateList = async ( pb: PocketBase, id: string, - data: ITodoListList, + data: TodoListSchemas.IList, ): Promise< WithPB< - ITodoListList & { + TodoListSchemas.IList & { amount: number; } > > => { const updated = await pb .collection("todo_list__lists") - .update>(id, data); + .update>(id, data); return pb.collection("todo_list__lists_aggregated").getOne< WithPB< - ITodoListList & { + TodoListSchemas.IList & { amount: number; } > diff --git a/server/src/apps/todoList/services/priorities.service.ts b/server/src/apps/todoList/services/priorities.service.ts index 153d1d64a..add17fdd3 100644 --- a/server/src/apps/todoList/services/priorities.service.ts +++ b/server/src/apps/todoList/services/priorities.service.ts @@ -1,21 +1,20 @@ import PocketBase from "pocketbase"; +import { TodoListSchemas } from "shared"; import { WithPB } from "@typescript/pocketbase_interfaces"; -import { ITodoListPriority } from "../schema"; - export const getAllPriorities = ( pb: PocketBase, ): Promise< WithPB< - ITodoListPriority & { + TodoListSchemas.IPriority & { amount: number; } >[] > => pb.collection("todo_list__priorities_aggregated").getFullList< WithPB< - ITodoListPriority & { + TodoListSchemas.IPriority & { amount: number; } > @@ -23,41 +22,41 @@ export const getAllPriorities = ( export const createPriority = async ( pb: PocketBase, - data: Omit, + data: Omit, ): Promise< WithPB< - ITodoListPriority & { + TodoListSchemas.IPriority & { amount: number; } > > => { const created = await pb .collection("todo_list__priorities") - .create>(data); + .create>(data); return pb .collection("todo_list__priorities_aggregated") - .getOne>(created.id); + .getOne>(created.id); }; export const updatePriority = async ( pb: PocketBase, id: string, - data: Omit, + data: Omit, ): Promise< WithPB< - ITodoListPriority & { + TodoListSchemas.IPriority & { amount: number; } > > => { const updated = await pb .collection("todo_list__priorities") - .update>(id, data); + .update>(id, data); return pb .collection("todo_list__priorities_aggregated") - .getOne>(updated.id); + .getOne>(updated.id); }; export const deletePriority = async ( diff --git a/server/src/apps/todoList/services/tags.service.ts b/server/src/apps/todoList/services/tags.service.ts index f6fdf894a..d37c873ca 100644 --- a/server/src/apps/todoList/services/tags.service.ts +++ b/server/src/apps/todoList/services/tags.service.ts @@ -1,21 +1,20 @@ import PocketBase from "pocketbase"; +import { TodoListSchemas } from "shared"; import { WithPB } from "@typescript/pocketbase_interfaces"; -import { ITodoListTag } from "../schema"; - export const getAllTags = ( pb: PocketBase, ): Promise< WithPB< - ITodoListTag & { + TodoListSchemas.ITag & { amount: number; } >[] > => pb.collection("todo_list__tags_aggregated").getFullList< WithPB< - ITodoListTag & { + TodoListSchemas.ITag & { amount: number; } > @@ -23,41 +22,41 @@ export const getAllTags = ( export const createTag = async ( pb: PocketBase, - data: ITodoListTag, + data: TodoListSchemas.ITag, ): Promise< WithPB< - ITodoListTag & { + TodoListSchemas.ITag & { amount: number; } > > => { const created = await pb .collection("todo_list__tags") - .create>(data); + .create>(data); return pb .collection("todo_list__tags_aggregated") - .getOne>(created.id); + .getOne>(created.id); }; export const updateTag = async ( pb: PocketBase, id: string, - data: ITodoListTag, + data: TodoListSchemas.ITag, ): Promise< WithPB< - ITodoListTag & { + TodoListSchemas.ITag & { amount: number; } > > => { const updated = await pb .collection("todo_list__tags") - .update>(id, data); + .update>(id, data); return pb .collection("todo_list__tags_aggregated") - .getOne>(updated.id); + .getOne>(updated.id); }; export const deleteTag = async (pb: PocketBase, id: string): Promise => { diff --git a/server/src/apps/virtualWardrobe/controllers/entries.controller.ts b/server/src/apps/virtualWardrobe/controllers/entries.controller.ts index d7243e831..e592bcd33 100644 --- a/server/src/apps/virtualWardrobe/controllers/entries.controller.ts +++ b/server/src/apps/virtualWardrobe/controllers/entries.controller.ts @@ -4,16 +4,13 @@ import { } from "@functions/forgeController"; import express from "express"; import fs from "fs"; +import { VirtualWardrobeSchemas } from "shared"; import { z } from "zod/v4"; import { WithPBSchema } from "@typescript/pocketbase_interfaces"; import { fieldsUploadMiddleware } from "@middlewares/uploadMiddleware"; -import { - VirtualWardrobeEntrySchema, - VirtualWardrobeSidebarDataSchema, -} from "../schema"; import * as entriesService from "../services/entries.service"; import * as visionService from "../services/vision.service"; @@ -23,7 +20,7 @@ const getSidebarData = forgeController .route("GET /sidebar-data") .description("Get sidebar data for virtual wardrobe") .schema({ - response: VirtualWardrobeSidebarDataSchema, + response: VirtualWardrobeSchemas.VirtualWardrobeSidebarDataSchema, }) .callback(async ({ pb }) => await entriesService.getSidebarData(pb)); @@ -43,7 +40,7 @@ const getEntries = forgeController .transform((val) => val === "true"), q: z.string().optional(), }), - response: z.array(WithPBSchema(VirtualWardrobeEntrySchema)), + response: z.array(WithPBSchema(VirtualWardrobeSchemas.EntrySchema)), }) .callback( async ({ pb, query }) => await entriesService.getEntries(pb, query), @@ -63,7 +60,7 @@ const createEntry = forgeController price: z.string().transform((val) => parseFloat(val)), notes: z.string(), }), - response: WithPBSchema(VirtualWardrobeEntrySchema), + response: WithPBSchema(VirtualWardrobeSchemas.EntrySchema), }) .middlewares( fieldsUploadMiddleware.bind({ @@ -120,7 +117,7 @@ const updateEntry = forgeController price: z.number().optional(), notes: z.string().optional(), }), - response: WithPBSchema(VirtualWardrobeEntrySchema), + response: WithPBSchema(VirtualWardrobeSchemas.EntrySchema), }) .existenceCheck("params", { id: "virtual_wardrobe__entries", @@ -154,7 +151,7 @@ const toggleFavourite = forgeController params: z.object({ id: z.string(), }), - response: WithPBSchema(VirtualWardrobeEntrySchema), + response: WithPBSchema(VirtualWardrobeSchemas.EntrySchema), }) .existenceCheck("params", { id: "virtual_wardrobe__entries", diff --git a/server/src/apps/virtualWardrobe/controllers/session.controller.ts b/server/src/apps/virtualWardrobe/controllers/session.controller.ts index f9991778d..79d68f15e 100644 --- a/server/src/apps/virtualWardrobe/controllers/session.controller.ts +++ b/server/src/apps/virtualWardrobe/controllers/session.controller.ts @@ -3,11 +3,11 @@ import { forgeController, } from "@functions/forgeController"; import express from "express"; +import { VirtualWardrobeSchemas } from "shared"; import { z } from "zod/v4"; import { WithPBSchema } from "@typescript/pocketbase_interfaces"; -import { VirtualWardrobeEntrySchema } from "../schema"; import * as sessionService from "../services/session.service"; const virtualWardrobeSessionRouter = express.Router(); @@ -16,7 +16,7 @@ const getCart = forgeController .route("GET /cart") .description("Get session cart items") .schema({ - response: z.array(WithPBSchema(VirtualWardrobeEntrySchema)), + response: z.array(WithPBSchema(VirtualWardrobeSchemas.EntrySchema)), }) .callback(async () => sessionService.getSessionCart()); diff --git a/server/src/apps/virtualWardrobe/schema.ts b/server/src/apps/virtualWardrobe/schema.ts deleted file mode 100644 index 0f2a59832..000000000 --- a/server/src/apps/virtualWardrobe/schema.ts +++ /dev/null @@ -1,57 +0,0 @@ -/** - * This file is auto-generated. DO NOT EDIT IT MANUALLY. - * If you want to add custom schemas, you will find a dedicated space at the end of this file. - * Generated for module: virtualWardrobe - * Generated at: 2025-07-09T12:50:41.279Z - * Contains: virtual_wardrobe__entries, virtual_wardrobe__histories - */ -import { z } from "zod/v4"; - -const VirtualWardrobeEntrySchema = z.object({ - name: z.string(), - category: z.string(), - subcategory: z.string(), - colors: z.any(), - size: z.string(), - brand: z.string(), - front_image: z.string(), - back_image: z.string(), - last_worn: z.string(), - times_worn: z.number(), - purchase_date: z.string(), - price: z.number(), - notes: z.string(), - is_favourite: z.boolean(), -}); - -const VirtualWardrobeHistorySchema = z.object({ - entries: z.array(z.string()), - notes: z.string(), -}); - -type IVirtualWardrobeEntry = z.infer; -type IVirtualWardrobeHistory = z.infer; - -export { VirtualWardrobeEntrySchema, VirtualWardrobeHistorySchema }; - -export type { IVirtualWardrobeEntry, IVirtualWardrobeHistory }; - -// -------------------- CUSTOM SCHEMAS -------------------- - -const VirtualWardrobeSidebarDataSchema = z.object({ - total: z.number(), - favourites: z.number(), - categories: z.record(z.string(), z.number()), - subcategories: z.record(z.string(), z.number()), - brands: z.record(z.string(), z.number()), - sizes: z.record(z.string(), z.number()), - colors: z.record(z.string(), z.number()), -}); - -type IVirtualWardrobeSidebarData = z.infer< - typeof VirtualWardrobeSidebarDataSchema ->; - -export { VirtualWardrobeSidebarDataSchema }; - -export type { IVirtualWardrobeSidebarData }; diff --git a/server/src/apps/virtualWardrobe/services/entries.service.ts b/server/src/apps/virtualWardrobe/services/entries.service.ts index 775d0df37..0904852b0 100644 --- a/server/src/apps/virtualWardrobe/services/entries.service.ts +++ b/server/src/apps/virtualWardrobe/services/entries.service.ts @@ -1,15 +1,14 @@ import PocketBase from "pocketbase"; +import { VirtualWardrobeSchemas } from "shared"; import { WithPB } from "@typescript/pocketbase_interfaces"; -import { IVirtualWardrobeEntry, IVirtualWardrobeSidebarData } from "../schema"; - export const getSidebarData = async ( pb: PocketBase, -): Promise => { +): Promise => { const allEntries = await pb .collection("virtual_wardrobe__entries") - .getFullList(); + .getFullList>(); const categories = allEntries.reduce( (acc, curr) => { @@ -90,7 +89,7 @@ export const getEntries = async ( favourite?: boolean; q?: string; }, -): Promise[]> => { +): Promise[]> => { const filterArray = [ filters.category && `category = '${filters.category}'`, filters.subcategory && `subcategory = '${filters.subcategory}'`, @@ -104,7 +103,7 @@ export const getEntries = async ( const entries = await pb .collection("virtual_wardrobe__entries") - .getFullList>({ + .getFullList>({ filter: filterArray.join(" && "), sort: "-created", }); @@ -130,10 +129,10 @@ export const createEntry = async ( front_image: File; back_image: File; }, -): Promise> => { +): Promise> => { const newEntry = await pb .collection("virtual_wardrobe__entries") - .create>(data); + .create>(data); return { ...newEntry, @@ -149,11 +148,11 @@ export const createEntry = async ( export const updateEntry = async ( pb: PocketBase, id: string, - data: Partial, -): Promise> => { + data: Partial, +): Promise> => { const updatedEntry = await pb .collection("virtual_wardrobe__entries") - .update>(id, data); + .update>(id, data); return { ...updatedEntry, @@ -176,10 +175,10 @@ export const deleteEntry = async ( export const toggleFavourite = async ( pb: PocketBase, id: string, -): Promise> => { +): Promise> => { const entry = await pb .collection("virtual_wardrobe__entries") - .getOne>(id); + .getOne>(id); return await updateEntry(pb, id, { is_favourite: !entry.is_favourite, diff --git a/server/src/apps/virtualWardrobe/services/session.service.ts b/server/src/apps/virtualWardrobe/services/session.service.ts index 1d9c93984..7daf5f379 100644 --- a/server/src/apps/virtualWardrobe/services/session.service.ts +++ b/server/src/apps/virtualWardrobe/services/session.service.ts @@ -1,12 +1,11 @@ import PocketBase from "pocketbase"; +import { VirtualWardrobeSchemas } from "shared"; import { WithPB } from "@typescript/pocketbase_interfaces"; -import { IVirtualWardrobeEntry } from "../schema"; +const sessionCart = new Set>(); -const sessionCart = new Set>(); - -export const getSessionCart = (): WithPB[] => { +export const getSessionCart = (): WithPB[] => { return Array.from(sessionCart); }; @@ -20,7 +19,7 @@ export const addToCart = async ( const item = await pb .collection("virtual_wardrobe__entries") - .getOne>(entryId); + .getOne>(entryId); const processedItem = { ...item, diff --git a/server/src/apps/wallet/controllers/assets.controller.ts b/server/src/apps/wallet/controllers/assets.controller.ts index cfac5f1ba..13c78c7bc 100644 --- a/server/src/apps/wallet/controllers/assets.controller.ts +++ b/server/src/apps/wallet/controllers/assets.controller.ts @@ -3,11 +3,11 @@ import { forgeController, } from "@functions/forgeController"; import express from "express"; +import { WalletSchemas } from "shared"; import { z } from "zod/v4"; import { WithPBSchema } from "@typescript/pocketbase_interfaces"; -import { WalletAssetSchema } from "../schema"; import * as AssetsService from "../services/assets.service"; const walletAssetsRouter = express.Router(); @@ -16,7 +16,7 @@ const getAllAssets = forgeController .route("GET /") .description("Get all wallet assets") .schema({ - response: z.array(WithPBSchema(WalletAssetSchema)), + response: z.array(WithPBSchema(WalletSchemas.AssetAggregatedSchema)), }) .callback(async ({ pb }) => await AssetsService.getAllAssets(pb)); @@ -24,7 +24,7 @@ const createAsset = forgeController .route("POST /") .description("Create a new wallet asset") .schema({ - body: WalletAssetSchema.pick({ + body: WalletSchemas.AssetSchema.pick({ name: true, icon: true, starting_balance: true, @@ -34,7 +34,7 @@ const createAsset = forgeController return isNaN(balance) ? 0 : balance; }), }), - response: WithPBSchema(WalletAssetSchema), + response: WithPBSchema(WalletSchemas.AssetSchema), }) .statusCode(201) .callback(async ({ pb, body }) => await AssetsService.createAsset(pb, body)); @@ -63,7 +63,7 @@ const updateAsset = forgeController params: z.object({ id: z.string(), }), - body: WalletAssetSchema.pick({ + body: WalletSchemas.AssetSchema.pick({ name: true, icon: true, starting_balance: true, @@ -73,7 +73,7 @@ const updateAsset = forgeController return isNaN(balance) ? 0 : balance; }), }), - response: WithPBSchema(WalletAssetSchema), + response: WithPBSchema(WalletSchemas.AssetSchema), }) .existenceCheck("params", { id: "wallet__assets", diff --git a/server/src/apps/wallet/controllers/categories.controller.ts b/server/src/apps/wallet/controllers/categories.controller.ts index 687846281..68b245121 100644 --- a/server/src/apps/wallet/controllers/categories.controller.ts +++ b/server/src/apps/wallet/controllers/categories.controller.ts @@ -3,11 +3,11 @@ import { forgeController, } from "@functions/forgeController"; import express from "express"; +import { WalletSchemas } from "shared"; import { z } from "zod/v4"; import { WithPBSchema } from "@typescript/pocketbase_interfaces"; -import { WalletCategorySchema } from "../schema"; import * as CategoriesService from "../services/categories.service"; const walletCategoriesRouter = express.Router(); @@ -16,7 +16,7 @@ const getAllCategories = forgeController .route("GET /") .description("Get all wallet categories") .schema({ - response: z.array(WithPBSchema(WalletCategorySchema)), + response: z.array(WithPBSchema(WalletSchemas.CategoryAggregatedSchema)), }) .callback(async ({ pb }) => await CategoriesService.getAllCategories(pb)); @@ -24,8 +24,8 @@ const createCategory = forgeController .route("POST /") .description("Create a new wallet category") .schema({ - body: WalletCategorySchema, - response: WithPBSchema(WalletCategorySchema), + body: WalletSchemas.CategorySchema, + response: WithPBSchema(WalletSchemas.CategorySchema), }) .statusCode(201) .callback( @@ -39,8 +39,8 @@ const updateCategory = forgeController params: z.object({ id: z.string(), }), - body: WalletCategorySchema, - response: WithPBSchema(WalletCategorySchema), + body: WalletSchemas.CategorySchema, + response: WithPBSchema(WalletSchemas.CategorySchema), }) .existenceCheck("params", { id: "wallet__categories", diff --git a/server/src/apps/wallet/controllers/ledgers.controller.ts b/server/src/apps/wallet/controllers/ledgers.controller.ts index abff7d469..805028eb0 100644 --- a/server/src/apps/wallet/controllers/ledgers.controller.ts +++ b/server/src/apps/wallet/controllers/ledgers.controller.ts @@ -3,11 +3,11 @@ import { forgeController, } from "@functions/forgeController"; import express from "express"; +import { WalletSchemas } from "shared"; import { z } from "zod/v4"; import { WithPBSchema } from "@typescript/pocketbase_interfaces"; -import { WalletLedgerSchema } from "../schema"; import * as LedgersService from "../services/ledgers.service"; const walletLedgersRouter = express.Router(); @@ -16,7 +16,7 @@ const getAllLedgers = forgeController .route("GET /") .description("Get all wallet ledgers") .schema({ - response: z.array(WithPBSchema(WalletLedgerSchema)), + response: z.array(WithPBSchema(WalletSchemas.LedgerSchema)), }) .callback(async ({ pb }) => await LedgersService.getAllLedgers(pb)); @@ -24,8 +24,8 @@ const createLedger = forgeController .route("POST /") .description("Create a new wallet ledger") .schema({ - body: WalletLedgerSchema, - response: WithPBSchema(WalletLedgerSchema), + body: WalletSchemas.LedgerSchema, + response: WithPBSchema(WalletSchemas.LedgerSchema), }) .statusCode(201) .callback( @@ -39,8 +39,8 @@ const updateLedger = forgeController params: z.object({ id: z.string(), }), - body: WalletLedgerSchema, - response: WithPBSchema(WalletLedgerSchema), + body: WalletSchemas.LedgerSchema, + response: WithPBSchema(WalletSchemas.LedgerSchema), }) .existenceCheck("params", { id: "wallet__ledgers", diff --git a/server/src/apps/wallet/controllers/transactions.controller.ts b/server/src/apps/wallet/controllers/transactions.controller.ts index a7d274aa6..aa27db97c 100644 --- a/server/src/apps/wallet/controllers/transactions.controller.ts +++ b/server/src/apps/wallet/controllers/transactions.controller.ts @@ -3,16 +3,13 @@ import { forgeController, } from "@functions/forgeController"; import express from "express"; +import { WalletSchemas } from "shared"; import { z } from "zod/v4"; import { WithPBSchema } from "@typescript/pocketbase_interfaces"; import { singleUploadMiddleware } from "@middlewares/uploadMiddleware"; -import { - WalletReceiptScanResultSchema, - WalletTransactionSchema, -} from "../schema"; import * as TransactionsService from "../services/transactions.service"; const walletTransactionsRouter = express.Router(); @@ -21,7 +18,7 @@ const getAllTransactions = forgeController .route("GET /") .description("Get all wallet transactions") .schema({ - response: z.array(WithPBSchema(WalletTransactionSchema)), + response: z.array(WithPBSchema(WalletSchemas.TransactionSchema)), }) .callback(async ({ pb }) => await TransactionsService.getAllTransactions(pb)); @@ -59,7 +56,7 @@ const createTransaction = forgeController fromAsset: z.string().optional(), toAsset: z.string().optional(), }), - response: z.array(WithPBSchema(WalletTransactionSchema)), + response: z.array(WithPBSchema(WalletSchemas.TransactionSchema)), }) .middlewares(singleUploadMiddleware) .existenceCheck("body", { @@ -115,7 +112,7 @@ const updateTransaction = forgeController .default("false") .transform((val) => val === "true"), }), - response: WithPBSchema(WalletTransactionSchema), + response: WithPBSchema(WalletSchemas.TransactionSchema), }) .middlewares(singleUploadMiddleware) .existenceCheck("params", { @@ -158,7 +155,7 @@ const scanReceipt = forgeController .route("POST /scan-receipt") .description("Scan receipt to extract transaction data") .schema({ - response: WalletReceiptScanResultSchema, + response: WalletSchemas.WalletReceiptScanResultSchema, }) .middlewares(singleUploadMiddleware) .callback(async ({ pb, req }) => { diff --git a/server/src/apps/wallet/controllers/utils.controller.ts b/server/src/apps/wallet/controllers/utils.controller.ts index 9fe594729..77428a175 100644 --- a/server/src/apps/wallet/controllers/utils.controller.ts +++ b/server/src/apps/wallet/controllers/utils.controller.ts @@ -3,9 +3,9 @@ import { forgeController, } from "@functions/forgeController"; import express from "express"; +import { WalletSchemas } from "shared"; import { z } from "zod/v4"; -import { WalletIncomeExpensesSummarySchema } from "../schema"; import * as UtilsService from "../services/utils.service"; const walletUtilsRouter = express.Router(); @@ -32,7 +32,7 @@ const getIncomeExpensesSummary = forgeController year: z.string(), month: z.string(), }), - response: WalletIncomeExpensesSummarySchema, + response: WalletSchemas.WalletIncomeExpensesSummarySchema, }) .callback( async ({ pb, query: { year, month } }) => diff --git a/server/src/apps/wallet/schema.ts b/server/src/apps/wallet/schema.ts deleted file mode 100644 index 2efbb2a33..000000000 --- a/server/src/apps/wallet/schema.ts +++ /dev/null @@ -1,127 +0,0 @@ -/** - * This file is auto-generated. DO NOT EDIT IT MANUALLY. - * If you want to add custom schemas, you will find a dedicated space at the end of this file. - * Generated for module: wallet - * Generated at: 2025-07-09T12:50:41.284Z - * Contains: wallet__assets, wallet__ledgers, wallet__categories, wallet__transactions, wallet__categories_aggregated, wallet__assets_aggregated, wallet__ledgers_aggregated, wallet__transaction_types_aggregated - */ -import { z } from "zod/v4"; - -const WalletAssetSchema = z.object({ - name: z.string(), - icon: z.string(), - starting_balance: z.number(), -}); - -const WalletLedgerSchema = z.object({ - name: z.string(), - icon: z.string(), - color: z.string(), -}); - -const WalletCategorySchema = z.object({ - name: z.string(), - icon: z.string(), - color: z.string(), - type: z.enum(["income", "expenses", ""]), -}); - -const WalletTransactionSchema = z.object({ - type: z.enum(["income", "expenses", "transfer", ""]), - side: z.enum(["debit", "credit", ""]), - particulars: z.string(), - amount: z.number(), - date: z.string(), - location_name: z.string(), - location_coords: z.object({ lat: z.number(), lon: z.number() }), - category: z.string(), - asset: z.string(), - ledger: z.string(), - receipt: z.string(), -}); - -const WalletCategoryAggregatedSchema = z.object({ - type: z.enum(["income", "expenses", ""]), - name: z.string(), - icon: z.string(), - color: z.string(), - amount: z.number(), -}); - -const WalletAssetAggregatedSchema = z.object({ - name: z.string(), - icon: z.string(), - starting_balance: z.number(), - amount: z.number(), - balance: z.any(), -}); - -const WalletLedgerAggregatedSchema = z.object({ - name: z.string(), - color: z.string(), - icon: z.string(), - amount: z.number(), -}); - -const WalletTransactionTypeAggregatedSchema = z.object({ - name: z.enum(["income", "expenses", "transfer", ""]), - amount: z.number(), - accumulate: z.any(), -}); - -type IWalletAsset = z.infer; -type IWalletLedger = z.infer; -type IWalletCategory = z.infer; -type IWalletTransaction = z.infer; -type IWalletCategoryAggregated = z.infer; -type IWalletAssetAggregated = z.infer; -type IWalletLedgerAggregated = z.infer; -type IWalletTransactionTypeAggregated = z.infer< - typeof WalletTransactionTypeAggregatedSchema ->; - -export { - WalletAssetSchema, - WalletLedgerSchema, - WalletCategorySchema, - WalletTransactionSchema, - WalletCategoryAggregatedSchema, - WalletAssetAggregatedSchema, - WalletLedgerAggregatedSchema, - WalletTransactionTypeAggregatedSchema, -}; - -export type { - IWalletAsset, - IWalletLedger, - IWalletCategory, - IWalletTransaction, - IWalletCategoryAggregated, - IWalletAssetAggregated, - IWalletLedgerAggregated, - IWalletTransactionTypeAggregated, -}; - -// -------------------- CUSTOM SCHEMAS -------------------- - -const WalletIncomeExpensesSummarySchema = z.object({ - totalIncome: z.number(), - totalExpenses: z.number(), - monthlyIncome: z.number(), - monthlyExpenses: z.number(), -}); - -const WalletReceiptScanResultSchema = z.object({ - date: z.string(), - particulars: z.string(), - type: z.string(), - amount: z.number(), -}); - -type IWalletIncomeExpensesSummary = z.infer< - typeof WalletIncomeExpensesSummarySchema ->; -type IWalletReceiptScanResult = z.infer; - -export { WalletIncomeExpensesSummarySchema, WalletReceiptScanResultSchema }; -export type { IWalletIncomeExpensesSummary, IWalletReceiptScanResult }; diff --git a/server/src/apps/wallet/services/assets.service.ts b/server/src/apps/wallet/services/assets.service.ts index e9fe5f776..4d25d0349 100644 --- a/server/src/apps/wallet/services/assets.service.ts +++ b/server/src/apps/wallet/services/assets.service.ts @@ -1,15 +1,18 @@ import Moment from "moment"; import MomentRange from "moment-range"; import PocketBase from "pocketbase"; +import { WalletSchemas } from "shared"; import { WithPB } from "@typescript/pocketbase_interfaces"; -import { IWalletAsset, IWalletTransaction } from "../schema"; - -export const getAllAssets = (pb: PocketBase): Promise[]> => - pb.collection("wallet__assets_aggregated").getFullList>({ - sort: "name", - }); +export const getAllAssets = ( + pb: PocketBase, +): Promise[]> => + pb + .collection("wallet__assets_aggregated") + .getFullList>({ + sort: "name", + }); // @ts-ignore const moment = MomentRange.extendMoment(Moment); @@ -20,13 +23,15 @@ export const getAssetAccumulatedBalance = async ( ): Promise> => { const asset = await pb .collection("wallet__assets") - .getOne, "starting_balance">>(assetId, { + .getOne, "starting_balance">>(assetId, { fields: "starting_balance", }); const allTransactions = await pb .collection("wallet__transactions") - .getFullList, "amount" | "date" | "side">>({ + .getFullList< + Pick, "amount" | "date" | "side"> + >({ filter: `asset = '${assetId}'`, sort: "-date", fields: "amount,date,side", @@ -63,16 +68,18 @@ export const getAssetAccumulatedBalance = async ( export const createAsset = ( pb: PocketBase, - data: Pick, -): Promise> => - pb.collection("wallet__assets").create>(data); + data: Pick, +): Promise> => + pb.collection("wallet__assets").create>(data); export const updateAsset = ( pb: PocketBase, id: string, - data: Pick, -): Promise> => - pb.collection("wallet__assets").update>(id, data); + data: Pick, +): Promise> => + pb + .collection("wallet__assets") + .update>(id, data); export const deleteAsset = async ( pb: PocketBase, diff --git a/server/src/apps/wallet/services/categories.service.ts b/server/src/apps/wallet/services/categories.service.ts index 4962f9846..383f8ce29 100644 --- a/server/src/apps/wallet/services/categories.service.ts +++ b/server/src/apps/wallet/services/categories.service.ts @@ -1,30 +1,33 @@ import PocketBase from "pocketbase"; +import { WalletSchemas } from "shared"; import { WithPB } from "@typescript/pocketbase_interfaces"; -import { IWalletCategory } from "../schema"; - export const getAllCategories = ( pb: PocketBase, -): Promise[]> => +): Promise[]> => pb .collection("wallet__categories_aggregated") - .getFullList>({ + .getFullList>({ sort: "name", }); export const createCategory = ( pb: PocketBase, - data: Omit, -): Promise> => - pb.collection("wallet__categories").create>(data); + data: Omit, +): Promise> => + pb + .collection("wallet__categories") + .create>(data); export const updateCategory = ( pb: PocketBase, id: string, - data: Omit, -): Promise> => - pb.collection("wallet__categories").update>(id, data); + data: Omit, +): Promise> => + pb + .collection("wallet__categories") + .update>(id, data); export const deleteCategory = async ( pb: PocketBase, diff --git a/server/src/apps/wallet/services/ledgers.service.ts b/server/src/apps/wallet/services/ledgers.service.ts index 97e1e1a6e..b6b42043c 100644 --- a/server/src/apps/wallet/services/ledgers.service.ts +++ b/server/src/apps/wallet/services/ledgers.service.ts @@ -1,30 +1,31 @@ import PocketBase from "pocketbase"; +import { WalletSchemas } from "shared"; import { WithPB } from "@typescript/pocketbase_interfaces"; -import { IWalletLedger } from "../schema"; - export const getAllLedgers = ( pb: PocketBase, -): Promise[]> => +): Promise[]> => pb .collection("wallet__ledgers_aggregated") - .getFullList>({ + .getFullList>({ sort: "name", }); export const createLedger = ( pb: PocketBase, - data: Omit, -): Promise> => - pb.collection("wallet__ledgers").create>(data); + data: Omit, +): Promise> => + pb.collection("wallet__ledgers").create>(data); export const updateLedger = ( pb: PocketBase, id: string, - data: Omit, -): Promise> => - pb.collection("wallet__ledgers").update>(id, data); + data: Omit, +): Promise> => + pb + .collection("wallet__ledgers") + .update>(id, data); export const deleteLedger = async ( pb: PocketBase, diff --git a/server/src/apps/wallet/services/transactions.service.ts b/server/src/apps/wallet/services/transactions.service.ts index f9766ab67..406ef7d39 100644 --- a/server/src/apps/wallet/services/transactions.service.ts +++ b/server/src/apps/wallet/services/transactions.service.ts @@ -3,12 +3,11 @@ import parseOCR from "@functions/parseOCR"; import fs from "fs"; import { fromPath } from "pdf2pic"; import Pocketbase from "pocketbase"; +import { WalletSchemas } from "shared"; import { z } from "zod"; import { WithPB } from "@typescript/pocketbase_interfaces"; -import { IWalletReceiptScanResult, IWalletTransaction } from "../schema"; - function convertPDFToImage(path: string): Promise { return new Promise(async (resolve, reject) => { try { @@ -53,16 +52,19 @@ function convertPDFToImage(path: string): Promise { export const getAllTransactions = ( pb: Pocketbase, -): Promise[]> => +): Promise[]> => pb .collection("wallet__transactions") - .getFullList>({ + .getFullList>({ sort: "-date,-created", }); export const createTransaction = async ( pb: Pocketbase, - data: Pick & { + data: Pick< + WalletSchemas.ITransaction, + "particulars" | "date" | "amount" | "type" + > & { asset?: string; ledger?: string; category?: string; @@ -75,7 +77,7 @@ export const createTransaction = async ( }; }, file: Express.Multer.File | undefined, -): Promise[]> => { +): Promise[]> => { async function processFile(): Promise< [Express.Multer.File | File | undefined, string | undefined] > { @@ -110,10 +112,10 @@ export const createTransaction = async ( } async function createIncomeOrExpensesTransactions(): Promise< - WithPB[] + WithPB[] > { const newData: Omit< - IWalletTransaction, + WalletSchemas.ITransaction, "receipt" | "fromAsset" | "toAsset" > & { receipt: File | string; @@ -133,19 +135,19 @@ export const createTransaction = async ( const transaction = await pb .collection("wallet__transactions") - .create>(newData); + .create>(newData); return [transaction]; } async function createTransferTransactions(): Promise< - WithPB[] + WithPB[] > { const _from = await pb.collection("wallet__assets").getOne(fromAsset!); const _to = await pb.collection("wallet__assets").getOne(toAsset!); const baseTransferData: Omit< - IWalletTransaction, + WalletSchemas.ITransaction, | "receipt" | "category" | "ledger" @@ -169,14 +171,14 @@ export const createTransaction = async ( baseTransferData.asset = toAsset!; const debit = await pb .collection("wallet__transactions") - .create>(baseTransferData); + .create>(baseTransferData); baseTransferData.particulars = `Transfer to ${_to.name}`; baseTransferData.side = "credit"; baseTransferData.asset = fromAsset!; const credit = await pb .collection("wallet__transactions") - .create>(baseTransferData); + .create>(baseTransferData); return [debit, credit]; } @@ -195,7 +197,7 @@ export const createTransaction = async ( let [targetFile, fileName] = await processFile(); - let created: WithPB[] = []; + let created: WithPB[] = []; switch (type) { case "income": @@ -217,7 +219,10 @@ export const createTransaction = async ( export const updateTransaction = async ( pb: Pocketbase, id: string, - data: Pick & { + data: Pick< + WalletSchemas.ITransaction, + "particulars" | "date" | "amount" | "type" + > & { asset?: string; ledger?: string; category?: string; @@ -229,7 +234,7 @@ export const updateTransaction = async ( }, file: Express.Multer.File | undefined, toRemoveReceipt: boolean, -): Promise> => { +): Promise> => { async function processFile(): Promise< [Express.Multer.File | File | undefined, string | undefined] > { @@ -281,7 +286,7 @@ export const updateTransaction = async ( const foundTransaction = await pb .collection("wallet__transactions") - .getOne>(id); + .getOne>(id); const [targetFile, fileName] = await processFile(); @@ -292,7 +297,7 @@ export const updateTransaction = async ( } const updatedData: Omit< - IWalletTransaction, + WalletSchemas.ITransaction, "receipt" | "fromAsset" | "toAsset" > & { receipt: File | string; @@ -312,7 +317,7 @@ export const updateTransaction = async ( const transaction = await pb .collection("wallet__transactions") - .update>(id, updatedData); + .update>(id, updatedData); if (file && fs.existsSync(file.path)) { fs.unlinkSync(file.path); @@ -331,8 +336,8 @@ export const deleteTransaction = async ( export const scanReceipt = async ( pb: Pocketbase, file: Express.Multer.File, -): Promise => { - async function getTransactionDetails(): Promise { +): Promise => { + async function getTransactionDetails(): Promise { const TransactionDetails = z.object({ date: z.string(), particulars: z.string(), diff --git a/server/src/apps/wallet/services/utils.service.ts b/server/src/apps/wallet/services/utils.service.ts index 2eb2b5114..f1ef5008d 100644 --- a/server/src/apps/wallet/services/utils.service.ts +++ b/server/src/apps/wallet/services/utils.service.ts @@ -1,15 +1,9 @@ import moment from "moment"; import Pocketbase from "pocketbase"; +import { WalletSchemas } from "shared"; import { WithPB } from "@typescript/pocketbase_interfaces"; -import { - IWalletCategory, - IWalletIncomeExpensesSummary, - IWalletTransaction, - IWalletTransactionTypeAggregated, -} from "../schema"; - export const getTypesCount = async ( pb: Pocketbase, ): Promise<{ @@ -20,7 +14,7 @@ export const getTypesCount = async ( }> => { const types = await pb .collection("wallet__transaction_types_aggregated") - .getFullList>(); + .getFullList>(); const typesCount: { [key: string]: { @@ -43,7 +37,7 @@ export const getIncomeExpensesSummary = async ( pb: Pocketbase, year: string, month: string, -): Promise => { +): Promise => { const start = moment(`${year}-${month}-01`) .startOf("month") .format("YYYY-MM-DD"); @@ -51,7 +45,7 @@ export const getIncomeExpensesSummary = async ( const transactions = await pb .collection("wallet__transactions") - .getFullList>({ + .getFullList>({ filter: "type = 'income' || type = 'expenses'", sort: "-date,-created", }); @@ -130,8 +124,8 @@ export const getExpensesBreakdown = async ( .format("YYYY-MM-DD"); const expenses = await pb.collection("wallet__transactions").getFullList< - WithPB & { - expand?: { category: WithPB }; + WithPB & { + expand?: { category: WithPB }; } >({ filter: `date >= '${startDate}' && date <= '${endDate}' && type = 'expenses'`, diff --git a/server/src/apps/wishlist/controllers/entries.controller.ts b/server/src/apps/wishlist/controllers/entries.controller.ts index d6c002fd8..41c9daca9 100644 --- a/server/src/apps/wishlist/controllers/entries.controller.ts +++ b/server/src/apps/wishlist/controllers/entries.controller.ts @@ -4,13 +4,13 @@ import { } from "@functions/forgeController"; import express from "express"; import fs from "fs"; +import { WishlistSchemas } from "shared"; import { z } from "zod/v4"; import { WithPBSchema } from "@typescript/pocketbase_interfaces"; import { singleUploadMiddleware } from "@middlewares/uploadMiddleware"; -import { WishlistEntrySchema } from "../schema"; import * as entriesService from "../services/entries.service"; const wishlistEntriesRouter = express.Router(); @@ -36,7 +36,7 @@ const getEntriesByListId = forgeController .optional() .transform((val) => val === "true"), }), - response: z.array(WithPBSchema(WishlistEntrySchema)), + response: z.array(WithPBSchema(WishlistSchemas.EntrySchema)), }) .existenceCheck("params", { id: "wishlist__lists", @@ -72,7 +72,7 @@ const createEntry = forgeController list: z.string(), image: z.any().optional(), }), - response: WithPBSchema(WishlistEntrySchema), + response: WithPBSchema(WishlistSchemas.EntrySchema), }) .middlewares(singleUploadMiddleware) .existenceCheck("body", { @@ -118,7 +118,7 @@ const updateEntry = forgeController imageRemoved: z.string().optional(), }), response: z.union([ - WithPBSchema(WishlistEntrySchema), + WithPBSchema(WishlistSchemas.EntrySchema), z.literal("removed"), ]), }) @@ -170,7 +170,7 @@ const updateEntryBoughtStatus = forgeController params: z.object({ id: z.string(), }), - response: WithPBSchema(WishlistEntrySchema), + response: WithPBSchema(WishlistSchemas.EntrySchema), }) .existenceCheck("params", { id: "wishlist__entries", diff --git a/server/src/apps/wishlist/controllers/lists.controller.ts b/server/src/apps/wishlist/controllers/lists.controller.ts index 0e5c4d8fd..5242ac114 100644 --- a/server/src/apps/wishlist/controllers/lists.controller.ts +++ b/server/src/apps/wishlist/controllers/lists.controller.ts @@ -3,11 +3,11 @@ import { forgeController, } from "@functions/forgeController"; import express from "express"; +import { WishlistSchemas } from "shared"; import { z } from "zod/v4"; import { WithPBSchema } from "@typescript/pocketbase_interfaces"; -import { WishlistListSchema } from "../schema"; import * as listsService from "../services/lists.service"; const wishlistListsRouter = express.Router(); @@ -19,7 +19,7 @@ const getList = forgeController params: z.object({ id: z.string(), }), - response: WithPBSchema(WishlistListSchema), + response: WithPBSchema(WishlistSchemas.ListAggregatedSchema), }) .existenceCheck("params", { id: "wishlist__lists", @@ -46,16 +46,7 @@ const getAllLists = forgeController .route("GET /") .description("Get all wishlists with statistics") .schema({ - response: z.array( - WithPBSchema( - WishlistListSchema.extend({ - total_count: z.number(), - bought_count: z.number(), - total_amount: z.number(), - bought_amount: z.number(), - }), - ), - ), + response: z.array(WithPBSchema(WishlistSchemas.ListAggregatedSchema)), }) .callback(async ({ pb }) => await listsService.getAllLists(pb)); @@ -63,8 +54,8 @@ const createList = forgeController .route("POST /") .description("Create a new wishlist") .schema({ - body: WishlistListSchema, - response: WithPBSchema(WishlistListSchema), + body: WishlistSchemas.ListSchema, + response: WithPBSchema(WishlistSchemas.ListSchema), }) .statusCode(201) .callback(async ({ pb, body }) => await listsService.createList(pb, body)); @@ -76,8 +67,8 @@ const updateList = forgeController params: z.object({ id: z.string(), }), - body: WishlistListSchema, - response: WithPBSchema(WishlistListSchema), + body: WishlistSchemas.ListSchema, + response: WithPBSchema(WishlistSchemas.ListSchema), }) .existenceCheck("params", { id: "wishlist__lists", diff --git a/server/src/apps/wishlist/schema.ts b/server/src/apps/wishlist/schema.ts deleted file mode 100644 index cbfc215b0..000000000 --- a/server/src/apps/wishlist/schema.ts +++ /dev/null @@ -1,52 +0,0 @@ -/** - * This file is auto-generated. DO NOT EDIT IT MANUALLY. - * If you want to add custom schemas, you will find a dedicated space at the end of this file. - * Generated for module: wishlist - * Generated at: 2025-07-09T12:50:41.285Z - * Contains: wishlist__lists, wishlist__entries, wishlist__lists_aggregated - */ -import { z } from "zod/v4"; - -const WishlistListSchema = z.object({ - name: z.string(), - description: z.string(), - color: z.string(), - icon: z.string(), -}); - -const WishlistEntrySchema = z.object({ - name: z.string(), - url: z.string(), - price: z.number(), - image: z.string(), - list: z.string(), - bought: z.boolean(), - bought_at: z.string(), -}); - -const WishlistListAggregatedSchema = z.object({ - name: z.string(), - description: z.string(), - color: z.string(), - icon: z.string(), - total_count: z.number(), - total_amount: z.any(), - bought_count: z.number(), - bought_amount: z.any(), -}); - -type IWishlistList = z.infer; -type IWishlistEntry = z.infer; -type IWishlistListAggregated = z.infer; - -export { - WishlistListSchema, - WishlistEntrySchema, - WishlistListAggregatedSchema, -}; - -export type { IWishlistList, IWishlistEntry, IWishlistListAggregated }; - -// -------------------- CUSTOM SCHEMAS -------------------- - -// Add your custom schemas here. They will not be overwritten by this script. diff --git a/server/src/apps/wishlist/services/entries.service.ts b/server/src/apps/wishlist/services/entries.service.ts index 837d74d6b..721d62f92 100644 --- a/server/src/apps/wishlist/services/entries.service.ts +++ b/server/src/apps/wishlist/services/entries.service.ts @@ -1,9 +1,9 @@ import PocketBase from "pocketbase"; +import { WishlistSchemas } from "shared"; import { WithPB } from "@typescript/pocketbase_interfaces"; import scrapeProviders from "../helpers/scrapers/index"; -import { IWishlistEntry } from "../schema"; export const getCollectionId = (pb: PocketBase): string => pb.collection("wishlist__entries").collectionIdOrName; @@ -12,12 +12,14 @@ export const getEntriesByListId = ( pb: PocketBase, listId: string, bought?: boolean, -): Promise[]> => - pb.collection("wishlist__entries").getFullList>({ - filter: `list = "${listId}" ${ - typeof bought !== "undefined" ? `&& bought = ${bought}` : "" - }`, - }); +): Promise[]> => + pb + .collection("wishlist__entries") + .getFullList>({ + filter: `list = "${listId}" ${ + typeof bought !== "undefined" ? `&& bought = ${bought}` : "" + }`, + }); export const scrapeExternal = async ( pb: PocketBase, @@ -41,11 +43,11 @@ export const scrapeExternal = async ( export const createEntry = async ( pb: PocketBase, - data: Omit & { image?: File }, -): Promise> => { + data: Omit & { image?: File }, +): Promise> => { const entry = await pb .collection("wishlist__entries") - .create>(data); + .create>(data); return entry; }; @@ -60,10 +62,10 @@ export const updateEntry = async ( price: number; image?: File | null; }, -): Promise> => { +): Promise> => { const entry = await pb .collection("wishlist__entries") - .update>(id, data); + .update>(id, data); return entry; }; @@ -71,23 +73,23 @@ export const updateEntry = async ( export const getEntry = async ( pb: PocketBase, id: string, -): Promise> => { +): Promise> => { return await pb .collection("wishlist__entries") - .getOne>(id); + .getOne>(id); }; export const updateEntryBoughtStatus = async ( pb: PocketBase, id: string, -): Promise> => { +): Promise> => { const oldEntry = await pb .collection("wishlist__entries") - .getOne>(id); + .getOne>(id); const entry = await pb .collection("wishlist__entries") - .update>(id, { + .update>(id, { bought: !oldEntry.bought, bought_at: oldEntry.bought ? null : new Date().toISOString(), }); diff --git a/server/src/apps/wishlist/services/lists.service.ts b/server/src/apps/wishlist/services/lists.service.ts index ba7d58462..c5b16fc30 100644 --- a/server/src/apps/wishlist/services/lists.service.ts +++ b/server/src/apps/wishlist/services/lists.service.ts @@ -1,9 +1,8 @@ import PocketBase from "pocketbase"; +import { WishlistSchemas } from "shared"; import { WithPB } from "@typescript/pocketbase_interfaces"; -import { IWishlistList } from "../schema"; - export const checkListExists = async ( pb: PocketBase, id: string, @@ -19,64 +18,34 @@ export const checkListExists = async ( export const getList = ( pb: PocketBase, id: string, -): Promise< - WithPB< - IWishlistList & { - total_count: number; - bought_count: number; - total_amount: number; - bought_amount: number; - } - > -> => - pb.collection("wishlist__lists_aggregated").getOne< - WithPB< - IWishlistList & { - total_count: number; - bought_count: number; - total_amount: number; - bought_amount: number; - } - > - >(id); +): Promise> => + pb + .collection("wishlist__lists_aggregated") + .getOne>(id); export const getAllLists = ( pb: PocketBase, -): Promise< - WithPB< - IWishlistList & { - total_count: number; - bought_count: number; - total_amount: number; - bought_amount: number; - } - >[] -> => - pb.collection("wishlist__lists_aggregated").getFullList< - WithPB< - IWishlistList & { - total_count: number; - bought_count: number; - total_amount: number; - bought_amount: number; - } - > - >({ - sort: "name", - }); +): Promise[]> => + pb + .collection("wishlist__lists_aggregated") + .getFullList>({ + sort: "name", + }); export const createList = ( pb: PocketBase, - data: IWishlistList, -): Promise> => - pb.collection("wishlist__lists").create>(data); + data: WishlistSchemas.IList, +): Promise> => + pb.collection("wishlist__lists").create>(data); export const updateList = async ( pb: PocketBase, id: string, - data: IWishlistList, -): Promise> => - pb.collection("wishlist__lists").update>(id, data); + data: WishlistSchemas.IList, +): Promise> => + pb + .collection("wishlist__lists") + .update>(id, data); export const deleteList = async (pb: PocketBase, id: string): Promise => { await pb.collection("wishlist__lists").delete(id); diff --git a/server/src/core/lib/apiKeys/controllers/entries.controller.ts b/server/src/core/lib/apiKeys/controllers/entries.controller.ts index ad8f6c8fb..c36e99ab6 100644 --- a/server/src/core/lib/apiKeys/controllers/entries.controller.ts +++ b/server/src/core/lib/apiKeys/controllers/entries.controller.ts @@ -4,11 +4,11 @@ import { forgeController, } from "@functions/forgeController"; import express from "express"; +import { ApiKeysSchemas } from "shared"; import { z } from "zod/v4"; import { WithPBSchema } from "@typescript/pocketbase_interfaces"; -import { ApiKeysEntrySchema } from "../schema"; import { challenge } from "../services/auth.service"; import getDecryptedMaster, * as entriesService from "../services/entries.service"; @@ -21,7 +21,7 @@ const getAllEntries = forgeController query: z.object({ master: z.string(), }), - response: z.array(WithPBSchema(ApiKeysEntrySchema)), + response: z.array(WithPBSchema(ApiKeysSchemas.EntrySchema)), }) .callback(async ({ pb, query: { master } }) => { await getDecryptedMaster(pb, decodeURIComponent(master)); @@ -71,7 +71,7 @@ const createEntry = forgeController body: z.object({ data: z.string(), }), - response: WithPBSchema(ApiKeysEntrySchema), + response: WithPBSchema(ApiKeysSchemas.EntrySchema), }) .statusCode(201) .callback(async ({ pb, body: { data } }) => { @@ -100,7 +100,7 @@ const updateEntry = forgeController body: z.object({ data: z.string(), }), - response: WithPBSchema(ApiKeysEntrySchema), + response: WithPBSchema(ApiKeysSchemas.EntrySchema), }) .existenceCheck("params", { id: "api_keys__entries", diff --git a/server/src/core/lib/apiKeys/schema.ts b/server/src/core/lib/apiKeys/schema.ts deleted file mode 100644 index 7bbe3bf48..000000000 --- a/server/src/core/lib/apiKeys/schema.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file is auto-generated. DO NOT EDIT IT MANUALLY. - * If you want to add custom schemas, you will find a dedicated space at the end of this file. - * Generated for module: apiKeys - * Generated at: 2025-07-09T12:50:41.286Z - * Contains: api_keys__entries - */ -import { z } from "zod/v4"; - -const ApiKeysEntrySchema = z.object({ - keyId: z.string(), - name: z.string(), - description: z.string(), - icon: z.string(), - key: z.string(), -}); - -type IApiKeysEntry = z.infer; - -export { ApiKeysEntrySchema }; - -export type { IApiKeysEntry }; - -// -------------------- CUSTOM SCHEMAS -------------------- - -// Add your custom schemas here. They will not be overwritten by this script. diff --git a/server/src/core/lib/apiKeys/services/entries.service.ts b/server/src/core/lib/apiKeys/services/entries.service.ts index d653c59c1..80943744e 100644 --- a/server/src/core/lib/apiKeys/services/entries.service.ts +++ b/server/src/core/lib/apiKeys/services/entries.service.ts @@ -2,10 +2,10 @@ import ClientError from "@functions/ClientError"; import { decrypt2, encrypt2 } from "@functions/encryption"; import bcrypt from "bcrypt"; import PocketBase from "pocketbase"; +import { ApiKeysSchemas } from "shared"; import { WithPB } from "@typescript/pocketbase_interfaces"; -import { IApiKeysEntry } from "../schema"; import { challenge } from "./auth.service"; export default async function getDecryptedMaster( @@ -32,10 +32,10 @@ export default async function getDecryptedMaster( export const getAllEntries = async ( pb: PocketBase, -): Promise[]> => { +): Promise[]> => { const entries = await pb .collection("api_keys__entries") - .getFullList>({ + .getFullList>({ sort: "name", }); @@ -94,13 +94,13 @@ export const createEntry = async ( key: string; decryptedMaster: string; }, -): Promise> => { +): Promise> => { const decryptedKey = decrypt2(key, decryptedMaster); const encryptedKey = encrypt2(decryptedKey, process.env.MASTER_KEY!); const entry = await pb .collection("api_keys__entries") - .create>({ + .create>({ keyId, name, description, @@ -131,13 +131,13 @@ export const updateEntry = async ( key: string; decryptedMaster: string; }, -): Promise> => { +): Promise> => { const decryptedKey = decrypt2(key, decryptedMaster); const encryptedKey = encrypt2(decryptedKey, process.env.MASTER_KEY!); const updatedEntry = await pb .collection("api_keys__entries") - .update>(id, { + .update>(id, { keyId, name, description, diff --git a/server/src/core/lib/user/schema.ts b/server/src/core/lib/user/schema.ts deleted file mode 100644 index f6afd3026..000000000 --- a/server/src/core/lib/user/schema.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * This file is auto-generated. DO NOT EDIT IT MANUALLY. - * If you want to add custom schemas, you will find a dedicated space at the end of this file. - * Generated for module: user - * Generated at: 2025-07-09T12:50:41.286Z - * Contains: users - */ -import { z } from "zod/v4"; - -const UserSchema = z.object({ - password: z.string(), - tokenKey: z.string(), - email: z.email(), - emailVisibility: z.boolean(), - verified: z.boolean(), - username: z.string(), - name: z.string(), - avatar: z.string(), - dateOfBirth: z.string(), - theme: z.enum(["system", "light", "dark"]), - color: z.string(), - bgTemp: z.string(), - bgImage: z.string(), - backdropFilters: z.any(), - fontFamily: z.string(), - language: z.enum(["zh-CN", "en", "ms", "zh-TW", ""]), - moduleConfigs: z.any(), - enabledModules: z.any(), - dashboardLayout: z.any(), - spotifyAccessToken: z.string(), - spotifyRefreshToken: z.string(), - spotifyTokenExpires: z.string(), - masterPasswordHash: z.string(), - journalMasterPasswordHash: z.string(), - APIKeysMasterPasswordHash: z.string(), - twoFASecret: z.string(), -}); - -type IUser = z.infer; - -export { UserSchema }; - -export type { IUser }; - -// -------------------- CUSTOM SCHEMAS -------------------- - -// Add your custom schemas here. They will not be overwritten by this script. diff --git a/shared/src/index.ts b/shared/src/index.ts index a4135c775..8aa87a185 100644 --- a/shared/src/index.ts +++ b/shared/src/index.ts @@ -1,4 +1,3 @@ - /** * This file is auto-generated. DO NOT EDIT IT MANUALLY. * You may regenerate it by running `npm run generate:schema`. @@ -7,23 +6,24 @@ * Contains schemas for all modules. */ -export * as UserSchemas from './types/user.schema'; -export * as TodoListSchemas from './types/todoList.schema'; -export * as CodeTimeSchemas from './types/codeTime.schema'; -export * as IdeaBoxSchemas from './types/ideaBox.schema'; -export * as PasswordsSchemas from './types/passwords.schema'; -export * as CalendarSchemas from './types/calendar.schema'; -export * as MusicSchemas from './types/music.schema'; -export * as AchievementsSchemas from './types/achievements.schema'; -export * as WalletSchemas from './types/wallet.schema'; -export * as GuitarTabsSchemas from './types/guitarTabs.schema'; -export * as ApiKeysSchemas from './types/apiKeys.schema'; -export * as BooksLibrarySchemas from './types/booksLibrary.schema'; -export * as WishlistSchemas from './types/wishlist.schema'; -export * as VirtualWardrobeSchemas from './types/virtualWardrobe.schema'; -export * as MomentVaultSchemas from './types/momentVault.schema'; -export * as MoviesSchemas from './types/movies.schema'; -export * as RailwayMapSchemas from './types/railwayMap.schema'; -export * as BlogSchemas from './types/blog.schema'; +export * as UserSchemas from './types/user.schema' +export * as TodoListSchemas from './types/todoList.schema' +export * as CodeTimeSchemas from './types/codeTime.schema' +export * as IdeaBoxSchemas from './types/ideaBox.schema' +export * as PasswordsSchemas from './types/passwords.schema' +export * as CalendarSchemas from './types/calendar.schema' +export * as MusicSchemas from './types/music.schema' +export * as AchievementsSchemas from './types/achievements.schema' +export * as WalletSchemas from './types/wallet.schema' +export * as GuitarTabsSchemas from './types/guitarTabs.schema' +export * as ApiKeysSchemas from './types/apiKeys.schema' +export * as BooksLibrarySchemas from './types/booksLibrary.schema' +export * as WishlistSchemas from './types/wishlist.schema' +export * as VirtualWardrobeSchemas from './types/virtualWardrobe.schema' +export * as MomentVaultSchemas from './types/momentVault.schema' +export * as MoviesSchemas from './types/movies.schema' +export * as RailwayMapSchemas from './types/railwayMap.schema' +export * as BlogSchemas from './types/blog.schema' -export type { SchemaWithPB } from './utils/schemaWithPB.types' +export { SchemaWithPB } from './utils/schemaWithPB' +export type { ISchemaWithPB } from './utils/schemaWithPB' diff --git a/shared/src/types/booksLibrary.schema.ts b/shared/src/types/booksLibrary.schema.ts index 359047c80..60ac887a5 100644 --- a/shared/src/types/booksLibrary.schema.ts +++ b/shared/src/types/booksLibrary.schema.ts @@ -5,17 +5,17 @@ * Generated at: 2025-07-17T08:55:29.696Z * Contains: books_library__collections, books_library__languages, books_library__entries, books_library__file_types, books_library__file_types_aggregated, books_library__languages_aggregated, books_library__collections_aggregated */ +import { z } from 'zod/v4' -import { z } from "zod/v4"; const CollectionSchema = z.object({ name: z.string(), - icon: z.string(), -}); + icon: z.string() +}) const LanguageSchema = z.object({ name: z.string(), - icon: z.string(), -}); + icon: z.string() +}) const EntrySchema = z.object({ title: z.string(), @@ -33,37 +33,37 @@ const EntrySchema = z.object({ thumbnail: z.string(), is_favourite: z.boolean(), is_read: z.boolean(), - time_finished: z.string(), -}); + time_finished: z.string() +}) const FileTypeSchema = z.object({ - name: z.string(), -}); + name: z.string() +}) const FileTypeAggregatedSchema = z.object({ name: z.string(), - amount: z.number(), -}); + amount: z.number() +}) const LanguageAggregatedSchema = z.object({ name: z.string(), icon: z.string(), - amount: z.number(), -}); + amount: z.number() +}) const CollectionAggregatedSchema = z.object({ name: z.string(), icon: z.string(), - amount: z.number(), -}); + amount: z.number() +}) -type ICollection = z.infer; -type ILanguage = z.infer; -type IEntry = z.infer; -type IFileType = z.infer; -type IFileTypeAggregated = z.infer; -type ILanguageAggregated = z.infer; -type ICollectionAggregated = z.infer; +type ICollection = z.infer +type ILanguage = z.infer +type IEntry = z.infer +type IFileType = z.infer +type IFileTypeAggregated = z.infer +type ILanguageAggregated = z.infer +type ICollectionAggregated = z.infer export { CollectionSchema, @@ -72,8 +72,8 @@ export { FileTypeSchema, FileTypeAggregatedSchema, LanguageAggregatedSchema, - CollectionAggregatedSchema, -}; + CollectionAggregatedSchema +} export type { ICollection, @@ -82,9 +82,23 @@ export type { IFileType, IFileTypeAggregated, ILanguageAggregated, - ICollectionAggregated, -}; + ICollectionAggregated +} // -------------------- CUSTOM SCHEMAS -------------------- -// Add your custom schemas here. They will not be overwritten by this script. +const BooksLibraryLibgenSearchResultSchema = z.object({ + provider: z.string(), + query: z.string(), + resultsCount: z.string(), + data: z.record(z.string(), z.any()), + page: z.number() +}) + +type IBooksLibraryLibgenSearchResult = z.infer< + typeof BooksLibraryLibgenSearchResultSchema +> + +export { BooksLibraryLibgenSearchResultSchema } + +export type { IBooksLibraryLibgenSearchResult } diff --git a/shared/src/types/codeTime.schema.ts b/shared/src/types/codeTime.schema.ts index 62f702c40..7287b0ea5 100644 --- a/shared/src/types/codeTime.schema.ts +++ b/shared/src/types/codeTime.schema.ts @@ -5,19 +5,19 @@ * Generated at: 2025-07-17T08:55:29.696Z * Contains: code_time__projects, code_time__languages, code_time__daily_entries */ +import { z } from 'zod/v4' -import { z } from "zod/v4"; const ProjectSchema = z.object({ name: z.string(), - duration: z.number(), -}); + duration: z.number() +}) const LanguageSchema = z.object({ name: z.string(), icon: z.string(), color: z.string(), - duration: z.number(), -}); + duration: z.number() +}) const DailyEntrySchema = z.object({ date: z.string(), @@ -25,25 +25,41 @@ const DailyEntrySchema = z.object({ projects: z.any(), total_minutes: z.number(), last_timestamp: z.number(), - languages: z.any(), -}); + languages: z.any() +}) -type IProject = z.infer; -type ILanguage = z.infer; -type IDailyEntry = z.infer; +type IProject = z.infer +type ILanguage = z.infer +type IDailyEntry = z.infer -export { - ProjectSchema, - LanguageSchema, - DailyEntrySchema, -}; +export { ProjectSchema, LanguageSchema, DailyEntrySchema } -export type { - IProject, - ILanguage, - IDailyEntry, -}; +export type { IProject, ILanguage, IDailyEntry } // -------------------- CUSTOM SCHEMAS -------------------- -// Add your custom schemas here. They will not be overwritten by this script. +const CodeTimeActivitiesSchema = z.object({ + data: z.array( + z.object({ + date: z.string(), + count: z.number(), + level: z.number() + }) + ), + firstYear: z.number() +}) + +const CodeTimeStatisticsSchema = z.object({ + 'Most time spent': z.number(), + 'Total time spent': z.number(), + 'Average time spent': z.number(), + 'Longest streak': z.number(), + 'Current streak': z.number() +}) + +type ICodeTimeActivities = z.infer +type ICodeTimeStatistics = z.infer + +export { CodeTimeActivitiesSchema, CodeTimeStatisticsSchema } + +export type { ICodeTimeActivities, ICodeTimeStatistics } diff --git a/shared/src/types/guitarTabs.schema.ts b/shared/src/types/guitarTabs.schema.ts index 0551352ec..9ba3525ab 100644 --- a/shared/src/types/guitarTabs.schema.ts +++ b/shared/src/types/guitarTabs.schema.ts @@ -39,4 +39,32 @@ export type { // -------------------- CUSTOM SCHEMAS -------------------- -// Add your custom schemas here. They will not be overwritten by this script. +const GuitarTabsSidebarDataSchema = z.object({ + total: z.number(), + favourites: z.number(), + categories: z.object({ + fingerstyle: z.number(), + singalong: z.number(), + uncategorized: z.number(), + }), + authors: z.record(z.string(), z.number()), +}); + +const GuitarTabsGuitarWorldEntrySchema = z.object({ + id: z.number(), + name: z.string(), + subtitle: z.string(), + category: z.string(), + mainArtist: z.string(), + uploader: z.string(), + audioUrl: z.string(), +}); + +type IGuitarTabsSidebarData = z.infer; +type IGuitarTabsGuitarWorldEntry = z.infer< + typeof GuitarTabsGuitarWorldEntrySchema +>; + +export { GuitarTabsSidebarDataSchema, GuitarTabsGuitarWorldEntrySchema }; + +export type { IGuitarTabsSidebarData, IGuitarTabsGuitarWorldEntry }; diff --git a/shared/src/types/music.schema.ts b/shared/src/types/music.schema.ts index 9dfcb94fc..ee731e972 100644 --- a/shared/src/types/music.schema.ts +++ b/shared/src/types/music.schema.ts @@ -5,26 +5,37 @@ * Generated at: 2025-07-17T08:55:29.692Z * Contains: music__entries */ +import { z } from 'zod/v4' -import { z } from "zod/v4"; const EntrySchema = z.object({ name: z.string(), duration: z.string(), author: z.string(), file: z.string(), - is_favourite: z.boolean(), -}); + is_favourite: z.boolean() +}) -type IEntry = z.infer; +type IEntry = z.infer -export { - EntrySchema, -}; +export { EntrySchema } -export type { - IEntry, -}; +export type { IEntry } // -------------------- CUSTOM SCHEMAS -------------------- -// Add your custom schemas here. They will not be overwritten by this script. +const YoutubeDataSchema = z.object({ + title: z.string(), + uploadDate: z.string(), + uploader: z.string(), + uploaderUrl: z.string().optional(), + duration: z.string(), + viewCount: z.number(), + likeCount: z.number(), + thumbnail: z.string() +}) + +type IYoutubeData = z.infer + +export { YoutubeDataSchema } + +export type { IYoutubeData } diff --git a/shared/src/types/todoList.schema.ts b/shared/src/types/todoList.schema.ts index 7523c58a7..6eba3a16f 100644 --- a/shared/src/types/todoList.schema.ts +++ b/shared/src/types/todoList.schema.ts @@ -5,17 +5,17 @@ * Generated at: 2025-07-17T08:55:29.693Z * Contains: todo_list__lists, todo_list__tags, todo_list__entries, todo_list__priorities, todo_list__lists_aggregated, todo_list__tags_aggregated, todo_list__priorities_aggregated */ +import { z } from 'zod/v4' -import { z } from "zod/v4"; const ListSchema = z.object({ name: z.string(), icon: z.string(), - color: z.string(), -}); + color: z.string() +}) const TagSchema = z.object({ - name: z.string(), -}); + name: z.string() +}) const EntrySchema = z.object({ summary: z.string(), @@ -26,40 +26,40 @@ const EntrySchema = z.object({ tags: z.array(z.string()), priority: z.string(), done: z.boolean(), - completed_at: z.string(), -}); + completed_at: z.string() +}) const PrioritySchema = z.object({ name: z.string(), color: z.string(), - amount: z.number(), -}); + amount: z.number() +}) const ListAggregatedSchema = z.object({ name: z.string(), color: z.string(), icon: z.string(), - amount: z.number(), -}); + amount: z.number() +}) const TagAggregatedSchema = z.object({ name: z.string(), - amount: z.number(), -}); + amount: z.number() +}) const PriorityAggregatedSchema = z.object({ name: z.string(), color: z.string(), - amount: z.number(), -}); + amount: z.number() +}) -type IList = z.infer; -type ITag = z.infer; -type IEntry = z.infer; -type IPriority = z.infer; -type IListAggregated = z.infer; -type ITagAggregated = z.infer; -type IPriorityAggregated = z.infer; +type IList = z.infer +type ITag = z.infer +type IEntry = z.infer +type IPriority = z.infer +type IListAggregated = z.infer +type ITagAggregated = z.infer +type IPriorityAggregated = z.infer export { ListSchema, @@ -68,8 +68,8 @@ export { PrioritySchema, ListAggregatedSchema, TagAggregatedSchema, - PriorityAggregatedSchema, -}; + PriorityAggregatedSchema +} export type { IList, @@ -78,9 +78,21 @@ export type { IPriority, IListAggregated, ITagAggregated, - IPriorityAggregated, -}; + IPriorityAggregated +} // -------------------- CUSTOM SCHEMAS -------------------- -// Add your custom schemas here. They will not be overwritten by this script. +const TodoListStatusCounterSchema = z.object({ + all: z.number(), + today: z.number(), + scheduled: z.number(), + overdue: z.number(), + completed: z.number() +}) + +type ITodoListStatusCounter = z.infer + +export { TodoListStatusCounterSchema } + +export type { ITodoListStatusCounter } diff --git a/shared/src/types/virtualWardrobe.schema.ts b/shared/src/types/virtualWardrobe.schema.ts index ce23a06ce..70e3f9e9a 100644 --- a/shared/src/types/virtualWardrobe.schema.ts +++ b/shared/src/types/virtualWardrobe.schema.ts @@ -5,8 +5,8 @@ * Generated at: 2025-07-17T08:55:29.691Z * Contains: virtual_wardrobe__entries, virtual_wardrobe__histories */ +import { z } from 'zod/v4' -import { z } from "zod/v4"; const EntrySchema = z.object({ name: z.string(), category: z.string(), @@ -21,27 +21,37 @@ const EntrySchema = z.object({ purchase_date: z.string(), price: z.number(), notes: z.string(), - is_favourite: z.boolean(), -}); + is_favourite: z.boolean() +}) const HistorySchema = z.object({ entries: z.array(z.string()), - notes: z.string(), -}); + notes: z.string() +}) -type IEntry = z.infer; -type IHistory = z.infer; +type IEntry = z.infer +type IHistory = z.infer -export { - EntrySchema, - HistorySchema, -}; +export { EntrySchema, HistorySchema } -export type { - IEntry, - IHistory, -}; +export type { IEntry, IHistory } // -------------------- CUSTOM SCHEMAS -------------------- -// Add your custom schemas here. They will not be overwritten by this script. +const VirtualWardrobeSidebarDataSchema = z.object({ + total: z.number(), + favourites: z.number(), + categories: z.record(z.string(), z.number()), + subcategories: z.record(z.string(), z.number()), + brands: z.record(z.string(), z.number()), + sizes: z.record(z.string(), z.number()), + colors: z.record(z.string(), z.number()) +}) + +type IVirtualWardrobeSidebarData = z.infer< + typeof VirtualWardrobeSidebarDataSchema +> + +export { VirtualWardrobeSidebarDataSchema } + +export type { IVirtualWardrobeSidebarData } diff --git a/shared/src/types/wallet.schema.ts b/shared/src/types/wallet.schema.ts index 6a9169db8..c5ca4ce45 100644 --- a/shared/src/types/wallet.schema.ts +++ b/shared/src/types/wallet.schema.ts @@ -5,30 +5,30 @@ * Generated at: 2025-07-17T08:55:29.695Z * Contains: wallet__assets, wallet__ledgers, wallet__categories, wallet__transactions, wallet__categories_aggregated, wallet__assets_aggregated, wallet__ledgers_aggregated, wallet__transaction_types_aggregated */ +import { z } from 'zod/v4' -import { z } from "zod/v4"; const AssetSchema = z.object({ name: z.string(), icon: z.string(), - starting_balance: z.number(), -}); + starting_balance: z.number() +}) const LedgerSchema = z.object({ name: z.string(), icon: z.string(), - color: z.string(), -}); + color: z.string() +}) const CategorySchema = z.object({ name: z.string(), icon: z.string(), color: z.string(), - type: z.enum(["income","expenses",""]), -}); + type: z.enum(['income', 'expenses', '']) +}) const TransactionSchema = z.object({ - type: z.enum(["income","expenses","transfer",""]), - side: z.enum(["debit","credit",""]), + type: z.enum(['income', 'expenses', 'transfer', '']), + side: z.enum(['debit', 'credit', '']), particulars: z.string(), amount: z.number(), date: z.string(), @@ -37,46 +37,48 @@ const TransactionSchema = z.object({ category: z.string(), asset: z.string(), ledger: z.string(), - receipt: z.string(), -}); + receipt: z.string() +}) const CategoryAggregatedSchema = z.object({ - type: z.enum(["income","expenses",""]), + type: z.enum(['income', 'expenses', '']), name: z.string(), icon: z.string(), color: z.string(), - amount: z.number(), -}); + amount: z.number() +}) const AssetAggregatedSchema = z.object({ name: z.string(), icon: z.string(), starting_balance: z.number(), amount: z.number(), - balance: z.any(), -}); + balance: z.any() +}) const LedgerAggregatedSchema = z.object({ name: z.string(), color: z.string(), icon: z.string(), - amount: z.number(), -}); + amount: z.number() +}) const TransactionTypeAggregatedSchema = z.object({ - name: z.enum(["income","expenses","transfer",""]), + name: z.enum(['income', 'expenses', 'transfer', '']), amount: z.number(), - accumulate: z.any(), -}); + accumulate: z.any() +}) -type IAsset = z.infer; -type ILedger = z.infer; -type ICategory = z.infer; -type ITransaction = z.infer; -type ICategoryAggregated = z.infer; -type IAssetAggregated = z.infer; -type ILedgerAggregated = z.infer; -type ITransactionTypeAggregated = z.infer; +type IAsset = z.infer +type ILedger = z.infer +type ICategory = z.infer +type ITransaction = z.infer +type ICategoryAggregated = z.infer +type IAssetAggregated = z.infer +type ILedgerAggregated = z.infer +type ITransactionTypeAggregated = z.infer< + typeof TransactionTypeAggregatedSchema +> export { AssetSchema, @@ -86,8 +88,8 @@ export { CategoryAggregatedSchema, AssetAggregatedSchema, LedgerAggregatedSchema, - TransactionTypeAggregatedSchema, -}; + TransactionTypeAggregatedSchema +} export type { IAsset, @@ -97,9 +99,29 @@ export type { ICategoryAggregated, IAssetAggregated, ILedgerAggregated, - ITransactionTypeAggregated, -}; + ITransactionTypeAggregated +} // -------------------- CUSTOM SCHEMAS -------------------- -// Add your custom schemas here. They will not be overwritten by this script. +const WalletIncomeExpensesSummarySchema = z.object({ + totalIncome: z.number(), + totalExpenses: z.number(), + monthlyIncome: z.number(), + monthlyExpenses: z.number() +}) + +const WalletReceiptScanResultSchema = z.object({ + date: z.string(), + particulars: z.string(), + type: z.string(), + amount: z.number() +}) + +type IWalletIncomeExpensesSummary = z.infer< + typeof WalletIncomeExpensesSummarySchema +> +type IWalletReceiptScanResult = z.infer + +export { WalletIncomeExpensesSummarySchema, WalletReceiptScanResultSchema } +export type { IWalletIncomeExpensesSummary, IWalletReceiptScanResult } diff --git a/shared/src/utils/schemaWithPB.ts b/shared/src/utils/schemaWithPB.ts new file mode 100644 index 000000000..9e5b30a25 --- /dev/null +++ b/shared/src/utils/schemaWithPB.ts @@ -0,0 +1,15 @@ +import { z } from 'zod/v4' + +const BasePBSchema = z.object({ + id: z.string(), + collectionId: z.string(), + collectionName: z.string(), + created: z.string(), + updated: z.string() +}) + +export const SchemaWithPB = (schema: T) => { + return z.intersection(schema, BasePBSchema) +} + +export type ISchemaWithPB = T & z.infer diff --git a/shared/src/utils/schemaWithPB.types.ts b/shared/src/utils/schemaWithPB.types.ts deleted file mode 100644 index 8561f1992..000000000 --- a/shared/src/utils/schemaWithPB.types.ts +++ /dev/null @@ -1,7 +0,0 @@ -export type SchemaWithPB = T & { - id: string - collectionName: string - collectionId: string - created: string - updated: string -} diff --git a/tsconfig.json b/tsconfig.json index a0034c124..f9b38747b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,40 +1,50 @@ { "compilerOptions": { // Environment setup & latest features - "lib": ["ESNext", "DOM", "DOM.Iterable"], + "lib": [ + "ESNext", + "DOM", + "DOM.Iterable" + ], "target": "ESNext", "module": "ESNext", "moduleDetection": "force", "jsx": "react-jsx", "allowJs": true, - // Path resolution "baseUrl": "./", "paths": { - "@server/*": ["./server/src/*"], - "@client/*": ["./client/src/*"], - "@shared/*": ["./shared/src/*"] + "@server/*": [ + "./server/src/*" + ], + "@client/*": [ + "./client/src/*" + ], + "@shared/*": [ + "./shared/src/*" + ] }, - // Module resolution "moduleResolution": "bundler", "allowSyntheticDefaultImports": true, "esModuleInterop": true, "verbatimModuleSyntax": true, - // Strictness and best practices "strict": true, "forceConsistentCasingInFileNames": true, "noFallthroughCasesInSwitch": true, "noUncheckedIndexedAccess": true, "experimentalDecorators": true, - // Output control "skipLibCheck": true, - // Optional strict flags (disabled by default) "noUnusedLocals": false, "noUnusedParameters": false, "noPropertyAccessFromIndexSignature": false - } -} + }, + "include": [ + "server/src", + "client/src", + "shared/src" + ], +} \ No newline at end of file