@yorkie-js/react 0.6.38 → 0.6.40

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.
@@ -6130,6 +6130,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
6130
6130
  * @generated from field: bool remove_on_detach = 16;
6131
6131
  */
6132
6132
  __publicField(this, "removeOnDetach", false);
6133
+ /**
6134
+ * @generated from field: bool auto_revision_enabled = 27;
6135
+ */
6136
+ __publicField(this, "autoRevisionEnabled", false);
6133
6137
  /**
6134
6138
  * @generated from field: repeated string allowed_origins = 14;
6135
6139
  */
@@ -6309,6 +6313,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
6309
6313
  T: 8
6310
6314
  /* ScalarType.BOOL */
6311
6315
  },
6316
+ {
6317
+ no: 27,
6318
+ name: "auto_revision_enabled",
6319
+ kind: "scalar",
6320
+ T: 8
6321
+ /* ScalarType.BOOL */
6322
+ },
6312
6323
  { no: 14, name: "allowed_origins", kind: "scalar", T: 9, repeated: true },
6313
6324
  { no: 12, name: "created_at", kind: "message", T: Timestamp },
6314
6325
  { no: 13, name: "updated_at", kind: "message", T: Timestamp }
@@ -6442,6 +6453,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
6442
6453
  * @generated from field: google.protobuf.BoolValue remove_on_detach = 11;
6443
6454
  */
6444
6455
  __publicField(this, "removeOnDetach");
6456
+ /**
6457
+ * @generated from field: google.protobuf.BoolValue auto_revision_enabled = 22;
6458
+ */
6459
+ __publicField(this, "autoRevisionEnabled");
6445
6460
  /**
6446
6461
  * @generated from field: yorkie.v1.UpdatableProjectFields.AllowedOrigins allowed_origins = 9;
6447
6462
  */
@@ -6484,6 +6499,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
6484
6499
  { no: 8, name: "max_attachments_per_document", kind: "message", T: Int32Value },
6485
6500
  { no: 10, name: "max_size_per_document", kind: "message", T: Int32Value },
6486
6501
  { no: 11, name: "remove_on_detach", kind: "message", T: BoolValue },
6502
+ { no: 22, name: "auto_revision_enabled", kind: "message", T: BoolValue },
6487
6503
  { no: 9, name: "allowed_origins", kind: "message", T: UpdatableProjectFields_AllowedOrigins }
6488
6504
  ]));
6489
6505
  let UpdatableProjectFields = _UpdatableProjectFields;
@@ -6752,6 +6768,51 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
6752
6768
  } }
6753
6769
  ]));
6754
6770
  let Presence = _Presence;
6771
+ const _ChannelSummary = class _ChannelSummary extends Message {
6772
+ constructor(data) {
6773
+ super();
6774
+ /**
6775
+ * @generated from field: string key = 1;
6776
+ */
6777
+ __publicField(this, "key", "");
6778
+ /**
6779
+ * @generated from field: int32 presence_count = 2;
6780
+ */
6781
+ __publicField(this, "presenceCount", 0);
6782
+ proto3.util.initPartial(data, this);
6783
+ }
6784
+ static fromBinary(bytes, options) {
6785
+ return new _ChannelSummary().fromBinary(bytes, options);
6786
+ }
6787
+ static fromJson(jsonValue, options) {
6788
+ return new _ChannelSummary().fromJson(jsonValue, options);
6789
+ }
6790
+ static fromJsonString(jsonString, options) {
6791
+ return new _ChannelSummary().fromJsonString(jsonString, options);
6792
+ }
6793
+ static equals(a, b) {
6794
+ return proto3.util.equals(_ChannelSummary, a, b);
6795
+ }
6796
+ };
6797
+ __publicField(_ChannelSummary, "runtime", proto3);
6798
+ __publicField(_ChannelSummary, "typeName", "yorkie.v1.ChannelSummary");
6799
+ __publicField(_ChannelSummary, "fields", proto3.util.newFieldList(() => [
6800
+ {
6801
+ no: 1,
6802
+ name: "key",
6803
+ kind: "scalar",
6804
+ T: 9
6805
+ /* ScalarType.STRING */
6806
+ },
6807
+ {
6808
+ no: 2,
6809
+ name: "presence_count",
6810
+ kind: "scalar",
6811
+ T: 5
6812
+ /* ScalarType.INT32 */
6813
+ }
6814
+ ]));
6815
+ let ChannelSummary = _ChannelSummary;
6755
6816
  let Checkpoint$1 = (_g = class extends Message {
6756
6817
  constructor(data) {
6757
6818
  super();
@@ -7278,6 +7339,78 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7278
7339
  }
7279
7340
  ]));
7280
7341
  let Rule = _Rule;
7342
+ const _RevisionSummary = class _RevisionSummary extends Message {
7343
+ constructor(data) {
7344
+ super();
7345
+ /**
7346
+ * @generated from field: string id = 1;
7347
+ */
7348
+ __publicField(this, "id", "");
7349
+ /**
7350
+ * @generated from field: string label = 2;
7351
+ */
7352
+ __publicField(this, "label", "");
7353
+ /**
7354
+ * @generated from field: string description = 3;
7355
+ */
7356
+ __publicField(this, "description", "");
7357
+ /**
7358
+ * @generated from field: string snapshot = 4;
7359
+ */
7360
+ __publicField(this, "snapshot", "");
7361
+ /**
7362
+ * @generated from field: google.protobuf.Timestamp created_at = 5;
7363
+ */
7364
+ __publicField(this, "createdAt");
7365
+ proto3.util.initPartial(data, this);
7366
+ }
7367
+ static fromBinary(bytes, options) {
7368
+ return new _RevisionSummary().fromBinary(bytes, options);
7369
+ }
7370
+ static fromJson(jsonValue, options) {
7371
+ return new _RevisionSummary().fromJson(jsonValue, options);
7372
+ }
7373
+ static fromJsonString(jsonString, options) {
7374
+ return new _RevisionSummary().fromJsonString(jsonString, options);
7375
+ }
7376
+ static equals(a, b) {
7377
+ return proto3.util.equals(_RevisionSummary, a, b);
7378
+ }
7379
+ };
7380
+ __publicField(_RevisionSummary, "runtime", proto3);
7381
+ __publicField(_RevisionSummary, "typeName", "yorkie.v1.RevisionSummary");
7382
+ __publicField(_RevisionSummary, "fields", proto3.util.newFieldList(() => [
7383
+ {
7384
+ no: 1,
7385
+ name: "id",
7386
+ kind: "scalar",
7387
+ T: 9
7388
+ /* ScalarType.STRING */
7389
+ },
7390
+ {
7391
+ no: 2,
7392
+ name: "label",
7393
+ kind: "scalar",
7394
+ T: 9
7395
+ /* ScalarType.STRING */
7396
+ },
7397
+ {
7398
+ no: 3,
7399
+ name: "description",
7400
+ kind: "scalar",
7401
+ T: 9
7402
+ /* ScalarType.STRING */
7403
+ },
7404
+ {
7405
+ no: 4,
7406
+ name: "snapshot",
7407
+ kind: "scalar",
7408
+ T: 9
7409
+ /* ScalarType.STRING */
7410
+ },
7411
+ { no: 5, name: "created_at", kind: "message", T: Timestamp }
7412
+ ]));
7413
+ let RevisionSummary = _RevisionSummary;
7281
7414
  const _ActivateClientRequest = class _ActivateClientRequest extends Message {
7282
7415
  constructor(data) {
7283
7416
  super();
@@ -7885,6 +8018,274 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7885
8018
  { no: 1, name: "change_pack", kind: "message", T: ChangePack$1 }
7886
8019
  ]));
7887
8020
  let PushPullChangesResponse = _PushPullChangesResponse;
8021
+ const _CreateRevisionRequest = class _CreateRevisionRequest extends Message {
8022
+ constructor(data) {
8023
+ super();
8024
+ /**
8025
+ * @generated from field: string client_id = 1;
8026
+ */
8027
+ __publicField(this, "clientId", "");
8028
+ /**
8029
+ * @generated from field: string document_id = 2;
8030
+ */
8031
+ __publicField(this, "documentId", "");
8032
+ /**
8033
+ * @generated from field: string label = 3;
8034
+ */
8035
+ __publicField(this, "label", "");
8036
+ /**
8037
+ * @generated from field: string description = 4;
8038
+ */
8039
+ __publicField(this, "description", "");
8040
+ proto3.util.initPartial(data, this);
8041
+ }
8042
+ static fromBinary(bytes, options) {
8043
+ return new _CreateRevisionRequest().fromBinary(bytes, options);
8044
+ }
8045
+ static fromJson(jsonValue, options) {
8046
+ return new _CreateRevisionRequest().fromJson(jsonValue, options);
8047
+ }
8048
+ static fromJsonString(jsonString, options) {
8049
+ return new _CreateRevisionRequest().fromJsonString(jsonString, options);
8050
+ }
8051
+ static equals(a, b) {
8052
+ return proto3.util.equals(_CreateRevisionRequest, a, b);
8053
+ }
8054
+ };
8055
+ __publicField(_CreateRevisionRequest, "runtime", proto3);
8056
+ __publicField(_CreateRevisionRequest, "typeName", "yorkie.v1.CreateRevisionRequest");
8057
+ __publicField(_CreateRevisionRequest, "fields", proto3.util.newFieldList(() => [
8058
+ {
8059
+ no: 1,
8060
+ name: "client_id",
8061
+ kind: "scalar",
8062
+ T: 9
8063
+ /* ScalarType.STRING */
8064
+ },
8065
+ {
8066
+ no: 2,
8067
+ name: "document_id",
8068
+ kind: "scalar",
8069
+ T: 9
8070
+ /* ScalarType.STRING */
8071
+ },
8072
+ {
8073
+ no: 3,
8074
+ name: "label",
8075
+ kind: "scalar",
8076
+ T: 9
8077
+ /* ScalarType.STRING */
8078
+ },
8079
+ {
8080
+ no: 4,
8081
+ name: "description",
8082
+ kind: "scalar",
8083
+ T: 9
8084
+ /* ScalarType.STRING */
8085
+ }
8086
+ ]));
8087
+ let CreateRevisionRequest = _CreateRevisionRequest;
8088
+ const _CreateRevisionResponse = class _CreateRevisionResponse extends Message {
8089
+ constructor(data) {
8090
+ super();
8091
+ /**
8092
+ * @generated from field: yorkie.v1.RevisionSummary revision = 1;
8093
+ */
8094
+ __publicField(this, "revision");
8095
+ proto3.util.initPartial(data, this);
8096
+ }
8097
+ static fromBinary(bytes, options) {
8098
+ return new _CreateRevisionResponse().fromBinary(bytes, options);
8099
+ }
8100
+ static fromJson(jsonValue, options) {
8101
+ return new _CreateRevisionResponse().fromJson(jsonValue, options);
8102
+ }
8103
+ static fromJsonString(jsonString, options) {
8104
+ return new _CreateRevisionResponse().fromJsonString(jsonString, options);
8105
+ }
8106
+ static equals(a, b) {
8107
+ return proto3.util.equals(_CreateRevisionResponse, a, b);
8108
+ }
8109
+ };
8110
+ __publicField(_CreateRevisionResponse, "runtime", proto3);
8111
+ __publicField(_CreateRevisionResponse, "typeName", "yorkie.v1.CreateRevisionResponse");
8112
+ __publicField(_CreateRevisionResponse, "fields", proto3.util.newFieldList(() => [
8113
+ { no: 1, name: "revision", kind: "message", T: RevisionSummary }
8114
+ ]));
8115
+ let CreateRevisionResponse = _CreateRevisionResponse;
8116
+ const _ListRevisionsRequest = class _ListRevisionsRequest extends Message {
8117
+ constructor(data) {
8118
+ super();
8119
+ /**
8120
+ * @generated from field: string project_id = 1;
8121
+ */
8122
+ __publicField(this, "projectId", "");
8123
+ /**
8124
+ * @generated from field: string document_id = 2;
8125
+ */
8126
+ __publicField(this, "documentId", "");
8127
+ /**
8128
+ * @generated from field: int32 page_size = 3;
8129
+ */
8130
+ __publicField(this, "pageSize", 0);
8131
+ /**
8132
+ * @generated from field: int32 offset = 4;
8133
+ */
8134
+ __publicField(this, "offset", 0);
8135
+ /**
8136
+ * @generated from field: bool is_forward = 5;
8137
+ */
8138
+ __publicField(this, "isForward", false);
8139
+ proto3.util.initPartial(data, this);
8140
+ }
8141
+ static fromBinary(bytes, options) {
8142
+ return new _ListRevisionsRequest().fromBinary(bytes, options);
8143
+ }
8144
+ static fromJson(jsonValue, options) {
8145
+ return new _ListRevisionsRequest().fromJson(jsonValue, options);
8146
+ }
8147
+ static fromJsonString(jsonString, options) {
8148
+ return new _ListRevisionsRequest().fromJsonString(jsonString, options);
8149
+ }
8150
+ static equals(a, b) {
8151
+ return proto3.util.equals(_ListRevisionsRequest, a, b);
8152
+ }
8153
+ };
8154
+ __publicField(_ListRevisionsRequest, "runtime", proto3);
8155
+ __publicField(_ListRevisionsRequest, "typeName", "yorkie.v1.ListRevisionsRequest");
8156
+ __publicField(_ListRevisionsRequest, "fields", proto3.util.newFieldList(() => [
8157
+ {
8158
+ no: 1,
8159
+ name: "project_id",
8160
+ kind: "scalar",
8161
+ T: 9
8162
+ /* ScalarType.STRING */
8163
+ },
8164
+ {
8165
+ no: 2,
8166
+ name: "document_id",
8167
+ kind: "scalar",
8168
+ T: 9
8169
+ /* ScalarType.STRING */
8170
+ },
8171
+ {
8172
+ no: 3,
8173
+ name: "page_size",
8174
+ kind: "scalar",
8175
+ T: 5
8176
+ /* ScalarType.INT32 */
8177
+ },
8178
+ {
8179
+ no: 4,
8180
+ name: "offset",
8181
+ kind: "scalar",
8182
+ T: 5
8183
+ /* ScalarType.INT32 */
8184
+ },
8185
+ {
8186
+ no: 5,
8187
+ name: "is_forward",
8188
+ kind: "scalar",
8189
+ T: 8
8190
+ /* ScalarType.BOOL */
8191
+ }
8192
+ ]));
8193
+ let ListRevisionsRequest = _ListRevisionsRequest;
8194
+ const _ListRevisionsResponse = class _ListRevisionsResponse extends Message {
8195
+ constructor(data) {
8196
+ super();
8197
+ /**
8198
+ * @generated from field: repeated yorkie.v1.RevisionSummary revisions = 1;
8199
+ */
8200
+ __publicField(this, "revisions", []);
8201
+ proto3.util.initPartial(data, this);
8202
+ }
8203
+ static fromBinary(bytes, options) {
8204
+ return new _ListRevisionsResponse().fromBinary(bytes, options);
8205
+ }
8206
+ static fromJson(jsonValue, options) {
8207
+ return new _ListRevisionsResponse().fromJson(jsonValue, options);
8208
+ }
8209
+ static fromJsonString(jsonString, options) {
8210
+ return new _ListRevisionsResponse().fromJsonString(jsonString, options);
8211
+ }
8212
+ static equals(a, b) {
8213
+ return proto3.util.equals(_ListRevisionsResponse, a, b);
8214
+ }
8215
+ };
8216
+ __publicField(_ListRevisionsResponse, "runtime", proto3);
8217
+ __publicField(_ListRevisionsResponse, "typeName", "yorkie.v1.ListRevisionsResponse");
8218
+ __publicField(_ListRevisionsResponse, "fields", proto3.util.newFieldList(() => [
8219
+ { no: 1, name: "revisions", kind: "message", T: RevisionSummary, repeated: true }
8220
+ ]));
8221
+ let ListRevisionsResponse = _ListRevisionsResponse;
8222
+ const _RestoreRevisionRequest = class _RestoreRevisionRequest extends Message {
8223
+ constructor(data) {
8224
+ super();
8225
+ /**
8226
+ * @generated from field: string client_id = 1;
8227
+ */
8228
+ __publicField(this, "clientId", "");
8229
+ /**
8230
+ * @generated from field: string revision_id = 2;
8231
+ */
8232
+ __publicField(this, "revisionId", "");
8233
+ proto3.util.initPartial(data, this);
8234
+ }
8235
+ static fromBinary(bytes, options) {
8236
+ return new _RestoreRevisionRequest().fromBinary(bytes, options);
8237
+ }
8238
+ static fromJson(jsonValue, options) {
8239
+ return new _RestoreRevisionRequest().fromJson(jsonValue, options);
8240
+ }
8241
+ static fromJsonString(jsonString, options) {
8242
+ return new _RestoreRevisionRequest().fromJsonString(jsonString, options);
8243
+ }
8244
+ static equals(a, b) {
8245
+ return proto3.util.equals(_RestoreRevisionRequest, a, b);
8246
+ }
8247
+ };
8248
+ __publicField(_RestoreRevisionRequest, "runtime", proto3);
8249
+ __publicField(_RestoreRevisionRequest, "typeName", "yorkie.v1.RestoreRevisionRequest");
8250
+ __publicField(_RestoreRevisionRequest, "fields", proto3.util.newFieldList(() => [
8251
+ {
8252
+ no: 1,
8253
+ name: "client_id",
8254
+ kind: "scalar",
8255
+ T: 9
8256
+ /* ScalarType.STRING */
8257
+ },
8258
+ {
8259
+ no: 2,
8260
+ name: "revision_id",
8261
+ kind: "scalar",
8262
+ T: 9
8263
+ /* ScalarType.STRING */
8264
+ }
8265
+ ]));
8266
+ let RestoreRevisionRequest = _RestoreRevisionRequest;
8267
+ const _RestoreRevisionResponse = class _RestoreRevisionResponse extends Message {
8268
+ constructor(data) {
8269
+ super();
8270
+ proto3.util.initPartial(data, this);
8271
+ }
8272
+ static fromBinary(bytes, options) {
8273
+ return new _RestoreRevisionResponse().fromBinary(bytes, options);
8274
+ }
8275
+ static fromJson(jsonValue, options) {
8276
+ return new _RestoreRevisionResponse().fromJson(jsonValue, options);
8277
+ }
8278
+ static fromJsonString(jsonString, options) {
8279
+ return new _RestoreRevisionResponse().fromJsonString(jsonString, options);
8280
+ }
8281
+ static equals(a, b) {
8282
+ return proto3.util.equals(_RestoreRevisionResponse, a, b);
8283
+ }
8284
+ };
8285
+ __publicField(_RestoreRevisionResponse, "runtime", proto3);
8286
+ __publicField(_RestoreRevisionResponse, "typeName", "yorkie.v1.RestoreRevisionResponse");
8287
+ __publicField(_RestoreRevisionResponse, "fields", proto3.util.newFieldList(() => []));
8288
+ let RestoreRevisionResponse = _RestoreRevisionResponse;
7888
8289
  const _AttachChannelRequest = class _AttachChannelRequest extends Message {
7889
8290
  constructor(data) {
7890
8291
  super();
@@ -8429,6 +8830,33 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8429
8830
  O: WatchDocumentResponse,
8430
8831
  kind: MethodKind.ServerStreaming
8431
8832
  },
8833
+ /**
8834
+ * @generated from rpc yorkie.v1.YorkieService.CreateRevision
8835
+ */
8836
+ createRevision: {
8837
+ name: "CreateRevision",
8838
+ I: CreateRevisionRequest,
8839
+ O: CreateRevisionResponse,
8840
+ kind: MethodKind.Unary
8841
+ },
8842
+ /**
8843
+ * @generated from rpc yorkie.v1.YorkieService.ListRevisions
8844
+ */
8845
+ listRevisions: {
8846
+ name: "ListRevisions",
8847
+ I: ListRevisionsRequest,
8848
+ O: ListRevisionsResponse,
8849
+ kind: MethodKind.Unary
8850
+ },
8851
+ /**
8852
+ * @generated from rpc yorkie.v1.YorkieService.RestoreRevision
8853
+ */
8854
+ restoreRevision: {
8855
+ name: "RestoreRevision",
8856
+ I: RestoreRevisionRequest,
8857
+ O: RestoreRevisionResponse,
8858
+ kind: MethodKind.Unary
8859
+ },
8432
8860
  /**
8433
8861
  * @generated from rpc yorkie.v1.YorkieService.AttachChannel
8434
8862
  */
@@ -17634,6 +18062,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
17634
18062
  versionVector: toVersionVector(pack.getVersionVector())
17635
18063
  });
17636
18064
  }
18065
+ function toRevisionSummary(pbRevision) {
18066
+ var _a2;
18067
+ return {
18068
+ id: pbRevision.id,
18069
+ label: pbRevision.label,
18070
+ description: pbRevision.description,
18071
+ snapshot: pbRevision.snapshot,
18072
+ createdAt: ((_a2 = pbRevision.createdAt) == null ? void 0 : _a2.toDate()) || /* @__PURE__ */ new Date()
18073
+ };
18074
+ }
17637
18075
  function errorMetadataOf(error) {
17638
18076
  if (!(error instanceof ConnectError)) {
17639
18077
  return {};
@@ -18263,7 +18701,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
18263
18701
  bytesToOperation,
18264
18702
  versionVectorToHex,
18265
18703
  hexToVersionVector,
18266
- fromSchemaRules
18704
+ fromSchemaRules,
18705
+ toRevisionSummary
18267
18706
  };
18268
18707
  var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
18269
18708
  LogLevel2[LogLevel2["Trivial"] = 0] = "Trivial";
@@ -22296,7 +22735,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
22296
22735
  };
22297
22736
  }
22298
22737
  const name$1 = "@yorkie-js/sdk";
22299
- const version$1 = "0.6.38";
22738
+ const version$1 = "0.6.40";
22300
22739
  const pkg$1 = {
22301
22740
  name: name$1,
22302
22741
  version: version$1
@@ -23144,6 +23583,131 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
23144
23583
  getCondition(condition) {
23145
23584
  return this.conditions[condition];
23146
23585
  }
23586
+ /**
23587
+ * `createRevision` creates a new revision for the given document.
23588
+ */
23589
+ async createRevision(doc, label, description) {
23590
+ if (!this.isActive()) {
23591
+ throw new YorkieError(
23592
+ Code.ErrClientNotActivated,
23593
+ `${this.key} is not active`
23594
+ );
23595
+ }
23596
+ const attachment = this.attachmentMap.get(doc.getKey());
23597
+ if (!attachment) {
23598
+ throw new YorkieError(
23599
+ Code.ErrNotAttached,
23600
+ `${doc.getKey()} is not attached`
23601
+ );
23602
+ }
23603
+ const task = async () => {
23604
+ try {
23605
+ const res = await this.rpcClient.createRevision(
23606
+ {
23607
+ clientId: this.id,
23608
+ documentId: attachment.resourceID,
23609
+ label,
23610
+ description: description || ""
23611
+ },
23612
+ { headers: { "x-shard-key": `${this.apiKey}/${doc.getKey()}` } }
23613
+ );
23614
+ if (!res.revision) {
23615
+ throw new YorkieError(
23616
+ Code.ErrInvalidArgument,
23617
+ "revision is not returned"
23618
+ );
23619
+ }
23620
+ logger.info(
23621
+ `[CR] c:"${this.getKey()}" creates revision d:"${doc.getKey()}" l:"${label}"`
23622
+ );
23623
+ return converter.toRevisionSummary(res.revision);
23624
+ } catch (err) {
23625
+ logger.error(`[CR] c:"${this.getKey()}" err :`, err);
23626
+ await this.handleConnectError(err);
23627
+ throw err;
23628
+ }
23629
+ };
23630
+ return this.enqueueTask(task);
23631
+ }
23632
+ /**
23633
+ * `listRevisions` lists all revisions for the given document.
23634
+ */
23635
+ async listRevisions(doc, options) {
23636
+ if (!this.isActive()) {
23637
+ throw new YorkieError(
23638
+ Code.ErrClientNotActivated,
23639
+ `${this.key} is not active`
23640
+ );
23641
+ }
23642
+ const attachment = this.attachmentMap.get(doc.getKey());
23643
+ if (!attachment) {
23644
+ throw new YorkieError(
23645
+ Code.ErrNotAttached,
23646
+ `${doc.getKey()} is not attached`
23647
+ );
23648
+ }
23649
+ const task = async () => {
23650
+ try {
23651
+ const res = await this.rpcClient.listRevisions(
23652
+ {
23653
+ projectId: "",
23654
+ // Will be filled by server from auth context
23655
+ documentId: attachment.resourceID,
23656
+ pageSize: (options == null ? void 0 : options.pageSize) || 10,
23657
+ offset: (options == null ? void 0 : options.offset) || 0,
23658
+ isForward: (options == null ? void 0 : options.isForward) ?? false
23659
+ },
23660
+ { headers: { "x-shard-key": `${this.apiKey}/${doc.getKey()}` } }
23661
+ );
23662
+ logger.info(
23663
+ `[LR] c:"${this.getKey()}" lists revisions d:"${doc.getKey()}" count:${res.revisions.length}`
23664
+ );
23665
+ return res.revisions.map(converter.toRevisionSummary);
23666
+ } catch (err) {
23667
+ logger.error(`[LR] c:"${this.getKey()}" err :`, err);
23668
+ await this.handleConnectError(err);
23669
+ throw err;
23670
+ }
23671
+ };
23672
+ return this.enqueueTask(task);
23673
+ }
23674
+ /**
23675
+ * `restoreRevision` restores the document to the given revision.
23676
+ */
23677
+ async restoreRevision(doc, revisionId) {
23678
+ if (!this.isActive()) {
23679
+ throw new YorkieError(
23680
+ Code.ErrClientNotActivated,
23681
+ `${this.key} is not active`
23682
+ );
23683
+ }
23684
+ const attachment = this.attachmentMap.get(doc.getKey());
23685
+ if (!attachment) {
23686
+ throw new YorkieError(
23687
+ Code.ErrNotAttached,
23688
+ `${doc.getKey()} is not attached`
23689
+ );
23690
+ }
23691
+ const task = async () => {
23692
+ try {
23693
+ await this.rpcClient.restoreRevision(
23694
+ {
23695
+ clientId: this.id,
23696
+ revisionId
23697
+ },
23698
+ { headers: { "x-shard-key": `${this.apiKey}/${doc.getKey()}` } }
23699
+ );
23700
+ logger.info(
23701
+ `[RR] c:"${this.getKey()}" restores revision d:"${doc.getKey()}" r:"${revisionId}"`
23702
+ );
23703
+ } catch (err) {
23704
+ logger.error(`[RR] c:"${this.getKey()}" err :`, err);
23705
+ await this.handleConnectError(err);
23706
+ throw err;
23707
+ }
23708
+ };
23709
+ return this.enqueueTask(task);
23710
+ }
23147
23711
  /**
23148
23712
  * `broadcast` broadcasts the given payload to the given topic.
23149
23713
  */
@@ -23717,7 +24281,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
23717
24281
  };
23718
24282
  }
23719
24283
  const name = "@yorkie-js/react";
23720
- const version = "0.6.38";
24284
+ const version = "0.6.40";
23721
24285
  const pkg = {
23722
24286
  name,
23723
24287
  version
@@ -23907,7 +24471,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
23907
24471
  valueB
23908
24472
  );
23909
24473
  }
23910
- function useYorkieDocument(client, clientLoading, clientError, docKey, initialRoot, initialPresence, documentStore) {
24474
+ function useYorkieDocument(client, clientLoading, clientError, docKey, initialRoot, initialPresence, enableDevtools, docStore) {
23911
24475
  const initialRootRef = react.useRef(initialRoot);
23912
24476
  const initialPresenceRef = react.useRef(initialPresence);
23913
24477
  const [didMount, setDidMount] = react.useState(false);
@@ -23916,7 +24480,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
23916
24480
  }, []);
23917
24481
  react.useEffect(() => {
23918
24482
  if (clientError) {
23919
- documentStore.setState((state) => ({
24483
+ docStore.setState((state) => ({
23920
24484
  ...state,
23921
24485
  loading: false,
23922
24486
  error: clientError
@@ -23924,22 +24488,22 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
23924
24488
  return;
23925
24489
  }
23926
24490
  if (!client || clientLoading || !didMount) {
23927
- documentStore.setState((state) => ({
24491
+ docStore.setState((state) => ({
23928
24492
  ...state,
23929
24493
  loading: true
23930
24494
  }));
23931
24495
  return;
23932
24496
  }
23933
- documentStore.setState((state) => ({
24497
+ docStore.setState((state) => ({
23934
24498
  ...state,
23935
24499
  loading: true,
23936
24500
  error: void 0
23937
24501
  }));
23938
- const newDoc = new Document(docKey);
24502
+ const newDoc = new Document(docKey, { enableDevtools });
23939
24503
  const unsubs = [];
23940
24504
  unsubs.push(
23941
24505
  newDoc.subscribe(() => {
23942
- documentStore.setState((state) => ({
24506
+ docStore.setState((state) => ({
23943
24507
  ...state,
23944
24508
  root: newDoc.getRoot()
23945
24509
  }));
@@ -23947,7 +24511,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
23947
24511
  );
23948
24512
  unsubs.push(
23949
24513
  newDoc.subscribe("presence", () => {
23950
- documentStore.setState((state) => ({
24514
+ docStore.setState((state) => ({
23951
24515
  ...state,
23952
24516
  presences: newDoc.getPresences()
23953
24517
  }));
@@ -23955,7 +24519,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
23955
24519
  );
23956
24520
  unsubs.push(
23957
24521
  newDoc.subscribe("connection", (event) => {
23958
- documentStore.setState((state) => ({
24522
+ docStore.setState((state) => ({
23959
24523
  ...state,
23960
24524
  connection: event.value
23961
24525
  }));
@@ -23971,13 +24535,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
23971
24535
  try {
23972
24536
  newDoc.update(callback);
23973
24537
  } catch (err) {
23974
- documentStore.setState((state) => ({
24538
+ docStore.setState((state) => ({
23975
24539
  ...state,
23976
24540
  error: err instanceof Error ? err : new Error("Failed to update document")
23977
24541
  }));
23978
24542
  }
23979
24543
  };
23980
- documentStore.setState((state) => ({
24544
+ docStore.setState((state) => ({
23981
24545
  ...state,
23982
24546
  doc: newDoc,
23983
24547
  root: newDoc.getRoot(),
@@ -23985,12 +24549,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
23985
24549
  update
23986
24550
  }));
23987
24551
  } catch (err) {
23988
- documentStore.setState((state) => ({
24552
+ docStore.setState((state) => ({
23989
24553
  ...state,
23990
24554
  error: err instanceof Error ? err : new Error("Failed to attach document")
23991
24555
  }));
23992
24556
  } finally {
23993
- documentStore.setState((state) => ({
24557
+ docStore.setState((state) => ({
23994
24558
  ...state,
23995
24559
  loading: false
23996
24560
  }));
@@ -24005,13 +24569,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
24005
24569
  unsub();
24006
24570
  }
24007
24571
  };
24008
- }, [client, clientLoading, clientError, docKey, documentStore, didMount]);
24572
+ }, [client, clientLoading, clientError, docKey, docStore, didMount]);
24009
24573
  }
24010
24574
  const DocumentContext = react.createContext(void 0);
24011
24575
  const DocumentProvider = ({
24012
24576
  docKey,
24013
24577
  initialRoot = {},
24014
24578
  initialPresence = {},
24579
+ enableDevtools = false,
24015
24580
  children
24016
24581
  }) => {
24017
24582
  const { client, loading: clientLoading, error: clientError } = useYorkie();
@@ -24036,6 +24601,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
24036
24601
  docKey,
24037
24602
  initialRoot,
24038
24603
  initialPresence,
24604
+ enableDevtools,
24039
24605
  documentStore
24040
24606
  );
24041
24607
  return /* @__PURE__ */ jsxRuntime.jsx(DocumentContext.Provider, { value: documentStore, children });
@@ -24110,6 +24676,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
24110
24676
  docKey,
24111
24677
  (opts == null ? void 0 : opts.initialRoot) ?? {},
24112
24678
  (opts == null ? void 0 : opts.initialPresence) ?? {},
24679
+ (opts == null ? void 0 : opts.enableDevtools) ?? false,
24113
24680
  documentStore
24114
24681
  );
24115
24682
  const documentState = useSelector(documentStore);