aboutsummaryrefslogtreecommitdiffhomepage
path: root/pkgs/shared
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-12-03 05:15:22 +0900
committernsfisis <nsfisis@gmail.com>2025-12-04 23:26:21 +0900
commit4ca12275c122dd84e489f8c15ee88a840eedb2cf (patch)
tree3db822390498485789fac90231fa379a512eb63a /pkgs/shared
parentc3fc3414dfdb8c7d018e792cde6b4b4374d3d573 (diff)
downloadkioku-4ca12275c122dd84e489f8c15ee88a840eedb2cf.tar.gz
kioku-4ca12275c122dd84e489f8c15ee88a840eedb2cf.tar.zst
kioku-4ca12275c122dd84e489f8c15ee88a840eedb2cf.zip
feat(shared): define types (User, Deck, Card, ReviewLog)
Add TypeScript type definitions for core data models used across client and server. Types are consistent with Drizzle schema defined in server. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'pkgs/shared')
-rw-r--r--pkgs/shared/src/index.ts2
-rw-r--r--pkgs/shared/src/types/index.ts79
2 files changed, 80 insertions, 1 deletions
diff --git a/pkgs/shared/src/index.ts b/pkgs/shared/src/index.ts
index cb0ff5c..2f88e30 100644
--- a/pkgs/shared/src/index.ts
+++ b/pkgs/shared/src/index.ts
@@ -1 +1 @@
-export {};
+export * from "./types/index.js";
diff --git a/pkgs/shared/src/types/index.ts b/pkgs/shared/src/types/index.ts
new file mode 100644
index 0000000..bfba06f
--- /dev/null
+++ b/pkgs/shared/src/types/index.ts
@@ -0,0 +1,79 @@
+// 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;
+}