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