@shaxpir/duiduidui-models 1.4.17 → 1.4.19
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/models/Billing.js +1 -1
- package/dist/models/Device.js +1 -1
- package/dist/models/Media.js +1 -1
- package/dist/models/Metric.js +1 -1
- package/dist/models/Operation.js +1 -1
- package/dist/models/Profile.js +1 -1
- package/dist/models/Progress.js +1 -1
- package/dist/models/Session.js +1 -1
- package/dist/models/Term.js +2 -2
- package/dist/models/User.js +1 -1
- package/dist/models/Workspace.js +1 -1
- package/dist/repo/ShareSync.d.ts +7 -0
- package/dist/repo/ShareSync.js +20 -0
- package/package.json +2 -2
package/dist/models/Billing.js
CHANGED
|
@@ -10,7 +10,7 @@ class Billing extends Content_1.Content {
|
|
|
10
10
|
return shaxpir_common_1.CachingHasher.makeMd5Base62Hash(userId + "-" + ContentKind_1.ContentKind.BILLING);
|
|
11
11
|
}
|
|
12
12
|
static create(userId, payload, createdAt) {
|
|
13
|
-
const now = shaxpir_common_1.
|
|
13
|
+
const now = shaxpir_common_1.ClockService.getClock().now();
|
|
14
14
|
// If the createdAt time is not provided, use the current time
|
|
15
15
|
createdAt ??= now;
|
|
16
16
|
const billingId = Billing.makeBillingId(userId);
|
package/dist/models/Device.js
CHANGED
|
@@ -8,7 +8,7 @@ const ContentKind_1 = require("./ContentKind");
|
|
|
8
8
|
const Operation_1 = require("./Operation");
|
|
9
9
|
class Device extends Content_1.Content {
|
|
10
10
|
static create(userId, deviceId) {
|
|
11
|
-
const now = shaxpir_common_1.
|
|
11
|
+
const now = shaxpir_common_1.ClockService.getClock().now();
|
|
12
12
|
return repo_1.ShareSyncFactory.get().createContent({
|
|
13
13
|
meta: {
|
|
14
14
|
ref: deviceId,
|
package/dist/models/Media.js
CHANGED
|
@@ -14,7 +14,7 @@ class Media extends Content_1.Content {
|
|
|
14
14
|
return this.doc.data.payload;
|
|
15
15
|
}
|
|
16
16
|
static create(userId, mediaId, payload) {
|
|
17
|
-
const now = shaxpir_common_1.
|
|
17
|
+
const now = shaxpir_common_1.ClockService.getClock().now();
|
|
18
18
|
return repo_1.ShareSyncFactory.get().createContent({
|
|
19
19
|
meta: {
|
|
20
20
|
ref: mediaId,
|
package/dist/models/Metric.js
CHANGED
|
@@ -35,7 +35,7 @@ class Metric extends Content_1.Content {
|
|
|
35
35
|
maxDate = date;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
const now = shaxpir_common_1.
|
|
38
|
+
const now = shaxpir_common_1.ClockService.getClock().now();
|
|
39
39
|
return repo_1.ShareSyncFactory.get().createContent({
|
|
40
40
|
meta: {
|
|
41
41
|
ref: metricId,
|
package/dist/models/Operation.js
CHANGED
package/dist/models/Profile.js
CHANGED
|
@@ -11,7 +11,7 @@ class Profile extends Content_1.Content {
|
|
|
11
11
|
return shaxpir_common_1.CachingHasher.makeMd5Base62Hash(userId + "-" + ContentKind_1.ContentKind.PROFILE);
|
|
12
12
|
}
|
|
13
13
|
static create(userId) {
|
|
14
|
-
const now = shaxpir_common_1.
|
|
14
|
+
const now = shaxpir_common_1.ClockService.getClock().now();
|
|
15
15
|
const profileId = Profile.makeProfileId(userId);
|
|
16
16
|
return repo_1.ShareSyncFactory.get().createContent({
|
|
17
17
|
meta: {
|
package/dist/models/Progress.js
CHANGED
|
@@ -11,7 +11,7 @@ class Progress extends Content_1.Content {
|
|
|
11
11
|
return shaxpir_common_1.CachingHasher.makeMd5Base62Hash(userId + "-" + ContentKind_1.ContentKind.PROGRESS);
|
|
12
12
|
}
|
|
13
13
|
static create(userId) {
|
|
14
|
-
const now = shaxpir_common_1.
|
|
14
|
+
const now = shaxpir_common_1.ClockService.getClock().now();
|
|
15
15
|
const progressId = Progress.makeProgressId(userId);
|
|
16
16
|
return repo_1.ShareSyncFactory.get().createContent({
|
|
17
17
|
meta: {
|
package/dist/models/Session.js
CHANGED
|
@@ -22,7 +22,7 @@ class Session extends Content_1.Content {
|
|
|
22
22
|
return `${sessionId}_${at.utc_time}`;
|
|
23
23
|
}
|
|
24
24
|
static create(userId, deviceId) {
|
|
25
|
-
let now = shaxpir_common_1.
|
|
25
|
+
let now = shaxpir_common_1.ClockService.getClock().now();
|
|
26
26
|
let sessionId = Session.makeSessionId(userId);
|
|
27
27
|
let sessionRef = Session.makeSessionRef(userId, now);
|
|
28
28
|
return repo_1.ShareSyncFactory.get().createContent({
|
package/dist/models/Term.js
CHANGED
|
@@ -16,7 +16,7 @@ class Term extends Content_1.Content {
|
|
|
16
16
|
this._reviewsView = new ArrayView_1.ArrayView(this, ['payload', 'reviews']);
|
|
17
17
|
}
|
|
18
18
|
static forUserPhrase(userId, textOrPhrase, senseRank, learnRank, phraseId) {
|
|
19
|
-
const now = shaxpir_common_1.
|
|
19
|
+
const now = shaxpir_common_1.ClockService.getClock().now();
|
|
20
20
|
// Handle overloaded parameters
|
|
21
21
|
let phrase;
|
|
22
22
|
if (typeof textOrPhrase === 'string') {
|
|
@@ -72,7 +72,7 @@ class Term extends Content_1.Content {
|
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
74
|
static forBuiltinPhrase(userId, phrase) {
|
|
75
|
-
const now = shaxpir_common_1.
|
|
75
|
+
const now = shaxpir_common_1.ClockService.getClock().now();
|
|
76
76
|
const termId = Term.makeTermId(userId, phrase.text, phrase.sense_rank);
|
|
77
77
|
return repo_1.ShareSyncFactory.get().createContent({
|
|
78
78
|
meta: {
|
package/dist/models/User.js
CHANGED
|
@@ -18,7 +18,7 @@ class User extends Content_1.Content {
|
|
|
18
18
|
}
|
|
19
19
|
static create(userId, payload, createdAt) {
|
|
20
20
|
// User creation always happens in UTC time
|
|
21
|
-
const now = shaxpir_common_1.
|
|
21
|
+
const now = shaxpir_common_1.ClockService.getClock().now();
|
|
22
22
|
// If the createdAt time is not provided, use the current time
|
|
23
23
|
createdAt ??= now;
|
|
24
24
|
return repo_1.ShareSyncFactory.get().createContent({
|
package/dist/models/Workspace.js
CHANGED
|
@@ -25,7 +25,7 @@ class Workspace extends Content_1.Content {
|
|
|
25
25
|
return shaxpir_common_1.CachingHasher.makeMd5Base62Hash(userId + "-" + ContentKind_1.ContentKind.WORKSPACE);
|
|
26
26
|
}
|
|
27
27
|
static create(userId, payload) {
|
|
28
|
-
const now = shaxpir_common_1.
|
|
28
|
+
const now = shaxpir_common_1.ClockService.getClock().now();
|
|
29
29
|
const workspaceId = Workspace.makeWorkspaceId(userId);
|
|
30
30
|
return repo_1.ShareSyncFactory.get().createContent({
|
|
31
31
|
meta: {
|
package/dist/repo/ShareSync.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export interface ShareSyncOptions {
|
|
|
23
23
|
webSocketConstructor?: any;
|
|
24
24
|
enableDurableStore?: boolean;
|
|
25
25
|
storageFactory?: () => Promise<any>;
|
|
26
|
+
maxBatchSize?: number;
|
|
26
27
|
}
|
|
27
28
|
export declare class ShareSyncFactory {
|
|
28
29
|
private static INSTANCE;
|
|
@@ -71,4 +72,10 @@ export declare class ShareSync {
|
|
|
71
72
|
dispose(model: Model): void;
|
|
72
73
|
onOperationError(opError: any): void;
|
|
73
74
|
private wrap;
|
|
75
|
+
/**
|
|
76
|
+
* Flush control methods for optimizing bulk write operations
|
|
77
|
+
*/
|
|
78
|
+
setAutoBatchEnabled(enabled: boolean): void;
|
|
79
|
+
isAutoBatchEnabled(): boolean;
|
|
80
|
+
flush(): void;
|
|
74
81
|
}
|
package/dist/repo/ShareSync.js
CHANGED
|
@@ -149,6 +149,7 @@ class ShareSync {
|
|
|
149
149
|
durableStore: {
|
|
150
150
|
storage: this._storage,
|
|
151
151
|
debug: this._debug,
|
|
152
|
+
maxBatchSize: options.maxBatchSize || 25, // Default 25 for better bulk write performance
|
|
152
153
|
extVersionDecoder: (docData) => {
|
|
153
154
|
if (docData &&
|
|
154
155
|
docData.meta &&
|
|
@@ -428,5 +429,24 @@ class ShareSync {
|
|
|
428
429
|
}
|
|
429
430
|
throw new Error(`can't wrap content ${kind}/${doc.id}`);
|
|
430
431
|
}
|
|
432
|
+
/**
|
|
433
|
+
* Flush control methods for optimizing bulk write operations
|
|
434
|
+
*/
|
|
435
|
+
setAutoBatchEnabled(enabled) {
|
|
436
|
+
if (this._durableStore && typeof this._durableStore.setAutoBatchEnabled === 'function') {
|
|
437
|
+
this._durableStore.setAutoBatchEnabled(enabled);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
isAutoBatchEnabled() {
|
|
441
|
+
if (this._durableStore && typeof this._durableStore.isAutoBatchEnabled === 'function') {
|
|
442
|
+
return this._durableStore.isAutoBatchEnabled();
|
|
443
|
+
}
|
|
444
|
+
return true; // Default to enabled if DurableStore doesn't support it
|
|
445
|
+
}
|
|
446
|
+
flush() {
|
|
447
|
+
if (this._durableStore && typeof this._durableStore.flush === 'function') {
|
|
448
|
+
this._durableStore.flush();
|
|
449
|
+
}
|
|
450
|
+
}
|
|
431
451
|
}
|
|
432
452
|
exports.ShareSync = ShareSync;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shaxpir/duiduidui-models",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.19",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/shaxpir/duiduidui-models"
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@shaxpir/duiduidui-models": "^1.4.14",
|
|
20
20
|
"@shaxpir/sharedb": "^6.0.6",
|
|
21
|
-
"@shaxpir/shaxpir-common": "1.
|
|
21
|
+
"@shaxpir/shaxpir-common": "1.4.0",
|
|
22
22
|
"ot-json1": "1.0.1",
|
|
23
23
|
"ot-text-unicode": "4.0.0",
|
|
24
24
|
"reconnecting-websocket": "4.4.0"
|