@vue-skuilder/db 0.1.11 → 0.1.12

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.
Files changed (53) hide show
  1. package/dist/core/index.d.mts +7 -6
  2. package/dist/core/index.d.ts +7 -6
  3. package/dist/core/index.js +146 -37
  4. package/dist/core/index.js.map +1 -1
  5. package/dist/core/index.mjs +146 -37
  6. package/dist/core/index.mjs.map +1 -1
  7. package/dist/{dataLayerProvider-VieuAAkV.d.mts → dataLayerProvider-BiP3kWix.d.mts} +1 -1
  8. package/dist/{dataLayerProvider-juuqUHOP.d.ts → dataLayerProvider-DSdeyRT3.d.ts} +1 -1
  9. package/dist/impl/couch/index.d.mts +3 -3
  10. package/dist/impl/couch/index.d.ts +3 -3
  11. package/dist/impl/couch/index.js +146 -37
  12. package/dist/impl/couch/index.js.map +1 -1
  13. package/dist/impl/couch/index.mjs +146 -37
  14. package/dist/impl/couch/index.mjs.map +1 -1
  15. package/dist/impl/static/index.d.mts +14 -6
  16. package/dist/impl/static/index.d.ts +14 -6
  17. package/dist/impl/static/index.js +147 -39
  18. package/dist/impl/static/index.js.map +1 -1
  19. package/dist/impl/static/index.mjs +147 -39
  20. package/dist/impl/static/index.mjs.map +1 -1
  21. package/dist/{index-DZyxHCcf.d.mts → index-Bmll7Xse.d.mts} +1 -1
  22. package/dist/{index-CWY6yhkV.d.ts → index-CD8BZz2k.d.ts} +1 -1
  23. package/dist/index.d.mts +119 -24
  24. package/dist/index.d.ts +119 -24
  25. package/dist/index.js +785 -261
  26. package/dist/index.js.map +1 -1
  27. package/dist/index.mjs +789 -265
  28. package/dist/index.mjs.map +1 -1
  29. package/dist/{types-DtoI27Xh.d.ts → types-CewsN87z.d.ts} +1 -1
  30. package/dist/{types-Che4wTwA.d.mts → types-Dbp5DaRR.d.mts} +1 -1
  31. package/dist/{types-legacy-B8ahaCbj.d.mts → types-legacy-6ettoclI.d.mts} +13 -2
  32. package/dist/{types-legacy-B8ahaCbj.d.ts → types-legacy-6ettoclI.d.ts} +13 -2
  33. package/dist/{userDB-DJ8HMw83.d.mts → userDB-C4yyAnpp.d.mts} +3 -3
  34. package/dist/{userDB-B7zTQ123.d.ts → userDB-CD6s6ZCp.d.ts} +3 -3
  35. package/dist/util/packer/index.d.mts +3 -3
  36. package/dist/util/packer/index.d.ts +3 -3
  37. package/package.json +3 -3
  38. package/src/core/navigators/hardcodedOrder.ts +64 -0
  39. package/src/core/navigators/index.ts +1 -0
  40. package/src/core/types/contentNavigationStrategy.ts +2 -1
  41. package/src/core/types/types-legacy.ts +2 -2
  42. package/src/impl/common/BaseUserDB.ts +15 -11
  43. package/src/impl/couch/courseDB.ts +74 -27
  44. package/src/impl/couch/updateQueue.ts +8 -3
  45. package/src/impl/static/StaticDataLayerProvider.ts +57 -17
  46. package/src/impl/static/courseDB.ts +17 -12
  47. package/src/impl/static/coursesDB.ts +10 -6
  48. package/src/study/ItemQueue.ts +58 -0
  49. package/src/study/SessionController.ts +132 -178
  50. package/src/study/services/CardHydrationService.ts +153 -0
  51. package/src/study/services/EloService.ts +85 -0
  52. package/src/study/services/ResponseProcessor.ts +224 -0
  53. package/src/study/services/SrsService.ts +44 -0
@@ -1,4 +1,4 @@
1
- import { P as PackerConfig, a as PackedCourseData, S as StaticCourseManifest } from './types-Che4wTwA.mjs';
1
+ import { P as PackerConfig, a as PackedCourseData, S as StaticCourseManifest } from './types-Dbp5DaRR.mjs';
2
2
 
3
3
  /**
4
4
  * Abstraction for file system operations needed by the migrator.
@@ -1,4 +1,4 @@
1
- import { P as PackerConfig, a as PackedCourseData, S as StaticCourseManifest } from './types-DtoI27Xh.js';
1
+ import { P as PackerConfig, a as PackedCourseData, S as StaticCourseManifest } from './types-CewsN87z.js';
2
2
 
3
3
  /**
4
4
  * Abstraction for file system operations needed by the migrator.
package/dist/index.d.mts CHANGED
@@ -1,17 +1,90 @@
1
- import { k as StudySessionItem, i as StudyContentSource } from './userDB-DJ8HMw83.mjs';
2
- export { G as ActivityRecord, A as AdminDBInterface, t as AssignedCard, h as AssignedContent, s as AssignedCourse, r as AssignedTag, c as ClassroomDBInterface, B as ClassroomRegistration, z as ClassroomRegistrationDesignation, E as ClassroomRegistrationDoc, p as ContentSourceID, C as CourseDBInterface, d as CourseInfo, H as CourseRegistration, I as CourseRegistrationDoc, b as CoursesDBInterface, J as DocumentUpdater, g as ScheduledCard, j as StudentClassroomDBInterface, l as StudySessionFailedItem, m as StudySessionFailedNewItem, n as StudySessionFailedReviewItem, S as StudySessionNewItem, f as StudySessionReviewItem, T as TeacherClassroomDBInterface, F as UserConfig, x as UserCourseSetting, w as UserCourseSettings, v as UserDBAuthenticator, U as UserDBInterface, a as UserDBReader, u as UserDBWriter, y as UsrCrsDataInterface, q as getStudySource, o as isReview, K as newInterval } from './userDB-DJ8HMw83.mjs';
3
- import { D as DataLayerProvider } from './dataLayerProvider-VieuAAkV.mjs';
4
- import { C as CardRecord } from './types-legacy-B8ahaCbj.mjs';
5
- export { b as CardData, h as CardHistory, c as CourseListData, e as DataShapeData, d as DisplayableData, D as DocType, g as DocTypePrefixes, F as Field, G as GuestUsername, Q as QualifiedCardID, f as QuestionData, i as QuestionRecord, S as SkuilderCourseData, a as Tag, T as TagStub, l as log } from './types-legacy-B8ahaCbj.mjs';
1
+ import { U as UserDBInterface, r as CourseRegistrationDoc, k as StudySessionItem, i as StudyContentSource } from './userDB-C4yyAnpp.mjs';
2
+ export { H as ActivityRecord, A as AdminDBInterface, u as AssignedCard, h as AssignedContent, t as AssignedCourse, s as AssignedTag, c as ClassroomDBInterface, E as ClassroomRegistration, B as ClassroomRegistrationDesignation, F as ClassroomRegistrationDoc, p as ContentSourceID, C as CourseDBInterface, d as CourseInfo, I as CourseRegistration, b as CoursesDBInterface, J as DocumentUpdater, g as ScheduledCard, j as StudentClassroomDBInterface, l as StudySessionFailedItem, m as StudySessionFailedNewItem, n as StudySessionFailedReviewItem, S as StudySessionNewItem, f as StudySessionReviewItem, T as TeacherClassroomDBInterface, G as UserConfig, y as UserCourseSetting, x as UserCourseSettings, w as UserDBAuthenticator, a as UserDBReader, v as UserDBWriter, z as UsrCrsDataInterface, q as getStudySource, o as isReview, K as newInterval } from './userDB-C4yyAnpp.mjs';
3
+ import { D as DataLayerProvider } from './dataLayerProvider-BiP3kWix.mjs';
4
+ import { C as CardHistory, c as CardRecord } from './types-legacy-6ettoclI.mjs';
5
+ export { d as CardData, e as CourseListData, g as DataShapeData, f as DisplayableData, D as DocType, b as DocTypePrefixes, F as Field, G as GuestUsername, Q as QualifiedCardID, h as QuestionData, i as QuestionRecord, S as SkuilderCourseData, a as Tag, T as TagStub, l as log } from './types-legacy-6ettoclI.mjs';
6
6
  import { Loggable } from './core/index.mjs';
7
7
  export { BulkCardProcessorConfig, ContentNavigator, ImportResult, Navigators, areQuestionRecords, docIsDeleted, getCardHistoryID, importParsedCards, isQuestionRecord, parseCardHistoryID, validateProcessorConfig } from './core/index.mjs';
8
- import { ViewData } from '@vue-skuilder/common';
9
- import { S as StaticCourseManifest } from './types-Che4wTwA.mjs';
10
- export { A as AttachmentData, C as ChunkMetadata, D as DesignDocument, I as IndexMetadata, a as PackedCourseData, P as PackerConfig } from './types-Che4wTwA.mjs';
11
- import { F as FileSystemAdapter } from './index-DZyxHCcf.mjs';
12
- export { C as CouchDBToStaticPacker, a as FileStats, b as FileSystemError } from './index-DZyxHCcf.mjs';
8
+ import { S as StaticCourseManifest } from './types-Dbp5DaRR.mjs';
9
+ export { A as AttachmentData, C as ChunkMetadata, D as DesignDocument, I as IndexMetadata, a as PackedCourseData, P as PackerConfig } from './types-Dbp5DaRR.mjs';
10
+ import { F as FileSystemAdapter } from './index-Bmll7Xse.mjs';
11
+ export { C as CouchDBToStaticPacker, a as FileStats, b as FileSystemError } from './index-Bmll7Xse.mjs';
12
+ import '@vue-skuilder/common';
13
13
  import 'moment';
14
14
 
15
+ /**
16
+ * Service responsible for ELO rating calculations and updates.
17
+ */
18
+ declare class EloService {
19
+ private dataLayer;
20
+ private user;
21
+ constructor(dataLayer: DataLayerProvider, user: UserDBInterface);
22
+ /**
23
+ * Updates both user and card ELO ratings based on user performance.
24
+ * @param userScore Score between 0-1 representing user performance
25
+ * @param course_id Course identifier
26
+ * @param card_id Card identifier
27
+ * @param userCourseRegDoc User's course registration document (will be mutated)
28
+ * @param currentCard Current card session record
29
+ * @param k Optional K-factor for ELO calculation
30
+ */
31
+ updateUserAndCardElo(userScore: number, course_id: string, card_id: string, userCourseRegDoc: CourseRegistrationDoc, currentCard: StudySessionRecord, k?: number): Promise<void>;
32
+ }
33
+
34
+ /**
35
+ * Service responsible for Spaced Repetition System (SRS) scheduling logic.
36
+ */
37
+ declare class SrsService {
38
+ private user;
39
+ constructor(user: UserDBInterface);
40
+ /**
41
+ * Calculates the next review time for a card based on its history and
42
+ * schedules it in the user's database.
43
+ * @param history The full history of the card.
44
+ * @param item The study session item, used to determine if a previous review needs to be cleared.
45
+ */
46
+ scheduleReview(history: CardHistory<CardRecord>, item: StudySessionItem): Promise<void>;
47
+ }
48
+
49
+ /**
50
+ * Service responsible for orchestrating the complete response processing workflow.
51
+ * Coordinates SRS scheduling and ELO updates for user card interactions.
52
+ */
53
+ declare class ResponseProcessor {
54
+ private srsService;
55
+ private eloService;
56
+ constructor(srsService: SrsService, eloService: EloService);
57
+ /**
58
+ * Processes a user's response to a card, handling SRS scheduling and ELO updates.
59
+ * @param cardRecord User's response record
60
+ * @param cardHistory Promise resolving to the card's history
61
+ * @param studySessionItem Current study session item
62
+ * @param courseRegistrationDoc User's course registration (for ELO updates)
63
+ * @param currentCard Current study session record
64
+ * @param courseId Course identifier
65
+ * @param cardId Card identifier
66
+ * @param maxAttemptsPerView Maximum attempts allowed per view
67
+ * @param maxSessionViews Maximum session views for this card
68
+ * @param sessionViews Current number of session views
69
+ * @returns ResponseResult with navigation and UI instructions
70
+ */
71
+ processResponse(cardRecord: CardRecord, cardHistory: Promise<CardHistory<CardRecord>>, studySessionItem: StudySessionItem, courseRegistrationDoc: CourseRegistrationDoc, currentCard: StudySessionRecord, courseId: string, cardId: string, maxAttemptsPerView: number, maxSessionViews: number, sessionViews: number): Promise<ResponseResult>;
72
+ /**
73
+ * Handles processing for correct responses: SRS scheduling and ELO updates.
74
+ */
75
+ private processCorrectResponse;
76
+ /**
77
+ * Handles processing for incorrect responses: ELO updates only.
78
+ */
79
+ private processIncorrectResponse;
80
+ }
81
+
82
+ interface HydratedCard<TView = unknown> {
83
+ item: StudySessionItem;
84
+ view: TView;
85
+ data: any[];
86
+ }
87
+
15
88
  interface MigrationOptions {
16
89
  chunkBatchSize: number;
17
90
  validateRoundTrip: boolean;
@@ -203,25 +276,31 @@ interface StudySessionRecord {
203
276
  item: StudySessionItem;
204
277
  records: CardRecord[];
205
278
  }
206
- interface HydratedCard<TView = unknown> {
207
- item: StudySessionItem;
208
- view: TView;
209
- data: ViewData[];
210
- }
211
279
 
280
+ type SessionAction = 'dismiss-success' | 'dismiss-failed' | 'marked-failed' | 'dismiss-error';
281
+ interface ResponseResult {
282
+ nextCardAction: Exclude<SessionAction, 'dismiss-error'> | 'none';
283
+ shouldLoadNextCard: boolean;
284
+ isCorrect: boolean;
285
+ performanceScore?: number;
286
+ shouldClearFeedbackShadow: boolean;
287
+ }
288
+ interface SessionServices {
289
+ response: ResponseProcessor;
290
+ }
212
291
  declare class SessionController<TView = unknown> extends Loggable {
213
292
  _className: string;
293
+ services: SessionServices;
294
+ private srsService;
295
+ private eloService;
296
+ private hydrationService;
214
297
  private sources;
215
- private dataLayer;
216
- private getViewComponent;
217
298
  private _sessionRecord;
218
299
  set sessionRecord(r: StudySessionRecord[]);
300
+ private _currentCard;
219
301
  private reviewQ;
220
302
  private newQ;
221
303
  private failedQ;
222
- private hydratedQ;
223
- private _currentCard;
224
- private hydration_in_progress;
225
304
  private startTime;
226
305
  private endTime;
227
306
  private _secondsRemaining;
@@ -255,11 +334,27 @@ declare class SessionController<TView = unknown> extends Loggable {
255
334
  private getScheduledReviews;
256
335
  private getNewCards;
257
336
  private _selectNextItemToHydrate;
258
- nextCard(action?: 'dismiss-success' | 'dismiss-failed' | 'marked-failed' | 'dismiss-error'): Promise<HydratedCard<TView> | null>;
337
+ nextCard(action?: SessionAction): Promise<HydratedCard<TView> | null>;
338
+ /**
339
+ * Public API for processing user responses to cards.
340
+ * @param cardRecord User's response record
341
+ * @param cardHistory Promise resolving to the card's history
342
+ * @param courseRegistrationDoc User's course registration document
343
+ * @param currentCard Current study session record
344
+ * @param courseId Course identifier
345
+ * @param cardId Card identifier
346
+ * @param maxAttemptsPerView Maximum attempts allowed per view
347
+ * @param maxSessionViews Maximum session views for this card
348
+ * @param sessionViews Current number of session views
349
+ * @returns ResponseResult with navigation and UI instructions
350
+ */
351
+ submitResponse(cardRecord: CardRecord, cardHistory: Promise<CardHistory<CardRecord>>, courseRegistrationDoc: CourseRegistrationDoc, currentCard: StudySessionRecord, courseId: string, cardId: string, maxAttemptsPerView: number, maxSessionViews: number, sessionViews: number): Promise<ResponseResult>;
259
352
  private dismissCurrentCard;
260
353
  private hasAvailableCards;
261
- private nextHydratedCard;
262
- private _fillHydratedQueue;
354
+ /**
355
+ * Helper method for CardHydrationService to remove items from appropriate queue.
356
+ */
357
+ private removeItemFromQueue;
263
358
  }
264
359
 
265
360
  interface CourseLookupDoc {
@@ -341,4 +436,4 @@ declare function getDataLayer(): DataLayerProvider;
341
436
  */
342
437
  declare function _resetDataLayer(): Promise<void>;
343
438
 
344
- export { type AggregatedDocument, type AttachmentUploadResult, CardRecord, CourseLookup, DEFAULT_MIGRATION_OPTIONS, type DataLayerConfig, DataLayerProvider, type DocumentCounts, ENV, FileSystemAdapter, type HydratedCard, Loggable, type MigrationOptions, type MigrationResult, NOT_SET, type RestoreProgress, SessionController, StaticCourseManifest, type StaticCourseValidation, StaticToCouchDBMigrator, StudyContentSource, StudySessionItem, type StudySessionRecord, type ValidationIssue, type ValidationResult, _resetDataLayer, ensureAppDataDirectory, getAppDataDirectory, getDataLayer, getDbPath, getLogFilePath, initializeDataDirectory, initializeDataLayer, initializeTuiLogging, logger, showUserError, showUserMessage, validateMigration, validateStaticCourse };
439
+ export { type AggregatedDocument, type AttachmentUploadResult, CardHistory, CardRecord, CourseLookup, CourseRegistrationDoc, DEFAULT_MIGRATION_OPTIONS, type DataLayerConfig, DataLayerProvider, type DocumentCounts, ENV, FileSystemAdapter, Loggable, type MigrationOptions, type MigrationResult, NOT_SET, type ResponseResult, type RestoreProgress, type SessionAction, SessionController, StaticCourseManifest, type StaticCourseValidation, StaticToCouchDBMigrator, StudyContentSource, StudySessionItem, type StudySessionRecord, UserDBInterface, type ValidationIssue, type ValidationResult, _resetDataLayer, ensureAppDataDirectory, getAppDataDirectory, getDataLayer, getDbPath, getLogFilePath, initializeDataDirectory, initializeDataLayer, initializeTuiLogging, logger, showUserError, showUserMessage, validateMigration, validateStaticCourse };
package/dist/index.d.ts CHANGED
@@ -1,17 +1,90 @@
1
- import { k as StudySessionItem, i as StudyContentSource } from './userDB-B7zTQ123.js';
2
- export { G as ActivityRecord, A as AdminDBInterface, t as AssignedCard, h as AssignedContent, s as AssignedCourse, r as AssignedTag, c as ClassroomDBInterface, B as ClassroomRegistration, z as ClassroomRegistrationDesignation, E as ClassroomRegistrationDoc, p as ContentSourceID, C as CourseDBInterface, d as CourseInfo, H as CourseRegistration, I as CourseRegistrationDoc, b as CoursesDBInterface, J as DocumentUpdater, g as ScheduledCard, j as StudentClassroomDBInterface, l as StudySessionFailedItem, m as StudySessionFailedNewItem, n as StudySessionFailedReviewItem, S as StudySessionNewItem, f as StudySessionReviewItem, T as TeacherClassroomDBInterface, F as UserConfig, x as UserCourseSetting, w as UserCourseSettings, v as UserDBAuthenticator, U as UserDBInterface, a as UserDBReader, u as UserDBWriter, y as UsrCrsDataInterface, q as getStudySource, o as isReview, K as newInterval } from './userDB-B7zTQ123.js';
3
- import { D as DataLayerProvider } from './dataLayerProvider-juuqUHOP.js';
4
- import { C as CardRecord } from './types-legacy-B8ahaCbj.js';
5
- export { b as CardData, h as CardHistory, c as CourseListData, e as DataShapeData, d as DisplayableData, D as DocType, g as DocTypePrefixes, F as Field, G as GuestUsername, Q as QualifiedCardID, f as QuestionData, i as QuestionRecord, S as SkuilderCourseData, a as Tag, T as TagStub, l as log } from './types-legacy-B8ahaCbj.js';
1
+ import { U as UserDBInterface, r as CourseRegistrationDoc, k as StudySessionItem, i as StudyContentSource } from './userDB-CD6s6ZCp.js';
2
+ export { H as ActivityRecord, A as AdminDBInterface, u as AssignedCard, h as AssignedContent, t as AssignedCourse, s as AssignedTag, c as ClassroomDBInterface, E as ClassroomRegistration, B as ClassroomRegistrationDesignation, F as ClassroomRegistrationDoc, p as ContentSourceID, C as CourseDBInterface, d as CourseInfo, I as CourseRegistration, b as CoursesDBInterface, J as DocumentUpdater, g as ScheduledCard, j as StudentClassroomDBInterface, l as StudySessionFailedItem, m as StudySessionFailedNewItem, n as StudySessionFailedReviewItem, S as StudySessionNewItem, f as StudySessionReviewItem, T as TeacherClassroomDBInterface, G as UserConfig, y as UserCourseSetting, x as UserCourseSettings, w as UserDBAuthenticator, a as UserDBReader, v as UserDBWriter, z as UsrCrsDataInterface, q as getStudySource, o as isReview, K as newInterval } from './userDB-CD6s6ZCp.js';
3
+ import { D as DataLayerProvider } from './dataLayerProvider-DSdeyRT3.js';
4
+ import { C as CardHistory, c as CardRecord } from './types-legacy-6ettoclI.js';
5
+ export { d as CardData, e as CourseListData, g as DataShapeData, f as DisplayableData, D as DocType, b as DocTypePrefixes, F as Field, G as GuestUsername, Q as QualifiedCardID, h as QuestionData, i as QuestionRecord, S as SkuilderCourseData, a as Tag, T as TagStub, l as log } from './types-legacy-6ettoclI.js';
6
6
  import { Loggable } from './core/index.js';
7
7
  export { BulkCardProcessorConfig, ContentNavigator, ImportResult, Navigators, areQuestionRecords, docIsDeleted, getCardHistoryID, importParsedCards, isQuestionRecord, parseCardHistoryID, validateProcessorConfig } from './core/index.js';
8
- import { ViewData } from '@vue-skuilder/common';
9
- import { S as StaticCourseManifest } from './types-DtoI27Xh.js';
10
- export { A as AttachmentData, C as ChunkMetadata, D as DesignDocument, I as IndexMetadata, a as PackedCourseData, P as PackerConfig } from './types-DtoI27Xh.js';
11
- import { F as FileSystemAdapter } from './index-CWY6yhkV.js';
12
- export { C as CouchDBToStaticPacker, a as FileStats, b as FileSystemError } from './index-CWY6yhkV.js';
8
+ import { S as StaticCourseManifest } from './types-CewsN87z.js';
9
+ export { A as AttachmentData, C as ChunkMetadata, D as DesignDocument, I as IndexMetadata, a as PackedCourseData, P as PackerConfig } from './types-CewsN87z.js';
10
+ import { F as FileSystemAdapter } from './index-CD8BZz2k.js';
11
+ export { C as CouchDBToStaticPacker, a as FileStats, b as FileSystemError } from './index-CD8BZz2k.js';
12
+ import '@vue-skuilder/common';
13
13
  import 'moment';
14
14
 
15
+ /**
16
+ * Service responsible for ELO rating calculations and updates.
17
+ */
18
+ declare class EloService {
19
+ private dataLayer;
20
+ private user;
21
+ constructor(dataLayer: DataLayerProvider, user: UserDBInterface);
22
+ /**
23
+ * Updates both user and card ELO ratings based on user performance.
24
+ * @param userScore Score between 0-1 representing user performance
25
+ * @param course_id Course identifier
26
+ * @param card_id Card identifier
27
+ * @param userCourseRegDoc User's course registration document (will be mutated)
28
+ * @param currentCard Current card session record
29
+ * @param k Optional K-factor for ELO calculation
30
+ */
31
+ updateUserAndCardElo(userScore: number, course_id: string, card_id: string, userCourseRegDoc: CourseRegistrationDoc, currentCard: StudySessionRecord, k?: number): Promise<void>;
32
+ }
33
+
34
+ /**
35
+ * Service responsible for Spaced Repetition System (SRS) scheduling logic.
36
+ */
37
+ declare class SrsService {
38
+ private user;
39
+ constructor(user: UserDBInterface);
40
+ /**
41
+ * Calculates the next review time for a card based on its history and
42
+ * schedules it in the user's database.
43
+ * @param history The full history of the card.
44
+ * @param item The study session item, used to determine if a previous review needs to be cleared.
45
+ */
46
+ scheduleReview(history: CardHistory<CardRecord>, item: StudySessionItem): Promise<void>;
47
+ }
48
+
49
+ /**
50
+ * Service responsible for orchestrating the complete response processing workflow.
51
+ * Coordinates SRS scheduling and ELO updates for user card interactions.
52
+ */
53
+ declare class ResponseProcessor {
54
+ private srsService;
55
+ private eloService;
56
+ constructor(srsService: SrsService, eloService: EloService);
57
+ /**
58
+ * Processes a user's response to a card, handling SRS scheduling and ELO updates.
59
+ * @param cardRecord User's response record
60
+ * @param cardHistory Promise resolving to the card's history
61
+ * @param studySessionItem Current study session item
62
+ * @param courseRegistrationDoc User's course registration (for ELO updates)
63
+ * @param currentCard Current study session record
64
+ * @param courseId Course identifier
65
+ * @param cardId Card identifier
66
+ * @param maxAttemptsPerView Maximum attempts allowed per view
67
+ * @param maxSessionViews Maximum session views for this card
68
+ * @param sessionViews Current number of session views
69
+ * @returns ResponseResult with navigation and UI instructions
70
+ */
71
+ processResponse(cardRecord: CardRecord, cardHistory: Promise<CardHistory<CardRecord>>, studySessionItem: StudySessionItem, courseRegistrationDoc: CourseRegistrationDoc, currentCard: StudySessionRecord, courseId: string, cardId: string, maxAttemptsPerView: number, maxSessionViews: number, sessionViews: number): Promise<ResponseResult>;
72
+ /**
73
+ * Handles processing for correct responses: SRS scheduling and ELO updates.
74
+ */
75
+ private processCorrectResponse;
76
+ /**
77
+ * Handles processing for incorrect responses: ELO updates only.
78
+ */
79
+ private processIncorrectResponse;
80
+ }
81
+
82
+ interface HydratedCard<TView = unknown> {
83
+ item: StudySessionItem;
84
+ view: TView;
85
+ data: any[];
86
+ }
87
+
15
88
  interface MigrationOptions {
16
89
  chunkBatchSize: number;
17
90
  validateRoundTrip: boolean;
@@ -203,25 +276,31 @@ interface StudySessionRecord {
203
276
  item: StudySessionItem;
204
277
  records: CardRecord[];
205
278
  }
206
- interface HydratedCard<TView = unknown> {
207
- item: StudySessionItem;
208
- view: TView;
209
- data: ViewData[];
210
- }
211
279
 
280
+ type SessionAction = 'dismiss-success' | 'dismiss-failed' | 'marked-failed' | 'dismiss-error';
281
+ interface ResponseResult {
282
+ nextCardAction: Exclude<SessionAction, 'dismiss-error'> | 'none';
283
+ shouldLoadNextCard: boolean;
284
+ isCorrect: boolean;
285
+ performanceScore?: number;
286
+ shouldClearFeedbackShadow: boolean;
287
+ }
288
+ interface SessionServices {
289
+ response: ResponseProcessor;
290
+ }
212
291
  declare class SessionController<TView = unknown> extends Loggable {
213
292
  _className: string;
293
+ services: SessionServices;
294
+ private srsService;
295
+ private eloService;
296
+ private hydrationService;
214
297
  private sources;
215
- private dataLayer;
216
- private getViewComponent;
217
298
  private _sessionRecord;
218
299
  set sessionRecord(r: StudySessionRecord[]);
300
+ private _currentCard;
219
301
  private reviewQ;
220
302
  private newQ;
221
303
  private failedQ;
222
- private hydratedQ;
223
- private _currentCard;
224
- private hydration_in_progress;
225
304
  private startTime;
226
305
  private endTime;
227
306
  private _secondsRemaining;
@@ -255,11 +334,27 @@ declare class SessionController<TView = unknown> extends Loggable {
255
334
  private getScheduledReviews;
256
335
  private getNewCards;
257
336
  private _selectNextItemToHydrate;
258
- nextCard(action?: 'dismiss-success' | 'dismiss-failed' | 'marked-failed' | 'dismiss-error'): Promise<HydratedCard<TView> | null>;
337
+ nextCard(action?: SessionAction): Promise<HydratedCard<TView> | null>;
338
+ /**
339
+ * Public API for processing user responses to cards.
340
+ * @param cardRecord User's response record
341
+ * @param cardHistory Promise resolving to the card's history
342
+ * @param courseRegistrationDoc User's course registration document
343
+ * @param currentCard Current study session record
344
+ * @param courseId Course identifier
345
+ * @param cardId Card identifier
346
+ * @param maxAttemptsPerView Maximum attempts allowed per view
347
+ * @param maxSessionViews Maximum session views for this card
348
+ * @param sessionViews Current number of session views
349
+ * @returns ResponseResult with navigation and UI instructions
350
+ */
351
+ submitResponse(cardRecord: CardRecord, cardHistory: Promise<CardHistory<CardRecord>>, courseRegistrationDoc: CourseRegistrationDoc, currentCard: StudySessionRecord, courseId: string, cardId: string, maxAttemptsPerView: number, maxSessionViews: number, sessionViews: number): Promise<ResponseResult>;
259
352
  private dismissCurrentCard;
260
353
  private hasAvailableCards;
261
- private nextHydratedCard;
262
- private _fillHydratedQueue;
354
+ /**
355
+ * Helper method for CardHydrationService to remove items from appropriate queue.
356
+ */
357
+ private removeItemFromQueue;
263
358
  }
264
359
 
265
360
  interface CourseLookupDoc {
@@ -341,4 +436,4 @@ declare function getDataLayer(): DataLayerProvider;
341
436
  */
342
437
  declare function _resetDataLayer(): Promise<void>;
343
438
 
344
- export { type AggregatedDocument, type AttachmentUploadResult, CardRecord, CourseLookup, DEFAULT_MIGRATION_OPTIONS, type DataLayerConfig, DataLayerProvider, type DocumentCounts, ENV, FileSystemAdapter, type HydratedCard, Loggable, type MigrationOptions, type MigrationResult, NOT_SET, type RestoreProgress, SessionController, StaticCourseManifest, type StaticCourseValidation, StaticToCouchDBMigrator, StudyContentSource, StudySessionItem, type StudySessionRecord, type ValidationIssue, type ValidationResult, _resetDataLayer, ensureAppDataDirectory, getAppDataDirectory, getDataLayer, getDbPath, getLogFilePath, initializeDataDirectory, initializeDataLayer, initializeTuiLogging, logger, showUserError, showUserMessage, validateMigration, validateStaticCourse };
439
+ export { type AggregatedDocument, type AttachmentUploadResult, CardHistory, CardRecord, CourseLookup, CourseRegistrationDoc, DEFAULT_MIGRATION_OPTIONS, type DataLayerConfig, DataLayerProvider, type DocumentCounts, ENV, FileSystemAdapter, Loggable, type MigrationOptions, type MigrationResult, NOT_SET, type ResponseResult, type RestoreProgress, type SessionAction, SessionController, StaticCourseManifest, type StaticCourseValidation, StaticToCouchDBMigrator, StudyContentSource, StudySessionItem, type StudySessionRecord, UserDBInterface, type ValidationIssue, type ValidationResult, _resetDataLayer, ensureAppDataDirectory, getAppDataDirectory, getDataLayer, getDbPath, getLogFilePath, initializeDataDirectory, initializeDataLayer, initializeTuiLogging, logger, showUserError, showUserMessage, validateMigration, validateStaticCourse };