cry-synced-db-client 0.1.213 → 0.1.215
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/index.js
CHANGED
|
@@ -3192,8 +3192,9 @@ function stripServerManagedFromChanges(changes) {
|
|
|
3192
3192
|
|
|
3193
3193
|
// src/db/sync/SyncEngine.ts
|
|
3194
3194
|
var SUPRESS_DB_WARNINGS = true;
|
|
3195
|
-
var
|
|
3195
|
+
var SyncEngine = class {
|
|
3196
3196
|
constructor(config) {
|
|
3197
|
+
var _a;
|
|
3197
3198
|
this.tenant = config.tenant;
|
|
3198
3199
|
this.collections = config.collections;
|
|
3199
3200
|
this.dexieDb = config.dexieDb;
|
|
@@ -3201,6 +3202,7 @@ var _SyncEngine = class _SyncEngine {
|
|
|
3201
3202
|
this.callbacks = config.callbacks;
|
|
3202
3203
|
this.deps = config.deps;
|
|
3203
3204
|
this.preprocessDirtyItem = config.preprocessDirtyItem;
|
|
3205
|
+
this.syncBatchSize = (_a = config.syncBatchSize) != null ? _a : 5e3;
|
|
3204
3206
|
}
|
|
3205
3207
|
/**
|
|
3206
3208
|
* Execute full sync cycle.
|
|
@@ -3331,7 +3333,9 @@ var _SyncEngine = class _SyncEngine {
|
|
|
3331
3333
|
items: items.length,
|
|
3332
3334
|
itemsCumulative: _perCollectionItems.get(collection),
|
|
3333
3335
|
isNewCollection: isNewColl,
|
|
3334
|
-
processingMs: Math.round(_processingMs)
|
|
3336
|
+
processingMs: Math.round(_processingMs),
|
|
3337
|
+
dexieMs: Math.round(stats.dexieMs),
|
|
3338
|
+
inMemMs: Math.round(stats.inMemMs)
|
|
3335
3339
|
});
|
|
3336
3340
|
},
|
|
3337
3341
|
{
|
|
@@ -4159,7 +4163,7 @@ var _SyncEngine = class _SyncEngine {
|
|
|
4159
4163
|
let totalDexieMs = 0;
|
|
4160
4164
|
let totalInMemMs = 0;
|
|
4161
4165
|
const allUpdatedIds = [];
|
|
4162
|
-
const BATCH =
|
|
4166
|
+
const BATCH = this.syncBatchSize;
|
|
4163
4167
|
for (let offset = 0; offset < serverData.length; offset += BATCH) {
|
|
4164
4168
|
const chunk = serverData.slice(offset, offset + BATCH);
|
|
4165
4169
|
const chunkIds = [];
|
|
@@ -4436,12 +4440,6 @@ var _SyncEngine = class _SyncEngine {
|
|
|
4436
4440
|
}
|
|
4437
4441
|
}
|
|
4438
4442
|
};
|
|
4439
|
-
// ============================================================
|
|
4440
|
-
// Private: Process Incoming Data
|
|
4441
|
-
// ============================================================
|
|
4442
|
-
/** Max items to process per batch in processIncomingServerData */
|
|
4443
|
-
_SyncEngine.SYNC_BATCH_SIZE = 2e3;
|
|
4444
|
-
var SyncEngine = _SyncEngine;
|
|
4445
4443
|
|
|
4446
4444
|
// src/db/sync/ServerUpdateHandler.ts
|
|
4447
4445
|
var ServerUpdateHandler = class {
|
|
@@ -5079,6 +5077,7 @@ var _SyncedDb = class _SyncedDb {
|
|
|
5079
5077
|
}
|
|
5080
5078
|
});
|
|
5081
5079
|
this.syncEngine = new SyncEngine({
|
|
5080
|
+
syncBatchSize: config.syncBatchSize,
|
|
5082
5081
|
tenant: this.tenant,
|
|
5083
5082
|
updaterId: this.updaterId,
|
|
5084
5083
|
collections: this.collections,
|
|
@@ -75,8 +75,7 @@ export declare class SyncEngine implements I_SyncEngine {
|
|
|
75
75
|
}): Promise<{
|
|
76
76
|
updatedIds: string[];
|
|
77
77
|
}>;
|
|
78
|
-
|
|
79
|
-
private static readonly SYNC_BATCH_SIZE;
|
|
78
|
+
private readonly syncBatchSize;
|
|
80
79
|
private processIncomingServerData;
|
|
81
80
|
private compareTimestamps;
|
|
82
81
|
private resolveCollectionConflict;
|
|
@@ -251,6 +251,8 @@ export interface SyncEngineCallbacks {
|
|
|
251
251
|
itemsCumulative?: number;
|
|
252
252
|
isNewCollection?: boolean;
|
|
253
253
|
processingMs?: number;
|
|
254
|
+
dexieMs?: number;
|
|
255
|
+
inMemMs?: number;
|
|
254
256
|
}) => void;
|
|
255
257
|
onServerSyncStart?: (info: {
|
|
256
258
|
calledFrom?: string;
|
|
@@ -303,6 +305,8 @@ export interface SyncEngineConfig {
|
|
|
303
305
|
collections: Map<string, CollectionConfig>;
|
|
304
306
|
dexieDb: I_DexieDb;
|
|
305
307
|
restInterface: I_RestInterface;
|
|
308
|
+
/** Items per batch in processIncomingServerData. Default 10000. */
|
|
309
|
+
syncBatchSize?: number;
|
|
306
310
|
/**
|
|
307
311
|
* Optional per-item filter / transform applied before upload. See
|
|
308
312
|
* `SyncedDbConfig.preprocessDirtyItem` for full semantics.
|
|
@@ -592,6 +592,8 @@ export interface SyncedDbConfig {
|
|
|
592
592
|
restTimeoutMs?: number;
|
|
593
593
|
/** Timeout za sync REST klice v ms (default: 120000) - daljši ker sync prenaša več podatkov */
|
|
594
594
|
syncTimeoutMs?: number;
|
|
595
|
+
/** Število itemov na batch v processIncomingServerData. Default 10000. */
|
|
596
|
+
syncBatchSize?: number;
|
|
595
597
|
/**
|
|
596
598
|
* Activity timeout za streaming odgovore (default: 30000).
|
|
597
599
|
*
|
|
@@ -678,8 +680,12 @@ export interface SyncedDbConfig {
|
|
|
678
680
|
itemsCumulative?: number;
|
|
679
681
|
/** True only for the first chunk of a new collection */
|
|
680
682
|
isNewCollection?: boolean;
|
|
681
|
-
/**
|
|
683
|
+
/** Total processing time for this chunk (ms) */
|
|
682
684
|
processingMs?: number;
|
|
685
|
+
/** Dexie (IndexedDB) write time for this chunk (ms) */
|
|
686
|
+
dexieMs?: number;
|
|
687
|
+
/** InMem (Vuex/dbx) write time for this chunk (ms) */
|
|
688
|
+
inMemMs?: number;
|
|
683
689
|
}) => void;
|
|
684
690
|
/**
|
|
685
691
|
* Callback when per-collection hydration status changes (hydration end,
|