@vue-skuilder/db 0.1.11-20 → 0.1.11-22

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 (39) hide show
  1. package/dist/core/index.d.mts +3 -3
  2. package/dist/core/index.d.ts +3 -3
  3. package/dist/core/index.js +87 -1
  4. package/dist/core/index.js.map +1 -1
  5. package/dist/core/index.mjs +87 -1
  6. package/dist/core/index.mjs.map +1 -1
  7. package/dist/{dataLayerProvider-BInqI_RF.d.mts → dataLayerProvider-Bx18k_g_.d.ts} +8 -1
  8. package/dist/{dataLayerProvider-DqtNroSh.d.ts → dataLayerProvider-DpqaIEJ5.d.mts} +8 -1
  9. package/dist/impl/couch/index.d.mts +4 -2
  10. package/dist/impl/couch/index.d.ts +4 -2
  11. package/dist/impl/couch/index.js +88 -1
  12. package/dist/impl/couch/index.js.map +1 -1
  13. package/dist/impl/couch/index.mjs +88 -1
  14. package/dist/impl/couch/index.mjs.map +1 -1
  15. package/dist/impl/static/index.d.mts +5 -2
  16. package/dist/impl/static/index.d.ts +5 -2
  17. package/dist/impl/static/index.js +19 -0
  18. package/dist/impl/static/index.js.map +1 -1
  19. package/dist/impl/static/index.mjs +19 -0
  20. package/dist/impl/static/index.mjs.map +1 -1
  21. package/dist/index.d.mts +3 -3
  22. package/dist/index.d.ts +3 -3
  23. package/dist/index.js +115 -2
  24. package/dist/index.js.map +1 -1
  25. package/dist/index.mjs +115 -2
  26. package/dist/index.mjs.map +1 -1
  27. package/dist/{userDB-C33Hzjgn.d.mts → userDB-C7hiVoA5.d.mts} +78 -49
  28. package/dist/{userDB-DusL7OXe.d.ts → userDB-D6HS-b9s.d.ts} +78 -49
  29. package/package.json +2 -2
  30. package/src/core/interfaces/courseDB.ts +14 -0
  31. package/src/core/interfaces/dataLayerProvider.ts +9 -1
  32. package/src/core/interfaces/userDB.ts +91 -74
  33. package/src/impl/common/BaseUserDB.ts +4 -0
  34. package/src/impl/couch/PouchDataLayerProvider.ts +21 -0
  35. package/src/impl/couch/courseDB.ts +106 -3
  36. package/src/impl/couch/courseLookupDB.ts +4 -3
  37. package/src/impl/static/StaticDataLayerProvider.ts +11 -0
  38. package/src/impl/static/courseDB.ts +16 -0
  39. package/src/study/SpacedRepetition.ts +1 -1
@@ -1,6 +1,6 @@
1
- import { h as StudyContentSource, U as UserDBInterface, C as CourseDBInterface, d as ContentNavigationStrategyData, e as StudySessionReviewItem, f as ScheduledCard, S as StudySessionNewItem } from '../userDB-C33Hzjgn.mjs';
2
- export { B as ActivityRecord, A as AdminDBInterface, s as AssignedCard, g as AssignedContent, r as AssignedCourse, q as AssignedTag, b as ClassroomDBInterface, x as ClassroomRegistration, w as ClassroomRegistrationDesignation, y as ClassroomRegistrationDoc, o as ContentSourceID, c as CourseInfo, E as CourseRegistration, F as CourseRegistrationDoc, a as CoursesDBInterface, i as StudentClassroomDBInterface, k as StudySessionFailedItem, l as StudySessionFailedNewItem, m as StudySessionFailedReviewItem, j as StudySessionItem, T as TeacherClassroomDBInterface, z as UserConfig, u as UserCourseSetting, t as UserCourseSettings, v as UsrCrsDataInterface, p as getStudySource, n as isReview } from '../userDB-C33Hzjgn.mjs';
3
- export { D as DataLayerProvider } from '../dataLayerProvider-BInqI_RF.mjs';
1
+ import { i as StudyContentSource, U as UserDBInterface, C as CourseDBInterface, e as ContentNavigationStrategyData, f as StudySessionReviewItem, g as ScheduledCard, S as StudySessionNewItem } from '../userDB-C7hiVoA5.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, d as CourseInfo, H as CourseRegistration, I as CourseRegistrationDoc, b as CoursesDBInterface, j as StudentClassroomDBInterface, l as StudySessionFailedItem, m as StudySessionFailedNewItem, n as StudySessionFailedReviewItem, k as StudySessionItem, T as TeacherClassroomDBInterface, F as UserConfig, x as UserCourseSetting, w as UserCourseSettings, v as UserDBAuthenticator, a as UserDBReader, u as UserDBWriter, y as UsrCrsDataInterface, q as getStudySource, o as isReview } from '../userDB-C7hiVoA5.mjs';
3
+ export { D as DataLayerProvider } from '../dataLayerProvider-DpqaIEJ5.mjs';
4
4
  import { g as CardHistory, C as CardRecord, h as QuestionRecord } from '../types-legacy-Birv-Jx6.mjs';
5
5
  export { b as CardData, c as CourseListData, e as DataShapeData, d as DisplayableData, D as DocType, f as DocTypePrefixes, F as Field, G as GuestUsername, Q as QuestionData, S as SkuilderCourseData, a as Tag, T as TagStub, l as log } from '../types-legacy-Birv-Jx6.mjs';
6
6
  import { DataShape, ParsedCard } from '@vue-skuilder/common';
@@ -1,6 +1,6 @@
1
- import { h as StudyContentSource, U as UserDBInterface, C as CourseDBInterface, d as ContentNavigationStrategyData, e as StudySessionReviewItem, f as ScheduledCard, S as StudySessionNewItem } from '../userDB-DusL7OXe.js';
2
- export { B as ActivityRecord, A as AdminDBInterface, s as AssignedCard, g as AssignedContent, r as AssignedCourse, q as AssignedTag, b as ClassroomDBInterface, x as ClassroomRegistration, w as ClassroomRegistrationDesignation, y as ClassroomRegistrationDoc, o as ContentSourceID, c as CourseInfo, E as CourseRegistration, F as CourseRegistrationDoc, a as CoursesDBInterface, i as StudentClassroomDBInterface, k as StudySessionFailedItem, l as StudySessionFailedNewItem, m as StudySessionFailedReviewItem, j as StudySessionItem, T as TeacherClassroomDBInterface, z as UserConfig, u as UserCourseSetting, t as UserCourseSettings, v as UsrCrsDataInterface, p as getStudySource, n as isReview } from '../userDB-DusL7OXe.js';
3
- export { D as DataLayerProvider } from '../dataLayerProvider-DqtNroSh.js';
1
+ import { i as StudyContentSource, U as UserDBInterface, C as CourseDBInterface, e as ContentNavigationStrategyData, f as StudySessionReviewItem, g as ScheduledCard, S as StudySessionNewItem } from '../userDB-D6HS-b9s.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, d as CourseInfo, H as CourseRegistration, I as CourseRegistrationDoc, b as CoursesDBInterface, j as StudentClassroomDBInterface, l as StudySessionFailedItem, m as StudySessionFailedNewItem, n as StudySessionFailedReviewItem, k as StudySessionItem, T as TeacherClassroomDBInterface, F as UserConfig, x as UserCourseSetting, w as UserCourseSettings, v as UserDBAuthenticator, a as UserDBReader, u as UserDBWriter, y as UsrCrsDataInterface, q as getStudySource, o as isReview } from '../userDB-D6HS-b9s.js';
3
+ export { D as DataLayerProvider } from '../dataLayerProvider-Bx18k_g_.js';
4
4
  import { g as CardHistory, C as CardRecord, h as QuestionRecord } from '../types-legacy-Birv-Jx6.js';
5
5
  export { b as CardData, c as CourseListData, e as DataShapeData, d as DisplayableData, D as DocType, f as DocTypePrefixes, F as Field, G as GuestUsername, Q as QuestionData, S as SkuilderCourseData, a as Tag, T as TagStub, l as log } from '../types-legacy-Birv-Jx6.js';
6
6
  import { DataShape, ParsedCard } from '@vue-skuilder/common';
@@ -1081,7 +1081,13 @@ ${above.rows.map((r) => ` ${r.id}-${r.key}
1081
1081
  }
1082
1082
  }
1083
1083
  async addTagToCard(cardId, tagId, updateELO) {
1084
- return await addTagToCard(this.id, cardId, tagId, (await this._getCurrentUser()).getUsername(), updateELO);
1084
+ return await addTagToCard(
1085
+ this.id,
1086
+ cardId,
1087
+ tagId,
1088
+ (await this._getCurrentUser()).getUsername(),
1089
+ updateELO
1090
+ );
1085
1091
  }
1086
1092
  async removeTagFromCard(cardId, tagId) {
1087
1093
  return await removeTagFromCard(this.id, cardId, tagId);
@@ -1285,6 +1291,83 @@ ${above.rows.map((r) => ` ${r.id}-${r.key}
1285
1291
  };
1286
1292
  });
1287
1293
  }
1294
+ // Admin search methods
1295
+ async searchCards(query) {
1296
+ logger.log(`[CourseDB ${this.id}] Searching for: "${query}"`);
1297
+ let displayableData;
1298
+ try {
1299
+ displayableData = await this.db.find({
1300
+ selector: {
1301
+ docType: "DISPLAYABLE_DATA",
1302
+ "data.0.data": { $regex: `.*${query}.*` }
1303
+ }
1304
+ });
1305
+ logger.log(`[CourseDB ${this.id}] Regex search on data[0].data successful`);
1306
+ } catch (regexError) {
1307
+ logger.log(
1308
+ `[CourseDB ${this.id}] Regex search failed, falling back to manual search:`,
1309
+ regexError
1310
+ );
1311
+ const allDisplayable = await this.db.find({
1312
+ selector: {
1313
+ docType: "DISPLAYABLE_DATA"
1314
+ }
1315
+ });
1316
+ logger.log(
1317
+ `[CourseDB ${this.id}] Retrieved ${allDisplayable.docs.length} documents for manual filtering`
1318
+ );
1319
+ displayableData = {
1320
+ docs: allDisplayable.docs.filter((doc) => {
1321
+ const docString = JSON.stringify(doc).toLowerCase();
1322
+ const match = docString.includes(query.toLowerCase());
1323
+ if (match) {
1324
+ logger.log(`[CourseDB ${this.id}] Manual match found in document: ${doc._id}`);
1325
+ }
1326
+ return match;
1327
+ })
1328
+ };
1329
+ }
1330
+ logger.log(
1331
+ `[CourseDB ${this.id}] Found ${displayableData.docs.length} displayable data documents`
1332
+ );
1333
+ if (displayableData.docs.length === 0) {
1334
+ const allDisplayableData = await this.db.find({
1335
+ selector: {
1336
+ docType: "DISPLAYABLE_DATA"
1337
+ },
1338
+ limit: 5
1339
+ // Just sample a few
1340
+ });
1341
+ logger.log(
1342
+ `[CourseDB ${this.id}] Sample displayable data:`,
1343
+ allDisplayableData.docs.map((d) => ({
1344
+ id: d._id,
1345
+ docType: d.docType,
1346
+ dataStructure: d.data ? Object.keys(d.data) : "no data field",
1347
+ dataContent: d.data,
1348
+ fullDoc: d
1349
+ }))
1350
+ );
1351
+ }
1352
+ const allResults = [];
1353
+ for (const dd of displayableData.docs) {
1354
+ const cards = await this.db.find({
1355
+ selector: {
1356
+ docType: "CARD",
1357
+ id_displayable_data: { $in: [dd._id] }
1358
+ }
1359
+ });
1360
+ logger.log(
1361
+ `[CourseDB ${this.id}] Displayable data ${dd._id} linked to ${cards.docs.length} cards`
1362
+ );
1363
+ allResults.push(...cards.docs);
1364
+ }
1365
+ logger.log(`[CourseDB ${this.id}] Total cards found: ${allResults.length}`);
1366
+ return allResults;
1367
+ }
1368
+ async find(request) {
1369
+ return this.db.find(request);
1370
+ }
1288
1371
  };
1289
1372
  }
1290
1373
  });
@@ -1768,6 +1851,9 @@ Currently logged-in as ${this._username}.`
1768
1851
  await this.init();
1769
1852
  return ret;
1770
1853
  }
1854
+ async get(id) {
1855
+ return this.localDB.get(id);
1856
+ }
1771
1857
  update(id, update) {
1772
1858
  return this.updateQueue.update(id, update);
1773
1859
  }