cry-synced-db-client 0.1.208 → 0.1.209
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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Versions
|
|
2
2
|
|
|
3
|
+
## 0.1.209 (2026-06-25)
|
|
4
|
+
|
|
5
|
+
### Removed hardcoded `{ returnDeleted: true }` from sync specs
|
|
6
|
+
|
|
7
|
+
`CollectionSyncConfig.opts` now carries `returnDeleted`, `returnArchived`, and
|
|
8
|
+
`project` per-collection instead of being hardcoded in `SyncEngine`. Each
|
|
9
|
+
sync spec passes its own opts directly to `findNewer`.
|
|
10
|
+
|
|
11
|
+
### Added `onEviction` callback
|
|
12
|
+
|
|
13
|
+
New optional `onEviction` callback on `SyncEngineCallbacks` — fires with
|
|
14
|
+
`{ collection, totalEvicted, totalServerEvicted }` after each eviction pass.
|
|
15
|
+
|
|
16
|
+
### Test script fixes
|
|
17
|
+
|
|
18
|
+
- Added `test/preload-bun.cjs` — polyfill for Bun's missing `process.getBuiltinModule('v8')`
|
|
19
|
+
- Fixed `test:real-mongo` script to use `npx vitest run` (not `bun test`)
|
|
20
|
+
|
|
3
21
|
## 0.1.204 (2026-06-17)
|
|
4
22
|
|
|
5
23
|
### Per-collection error isolation in `uploadDirtyItems`
|
package/dist/index.js
CHANGED
|
@@ -3212,7 +3212,7 @@ var _SyncEngine = class _SyncEngine {
|
|
|
3212
3212
|
* never enter the positive-sync processing path.
|
|
3213
3213
|
*/
|
|
3214
3214
|
async sync(calledFrom, extras) {
|
|
3215
|
-
var _a, _b;
|
|
3215
|
+
var _a, _b, _c;
|
|
3216
3216
|
const startTime = Date.now();
|
|
3217
3217
|
let receivedCount = 0;
|
|
3218
3218
|
let sentCount = 0;
|
|
@@ -3239,7 +3239,7 @@ var _SyncEngine = class _SyncEngine {
|
|
|
3239
3239
|
collection: collectionName,
|
|
3240
3240
|
timestamp: (meta == null ? void 0 : meta.lastSyncTs) || 0,
|
|
3241
3241
|
query,
|
|
3242
|
-
opts:
|
|
3242
|
+
opts: (_c = config.syncConfig) == null ? void 0 : _c.opts
|
|
3243
3243
|
});
|
|
3244
3244
|
configMap.set(collectionName, config);
|
|
3245
3245
|
}
|
|
@@ -3271,7 +3271,26 @@ var _SyncEngine = class _SyncEngine {
|
|
|
3271
3271
|
allSpecs,
|
|
3272
3272
|
async (collection, items, specId) => {
|
|
3273
3273
|
if (specId !== void 0) {
|
|
3274
|
-
if (
|
|
3274
|
+
if (specId.endsWith(":exit")) {
|
|
3275
|
+
const exitItems = items.filter((it) => it._evictIds);
|
|
3276
|
+
if (exitItems.length > 0) {
|
|
3277
|
+
const exitIds = exitItems.map((it) => String(it._id));
|
|
3278
|
+
await this.dexieDb.deleteMany(collection, exitIds);
|
|
3279
|
+
this.deps.writeToInMemBatch(
|
|
3280
|
+
collection,
|
|
3281
|
+
exitIds.map((id) => ({ _id: id })),
|
|
3282
|
+
"delete",
|
|
3283
|
+
{ source: "incremental" }
|
|
3284
|
+
);
|
|
3285
|
+
this.callbackSafe(this.callbacks.onEviction, {
|
|
3286
|
+
collection,
|
|
3287
|
+
totalEvicted: exitIds.length,
|
|
3288
|
+
totalServerEvicted: exitIds.length
|
|
3289
|
+
});
|
|
3290
|
+
}
|
|
3291
|
+
} else if (extras) {
|
|
3292
|
+
extras.onChunk(specId, items);
|
|
3293
|
+
}
|
|
3275
3294
|
return;
|
|
3276
3295
|
}
|
|
3277
3296
|
const config = configMap.get(collection);
|
|
@@ -268,6 +268,11 @@ export interface SyncEngineCallbacks {
|
|
|
268
268
|
onFindNewerManyResult?: (info: FindNewerManyResultInfo) => void;
|
|
269
269
|
onUploadSkip?: (info: import("../../types/I_SyncedDb").UploadSkipInfo) => void;
|
|
270
270
|
onDirtyItemStuck?: (info: import("../../types/I_SyncedDb").DirtyItemStuckInfo) => void;
|
|
271
|
+
onEviction?: (info: {
|
|
272
|
+
collection: string;
|
|
273
|
+
totalEvicted: number;
|
|
274
|
+
totalServerEvicted: number;
|
|
275
|
+
}) => void;
|
|
271
276
|
}
|
|
272
277
|
export interface SyncEngineDeps {
|
|
273
278
|
getSyncMetaCache: () => Map<string, SyncMeta>;
|
|
@@ -10,6 +10,15 @@ export interface CollectionSyncConfig<T = any> {
|
|
|
10
10
|
enabled?: boolean | (() => boolean);
|
|
11
11
|
/** Query filter for sync. If a function, called at each sync to get the query. */
|
|
12
12
|
query?: QuerySpec<T> | (() => QuerySpec<T>);
|
|
13
|
+
/**
|
|
14
|
+
* Options passed to findNewerManyStream during sync.
|
|
15
|
+
* e.g. `{ returnDeleted: true }` to include soft-deleted records.
|
|
16
|
+
* When omitted, cry-db applies its own defaults.
|
|
17
|
+
*/
|
|
18
|
+
opts?: {
|
|
19
|
+
returnDeleted?: boolean;
|
|
20
|
+
returnArchived?: boolean;
|
|
21
|
+
};
|
|
13
22
|
}
|
|
14
23
|
export interface CollectionConfig<T = any> {
|
|
15
24
|
name: string;
|
|
@@ -531,6 +531,12 @@ export interface CollectionSyncConfig {
|
|
|
531
531
|
enabled?: boolean | (() => boolean);
|
|
532
532
|
/** Query filter for sync. If a function, called at each sync to get the query. */
|
|
533
533
|
query?: QuerySpec<any> | (() => QuerySpec<any>);
|
|
534
|
+
/** Options passed through to findNewer (returnDeleted, returnArchived, project, ...) */
|
|
535
|
+
opts?: {
|
|
536
|
+
returnDeleted?: boolean;
|
|
537
|
+
returnArchived?: boolean;
|
|
538
|
+
project?: Record<string, any>;
|
|
539
|
+
};
|
|
534
540
|
}
|
|
535
541
|
/**
|
|
536
542
|
* Konfiguracija za posamezno kolekcijo
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cry-synced-db-client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.209",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -20,25 +20,25 @@
|
|
|
20
20
|
"build": "bun run clean && bun run build:js && bun run build:types",
|
|
21
21
|
"build:js": "esbuild ./src/index.ts --bundle --outdir=./dist --target=es2017 --format=esm --platform=browser --external:dexie --external:bson --external:cry-helpers",
|
|
22
22
|
"build:types": "tsc --emitDeclarationOnly --outDir dist",
|
|
23
|
-
"test": "bun test test/*.test.ts test/restProxy/*.test.ts
|
|
23
|
+
"test": "bun test --preload ./test/preload-bun.cjs test/*.test.ts test/restProxy/*.test.ts; vitest run",
|
|
24
24
|
"test:bun": "bun test test/*.test.ts test/restProxy/*.test.ts",
|
|
25
25
|
"test:node-only": "vitest run",
|
|
26
|
-
"test:real-mongo": "USE_REAL_MONGO=1
|
|
26
|
+
"test:real-mongo": "USE_REAL_MONGO=1 npx vitest run test/node-only/",
|
|
27
27
|
"prepublishOnly": "bun run build"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/bun": "latest",
|
|
31
|
-
"bson": "^7.
|
|
31
|
+
"bson": "^7.3.1",
|
|
32
32
|
"cry-ebus-proxy": "^2.0.0",
|
|
33
|
-
"dexie": "^4.4.
|
|
33
|
+
"dexie": "^4.4.4",
|
|
34
34
|
"esbuild": "^0.28.1",
|
|
35
35
|
"fake-indexeddb": "^6.2.5",
|
|
36
36
|
"typescript": "^6",
|
|
37
|
-
"vitest": "^4.1.
|
|
37
|
+
"vitest": "^4.1.9"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"cry-db": "^2.5.
|
|
41
|
-
"cry-helpers": "^2.1.
|
|
40
|
+
"cry-db": "^2.5.6",
|
|
41
|
+
"cry-helpers": "^2.1.206",
|
|
42
42
|
"msgpackr": "^2.0.4",
|
|
43
43
|
"superjson": "^2.2.6"
|
|
44
44
|
},
|