@vestcards/server-types 0.1.0 → 0.3.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.
@@ -8,6 +8,13 @@ export declare abstract class StudyService {
8
8
  type: StudyType, id?: string): Promise<SessionStats>;
9
9
  static getReviewCards(userId: string, type: StudyType, id?: string, maxToFetch?: number): Promise<import("../../types/study").SessionCard[]>;
10
10
  static getNewCards(userId: string, allocatedNewForToday: number, type: StudyType, id?: string): Promise<import("../../types/study").SessionCard[]>;
11
+ static getUserDeckStudy(userId: string, deckId: string): Promise<{
12
+ suspended: boolean;
13
+ id: string;
14
+ createdAt: Date;
15
+ userId: string;
16
+ deckId: string;
17
+ }>;
11
18
  static getCardReview(userId: string, cardId: string): Promise<CardReview>;
12
19
  static gradeCard(userId: string, input: StudyModel.GradeCardBody): Promise<void>;
13
20
  }
@@ -1,3 +1,4 @@
1
+ import type { SessionStats, StudyStatus } from '@vestcards/shared';
1
2
  import type { SessionCard, StudyType } from 'src/types/study';
2
3
  import type { SessionCardSelect } from 'src/utils/select';
3
4
  export declare const getSessionFilterByStudyType: (type: StudyType, id?: string) => import("drizzle-orm").SQL<unknown> | undefined;
@@ -11,4 +12,7 @@ export declare const allocateByPriority: (capacityLeft: number, counts: {
11
12
  new: number;
12
13
  total: number;
13
14
  };
15
+ export declare function getStudyStatus(stats: SessionStats, userDeckStudy: {
16
+ suspended: boolean;
17
+ } | undefined): StudyStatus;
14
18
  export declare function sessionCardToICard(sessionRows: SessionCardSelect[]): SessionCard[];
@@ -42,7 +42,7 @@ export declare const topicModule: Elysia<"/v1/topics", {
42
42
  route: string;
43
43
  request: Request;
44
44
  store: {};
45
- status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 404 | 409 | 429 | 500 | 422 | 200 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 300 | 301 | 302 | 303 | 304 | 307 | 308 | 402 | 405 | 406 | 407 | 408 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 423 | 424 | 425 | 426 | 428 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
45
+ status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 404 | 409 | 429 | 500 | 100 | 101 | 102 | 103 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 300 | 301 | 302 | 303 | 304 | 307 | 308 | 402 | 405 | 406 | 407 | 408 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
46
46
  readonly 100: "Continue";
47
47
  readonly 101: "Switching Protocols";
48
48
  readonly 102: "Processing";
@@ -214,7 +214,7 @@ export declare const topicModule: Elysia<"/v1/topics", {
214
214
  route: string;
215
215
  request: Request;
216
216
  store: {};
217
- status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 404 | 409 | 429 | 500 | 422 | 200 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 300 | 301 | 302 | 303 | 304 | 307 | 308 | 402 | 405 | 406 | 407 | 408 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 423 | 424 | 425 | 426 | 428 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
217
+ status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 404 | 409 | 429 | 500 | 100 | 101 | 102 | 103 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 300 | 301 | 302 | 303 | 304 | 307 | 308 | 402 | 405 | 406 | 407 | 408 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
218
218
  readonly 100: "Continue";
219
219
  readonly 101: "Switching Protocols";
220
220
  readonly 102: "Processing";
@@ -364,6 +364,11 @@ export declare const topicModule: Elysia<"/v1/topics", {
364
364
  };
365
365
  headers: unknown;
366
366
  response: {
367
+ 200: {
368
+ data: import("@vestcards/shared").Topic[];
369
+ pageCount: number;
370
+ total: number;
371
+ };
367
372
  422: {
368
373
  type: "validation";
369
374
  on: string;
@@ -373,26 +378,6 @@ export declare const topicModule: Elysia<"/v1/topics", {
373
378
  property?: string;
374
379
  expected?: string;
375
380
  };
376
- 200: {
377
- error: string;
378
- message: string;
379
- path: any;
380
- details?: undefined;
381
- } | {
382
- error: string;
383
- message: string;
384
- details: any;
385
- path?: undefined;
386
- } | {
387
- error: string;
388
- message: string;
389
- path?: undefined;
390
- details?: undefined;
391
- } | {
392
- data: import("@vestcards/shared").Topic[];
393
- pageCount: number;
394
- total: number;
395
- };
396
381
  };
397
382
  };
398
383
  };
@@ -409,21 +394,8 @@ export declare const topicModule: Elysia<"/v1/topics", {
409
394
  schema: {};
410
395
  standaloneSchema: {};
411
396
  response: {
412
- 200: {
413
- error: string;
414
- message: string;
415
- path: any;
416
- details?: undefined;
417
- } | {
418
- error: string;
419
- message: string;
420
- details: any;
421
- path?: undefined;
422
- } | {
423
- error: string;
424
- message: string;
425
- path?: undefined;
426
- details?: undefined;
397
+ [x: string]: {
398
+ [x: string]: any;
427
399
  };
428
400
  };
429
401
  }>;
@@ -42,7 +42,7 @@ export declare const userModule: Elysia<"/v1/user", {
42
42
  route: string;
43
43
  request: Request;
44
44
  store: {};
45
- status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 404 | 409 | 429 | 500 | 422 | 200 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 300 | 301 | 302 | 303 | 304 | 307 | 308 | 402 | 405 | 406 | 407 | 408 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 423 | 424 | 425 | 426 | 428 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
45
+ status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 404 | 409 | 429 | 500 | 100 | 101 | 102 | 103 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 300 | 301 | 302 | 303 | 304 | 307 | 308 | 402 | 405 | 406 | 407 | 408 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
46
46
  readonly 100: "Continue";
47
47
  readonly 101: "Switching Protocols";
48
48
  readonly 102: "Processing";
@@ -214,7 +214,7 @@ export declare const userModule: Elysia<"/v1/user", {
214
214
  route: string;
215
215
  request: Request;
216
216
  store: {};
217
- status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 404 | 409 | 429 | 500 | 422 | 200 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 300 | 301 | 302 | 303 | 304 | 307 | 308 | 402 | 405 | 406 | 407 | 408 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 423 | 424 | 425 | 426 | 428 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
217
+ status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 404 | 409 | 429 | 500 | 100 | 101 | 102 | 103 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 300 | 301 | 302 | 303 | 304 | 307 | 308 | 402 | 405 | 406 | 407 | 408 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
218
218
  readonly 100: "Continue";
219
219
  readonly 101: "Switching Protocols";
220
220
  readonly 102: "Processing";
@@ -360,21 +360,8 @@ export declare const userModule: Elysia<"/v1/user", {
360
360
  schema: {};
361
361
  standaloneSchema: {};
362
362
  response: {
363
- 200: {
364
- error: string;
365
- message: string;
366
- path: any;
367
- details?: undefined;
368
- } | {
369
- error: string;
370
- message: string;
371
- details: any;
372
- path?: undefined;
373
- } | {
374
- error: string;
375
- message: string;
376
- path?: undefined;
377
- details?: undefined;
363
+ [x: string]: {
364
+ [x: string]: any;
378
365
  };
379
366
  };
380
367
  }>;
@@ -102,11 +102,11 @@ export declare function createUserDeckStudy(data: {
102
102
  userId: string;
103
103
  suspended?: boolean;
104
104
  }): Promise<{
105
+ suspended: boolean;
105
106
  id: string;
106
107
  createdAt: Date;
107
108
  userId: string;
108
109
  deckId: string;
109
- suspended: boolean;
110
110
  }>;
111
111
  /**
112
112
  * Create a card review for a user deck study
@@ -26,6 +26,10 @@ export declare function post<TResponse = unknown, TBody = unknown>(path: string,
26
26
  * PUT request
27
27
  */
28
28
  export declare function put<TResponse = unknown, TBody = unknown>(path: string, body: TBody, cookie?: string): Promise<HttpResponse<TResponse>>;
29
+ /**
30
+ * PATCH request
31
+ */
32
+ export declare function patch<TResponse = unknown, TBody = unknown>(path: string, body: TBody, cookie?: string): Promise<HttpResponse<TResponse>>;
29
33
  /**
30
34
  * DELETE request
31
35
  */
@@ -1,6 +1,6 @@
1
1
  import type { Subject } from '@vestcards/shared';
2
2
  import type { CardReview } from 'src/db/schema/deck';
3
- export type { CardState, GradeCardInput, Rating, SessionStats, StudyType } from '@vestcards/shared';
3
+ export type { CardState, GradeCardInput, Rating, SessionStats, StudyStatus, StudyType } from '@vestcards/shared';
4
4
  export interface ICard {
5
5
  id: string;
6
6
  question: string;
@@ -10,7 +10,6 @@ export interface ICard {
10
10
  id: string;
11
11
  question: string;
12
12
  answer: string | null;
13
- order: number;
14
13
  frontImage?: {
15
14
  id: string;
16
15
  url: string;
@@ -13,3 +13,20 @@ export interface GradeCardInput {
13
13
  grade: Rating;
14
14
  reviewDurationInSeconds: number;
15
15
  }
16
+ export interface GroupedLibraryItem {
17
+ name: string;
18
+ id: string;
19
+ ownerId?: string;
20
+ type: StudyType;
21
+ stats: SessionStats;
22
+ subRows?: GroupedLibraryItem[];
23
+ }
24
+ export type GroupedLibraryData = GroupedLibraryItem[];
25
+ export type StudyStatus = 'not-started' | 'suspended' | 'has-cards' | 'no-cards';
26
+ export interface ArchivedLibraryItem {
27
+ deckId: string;
28
+ subject: string;
29
+ topic: string;
30
+ title: string;
31
+ ownerId?: string;
32
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vestcards/server-types",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "private": false,
5
5
  "types": "./dist/index.d.ts",
6
6
  "exports": {