aboutsummaryrefslogtreecommitdiffhomepage
path: root/pkgs/shared
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-12-06 17:05:21 +0900
committernsfisis <nsfisis@gmail.com>2025-12-06 17:37:04 +0900
commit811458427593a4172a2cd535cc768db375350dca (patch)
tree6c4f46c96b6f29392dc19d591e39e03c187033a1 /pkgs/shared
parent9736a8981fbd6c6defbd67517ca23904fc844629 (diff)
downloadkioku-811458427593a4172a2cd535cc768db375350dca.tar.gz
kioku-811458427593a4172a2cd535cc768db375350dca.tar.zst
kioku-811458427593a4172a2cd535cc768db375350dca.zip
feat(dev): change architecture and directory structure
Diffstat (limited to 'pkgs/shared')
-rw-r--r--pkgs/shared/package.json23
-rw-r--r--pkgs/shared/src/index.ts2
-rw-r--r--pkgs/shared/src/schemas/index.ts140
-rw-r--r--pkgs/shared/src/types/index.ts79
-rw-r--r--pkgs/shared/tsconfig.json9
5 files changed, 0 insertions, 253 deletions
diff --git a/pkgs/shared/package.json b/pkgs/shared/package.json
deleted file mode 100644
index 8c50a8b..0000000
--- a/pkgs/shared/package.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "name": "@kioku/shared",
- "version": "0.1.0",
- "private": true,
- "main": "./src/index.ts",
- "types": "./src/index.ts",
- "exports": {
- ".": {
- "types": "./src/index.ts",
- "import": "./src/index.ts"
- }
- },
- "scripts": {
- "test": "echo \"Error: no test specified\" && exit 1"
- },
- "author": "nsfisis",
- "license": "MIT",
- "packageManager": "pnpm@10.23.0",
- "type": "module",
- "dependencies": {
- "zod": "^4.1.13"
- }
-}
diff --git a/pkgs/shared/src/index.ts b/pkgs/shared/src/index.ts
deleted file mode 100644
index 0ca6112..0000000
--- a/pkgs/shared/src/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from "./schemas/index.js";
-export * from "./types/index.js";
diff --git a/pkgs/shared/src/schemas/index.ts b/pkgs/shared/src/schemas/index.ts
deleted file mode 100644
index 05b926a..0000000
--- a/pkgs/shared/src/schemas/index.ts
+++ /dev/null
@@ -1,140 +0,0 @@
-import { z } from "zod";
-
-// Card states for FSRS algorithm
-export const cardStateSchema = z.union([
- z.literal(0), // New
- z.literal(1), // Learning
- z.literal(2), // Review
- z.literal(3), // Relearning
-]);
-
-// Rating values for reviews
-export const ratingSchema = z.union([
- z.literal(1), // Again
- z.literal(2), // Hard
- z.literal(3), // Good
- z.literal(4), // Easy
-]);
-
-// User schema
-export const userSchema = z.object({
- id: z.string().uuid(),
- username: z.string().min(1).max(255),
- passwordHash: z.string(),
- createdAt: z.coerce.date(),
- updatedAt: z.coerce.date(),
-});
-
-// User creation input schema
-export const createUserSchema = z.object({
- username: z.string().min(1).max(255),
- password: z.string().min(15).max(255),
-});
-
-// Login input schema
-export const loginSchema = z.object({
- username: z.string().min(1),
- password: z.string().min(1),
-});
-
-// Refresh token input schema
-export const refreshTokenSchema = z.object({
- refreshToken: z.string().min(1),
-});
-
-// Deck schema
-export const deckSchema = z.object({
- id: z.string().uuid(),
- userId: z.string().uuid(),
- name: z.string().min(1).max(255),
- description: z.string().max(1000).nullable(),
- newCardsPerDay: z.number().int().min(0).default(20),
- createdAt: z.coerce.date(),
- updatedAt: z.coerce.date(),
- deletedAt: z.coerce.date().nullable(),
- syncVersion: z.number().int().min(0),
-});
-
-// Deck creation input schema
-export const createDeckSchema = z.object({
- name: z.string().min(1).max(255),
- description: z.string().max(1000).nullable().optional(),
- newCardsPerDay: z.number().int().min(0).default(20),
-});
-
-// Deck update input schema
-export const updateDeckSchema = z.object({
- name: z.string().min(1).max(255).optional(),
- description: z.string().max(1000).nullable().optional(),
- newCardsPerDay: z.number().int().min(0).optional(),
-});
-
-// Card schema
-export const cardSchema = z.object({
- id: z.string().uuid(),
- deckId: z.string().uuid(),
- front: z.string().min(1),
- back: z.string().min(1),
-
- // FSRS fields
- state: cardStateSchema,
- due: z.coerce.date(),
- stability: z.number().min(0),
- difficulty: z.number().min(0).max(10),
- elapsedDays: z.number().int().min(0),
- scheduledDays: z.number().int().min(0),
- reps: z.number().int().min(0),
- lapses: z.number().int().min(0),
- lastReview: z.coerce.date().nullable(),
-
- createdAt: z.coerce.date(),
- updatedAt: z.coerce.date(),
- deletedAt: z.coerce.date().nullable(),
- syncVersion: z.number().int().min(0),
-});
-
-// Card creation input schema
-export const createCardSchema = z.object({
- front: z.string().min(1),
- back: z.string().min(1),
-});
-
-// Card update input schema
-export const updateCardSchema = z.object({
- front: z.string().min(1).optional(),
- back: z.string().min(1).optional(),
-});
-
-// ReviewLog schema
-export const reviewLogSchema = z.object({
- id: z.string().uuid(),
- cardId: z.string().uuid(),
- userId: z.string().uuid(),
- rating: ratingSchema,
- state: cardStateSchema,
- scheduledDays: z.number().int().min(0),
- elapsedDays: z.number().int().min(0),
- reviewedAt: z.coerce.date(),
- durationMs: z.number().int().min(0).nullable(),
- syncVersion: z.number().int().min(0),
-});
-
-// Submit review input schema
-export const submitReviewSchema = z.object({
- rating: ratingSchema,
- durationMs: z.number().int().min(0).nullable().optional(),
-});
-
-// Inferred types from schemas
-export type UserSchema = z.infer<typeof userSchema>;
-export type CreateUserSchema = z.infer<typeof createUserSchema>;
-export type LoginSchema = z.infer<typeof loginSchema>;
-export type RefreshTokenSchema = z.infer<typeof refreshTokenSchema>;
-export type DeckSchema = z.infer<typeof deckSchema>;
-export type CreateDeckSchema = z.infer<typeof createDeckSchema>;
-export type UpdateDeckSchema = z.infer<typeof updateDeckSchema>;
-export type CardSchema = z.infer<typeof cardSchema>;
-export type CreateCardSchema = z.infer<typeof createCardSchema>;
-export type UpdateCardSchema = z.infer<typeof updateCardSchema>;
-export type ReviewLogSchema = z.infer<typeof reviewLogSchema>;
-export type SubmitReviewSchema = z.infer<typeof submitReviewSchema>;
diff --git a/pkgs/shared/src/types/index.ts b/pkgs/shared/src/types/index.ts
deleted file mode 100644
index bfba06f..0000000
--- a/pkgs/shared/src/types/index.ts
+++ /dev/null
@@ -1,79 +0,0 @@
-// Card states for FSRS algorithm
-export const CardState = {
- New: 0,
- Learning: 1,
- Review: 2,
- Relearning: 3,
-} as const;
-
-export type CardState = (typeof CardState)[keyof typeof CardState];
-
-// Rating values for reviews
-export const Rating = {
- Again: 1,
- Hard: 2,
- Good: 3,
- Easy: 4,
-} as const;
-
-export type Rating = (typeof Rating)[keyof typeof Rating];
-
-// User
-export interface User {
- id: string;
- username: string;
- passwordHash: string;
- createdAt: Date;
- updatedAt: Date;
-}
-
-// Deck
-export interface Deck {
- id: string;
- userId: string;
- name: string;
- description: string | null;
- newCardsPerDay: number;
- createdAt: Date;
- updatedAt: Date;
- deletedAt: Date | null;
- syncVersion: number;
-}
-
-// Card with FSRS fields
-export interface Card {
- id: string;
- deckId: string;
- front: string;
- back: string;
-
- // FSRS fields
- state: CardState;
- due: Date;
- stability: number;
- difficulty: number;
- elapsedDays: number;
- scheduledDays: number;
- reps: number;
- lapses: number;
- lastReview: Date | null;
-
- createdAt: Date;
- updatedAt: Date;
- deletedAt: Date | null;
- syncVersion: number;
-}
-
-// ReviewLog (append-only)
-export interface ReviewLog {
- id: string;
- cardId: string;
- userId: string;
- rating: Rating;
- state: CardState;
- scheduledDays: number;
- elapsedDays: number;
- reviewedAt: Date;
- durationMs: number | null;
- syncVersion: number;
-}
diff --git a/pkgs/shared/tsconfig.json b/pkgs/shared/tsconfig.json
deleted file mode 100644
index 038af8a..0000000
--- a/pkgs/shared/tsconfig.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "extends": "../../tsconfig.json",
- "compilerOptions": {
- "outDir": "./dist",
- "rootDir": "./src"
- },
- "include": ["src/**/*"],
- "exclude": ["node_modules", "dist"]
-}