@vue-skuilder/db 0.1.11-9 → 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 (76) 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 +358 -87
  4. package/dist/core/index.js.map +1 -1
  5. package/dist/core/index.mjs +358 -87
  6. package/dist/core/index.mjs.map +1 -1
  7. package/dist/{dataLayerProvider-DqtNroSh.d.ts → dataLayerProvider-BiP3kWix.d.mts} +8 -1
  8. package/dist/{dataLayerProvider-BInqI_RF.d.mts → dataLayerProvider-DSdeyRT3.d.ts} +8 -1
  9. package/dist/impl/couch/index.d.mts +19 -7
  10. package/dist/impl/couch/index.d.ts +19 -7
  11. package/dist/impl/couch/index.js +375 -100
  12. package/dist/impl/couch/index.js.map +1 -1
  13. package/dist/impl/couch/index.mjs +374 -99
  14. package/dist/impl/couch/index.mjs.map +1 -1
  15. package/dist/impl/static/index.d.mts +23 -8
  16. package/dist/impl/static/index.d.ts +23 -8
  17. package/dist/impl/static/index.js +289 -85
  18. package/dist/impl/static/index.js.map +1 -1
  19. package/dist/impl/static/index.mjs +289 -85
  20. package/dist/impl/static/index.mjs.map +1 -1
  21. package/dist/{index-CUNnL38E.d.mts → index-Bmll7Xse.d.mts} +1 -1
  22. package/dist/{index-CLL31bEy.d.ts → index-CD8BZz2k.d.ts} +1 -1
  23. package/dist/index.d.mts +123 -20
  24. package/dist/index.d.ts +123 -20
  25. package/dist/index.js +1133 -343
  26. package/dist/index.js.map +1 -1
  27. package/dist/index.mjs +1137 -343
  28. package/dist/index.mjs.map +1 -1
  29. package/dist/pouch/index.d.mts +1 -0
  30. package/dist/pouch/index.d.ts +1 -0
  31. package/dist/pouch/index.js +49 -0
  32. package/dist/pouch/index.js.map +1 -0
  33. package/dist/pouch/index.mjs +16 -0
  34. package/dist/pouch/index.mjs.map +1 -0
  35. package/dist/{types-BefDGkKa.d.ts → types-CewsN87z.d.ts} +1 -1
  36. package/dist/{types-DC-ckZug.d.mts → types-Dbp5DaRR.d.mts} +1 -1
  37. package/dist/{types-legacy-Birv-Jx6.d.mts → types-legacy-6ettoclI.d.mts} +17 -2
  38. package/dist/{types-legacy-Birv-Jx6.d.ts → types-legacy-6ettoclI.d.ts} +17 -2
  39. package/dist/{userDB-DusL7OXe.d.ts → userDB-C4yyAnpp.d.mts} +89 -56
  40. package/dist/{userDB-C33Hzjgn.d.mts → userDB-CD6s6ZCp.d.ts} +89 -56
  41. package/dist/util/packer/index.d.mts +3 -3
  42. package/dist/util/packer/index.d.ts +3 -3
  43. package/package.json +3 -3
  44. package/src/core/interfaces/contentSource.ts +3 -2
  45. package/src/core/interfaces/courseDB.ts +26 -3
  46. package/src/core/interfaces/dataLayerProvider.ts +9 -1
  47. package/src/core/interfaces/userDB.ts +80 -64
  48. package/src/core/navigators/elo.ts +10 -7
  49. package/src/core/navigators/hardcodedOrder.ts +64 -0
  50. package/src/core/navigators/index.ts +2 -1
  51. package/src/core/types/contentNavigationStrategy.ts +2 -1
  52. package/src/core/types/types-legacy.ts +7 -2
  53. package/src/impl/common/BaseUserDB.ts +60 -14
  54. package/src/impl/couch/CouchDBSyncStrategy.ts +2 -2
  55. package/src/impl/couch/PouchDataLayerProvider.ts +21 -0
  56. package/src/impl/couch/adminDB.ts +2 -2
  57. package/src/impl/couch/auth.ts +13 -4
  58. package/src/impl/couch/classroomDB.ts +10 -12
  59. package/src/impl/couch/courseAPI.ts +2 -2
  60. package/src/impl/couch/courseDB.ts +204 -38
  61. package/src/impl/couch/courseLookupDB.ts +4 -3
  62. package/src/impl/couch/index.ts +36 -4
  63. package/src/impl/couch/pouchdb-setup.ts +3 -3
  64. package/src/impl/couch/updateQueue.ts +59 -36
  65. package/src/impl/static/StaticDataLayerProvider.ts +68 -17
  66. package/src/impl/static/courseDB.ts +64 -20
  67. package/src/impl/static/coursesDB.ts +10 -6
  68. package/src/pouch/index.ts +2 -0
  69. package/src/study/ItemQueue.ts +58 -0
  70. package/src/study/SessionController.ts +182 -111
  71. package/src/study/SpacedRepetition.ts +1 -1
  72. package/src/study/services/CardHydrationService.ts +153 -0
  73. package/src/study/services/EloService.ts +85 -0
  74. package/src/study/services/ResponseProcessor.ts +224 -0
  75. package/src/study/services/SrsService.ts +44 -0
  76. package/tsup.config.ts +1 -0
@@ -1,4 +1,4 @@
1
- import { U as UserDBInterface, C as CourseDBInterface, a as CoursesDBInterface, b as ClassroomDBInterface, A as AdminDBInterface } from './userDB-DusL7OXe.js';
1
+ import { U as UserDBInterface, a as UserDBReader, C as CourseDBInterface, b as CoursesDBInterface, c as ClassroomDBInterface, A as AdminDBInterface } from './userDB-C4yyAnpp.mjs';
2
2
 
3
3
  /**
4
4
  * Main factory interface for data access
@@ -8,6 +8,13 @@ interface DataLayerProvider {
8
8
  * Get the user database interface
9
9
  */
10
10
  getUserDB(): UserDBInterface;
11
+ /**
12
+ * Create a UserDBReader for a specific user (admin access required)
13
+ * Uses session authentication to verify requesting user is admin
14
+ * @param targetUsername - The username to create a reader for
15
+ * @throws Error if requesting user is not 'admin'
16
+ */
17
+ createUserReaderForUser(targetUsername: string): Promise<UserDBReader>;
11
18
  /**
12
19
  * Get a course database interface
13
20
  */
@@ -1,4 +1,4 @@
1
- import { U as UserDBInterface, C as CourseDBInterface, a as CoursesDBInterface, b as ClassroomDBInterface, A as AdminDBInterface } from './userDB-C33Hzjgn.mjs';
1
+ import { U as UserDBInterface, a as UserDBReader, C as CourseDBInterface, b as CoursesDBInterface, c as ClassroomDBInterface, A as AdminDBInterface } from './userDB-CD6s6ZCp.js';
2
2
 
3
3
  /**
4
4
  * Main factory interface for data access
@@ -8,6 +8,13 @@ interface DataLayerProvider {
8
8
  * Get the user database interface
9
9
  */
10
10
  getUserDB(): UserDBInterface;
11
+ /**
12
+ * Create a UserDBReader for a specific user (admin access required)
13
+ * Uses session authentication to verify requesting user is admin
14
+ * @param targetUsername - The username to create a reader for
15
+ * @throws Error if requesting user is not 'admin'
16
+ */
17
+ createUserReaderForUser(targetUsername: string): Promise<UserDBReader>;
11
18
  /**
12
19
  * Get a course database interface
13
20
  */
@@ -1,7 +1,7 @@
1
- import { T as TagStub, a as Tag, S as SkuilderCourseData } from '../../types-legacy-Birv-Jx6.mjs';
1
+ import { T as TagStub, a as Tag, S as SkuilderCourseData, Q as QualifiedCardID } from '../../types-legacy-6ettoclI.mjs';
2
2
  import { Moment } from 'moment';
3
- import { A as AdminDBInterface, g as AssignedContent, h as StudyContentSource, i as StudentClassroomDBInterface, U as UserDBInterface, e as StudySessionReviewItem, f as ScheduledCard, S as StudySessionNewItem, T as TeacherClassroomDBInterface, a as CoursesDBInterface, C as CourseDBInterface, c as CourseInfo, D as DataLayerResult, d as ContentNavigationStrategyData, j as StudySessionItem } from '../../userDB-C33Hzjgn.mjs';
4
- export { o as ContentSourceID, k as StudySessionFailedItem, l as StudySessionFailedNewItem, m as StudySessionFailedReviewItem, p as getStudySource, n as isReview } from '../../userDB-C33Hzjgn.mjs';
3
+ import { A as AdminDBInterface, h as AssignedContent, i as StudyContentSource, j as StudentClassroomDBInterface, U as UserDBInterface, f as StudySessionReviewItem, g as ScheduledCard, S as StudySessionNewItem, T as TeacherClassroomDBInterface, b as CoursesDBInterface, C as CourseDBInterface, d as CourseInfo, D as DataLayerResult, e as ContentNavigationStrategyData, k as StudySessionItem } from '../../userDB-C4yyAnpp.mjs';
4
+ export { p as ContentSourceID, l as StudySessionFailedItem, m as StudySessionFailedNewItem, n as StudySessionFailedReviewItem, q as getStudySource, o as isReview } from '../../userDB-C4yyAnpp.mjs';
5
5
  import * as _vue_skuilder_common from '@vue-skuilder/common';
6
6
  import { ClassroomConfig, DataShape, CourseElo, CourseConfig as CourseConfig$1 } from '@vue-skuilder/common';
7
7
  import { S as SyncStrategy, A as AccountCreationResult, a as AuthenticationResult } from '../../SyncStrategy-CyATpyLQ.mjs';
@@ -10,6 +10,7 @@ type NamespacedDatashape = string;
10
10
  interface DataShape55 {
11
11
  name: NamespacedDatashape;
12
12
  questionTypes: PouchDB.Core.DocumentId[];
13
+ serializedZodSchema?: string;
13
14
  }
14
15
  type NamespacedQuestion = string;
15
16
  interface QuestionType55 {
@@ -170,7 +171,11 @@ declare class CourseDB implements StudyContentSource, CourseDBInterface {
170
171
  getCardDisplayableDataIDs(id: string[]): Promise<{
171
172
  [card: string]: string[];
172
173
  }>;
173
- getCardsByELO(elo: number, cardLimit?: number): Promise<string[]>;
174
+ getCardsByELO(elo: number, cardLimit?: number): Promise<{
175
+ courseID: string;
176
+ cardID: any;
177
+ elo: any;
178
+ }[]>;
174
179
  getCourseConfig(): Promise<CourseConfig$1>;
175
180
  updateCourseConfig(cfg: CourseConfig$1): Promise<PouchDB.Core.Response>;
176
181
  updateCardElo(cardId: string, elo: CourseElo): Promise<PouchDB.Core.Response>;
@@ -196,7 +201,9 @@ declare class CourseDB implements StudyContentSource, CourseDBInterface {
196
201
  getCardsCenteredAtELO(options?: {
197
202
  limit: number;
198
203
  elo: 'user' | 'random' | number;
199
- }, filter?: (a: string) => boolean): Promise<StudySessionItem[]>;
204
+ }, filter?: (a: QualifiedCardID) => boolean): Promise<StudySessionItem[]>;
205
+ searchCards(query: string): Promise<any[]>;
206
+ find(request: PouchDB.Find.FindRequest<any>): Promise<PouchDB.Find.FindResponse<any>>;
200
207
  }
201
208
  /**
202
209
  * Returns a list of registered datashapes for the specified
@@ -255,7 +262,12 @@ declare class CouchDBSyncStrategy implements SyncStrategy {
255
262
 
256
263
  declare const localUserDB: PouchDB.Database;
257
264
  declare function hexEncode(str: string): string;
258
- declare const pouchDBincludeCredentialsConfig: PouchDB.Configuration.RemoteDatabaseConfiguration;
265
+ /**
266
+ * Creates PouchDB configuration with appropriate authentication method
267
+ * - Uses HTTP Basic Auth when credentials are available (Node.js/MCP)
268
+ * - Falls back to cookie auth for browser environments
269
+ */
270
+ declare function createPouchDBConfig(): PouchDB.Configuration.RemoteDatabaseConfiguration;
259
271
  declare function getCourseDB(courseID: string): PouchDB.Database;
260
272
  declare function getLatestVersion(): Promise<string>;
261
273
  /**
@@ -289,4 +301,4 @@ declare function getStartAndEndKeys(key: string): {
289
301
  endkey: string;
290
302
  };
291
303
 
292
- export { AdminDB, CLASSROOM_CONFIG, ClassroomLookupDB, type ClassroomMessage, CouchDBSyncStrategy, CourseDB, CoursesDB, REVIEW_TIME_FORMAT, StudentClassroomDB, StudyContentSource, StudySessionItem, StudySessionNewItem, StudySessionReviewItem, TeacherClassroomDB, addNote55, addTagToCard, createTag, deleteTag, filterAllDocsByPrefix, getAncestorTagIDs, getAppliedTags, getChildTagStubs, getClassroomConfig, getClassroomDB, getCouchUserDB, getCourseDB, getCourseDataShapes, getCourseDoc, getCourseDocs, getCourseQuestionTypes, getCourseTagStubs, getCredentialledCourseConfig, getCredentialledDataShapes, getLatestVersion, getRandomCards, getStartAndEndKeys, getTag, getTagID, hexEncode, localUserDB, pouchDBincludeCredentialsConfig, removeTagFromCard, scheduleCardReview, updateCardElo, updateCredentialledCourseConfig, updateGuestAccountExpirationDate, updateTag, usernameIsAvailable };
304
+ export { AdminDB, CLASSROOM_CONFIG, ClassroomLookupDB, type ClassroomMessage, CouchDBSyncStrategy, CourseDB, CoursesDB, REVIEW_TIME_FORMAT, StudentClassroomDB, StudyContentSource, StudySessionItem, StudySessionNewItem, StudySessionReviewItem, TeacherClassroomDB, addNote55, addTagToCard, createPouchDBConfig, createTag, deleteTag, filterAllDocsByPrefix, getAncestorTagIDs, getAppliedTags, getChildTagStubs, getClassroomConfig, getClassroomDB, getCouchUserDB, getCourseDB, getCourseDataShapes, getCourseDoc, getCourseDocs, getCourseQuestionTypes, getCourseTagStubs, getCredentialledCourseConfig, getCredentialledDataShapes, getLatestVersion, getRandomCards, getStartAndEndKeys, getTag, getTagID, hexEncode, localUserDB, removeTagFromCard, scheduleCardReview, updateCardElo, updateCredentialledCourseConfig, updateGuestAccountExpirationDate, updateTag, usernameIsAvailable };
@@ -1,7 +1,7 @@
1
- import { T as TagStub, a as Tag, S as SkuilderCourseData } from '../../types-legacy-Birv-Jx6.js';
1
+ import { T as TagStub, a as Tag, S as SkuilderCourseData, Q as QualifiedCardID } from '../../types-legacy-6ettoclI.js';
2
2
  import { Moment } from 'moment';
3
- import { A as AdminDBInterface, g as AssignedContent, h as StudyContentSource, i as StudentClassroomDBInterface, U as UserDBInterface, e as StudySessionReviewItem, f as ScheduledCard, S as StudySessionNewItem, T as TeacherClassroomDBInterface, a as CoursesDBInterface, C as CourseDBInterface, c as CourseInfo, D as DataLayerResult, d as ContentNavigationStrategyData, j as StudySessionItem } from '../../userDB-DusL7OXe.js';
4
- export { o as ContentSourceID, k as StudySessionFailedItem, l as StudySessionFailedNewItem, m as StudySessionFailedReviewItem, p as getStudySource, n as isReview } from '../../userDB-DusL7OXe.js';
3
+ import { A as AdminDBInterface, h as AssignedContent, i as StudyContentSource, j as StudentClassroomDBInterface, U as UserDBInterface, f as StudySessionReviewItem, g as ScheduledCard, S as StudySessionNewItem, T as TeacherClassroomDBInterface, b as CoursesDBInterface, C as CourseDBInterface, d as CourseInfo, D as DataLayerResult, e as ContentNavigationStrategyData, k as StudySessionItem } from '../../userDB-CD6s6ZCp.js';
4
+ export { p as ContentSourceID, l as StudySessionFailedItem, m as StudySessionFailedNewItem, n as StudySessionFailedReviewItem, q as getStudySource, o as isReview } from '../../userDB-CD6s6ZCp.js';
5
5
  import * as _vue_skuilder_common from '@vue-skuilder/common';
6
6
  import { ClassroomConfig, DataShape, CourseElo, CourseConfig as CourseConfig$1 } from '@vue-skuilder/common';
7
7
  import { S as SyncStrategy, A as AccountCreationResult, a as AuthenticationResult } from '../../SyncStrategy-CyATpyLQ.js';
@@ -10,6 +10,7 @@ type NamespacedDatashape = string;
10
10
  interface DataShape55 {
11
11
  name: NamespacedDatashape;
12
12
  questionTypes: PouchDB.Core.DocumentId[];
13
+ serializedZodSchema?: string;
13
14
  }
14
15
  type NamespacedQuestion = string;
15
16
  interface QuestionType55 {
@@ -170,7 +171,11 @@ declare class CourseDB implements StudyContentSource, CourseDBInterface {
170
171
  getCardDisplayableDataIDs(id: string[]): Promise<{
171
172
  [card: string]: string[];
172
173
  }>;
173
- getCardsByELO(elo: number, cardLimit?: number): Promise<string[]>;
174
+ getCardsByELO(elo: number, cardLimit?: number): Promise<{
175
+ courseID: string;
176
+ cardID: any;
177
+ elo: any;
178
+ }[]>;
174
179
  getCourseConfig(): Promise<CourseConfig$1>;
175
180
  updateCourseConfig(cfg: CourseConfig$1): Promise<PouchDB.Core.Response>;
176
181
  updateCardElo(cardId: string, elo: CourseElo): Promise<PouchDB.Core.Response>;
@@ -196,7 +201,9 @@ declare class CourseDB implements StudyContentSource, CourseDBInterface {
196
201
  getCardsCenteredAtELO(options?: {
197
202
  limit: number;
198
203
  elo: 'user' | 'random' | number;
199
- }, filter?: (a: string) => boolean): Promise<StudySessionItem[]>;
204
+ }, filter?: (a: QualifiedCardID) => boolean): Promise<StudySessionItem[]>;
205
+ searchCards(query: string): Promise<any[]>;
206
+ find(request: PouchDB.Find.FindRequest<any>): Promise<PouchDB.Find.FindResponse<any>>;
200
207
  }
201
208
  /**
202
209
  * Returns a list of registered datashapes for the specified
@@ -255,7 +262,12 @@ declare class CouchDBSyncStrategy implements SyncStrategy {
255
262
 
256
263
  declare const localUserDB: PouchDB.Database;
257
264
  declare function hexEncode(str: string): string;
258
- declare const pouchDBincludeCredentialsConfig: PouchDB.Configuration.RemoteDatabaseConfiguration;
265
+ /**
266
+ * Creates PouchDB configuration with appropriate authentication method
267
+ * - Uses HTTP Basic Auth when credentials are available (Node.js/MCP)
268
+ * - Falls back to cookie auth for browser environments
269
+ */
270
+ declare function createPouchDBConfig(): PouchDB.Configuration.RemoteDatabaseConfiguration;
259
271
  declare function getCourseDB(courseID: string): PouchDB.Database;
260
272
  declare function getLatestVersion(): Promise<string>;
261
273
  /**
@@ -289,4 +301,4 @@ declare function getStartAndEndKeys(key: string): {
289
301
  endkey: string;
290
302
  };
291
303
 
292
- export { AdminDB, CLASSROOM_CONFIG, ClassroomLookupDB, type ClassroomMessage, CouchDBSyncStrategy, CourseDB, CoursesDB, REVIEW_TIME_FORMAT, StudentClassroomDB, StudyContentSource, StudySessionItem, StudySessionNewItem, StudySessionReviewItem, TeacherClassroomDB, addNote55, addTagToCard, createTag, deleteTag, filterAllDocsByPrefix, getAncestorTagIDs, getAppliedTags, getChildTagStubs, getClassroomConfig, getClassroomDB, getCouchUserDB, getCourseDB, getCourseDataShapes, getCourseDoc, getCourseDocs, getCourseQuestionTypes, getCourseTagStubs, getCredentialledCourseConfig, getCredentialledDataShapes, getLatestVersion, getRandomCards, getStartAndEndKeys, getTag, getTagID, hexEncode, localUserDB, pouchDBincludeCredentialsConfig, removeTagFromCard, scheduleCardReview, updateCardElo, updateCredentialledCourseConfig, updateGuestAccountExpirationDate, updateTag, usernameIsAvailable };
304
+ export { AdminDB, CLASSROOM_CONFIG, ClassroomLookupDB, type ClassroomMessage, CouchDBSyncStrategy, CourseDB, CoursesDB, REVIEW_TIME_FORMAT, StudentClassroomDB, StudyContentSource, StudySessionItem, StudySessionNewItem, StudySessionReviewItem, TeacherClassroomDB, addNote55, addTagToCard, createPouchDBConfig, createTag, deleteTag, filterAllDocsByPrefix, getAncestorTagIDs, getAppliedTags, getChildTagStubs, getClassroomConfig, getClassroomDB, getCouchUserDB, getCourseDB, getCourseDataShapes, getCourseDoc, getCourseDocs, getCourseQuestionTypes, getCourseTagStubs, getCredentialledCourseConfig, getCredentialledDataShapes, getLatestVersion, getRandomCards, getStartAndEndKeys, getTag, getTagID, hexEncode, localUserDB, removeTagFromCard, scheduleCardReview, updateCardElo, updateCredentialledCourseConfig, updateGuestAccountExpirationDate, updateTag, usernameIsAvailable };