@vue-skuilder/db 0.1.39 → 0.1.40
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.js.map +1 -1
- package/dist/core/index.mjs.map +1 -1
- package/dist/impl/couch/index.d.cts +25 -1
- package/dist/impl/couch/index.d.ts +25 -1
- package/dist/impl/couch/index.js +24 -2
- package/dist/impl/couch/index.js.map +1 -1
- package/dist/impl/couch/index.mjs +24 -2
- package/dist/impl/couch/index.mjs.map +1 -1
- package/dist/impl/static/index.js.map +1 -1
- package/dist/impl/static/index.mjs.map +1 -1
- package/dist/index.d.cts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +34 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/factory.ts +17 -0
- package/src/impl/couch/CourseSyncService.ts +46 -1
- package/src/study/SessionController.ts +12 -5
package/dist/index.mjs
CHANGED
|
@@ -6451,16 +6451,25 @@ var init_adminDB2 = __esm({
|
|
|
6451
6451
|
});
|
|
6452
6452
|
|
|
6453
6453
|
// src/impl/couch/CourseSyncService.ts
|
|
6454
|
-
var
|
|
6454
|
+
var CourseSyncService_exports = {};
|
|
6455
|
+
__export(CourseSyncService_exports, {
|
|
6456
|
+
CourseSyncService: () => CourseSyncService
|
|
6457
|
+
});
|
|
6458
|
+
var DEFAULT_REPLICATION, CourseSyncService;
|
|
6455
6459
|
var init_CourseSyncService = __esm({
|
|
6456
6460
|
"src/impl/couch/CourseSyncService.ts"() {
|
|
6457
6461
|
"use strict";
|
|
6458
6462
|
init_pouchdb_setup();
|
|
6459
6463
|
init_couch();
|
|
6460
6464
|
init_logger();
|
|
6465
|
+
DEFAULT_REPLICATION = {
|
|
6466
|
+
batchSize: 1e3,
|
|
6467
|
+
batchesLimit: 5
|
|
6468
|
+
};
|
|
6461
6469
|
CourseSyncService = class _CourseSyncService {
|
|
6462
6470
|
static instance = null;
|
|
6463
6471
|
entries = /* @__PURE__ */ new Map();
|
|
6472
|
+
replicationOptions = DEFAULT_REPLICATION;
|
|
6464
6473
|
constructor() {
|
|
6465
6474
|
}
|
|
6466
6475
|
static getInstance() {
|
|
@@ -6469,6 +6478,21 @@ var init_CourseSyncService = __esm({
|
|
|
6469
6478
|
}
|
|
6470
6479
|
return _CourseSyncService.instance;
|
|
6471
6480
|
}
|
|
6481
|
+
/**
|
|
6482
|
+
* Apply replication tuning. Typically called once from `initializeDataLayer`.
|
|
6483
|
+
* Partial overrides merge with defaults.
|
|
6484
|
+
*/
|
|
6485
|
+
configure(opts) {
|
|
6486
|
+
if (opts.replication) {
|
|
6487
|
+
this.replicationOptions = {
|
|
6488
|
+
...DEFAULT_REPLICATION,
|
|
6489
|
+
...opts.replication
|
|
6490
|
+
};
|
|
6491
|
+
logger.info(
|
|
6492
|
+
`[CourseSyncService] Replication configured: batch_size=${this.replicationOptions.batchSize}, batches_limit=${this.replicationOptions.batchesLimit}`
|
|
6493
|
+
);
|
|
6494
|
+
}
|
|
6495
|
+
}
|
|
6472
6496
|
/**
|
|
6473
6497
|
* Reset the singleton (for testing).
|
|
6474
6498
|
*/
|
|
@@ -6597,7 +6621,7 @@ var init_CourseSyncService = __esm({
|
|
|
6597
6621
|
const remoteDB = this.getRemoteDB(courseId);
|
|
6598
6622
|
const syncStart = Date.now();
|
|
6599
6623
|
logger.info(
|
|
6600
|
-
`[CourseSyncService] Starting one-shot replication for course ${courseId}`
|
|
6624
|
+
`[CourseSyncService] Starting one-shot replication for course ${courseId} (batch_size=${this.replicationOptions.batchSize}, batches_limit=${this.replicationOptions.batchesLimit})`
|
|
6601
6625
|
);
|
|
6602
6626
|
const result = await this.replicate(remoteDB, localDB);
|
|
6603
6627
|
const syncTimeMs = Date.now() - syncStart;
|
|
@@ -6655,6 +6679,8 @@ var init_CourseSyncService = __esm({
|
|
|
6655
6679
|
return new Promise((resolve, reject) => {
|
|
6656
6680
|
void pouchdb_setup_default.replicate(source, target, {
|
|
6657
6681
|
// One-shot, not live. Local is a read-only snapshot.
|
|
6682
|
+
batch_size: this.replicationOptions.batchSize,
|
|
6683
|
+
batches_limit: this.replicationOptions.batchesLimit
|
|
6658
6684
|
}).on("complete", (info) => {
|
|
6659
6685
|
resolve(info);
|
|
6660
6686
|
}).on("error", (err) => {
|
|
@@ -9279,6 +9305,10 @@ async function initializeDataLayer(config) {
|
|
|
9279
9305
|
ENV.COUCHDB_SERVER_URL = config.options.COUCHDB_SERVER_URL;
|
|
9280
9306
|
ENV.COUCHDB_USERNAME = config.options.COUCHDB_USERNAME;
|
|
9281
9307
|
ENV.COUCHDB_PASSWORD = config.options.COUCHDB_PASSWORD;
|
|
9308
|
+
if (config.options.courseSync) {
|
|
9309
|
+
const { CourseSyncService: CourseSyncService2 } = await Promise.resolve().then(() => (init_CourseSyncService(), CourseSyncService_exports));
|
|
9310
|
+
CourseSyncService2.getInstance().configure(config.options.courseSync);
|
|
9311
|
+
}
|
|
9282
9312
|
if (config.options.COUCHDB_PASSWORD && config.options.COUCHDB_USERNAME && typeof window !== "undefined") {
|
|
9283
9313
|
const { CouchDBSyncStrategy: CouchDBSyncStrategy2 } = await Promise.resolve().then(() => (init_CouchDBSyncStrategy(), CouchDBSyncStrategy_exports));
|
|
9284
9314
|
const syncStrategy = new CouchDBSyncStrategy2();
|
|
@@ -13866,8 +13896,8 @@ var SessionController = class _SessionController extends Loggable {
|
|
|
13866
13896
|
this._minCardsGuarantee--;
|
|
13867
13897
|
this.log(`[CardGuarantee] ${this._minCardsGuarantee} guaranteed cards remaining`);
|
|
13868
13898
|
}
|
|
13869
|
-
if (this._replanPromise) {
|
|
13870
|
-
this.log("nextCard: awaiting in-flight replan before drawing");
|
|
13899
|
+
if (this._replanPromise && this.newQ.length === 0 && this.reviewQ.length === 0 && this.failedQ.length === 0) {
|
|
13900
|
+
this.log("nextCard: queues empty, awaiting in-flight replan before drawing");
|
|
13871
13901
|
await this._replanPromise;
|
|
13872
13902
|
}
|
|
13873
13903
|
if (this.newQ.length <= 1 && this._secondsRemaining > 0 && !this._replanPromise) {
|