@yorkie-js/sdk 0.6.39 → 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.
@@ -6101,6 +6101,10 @@ const _Project = class _Project extends Message {
6101
6101
  * @generated from field: bool remove_on_detach = 16;
6102
6102
  */
6103
6103
  __publicField(this, "removeOnDetach", false);
6104
+ /**
6105
+ * @generated from field: bool auto_revision_enabled = 27;
6106
+ */
6107
+ __publicField(this, "autoRevisionEnabled", false);
6104
6108
  /**
6105
6109
  * @generated from field: repeated string allowed_origins = 14;
6106
6110
  */
@@ -6280,6 +6284,13 @@ __publicField(_Project, "fields", proto3.util.newFieldList(() => [
6280
6284
  T: 8
6281
6285
  /* ScalarType.BOOL */
6282
6286
  },
6287
+ {
6288
+ no: 27,
6289
+ name: "auto_revision_enabled",
6290
+ kind: "scalar",
6291
+ T: 8
6292
+ /* ScalarType.BOOL */
6293
+ },
6283
6294
  { no: 14, name: "allowed_origins", kind: "scalar", T: 9, repeated: true },
6284
6295
  { no: 12, name: "created_at", kind: "message", T: Timestamp },
6285
6296
  { no: 13, name: "updated_at", kind: "message", T: Timestamp }
@@ -6413,6 +6424,10 @@ const _UpdatableProjectFields = class _UpdatableProjectFields extends Message {
6413
6424
  * @generated from field: google.protobuf.BoolValue remove_on_detach = 11;
6414
6425
  */
6415
6426
  __publicField(this, "removeOnDetach");
6427
+ /**
6428
+ * @generated from field: google.protobuf.BoolValue auto_revision_enabled = 22;
6429
+ */
6430
+ __publicField(this, "autoRevisionEnabled");
6416
6431
  /**
6417
6432
  * @generated from field: yorkie.v1.UpdatableProjectFields.AllowedOrigins allowed_origins = 9;
6418
6433
  */
@@ -6455,6 +6470,7 @@ __publicField(_UpdatableProjectFields, "fields", proto3.util.newFieldList(() =>
6455
6470
  { no: 8, name: "max_attachments_per_document", kind: "message", T: Int32Value },
6456
6471
  { no: 10, name: "max_size_per_document", kind: "message", T: Int32Value },
6457
6472
  { no: 11, name: "remove_on_detach", kind: "message", T: BoolValue },
6473
+ { no: 22, name: "auto_revision_enabled", kind: "message", T: BoolValue },
6458
6474
  { no: 9, name: "allowed_origins", kind: "message", T: UpdatableProjectFields_AllowedOrigins }
6459
6475
  ]));
6460
6476
  let UpdatableProjectFields = _UpdatableProjectFields;
@@ -6723,6 +6739,51 @@ __publicField(_Presence, "fields", proto3.util.newFieldList(() => [
6723
6739
  } }
6724
6740
  ]));
6725
6741
  let Presence = _Presence;
6742
+ const _ChannelSummary = class _ChannelSummary extends Message {
6743
+ constructor(data) {
6744
+ super();
6745
+ /**
6746
+ * @generated from field: string key = 1;
6747
+ */
6748
+ __publicField(this, "key", "");
6749
+ /**
6750
+ * @generated from field: int32 presence_count = 2;
6751
+ */
6752
+ __publicField(this, "presenceCount", 0);
6753
+ proto3.util.initPartial(data, this);
6754
+ }
6755
+ static fromBinary(bytes, options) {
6756
+ return new _ChannelSummary().fromBinary(bytes, options);
6757
+ }
6758
+ static fromJson(jsonValue, options) {
6759
+ return new _ChannelSummary().fromJson(jsonValue, options);
6760
+ }
6761
+ static fromJsonString(jsonString, options) {
6762
+ return new _ChannelSummary().fromJsonString(jsonString, options);
6763
+ }
6764
+ static equals(a, b) {
6765
+ return proto3.util.equals(_ChannelSummary, a, b);
6766
+ }
6767
+ };
6768
+ __publicField(_ChannelSummary, "runtime", proto3);
6769
+ __publicField(_ChannelSummary, "typeName", "yorkie.v1.ChannelSummary");
6770
+ __publicField(_ChannelSummary, "fields", proto3.util.newFieldList(() => [
6771
+ {
6772
+ no: 1,
6773
+ name: "key",
6774
+ kind: "scalar",
6775
+ T: 9
6776
+ /* ScalarType.STRING */
6777
+ },
6778
+ {
6779
+ no: 2,
6780
+ name: "presence_count",
6781
+ kind: "scalar",
6782
+ T: 5
6783
+ /* ScalarType.INT32 */
6784
+ }
6785
+ ]));
6786
+ let ChannelSummary = _ChannelSummary;
6726
6787
  let Checkpoint$1 = (_g = class extends Message {
6727
6788
  constructor(data) {
6728
6789
  super();
@@ -7249,6 +7310,78 @@ __publicField(_Rule, "fields", proto3.util.newFieldList(() => [
7249
7310
  }
7250
7311
  ]));
7251
7312
  let Rule = _Rule;
7313
+ const _RevisionSummary = class _RevisionSummary extends Message {
7314
+ constructor(data) {
7315
+ super();
7316
+ /**
7317
+ * @generated from field: string id = 1;
7318
+ */
7319
+ __publicField(this, "id", "");
7320
+ /**
7321
+ * @generated from field: string label = 2;
7322
+ */
7323
+ __publicField(this, "label", "");
7324
+ /**
7325
+ * @generated from field: string description = 3;
7326
+ */
7327
+ __publicField(this, "description", "");
7328
+ /**
7329
+ * @generated from field: string snapshot = 4;
7330
+ */
7331
+ __publicField(this, "snapshot", "");
7332
+ /**
7333
+ * @generated from field: google.protobuf.Timestamp created_at = 5;
7334
+ */
7335
+ __publicField(this, "createdAt");
7336
+ proto3.util.initPartial(data, this);
7337
+ }
7338
+ static fromBinary(bytes, options) {
7339
+ return new _RevisionSummary().fromBinary(bytes, options);
7340
+ }
7341
+ static fromJson(jsonValue, options) {
7342
+ return new _RevisionSummary().fromJson(jsonValue, options);
7343
+ }
7344
+ static fromJsonString(jsonString, options) {
7345
+ return new _RevisionSummary().fromJsonString(jsonString, options);
7346
+ }
7347
+ static equals(a, b) {
7348
+ return proto3.util.equals(_RevisionSummary, a, b);
7349
+ }
7350
+ };
7351
+ __publicField(_RevisionSummary, "runtime", proto3);
7352
+ __publicField(_RevisionSummary, "typeName", "yorkie.v1.RevisionSummary");
7353
+ __publicField(_RevisionSummary, "fields", proto3.util.newFieldList(() => [
7354
+ {
7355
+ no: 1,
7356
+ name: "id",
7357
+ kind: "scalar",
7358
+ T: 9
7359
+ /* ScalarType.STRING */
7360
+ },
7361
+ {
7362
+ no: 2,
7363
+ name: "label",
7364
+ kind: "scalar",
7365
+ T: 9
7366
+ /* ScalarType.STRING */
7367
+ },
7368
+ {
7369
+ no: 3,
7370
+ name: "description",
7371
+ kind: "scalar",
7372
+ T: 9
7373
+ /* ScalarType.STRING */
7374
+ },
7375
+ {
7376
+ no: 4,
7377
+ name: "snapshot",
7378
+ kind: "scalar",
7379
+ T: 9
7380
+ /* ScalarType.STRING */
7381
+ },
7382
+ { no: 5, name: "created_at", kind: "message", T: Timestamp }
7383
+ ]));
7384
+ let RevisionSummary = _RevisionSummary;
7252
7385
  const _ActivateClientRequest = class _ActivateClientRequest extends Message {
7253
7386
  constructor(data) {
7254
7387
  super();
@@ -7856,6 +7989,274 @@ __publicField(_PushPullChangesResponse, "fields", proto3.util.newFieldList(() =>
7856
7989
  { no: 1, name: "change_pack", kind: "message", T: ChangePack$1 }
7857
7990
  ]));
7858
7991
  let PushPullChangesResponse = _PushPullChangesResponse;
7992
+ const _CreateRevisionRequest = class _CreateRevisionRequest extends Message {
7993
+ constructor(data) {
7994
+ super();
7995
+ /**
7996
+ * @generated from field: string client_id = 1;
7997
+ */
7998
+ __publicField(this, "clientId", "");
7999
+ /**
8000
+ * @generated from field: string document_id = 2;
8001
+ */
8002
+ __publicField(this, "documentId", "");
8003
+ /**
8004
+ * @generated from field: string label = 3;
8005
+ */
8006
+ __publicField(this, "label", "");
8007
+ /**
8008
+ * @generated from field: string description = 4;
8009
+ */
8010
+ __publicField(this, "description", "");
8011
+ proto3.util.initPartial(data, this);
8012
+ }
8013
+ static fromBinary(bytes, options) {
8014
+ return new _CreateRevisionRequest().fromBinary(bytes, options);
8015
+ }
8016
+ static fromJson(jsonValue, options) {
8017
+ return new _CreateRevisionRequest().fromJson(jsonValue, options);
8018
+ }
8019
+ static fromJsonString(jsonString, options) {
8020
+ return new _CreateRevisionRequest().fromJsonString(jsonString, options);
8021
+ }
8022
+ static equals(a, b) {
8023
+ return proto3.util.equals(_CreateRevisionRequest, a, b);
8024
+ }
8025
+ };
8026
+ __publicField(_CreateRevisionRequest, "runtime", proto3);
8027
+ __publicField(_CreateRevisionRequest, "typeName", "yorkie.v1.CreateRevisionRequest");
8028
+ __publicField(_CreateRevisionRequest, "fields", proto3.util.newFieldList(() => [
8029
+ {
8030
+ no: 1,
8031
+ name: "client_id",
8032
+ kind: "scalar",
8033
+ T: 9
8034
+ /* ScalarType.STRING */
8035
+ },
8036
+ {
8037
+ no: 2,
8038
+ name: "document_id",
8039
+ kind: "scalar",
8040
+ T: 9
8041
+ /* ScalarType.STRING */
8042
+ },
8043
+ {
8044
+ no: 3,
8045
+ name: "label",
8046
+ kind: "scalar",
8047
+ T: 9
8048
+ /* ScalarType.STRING */
8049
+ },
8050
+ {
8051
+ no: 4,
8052
+ name: "description",
8053
+ kind: "scalar",
8054
+ T: 9
8055
+ /* ScalarType.STRING */
8056
+ }
8057
+ ]));
8058
+ let CreateRevisionRequest = _CreateRevisionRequest;
8059
+ const _CreateRevisionResponse = class _CreateRevisionResponse extends Message {
8060
+ constructor(data) {
8061
+ super();
8062
+ /**
8063
+ * @generated from field: yorkie.v1.RevisionSummary revision = 1;
8064
+ */
8065
+ __publicField(this, "revision");
8066
+ proto3.util.initPartial(data, this);
8067
+ }
8068
+ static fromBinary(bytes, options) {
8069
+ return new _CreateRevisionResponse().fromBinary(bytes, options);
8070
+ }
8071
+ static fromJson(jsonValue, options) {
8072
+ return new _CreateRevisionResponse().fromJson(jsonValue, options);
8073
+ }
8074
+ static fromJsonString(jsonString, options) {
8075
+ return new _CreateRevisionResponse().fromJsonString(jsonString, options);
8076
+ }
8077
+ static equals(a, b) {
8078
+ return proto3.util.equals(_CreateRevisionResponse, a, b);
8079
+ }
8080
+ };
8081
+ __publicField(_CreateRevisionResponse, "runtime", proto3);
8082
+ __publicField(_CreateRevisionResponse, "typeName", "yorkie.v1.CreateRevisionResponse");
8083
+ __publicField(_CreateRevisionResponse, "fields", proto3.util.newFieldList(() => [
8084
+ { no: 1, name: "revision", kind: "message", T: RevisionSummary }
8085
+ ]));
8086
+ let CreateRevisionResponse = _CreateRevisionResponse;
8087
+ const _ListRevisionsRequest = class _ListRevisionsRequest extends Message {
8088
+ constructor(data) {
8089
+ super();
8090
+ /**
8091
+ * @generated from field: string project_id = 1;
8092
+ */
8093
+ __publicField(this, "projectId", "");
8094
+ /**
8095
+ * @generated from field: string document_id = 2;
8096
+ */
8097
+ __publicField(this, "documentId", "");
8098
+ /**
8099
+ * @generated from field: int32 page_size = 3;
8100
+ */
8101
+ __publicField(this, "pageSize", 0);
8102
+ /**
8103
+ * @generated from field: int32 offset = 4;
8104
+ */
8105
+ __publicField(this, "offset", 0);
8106
+ /**
8107
+ * @generated from field: bool is_forward = 5;
8108
+ */
8109
+ __publicField(this, "isForward", false);
8110
+ proto3.util.initPartial(data, this);
8111
+ }
8112
+ static fromBinary(bytes, options) {
8113
+ return new _ListRevisionsRequest().fromBinary(bytes, options);
8114
+ }
8115
+ static fromJson(jsonValue, options) {
8116
+ return new _ListRevisionsRequest().fromJson(jsonValue, options);
8117
+ }
8118
+ static fromJsonString(jsonString, options) {
8119
+ return new _ListRevisionsRequest().fromJsonString(jsonString, options);
8120
+ }
8121
+ static equals(a, b) {
8122
+ return proto3.util.equals(_ListRevisionsRequest, a, b);
8123
+ }
8124
+ };
8125
+ __publicField(_ListRevisionsRequest, "runtime", proto3);
8126
+ __publicField(_ListRevisionsRequest, "typeName", "yorkie.v1.ListRevisionsRequest");
8127
+ __publicField(_ListRevisionsRequest, "fields", proto3.util.newFieldList(() => [
8128
+ {
8129
+ no: 1,
8130
+ name: "project_id",
8131
+ kind: "scalar",
8132
+ T: 9
8133
+ /* ScalarType.STRING */
8134
+ },
8135
+ {
8136
+ no: 2,
8137
+ name: "document_id",
8138
+ kind: "scalar",
8139
+ T: 9
8140
+ /* ScalarType.STRING */
8141
+ },
8142
+ {
8143
+ no: 3,
8144
+ name: "page_size",
8145
+ kind: "scalar",
8146
+ T: 5
8147
+ /* ScalarType.INT32 */
8148
+ },
8149
+ {
8150
+ no: 4,
8151
+ name: "offset",
8152
+ kind: "scalar",
8153
+ T: 5
8154
+ /* ScalarType.INT32 */
8155
+ },
8156
+ {
8157
+ no: 5,
8158
+ name: "is_forward",
8159
+ kind: "scalar",
8160
+ T: 8
8161
+ /* ScalarType.BOOL */
8162
+ }
8163
+ ]));
8164
+ let ListRevisionsRequest = _ListRevisionsRequest;
8165
+ const _ListRevisionsResponse = class _ListRevisionsResponse extends Message {
8166
+ constructor(data) {
8167
+ super();
8168
+ /**
8169
+ * @generated from field: repeated yorkie.v1.RevisionSummary revisions = 1;
8170
+ */
8171
+ __publicField(this, "revisions", []);
8172
+ proto3.util.initPartial(data, this);
8173
+ }
8174
+ static fromBinary(bytes, options) {
8175
+ return new _ListRevisionsResponse().fromBinary(bytes, options);
8176
+ }
8177
+ static fromJson(jsonValue, options) {
8178
+ return new _ListRevisionsResponse().fromJson(jsonValue, options);
8179
+ }
8180
+ static fromJsonString(jsonString, options) {
8181
+ return new _ListRevisionsResponse().fromJsonString(jsonString, options);
8182
+ }
8183
+ static equals(a, b) {
8184
+ return proto3.util.equals(_ListRevisionsResponse, a, b);
8185
+ }
8186
+ };
8187
+ __publicField(_ListRevisionsResponse, "runtime", proto3);
8188
+ __publicField(_ListRevisionsResponse, "typeName", "yorkie.v1.ListRevisionsResponse");
8189
+ __publicField(_ListRevisionsResponse, "fields", proto3.util.newFieldList(() => [
8190
+ { no: 1, name: "revisions", kind: "message", T: RevisionSummary, repeated: true }
8191
+ ]));
8192
+ let ListRevisionsResponse = _ListRevisionsResponse;
8193
+ const _RestoreRevisionRequest = class _RestoreRevisionRequest extends Message {
8194
+ constructor(data) {
8195
+ super();
8196
+ /**
8197
+ * @generated from field: string client_id = 1;
8198
+ */
8199
+ __publicField(this, "clientId", "");
8200
+ /**
8201
+ * @generated from field: string revision_id = 2;
8202
+ */
8203
+ __publicField(this, "revisionId", "");
8204
+ proto3.util.initPartial(data, this);
8205
+ }
8206
+ static fromBinary(bytes, options) {
8207
+ return new _RestoreRevisionRequest().fromBinary(bytes, options);
8208
+ }
8209
+ static fromJson(jsonValue, options) {
8210
+ return new _RestoreRevisionRequest().fromJson(jsonValue, options);
8211
+ }
8212
+ static fromJsonString(jsonString, options) {
8213
+ return new _RestoreRevisionRequest().fromJsonString(jsonString, options);
8214
+ }
8215
+ static equals(a, b) {
8216
+ return proto3.util.equals(_RestoreRevisionRequest, a, b);
8217
+ }
8218
+ };
8219
+ __publicField(_RestoreRevisionRequest, "runtime", proto3);
8220
+ __publicField(_RestoreRevisionRequest, "typeName", "yorkie.v1.RestoreRevisionRequest");
8221
+ __publicField(_RestoreRevisionRequest, "fields", proto3.util.newFieldList(() => [
8222
+ {
8223
+ no: 1,
8224
+ name: "client_id",
8225
+ kind: "scalar",
8226
+ T: 9
8227
+ /* ScalarType.STRING */
8228
+ },
8229
+ {
8230
+ no: 2,
8231
+ name: "revision_id",
8232
+ kind: "scalar",
8233
+ T: 9
8234
+ /* ScalarType.STRING */
8235
+ }
8236
+ ]));
8237
+ let RestoreRevisionRequest = _RestoreRevisionRequest;
8238
+ const _RestoreRevisionResponse = class _RestoreRevisionResponse extends Message {
8239
+ constructor(data) {
8240
+ super();
8241
+ proto3.util.initPartial(data, this);
8242
+ }
8243
+ static fromBinary(bytes, options) {
8244
+ return new _RestoreRevisionResponse().fromBinary(bytes, options);
8245
+ }
8246
+ static fromJson(jsonValue, options) {
8247
+ return new _RestoreRevisionResponse().fromJson(jsonValue, options);
8248
+ }
8249
+ static fromJsonString(jsonString, options) {
8250
+ return new _RestoreRevisionResponse().fromJsonString(jsonString, options);
8251
+ }
8252
+ static equals(a, b) {
8253
+ return proto3.util.equals(_RestoreRevisionResponse, a, b);
8254
+ }
8255
+ };
8256
+ __publicField(_RestoreRevisionResponse, "runtime", proto3);
8257
+ __publicField(_RestoreRevisionResponse, "typeName", "yorkie.v1.RestoreRevisionResponse");
8258
+ __publicField(_RestoreRevisionResponse, "fields", proto3.util.newFieldList(() => []));
8259
+ let RestoreRevisionResponse = _RestoreRevisionResponse;
7859
8260
  const _AttachChannelRequest = class _AttachChannelRequest extends Message {
7860
8261
  constructor(data) {
7861
8262
  super();
@@ -8400,6 +8801,33 @@ const YorkieService = {
8400
8801
  O: WatchDocumentResponse,
8401
8802
  kind: MethodKind.ServerStreaming
8402
8803
  },
8804
+ /**
8805
+ * @generated from rpc yorkie.v1.YorkieService.CreateRevision
8806
+ */
8807
+ createRevision: {
8808
+ name: "CreateRevision",
8809
+ I: CreateRevisionRequest,
8810
+ O: CreateRevisionResponse,
8811
+ kind: MethodKind.Unary
8812
+ },
8813
+ /**
8814
+ * @generated from rpc yorkie.v1.YorkieService.ListRevisions
8815
+ */
8816
+ listRevisions: {
8817
+ name: "ListRevisions",
8818
+ I: ListRevisionsRequest,
8819
+ O: ListRevisionsResponse,
8820
+ kind: MethodKind.Unary
8821
+ },
8822
+ /**
8823
+ * @generated from rpc yorkie.v1.YorkieService.RestoreRevision
8824
+ */
8825
+ restoreRevision: {
8826
+ name: "RestoreRevision",
8827
+ I: RestoreRevisionRequest,
8828
+ O: RestoreRevisionResponse,
8829
+ kind: MethodKind.Unary
8830
+ },
8403
8831
  /**
8404
8832
  * @generated from rpc yorkie.v1.YorkieService.AttachChannel
8405
8833
  */
@@ -17605,6 +18033,16 @@ function toChangePack(pack) {
17605
18033
  versionVector: toVersionVector(pack.getVersionVector())
17606
18034
  });
17607
18035
  }
18036
+ function toRevisionSummary(pbRevision) {
18037
+ var _a2;
18038
+ return {
18039
+ id: pbRevision.id,
18040
+ label: pbRevision.label,
18041
+ description: pbRevision.description,
18042
+ snapshot: pbRevision.snapshot,
18043
+ createdAt: ((_a2 = pbRevision.createdAt) == null ? void 0 : _a2.toDate()) || /* @__PURE__ */ new Date()
18044
+ };
18045
+ }
17608
18046
  function errorMetadataOf(error) {
17609
18047
  if (!(error instanceof ConnectError)) {
17610
18048
  return {};
@@ -18234,7 +18672,8 @@ const converter = {
18234
18672
  bytesToOperation,
18235
18673
  versionVectorToHex,
18236
18674
  hexToVersionVector,
18237
- fromSchemaRules
18675
+ fromSchemaRules,
18676
+ toRevisionSummary
18238
18677
  };
18239
18678
  var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
18240
18679
  LogLevel2[LogLevel2["Trivial"] = 0] = "Trivial";
@@ -22272,7 +22711,7 @@ function createAuthInterceptor(apiKey, token) {
22272
22711
  };
22273
22712
  }
22274
22713
  const name = "@yorkie-js/sdk";
22275
- const version = "0.6.39";
22714
+ const version = "0.6.40";
22276
22715
  const pkg = {
22277
22716
  name,
22278
22717
  version
@@ -23130,6 +23569,131 @@ class Client {
23130
23569
  getCondition(condition) {
23131
23570
  return this.conditions[condition];
23132
23571
  }
23572
+ /**
23573
+ * `createRevision` creates a new revision for the given document.
23574
+ */
23575
+ async createRevision(doc, label, description) {
23576
+ if (!this.isActive()) {
23577
+ throw new YorkieError(
23578
+ Code.ErrClientNotActivated,
23579
+ `${this.key} is not active`
23580
+ );
23581
+ }
23582
+ const attachment = this.attachmentMap.get(doc.getKey());
23583
+ if (!attachment) {
23584
+ throw new YorkieError(
23585
+ Code.ErrNotAttached,
23586
+ `${doc.getKey()} is not attached`
23587
+ );
23588
+ }
23589
+ const task = async () => {
23590
+ try {
23591
+ const res = await this.rpcClient.createRevision(
23592
+ {
23593
+ clientId: this.id,
23594
+ documentId: attachment.resourceID,
23595
+ label,
23596
+ description: description || ""
23597
+ },
23598
+ { headers: { "x-shard-key": `${this.apiKey}/${doc.getKey()}` } }
23599
+ );
23600
+ if (!res.revision) {
23601
+ throw new YorkieError(
23602
+ Code.ErrInvalidArgument,
23603
+ "revision is not returned"
23604
+ );
23605
+ }
23606
+ logger.info(
23607
+ `[CR] c:"${this.getKey()}" creates revision d:"${doc.getKey()}" l:"${label}"`
23608
+ );
23609
+ return converter.toRevisionSummary(res.revision);
23610
+ } catch (err) {
23611
+ logger.error(`[CR] c:"${this.getKey()}" err :`, err);
23612
+ await this.handleConnectError(err);
23613
+ throw err;
23614
+ }
23615
+ };
23616
+ return this.enqueueTask(task);
23617
+ }
23618
+ /**
23619
+ * `listRevisions` lists all revisions for the given document.
23620
+ */
23621
+ async listRevisions(doc, options) {
23622
+ if (!this.isActive()) {
23623
+ throw new YorkieError(
23624
+ Code.ErrClientNotActivated,
23625
+ `${this.key} is not active`
23626
+ );
23627
+ }
23628
+ const attachment = this.attachmentMap.get(doc.getKey());
23629
+ if (!attachment) {
23630
+ throw new YorkieError(
23631
+ Code.ErrNotAttached,
23632
+ `${doc.getKey()} is not attached`
23633
+ );
23634
+ }
23635
+ const task = async () => {
23636
+ try {
23637
+ const res = await this.rpcClient.listRevisions(
23638
+ {
23639
+ projectId: "",
23640
+ // Will be filled by server from auth context
23641
+ documentId: attachment.resourceID,
23642
+ pageSize: (options == null ? void 0 : options.pageSize) || 10,
23643
+ offset: (options == null ? void 0 : options.offset) || 0,
23644
+ isForward: (options == null ? void 0 : options.isForward) ?? false
23645
+ },
23646
+ { headers: { "x-shard-key": `${this.apiKey}/${doc.getKey()}` } }
23647
+ );
23648
+ logger.info(
23649
+ `[LR] c:"${this.getKey()}" lists revisions d:"${doc.getKey()}" count:${res.revisions.length}`
23650
+ );
23651
+ return res.revisions.map(converter.toRevisionSummary);
23652
+ } catch (err) {
23653
+ logger.error(`[LR] c:"${this.getKey()}" err :`, err);
23654
+ await this.handleConnectError(err);
23655
+ throw err;
23656
+ }
23657
+ };
23658
+ return this.enqueueTask(task);
23659
+ }
23660
+ /**
23661
+ * `restoreRevision` restores the document to the given revision.
23662
+ */
23663
+ async restoreRevision(doc, revisionId) {
23664
+ if (!this.isActive()) {
23665
+ throw new YorkieError(
23666
+ Code.ErrClientNotActivated,
23667
+ `${this.key} is not active`
23668
+ );
23669
+ }
23670
+ const attachment = this.attachmentMap.get(doc.getKey());
23671
+ if (!attachment) {
23672
+ throw new YorkieError(
23673
+ Code.ErrNotAttached,
23674
+ `${doc.getKey()} is not attached`
23675
+ );
23676
+ }
23677
+ const task = async () => {
23678
+ try {
23679
+ await this.rpcClient.restoreRevision(
23680
+ {
23681
+ clientId: this.id,
23682
+ revisionId
23683
+ },
23684
+ { headers: { "x-shard-key": `${this.apiKey}/${doc.getKey()}` } }
23685
+ );
23686
+ logger.info(
23687
+ `[RR] c:"${this.getKey()}" restores revision d:"${doc.getKey()}" r:"${revisionId}"`
23688
+ );
23689
+ } catch (err) {
23690
+ logger.error(`[RR] c:"${this.getKey()}" err :`, err);
23691
+ await this.handleConnectError(err);
23692
+ throw err;
23693
+ }
23694
+ };
23695
+ return this.enqueueTask(task);
23696
+ }
23133
23697
  /**
23134
23698
  * `broadcast` broadcasts the given payload to the given topic.
23135
23699
  */