@vue-skuilder/db 0.1.26 → 0.1.27
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.
- package/dist/core/index.d.cts +51 -1
- package/dist/core/index.d.ts +51 -1
- package/dist/core/index.js +337 -2
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +335 -2
- package/dist/core/index.mjs.map +1 -1
- package/dist/impl/couch/index.js +367 -20
- package/dist/impl/couch/index.js.map +1 -1
- package/dist/impl/couch/index.mjs +367 -20
- package/dist/impl/couch/index.mjs.map +1 -1
- package/dist/impl/static/index.js +358 -4
- package/dist/impl/static/index.js.map +1 -1
- package/dist/impl/static/index.mjs +358 -4
- package/dist/impl/static/index.mjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +337 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +335 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/core/UserDBDebugger.ts +466 -0
- package/src/core/index.ts +3 -0
- package/src/core/navigators/filters/hierarchyDefinition.ts +4 -3
package/dist/core/index.d.cts
CHANGED
|
@@ -605,4 +605,54 @@ declare function validateProcessorConfig(config: Partial<BulkCardProcessorConfig
|
|
|
605
605
|
errorMessage?: string;
|
|
606
606
|
};
|
|
607
607
|
|
|
608
|
-
|
|
608
|
+
/**
|
|
609
|
+
* Console API object exposed on window.skuilder.userdb
|
|
610
|
+
*/
|
|
611
|
+
declare const userDBDebugAPI: {
|
|
612
|
+
/**
|
|
613
|
+
* Show current user information
|
|
614
|
+
*/
|
|
615
|
+
showUser(): void;
|
|
616
|
+
/**
|
|
617
|
+
* Show scheduled reviews
|
|
618
|
+
*/
|
|
619
|
+
showScheduledReviews(courseId?: string): Promise<void>;
|
|
620
|
+
/**
|
|
621
|
+
* Show course registrations
|
|
622
|
+
*/
|
|
623
|
+
showCourseRegistrations(): Promise<void>;
|
|
624
|
+
/**
|
|
625
|
+
* Show card history for a specific card
|
|
626
|
+
*/
|
|
627
|
+
showCardHistory(cardId: string): Promise<void>;
|
|
628
|
+
/**
|
|
629
|
+
* Query documents by type
|
|
630
|
+
*/
|
|
631
|
+
queryByType(docType: keyof typeof DocType, limit?: number): Promise<void>;
|
|
632
|
+
/**
|
|
633
|
+
* Show database info and statistics
|
|
634
|
+
*/
|
|
635
|
+
dbInfo(): Promise<void>;
|
|
636
|
+
/**
|
|
637
|
+
* List all document types
|
|
638
|
+
*/
|
|
639
|
+
listDocTypes(): void;
|
|
640
|
+
/**
|
|
641
|
+
* Export database contents (limited, for debugging)
|
|
642
|
+
*/
|
|
643
|
+
export(includeContent?: boolean): Promise<string>;
|
|
644
|
+
/**
|
|
645
|
+
* Execute raw PouchDB query
|
|
646
|
+
*/
|
|
647
|
+
raw(queryFn: (db: PouchDB.Database) => Promise<any>): Promise<void>;
|
|
648
|
+
/**
|
|
649
|
+
* Show help
|
|
650
|
+
*/
|
|
651
|
+
help(): void;
|
|
652
|
+
};
|
|
653
|
+
/**
|
|
654
|
+
* Mount the debug API on window.skuilder.userdb
|
|
655
|
+
*/
|
|
656
|
+
declare function mountUserDBDebugger(): void;
|
|
657
|
+
|
|
658
|
+
export { type BulkCardProcessorConfig, type CardFilter, type CardFilterFactory, type CardGenerator, type CardGeneratorFactory, CardHistory, CardRecord, CourseDBInterface, DocType, DocTypePrefixes, type FilterContext, type FilterImpact, type GeneratorContext, type GeneratorSummary, type GradientObservation, type GradientResult, type ImportResult, LearnableWeight, Loggable, OrchestrationContext, type PeriodUpdateInput, type PeriodUpdateResult, type PipelineRunReport, QuestionRecord, type SignalConfig, StrategyContribution, type StrategyLearningState, type StrategyStateDoc, type StrategyStateId, UserDBInterface, UserOutcomeRecord, WeightedCard, aggregateOutcomesForGradient, areQuestionRecords, buildStrategyStateId, computeOutcomeSignal, computeStrategyGradient, docIsDeleted, getCardHistoryID, getDefaultLearnableWeight, importParsedCards, isQuestionRecord, mountPipelineDebugger, mountUserDBDebugger, parseCardHistoryID, pipelineDebugAPI, recordUserOutcome, runPeriodUpdate, scoreAccuracyInZone, updateLearningState, updateStrategyWeight, userDBDebugAPI, validateProcessorConfig };
|
package/dist/core/index.d.ts
CHANGED
|
@@ -605,4 +605,54 @@ declare function validateProcessorConfig(config: Partial<BulkCardProcessorConfig
|
|
|
605
605
|
errorMessage?: string;
|
|
606
606
|
};
|
|
607
607
|
|
|
608
|
-
|
|
608
|
+
/**
|
|
609
|
+
* Console API object exposed on window.skuilder.userdb
|
|
610
|
+
*/
|
|
611
|
+
declare const userDBDebugAPI: {
|
|
612
|
+
/**
|
|
613
|
+
* Show current user information
|
|
614
|
+
*/
|
|
615
|
+
showUser(): void;
|
|
616
|
+
/**
|
|
617
|
+
* Show scheduled reviews
|
|
618
|
+
*/
|
|
619
|
+
showScheduledReviews(courseId?: string): Promise<void>;
|
|
620
|
+
/**
|
|
621
|
+
* Show course registrations
|
|
622
|
+
*/
|
|
623
|
+
showCourseRegistrations(): Promise<void>;
|
|
624
|
+
/**
|
|
625
|
+
* Show card history for a specific card
|
|
626
|
+
*/
|
|
627
|
+
showCardHistory(cardId: string): Promise<void>;
|
|
628
|
+
/**
|
|
629
|
+
* Query documents by type
|
|
630
|
+
*/
|
|
631
|
+
queryByType(docType: keyof typeof DocType, limit?: number): Promise<void>;
|
|
632
|
+
/**
|
|
633
|
+
* Show database info and statistics
|
|
634
|
+
*/
|
|
635
|
+
dbInfo(): Promise<void>;
|
|
636
|
+
/**
|
|
637
|
+
* List all document types
|
|
638
|
+
*/
|
|
639
|
+
listDocTypes(): void;
|
|
640
|
+
/**
|
|
641
|
+
* Export database contents (limited, for debugging)
|
|
642
|
+
*/
|
|
643
|
+
export(includeContent?: boolean): Promise<string>;
|
|
644
|
+
/**
|
|
645
|
+
* Execute raw PouchDB query
|
|
646
|
+
*/
|
|
647
|
+
raw(queryFn: (db: PouchDB.Database) => Promise<any>): Promise<void>;
|
|
648
|
+
/**
|
|
649
|
+
* Show help
|
|
650
|
+
*/
|
|
651
|
+
help(): void;
|
|
652
|
+
};
|
|
653
|
+
/**
|
|
654
|
+
* Mount the debug API on window.skuilder.userdb
|
|
655
|
+
*/
|
|
656
|
+
declare function mountUserDBDebugger(): void;
|
|
657
|
+
|
|
658
|
+
export { type BulkCardProcessorConfig, type CardFilter, type CardFilterFactory, type CardGenerator, type CardGeneratorFactory, CardHistory, CardRecord, CourseDBInterface, DocType, DocTypePrefixes, type FilterContext, type FilterImpact, type GeneratorContext, type GeneratorSummary, type GradientObservation, type GradientResult, type ImportResult, LearnableWeight, Loggable, OrchestrationContext, type PeriodUpdateInput, type PeriodUpdateResult, type PipelineRunReport, QuestionRecord, type SignalConfig, StrategyContribution, type StrategyLearningState, type StrategyStateDoc, type StrategyStateId, UserDBInterface, UserOutcomeRecord, WeightedCard, aggregateOutcomesForGradient, areQuestionRecords, buildStrategyStateId, computeOutcomeSignal, computeStrategyGradient, docIsDeleted, getCardHistoryID, getDefaultLearnableWeight, importParsedCards, isQuestionRecord, mountPipelineDebugger, mountUserDBDebugger, parseCardHistoryID, pipelineDebugAPI, recordUserOutcome, runPeriodUpdate, scoreAccuracyInZone, updateLearningState, updateStrategyWeight, userDBDebugAPI, validateProcessorConfig };
|
package/dist/core/index.js
CHANGED
|
@@ -1742,7 +1742,7 @@ var init_hierarchyDefinition = __esm({
|
|
|
1742
1742
|
/**
|
|
1743
1743
|
* CardFilter.transform implementation.
|
|
1744
1744
|
*
|
|
1745
|
-
* Apply prerequisite gating to cards. Cards with locked tags receive score
|
|
1745
|
+
* Apply prerequisite gating to cards. Cards with locked tags receive score * 0.01.
|
|
1746
1746
|
*/
|
|
1747
1747
|
async transform(cards, context) {
|
|
1748
1748
|
const masteredTags = await this.getMasteredTags(context);
|
|
@@ -1755,7 +1755,8 @@ var init_hierarchyDefinition = __esm({
|
|
|
1755
1755
|
unlockedTags,
|
|
1756
1756
|
masteredTags
|
|
1757
1757
|
);
|
|
1758
|
-
const
|
|
1758
|
+
const LOCKED_PENALTY = 0.01;
|
|
1759
|
+
const finalScore = isUnlocked ? card.score : card.score * LOCKED_PENALTY;
|
|
1759
1760
|
const action = isUnlocked ? "passed" : "penalized";
|
|
1760
1761
|
gated.push({
|
|
1761
1762
|
...card,
|
|
@@ -5803,6 +5804,335 @@ var init_bulkImport = __esm({
|
|
|
5803
5804
|
}
|
|
5804
5805
|
});
|
|
5805
5806
|
|
|
5807
|
+
// src/core/UserDBDebugger.ts
|
|
5808
|
+
function getUserDB() {
|
|
5809
|
+
try {
|
|
5810
|
+
const provider = getDataLayer();
|
|
5811
|
+
return provider.getUserDB();
|
|
5812
|
+
} catch {
|
|
5813
|
+
logger.info("[UserDB Debug] Data layer not initialized yet.");
|
|
5814
|
+
return null;
|
|
5815
|
+
}
|
|
5816
|
+
}
|
|
5817
|
+
function getRawDB() {
|
|
5818
|
+
const userDB = getUserDB();
|
|
5819
|
+
if (!userDB) return null;
|
|
5820
|
+
const rawDB = userDB.localDB;
|
|
5821
|
+
if (!rawDB) {
|
|
5822
|
+
logger.info("[UserDB Debug] Unable to access raw database instance.");
|
|
5823
|
+
return null;
|
|
5824
|
+
}
|
|
5825
|
+
return rawDB;
|
|
5826
|
+
}
|
|
5827
|
+
function formatTimestamp(isoString) {
|
|
5828
|
+
const date = new Date(isoString);
|
|
5829
|
+
return date.toLocaleString();
|
|
5830
|
+
}
|
|
5831
|
+
function mountUserDBDebugger() {
|
|
5832
|
+
if (typeof window === "undefined") return;
|
|
5833
|
+
const win = window;
|
|
5834
|
+
win.skuilder = win.skuilder || {};
|
|
5835
|
+
win.skuilder.userdb = userDBDebugAPI;
|
|
5836
|
+
}
|
|
5837
|
+
var userDBDebugAPI;
|
|
5838
|
+
var init_UserDBDebugger = __esm({
|
|
5839
|
+
"src/core/UserDBDebugger.ts"() {
|
|
5840
|
+
"use strict";
|
|
5841
|
+
init_logger();
|
|
5842
|
+
init_factory();
|
|
5843
|
+
init_types_legacy();
|
|
5844
|
+
init_userDBHelpers();
|
|
5845
|
+
userDBDebugAPI = {
|
|
5846
|
+
/**
|
|
5847
|
+
* Show current user information
|
|
5848
|
+
*/
|
|
5849
|
+
showUser() {
|
|
5850
|
+
const userDB = getUserDB();
|
|
5851
|
+
if (!userDB) return;
|
|
5852
|
+
console.group("\u{1F464} User Information");
|
|
5853
|
+
logger.info(`Username: ${userDB.getUsername()}`);
|
|
5854
|
+
logger.info(`Logged in: ${userDB.isLoggedIn() ? "Yes \u2705" : "No (Guest) \u274C"}`);
|
|
5855
|
+
userDB.getConfig().then((config) => {
|
|
5856
|
+
logger.info("Configuration:");
|
|
5857
|
+
logger.info(JSON.stringify(config, null, 2));
|
|
5858
|
+
}).catch((err) => {
|
|
5859
|
+
logger.info(`Error loading config: ${err.message}`);
|
|
5860
|
+
}).finally(() => {
|
|
5861
|
+
console.groupEnd();
|
|
5862
|
+
});
|
|
5863
|
+
},
|
|
5864
|
+
/**
|
|
5865
|
+
* Show scheduled reviews
|
|
5866
|
+
*/
|
|
5867
|
+
async showScheduledReviews(courseId) {
|
|
5868
|
+
const userDB = getUserDB();
|
|
5869
|
+
if (!userDB) return;
|
|
5870
|
+
try {
|
|
5871
|
+
const reviews = await userDB.getPendingReviews(courseId);
|
|
5872
|
+
console.group(`\u{1F4C5} Scheduled Reviews${courseId ? ` (${courseId})` : ""}`);
|
|
5873
|
+
logger.info(`Total: ${reviews.length}`);
|
|
5874
|
+
if (reviews.length > 0) {
|
|
5875
|
+
const byCourse = /* @__PURE__ */ new Map();
|
|
5876
|
+
for (const review of reviews) {
|
|
5877
|
+
if (!byCourse.has(review.courseId)) {
|
|
5878
|
+
byCourse.set(review.courseId, []);
|
|
5879
|
+
}
|
|
5880
|
+
byCourse.get(review.courseId).push(review);
|
|
5881
|
+
}
|
|
5882
|
+
for (const [course, courseReviews] of byCourse) {
|
|
5883
|
+
console.group(`Course: ${course} (${courseReviews.length} reviews)`);
|
|
5884
|
+
const sorted = courseReviews.sort((a, b) => {
|
|
5885
|
+
const timeA = typeof a.reviewTime === "string" ? a.reviewTime : a.reviewTime.toISOString();
|
|
5886
|
+
const timeB = typeof b.reviewTime === "string" ? b.reviewTime : b.reviewTime.toISOString();
|
|
5887
|
+
return new Date(timeA).getTime() - new Date(timeB).getTime();
|
|
5888
|
+
});
|
|
5889
|
+
for (const review of sorted.slice(0, 10)) {
|
|
5890
|
+
const reviewTimeStr = typeof review.reviewTime === "string" ? review.reviewTime : review.reviewTime.toISOString();
|
|
5891
|
+
logger.info(
|
|
5892
|
+
` ${review.cardId.slice(0, 12)}... @ ${formatTimestamp(reviewTimeStr)} [${review.scheduledFor}/${review.schedulingAgentId}]`
|
|
5893
|
+
);
|
|
5894
|
+
}
|
|
5895
|
+
if (sorted.length > 10) {
|
|
5896
|
+
logger.info(` ... and ${sorted.length - 10} more`);
|
|
5897
|
+
}
|
|
5898
|
+
console.groupEnd();
|
|
5899
|
+
}
|
|
5900
|
+
}
|
|
5901
|
+
console.groupEnd();
|
|
5902
|
+
} catch (err) {
|
|
5903
|
+
logger.info(`Error loading scheduled reviews: ${err.message}`);
|
|
5904
|
+
}
|
|
5905
|
+
},
|
|
5906
|
+
/**
|
|
5907
|
+
* Show course registrations
|
|
5908
|
+
*/
|
|
5909
|
+
async showCourseRegistrations() {
|
|
5910
|
+
const userDB = getUserDB();
|
|
5911
|
+
if (!userDB) return;
|
|
5912
|
+
try {
|
|
5913
|
+
const registrations = await userDB.getActiveCourses();
|
|
5914
|
+
console.group("\u{1F4DA} Course Registrations");
|
|
5915
|
+
logger.info(`Total: ${registrations.length}`);
|
|
5916
|
+
if (registrations.length > 0) {
|
|
5917
|
+
console.table(
|
|
5918
|
+
registrations.map((reg) => ({
|
|
5919
|
+
courseId: reg.courseID,
|
|
5920
|
+
status: reg.status || "active",
|
|
5921
|
+
elo: typeof reg.elo === "number" ? reg.elo.toFixed(0) : reg.elo?.global?.score?.toFixed(0) || "N/A"
|
|
5922
|
+
}))
|
|
5923
|
+
);
|
|
5924
|
+
}
|
|
5925
|
+
console.groupEnd();
|
|
5926
|
+
} catch (err) {
|
|
5927
|
+
logger.info(`Error loading course registrations: ${err.message}`);
|
|
5928
|
+
}
|
|
5929
|
+
},
|
|
5930
|
+
/**
|
|
5931
|
+
* Show card history for a specific card
|
|
5932
|
+
*/
|
|
5933
|
+
async showCardHistory(cardId) {
|
|
5934
|
+
const rawDB = getRawDB();
|
|
5935
|
+
if (!rawDB) return;
|
|
5936
|
+
try {
|
|
5937
|
+
const result = await filterAllDocsByPrefix(rawDB, DocTypePrefixes["CARDRECORD" /* CARDRECORD */]);
|
|
5938
|
+
const cardHistories = result.rows.filter((row) => row.doc && row.doc.cardID === cardId).map((row) => row.doc);
|
|
5939
|
+
console.group(`\u{1F3B4} Card History: ${cardId}`);
|
|
5940
|
+
logger.info(`Total interactions: ${cardHistories.length}`);
|
|
5941
|
+
if (cardHistories.length > 0) {
|
|
5942
|
+
const sorted = cardHistories.sort(
|
|
5943
|
+
(a, b) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime()
|
|
5944
|
+
);
|
|
5945
|
+
console.table(
|
|
5946
|
+
sorted.slice(0, 20).map((doc) => ({
|
|
5947
|
+
time: formatTimestamp(doc.timestamp),
|
|
5948
|
+
outcome: doc.outcome || "N/A",
|
|
5949
|
+
duration: doc.duration ? `${(doc.duration / 1e3).toFixed(1)}s` : "N/A",
|
|
5950
|
+
courseId: doc.courseId
|
|
5951
|
+
}))
|
|
5952
|
+
);
|
|
5953
|
+
if (sorted.length > 20) {
|
|
5954
|
+
logger.info(`... and ${sorted.length - 20} more interactions`);
|
|
5955
|
+
}
|
|
5956
|
+
}
|
|
5957
|
+
console.groupEnd();
|
|
5958
|
+
} catch (err) {
|
|
5959
|
+
logger.info(`Error loading card history: ${err.message}`);
|
|
5960
|
+
}
|
|
5961
|
+
},
|
|
5962
|
+
/**
|
|
5963
|
+
* Query documents by type
|
|
5964
|
+
*/
|
|
5965
|
+
async queryByType(docType, limit = 50) {
|
|
5966
|
+
const rawDB = getRawDB();
|
|
5967
|
+
if (!rawDB) return;
|
|
5968
|
+
try {
|
|
5969
|
+
const prefix = DocTypePrefixes[DocType[docType]];
|
|
5970
|
+
if (!prefix) {
|
|
5971
|
+
logger.info(`Unknown document type: ${docType}`);
|
|
5972
|
+
return;
|
|
5973
|
+
}
|
|
5974
|
+
const result = await filterAllDocsByPrefix(rawDB, prefix);
|
|
5975
|
+
console.group(`\u{1F4C4} Documents: ${docType}`);
|
|
5976
|
+
logger.info(`Total: ${result.rows.length}`);
|
|
5977
|
+
logger.info(`Prefix: ${prefix}`);
|
|
5978
|
+
if (result.rows.length > 0) {
|
|
5979
|
+
logger.info("Sample documents:");
|
|
5980
|
+
const samples = result.rows.slice(0, Math.min(limit, result.rows.length));
|
|
5981
|
+
for (const row of samples) {
|
|
5982
|
+
logger.info(`
|
|
5983
|
+
${row.id}:`);
|
|
5984
|
+
logger.info(JSON.stringify(row.doc, null, 2));
|
|
5985
|
+
}
|
|
5986
|
+
if (result.rows.length > limit) {
|
|
5987
|
+
logger.info(`
|
|
5988
|
+
... and ${result.rows.length - limit} more documents`);
|
|
5989
|
+
}
|
|
5990
|
+
}
|
|
5991
|
+
console.groupEnd();
|
|
5992
|
+
} catch (err) {
|
|
5993
|
+
logger.info(`Error querying documents: ${err.message}`);
|
|
5994
|
+
}
|
|
5995
|
+
},
|
|
5996
|
+
/**
|
|
5997
|
+
* Show database info and statistics
|
|
5998
|
+
*/
|
|
5999
|
+
async dbInfo() {
|
|
6000
|
+
const rawDB = getRawDB();
|
|
6001
|
+
if (!rawDB) return;
|
|
6002
|
+
try {
|
|
6003
|
+
const info = await rawDB.info();
|
|
6004
|
+
console.group("\u2139\uFE0F Database Information");
|
|
6005
|
+
logger.info(`Database name: ${info.db_name}`);
|
|
6006
|
+
logger.info(`Total documents: ${info.doc_count}`);
|
|
6007
|
+
logger.info(`Update sequence: ${info.update_seq}`);
|
|
6008
|
+
if ("disk_size" in info) {
|
|
6009
|
+
logger.info(`Disk size: ${(info.disk_size || 0) / 1024 / 1024} MB`);
|
|
6010
|
+
}
|
|
6011
|
+
logger.info("\nDocument counts by type:");
|
|
6012
|
+
const allDocs = await rawDB.allDocs({ include_docs: false });
|
|
6013
|
+
const typeCounts = /* @__PURE__ */ new Map();
|
|
6014
|
+
for (const row of allDocs.rows) {
|
|
6015
|
+
let prefix = "other";
|
|
6016
|
+
for (const [type, typePrefix] of Object.entries(DocTypePrefixes)) {
|
|
6017
|
+
if (row.id.startsWith(typePrefix)) {
|
|
6018
|
+
prefix = type;
|
|
6019
|
+
break;
|
|
6020
|
+
}
|
|
6021
|
+
}
|
|
6022
|
+
typeCounts.set(prefix, (typeCounts.get(prefix) || 0) + 1);
|
|
6023
|
+
}
|
|
6024
|
+
console.table(
|
|
6025
|
+
Array.from(typeCounts.entries()).sort((a, b) => b[1] - a[1]).map(([type, count]) => ({ type, count }))
|
|
6026
|
+
);
|
|
6027
|
+
console.groupEnd();
|
|
6028
|
+
} catch (err) {
|
|
6029
|
+
logger.info(`Error getting database info: ${err.message}`);
|
|
6030
|
+
}
|
|
6031
|
+
},
|
|
6032
|
+
/**
|
|
6033
|
+
* List all document types
|
|
6034
|
+
*/
|
|
6035
|
+
listDocTypes() {
|
|
6036
|
+
console.group("\u{1F4CB} Available Document Types");
|
|
6037
|
+
logger.info("Use with queryByType(type):");
|
|
6038
|
+
for (const [type, prefix] of Object.entries(DocTypePrefixes)) {
|
|
6039
|
+
logger.info(` ${type.padEnd(30)} \u2192 prefix: "${prefix}"`);
|
|
6040
|
+
}
|
|
6041
|
+
console.groupEnd();
|
|
6042
|
+
},
|
|
6043
|
+
/**
|
|
6044
|
+
* Export database contents (limited, for debugging)
|
|
6045
|
+
*/
|
|
6046
|
+
async export(includeContent = false) {
|
|
6047
|
+
const rawDB = getRawDB();
|
|
6048
|
+
const userDB = getUserDB();
|
|
6049
|
+
if (!rawDB || !userDB) return "{}";
|
|
6050
|
+
try {
|
|
6051
|
+
const data = {
|
|
6052
|
+
username: userDB.getUsername(),
|
|
6053
|
+
loggedIn: userDB.isLoggedIn(),
|
|
6054
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
6055
|
+
};
|
|
6056
|
+
if (includeContent) {
|
|
6057
|
+
const allDocs = await rawDB.allDocs({ include_docs: true });
|
|
6058
|
+
data.documents = allDocs.rows.map((row) => ({
|
|
6059
|
+
id: row.id,
|
|
6060
|
+
doc: row.doc
|
|
6061
|
+
}));
|
|
6062
|
+
data.totalDocs = allDocs.rows.length;
|
|
6063
|
+
} else {
|
|
6064
|
+
const allDocs = await rawDB.allDocs({ include_docs: false });
|
|
6065
|
+
data.totalDocs = allDocs.rows.length;
|
|
6066
|
+
const typeCounts = /* @__PURE__ */ new Map();
|
|
6067
|
+
for (const row of allDocs.rows) {
|
|
6068
|
+
let prefix = "other";
|
|
6069
|
+
for (const [type, typePrefix] of Object.entries(DocTypePrefixes)) {
|
|
6070
|
+
if (row.id.startsWith(typePrefix)) {
|
|
6071
|
+
prefix = type;
|
|
6072
|
+
break;
|
|
6073
|
+
}
|
|
6074
|
+
}
|
|
6075
|
+
typeCounts.set(prefix, (typeCounts.get(prefix) || 0) + 1);
|
|
6076
|
+
}
|
|
6077
|
+
data.docCounts = Object.fromEntries(typeCounts);
|
|
6078
|
+
}
|
|
6079
|
+
const json = JSON.stringify(data, null, 2);
|
|
6080
|
+
logger.info("[UserDB Debug] Database info exported. Copy the returned string or use:");
|
|
6081
|
+
logger.info(" copy(window.skuilder.userdb.export())");
|
|
6082
|
+
if (!includeContent) {
|
|
6083
|
+
logger.info(" For full content export: window.skuilder.userdb.export(true)");
|
|
6084
|
+
}
|
|
6085
|
+
return json;
|
|
6086
|
+
} catch (err) {
|
|
6087
|
+
logger.info(`Error exporting database: ${err.message}`);
|
|
6088
|
+
return "{}";
|
|
6089
|
+
}
|
|
6090
|
+
},
|
|
6091
|
+
/**
|
|
6092
|
+
* Execute raw PouchDB query
|
|
6093
|
+
*/
|
|
6094
|
+
async raw(queryFn) {
|
|
6095
|
+
const rawDB = getRawDB();
|
|
6096
|
+
if (!rawDB) return;
|
|
6097
|
+
try {
|
|
6098
|
+
const result = await queryFn(rawDB);
|
|
6099
|
+
logger.info("[UserDB Debug] Query result:");
|
|
6100
|
+
logger.info(result);
|
|
6101
|
+
} catch (err) {
|
|
6102
|
+
logger.info(`[UserDB Debug] Query error: ${err.message}`);
|
|
6103
|
+
}
|
|
6104
|
+
},
|
|
6105
|
+
/**
|
|
6106
|
+
* Show help
|
|
6107
|
+
*/
|
|
6108
|
+
help() {
|
|
6109
|
+
logger.info(`
|
|
6110
|
+
\u{1F527} UserDB Debug API
|
|
6111
|
+
|
|
6112
|
+
Commands:
|
|
6113
|
+
.showUser() Show current user info and config
|
|
6114
|
+
.showScheduledReviews(courseId?) Show scheduled reviews (optionally filter by course)
|
|
6115
|
+
.showCourseRegistrations() Show all course registrations
|
|
6116
|
+
.showCardHistory(cardId) Show interaction history for a card
|
|
6117
|
+
.queryByType(docType, limit?) Query documents by type (e.g., 'SCHEDULED_CARD')
|
|
6118
|
+
.listDocTypes() List all available document types
|
|
6119
|
+
.dbInfo() Show database info and statistics
|
|
6120
|
+
.export(includeContent?) Export database info (true = include all docs)
|
|
6121
|
+
.raw(queryFn) Execute raw PouchDB query
|
|
6122
|
+
.help() Show this help message
|
|
6123
|
+
|
|
6124
|
+
Examples:
|
|
6125
|
+
window.skuilder.userdb.showUser()
|
|
6126
|
+
window.skuilder.userdb.showScheduledReviews('course123')
|
|
6127
|
+
window.skuilder.userdb.queryByType('SCHEDULED_CARD', 10)
|
|
6128
|
+
window.skuilder.userdb.raw(db => db.allDocs({ limit: 5 }))
|
|
6129
|
+
`);
|
|
6130
|
+
}
|
|
6131
|
+
};
|
|
6132
|
+
mountUserDBDebugger();
|
|
6133
|
+
}
|
|
6134
|
+
});
|
|
6135
|
+
|
|
5806
6136
|
// src/core/index.ts
|
|
5807
6137
|
var core_exports = {};
|
|
5808
6138
|
__export(core_exports, {
|
|
@@ -5839,6 +6169,7 @@ __export(core_exports, {
|
|
|
5839
6169
|
isReview: () => isReview,
|
|
5840
6170
|
log: () => log,
|
|
5841
6171
|
mountPipelineDebugger: () => mountPipelineDebugger,
|
|
6172
|
+
mountUserDBDebugger: () => mountUserDBDebugger,
|
|
5842
6173
|
parseCardHistoryID: () => parseCardHistoryID,
|
|
5843
6174
|
pipelineDebugAPI: () => pipelineDebugAPI,
|
|
5844
6175
|
recordUserOutcome: () => recordUserOutcome,
|
|
@@ -5847,6 +6178,7 @@ __export(core_exports, {
|
|
|
5847
6178
|
scoreAccuracyInZone: () => scoreAccuracyInZone,
|
|
5848
6179
|
updateLearningState: () => updateLearningState,
|
|
5849
6180
|
updateStrategyWeight: () => updateStrategyWeight,
|
|
6181
|
+
userDBDebugAPI: () => userDBDebugAPI,
|
|
5850
6182
|
validateProcessorConfig: () => validateProcessorConfig
|
|
5851
6183
|
});
|
|
5852
6184
|
module.exports = __toCommonJS(core_exports);
|
|
@@ -5862,6 +6194,7 @@ var init_core = __esm({
|
|
|
5862
6194
|
init_navigators();
|
|
5863
6195
|
init_bulkImport();
|
|
5864
6196
|
init_orchestration();
|
|
6197
|
+
init_UserDBDebugger();
|
|
5865
6198
|
}
|
|
5866
6199
|
});
|
|
5867
6200
|
init_core();
|
|
@@ -5900,6 +6233,7 @@ init_core();
|
|
|
5900
6233
|
isReview,
|
|
5901
6234
|
log,
|
|
5902
6235
|
mountPipelineDebugger,
|
|
6236
|
+
mountUserDBDebugger,
|
|
5903
6237
|
parseCardHistoryID,
|
|
5904
6238
|
pipelineDebugAPI,
|
|
5905
6239
|
recordUserOutcome,
|
|
@@ -5908,6 +6242,7 @@ init_core();
|
|
|
5908
6242
|
scoreAccuracyInZone,
|
|
5909
6243
|
updateLearningState,
|
|
5910
6244
|
updateStrategyWeight,
|
|
6245
|
+
userDBDebugAPI,
|
|
5911
6246
|
validateProcessorConfig
|
|
5912
6247
|
});
|
|
5913
6248
|
//# sourceMappingURL=index.js.map
|