@shaxpir/duiduidui-models 1.4.20 → 1.4.22

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.
@@ -260,6 +260,10 @@ class ShareSync {
260
260
  }
261
261
  async acquire(kind, id, timestamp) {
262
262
  let model = this.load(kind, id);
263
+ if (!model) {
264
+ // Document doesn't exist or couldn't be loaded
265
+ return null;
266
+ }
263
267
  if (timestamp) {
264
268
  model = await model.acquire(timestamp);
265
269
  }
@@ -278,7 +282,12 @@ class ShareSync {
278
282
  return [];
279
283
  }
280
284
  // Load all models first (this creates docs, wraps them, and caches them)
281
- const models = ids.map(id => this.load(kind, id));
285
+ // Filter out any null models (documents that don't exist)
286
+ const models = ids.map(id => this.load(kind, id)).filter(model => model !== null);
287
+ // If no valid models were loaded, return empty array
288
+ if (models.length === 0) {
289
+ return [];
290
+ }
282
291
  // Try bulk acquire if DurableStore supports it
283
292
  if (this._durableStore?.getDocsBulk) {
284
293
  try {
@@ -315,6 +324,10 @@ class ShareSync {
315
324
  // If not in the cache, get the model doc from the connection.
316
325
  // Then wrap it and put it in the cache for future reference.
317
326
  const doc = this._connection.get(kind, id);
327
+ if (!doc) {
328
+ console.error(`[ShareSync] connection.get(${kind}, ${id}) returned null/undefined doc`);
329
+ return null;
330
+ }
318
331
  const model = this.wrap(kind, doc, false);
319
332
  this._modelCache.set(compoundKey, model);
320
333
  return model;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shaxpir/duiduidui-models",
3
- "version": "1.4.20",
3
+ "version": "1.4.22",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/shaxpir/duiduidui-models"