cry-synced-db-client 0.1.83 → 0.1.92

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.
Files changed (2) hide show
  1. package/dist/index.js +13 -8
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1970,9 +1970,9 @@ var PendingChangesManager = class {
1970
1970
  if (existing) {
1971
1971
  clearTimeout(existing.timer);
1972
1972
  }
1973
- const deltaWithId = existing ? data : __spreadValues({ _id: id }, data);
1973
+ const deltaWithId = existing ? data : __spreadProps(__spreadValues({}, data), { _id: id });
1974
1974
  savePendingWrite(this.tenant, collection, id, deltaWithId);
1975
- const fullData = existing ? Object.assign(existing.data, data) : __spreadValues({ _id: id }, data);
1975
+ const fullData = existing ? Object.assign(existing.data, data, { _id: id }) : __spreadProps(__spreadValues({}, data), { _id: id });
1976
1976
  const timer = setTimeout(() => {
1977
1977
  this.executePendingChange(key);
1978
1978
  }, this.debounceDexieWritesMs);
@@ -2144,9 +2144,14 @@ var PendingChangesManager = class {
2144
2144
  pending.data
2145
2145
  );
2146
2146
  } else {
2147
- await this.deps.dexieDb.insert(pending.collection, __spreadValues({
2147
+ const insertData = __spreadProps(__spreadValues({}, pending.data), {
2148
2148
  _id: pending.id
2149
- }, pending.data));
2149
+ // ensure _id is after spread
2150
+ });
2151
+ if (typeof insertData._id === "object") {
2152
+ console.error(`Dexie: _id is object type in ${pending.collection}:`, typeof insertData._id, insertData._id);
2153
+ }
2154
+ await this.deps.dexieDb.insert(pending.collection, insertData);
2150
2155
  }
2151
2156
  if (this.callbacks.onDexieWriteResult) {
2152
2157
  try {
@@ -2861,7 +2866,7 @@ var _SyncEngine = class _SyncEngine {
2861
2866
  // Private: Process Incoming Data
2862
2867
  // ============================================================
2863
2868
  /** Max items to process per batch in processIncomingServerData */
2864
- _SyncEngine.SYNC_BATCH_SIZE = 200;
2869
+ _SyncEngine.SYNC_BATCH_SIZE = 2e3;
2865
2870
  var SyncEngine = _SyncEngine;
2866
2871
 
2867
2872
  // src/db/sync/ServerUpdateHandler.ts
@@ -3904,12 +3909,12 @@ var SyncedDb = class _SyncedDb {
3904
3909
  }
3905
3910
  // ==================== Write Operations ====================
3906
3911
  async save(collection, id, update) {
3907
- var _a;
3912
+ var _a, _b;
3908
3913
  this.assertCollection(collection);
3909
3914
  id = this.normalizeId(id);
3910
3915
  update = _SyncedDb.stringifyObjectIds(update);
3911
3916
  const existing = await this.dexieDb.getById(collection, id);
3912
- if (!existing) {
3917
+ if (!existing && !((_a = this.collections.get(collection)) == null ? void 0 : _a.writeOnly)) {
3913
3918
  console.warn(
3914
3919
  `SyncedDb.save: Object ${String(id)} not found in ${collection}, creating new`
3915
3920
  );
@@ -3924,7 +3929,7 @@ var SyncedDb = class _SyncedDb {
3924
3929
  _lastUpdaterId: this.updaterId
3925
3930
  });
3926
3931
  this.pendingChanges.schedule(collection, id, newData, 0, "save");
3927
- const isWriteOnly = (_a = this.collections.get(collection)) == null ? void 0 : _a.writeOnly;
3932
+ const isWriteOnly = (_b = this.collections.get(collection)) == null ? void 0 : _b.writeOnly;
3928
3933
  const currentMem = isWriteOnly ? null : this.inMemDb.getById(collection, id);
3929
3934
  const merged = __spreadValues(__spreadValues({}, currentMem || existing || { _id: id }), update);
3930
3935
  if (!isWriteOnly && !(existing == null ? void 0 : existing._deleted) && !(existing == null ? void 0 : existing._archived)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cry-synced-db-client",
3
- "version": "0.1.83",
3
+ "version": "0.1.92",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -37,7 +37,7 @@
37
37
  "dependencies": {
38
38
  "cry-db": "^2.4.23",
39
39
  "cry-helpers": "^2.1.193",
40
- "cry-synced-db-client": "0.1.81",
40
+ "cry-synced-db-client": "0.1.84",
41
41
  "msgpackr": "^1.11.9",
42
42
  "notepack": "^0.0.2",
43
43
  "notepack.io": "^3.0.1",