@vue-skuilder/db 0.1.6 → 0.1.8-0
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/{SyncStrategy-DnJRj-Xp.d.mts → SyncStrategy-CyATpyLQ.d.mts} +6 -0
- package/dist/{SyncStrategy-DnJRj-Xp.d.ts → SyncStrategy-CyATpyLQ.d.ts} +6 -0
- package/dist/core/index.d.mts +5 -5
- package/dist/core/index.d.ts +5 -5
- package/dist/core/index.js +825 -762
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +812 -750
- package/dist/core/index.mjs.map +1 -1
- package/dist/{dataLayerProvider-BZmLyBVw.d.mts → dataLayerProvider-BInqI_RF.d.mts} +1 -1
- package/dist/{dataLayerProvider-BuntXkCs.d.ts → dataLayerProvider-DqtNroSh.d.ts} +1 -1
- package/dist/impl/couch/index.d.mts +6 -6
- package/dist/impl/couch/index.d.ts +6 -6
- package/dist/impl/couch/index.js +2261 -2081
- package/dist/impl/couch/index.js.map +1 -1
- package/dist/impl/couch/index.mjs +2274 -2095
- package/dist/impl/couch/index.mjs.map +1 -1
- package/dist/impl/static/index.d.mts +8 -6
- package/dist/impl/static/index.d.ts +8 -6
- package/dist/impl/static/index.js +524 -1064
- package/dist/impl/static/index.js.map +1 -1
- package/dist/impl/static/index.mjs +515 -1058
- package/dist/impl/static/index.mjs.map +1 -1
- package/dist/index-CLL31bEy.d.ts +137 -0
- package/dist/index-CUNnL38E.d.mts +137 -0
- package/dist/index.d.mts +200 -9
- package/dist/index.d.ts +200 -9
- package/dist/index.js +4123 -2820
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4119 -2830
- package/dist/index.mjs.map +1 -1
- package/dist/{types-D6SnlHPm.d.ts → types-BefDGkKa.d.ts} +1 -1
- package/dist/{types-DPRvCrIk.d.mts → types-DC-ckZug.d.mts} +1 -1
- package/dist/{types-legacy-WPe8CtO-.d.mts → types-legacy-Birv-Jx6.d.mts} +2 -2
- package/dist/{types-legacy-WPe8CtO-.d.ts → types-legacy-Birv-Jx6.d.ts} +2 -2
- package/dist/{userDB-D9EuWTp1.d.ts → userDB-C33Hzjgn.d.mts} +11 -4
- package/dist/{userDB-31gsvxyd.d.mts → userDB-DusL7OXe.d.ts} +11 -4
- package/dist/util/packer/index.d.mts +3 -63
- package/dist/util/packer/index.d.ts +3 -63
- package/dist/util/packer/index.js +53 -1
- package/dist/util/packer/index.js.map +1 -1
- package/dist/util/packer/index.mjs +53 -1
- package/dist/util/packer/index.mjs.map +1 -1
- package/package.json +7 -4
- package/src/core/types/types-legacy.ts +13 -1
- package/src/core/types/user.ts +9 -2
- package/src/core/util/index.ts +5 -4
- package/src/factory.ts +25 -0
- package/src/impl/common/BaseUserDB.ts +62 -28
- package/src/impl/common/SyncStrategy.ts +7 -0
- package/src/impl/common/index.ts +0 -1
- package/src/impl/common/userDBHelpers.ts +15 -5
- package/src/impl/couch/CouchDBSyncStrategy.ts +10 -0
- package/src/impl/couch/courseAPI.ts +7 -6
- package/src/impl/couch/courseLookupDB.ts +24 -0
- package/src/impl/couch/index.ts +10 -5
- package/src/impl/couch/updateQueue.ts +12 -8
- package/src/impl/couch/user-course-relDB.ts +17 -27
- package/src/impl/static/NoOpSyncStrategy.ts +5 -0
- package/src/impl/static/StaticDataUnpacker.ts +18 -36
- package/src/impl/static/courseDB.ts +135 -17
- package/src/util/dataDirectory.test.ts +53 -0
- package/src/util/dataDirectory.ts +52 -0
- package/src/util/index.ts +3 -0
- package/src/util/migrator/FileSystemAdapter.ts +79 -0
- package/src/util/migrator/StaticToCouchDBMigrator.ts +713 -0
- package/src/util/migrator/index.ts +18 -0
- package/src/util/migrator/types.ts +84 -0
- package/src/util/migrator/validation.ts +517 -0
- package/src/util/packer/CouchDBToStaticPacker.ts +92 -2
- package/src/util/tuiLogger.ts +139 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,199 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import { D as DataLayerProvider } from './dataLayerProvider-
|
|
4
|
-
import { C as CardRecord } from './types-legacy-
|
|
5
|
-
export { b as CardData, g as CardHistory, c as CourseListData, e as DataShapeData, d as DisplayableData, D as DocType, F as Field, G as GuestUsername, Q as QuestionData, h as QuestionRecord, S as SkuilderCourseData,
|
|
1
|
+
import { j as StudySessionItem, h as StudyContentSource } 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 CourseDBInterface, c as CourseInfo, E as CourseRegistration, F as CourseRegistrationDoc, a as CoursesDBInterface, G as DocumentUpdater, f as ScheduledCard, i as StudentClassroomDBInterface, k as StudySessionFailedItem, l as StudySessionFailedNewItem, m as StudySessionFailedReviewItem, S as StudySessionNewItem, e as StudySessionReviewItem, T as TeacherClassroomDBInterface, z as UserConfig, u as UserCourseSetting, t as UserCourseSettings, U as UserDBInterface, v as UsrCrsDataInterface, p as getStudySource, n as isReview, H as newInterval } from './userDB-DusL7OXe.js';
|
|
3
|
+
import { D as DataLayerProvider } from './dataLayerProvider-DqtNroSh.js';
|
|
4
|
+
import { C as CardRecord } from './types-legacy-Birv-Jx6.js';
|
|
5
|
+
export { b as CardData, g as CardHistory, c as CourseListData, e as DataShapeData, d as DisplayableData, D as DocType, f as DocTypePrefixes, F as Field, G as GuestUsername, Q as QuestionData, h as QuestionRecord, S as SkuilderCourseData, a as Tag, T as TagStub, l as log } from './types-legacy-Birv-Jx6.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 { S as StaticCourseManifest } from './types-
|
|
9
|
-
export { A as AttachmentData, C as ChunkMetadata, D as DesignDocument, I as IndexMetadata, a as PackedCourseData, P as PackerConfig } from './types-
|
|
10
|
-
|
|
8
|
+
import { S as StaticCourseManifest } from './types-BefDGkKa.js';
|
|
9
|
+
export { A as AttachmentData, C as ChunkMetadata, D as DesignDocument, I as IndexMetadata, a as PackedCourseData, P as PackerConfig } from './types-BefDGkKa.js';
|
|
10
|
+
import { F as FileSystemAdapter } from './index-CLL31bEy.js';
|
|
11
|
+
export { C as CouchDBToStaticPacker, a as FileStats, b as FileSystemError } from './index-CLL31bEy.js';
|
|
11
12
|
import '@vue-skuilder/common';
|
|
12
13
|
import 'moment';
|
|
13
14
|
|
|
15
|
+
interface MigrationOptions {
|
|
16
|
+
chunkBatchSize: number;
|
|
17
|
+
validateRoundTrip: boolean;
|
|
18
|
+
cleanupOnFailure: boolean;
|
|
19
|
+
timeout: number;
|
|
20
|
+
}
|
|
21
|
+
interface MigrationResult {
|
|
22
|
+
success: boolean;
|
|
23
|
+
documentsRestored: number;
|
|
24
|
+
attachmentsRestored: number;
|
|
25
|
+
designDocsRestored: number;
|
|
26
|
+
courseConfigRestored: number;
|
|
27
|
+
errors: string[];
|
|
28
|
+
warnings: string[];
|
|
29
|
+
migrationTime: number;
|
|
30
|
+
tempDatabaseName?: string;
|
|
31
|
+
}
|
|
32
|
+
interface ValidationResult {
|
|
33
|
+
valid: boolean;
|
|
34
|
+
documentCountMatch: boolean;
|
|
35
|
+
attachmentIntegrity: boolean;
|
|
36
|
+
viewFunctionality: boolean;
|
|
37
|
+
issues: ValidationIssue[];
|
|
38
|
+
}
|
|
39
|
+
interface ValidationIssue {
|
|
40
|
+
type: 'error' | 'warning';
|
|
41
|
+
category: 'documents' | 'attachments' | 'views' | 'metadata' | 'course_config';
|
|
42
|
+
message: string;
|
|
43
|
+
details?: any;
|
|
44
|
+
}
|
|
45
|
+
interface DocumentCounts {
|
|
46
|
+
[docType: string]: number;
|
|
47
|
+
}
|
|
48
|
+
interface RestoreProgress {
|
|
49
|
+
phase: 'manifest' | 'design_docs' | 'course_config' | 'documents' | 'attachments' | 'validation';
|
|
50
|
+
current: number;
|
|
51
|
+
total: number;
|
|
52
|
+
message: string;
|
|
53
|
+
}
|
|
54
|
+
interface StaticCourseValidation {
|
|
55
|
+
valid: boolean;
|
|
56
|
+
manifestExists: boolean;
|
|
57
|
+
chunksExist: boolean;
|
|
58
|
+
attachmentsExist: boolean;
|
|
59
|
+
errors: string[];
|
|
60
|
+
warnings: string[];
|
|
61
|
+
courseId?: string;
|
|
62
|
+
courseName?: string;
|
|
63
|
+
}
|
|
64
|
+
interface AggregatedDocument {
|
|
65
|
+
_id: string;
|
|
66
|
+
_attachments?: Record<string, any>;
|
|
67
|
+
docType: string;
|
|
68
|
+
[key: string]: any;
|
|
69
|
+
}
|
|
70
|
+
interface AttachmentUploadResult {
|
|
71
|
+
success: boolean;
|
|
72
|
+
attachmentName: string;
|
|
73
|
+
docId: string;
|
|
74
|
+
error?: string;
|
|
75
|
+
}
|
|
76
|
+
declare const DEFAULT_MIGRATION_OPTIONS: MigrationOptions;
|
|
77
|
+
|
|
78
|
+
declare class StaticToCouchDBMigrator {
|
|
79
|
+
private options;
|
|
80
|
+
private progressCallback?;
|
|
81
|
+
private fs?;
|
|
82
|
+
constructor(options?: Partial<MigrationOptions>, fileSystemAdapter?: FileSystemAdapter);
|
|
83
|
+
/**
|
|
84
|
+
* Set a progress callback to receive updates during migration
|
|
85
|
+
*/
|
|
86
|
+
setProgressCallback(callback: (progress: RestoreProgress) => void): void;
|
|
87
|
+
/**
|
|
88
|
+
* Migrate a static course to CouchDB
|
|
89
|
+
*/
|
|
90
|
+
migrateCourse(staticPath: string, targetDB: PouchDB.Database): Promise<MigrationResult>;
|
|
91
|
+
/**
|
|
92
|
+
* Load and parse the manifest file
|
|
93
|
+
*/
|
|
94
|
+
private loadManifest;
|
|
95
|
+
/**
|
|
96
|
+
* Restore design documents to CouchDB
|
|
97
|
+
*/
|
|
98
|
+
private restoreDesignDocuments;
|
|
99
|
+
/**
|
|
100
|
+
* Aggregate documents from all chunks
|
|
101
|
+
*/
|
|
102
|
+
private aggregateDocuments;
|
|
103
|
+
/**
|
|
104
|
+
* Load documents from a single chunk file
|
|
105
|
+
*/
|
|
106
|
+
private loadChunk;
|
|
107
|
+
/**
|
|
108
|
+
* Upload documents to CouchDB in batches
|
|
109
|
+
*/
|
|
110
|
+
private uploadDocuments;
|
|
111
|
+
/**
|
|
112
|
+
* Upload attachments from filesystem to CouchDB
|
|
113
|
+
*/
|
|
114
|
+
private uploadAttachments;
|
|
115
|
+
/**
|
|
116
|
+
* Upload a single attachment file
|
|
117
|
+
*/
|
|
118
|
+
private uploadSingleAttachment;
|
|
119
|
+
/**
|
|
120
|
+
* Restore CourseConfig document from manifest
|
|
121
|
+
*/
|
|
122
|
+
private restoreCourseConfig;
|
|
123
|
+
/**
|
|
124
|
+
* Calculate expected document counts from manifest
|
|
125
|
+
*/
|
|
126
|
+
private calculateExpectedCounts;
|
|
127
|
+
/**
|
|
128
|
+
* Clean up database after failed migration
|
|
129
|
+
*/
|
|
130
|
+
private cleanupFailedMigration;
|
|
131
|
+
/**
|
|
132
|
+
* Report progress to callback if available
|
|
133
|
+
*/
|
|
134
|
+
private reportProgress;
|
|
135
|
+
/**
|
|
136
|
+
* Check if a path is a local file path (vs URL)
|
|
137
|
+
*/
|
|
138
|
+
private isLocalPath;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Validate that a static course directory contains all required files
|
|
143
|
+
*/
|
|
144
|
+
declare function validateStaticCourse(staticPath: string, fs?: FileSystemAdapter): Promise<StaticCourseValidation>;
|
|
145
|
+
/**
|
|
146
|
+
* Validate the result of a migration by checking document counts and integrity
|
|
147
|
+
*/
|
|
148
|
+
declare function validateMigration(targetDB: PouchDB.Database, expectedCounts: DocumentCounts, manifest: StaticCourseManifest): Promise<ValidationResult>;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Get the application data directory for the current platform
|
|
152
|
+
* Uses ~/.tuilder as requested by user for simplicity
|
|
153
|
+
*/
|
|
154
|
+
declare function getAppDataDirectory(): string;
|
|
155
|
+
/**
|
|
156
|
+
* Ensure the application data directory exists
|
|
157
|
+
* Creates directory recursively if it doesn't exist
|
|
158
|
+
*/
|
|
159
|
+
declare function ensureAppDataDirectory(): Promise<string>;
|
|
160
|
+
/**
|
|
161
|
+
* Get the full path for a PouchDB database file
|
|
162
|
+
* @param dbName - The database name (e.g., 'userdb-Colin')
|
|
163
|
+
*/
|
|
164
|
+
declare function getDbPath(dbName: string): string;
|
|
165
|
+
/**
|
|
166
|
+
* Initialize data directory for PouchDB usage
|
|
167
|
+
* Should be called once at application startup
|
|
168
|
+
*/
|
|
169
|
+
declare function initializeDataDirectory(): Promise<void>;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Initialize TUI logging - redirect console logs to file in Node.js
|
|
173
|
+
*/
|
|
174
|
+
declare function initializeTuiLogging(): void;
|
|
175
|
+
/**
|
|
176
|
+
* Get the current log file path (for debugging)
|
|
177
|
+
*/
|
|
178
|
+
declare function getLogFilePath(): string | null;
|
|
179
|
+
/**
|
|
180
|
+
* Show user-facing message (always visible in TUI)
|
|
181
|
+
*/
|
|
182
|
+
declare function showUserMessage(message: string): void;
|
|
183
|
+
/**
|
|
184
|
+
* Show user-facing error (always visible in TUI)
|
|
185
|
+
*/
|
|
186
|
+
declare function showUserError(message: string): void;
|
|
187
|
+
/**
|
|
188
|
+
* Logger object with standard log levels
|
|
189
|
+
*/
|
|
190
|
+
declare const logger: {
|
|
191
|
+
debug: (message: string, ...args: any[]) => void;
|
|
192
|
+
info: (message: string, ...args: any[]) => void;
|
|
193
|
+
warn: (message: string, ...args: any[]) => void;
|
|
194
|
+
error: (message: string, ...args: any[]) => void;
|
|
195
|
+
};
|
|
196
|
+
|
|
14
197
|
interface StudySessionRecord {
|
|
15
198
|
card: {
|
|
16
199
|
course_id: string;
|
|
@@ -95,6 +278,14 @@ declare class CourseLookup {
|
|
|
95
278
|
* @returns
|
|
96
279
|
*/
|
|
97
280
|
static add(courseName: string): Promise<string>;
|
|
281
|
+
/**
|
|
282
|
+
* Adds a new course to the lookup database with a specific courseID
|
|
283
|
+
* @param courseId The specific course ID to use
|
|
284
|
+
* @param courseName The course name
|
|
285
|
+
* @param disambiguator Optional disambiguator
|
|
286
|
+
* @returns Promise<void>
|
|
287
|
+
*/
|
|
288
|
+
static addWithId(courseId: string, courseName: string, disambiguator?: string): Promise<void>;
|
|
98
289
|
/**
|
|
99
290
|
* Removes a course from the index
|
|
100
291
|
* @param courseID
|
|
@@ -139,4 +330,4 @@ declare function getDataLayer(): DataLayerProvider;
|
|
|
139
330
|
*/
|
|
140
331
|
declare function _resetDataLayer(): Promise<void>;
|
|
141
332
|
|
|
142
|
-
export { CardRecord, CourseLookup, type DataLayerConfig, DataLayerProvider, ENV, Loggable, SessionController, StaticCourseManifest, StudyContentSource, StudySessionItem, type StudySessionRecord, _resetDataLayer, getDataLayer, initializeDataLayer };
|
|
333
|
+
export { type AggregatedDocument, type AttachmentUploadResult, CardRecord, CourseLookup, DEFAULT_MIGRATION_OPTIONS, type DataLayerConfig, DataLayerProvider, type DocumentCounts, ENV, FileSystemAdapter, Loggable, type MigrationOptions, type MigrationResult, 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 };
|