@shaxpir/duiduidui-models 1.4.11 → 1.4.14
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/repo/ShareSync.d.ts +6 -0
- package/dist/repo/ShareSync.js +38 -0
- package/package.json +2 -2
package/dist/repo/ShareSync.d.ts
CHANGED
|
@@ -57,6 +57,12 @@ export declare class ShareSync {
|
|
|
57
57
|
createManifest(body: ManifestBody): Manifest;
|
|
58
58
|
createContent(body: ContentBody): Content;
|
|
59
59
|
acquire(kind: ContentKind, id: ContentId, timestamp?: CompactDateTime): Promise<Model>;
|
|
60
|
+
/**
|
|
61
|
+
* Acquire multiple models of the same kind in a bulk operation.
|
|
62
|
+
* This leverages DurableStore's bulk capabilities for significant performance gains
|
|
63
|
+
* when loading multiple models simultaneously (e.g., component terms in proficiency updates).
|
|
64
|
+
*/
|
|
65
|
+
acquireMultiple(kind: ContentKind, ids: ContentId[], timestamp?: CompactDateTime): Promise<Model[]>;
|
|
60
66
|
load(kind: ContentKind, id: ContentId): Model;
|
|
61
67
|
findAndAcquire(kind: ContentKind, query: any): Promise<Content[]>;
|
|
62
68
|
updateManifestForContent(content: Content): Promise<void>;
|
package/dist/repo/ShareSync.js
CHANGED
|
@@ -267,6 +267,44 @@ class ShareSync {
|
|
|
267
267
|
}
|
|
268
268
|
return model;
|
|
269
269
|
}
|
|
270
|
+
/**
|
|
271
|
+
* Acquire multiple models of the same kind in a bulk operation.
|
|
272
|
+
* This leverages DurableStore's bulk capabilities for significant performance gains
|
|
273
|
+
* when loading multiple models simultaneously (e.g., component terms in proficiency updates).
|
|
274
|
+
*/
|
|
275
|
+
async acquireMultiple(kind, ids, timestamp) {
|
|
276
|
+
if (!Array.isArray(ids) || ids.length === 0) {
|
|
277
|
+
return [];
|
|
278
|
+
}
|
|
279
|
+
// Load all models first (this creates docs, wraps them, and caches them)
|
|
280
|
+
const models = ids.map(id => this.load(kind, id));
|
|
281
|
+
// Try bulk acquire if DurableStore supports it
|
|
282
|
+
if (this._durableStore?.getDocsBulk) {
|
|
283
|
+
try {
|
|
284
|
+
const durableStore = this._durableStore;
|
|
285
|
+
const docIds = models.map(model => model.doc.id);
|
|
286
|
+
// Use DurableStore's bulk retrieval
|
|
287
|
+
const docDatas = await new Promise((resolve, reject) => {
|
|
288
|
+
durableStore.getDocsBulk(kind, docIds, (error, data) => {
|
|
289
|
+
if (error)
|
|
290
|
+
reject(error);
|
|
291
|
+
else
|
|
292
|
+
resolve(data || []);
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
// Bulk retrieval was successful, now do normal acquire for all models
|
|
296
|
+
// The DurableStore bulk operation has already loaded the data, so individual
|
|
297
|
+
// acquire operations should be fast (no additional network requests)
|
|
298
|
+
const acquirePromises = models.map(model => timestamp ? model.acquire(timestamp) : model.acquire());
|
|
299
|
+
return Promise.all(acquirePromises);
|
|
300
|
+
}
|
|
301
|
+
catch (error) {
|
|
302
|
+
console.warn('Bulk acquire failed, falling back to individual acquire:', error);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
// Fallback to individual acquire calls
|
|
306
|
+
return Promise.all(models.map(model => timestamp ? model.acquire(timestamp) : model.acquire()));
|
|
307
|
+
}
|
|
270
308
|
load(kind, id) {
|
|
271
309
|
// First, try getting the content from the cache
|
|
272
310
|
const compoundKey = `${kind}/${id}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shaxpir/duiduidui-models",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.14",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/shaxpir/duiduidui-models"
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"dist/"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@shaxpir/sharedb": "^6.0.
|
|
19
|
+
"@shaxpir/sharedb": "^6.0.6",
|
|
20
20
|
"@shaxpir/shaxpir-common": "1.3.0",
|
|
21
21
|
"ot-json1": "1.0.1",
|
|
22
22
|
"ot-text-unicode": "4.0.0",
|