@vestcards/server-types 0.5.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -530,7 +530,7 @@ declare const app: Elysia<"", {
530
530
  };
531
531
  headers: {};
532
532
  response: {
533
- 200: import("./types/study").SessionData;
533
+ 200: import("@vestcards/shared").ISessionData;
534
534
  422: {
535
535
  type: "validation";
536
536
  on: string;
@@ -558,7 +558,7 @@ declare const app: Elysia<"", {
558
558
  };
559
559
  headers: {};
560
560
  response: {
561
- 200: import("@vestcards/shared").SessionStats | {
561
+ 200: import("@vestcards/shared").IStudyStats | {
562
562
  status: import("@vestcards/shared").StudyStatus;
563
563
  review: number;
564
564
  learning: number;
@@ -624,7 +624,7 @@ declare const app: Elysia<"", {
624
624
  query: {};
625
625
  headers: {};
626
626
  response: {
627
- 200: import("@vestcards/shared").GroupedLibraryData;
627
+ 200: import("@vestcards/shared").IGroupedLibraryData;
628
628
  };
629
629
  };
630
630
  };
@@ -639,7 +639,7 @@ declare const app: Elysia<"", {
639
639
  query: {};
640
640
  headers: {};
641
641
  response: {
642
- 200: import("@vestcards/shared").ArchivedLibraryItem[];
642
+ 200: import("@vestcards/shared").IArchivedLibraryItem[];
643
643
  };
644
644
  };
645
645
  };
@@ -1019,7 +1019,7 @@ export declare const reviewLogs: import("drizzle-orm/pg-core").PgTableWithColumn
1019
1019
  tableName: "review_log";
1020
1020
  dataType: "string";
1021
1021
  columnType: "PgText";
1022
- data: "Again" | "Hard" | "Good" | "Easy" | "Manual";
1022
+ data: "Manual" | "Again" | "Hard" | "Good" | "Easy";
1023
1023
  driverParam: string;
1024
1024
  notNull: true;
1025
1025
  hasDefault: false;
@@ -357,7 +357,7 @@ export declare const libraryModule: Elysia<"/v1/library", {
357
357
  query: {};
358
358
  headers: {};
359
359
  response: {
360
- 200: import("@vestcards/shared").GroupedLibraryData;
360
+ 200: import("@vestcards/shared").IGroupedLibraryData;
361
361
  };
362
362
  };
363
363
  };
@@ -372,7 +372,7 @@ export declare const libraryModule: Elysia<"/v1/library", {
372
372
  query: {};
373
373
  headers: {};
374
374
  response: {
375
- 200: import("@vestcards/shared").ArchivedLibraryItem[];
375
+ 200: import("@vestcards/shared").IArchivedLibraryItem[];
376
376
  };
377
377
  };
378
378
  };
@@ -1,7 +1,7 @@
1
- import type { ArchivedLibraryItem, GroupedLibraryData } from '@vestcards/shared';
1
+ import type { IArchivedLibraryItem, IGroupedLibraryData } from '@vestcards/shared';
2
2
  export declare abstract class LibraryService {
3
- static getGroupedLibraryData(userId: string): Promise<GroupedLibraryData>;
4
- static getArchivedLibraryData(userId: string): Promise<ArchivedLibraryItem[]>;
3
+ static getGroupedLibraryData(userId: string): Promise<IGroupedLibraryData>;
4
+ static getArchivedLibraryData(userId: string): Promise<IArchivedLibraryItem[]>;
5
5
  static startDeckStudy(userId: string, deckId: string): Promise<void>;
6
6
  static deleteDeckStudy(userId: string, deckId: string): Promise<void>;
7
7
  static updateDeckStudySuspended(userId: string, deckId: string, suspended: boolean): Promise<void>;
@@ -361,7 +361,7 @@ export declare const studyModule: Elysia<"/v1/study", {
361
361
  };
362
362
  headers: {};
363
363
  response: {
364
- 200: import("../../types/study").SessionData;
364
+ 200: import("@vestcards/shared").ISessionData;
365
365
  422: {
366
366
  type: "validation";
367
367
  on: string;
@@ -389,7 +389,7 @@ export declare const studyModule: Elysia<"/v1/study", {
389
389
  };
390
390
  headers: {};
391
391
  response: {
392
- 200: import("@vestcards/shared").SessionStats | {
392
+ 200: import("@vestcards/shared").IStudyStats | {
393
393
  status: import("@vestcards/shared").StudyStatus;
394
394
  review: number;
395
395
  learning: number;
@@ -1,13 +1,13 @@
1
+ import type { ISessionData, IStudyStats, StudyType } from '@vestcards/shared';
1
2
  import { type CardReview } from '../../db/schema/deck';
2
- import type { SessionData, SessionStats, StudyType } from '../../types/study';
3
3
  import type { StudyModel } from './model';
4
4
  export declare abstract class StudyService {
5
- static getSessionData(userId: string, type: StudyType, id?: string): Promise<SessionData>;
5
+ static getSessionData(userId: string, type: StudyType, id?: string): Promise<ISessionData>;
6
6
  static getNumberLeftToLearnToday(userId: string, date?: Date): Promise<number>;
7
7
  static getStats(userId: string, numLeftToLearn: number, // capacity left today (from the function above)
8
- type: StudyType, id?: string): Promise<SessionStats>;
9
- static getReviewCards(userId: string, type: StudyType, id?: string, maxToFetch?: number): Promise<import("../../types/study").SessionCard[]>;
10
- static getNewCards(userId: string, allocatedNewForToday: number, type: StudyType, id?: string): Promise<import("../../types/study").SessionCard[]>;
8
+ type: StudyType, id?: string): Promise<IStudyStats>;
9
+ static getReviewCards(userId: string, type: StudyType, id?: string, maxToFetch?: number): Promise<import("@vestcards/shared").ISessionCard[]>;
10
+ static getNewCards(userId: string, allocatedNewForToday: number, type: StudyType, id?: string): Promise<import("@vestcards/shared").ISessionCard[]>;
11
11
  static getUserDeckStudy(userId: string, deckId: string): Promise<{
12
12
  suspended: boolean;
13
13
  id: string;
@@ -1,5 +1,4 @@
1
- import type { SessionStats, StudyStatus } from '@vestcards/shared';
2
- import type { SessionCard, StudyType } from 'src/types/study';
1
+ import type { ISessionCard, IStudyStats, StudyStatus, StudyType } from '@vestcards/shared';
3
2
  import type { SessionCardSelect } from 'src/utils/select';
4
3
  export declare const getSessionFilterByStudyType: (type: StudyType, id?: string) => import("drizzle-orm").SQL<unknown> | undefined;
5
4
  export declare const allocateByPriority: (capacityLeft: number, counts: {
@@ -12,7 +11,7 @@ export declare const allocateByPriority: (capacityLeft: number, counts: {
12
11
  new: number;
13
12
  total: number;
14
13
  };
15
- export declare function getStudyStatus(stats: SessionStats, userDeckStudy: {
14
+ export declare function getStudyStatus(stats: IStudyStats, userDeckStudy: {
16
15
  suspended: boolean;
17
16
  } | undefined): StudyStatus;
18
- export declare function sessionCardToICard(sessionRows: SessionCardSelect[]): SessionCard[];
17
+ export declare function sessionCardToICard(sessionRows: SessionCardSelect[]): ISessionCard[];
@@ -1,4 +1,4 @@
1
- import type { Topic } from 'src/types/topic';
1
+ import type { Topic } from '@vestcards/shared';
2
2
  import { type Paginated } from 'src/utils/api';
3
3
  import type { TopicModel } from './model';
4
4
  export declare abstract class TopicService {
@@ -1,5 +1,5 @@
1
1
  import type { Subject } from '@vestcards/shared';
2
- import { type InferColumnsDataTypes } from 'drizzle-orm';
2
+ import type { CardReview } from '../db/schema/deck';
3
3
  export declare const sessionCardSelect: {
4
4
  card: {
5
5
  id: import("drizzle-orm/pg-core").PgColumn<{
@@ -364,7 +364,7 @@ export type SessionCardSelect = {
364
364
  subject: Subject;
365
365
  topicName: string;
366
366
  userDeckStudyId: string;
367
- cardReview: InferColumnsDataTypes<typeof sessionCardSelect.cardReview> | null;
367
+ cardReview: Omit<CardReview, 'cardId' | 'userDeckStudyId'> | null;
368
368
  };
369
369
  export declare const statsSelect: {
370
370
  new: import("drizzle-orm").SQL<number>;
@@ -1,4 +1,5 @@
1
1
  export * from './types/deck';
2
+ export * from './types/fsrs';
2
3
  export * from './types/study';
3
4
  export * from './types/subject';
4
5
  export * from './types/topic';
@@ -0,0 +1,17 @@
1
+ export declare enum ReviewState {
2
+ New = "New",
3
+ Learning = "Learning",
4
+ Review = "Review",
5
+ Relearning = "Relearning"
6
+ }
7
+ export declare const reviewStates: readonly ["New", "Learning", "Review", "Relearning"];
8
+ export type ReviewStateType = keyof typeof ReviewState;
9
+ export declare enum ReviewRating {
10
+ Manual = "Manual",
11
+ Again = "Again",
12
+ Hard = "Hard",
13
+ Good = "Good",
14
+ Easy = "Easy"
15
+ }
16
+ export declare const reviewRatings: readonly ["Manual", "Again", "Hard", "Good", "Easy"];
17
+ export type ReviewRatingType = keyof typeof ReviewRating;
@@ -1,29 +1,63 @@
1
+ import type { ICard, Subject } from './deck';
2
+ import type { ReviewRating, ReviewState } from './fsrs';
1
3
  export type StudyType = 'ALL' | 'DECK' | 'TOPIC' | 'SUBJECT';
2
- export type Rating = 'Again' | 'Hard' | 'Good' | 'Easy';
3
- export type CardState = 'New' | 'Learning' | 'Review' | 'Relearning';
4
- export interface SessionStats {
4
+ export interface ICardReview {
5
+ id: string;
6
+ due: Date | null;
7
+ stability: number;
8
+ difficulty: number;
9
+ elapsedDays: number;
10
+ scheduledDays: number;
11
+ reps: number;
12
+ lapses: number;
13
+ state: ReviewState;
14
+ lastReview: Date | null;
15
+ userDeckStudyId: string;
16
+ cardId: string;
17
+ }
18
+ export interface IReviewLog {
19
+ id: number;
20
+ cardReviewId: string;
21
+ grade: ReviewRating;
22
+ state: ReviewState;
23
+ due: Date;
24
+ stability: number;
25
+ difficulty: number;
26
+ elapsedDays: number;
27
+ lastElapsedDays: number;
28
+ scheduledDays: number;
29
+ review: Date;
30
+ duration: number;
31
+ }
32
+ export interface ISessionCard {
33
+ card: ICard;
34
+ cardReview: ICardReview;
35
+ subject: Subject;
36
+ topicName: string;
37
+ userDeckStudyId: string;
38
+ }
39
+ export interface ISessionData {
40
+ reviewCards: ISessionCard[];
41
+ newCards: ISessionCard[];
42
+ stats: IStudyStats;
43
+ }
44
+ export interface IStudyStats {
5
45
  review: number;
6
46
  learning: number;
7
47
  new: number;
8
48
  total: number;
9
49
  }
10
- export interface GradeCardInput {
11
- cardId: string;
12
- userDeckStudyId: string;
13
- grade: Rating;
14
- reviewDurationInSeconds: number;
15
- }
16
- export interface GroupedLibraryItem {
50
+ export type StudyStatus = 'not-started' | 'suspended' | 'has-cards' | 'no-cards';
51
+ export interface IGroupedLibraryItem {
17
52
  name: string;
18
53
  id: string;
19
54
  ownerId?: string;
20
55
  type: StudyType;
21
- stats: SessionStats;
22
- subRows?: GroupedLibraryItem[];
56
+ stats: IStudyStats;
57
+ subRows?: IGroupedLibraryItem[];
23
58
  }
24
- export type GroupedLibraryData = GroupedLibraryItem[];
25
- export type StudyStatus = 'not-started' | 'suspended' | 'has-cards' | 'no-cards';
26
- export interface ArchivedLibraryItem {
59
+ export type IGroupedLibraryData = IGroupedLibraryItem[];
60
+ export interface IArchivedLibraryItem {
27
61
  deckId: string;
28
62
  subject: string;
29
63
  topic: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vestcards/server-types",
3
- "version": "0.5.0",
3
+ "version": "1.0.0",
4
4
  "private": false,
5
5
  "types": "./dist/index.d.ts",
6
6
  "exports": {
@@ -1,28 +0,0 @@
1
- import type { Subject } from '@vestcards/shared';
2
- import type { CardReview } from 'src/db/schema/deck';
3
- export type { CardState, GradeCardInput, Rating, SessionStats, StudyStatus, StudyType } from '@vestcards/shared';
4
- export interface ICard {
5
- id: string;
6
- question: string;
7
- answer: string | null;
8
- frontImage?: {
9
- id: string;
10
- url: string;
11
- };
12
- backImage?: {
13
- id: string;
14
- url: string;
15
- };
16
- }
17
- export type SessionCard = {
18
- card: ICard;
19
- card_review: CardReview;
20
- subject: Subject;
21
- topicName: string;
22
- userDeckStudyId: string;
23
- };
24
- export interface SessionData {
25
- reviewCards: SessionCard[];
26
- newCards: SessionCard[];
27
- stats: import('@vestcards/shared').SessionStats;
28
- }
@@ -1 +0,0 @@
1
- export type { Topic } from '@vestcards/shared';