@shaxpir/duiduidui-models 1.24.4 → 1.25.0

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.
@@ -69,9 +69,8 @@ class Chat extends SharedContent_1.SharedContent {
69
69
  workspace.release();
70
70
  }
71
71
  }
72
- catch {
73
- // Workspace may not exist yet for this user — this is expected
74
- // during initial account setup before the workspace is created.
72
+ catch (err) {
73
+ this.shareSync.onError(err, 'Chat.modelUpdated.workspaceStub');
75
74
  }
76
75
  }
77
76
  }
@@ -30,11 +30,16 @@ class SharedContent extends Content_1.Content {
30
30
  this.acquire();
31
31
  const userIds = this.getAllSharedUserIds();
32
32
  for (const userId of userIds) {
33
- const manifestId = Manifest_1.Manifest.makeManifestId(userId);
34
- const manifest = await this.shareSync.acquire(ContentKind_1.ContentKind.MANIFEST, manifestId);
35
- if (manifest && manifest.exists()) {
36
- manifest.update(this);
37
- manifest.release();
33
+ try {
34
+ const manifestId = Manifest_1.Manifest.makeManifestId(userId);
35
+ const manifest = await this.shareSync.acquire(ContentKind_1.ContentKind.MANIFEST, manifestId);
36
+ if (manifest && manifest.exists()) {
37
+ manifest.update(this);
38
+ manifest.release();
39
+ }
40
+ }
41
+ catch (err) {
42
+ this.shareSync.onError(err, 'SharedContent.modelUpdated.manifest');
38
43
  }
39
44
  }
40
45
  this.release();
@@ -17,6 +17,7 @@ export interface ShareSyncOptions {
17
17
  connectionListener: ConnectionListener;
18
18
  urlProvider: () => Promise<string>;
19
19
  opErrorCallback: (error?: any) => void;
20
+ errorCallback?: (error: any, context: string) => void;
20
21
  onReadyCallback?: () => void;
21
22
  pingInterval?: number;
22
23
  encryptionKey?: string;
@@ -53,6 +54,7 @@ export declare class ShareSync {
53
54
  private _debug;
54
55
  private _disposalStrategy;
55
56
  private _opErrorCallback;
57
+ private _errorCallback;
56
58
  private _modelCache;
57
59
  private _encryption;
58
60
  private _hasDurableStore;
@@ -94,6 +96,7 @@ export declare class ShareSync {
94
96
  isDocInInventory(kind: ContentKind, ref: ContentRef, minVersion?: CompactDateTime): boolean;
95
97
  dispose(model: Model): void;
96
98
  onOperationError(opError: any): void;
99
+ onError(error: any, context: string): void;
97
100
  private wrap;
98
101
  /**
99
102
  * Flush control methods for optimizing bulk write operations
@@ -121,6 +121,7 @@ class ShareSync {
121
121
  shareSync._debug = options.debug;
122
122
  shareSync._disposalStrategy = options.disposalStrategy;
123
123
  shareSync._opErrorCallback = options.opErrorCallback;
124
+ shareSync._errorCallback = options.errorCallback || null;
124
125
  shareSync._hasDurableStore = options.enableDurableStore === true && options.namespace && options.namespace.length > 0;
125
126
  shareSync._useDurableStoreEncryption = options.encryptionKey && options.encryptionKey.length > 0;
126
127
  shareSync._durableStoreEncryptionKey = options.encryptionKey;
@@ -324,7 +325,7 @@ class ShareSync {
324
325
  shareSync.isDebug() && console.log(`created content ${compoundKey}`);
325
326
  const content = shareSync.wrap(body.meta.kind, doc, true);
326
327
  this._modelCache.set(compoundKey, content);
327
- this.updateManifestForContent(content);
328
+ content.modelUpdated();
328
329
  return content;
329
330
  }
330
331
  async acquire(kind, id, timestamp) {
@@ -474,6 +475,11 @@ class ShareSync {
474
475
  onOperationError(opError) {
475
476
  this._opErrorCallback && this._opErrorCallback(opError);
476
477
  }
478
+ onError(error, context) {
479
+ if (this._errorCallback) {
480
+ this._errorCallback(error, context);
481
+ }
482
+ }
477
483
  wrap(kind, doc, shouldAcquire) {
478
484
  const shareSync = this;
479
485
  if (kind === ContentKind_1.ContentKind.BILLING) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shaxpir/duiduidui-models",
3
- "version": "1.24.4",
3
+ "version": "1.25.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/shaxpir/duiduidui-models"