@vue-skuilder/db 0.1.1

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 (62) hide show
  1. package/README.md +26 -0
  2. package/dist/core/index.d.mts +3 -0
  3. package/dist/core/index.d.ts +3 -0
  4. package/dist/core/index.js +7906 -0
  5. package/dist/core/index.js.map +1 -0
  6. package/dist/core/index.mjs +7886 -0
  7. package/dist/core/index.mjs.map +1 -0
  8. package/dist/index-QMtzQI65.d.mts +734 -0
  9. package/dist/index-QMtzQI65.d.ts +734 -0
  10. package/dist/index.d.mts +133 -0
  11. package/dist/index.d.ts +133 -0
  12. package/dist/index.js +8726 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/index.mjs +8699 -0
  15. package/dist/index.mjs.map +1 -0
  16. package/eslint.config.mjs +20 -0
  17. package/package.json +47 -0
  18. package/src/core/bulkImport/cardProcessor.ts +165 -0
  19. package/src/core/bulkImport/index.ts +2 -0
  20. package/src/core/bulkImport/types.ts +27 -0
  21. package/src/core/index.ts +9 -0
  22. package/src/core/interfaces/adminDB.ts +27 -0
  23. package/src/core/interfaces/classroomDB.ts +75 -0
  24. package/src/core/interfaces/contentSource.ts +64 -0
  25. package/src/core/interfaces/courseDB.ts +139 -0
  26. package/src/core/interfaces/dataLayerProvider.ts +46 -0
  27. package/src/core/interfaces/index.ts +7 -0
  28. package/src/core/interfaces/navigationStrategyManager.ts +46 -0
  29. package/src/core/interfaces/userDB.ts +183 -0
  30. package/src/core/navigators/elo.ts +76 -0
  31. package/src/core/navigators/index.ts +57 -0
  32. package/src/core/readme.md +9 -0
  33. package/src/core/types/contentNavigationStrategy.ts +21 -0
  34. package/src/core/types/db.ts +7 -0
  35. package/src/core/types/types-legacy.ts +155 -0
  36. package/src/core/types/user.ts +70 -0
  37. package/src/core/util/index.ts +42 -0
  38. package/src/factory.ts +86 -0
  39. package/src/impl/pouch/PouchDataLayerProvider.ts +102 -0
  40. package/src/impl/pouch/adminDB.ts +91 -0
  41. package/src/impl/pouch/auth.ts +48 -0
  42. package/src/impl/pouch/classroomDB.ts +306 -0
  43. package/src/impl/pouch/clientCache.ts +19 -0
  44. package/src/impl/pouch/courseAPI.ts +245 -0
  45. package/src/impl/pouch/courseDB.ts +772 -0
  46. package/src/impl/pouch/courseLookupDB.ts +135 -0
  47. package/src/impl/pouch/index.ts +235 -0
  48. package/src/impl/pouch/pouchdb-setup.ts +16 -0
  49. package/src/impl/pouch/types.ts +7 -0
  50. package/src/impl/pouch/updateQueue.ts +89 -0
  51. package/src/impl/pouch/user-course-relDB.ts +73 -0
  52. package/src/impl/pouch/userDB.ts +1097 -0
  53. package/src/index.ts +8 -0
  54. package/src/study/SessionController.ts +401 -0
  55. package/src/study/SpacedRepetition.ts +128 -0
  56. package/src/study/getCardDataShape.ts +34 -0
  57. package/src/study/index.ts +2 -0
  58. package/src/util/Loggable.ts +11 -0
  59. package/src/util/index.ts +1 -0
  60. package/src/util/logger.ts +55 -0
  61. package/tsconfig.json +12 -0
  62. package/tsup.config.ts +17 -0
@@ -0,0 +1,133 @@
1
+ import { S as StudySessionItem, C as CardRecord, L as Loggable, a as StudyContentSource, D as DataLayerProvider } from './index-QMtzQI65.mjs';
2
+ export { V as ActivityRecord, A as AdminDBInterface, g as AssignedCard, d as AssignedContent, f as AssignedCourse, e as AssignedTag, a7 as BulkCardProcessorConfig, H as CardData, O as CardHistory, b as ClassroomDBInterface, w as ClassroomRegistration, v as ClassroomRegistrationDesignation, x as ClassroomRegistrationDoc, a3 as ContentNavigator, n as ContentSourceID, r as CourseDBInterface, q as CourseInfo, I as CourseListData, W as CourseRegistration, X as CourseRegistrationDoc, p as CoursesDBInterface, M as DataShapeData, J as DisplayableData, z as DocType, a8 as DocumentUpdater, K as Field, G as GuestUsername, a6 as ImportResult, a2 as Navigators, Q as QuestionData, P as QuestionRecord, Y as ScheduledCard, B as SkuilderCourseData, c as StudentClassroomDBInterface, h as StudySessionFailedItem, i as StudySessionFailedNewItem, j as StudySessionFailedReviewItem, k as StudySessionNewItem, l as StudySessionReviewItem, E as Tag, F as TagStub, T as TeacherClassroomDBInterface, R as UserConfig, t as UserCourseSetting, s as UserCourseSettings, U as UserDBInterface, u as UsrCrsDataInterface, Z as areQuestionRecords, N as cardHistoryPrefix, a1 as docIsDeleted, $ as getCardHistoryID, o as getStudySource, a4 as importParsedCards, _ as isQuestionRecord, m as isReview, y as log, a9 as newInterval, a0 as parseCardHistoryID, a5 as validateProcessorConfig } from './index-QMtzQI65.mjs';
3
+ import '@vue-skuilder/common';
4
+ import 'moment';
5
+
6
+ interface StudySessionRecord {
7
+ card: {
8
+ course_id: string;
9
+ card_id: string;
10
+ card_elo: number;
11
+ };
12
+ item: StudySessionItem;
13
+ records: CardRecord[];
14
+ }
15
+ declare class SessionController extends Loggable {
16
+ _className: string;
17
+ private sources;
18
+ private _sessionRecord;
19
+ set sessionRecord(r: StudySessionRecord[]);
20
+ private reviewQ;
21
+ private newQ;
22
+ private failedQ;
23
+ private _currentCard;
24
+ /**
25
+ * Indicates whether the session has been initialized - eg, the
26
+ * queues have been populated.
27
+ */
28
+ private _isInitialized;
29
+ private startTime;
30
+ private endTime;
31
+ private _secondsRemaining;
32
+ get secondsRemaining(): number;
33
+ get report(): string;
34
+ get detailedReport(): string;
35
+ private _intervalHandle;
36
+ /**
37
+ *
38
+ */
39
+ constructor(sources: StudyContentSource[], time: number);
40
+ private tick;
41
+ /**
42
+ * Returns a rough, erring toward conservative, guess at
43
+ * the amount of time the failed cards queue will require
44
+ * to clean up.
45
+ *
46
+ * (seconds)
47
+ */
48
+ private estimateCleanupTime;
49
+ /**
50
+ * Extremely rough, conservative, estimate of amound of time to complete
51
+ * all scheduled reviews
52
+ */
53
+ private estimateReviewTime;
54
+ prepareSession(): Promise<void>;
55
+ addTime(seconds: number): void;
56
+ get failedCount(): number;
57
+ toString(): string;
58
+ reportString(): string;
59
+ private getScheduledReviews;
60
+ private getNewCards;
61
+ private nextNewCard;
62
+ nextCard(action?: 'dismiss-success' | 'dismiss-failed' | 'marked-failed' | 'dismiss-error'): StudySessionItem | null;
63
+ private dismissCurrentCard;
64
+ }
65
+
66
+ interface CourseLookupDoc {
67
+ _id: string;
68
+ _rev: string;
69
+ name: string;
70
+ disambiguator?: string;
71
+ }
72
+ /**
73
+ * A Lookup table of existant courses. Each docID in this DB correspondes to a
74
+ * course database whose name is `coursedb-{docID}`
75
+ */
76
+ declare class CourseLookup {
77
+ private static _dbInstance;
78
+ /**
79
+ * Static getter for the PouchDB database instance.
80
+ * Connects using ENV variables and caches the instance.
81
+ * Throws an error if required ENV variables are not set.
82
+ */
83
+ private static get _db();
84
+ /**
85
+ * Adds a new course to the lookup database, and returns the courseID
86
+ * @param courseName
87
+ * @returns
88
+ */
89
+ static add(courseName: string): Promise<string>;
90
+ /**
91
+ * Removes a course from the index
92
+ * @param courseID
93
+ */
94
+ static delete(courseID: string): Promise<PouchDB.Core.Response>;
95
+ static allCourses(): Promise<CourseLookupDoc[]>;
96
+ static updateDisambiguator(courseID: string, disambiguator?: string): Promise<PouchDB.Core.Response>;
97
+ static isCourse(courseID: string): Promise<boolean>;
98
+ }
99
+
100
+ interface DBEnv {
101
+ COUCHDB_SERVER_URL: string;
102
+ COUCHDB_SERVER_PROTOCOL: string;
103
+ COUCHDB_USERNAME?: string;
104
+ COUCHDB_PASSWORD?: string;
105
+ }
106
+ declare const ENV: DBEnv;
107
+ interface DataLayerConfig {
108
+ type: 'pouch' | 'static';
109
+ options: {
110
+ staticContentPath?: string;
111
+ localStoragePrefix?: string;
112
+ COUCHDB_SERVER_URL?: string;
113
+ COUCHDB_SERVER_PROTOCOL?: string;
114
+ COUCHDB_USERNAME?: string;
115
+ COUCHDB_PASSWORD?: string;
116
+ COURSE_IDS?: string[];
117
+ };
118
+ }
119
+ /**
120
+ * Initialize the data layer with the specified configuration
121
+ */
122
+ declare function initializeDataLayer(config: DataLayerConfig): Promise<DataLayerProvider>;
123
+ /**
124
+ * Get the initialized data layer instance
125
+ * @throws Error if not initialized
126
+ */
127
+ declare function getDataLayer(): DataLayerProvider;
128
+ /**
129
+ * Reset the data layer (primarily for testing)
130
+ */
131
+ declare function _resetDataLayer(): Promise<void>;
132
+
133
+ export { CardRecord, CourseLookup, type DataLayerConfig, DataLayerProvider, ENV, Loggable, SessionController, StudyContentSource, StudySessionItem, type StudySessionRecord, _resetDataLayer, getDataLayer, initializeDataLayer };
@@ -0,0 +1,133 @@
1
+ import { S as StudySessionItem, C as CardRecord, L as Loggable, a as StudyContentSource, D as DataLayerProvider } from './index-QMtzQI65.js';
2
+ export { V as ActivityRecord, A as AdminDBInterface, g as AssignedCard, d as AssignedContent, f as AssignedCourse, e as AssignedTag, a7 as BulkCardProcessorConfig, H as CardData, O as CardHistory, b as ClassroomDBInterface, w as ClassroomRegistration, v as ClassroomRegistrationDesignation, x as ClassroomRegistrationDoc, a3 as ContentNavigator, n as ContentSourceID, r as CourseDBInterface, q as CourseInfo, I as CourseListData, W as CourseRegistration, X as CourseRegistrationDoc, p as CoursesDBInterface, M as DataShapeData, J as DisplayableData, z as DocType, a8 as DocumentUpdater, K as Field, G as GuestUsername, a6 as ImportResult, a2 as Navigators, Q as QuestionData, P as QuestionRecord, Y as ScheduledCard, B as SkuilderCourseData, c as StudentClassroomDBInterface, h as StudySessionFailedItem, i as StudySessionFailedNewItem, j as StudySessionFailedReviewItem, k as StudySessionNewItem, l as StudySessionReviewItem, E as Tag, F as TagStub, T as TeacherClassroomDBInterface, R as UserConfig, t as UserCourseSetting, s as UserCourseSettings, U as UserDBInterface, u as UsrCrsDataInterface, Z as areQuestionRecords, N as cardHistoryPrefix, a1 as docIsDeleted, $ as getCardHistoryID, o as getStudySource, a4 as importParsedCards, _ as isQuestionRecord, m as isReview, y as log, a9 as newInterval, a0 as parseCardHistoryID, a5 as validateProcessorConfig } from './index-QMtzQI65.js';
3
+ import '@vue-skuilder/common';
4
+ import 'moment';
5
+
6
+ interface StudySessionRecord {
7
+ card: {
8
+ course_id: string;
9
+ card_id: string;
10
+ card_elo: number;
11
+ };
12
+ item: StudySessionItem;
13
+ records: CardRecord[];
14
+ }
15
+ declare class SessionController extends Loggable {
16
+ _className: string;
17
+ private sources;
18
+ private _sessionRecord;
19
+ set sessionRecord(r: StudySessionRecord[]);
20
+ private reviewQ;
21
+ private newQ;
22
+ private failedQ;
23
+ private _currentCard;
24
+ /**
25
+ * Indicates whether the session has been initialized - eg, the
26
+ * queues have been populated.
27
+ */
28
+ private _isInitialized;
29
+ private startTime;
30
+ private endTime;
31
+ private _secondsRemaining;
32
+ get secondsRemaining(): number;
33
+ get report(): string;
34
+ get detailedReport(): string;
35
+ private _intervalHandle;
36
+ /**
37
+ *
38
+ */
39
+ constructor(sources: StudyContentSource[], time: number);
40
+ private tick;
41
+ /**
42
+ * Returns a rough, erring toward conservative, guess at
43
+ * the amount of time the failed cards queue will require
44
+ * to clean up.
45
+ *
46
+ * (seconds)
47
+ */
48
+ private estimateCleanupTime;
49
+ /**
50
+ * Extremely rough, conservative, estimate of amound of time to complete
51
+ * all scheduled reviews
52
+ */
53
+ private estimateReviewTime;
54
+ prepareSession(): Promise<void>;
55
+ addTime(seconds: number): void;
56
+ get failedCount(): number;
57
+ toString(): string;
58
+ reportString(): string;
59
+ private getScheduledReviews;
60
+ private getNewCards;
61
+ private nextNewCard;
62
+ nextCard(action?: 'dismiss-success' | 'dismiss-failed' | 'marked-failed' | 'dismiss-error'): StudySessionItem | null;
63
+ private dismissCurrentCard;
64
+ }
65
+
66
+ interface CourseLookupDoc {
67
+ _id: string;
68
+ _rev: string;
69
+ name: string;
70
+ disambiguator?: string;
71
+ }
72
+ /**
73
+ * A Lookup table of existant courses. Each docID in this DB correspondes to a
74
+ * course database whose name is `coursedb-{docID}`
75
+ */
76
+ declare class CourseLookup {
77
+ private static _dbInstance;
78
+ /**
79
+ * Static getter for the PouchDB database instance.
80
+ * Connects using ENV variables and caches the instance.
81
+ * Throws an error if required ENV variables are not set.
82
+ */
83
+ private static get _db();
84
+ /**
85
+ * Adds a new course to the lookup database, and returns the courseID
86
+ * @param courseName
87
+ * @returns
88
+ */
89
+ static add(courseName: string): Promise<string>;
90
+ /**
91
+ * Removes a course from the index
92
+ * @param courseID
93
+ */
94
+ static delete(courseID: string): Promise<PouchDB.Core.Response>;
95
+ static allCourses(): Promise<CourseLookupDoc[]>;
96
+ static updateDisambiguator(courseID: string, disambiguator?: string): Promise<PouchDB.Core.Response>;
97
+ static isCourse(courseID: string): Promise<boolean>;
98
+ }
99
+
100
+ interface DBEnv {
101
+ COUCHDB_SERVER_URL: string;
102
+ COUCHDB_SERVER_PROTOCOL: string;
103
+ COUCHDB_USERNAME?: string;
104
+ COUCHDB_PASSWORD?: string;
105
+ }
106
+ declare const ENV: DBEnv;
107
+ interface DataLayerConfig {
108
+ type: 'pouch' | 'static';
109
+ options: {
110
+ staticContentPath?: string;
111
+ localStoragePrefix?: string;
112
+ COUCHDB_SERVER_URL?: string;
113
+ COUCHDB_SERVER_PROTOCOL?: string;
114
+ COUCHDB_USERNAME?: string;
115
+ COUCHDB_PASSWORD?: string;
116
+ COURSE_IDS?: string[];
117
+ };
118
+ }
119
+ /**
120
+ * Initialize the data layer with the specified configuration
121
+ */
122
+ declare function initializeDataLayer(config: DataLayerConfig): Promise<DataLayerProvider>;
123
+ /**
124
+ * Get the initialized data layer instance
125
+ * @throws Error if not initialized
126
+ */
127
+ declare function getDataLayer(): DataLayerProvider;
128
+ /**
129
+ * Reset the data layer (primarily for testing)
130
+ */
131
+ declare function _resetDataLayer(): Promise<void>;
132
+
133
+ export { CardRecord, CourseLookup, type DataLayerConfig, DataLayerProvider, ENV, Loggable, SessionController, StudyContentSource, StudySessionItem, type StudySessionRecord, _resetDataLayer, getDataLayer, initializeDataLayer };