diff --git a/CHANGELOG.md b/CHANGELOG.md index 459f4f1bb..9c9886819 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,33 @@ and Yorkie JS SDK adheres to [Semantic Versioning](https://semver.org/spec/v2.0. ## [Unreleased] +## [0.5.3] - 2024-10-23 + +### Changed + +- Introducing version vector to solve GC problem by @JOOHOJANG in https://github.com/yorkie-team/yorkie-js-sdk/pull/899 + +## [0.5.2] - 2024-10-22 + +### Changed + +- Update target to ES2020 and replace Long with bigint by @hackerwins in https://github.com/yorkie-team/yorkie-js-sdk/pull/912 + +## [0.5.1] - 2024-10-15 + +### Added + +- Add configurable retry mechanism to broadcast interface by @gwbaik9717 in https://github.com/yorkie-team/yorkie-js-sdk/pull/901 + +### Changed + +- Ensure `find` and `indexOf` perform splay by @m4ushold in https://github.com/yorkie-team/yorkie-js-sdk/pull/904 +- Restrict presence object type to JSON serializable values by @gwbaik9717 in https://github.com/yorkie-team/yorkie-js-sdk/pull/898 + +### Fixed + +- Automate Linting with Husky and lint-staged to Prevent CI Failures by @gwbaik9717 in https://github.com/yorkie-team/yorkie-js-sdk/pull/896 + ## [0.5.0] - 2024-09-05 ### Added diff --git a/MAINTAINING.md b/MAINTAINING.md index f9a9acd3d..73e7c3fea 100644 --- a/MAINTAINING.md +++ b/MAINTAINING.md @@ -4,7 +4,7 @@ ### 1. Update the version number. -- Update `version` in [package.json](https://github.com/yorkie-team/yorkie-js-sdk/blob/main/package.json#L3). +- Update `version` in [package.json](https://github.com/yorkie-team/yorkie-js-sdk/blob/main/packages/sdk/package.json#L3). ### 2. Write changelog of this version in [CHANGELOG.md](https://github.com/yorkie-team/yorkie-js-sdk/blob/main/CHANGELOG.md). diff --git a/packages/sdk/buf.gen.yaml b/packages/sdk/buf.gen.yaml index be0eaeb96..a08aca642 100644 --- a/packages/sdk/buf.gen.yaml +++ b/packages/sdk/buf.gen.yaml @@ -4,9 +4,9 @@ plugins: out: . opt: - target=ts - - js_import_style=module + - import_extension=none - plugin: connect-es out: . opt: - target=ts - - js_import_style=module + - import_extension=none diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 76d1e1244..0cd9af350 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "yorkie-js-sdk", - "version": "0.5.0", + "version": "0.5.3", "description": "Yorkie JS SDK", "main": "./src/yorkie.ts", "publishConfig": { @@ -64,7 +64,7 @@ "vite": "^5.0.12", "vite-plugin-commonjs": "^0.10.1", "vite-plugin-dts": "^3.9.1", - "vite-tsconfig-paths": "^4.2.1", + "vite-tsconfig-paths": "^4.3.1", "vitest": "^0.34.5" }, "dependencies": { diff --git a/packages/sdk/src/api/converter.ts b/packages/sdk/src/api/converter.ts index 502ad34a5..3926bace0 100644 --- a/packages/sdk/src/api/converter.ts +++ b/packages/sdk/src/api/converter.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -import Long from 'long'; import { ConnectError } from '@connectrpc/connect'; import { ErrorInfo } from '@buf/googleapis_googleapis.bufbuild_es/google/rpc/error_details_pb'; import { Code, YorkieError } from '@yorkie-js-sdk/src/util/error'; @@ -45,6 +44,7 @@ import { RGATreeList } from '@yorkie-js-sdk/src/document/crdt/rga_tree_list'; import { CRDTElement } from '@yorkie-js-sdk/src/document/crdt/element'; import { CRDTObject } from '@yorkie-js-sdk/src/document/crdt/object'; import { CRDTArray } from '@yorkie-js-sdk/src/document/crdt/array'; +import { VersionVector } from '@yorkie-js-sdk/src/document/time/version_vector'; import { CRDTTreePos } from './../document/crdt/tree'; import { RGATreeSplit, @@ -79,6 +79,7 @@ import { TreeNodes as PbTreeNodes, TreePos as PbTreePos, TreeNodeID as PbTreeNodeID, + VersionVector as PbVersionVector, ValueType as PbValueType, JSONElement_Tree as PbJSONElement_Tree, JSONElement_Text as PbJSONElement_Text, @@ -149,7 +150,7 @@ function toPresenceChange( */ function toCheckpoint(checkpoint: Checkpoint): PbCheckpoint { return new PbCheckpoint({ - serverSeq: checkpoint.getServerSeqAsString(), + serverSeq: checkpoint.getServerSeq(), clientSeq: checkpoint.getClientSeq(), }); } @@ -160,8 +161,9 @@ function toCheckpoint(checkpoint: Checkpoint): PbCheckpoint { function toChangeID(changeID: ChangeID): PbChangeID { return new PbChangeID({ clientSeq: changeID.getClientSeq(), - lamport: changeID.getLamportAsString(), + lamport: changeID.getLamport(), actorId: toUint8Array(changeID.getActorID()), + versionVector: toVersionVector(changeID.getVersionVector()), }); } @@ -174,12 +176,27 @@ function toTimeTicket(ticket?: TimeTicket): PbTimeTicket | undefined { } return new PbTimeTicket({ - lamport: ticket.getLamportAsString(), + lamport: ticket.getLamport(), delimiter: ticket.getDelimiter(), actorId: toUint8Array(ticket.getActorID()), }); } +/** + * `toVersionVector` converts the given model to Protobuf format. + */ +function toVersionVector(vector?: VersionVector): PbVersionVector | undefined { + if (!vector) { + return; + } + + const pbVector = new PbVersionVector(); + for (const [actorID, lamport] of vector) { + pbVector.vector[actorID] = BigInt(lamport.toString()); + } + return pbVector; +} + /** * `toValueType` converts the given model to Protobuf format. */ @@ -781,6 +798,7 @@ function toChangePack(pack: ChangePack): PbChangePack { isRemoved: pack.getIsRemoved(), changes: toChanges(pack.getChanges()), snapshot: pack.getSnapshot(), + versionVector: toVersionVector(pack.getVersionVector()), minSyncedTicket: toTimeTicket(pack.getMinSyncedTicket()), }); } @@ -817,19 +835,34 @@ export function errorMetadataOf(error: ConnectError): Record { * `fromChangeID` converts the given Protobuf format to model format. */ function fromChangeID(pbChangeID: PbChangeID): ChangeID { - let serverSeq: Long | undefined; - if (pbChangeID.serverSeq) { - serverSeq = Long.fromString(pbChangeID.serverSeq, true); - } - + // TODO(hackerwins): Remove BigInt conversion. Some of the bigint values are + // passed as string in the protobuf. We should fix this in the future. return ChangeID.of( pbChangeID.clientSeq, - Long.fromString(pbChangeID.lamport, true), + BigInt(pbChangeID.lamport), toHexString(pbChangeID.actorId), - serverSeq, + fromVersionVector(pbChangeID.versionVector)!, + BigInt(pbChangeID.serverSeq), ); } +/** + * `fromVersionVector` converts the given Protobuf format to model format. + */ +function fromVersionVector( + pbVersionVector?: PbVersionVector, +): VersionVector | undefined { + if (!pbVersionVector) { + return; + } + + const vector = new VersionVector(); + Object.entries(pbVersionVector.vector).forEach(([key, value]) => { + vector.set(key, BigInt(value.toString())); + }); + return vector; +} + /** * `fromTimeTicket` converts the given Protobuf format to model format. */ @@ -839,7 +872,7 @@ function fromTimeTicket(pbTimeTicket?: PbTimeTicket): TimeTicket | undefined { } return TimeTicket.of( - Long.fromString(pbTimeTicket.lamport, true), + BigInt(pbTimeTicket.lamport), pbTimeTicket.delimiter, toHexString(pbTimeTicket.actorId), ); @@ -1326,10 +1359,7 @@ function fromChanges

( * `fromCheckpoint` converts the given Protobuf format to model format. */ function fromCheckpoint(pbCheckpoint: PbCheckpoint): Checkpoint { - return Checkpoint.of( - Long.fromString(pbCheckpoint.serverSeq, true), - pbCheckpoint.clientSeq, - ); + return Checkpoint.of(BigInt(pbCheckpoint.serverSeq), pbCheckpoint.clientSeq); } /** @@ -1343,6 +1373,7 @@ function fromChangePack

( fromCheckpoint(pbPack.checkpoint!), pbPack.isRemoved, fromChanges(pbPack.changes), + fromVersionVector(pbPack.versionVector), pbPack.snapshot, fromTimeTicket(pbPack.minSyncedTicket), ); @@ -1489,6 +1520,25 @@ function bytesToSnapshot

( }; } +/** + * `versionVectorToHex` converts the given VersionVector to bytes. + */ +function versionVectorToHex(vector: VersionVector): string { + const pbVersionVector = toVersionVector(vector)!; + + return bytesToHex(pbVersionVector.toBinary()); +} + +/** + * `hexToVersionVector` creates a VersionVector from the given bytes. + */ +function hexToVersionVector(hex: string): VersionVector { + const bytes = hexToBytes(hex); + const pbVersionVector = PbVersionVector.fromBinary(bytes); + + return fromVersionVector(pbVersionVector)!; +} + /** * `bytesToObject` creates an JSONObject from the given byte array. */ @@ -1621,4 +1671,6 @@ export const converter = { PbChangeID, bytesToChangeID, bytesToOperation, + versionVectorToHex, + hexToVersionVector, }; diff --git a/packages/sdk/src/api/yorkie/v1/resources.proto b/packages/sdk/src/api/yorkie/v1/resources.proto index d1a8c3776..547ec6c55 100644 --- a/packages/sdk/src/api/yorkie/v1/resources.proto +++ b/packages/sdk/src/api/yorkie/v1/resources.proto @@ -46,6 +46,7 @@ message ChangePack { repeated Change changes = 4; TimeTicket min_synced_ticket = 5; bool is_removed = 6; + VersionVector version_vector = 7; } message Change { @@ -57,9 +58,14 @@ message Change { message ChangeID { uint32 client_seq = 1; - int64 server_seq = 2 [jstype = JS_STRING]; - int64 lamport = 3 [jstype = JS_STRING]; + int64 server_seq = 2; + int64 lamport = 3; bytes actor_id = 4; + VersionVector version_vector = 5; +} + +message VersionVector { + map vector = 1; } message Operation { @@ -136,6 +142,12 @@ message Operation { repeated string attributes_to_remove = 6; map created_at_map_by_actor = 7; } + message ArraySet { + TimeTicket parent_created_at = 1; + TimeTicket created_at = 2; + JSONElementSimple value = 3; + TimeTicket executed_at = 4; + } oneof body { Set set = 1; @@ -148,6 +160,7 @@ message Operation { Increase increase = 8; TreeEdit tree_edit = 9; TreeStyle tree_style = 10; + ArraySet array_set = 11; } } @@ -325,7 +338,7 @@ message Presence { } message Checkpoint { - int64 server_seq = 1 [jstype = JS_STRING]; + int64 server_seq = 1; uint32 client_seq = 2; } @@ -336,7 +349,7 @@ message TextNodePos { } message TimeTicket { - int64 lamport = 1 [jstype = JS_STRING]; + int64 lamport = 1; uint32 delimiter = 2; bytes actor_id = 3; } diff --git a/packages/sdk/src/api/yorkie/v1/resources_pb.d.ts b/packages/sdk/src/api/yorkie/v1/resources_pb.d.ts deleted file mode 100644 index 7d77073f6..000000000 --- a/packages/sdk/src/api/yorkie/v1/resources_pb.d.ts +++ /dev/null @@ -1,1912 +0,0 @@ -// -// Copyright 2022 The Yorkie Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// @generated by protoc-gen-es v1.6.0 with parameter "target=js+dts,js_import_style=module" -// @generated from file src/api/yorkie/v1/resources.proto (package yorkie.v1, syntax proto3) -/* eslint-disable */ -// @ts-nocheck - -import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage, Timestamp } from "@bufbuild/protobuf"; -import { Message, proto3 } from "@bufbuild/protobuf"; - -/** - * @generated from enum yorkie.v1.ValueType - */ -export declare enum ValueType { - /** - * @generated from enum value: VALUE_TYPE_NULL = 0; - */ - NULL = 0, - - /** - * @generated from enum value: VALUE_TYPE_BOOLEAN = 1; - */ - BOOLEAN = 1, - - /** - * @generated from enum value: VALUE_TYPE_INTEGER = 2; - */ - INTEGER = 2, - - /** - * @generated from enum value: VALUE_TYPE_LONG = 3; - */ - LONG = 3, - - /** - * @generated from enum value: VALUE_TYPE_DOUBLE = 4; - */ - DOUBLE = 4, - - /** - * @generated from enum value: VALUE_TYPE_STRING = 5; - */ - STRING = 5, - - /** - * @generated from enum value: VALUE_TYPE_BYTES = 6; - */ - BYTES = 6, - - /** - * @generated from enum value: VALUE_TYPE_DATE = 7; - */ - DATE = 7, - - /** - * @generated from enum value: VALUE_TYPE_JSON_OBJECT = 8; - */ - JSON_OBJECT = 8, - - /** - * @generated from enum value: VALUE_TYPE_JSON_ARRAY = 9; - */ - JSON_ARRAY = 9, - - /** - * @generated from enum value: VALUE_TYPE_TEXT = 10; - */ - TEXT = 10, - - /** - * @generated from enum value: VALUE_TYPE_INTEGER_CNT = 11; - */ - INTEGER_CNT = 11, - - /** - * @generated from enum value: VALUE_TYPE_LONG_CNT = 12; - */ - LONG_CNT = 12, - - /** - * @generated from enum value: VALUE_TYPE_TREE = 13; - */ - TREE = 13, -} - -/** - * @generated from enum yorkie.v1.DocEventType - */ -export declare enum DocEventType { - /** - * @generated from enum value: DOC_EVENT_TYPE_DOCUMENT_CHANGED = 0; - */ - DOCUMENT_CHANGED = 0, - - /** - * @generated from enum value: DOC_EVENT_TYPE_DOCUMENT_WATCHED = 1; - */ - DOCUMENT_WATCHED = 1, - - /** - * @generated from enum value: DOC_EVENT_TYPE_DOCUMENT_UNWATCHED = 2; - */ - DOCUMENT_UNWATCHED = 2, - - /** - * @generated from enum value: DOC_EVENT_TYPE_DOCUMENT_BROADCAST = 3; - */ - DOCUMENT_BROADCAST = 3, -} - -/** - * /////////////////////////////////////// - * Messages for Snapshot // - * /////////////////////////////////////// - * - * @generated from message yorkie.v1.Snapshot - */ -export declare class Snapshot extends Message { - /** - * @generated from field: yorkie.v1.JSONElement root = 1; - */ - root?: JSONElement; - - /** - * @generated from field: map presences = 2; - */ - presences: { [key: string]: Presence }; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.Snapshot"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): Snapshot; - - static fromJson(jsonValue: JsonValue, options?: Partial): Snapshot; - - static fromJsonString(jsonString: string, options?: Partial): Snapshot; - - static equals(a: Snapshot | PlainMessage | undefined, b: Snapshot | PlainMessage | undefined): boolean; -} - -/** - * ChangePack is a message that contains all changes that occurred in a document. - * It is used to synchronize changes between clients and servers. - * - * @generated from message yorkie.v1.ChangePack - */ -export declare class ChangePack extends Message { - /** - * @generated from field: string document_key = 1; - */ - documentKey: string; - - /** - * @generated from field: yorkie.v1.Checkpoint checkpoint = 2; - */ - checkpoint?: Checkpoint; - - /** - * @generated from field: bytes snapshot = 3; - */ - snapshot: Uint8Array; - - /** - * @generated from field: repeated yorkie.v1.Change changes = 4; - */ - changes: Change[]; - - /** - * @generated from field: yorkie.v1.TimeTicket min_synced_ticket = 5; - */ - minSyncedTicket?: TimeTicket; - - /** - * @generated from field: bool is_removed = 6; - */ - isRemoved: boolean; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.ChangePack"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): ChangePack; - - static fromJson(jsonValue: JsonValue, options?: Partial): ChangePack; - - static fromJsonString(jsonString: string, options?: Partial): ChangePack; - - static equals(a: ChangePack | PlainMessage | undefined, b: ChangePack | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.Change - */ -export declare class Change extends Message { - /** - * @generated from field: yorkie.v1.ChangeID id = 1; - */ - id?: ChangeID; - - /** - * @generated from field: string message = 2; - */ - message: string; - - /** - * @generated from field: repeated yorkie.v1.Operation operations = 3; - */ - operations: Operation[]; - - /** - * @generated from field: yorkie.v1.PresenceChange presence_change = 4; - */ - presenceChange?: PresenceChange; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.Change"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): Change; - - static fromJson(jsonValue: JsonValue, options?: Partial): Change; - - static fromJsonString(jsonString: string, options?: Partial): Change; - - static equals(a: Change | PlainMessage | undefined, b: Change | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.ChangeID - */ -export declare class ChangeID extends Message { - /** - * @generated from field: uint32 client_seq = 1; - */ - clientSeq: number; - - /** - * @generated from field: int64 server_seq = 2 [jstype = JS_STRING]; - */ - serverSeq: string; - - /** - * @generated from field: int64 lamport = 3 [jstype = JS_STRING]; - */ - lamport: string; - - /** - * @generated from field: bytes actor_id = 4; - */ - actorId: Uint8Array; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.ChangeID"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): ChangeID; - - static fromJson(jsonValue: JsonValue, options?: Partial): ChangeID; - - static fromJsonString(jsonString: string, options?: Partial): ChangeID; - - static equals(a: ChangeID | PlainMessage | undefined, b: ChangeID | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.Operation - */ -export declare class Operation extends Message { - /** - * @generated from oneof yorkie.v1.Operation.body - */ - body: { - /** - * @generated from field: yorkie.v1.Operation.Set set = 1; - */ - value: Operation_Set; - case: "set"; - } | { - /** - * @generated from field: yorkie.v1.Operation.Add add = 2; - */ - value: Operation_Add; - case: "add"; - } | { - /** - * @generated from field: yorkie.v1.Operation.Move move = 3; - */ - value: Operation_Move; - case: "move"; - } | { - /** - * @generated from field: yorkie.v1.Operation.Remove remove = 4; - */ - value: Operation_Remove; - case: "remove"; - } | { - /** - * @generated from field: yorkie.v1.Operation.Edit edit = 5; - */ - value: Operation_Edit; - case: "edit"; - } | { - /** - * @generated from field: yorkie.v1.Operation.Select select = 6; - */ - value: Operation_Select; - case: "select"; - } | { - /** - * @generated from field: yorkie.v1.Operation.Style style = 7; - */ - value: Operation_Style; - case: "style"; - } | { - /** - * @generated from field: yorkie.v1.Operation.Increase increase = 8; - */ - value: Operation_Increase; - case: "increase"; - } | { - /** - * @generated from field: yorkie.v1.Operation.TreeEdit tree_edit = 9; - */ - value: Operation_TreeEdit; - case: "treeEdit"; - } | { - /** - * @generated from field: yorkie.v1.Operation.TreeStyle tree_style = 10; - */ - value: Operation_TreeStyle; - case: "treeStyle"; - } | { case: undefined; value?: undefined }; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.Operation"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): Operation; - - static fromJson(jsonValue: JsonValue, options?: Partial): Operation; - - static fromJsonString(jsonString: string, options?: Partial): Operation; - - static equals(a: Operation | PlainMessage | undefined, b: Operation | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.Operation.Set - */ -export declare class Operation_Set extends Message { - /** - * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1; - */ - parentCreatedAt?: TimeTicket; - - /** - * @generated from field: string key = 2; - */ - key: string; - - /** - * @generated from field: yorkie.v1.JSONElementSimple value = 3; - */ - value?: JSONElementSimple; - - /** - * @generated from field: yorkie.v1.TimeTicket executed_at = 4; - */ - executedAt?: TimeTicket; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.Operation.Set"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): Operation_Set; - - static fromJson(jsonValue: JsonValue, options?: Partial): Operation_Set; - - static fromJsonString(jsonString: string, options?: Partial): Operation_Set; - - static equals(a: Operation_Set | PlainMessage | undefined, b: Operation_Set | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.Operation.Add - */ -export declare class Operation_Add extends Message { - /** - * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1; - */ - parentCreatedAt?: TimeTicket; - - /** - * @generated from field: yorkie.v1.TimeTicket prev_created_at = 2; - */ - prevCreatedAt?: TimeTicket; - - /** - * @generated from field: yorkie.v1.JSONElementSimple value = 3; - */ - value?: JSONElementSimple; - - /** - * @generated from field: yorkie.v1.TimeTicket executed_at = 4; - */ - executedAt?: TimeTicket; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.Operation.Add"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): Operation_Add; - - static fromJson(jsonValue: JsonValue, options?: Partial): Operation_Add; - - static fromJsonString(jsonString: string, options?: Partial): Operation_Add; - - static equals(a: Operation_Add | PlainMessage | undefined, b: Operation_Add | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.Operation.Move - */ -export declare class Operation_Move extends Message { - /** - * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1; - */ - parentCreatedAt?: TimeTicket; - - /** - * @generated from field: yorkie.v1.TimeTicket prev_created_at = 2; - */ - prevCreatedAt?: TimeTicket; - - /** - * @generated from field: yorkie.v1.TimeTicket created_at = 3; - */ - createdAt?: TimeTicket; - - /** - * @generated from field: yorkie.v1.TimeTicket executed_at = 4; - */ - executedAt?: TimeTicket; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.Operation.Move"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): Operation_Move; - - static fromJson(jsonValue: JsonValue, options?: Partial): Operation_Move; - - static fromJsonString(jsonString: string, options?: Partial): Operation_Move; - - static equals(a: Operation_Move | PlainMessage | undefined, b: Operation_Move | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.Operation.Remove - */ -export declare class Operation_Remove extends Message { - /** - * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1; - */ - parentCreatedAt?: TimeTicket; - - /** - * @generated from field: yorkie.v1.TimeTicket created_at = 2; - */ - createdAt?: TimeTicket; - - /** - * @generated from field: yorkie.v1.TimeTicket executed_at = 3; - */ - executedAt?: TimeTicket; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.Operation.Remove"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): Operation_Remove; - - static fromJson(jsonValue: JsonValue, options?: Partial): Operation_Remove; - - static fromJsonString(jsonString: string, options?: Partial): Operation_Remove; - - static equals(a: Operation_Remove | PlainMessage | undefined, b: Operation_Remove | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.Operation.Edit - */ -export declare class Operation_Edit extends Message { - /** - * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1; - */ - parentCreatedAt?: TimeTicket; - - /** - * @generated from field: yorkie.v1.TextNodePos from = 2; - */ - from?: TextNodePos; - - /** - * @generated from field: yorkie.v1.TextNodePos to = 3; - */ - to?: TextNodePos; - - /** - * @generated from field: map created_at_map_by_actor = 4; - */ - createdAtMapByActor: { [key: string]: TimeTicket }; - - /** - * @generated from field: string content = 5; - */ - content: string; - - /** - * @generated from field: yorkie.v1.TimeTicket executed_at = 6; - */ - executedAt?: TimeTicket; - - /** - * @generated from field: map attributes = 7; - */ - attributes: { [key: string]: string }; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.Operation.Edit"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): Operation_Edit; - - static fromJson(jsonValue: JsonValue, options?: Partial): Operation_Edit; - - static fromJsonString(jsonString: string, options?: Partial): Operation_Edit; - - static equals(a: Operation_Edit | PlainMessage | undefined, b: Operation_Edit | PlainMessage | undefined): boolean; -} - -/** - * NOTE(hackerwins): Select Operation is not used in the current version. - * In the previous version, it was used to represent selection of Text. - * However, it has been replaced by Presence now. It is retained for backward - * compatibility purposes. - * - * @generated from message yorkie.v1.Operation.Select - */ -export declare class Operation_Select extends Message { - /** - * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1; - */ - parentCreatedAt?: TimeTicket; - - /** - * @generated from field: yorkie.v1.TextNodePos from = 2; - */ - from?: TextNodePos; - - /** - * @generated from field: yorkie.v1.TextNodePos to = 3; - */ - to?: TextNodePos; - - /** - * @generated from field: yorkie.v1.TimeTicket executed_at = 4; - */ - executedAt?: TimeTicket; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.Operation.Select"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): Operation_Select; - - static fromJson(jsonValue: JsonValue, options?: Partial): Operation_Select; - - static fromJsonString(jsonString: string, options?: Partial): Operation_Select; - - static equals(a: Operation_Select | PlainMessage | undefined, b: Operation_Select | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.Operation.Style - */ -export declare class Operation_Style extends Message { - /** - * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1; - */ - parentCreatedAt?: TimeTicket; - - /** - * @generated from field: yorkie.v1.TextNodePos from = 2; - */ - from?: TextNodePos; - - /** - * @generated from field: yorkie.v1.TextNodePos to = 3; - */ - to?: TextNodePos; - - /** - * @generated from field: map attributes = 4; - */ - attributes: { [key: string]: string }; - - /** - * @generated from field: yorkie.v1.TimeTicket executed_at = 5; - */ - executedAt?: TimeTicket; - - /** - * @generated from field: map created_at_map_by_actor = 6; - */ - createdAtMapByActor: { [key: string]: TimeTicket }; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.Operation.Style"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): Operation_Style; - - static fromJson(jsonValue: JsonValue, options?: Partial): Operation_Style; - - static fromJsonString(jsonString: string, options?: Partial): Operation_Style; - - static equals(a: Operation_Style | PlainMessage | undefined, b: Operation_Style | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.Operation.Increase - */ -export declare class Operation_Increase extends Message { - /** - * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1; - */ - parentCreatedAt?: TimeTicket; - - /** - * @generated from field: yorkie.v1.JSONElementSimple value = 2; - */ - value?: JSONElementSimple; - - /** - * @generated from field: yorkie.v1.TimeTicket executed_at = 3; - */ - executedAt?: TimeTicket; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.Operation.Increase"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): Operation_Increase; - - static fromJson(jsonValue: JsonValue, options?: Partial): Operation_Increase; - - static fromJsonString(jsonString: string, options?: Partial): Operation_Increase; - - static equals(a: Operation_Increase | PlainMessage | undefined, b: Operation_Increase | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.Operation.TreeEdit - */ -export declare class Operation_TreeEdit extends Message { - /** - * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1; - */ - parentCreatedAt?: TimeTicket; - - /** - * @generated from field: yorkie.v1.TreePos from = 2; - */ - from?: TreePos; - - /** - * @generated from field: yorkie.v1.TreePos to = 3; - */ - to?: TreePos; - - /** - * @generated from field: map created_at_map_by_actor = 4; - */ - createdAtMapByActor: { [key: string]: TimeTicket }; - - /** - * @generated from field: repeated yorkie.v1.TreeNodes contents = 5; - */ - contents: TreeNodes[]; - - /** - * @generated from field: int32 split_level = 7; - */ - splitLevel: number; - - /** - * @generated from field: yorkie.v1.TimeTicket executed_at = 6; - */ - executedAt?: TimeTicket; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.Operation.TreeEdit"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): Operation_TreeEdit; - - static fromJson(jsonValue: JsonValue, options?: Partial): Operation_TreeEdit; - - static fromJsonString(jsonString: string, options?: Partial): Operation_TreeEdit; - - static equals(a: Operation_TreeEdit | PlainMessage | undefined, b: Operation_TreeEdit | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.Operation.TreeStyle - */ -export declare class Operation_TreeStyle extends Message { - /** - * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1; - */ - parentCreatedAt?: TimeTicket; - - /** - * @generated from field: yorkie.v1.TreePos from = 2; - */ - from?: TreePos; - - /** - * @generated from field: yorkie.v1.TreePos to = 3; - */ - to?: TreePos; - - /** - * @generated from field: map attributes = 4; - */ - attributes: { [key: string]: string }; - - /** - * @generated from field: yorkie.v1.TimeTicket executed_at = 5; - */ - executedAt?: TimeTicket; - - /** - * @generated from field: repeated string attributes_to_remove = 6; - */ - attributesToRemove: string[]; - - /** - * @generated from field: map created_at_map_by_actor = 7; - */ - createdAtMapByActor: { [key: string]: TimeTicket }; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.Operation.TreeStyle"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): Operation_TreeStyle; - - static fromJson(jsonValue: JsonValue, options?: Partial): Operation_TreeStyle; - - static fromJsonString(jsonString: string, options?: Partial): Operation_TreeStyle; - - static equals(a: Operation_TreeStyle | PlainMessage | undefined, b: Operation_TreeStyle | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.JSONElementSimple - */ -export declare class JSONElementSimple extends Message { - /** - * @generated from field: yorkie.v1.TimeTicket created_at = 1; - */ - createdAt?: TimeTicket; - - /** - * @generated from field: yorkie.v1.TimeTicket moved_at = 2; - */ - movedAt?: TimeTicket; - - /** - * @generated from field: yorkie.v1.TimeTicket removed_at = 3; - */ - removedAt?: TimeTicket; - - /** - * @generated from field: yorkie.v1.ValueType type = 4; - */ - type: ValueType; - - /** - * @generated from field: bytes value = 5; - */ - value: Uint8Array; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.JSONElementSimple"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): JSONElementSimple; - - static fromJson(jsonValue: JsonValue, options?: Partial): JSONElementSimple; - - static fromJsonString(jsonString: string, options?: Partial): JSONElementSimple; - - static equals(a: JSONElementSimple | PlainMessage | undefined, b: JSONElementSimple | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.JSONElement - */ -export declare class JSONElement extends Message { - /** - * @generated from oneof yorkie.v1.JSONElement.body - */ - body: { - /** - * @generated from field: yorkie.v1.JSONElement.JSONObject json_object = 1; - */ - value: JSONElement_JSONObject; - case: "jsonObject"; - } | { - /** - * @generated from field: yorkie.v1.JSONElement.JSONArray json_array = 2; - */ - value: JSONElement_JSONArray; - case: "jsonArray"; - } | { - /** - * @generated from field: yorkie.v1.JSONElement.Primitive primitive = 3; - */ - value: JSONElement_Primitive; - case: "primitive"; - } | { - /** - * @generated from field: yorkie.v1.JSONElement.Text text = 5; - */ - value: JSONElement_Text; - case: "text"; - } | { - /** - * @generated from field: yorkie.v1.JSONElement.Counter counter = 6; - */ - value: JSONElement_Counter; - case: "counter"; - } | { - /** - * @generated from field: yorkie.v1.JSONElement.Tree tree = 7; - */ - value: JSONElement_Tree; - case: "tree"; - } | { case: undefined; value?: undefined }; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.JSONElement"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): JSONElement; - - static fromJson(jsonValue: JsonValue, options?: Partial): JSONElement; - - static fromJsonString(jsonString: string, options?: Partial): JSONElement; - - static equals(a: JSONElement | PlainMessage | undefined, b: JSONElement | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.JSONElement.JSONObject - */ -export declare class JSONElement_JSONObject extends Message { - /** - * @generated from field: repeated yorkie.v1.RHTNode nodes = 1; - */ - nodes: RHTNode[]; - - /** - * @generated from field: yorkie.v1.TimeTicket created_at = 2; - */ - createdAt?: TimeTicket; - - /** - * @generated from field: yorkie.v1.TimeTicket moved_at = 3; - */ - movedAt?: TimeTicket; - - /** - * @generated from field: yorkie.v1.TimeTicket removed_at = 4; - */ - removedAt?: TimeTicket; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.JSONElement.JSONObject"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): JSONElement_JSONObject; - - static fromJson(jsonValue: JsonValue, options?: Partial): JSONElement_JSONObject; - - static fromJsonString(jsonString: string, options?: Partial): JSONElement_JSONObject; - - static equals(a: JSONElement_JSONObject | PlainMessage | undefined, b: JSONElement_JSONObject | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.JSONElement.JSONArray - */ -export declare class JSONElement_JSONArray extends Message { - /** - * @generated from field: repeated yorkie.v1.RGANode nodes = 1; - */ - nodes: RGANode[]; - - /** - * @generated from field: yorkie.v1.TimeTicket created_at = 2; - */ - createdAt?: TimeTicket; - - /** - * @generated from field: yorkie.v1.TimeTicket moved_at = 3; - */ - movedAt?: TimeTicket; - - /** - * @generated from field: yorkie.v1.TimeTicket removed_at = 4; - */ - removedAt?: TimeTicket; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.JSONElement.JSONArray"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): JSONElement_JSONArray; - - static fromJson(jsonValue: JsonValue, options?: Partial): JSONElement_JSONArray; - - static fromJsonString(jsonString: string, options?: Partial): JSONElement_JSONArray; - - static equals(a: JSONElement_JSONArray | PlainMessage | undefined, b: JSONElement_JSONArray | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.JSONElement.Primitive - */ -export declare class JSONElement_Primitive extends Message { - /** - * @generated from field: yorkie.v1.ValueType type = 1; - */ - type: ValueType; - - /** - * @generated from field: bytes value = 2; - */ - value: Uint8Array; - - /** - * @generated from field: yorkie.v1.TimeTicket created_at = 3; - */ - createdAt?: TimeTicket; - - /** - * @generated from field: yorkie.v1.TimeTicket moved_at = 4; - */ - movedAt?: TimeTicket; - - /** - * @generated from field: yorkie.v1.TimeTicket removed_at = 5; - */ - removedAt?: TimeTicket; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.JSONElement.Primitive"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): JSONElement_Primitive; - - static fromJson(jsonValue: JsonValue, options?: Partial): JSONElement_Primitive; - - static fromJsonString(jsonString: string, options?: Partial): JSONElement_Primitive; - - static equals(a: JSONElement_Primitive | PlainMessage | undefined, b: JSONElement_Primitive | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.JSONElement.Text - */ -export declare class JSONElement_Text extends Message { - /** - * @generated from field: repeated yorkie.v1.TextNode nodes = 1; - */ - nodes: TextNode[]; - - /** - * @generated from field: yorkie.v1.TimeTicket created_at = 2; - */ - createdAt?: TimeTicket; - - /** - * @generated from field: yorkie.v1.TimeTicket moved_at = 3; - */ - movedAt?: TimeTicket; - - /** - * @generated from field: yorkie.v1.TimeTicket removed_at = 4; - */ - removedAt?: TimeTicket; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.JSONElement.Text"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): JSONElement_Text; - - static fromJson(jsonValue: JsonValue, options?: Partial): JSONElement_Text; - - static fromJsonString(jsonString: string, options?: Partial): JSONElement_Text; - - static equals(a: JSONElement_Text | PlainMessage | undefined, b: JSONElement_Text | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.JSONElement.Counter - */ -export declare class JSONElement_Counter extends Message { - /** - * @generated from field: yorkie.v1.ValueType type = 1; - */ - type: ValueType; - - /** - * @generated from field: bytes value = 2; - */ - value: Uint8Array; - - /** - * @generated from field: yorkie.v1.TimeTicket created_at = 3; - */ - createdAt?: TimeTicket; - - /** - * @generated from field: yorkie.v1.TimeTicket moved_at = 4; - */ - movedAt?: TimeTicket; - - /** - * @generated from field: yorkie.v1.TimeTicket removed_at = 5; - */ - removedAt?: TimeTicket; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.JSONElement.Counter"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): JSONElement_Counter; - - static fromJson(jsonValue: JsonValue, options?: Partial): JSONElement_Counter; - - static fromJsonString(jsonString: string, options?: Partial): JSONElement_Counter; - - static equals(a: JSONElement_Counter | PlainMessage | undefined, b: JSONElement_Counter | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.JSONElement.Tree - */ -export declare class JSONElement_Tree extends Message { - /** - * @generated from field: repeated yorkie.v1.TreeNode nodes = 1; - */ - nodes: TreeNode[]; - - /** - * @generated from field: yorkie.v1.TimeTicket created_at = 2; - */ - createdAt?: TimeTicket; - - /** - * @generated from field: yorkie.v1.TimeTicket moved_at = 3; - */ - movedAt?: TimeTicket; - - /** - * @generated from field: yorkie.v1.TimeTicket removed_at = 4; - */ - removedAt?: TimeTicket; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.JSONElement.Tree"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): JSONElement_Tree; - - static fromJson(jsonValue: JsonValue, options?: Partial): JSONElement_Tree; - - static fromJsonString(jsonString: string, options?: Partial): JSONElement_Tree; - - static equals(a: JSONElement_Tree | PlainMessage | undefined, b: JSONElement_Tree | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.RHTNode - */ -export declare class RHTNode extends Message { - /** - * @generated from field: string key = 1; - */ - key: string; - - /** - * @generated from field: yorkie.v1.JSONElement element = 2; - */ - element?: JSONElement; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.RHTNode"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): RHTNode; - - static fromJson(jsonValue: JsonValue, options?: Partial): RHTNode; - - static fromJsonString(jsonString: string, options?: Partial): RHTNode; - - static equals(a: RHTNode | PlainMessage | undefined, b: RHTNode | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.RGANode - */ -export declare class RGANode extends Message { - /** - * @generated from field: yorkie.v1.RGANode next = 1; - */ - next?: RGANode; - - /** - * @generated from field: yorkie.v1.JSONElement element = 2; - */ - element?: JSONElement; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.RGANode"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): RGANode; - - static fromJson(jsonValue: JsonValue, options?: Partial): RGANode; - - static fromJsonString(jsonString: string, options?: Partial): RGANode; - - static equals(a: RGANode | PlainMessage | undefined, b: RGANode | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.NodeAttr - */ -export declare class NodeAttr extends Message { - /** - * @generated from field: string value = 1; - */ - value: string; - - /** - * @generated from field: yorkie.v1.TimeTicket updated_at = 2; - */ - updatedAt?: TimeTicket; - - /** - * @generated from field: bool is_removed = 3; - */ - isRemoved: boolean; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.NodeAttr"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): NodeAttr; - - static fromJson(jsonValue: JsonValue, options?: Partial): NodeAttr; - - static fromJsonString(jsonString: string, options?: Partial): NodeAttr; - - static equals(a: NodeAttr | PlainMessage | undefined, b: NodeAttr | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.TextNode - */ -export declare class TextNode extends Message { - /** - * @generated from field: yorkie.v1.TextNodeID id = 1; - */ - id?: TextNodeID; - - /** - * @generated from field: string value = 2; - */ - value: string; - - /** - * @generated from field: yorkie.v1.TimeTicket removed_at = 3; - */ - removedAt?: TimeTicket; - - /** - * @generated from field: yorkie.v1.TextNodeID ins_prev_id = 4; - */ - insPrevId?: TextNodeID; - - /** - * @generated from field: map attributes = 5; - */ - attributes: { [key: string]: NodeAttr }; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.TextNode"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): TextNode; - - static fromJson(jsonValue: JsonValue, options?: Partial): TextNode; - - static fromJsonString(jsonString: string, options?: Partial): TextNode; - - static equals(a: TextNode | PlainMessage | undefined, b: TextNode | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.TextNodeID - */ -export declare class TextNodeID extends Message { - /** - * @generated from field: yorkie.v1.TimeTicket created_at = 1; - */ - createdAt?: TimeTicket; - - /** - * @generated from field: int32 offset = 2; - */ - offset: number; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.TextNodeID"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): TextNodeID; - - static fromJson(jsonValue: JsonValue, options?: Partial): TextNodeID; - - static fromJsonString(jsonString: string, options?: Partial): TextNodeID; - - static equals(a: TextNodeID | PlainMessage | undefined, b: TextNodeID | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.TreeNode - */ -export declare class TreeNode extends Message { - /** - * @generated from field: yorkie.v1.TreeNodeID id = 1; - */ - id?: TreeNodeID; - - /** - * @generated from field: string type = 2; - */ - type: string; - - /** - * @generated from field: string value = 3; - */ - value: string; - - /** - * @generated from field: yorkie.v1.TimeTicket removed_at = 4; - */ - removedAt?: TimeTicket; - - /** - * @generated from field: yorkie.v1.TreeNodeID ins_prev_id = 5; - */ - insPrevId?: TreeNodeID; - - /** - * @generated from field: yorkie.v1.TreeNodeID ins_next_id = 6; - */ - insNextId?: TreeNodeID; - - /** - * @generated from field: int32 depth = 7; - */ - depth: number; - - /** - * @generated from field: map attributes = 8; - */ - attributes: { [key: string]: NodeAttr }; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.TreeNode"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): TreeNode; - - static fromJson(jsonValue: JsonValue, options?: Partial): TreeNode; - - static fromJsonString(jsonString: string, options?: Partial): TreeNode; - - static equals(a: TreeNode | PlainMessage | undefined, b: TreeNode | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.TreeNodes - */ -export declare class TreeNodes extends Message { - /** - * @generated from field: repeated yorkie.v1.TreeNode content = 1; - */ - content: TreeNode[]; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.TreeNodes"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): TreeNodes; - - static fromJson(jsonValue: JsonValue, options?: Partial): TreeNodes; - - static fromJsonString(jsonString: string, options?: Partial): TreeNodes; - - static equals(a: TreeNodes | PlainMessage | undefined, b: TreeNodes | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.TreeNodeID - */ -export declare class TreeNodeID extends Message { - /** - * @generated from field: yorkie.v1.TimeTicket created_at = 1; - */ - createdAt?: TimeTicket; - - /** - * @generated from field: int32 offset = 2; - */ - offset: number; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.TreeNodeID"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): TreeNodeID; - - static fromJson(jsonValue: JsonValue, options?: Partial): TreeNodeID; - - static fromJsonString(jsonString: string, options?: Partial): TreeNodeID; - - static equals(a: TreeNodeID | PlainMessage | undefined, b: TreeNodeID | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.TreePos - */ -export declare class TreePos extends Message { - /** - * @generated from field: yorkie.v1.TreeNodeID parent_id = 1; - */ - parentId?: TreeNodeID; - - /** - * @generated from field: yorkie.v1.TreeNodeID left_sibling_id = 2; - */ - leftSiblingId?: TreeNodeID; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.TreePos"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): TreePos; - - static fromJson(jsonValue: JsonValue, options?: Partial): TreePos; - - static fromJsonString(jsonString: string, options?: Partial): TreePos; - - static equals(a: TreePos | PlainMessage | undefined, b: TreePos | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.User - */ -export declare class User extends Message { - /** - * @generated from field: string id = 1; - */ - id: string; - - /** - * @generated from field: string username = 2; - */ - username: string; - - /** - * @generated from field: google.protobuf.Timestamp created_at = 3; - */ - createdAt?: Timestamp; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.User"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): User; - - static fromJson(jsonValue: JsonValue, options?: Partial): User; - - static fromJsonString(jsonString: string, options?: Partial): User; - - static equals(a: User | PlainMessage | undefined, b: User | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.Project - */ -export declare class Project extends Message { - /** - * @generated from field: string id = 1; - */ - id: string; - - /** - * @generated from field: string name = 2; - */ - name: string; - - /** - * @generated from field: string public_key = 3; - */ - publicKey: string; - - /** - * @generated from field: string secret_key = 4; - */ - secretKey: string; - - /** - * @generated from field: string auth_webhook_url = 5; - */ - authWebhookUrl: string; - - /** - * @generated from field: repeated string auth_webhook_methods = 6; - */ - authWebhookMethods: string[]; - - /** - * @generated from field: string client_deactivate_threshold = 7; - */ - clientDeactivateThreshold: string; - - /** - * @generated from field: google.protobuf.Timestamp created_at = 8; - */ - createdAt?: Timestamp; - - /** - * @generated from field: google.protobuf.Timestamp updated_at = 9; - */ - updatedAt?: Timestamp; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.Project"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): Project; - - static fromJson(jsonValue: JsonValue, options?: Partial): Project; - - static fromJsonString(jsonString: string, options?: Partial): Project; - - static equals(a: Project | PlainMessage | undefined, b: Project | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.UpdatableProjectFields - */ -export declare class UpdatableProjectFields extends Message { - /** - * @generated from field: google.protobuf.StringValue name = 1; - */ - name?: string; - - /** - * @generated from field: google.protobuf.StringValue auth_webhook_url = 2; - */ - authWebhookUrl?: string; - - /** - * @generated from field: yorkie.v1.UpdatableProjectFields.AuthWebhookMethods auth_webhook_methods = 3; - */ - authWebhookMethods?: UpdatableProjectFields_AuthWebhookMethods; - - /** - * @generated from field: google.protobuf.StringValue client_deactivate_threshold = 4; - */ - clientDeactivateThreshold?: string; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.UpdatableProjectFields"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): UpdatableProjectFields; - - static fromJson(jsonValue: JsonValue, options?: Partial): UpdatableProjectFields; - - static fromJsonString(jsonString: string, options?: Partial): UpdatableProjectFields; - - static equals(a: UpdatableProjectFields | PlainMessage | undefined, b: UpdatableProjectFields | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.UpdatableProjectFields.AuthWebhookMethods - */ -export declare class UpdatableProjectFields_AuthWebhookMethods extends Message { - /** - * @generated from field: repeated string methods = 1; - */ - methods: string[]; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.UpdatableProjectFields.AuthWebhookMethods"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): UpdatableProjectFields_AuthWebhookMethods; - - static fromJson(jsonValue: JsonValue, options?: Partial): UpdatableProjectFields_AuthWebhookMethods; - - static fromJsonString(jsonString: string, options?: Partial): UpdatableProjectFields_AuthWebhookMethods; - - static equals(a: UpdatableProjectFields_AuthWebhookMethods | PlainMessage | undefined, b: UpdatableProjectFields_AuthWebhookMethods | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.DocumentSummary - */ -export declare class DocumentSummary extends Message { - /** - * @generated from field: string id = 1; - */ - id: string; - - /** - * @generated from field: string key = 2; - */ - key: string; - - /** - * @generated from field: string snapshot = 3; - */ - snapshot: string; - - /** - * @generated from field: google.protobuf.Timestamp created_at = 4; - */ - createdAt?: Timestamp; - - /** - * @generated from field: google.protobuf.Timestamp accessed_at = 5; - */ - accessedAt?: Timestamp; - - /** - * @generated from field: google.protobuf.Timestamp updated_at = 6; - */ - updatedAt?: Timestamp; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.DocumentSummary"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): DocumentSummary; - - static fromJson(jsonValue: JsonValue, options?: Partial): DocumentSummary; - - static fromJsonString(jsonString: string, options?: Partial): DocumentSummary; - - static equals(a: DocumentSummary | PlainMessage | undefined, b: DocumentSummary | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.PresenceChange - */ -export declare class PresenceChange extends Message { - /** - * @generated from field: yorkie.v1.PresenceChange.ChangeType type = 1; - */ - type: PresenceChange_ChangeType; - - /** - * @generated from field: yorkie.v1.Presence presence = 2; - */ - presence?: Presence; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.PresenceChange"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): PresenceChange; - - static fromJson(jsonValue: JsonValue, options?: Partial): PresenceChange; - - static fromJsonString(jsonString: string, options?: Partial): PresenceChange; - - static equals(a: PresenceChange | PlainMessage | undefined, b: PresenceChange | PlainMessage | undefined): boolean; -} - -/** - * @generated from enum yorkie.v1.PresenceChange.ChangeType - */ -export declare enum PresenceChange_ChangeType { - /** - * @generated from enum value: CHANGE_TYPE_UNSPECIFIED = 0; - */ - UNSPECIFIED = 0, - - /** - * @generated from enum value: CHANGE_TYPE_PUT = 1; - */ - PUT = 1, - - /** - * @generated from enum value: CHANGE_TYPE_DELETE = 2; - */ - DELETE = 2, - - /** - * @generated from enum value: CHANGE_TYPE_CLEAR = 3; - */ - CLEAR = 3, -} - -/** - * @generated from message yorkie.v1.Presence - */ -export declare class Presence extends Message { - /** - * @generated from field: map data = 1; - */ - data: { [key: string]: string }; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.Presence"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): Presence; - - static fromJson(jsonValue: JsonValue, options?: Partial): Presence; - - static fromJsonString(jsonString: string, options?: Partial): Presence; - - static equals(a: Presence | PlainMessage | undefined, b: Presence | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.Checkpoint - */ -export declare class Checkpoint extends Message { - /** - * @generated from field: int64 server_seq = 1 [jstype = JS_STRING]; - */ - serverSeq: string; - - /** - * @generated from field: uint32 client_seq = 2; - */ - clientSeq: number; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.Checkpoint"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): Checkpoint; - - static fromJson(jsonValue: JsonValue, options?: Partial): Checkpoint; - - static fromJsonString(jsonString: string, options?: Partial): Checkpoint; - - static equals(a: Checkpoint | PlainMessage | undefined, b: Checkpoint | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.TextNodePos - */ -export declare class TextNodePos extends Message { - /** - * @generated from field: yorkie.v1.TimeTicket created_at = 1; - */ - createdAt?: TimeTicket; - - /** - * @generated from field: int32 offset = 2; - */ - offset: number; - - /** - * @generated from field: int32 relative_offset = 3; - */ - relativeOffset: number; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.TextNodePos"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): TextNodePos; - - static fromJson(jsonValue: JsonValue, options?: Partial): TextNodePos; - - static fromJsonString(jsonString: string, options?: Partial): TextNodePos; - - static equals(a: TextNodePos | PlainMessage | undefined, b: TextNodePos | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.TimeTicket - */ -export declare class TimeTicket extends Message { - /** - * @generated from field: int64 lamport = 1 [jstype = JS_STRING]; - */ - lamport: string; - - /** - * @generated from field: uint32 delimiter = 2; - */ - delimiter: number; - - /** - * @generated from field: bytes actor_id = 3; - */ - actorId: Uint8Array; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.TimeTicket"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): TimeTicket; - - static fromJson(jsonValue: JsonValue, options?: Partial): TimeTicket; - - static fromJsonString(jsonString: string, options?: Partial): TimeTicket; - - static equals(a: TimeTicket | PlainMessage | undefined, b: TimeTicket | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.DocEventBody - */ -export declare class DocEventBody extends Message { - /** - * @generated from field: string topic = 1; - */ - topic: string; - - /** - * @generated from field: bytes payload = 2; - */ - payload: Uint8Array; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.DocEventBody"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): DocEventBody; - - static fromJson(jsonValue: JsonValue, options?: Partial): DocEventBody; - - static fromJsonString(jsonString: string, options?: Partial): DocEventBody; - - static equals(a: DocEventBody | PlainMessage | undefined, b: DocEventBody | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.DocEvent - */ -export declare class DocEvent extends Message { - /** - * @generated from field: yorkie.v1.DocEventType type = 1; - */ - type: DocEventType; - - /** - * @generated from field: string publisher = 2; - */ - publisher: string; - - /** - * @generated from field: yorkie.v1.DocEventBody body = 3; - */ - body?: DocEventBody; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.DocEvent"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): DocEvent; - - static fromJson(jsonValue: JsonValue, options?: Partial): DocEvent; - - static fromJsonString(jsonString: string, options?: Partial): DocEvent; - - static equals(a: DocEvent | PlainMessage | undefined, b: DocEvent | PlainMessage | undefined): boolean; -} - diff --git a/packages/sdk/src/api/yorkie/v1/resources_pb.js b/packages/sdk/src/api/yorkie/v1/resources_pb.js deleted file mode 100644 index 6b3a5aa71..000000000 --- a/packages/sdk/src/api/yorkie/v1/resources_pb.js +++ /dev/null @@ -1,674 +0,0 @@ -// -// Copyright 2022 The Yorkie Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// @generated by protoc-gen-es v1.6.0 with parameter "target=js+dts,js_import_style=module" -// @generated from file src/api/yorkie/v1/resources.proto (package yorkie.v1, syntax proto3) -/* eslint-disable */ -// @ts-nocheck - -import { proto3, StringValue, Timestamp } from "@bufbuild/protobuf"; - -/** - * @generated from enum yorkie.v1.ValueType - */ -export const ValueType = proto3.makeEnum( - "yorkie.v1.ValueType", - [ - {no: 0, name: "VALUE_TYPE_NULL", localName: "NULL"}, - {no: 1, name: "VALUE_TYPE_BOOLEAN", localName: "BOOLEAN"}, - {no: 2, name: "VALUE_TYPE_INTEGER", localName: "INTEGER"}, - {no: 3, name: "VALUE_TYPE_LONG", localName: "LONG"}, - {no: 4, name: "VALUE_TYPE_DOUBLE", localName: "DOUBLE"}, - {no: 5, name: "VALUE_TYPE_STRING", localName: "STRING"}, - {no: 6, name: "VALUE_TYPE_BYTES", localName: "BYTES"}, - {no: 7, name: "VALUE_TYPE_DATE", localName: "DATE"}, - {no: 8, name: "VALUE_TYPE_JSON_OBJECT", localName: "JSON_OBJECT"}, - {no: 9, name: "VALUE_TYPE_JSON_ARRAY", localName: "JSON_ARRAY"}, - {no: 10, name: "VALUE_TYPE_TEXT", localName: "TEXT"}, - {no: 11, name: "VALUE_TYPE_INTEGER_CNT", localName: "INTEGER_CNT"}, - {no: 12, name: "VALUE_TYPE_LONG_CNT", localName: "LONG_CNT"}, - {no: 13, name: "VALUE_TYPE_TREE", localName: "TREE"}, - ], -); - -/** - * @generated from enum yorkie.v1.DocEventType - */ -export const DocEventType = proto3.makeEnum( - "yorkie.v1.DocEventType", - [ - {no: 0, name: "DOC_EVENT_TYPE_DOCUMENT_CHANGED", localName: "DOCUMENT_CHANGED"}, - {no: 1, name: "DOC_EVENT_TYPE_DOCUMENT_WATCHED", localName: "DOCUMENT_WATCHED"}, - {no: 2, name: "DOC_EVENT_TYPE_DOCUMENT_UNWATCHED", localName: "DOCUMENT_UNWATCHED"}, - {no: 3, name: "DOC_EVENT_TYPE_DOCUMENT_BROADCAST", localName: "DOCUMENT_BROADCAST"}, - ], -); - -/** - * /////////////////////////////////////// - * Messages for Snapshot // - * /////////////////////////////////////// - * - * @generated from message yorkie.v1.Snapshot - */ -export const Snapshot = proto3.makeMessageType( - "yorkie.v1.Snapshot", - () => [ - { no: 1, name: "root", kind: "message", T: JSONElement }, - { no: 2, name: "presences", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: Presence} }, - ], -); - -/** - * ChangePack is a message that contains all changes that occurred in a document. - * It is used to synchronize changes between clients and servers. - * - * @generated from message yorkie.v1.ChangePack - */ -export const ChangePack = proto3.makeMessageType( - "yorkie.v1.ChangePack", - () => [ - { no: 1, name: "document_key", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 2, name: "checkpoint", kind: "message", T: Checkpoint }, - { no: 3, name: "snapshot", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, - { no: 4, name: "changes", kind: "message", T: Change, repeated: true }, - { no: 5, name: "min_synced_ticket", kind: "message", T: TimeTicket }, - { no: 6, name: "is_removed", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, - ], -); - -/** - * @generated from message yorkie.v1.Change - */ -export const Change = proto3.makeMessageType( - "yorkie.v1.Change", - () => [ - { no: 1, name: "id", kind: "message", T: ChangeID }, - { no: 2, name: "message", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 3, name: "operations", kind: "message", T: Operation, repeated: true }, - { no: 4, name: "presence_change", kind: "message", T: PresenceChange }, - ], -); - -/** - * @generated from message yorkie.v1.ChangeID - */ -export const ChangeID = proto3.makeMessageType( - "yorkie.v1.ChangeID", - () => [ - { no: 1, name: "client_seq", kind: "scalar", T: 13 /* ScalarType.UINT32 */ }, - { no: 2, name: "server_seq", kind: "scalar", T: 3 /* ScalarType.INT64 */, L: 1 /* LongType.STRING */ }, - { no: 3, name: "lamport", kind: "scalar", T: 3 /* ScalarType.INT64 */, L: 1 /* LongType.STRING */ }, - { no: 4, name: "actor_id", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, - ], -); - -/** - * @generated from message yorkie.v1.Operation - */ -export const Operation = proto3.makeMessageType( - "yorkie.v1.Operation", - () => [ - { no: 1, name: "set", kind: "message", T: Operation_Set, oneof: "body" }, - { no: 2, name: "add", kind: "message", T: Operation_Add, oneof: "body" }, - { no: 3, name: "move", kind: "message", T: Operation_Move, oneof: "body" }, - { no: 4, name: "remove", kind: "message", T: Operation_Remove, oneof: "body" }, - { no: 5, name: "edit", kind: "message", T: Operation_Edit, oneof: "body" }, - { no: 6, name: "select", kind: "message", T: Operation_Select, oneof: "body" }, - { no: 7, name: "style", kind: "message", T: Operation_Style, oneof: "body" }, - { no: 8, name: "increase", kind: "message", T: Operation_Increase, oneof: "body" }, - { no: 9, name: "tree_edit", kind: "message", T: Operation_TreeEdit, oneof: "body" }, - { no: 10, name: "tree_style", kind: "message", T: Operation_TreeStyle, oneof: "body" }, - ], -); - -/** - * @generated from message yorkie.v1.Operation.Set - */ -export const Operation_Set = proto3.makeMessageType( - "yorkie.v1.Operation.Set", - () => [ - { no: 1, name: "parent_created_at", kind: "message", T: TimeTicket }, - { no: 2, name: "key", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 3, name: "value", kind: "message", T: JSONElementSimple }, - { no: 4, name: "executed_at", kind: "message", T: TimeTicket }, - ], - {localName: "Operation_Set"}, -); - -/** - * @generated from message yorkie.v1.Operation.Add - */ -export const Operation_Add = proto3.makeMessageType( - "yorkie.v1.Operation.Add", - () => [ - { no: 1, name: "parent_created_at", kind: "message", T: TimeTicket }, - { no: 2, name: "prev_created_at", kind: "message", T: TimeTicket }, - { no: 3, name: "value", kind: "message", T: JSONElementSimple }, - { no: 4, name: "executed_at", kind: "message", T: TimeTicket }, - ], - {localName: "Operation_Add"}, -); - -/** - * @generated from message yorkie.v1.Operation.Move - */ -export const Operation_Move = proto3.makeMessageType( - "yorkie.v1.Operation.Move", - () => [ - { no: 1, name: "parent_created_at", kind: "message", T: TimeTicket }, - { no: 2, name: "prev_created_at", kind: "message", T: TimeTicket }, - { no: 3, name: "created_at", kind: "message", T: TimeTicket }, - { no: 4, name: "executed_at", kind: "message", T: TimeTicket }, - ], - {localName: "Operation_Move"}, -); - -/** - * @generated from message yorkie.v1.Operation.Remove - */ -export const Operation_Remove = proto3.makeMessageType( - "yorkie.v1.Operation.Remove", - () => [ - { no: 1, name: "parent_created_at", kind: "message", T: TimeTicket }, - { no: 2, name: "created_at", kind: "message", T: TimeTicket }, - { no: 3, name: "executed_at", kind: "message", T: TimeTicket }, - ], - {localName: "Operation_Remove"}, -); - -/** - * @generated from message yorkie.v1.Operation.Edit - */ -export const Operation_Edit = proto3.makeMessageType( - "yorkie.v1.Operation.Edit", - () => [ - { no: 1, name: "parent_created_at", kind: "message", T: TimeTicket }, - { no: 2, name: "from", kind: "message", T: TextNodePos }, - { no: 3, name: "to", kind: "message", T: TextNodePos }, - { no: 4, name: "created_at_map_by_actor", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: TimeTicket} }, - { no: 5, name: "content", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 6, name: "executed_at", kind: "message", T: TimeTicket }, - { no: 7, name: "attributes", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "scalar", T: 9 /* ScalarType.STRING */} }, - ], - {localName: "Operation_Edit"}, -); - -/** - * NOTE(hackerwins): Select Operation is not used in the current version. - * In the previous version, it was used to represent selection of Text. - * However, it has been replaced by Presence now. It is retained for backward - * compatibility purposes. - * - * @generated from message yorkie.v1.Operation.Select - */ -export const Operation_Select = proto3.makeMessageType( - "yorkie.v1.Operation.Select", - () => [ - { no: 1, name: "parent_created_at", kind: "message", T: TimeTicket }, - { no: 2, name: "from", kind: "message", T: TextNodePos }, - { no: 3, name: "to", kind: "message", T: TextNodePos }, - { no: 4, name: "executed_at", kind: "message", T: TimeTicket }, - ], - {localName: "Operation_Select"}, -); - -/** - * @generated from message yorkie.v1.Operation.Style - */ -export const Operation_Style = proto3.makeMessageType( - "yorkie.v1.Operation.Style", - () => [ - { no: 1, name: "parent_created_at", kind: "message", T: TimeTicket }, - { no: 2, name: "from", kind: "message", T: TextNodePos }, - { no: 3, name: "to", kind: "message", T: TextNodePos }, - { no: 4, name: "attributes", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "scalar", T: 9 /* ScalarType.STRING */} }, - { no: 5, name: "executed_at", kind: "message", T: TimeTicket }, - { no: 6, name: "created_at_map_by_actor", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: TimeTicket} }, - ], - {localName: "Operation_Style"}, -); - -/** - * @generated from message yorkie.v1.Operation.Increase - */ -export const Operation_Increase = proto3.makeMessageType( - "yorkie.v1.Operation.Increase", - () => [ - { no: 1, name: "parent_created_at", kind: "message", T: TimeTicket }, - { no: 2, name: "value", kind: "message", T: JSONElementSimple }, - { no: 3, name: "executed_at", kind: "message", T: TimeTicket }, - ], - {localName: "Operation_Increase"}, -); - -/** - * @generated from message yorkie.v1.Operation.TreeEdit - */ -export const Operation_TreeEdit = proto3.makeMessageType( - "yorkie.v1.Operation.TreeEdit", - () => [ - { no: 1, name: "parent_created_at", kind: "message", T: TimeTicket }, - { no: 2, name: "from", kind: "message", T: TreePos }, - { no: 3, name: "to", kind: "message", T: TreePos }, - { no: 4, name: "created_at_map_by_actor", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: TimeTicket} }, - { no: 5, name: "contents", kind: "message", T: TreeNodes, repeated: true }, - { no: 7, name: "split_level", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, - { no: 6, name: "executed_at", kind: "message", T: TimeTicket }, - ], - {localName: "Operation_TreeEdit"}, -); - -/** - * @generated from message yorkie.v1.Operation.TreeStyle - */ -export const Operation_TreeStyle = proto3.makeMessageType( - "yorkie.v1.Operation.TreeStyle", - () => [ - { no: 1, name: "parent_created_at", kind: "message", T: TimeTicket }, - { no: 2, name: "from", kind: "message", T: TreePos }, - { no: 3, name: "to", kind: "message", T: TreePos }, - { no: 4, name: "attributes", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "scalar", T: 9 /* ScalarType.STRING */} }, - { no: 5, name: "executed_at", kind: "message", T: TimeTicket }, - { no: 6, name: "attributes_to_remove", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true }, - { no: 7, name: "created_at_map_by_actor", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: TimeTicket} }, - ], - {localName: "Operation_TreeStyle"}, -); - -/** - * @generated from message yorkie.v1.JSONElementSimple - */ -export const JSONElementSimple = proto3.makeMessageType( - "yorkie.v1.JSONElementSimple", - () => [ - { no: 1, name: "created_at", kind: "message", T: TimeTicket }, - { no: 2, name: "moved_at", kind: "message", T: TimeTicket }, - { no: 3, name: "removed_at", kind: "message", T: TimeTicket }, - { no: 4, name: "type", kind: "enum", T: proto3.getEnumType(ValueType) }, - { no: 5, name: "value", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, - ], -); - -/** - * @generated from message yorkie.v1.JSONElement - */ -export const JSONElement = proto3.makeMessageType( - "yorkie.v1.JSONElement", - () => [ - { no: 1, name: "json_object", kind: "message", T: JSONElement_JSONObject, oneof: "body" }, - { no: 2, name: "json_array", kind: "message", T: JSONElement_JSONArray, oneof: "body" }, - { no: 3, name: "primitive", kind: "message", T: JSONElement_Primitive, oneof: "body" }, - { no: 5, name: "text", kind: "message", T: JSONElement_Text, oneof: "body" }, - { no: 6, name: "counter", kind: "message", T: JSONElement_Counter, oneof: "body" }, - { no: 7, name: "tree", kind: "message", T: JSONElement_Tree, oneof: "body" }, - ], -); - -/** - * @generated from message yorkie.v1.JSONElement.JSONObject - */ -export const JSONElement_JSONObject = proto3.makeMessageType( - "yorkie.v1.JSONElement.JSONObject", - () => [ - { no: 1, name: "nodes", kind: "message", T: RHTNode, repeated: true }, - { no: 2, name: "created_at", kind: "message", T: TimeTicket }, - { no: 3, name: "moved_at", kind: "message", T: TimeTicket }, - { no: 4, name: "removed_at", kind: "message", T: TimeTicket }, - ], - {localName: "JSONElement_JSONObject"}, -); - -/** - * @generated from message yorkie.v1.JSONElement.JSONArray - */ -export const JSONElement_JSONArray = proto3.makeMessageType( - "yorkie.v1.JSONElement.JSONArray", - () => [ - { no: 1, name: "nodes", kind: "message", T: RGANode, repeated: true }, - { no: 2, name: "created_at", kind: "message", T: TimeTicket }, - { no: 3, name: "moved_at", kind: "message", T: TimeTicket }, - { no: 4, name: "removed_at", kind: "message", T: TimeTicket }, - ], - {localName: "JSONElement_JSONArray"}, -); - -/** - * @generated from message yorkie.v1.JSONElement.Primitive - */ -export const JSONElement_Primitive = proto3.makeMessageType( - "yorkie.v1.JSONElement.Primitive", - () => [ - { no: 1, name: "type", kind: "enum", T: proto3.getEnumType(ValueType) }, - { no: 2, name: "value", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, - { no: 3, name: "created_at", kind: "message", T: TimeTicket }, - { no: 4, name: "moved_at", kind: "message", T: TimeTicket }, - { no: 5, name: "removed_at", kind: "message", T: TimeTicket }, - ], - {localName: "JSONElement_Primitive"}, -); - -/** - * @generated from message yorkie.v1.JSONElement.Text - */ -export const JSONElement_Text = proto3.makeMessageType( - "yorkie.v1.JSONElement.Text", - () => [ - { no: 1, name: "nodes", kind: "message", T: TextNode, repeated: true }, - { no: 2, name: "created_at", kind: "message", T: TimeTicket }, - { no: 3, name: "moved_at", kind: "message", T: TimeTicket }, - { no: 4, name: "removed_at", kind: "message", T: TimeTicket }, - ], - {localName: "JSONElement_Text"}, -); - -/** - * @generated from message yorkie.v1.JSONElement.Counter - */ -export const JSONElement_Counter = proto3.makeMessageType( - "yorkie.v1.JSONElement.Counter", - () => [ - { no: 1, name: "type", kind: "enum", T: proto3.getEnumType(ValueType) }, - { no: 2, name: "value", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, - { no: 3, name: "created_at", kind: "message", T: TimeTicket }, - { no: 4, name: "moved_at", kind: "message", T: TimeTicket }, - { no: 5, name: "removed_at", kind: "message", T: TimeTicket }, - ], - {localName: "JSONElement_Counter"}, -); - -/** - * @generated from message yorkie.v1.JSONElement.Tree - */ -export const JSONElement_Tree = proto3.makeMessageType( - "yorkie.v1.JSONElement.Tree", - () => [ - { no: 1, name: "nodes", kind: "message", T: TreeNode, repeated: true }, - { no: 2, name: "created_at", kind: "message", T: TimeTicket }, - { no: 3, name: "moved_at", kind: "message", T: TimeTicket }, - { no: 4, name: "removed_at", kind: "message", T: TimeTicket }, - ], - {localName: "JSONElement_Tree"}, -); - -/** - * @generated from message yorkie.v1.RHTNode - */ -export const RHTNode = proto3.makeMessageType( - "yorkie.v1.RHTNode", - () => [ - { no: 1, name: "key", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 2, name: "element", kind: "message", T: JSONElement }, - ], -); - -/** - * @generated from message yorkie.v1.RGANode - */ -export const RGANode = proto3.makeMessageType( - "yorkie.v1.RGANode", - () => [ - { no: 1, name: "next", kind: "message", T: RGANode }, - { no: 2, name: "element", kind: "message", T: JSONElement }, - ], -); - -/** - * @generated from message yorkie.v1.NodeAttr - */ -export const NodeAttr = proto3.makeMessageType( - "yorkie.v1.NodeAttr", - () => [ - { no: 1, name: "value", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 2, name: "updated_at", kind: "message", T: TimeTicket }, - { no: 3, name: "is_removed", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, - ], -); - -/** - * @generated from message yorkie.v1.TextNode - */ -export const TextNode = proto3.makeMessageType( - "yorkie.v1.TextNode", - () => [ - { no: 1, name: "id", kind: "message", T: TextNodeID }, - { no: 2, name: "value", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 3, name: "removed_at", kind: "message", T: TimeTicket }, - { no: 4, name: "ins_prev_id", kind: "message", T: TextNodeID }, - { no: 5, name: "attributes", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: NodeAttr} }, - ], -); - -/** - * @generated from message yorkie.v1.TextNodeID - */ -export const TextNodeID = proto3.makeMessageType( - "yorkie.v1.TextNodeID", - () => [ - { no: 1, name: "created_at", kind: "message", T: TimeTicket }, - { no: 2, name: "offset", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, - ], -); - -/** - * @generated from message yorkie.v1.TreeNode - */ -export const TreeNode = proto3.makeMessageType( - "yorkie.v1.TreeNode", - () => [ - { no: 1, name: "id", kind: "message", T: TreeNodeID }, - { no: 2, name: "type", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 3, name: "value", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 4, name: "removed_at", kind: "message", T: TimeTicket }, - { no: 5, name: "ins_prev_id", kind: "message", T: TreeNodeID }, - { no: 6, name: "ins_next_id", kind: "message", T: TreeNodeID }, - { no: 7, name: "depth", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, - { no: 8, name: "attributes", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: NodeAttr} }, - ], -); - -/** - * @generated from message yorkie.v1.TreeNodes - */ -export const TreeNodes = proto3.makeMessageType( - "yorkie.v1.TreeNodes", - () => [ - { no: 1, name: "content", kind: "message", T: TreeNode, repeated: true }, - ], -); - -/** - * @generated from message yorkie.v1.TreeNodeID - */ -export const TreeNodeID = proto3.makeMessageType( - "yorkie.v1.TreeNodeID", - () => [ - { no: 1, name: "created_at", kind: "message", T: TimeTicket }, - { no: 2, name: "offset", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, - ], -); - -/** - * @generated from message yorkie.v1.TreePos - */ -export const TreePos = proto3.makeMessageType( - "yorkie.v1.TreePos", - () => [ - { no: 1, name: "parent_id", kind: "message", T: TreeNodeID }, - { no: 2, name: "left_sibling_id", kind: "message", T: TreeNodeID }, - ], -); - -/** - * @generated from message yorkie.v1.User - */ -export const User = proto3.makeMessageType( - "yorkie.v1.User", - () => [ - { no: 1, name: "id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 2, name: "username", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 3, name: "created_at", kind: "message", T: Timestamp }, - ], -); - -/** - * @generated from message yorkie.v1.Project - */ -export const Project = proto3.makeMessageType( - "yorkie.v1.Project", - () => [ - { no: 1, name: "id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 2, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 3, name: "public_key", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 4, name: "secret_key", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 5, name: "auth_webhook_url", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 6, name: "auth_webhook_methods", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true }, - { no: 7, name: "client_deactivate_threshold", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 8, name: "created_at", kind: "message", T: Timestamp }, - { no: 9, name: "updated_at", kind: "message", T: Timestamp }, - ], -); - -/** - * @generated from message yorkie.v1.UpdatableProjectFields - */ -export const UpdatableProjectFields = proto3.makeMessageType( - "yorkie.v1.UpdatableProjectFields", - () => [ - { no: 1, name: "name", kind: "message", T: StringValue }, - { no: 2, name: "auth_webhook_url", kind: "message", T: StringValue }, - { no: 3, name: "auth_webhook_methods", kind: "message", T: UpdatableProjectFields_AuthWebhookMethods }, - { no: 4, name: "client_deactivate_threshold", kind: "message", T: StringValue }, - ], -); - -/** - * @generated from message yorkie.v1.UpdatableProjectFields.AuthWebhookMethods - */ -export const UpdatableProjectFields_AuthWebhookMethods = proto3.makeMessageType( - "yorkie.v1.UpdatableProjectFields.AuthWebhookMethods", - () => [ - { no: 1, name: "methods", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true }, - ], - {localName: "UpdatableProjectFields_AuthWebhookMethods"}, -); - -/** - * @generated from message yorkie.v1.DocumentSummary - */ -export const DocumentSummary = proto3.makeMessageType( - "yorkie.v1.DocumentSummary", - () => [ - { no: 1, name: "id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 2, name: "key", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 3, name: "snapshot", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 4, name: "created_at", kind: "message", T: Timestamp }, - { no: 5, name: "accessed_at", kind: "message", T: Timestamp }, - { no: 6, name: "updated_at", kind: "message", T: Timestamp }, - ], -); - -/** - * @generated from message yorkie.v1.PresenceChange - */ -export const PresenceChange = proto3.makeMessageType( - "yorkie.v1.PresenceChange", - () => [ - { no: 1, name: "type", kind: "enum", T: proto3.getEnumType(PresenceChange_ChangeType) }, - { no: 2, name: "presence", kind: "message", T: Presence }, - ], -); - -/** - * @generated from enum yorkie.v1.PresenceChange.ChangeType - */ -export const PresenceChange_ChangeType = proto3.makeEnum( - "yorkie.v1.PresenceChange.ChangeType", - [ - {no: 0, name: "CHANGE_TYPE_UNSPECIFIED", localName: "UNSPECIFIED"}, - {no: 1, name: "CHANGE_TYPE_PUT", localName: "PUT"}, - {no: 2, name: "CHANGE_TYPE_DELETE", localName: "DELETE"}, - {no: 3, name: "CHANGE_TYPE_CLEAR", localName: "CLEAR"}, - ], -); - -/** - * @generated from message yorkie.v1.Presence - */ -export const Presence = proto3.makeMessageType( - "yorkie.v1.Presence", - () => [ - { no: 1, name: "data", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "scalar", T: 9 /* ScalarType.STRING */} }, - ], -); - -/** - * @generated from message yorkie.v1.Checkpoint - */ -export const Checkpoint = proto3.makeMessageType( - "yorkie.v1.Checkpoint", - () => [ - { no: 1, name: "server_seq", kind: "scalar", T: 3 /* ScalarType.INT64 */, L: 1 /* LongType.STRING */ }, - { no: 2, name: "client_seq", kind: "scalar", T: 13 /* ScalarType.UINT32 */ }, - ], -); - -/** - * @generated from message yorkie.v1.TextNodePos - */ -export const TextNodePos = proto3.makeMessageType( - "yorkie.v1.TextNodePos", - () => [ - { no: 1, name: "created_at", kind: "message", T: TimeTicket }, - { no: 2, name: "offset", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, - { no: 3, name: "relative_offset", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, - ], -); - -/** - * @generated from message yorkie.v1.TimeTicket - */ -export const TimeTicket = proto3.makeMessageType( - "yorkie.v1.TimeTicket", - () => [ - { no: 1, name: "lamport", kind: "scalar", T: 3 /* ScalarType.INT64 */, L: 1 /* LongType.STRING */ }, - { no: 2, name: "delimiter", kind: "scalar", T: 13 /* ScalarType.UINT32 */ }, - { no: 3, name: "actor_id", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, - ], -); - -/** - * @generated from message yorkie.v1.DocEventBody - */ -export const DocEventBody = proto3.makeMessageType( - "yorkie.v1.DocEventBody", - () => [ - { no: 1, name: "topic", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 2, name: "payload", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, - ], -); - -/** - * @generated from message yorkie.v1.DocEvent - */ -export const DocEvent = proto3.makeMessageType( - "yorkie.v1.DocEvent", - () => [ - { no: 1, name: "type", kind: "enum", T: proto3.getEnumType(DocEventType) }, - { no: 2, name: "publisher", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 3, name: "body", kind: "message", T: DocEventBody }, - ], -); - diff --git a/packages/sdk/src/api/yorkie/v1/resources_pb.ts b/packages/sdk/src/api/yorkie/v1/resources_pb.ts new file mode 100644 index 000000000..9297e1fb0 --- /dev/null +++ b/packages/sdk/src/api/yorkie/v1/resources_pb.ts @@ -0,0 +1,2760 @@ +// +// Copyright 2022 The Yorkie Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// @generated by protoc-gen-es v1.10.0 with parameter "target=ts,import_extension=none" +// @generated from file src/api/yorkie/v1/resources.proto (package yorkie.v1, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3, protoInt64, StringValue, Timestamp } from "@bufbuild/protobuf"; + +/** + * @generated from enum yorkie.v1.ValueType + */ +export enum ValueType { + /** + * @generated from enum value: VALUE_TYPE_NULL = 0; + */ + NULL = 0, + + /** + * @generated from enum value: VALUE_TYPE_BOOLEAN = 1; + */ + BOOLEAN = 1, + + /** + * @generated from enum value: VALUE_TYPE_INTEGER = 2; + */ + INTEGER = 2, + + /** + * @generated from enum value: VALUE_TYPE_LONG = 3; + */ + LONG = 3, + + /** + * @generated from enum value: VALUE_TYPE_DOUBLE = 4; + */ + DOUBLE = 4, + + /** + * @generated from enum value: VALUE_TYPE_STRING = 5; + */ + STRING = 5, + + /** + * @generated from enum value: VALUE_TYPE_BYTES = 6; + */ + BYTES = 6, + + /** + * @generated from enum value: VALUE_TYPE_DATE = 7; + */ + DATE = 7, + + /** + * @generated from enum value: VALUE_TYPE_JSON_OBJECT = 8; + */ + JSON_OBJECT = 8, + + /** + * @generated from enum value: VALUE_TYPE_JSON_ARRAY = 9; + */ + JSON_ARRAY = 9, + + /** + * @generated from enum value: VALUE_TYPE_TEXT = 10; + */ + TEXT = 10, + + /** + * @generated from enum value: VALUE_TYPE_INTEGER_CNT = 11; + */ + INTEGER_CNT = 11, + + /** + * @generated from enum value: VALUE_TYPE_LONG_CNT = 12; + */ + LONG_CNT = 12, + + /** + * @generated from enum value: VALUE_TYPE_TREE = 13; + */ + TREE = 13, +} +// Retrieve enum metadata with: proto3.getEnumType(ValueType) +proto3.util.setEnumType(ValueType, "yorkie.v1.ValueType", [ + { no: 0, name: "VALUE_TYPE_NULL" }, + { no: 1, name: "VALUE_TYPE_BOOLEAN" }, + { no: 2, name: "VALUE_TYPE_INTEGER" }, + { no: 3, name: "VALUE_TYPE_LONG" }, + { no: 4, name: "VALUE_TYPE_DOUBLE" }, + { no: 5, name: "VALUE_TYPE_STRING" }, + { no: 6, name: "VALUE_TYPE_BYTES" }, + { no: 7, name: "VALUE_TYPE_DATE" }, + { no: 8, name: "VALUE_TYPE_JSON_OBJECT" }, + { no: 9, name: "VALUE_TYPE_JSON_ARRAY" }, + { no: 10, name: "VALUE_TYPE_TEXT" }, + { no: 11, name: "VALUE_TYPE_INTEGER_CNT" }, + { no: 12, name: "VALUE_TYPE_LONG_CNT" }, + { no: 13, name: "VALUE_TYPE_TREE" }, +]); + +/** + * @generated from enum yorkie.v1.DocEventType + */ +export enum DocEventType { + /** + * @generated from enum value: DOC_EVENT_TYPE_DOCUMENT_CHANGED = 0; + */ + DOCUMENT_CHANGED = 0, + + /** + * @generated from enum value: DOC_EVENT_TYPE_DOCUMENT_WATCHED = 1; + */ + DOCUMENT_WATCHED = 1, + + /** + * @generated from enum value: DOC_EVENT_TYPE_DOCUMENT_UNWATCHED = 2; + */ + DOCUMENT_UNWATCHED = 2, + + /** + * @generated from enum value: DOC_EVENT_TYPE_DOCUMENT_BROADCAST = 3; + */ + DOCUMENT_BROADCAST = 3, +} +// Retrieve enum metadata with: proto3.getEnumType(DocEventType) +proto3.util.setEnumType(DocEventType, "yorkie.v1.DocEventType", [ + { no: 0, name: "DOC_EVENT_TYPE_DOCUMENT_CHANGED" }, + { no: 1, name: "DOC_EVENT_TYPE_DOCUMENT_WATCHED" }, + { no: 2, name: "DOC_EVENT_TYPE_DOCUMENT_UNWATCHED" }, + { no: 3, name: "DOC_EVENT_TYPE_DOCUMENT_BROADCAST" }, +]); + +/** + * /////////////////////////////////////// + * Messages for Snapshot // + * /////////////////////////////////////// + * + * @generated from message yorkie.v1.Snapshot + */ +export class Snapshot extends Message { + /** + * @generated from field: yorkie.v1.JSONElement root = 1; + */ + root?: JSONElement; + + /** + * @generated from field: map presences = 2; + */ + presences: { [key: string]: Presence } = {}; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.Snapshot"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "root", kind: "message", T: JSONElement }, + { no: 2, name: "presences", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: Presence} }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): Snapshot { + return new Snapshot().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): Snapshot { + return new Snapshot().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): Snapshot { + return new Snapshot().fromJsonString(jsonString, options); + } + + static equals(a: Snapshot | PlainMessage | undefined, b: Snapshot | PlainMessage | undefined): boolean { + return proto3.util.equals(Snapshot, a, b); + } +} + +/** + * ChangePack is a message that contains all changes that occurred in a document. + * It is used to synchronize changes between clients and servers. + * + * @generated from message yorkie.v1.ChangePack + */ +export class ChangePack extends Message { + /** + * @generated from field: string document_key = 1; + */ + documentKey = ""; + + /** + * @generated from field: yorkie.v1.Checkpoint checkpoint = 2; + */ + checkpoint?: Checkpoint; + + /** + * @generated from field: bytes snapshot = 3; + */ + snapshot = new Uint8Array(0); + + /** + * @generated from field: repeated yorkie.v1.Change changes = 4; + */ + changes: Change[] = []; + + /** + * @generated from field: yorkie.v1.TimeTicket min_synced_ticket = 5; + */ + minSyncedTicket?: TimeTicket; + + /** + * @generated from field: bool is_removed = 6; + */ + isRemoved = false; + + /** + * @generated from field: yorkie.v1.VersionVector version_vector = 7; + */ + versionVector?: VersionVector; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.ChangePack"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "document_key", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "checkpoint", kind: "message", T: Checkpoint }, + { no: 3, name: "snapshot", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + { no: 4, name: "changes", kind: "message", T: Change, repeated: true }, + { no: 5, name: "min_synced_ticket", kind: "message", T: TimeTicket }, + { no: 6, name: "is_removed", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, + { no: 7, name: "version_vector", kind: "message", T: VersionVector }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): ChangePack { + return new ChangePack().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): ChangePack { + return new ChangePack().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): ChangePack { + return new ChangePack().fromJsonString(jsonString, options); + } + + static equals(a: ChangePack | PlainMessage | undefined, b: ChangePack | PlainMessage | undefined): boolean { + return proto3.util.equals(ChangePack, a, b); + } +} + +/** + * @generated from message yorkie.v1.Change + */ +export class Change extends Message { + /** + * @generated from field: yorkie.v1.ChangeID id = 1; + */ + id?: ChangeID; + + /** + * @generated from field: string message = 2; + */ + message = ""; + + /** + * @generated from field: repeated yorkie.v1.Operation operations = 3; + */ + operations: Operation[] = []; + + /** + * @generated from field: yorkie.v1.PresenceChange presence_change = 4; + */ + presenceChange?: PresenceChange; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.Change"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "id", kind: "message", T: ChangeID }, + { no: 2, name: "message", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "operations", kind: "message", T: Operation, repeated: true }, + { no: 4, name: "presence_change", kind: "message", T: PresenceChange }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): Change { + return new Change().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): Change { + return new Change().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): Change { + return new Change().fromJsonString(jsonString, options); + } + + static equals(a: Change | PlainMessage | undefined, b: Change | PlainMessage | undefined): boolean { + return proto3.util.equals(Change, a, b); + } +} + +/** + * @generated from message yorkie.v1.ChangeID + */ +export class ChangeID extends Message { + /** + * @generated from field: uint32 client_seq = 1; + */ + clientSeq = 0; + + /** + * @generated from field: int64 server_seq = 2; + */ + serverSeq = protoInt64.zero; + + /** + * @generated from field: int64 lamport = 3; + */ + lamport = protoInt64.zero; + + /** + * @generated from field: bytes actor_id = 4; + */ + actorId = new Uint8Array(0); + + /** + * @generated from field: yorkie.v1.VersionVector version_vector = 5; + */ + versionVector?: VersionVector; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.ChangeID"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "client_seq", kind: "scalar", T: 13 /* ScalarType.UINT32 */ }, + { no: 2, name: "server_seq", kind: "scalar", T: 3 /* ScalarType.INT64 */ }, + { no: 3, name: "lamport", kind: "scalar", T: 3 /* ScalarType.INT64 */ }, + { no: 4, name: "actor_id", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + { no: 5, name: "version_vector", kind: "message", T: VersionVector }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): ChangeID { + return new ChangeID().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): ChangeID { + return new ChangeID().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): ChangeID { + return new ChangeID().fromJsonString(jsonString, options); + } + + static equals(a: ChangeID | PlainMessage | undefined, b: ChangeID | PlainMessage | undefined): boolean { + return proto3.util.equals(ChangeID, a, b); + } +} + +/** + * @generated from message yorkie.v1.VersionVector + */ +export class VersionVector extends Message { + /** + * @generated from field: map vector = 1; + */ + vector: { [key: string]: bigint } = {}; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.VersionVector"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "vector", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "scalar", T: 3 /* ScalarType.INT64 */} }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): VersionVector { + return new VersionVector().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): VersionVector { + return new VersionVector().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): VersionVector { + return new VersionVector().fromJsonString(jsonString, options); + } + + static equals(a: VersionVector | PlainMessage | undefined, b: VersionVector | PlainMessage | undefined): boolean { + return proto3.util.equals(VersionVector, a, b); + } +} + +/** + * @generated from message yorkie.v1.Operation + */ +export class Operation extends Message { + /** + * @generated from oneof yorkie.v1.Operation.body + */ + body: { + /** + * @generated from field: yorkie.v1.Operation.Set set = 1; + */ + value: Operation_Set; + case: "set"; + } | { + /** + * @generated from field: yorkie.v1.Operation.Add add = 2; + */ + value: Operation_Add; + case: "add"; + } | { + /** + * @generated from field: yorkie.v1.Operation.Move move = 3; + */ + value: Operation_Move; + case: "move"; + } | { + /** + * @generated from field: yorkie.v1.Operation.Remove remove = 4; + */ + value: Operation_Remove; + case: "remove"; + } | { + /** + * @generated from field: yorkie.v1.Operation.Edit edit = 5; + */ + value: Operation_Edit; + case: "edit"; + } | { + /** + * @generated from field: yorkie.v1.Operation.Select select = 6; + */ + value: Operation_Select; + case: "select"; + } | { + /** + * @generated from field: yorkie.v1.Operation.Style style = 7; + */ + value: Operation_Style; + case: "style"; + } | { + /** + * @generated from field: yorkie.v1.Operation.Increase increase = 8; + */ + value: Operation_Increase; + case: "increase"; + } | { + /** + * @generated from field: yorkie.v1.Operation.TreeEdit tree_edit = 9; + */ + value: Operation_TreeEdit; + case: "treeEdit"; + } | { + /** + * @generated from field: yorkie.v1.Operation.TreeStyle tree_style = 10; + */ + value: Operation_TreeStyle; + case: "treeStyle"; + } | { + /** + * @generated from field: yorkie.v1.Operation.ArraySet array_set = 11; + */ + value: Operation_ArraySet; + case: "arraySet"; + } | { case: undefined; value?: undefined } = { case: undefined }; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.Operation"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "set", kind: "message", T: Operation_Set, oneof: "body" }, + { no: 2, name: "add", kind: "message", T: Operation_Add, oneof: "body" }, + { no: 3, name: "move", kind: "message", T: Operation_Move, oneof: "body" }, + { no: 4, name: "remove", kind: "message", T: Operation_Remove, oneof: "body" }, + { no: 5, name: "edit", kind: "message", T: Operation_Edit, oneof: "body" }, + { no: 6, name: "select", kind: "message", T: Operation_Select, oneof: "body" }, + { no: 7, name: "style", kind: "message", T: Operation_Style, oneof: "body" }, + { no: 8, name: "increase", kind: "message", T: Operation_Increase, oneof: "body" }, + { no: 9, name: "tree_edit", kind: "message", T: Operation_TreeEdit, oneof: "body" }, + { no: 10, name: "tree_style", kind: "message", T: Operation_TreeStyle, oneof: "body" }, + { no: 11, name: "array_set", kind: "message", T: Operation_ArraySet, oneof: "body" }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): Operation { + return new Operation().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): Operation { + return new Operation().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): Operation { + return new Operation().fromJsonString(jsonString, options); + } + + static equals(a: Operation | PlainMessage | undefined, b: Operation | PlainMessage | undefined): boolean { + return proto3.util.equals(Operation, a, b); + } +} + +/** + * @generated from message yorkie.v1.Operation.Set + */ +export class Operation_Set extends Message { + /** + * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1; + */ + parentCreatedAt?: TimeTicket; + + /** + * @generated from field: string key = 2; + */ + key = ""; + + /** + * @generated from field: yorkie.v1.JSONElementSimple value = 3; + */ + value?: JSONElementSimple; + + /** + * @generated from field: yorkie.v1.TimeTicket executed_at = 4; + */ + executedAt?: TimeTicket; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.Operation.Set"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "parent_created_at", kind: "message", T: TimeTicket }, + { no: 2, name: "key", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "value", kind: "message", T: JSONElementSimple }, + { no: 4, name: "executed_at", kind: "message", T: TimeTicket }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): Operation_Set { + return new Operation_Set().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): Operation_Set { + return new Operation_Set().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): Operation_Set { + return new Operation_Set().fromJsonString(jsonString, options); + } + + static equals(a: Operation_Set | PlainMessage | undefined, b: Operation_Set | PlainMessage | undefined): boolean { + return proto3.util.equals(Operation_Set, a, b); + } +} + +/** + * @generated from message yorkie.v1.Operation.Add + */ +export class Operation_Add extends Message { + /** + * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1; + */ + parentCreatedAt?: TimeTicket; + + /** + * @generated from field: yorkie.v1.TimeTicket prev_created_at = 2; + */ + prevCreatedAt?: TimeTicket; + + /** + * @generated from field: yorkie.v1.JSONElementSimple value = 3; + */ + value?: JSONElementSimple; + + /** + * @generated from field: yorkie.v1.TimeTicket executed_at = 4; + */ + executedAt?: TimeTicket; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.Operation.Add"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "parent_created_at", kind: "message", T: TimeTicket }, + { no: 2, name: "prev_created_at", kind: "message", T: TimeTicket }, + { no: 3, name: "value", kind: "message", T: JSONElementSimple }, + { no: 4, name: "executed_at", kind: "message", T: TimeTicket }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): Operation_Add { + return new Operation_Add().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): Operation_Add { + return new Operation_Add().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): Operation_Add { + return new Operation_Add().fromJsonString(jsonString, options); + } + + static equals(a: Operation_Add | PlainMessage | undefined, b: Operation_Add | PlainMessage | undefined): boolean { + return proto3.util.equals(Operation_Add, a, b); + } +} + +/** + * @generated from message yorkie.v1.Operation.Move + */ +export class Operation_Move extends Message { + /** + * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1; + */ + parentCreatedAt?: TimeTicket; + + /** + * @generated from field: yorkie.v1.TimeTicket prev_created_at = 2; + */ + prevCreatedAt?: TimeTicket; + + /** + * @generated from field: yorkie.v1.TimeTicket created_at = 3; + */ + createdAt?: TimeTicket; + + /** + * @generated from field: yorkie.v1.TimeTicket executed_at = 4; + */ + executedAt?: TimeTicket; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.Operation.Move"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "parent_created_at", kind: "message", T: TimeTicket }, + { no: 2, name: "prev_created_at", kind: "message", T: TimeTicket }, + { no: 3, name: "created_at", kind: "message", T: TimeTicket }, + { no: 4, name: "executed_at", kind: "message", T: TimeTicket }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): Operation_Move { + return new Operation_Move().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): Operation_Move { + return new Operation_Move().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): Operation_Move { + return new Operation_Move().fromJsonString(jsonString, options); + } + + static equals(a: Operation_Move | PlainMessage | undefined, b: Operation_Move | PlainMessage | undefined): boolean { + return proto3.util.equals(Operation_Move, a, b); + } +} + +/** + * @generated from message yorkie.v1.Operation.Remove + */ +export class Operation_Remove extends Message { + /** + * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1; + */ + parentCreatedAt?: TimeTicket; + + /** + * @generated from field: yorkie.v1.TimeTicket created_at = 2; + */ + createdAt?: TimeTicket; + + /** + * @generated from field: yorkie.v1.TimeTicket executed_at = 3; + */ + executedAt?: TimeTicket; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.Operation.Remove"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "parent_created_at", kind: "message", T: TimeTicket }, + { no: 2, name: "created_at", kind: "message", T: TimeTicket }, + { no: 3, name: "executed_at", kind: "message", T: TimeTicket }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): Operation_Remove { + return new Operation_Remove().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): Operation_Remove { + return new Operation_Remove().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): Operation_Remove { + return new Operation_Remove().fromJsonString(jsonString, options); + } + + static equals(a: Operation_Remove | PlainMessage | undefined, b: Operation_Remove | PlainMessage | undefined): boolean { + return proto3.util.equals(Operation_Remove, a, b); + } +} + +/** + * @generated from message yorkie.v1.Operation.Edit + */ +export class Operation_Edit extends Message { + /** + * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1; + */ + parentCreatedAt?: TimeTicket; + + /** + * @generated from field: yorkie.v1.TextNodePos from = 2; + */ + from?: TextNodePos; + + /** + * @generated from field: yorkie.v1.TextNodePos to = 3; + */ + to?: TextNodePos; + + /** + * @generated from field: map created_at_map_by_actor = 4; + */ + createdAtMapByActor: { [key: string]: TimeTicket } = {}; + + /** + * @generated from field: string content = 5; + */ + content = ""; + + /** + * @generated from field: yorkie.v1.TimeTicket executed_at = 6; + */ + executedAt?: TimeTicket; + + /** + * @generated from field: map attributes = 7; + */ + attributes: { [key: string]: string } = {}; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.Operation.Edit"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "parent_created_at", kind: "message", T: TimeTicket }, + { no: 2, name: "from", kind: "message", T: TextNodePos }, + { no: 3, name: "to", kind: "message", T: TextNodePos }, + { no: 4, name: "created_at_map_by_actor", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: TimeTicket} }, + { no: 5, name: "content", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 6, name: "executed_at", kind: "message", T: TimeTicket }, + { no: 7, name: "attributes", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "scalar", T: 9 /* ScalarType.STRING */} }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): Operation_Edit { + return new Operation_Edit().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): Operation_Edit { + return new Operation_Edit().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): Operation_Edit { + return new Operation_Edit().fromJsonString(jsonString, options); + } + + static equals(a: Operation_Edit | PlainMessage | undefined, b: Operation_Edit | PlainMessage | undefined): boolean { + return proto3.util.equals(Operation_Edit, a, b); + } +} + +/** + * NOTE(hackerwins): Select Operation is not used in the current version. + * In the previous version, it was used to represent selection of Text. + * However, it has been replaced by Presence now. It is retained for backward + * compatibility purposes. + * + * @generated from message yorkie.v1.Operation.Select + */ +export class Operation_Select extends Message { + /** + * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1; + */ + parentCreatedAt?: TimeTicket; + + /** + * @generated from field: yorkie.v1.TextNodePos from = 2; + */ + from?: TextNodePos; + + /** + * @generated from field: yorkie.v1.TextNodePos to = 3; + */ + to?: TextNodePos; + + /** + * @generated from field: yorkie.v1.TimeTicket executed_at = 4; + */ + executedAt?: TimeTicket; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.Operation.Select"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "parent_created_at", kind: "message", T: TimeTicket }, + { no: 2, name: "from", kind: "message", T: TextNodePos }, + { no: 3, name: "to", kind: "message", T: TextNodePos }, + { no: 4, name: "executed_at", kind: "message", T: TimeTicket }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): Operation_Select { + return new Operation_Select().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): Operation_Select { + return new Operation_Select().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): Operation_Select { + return new Operation_Select().fromJsonString(jsonString, options); + } + + static equals(a: Operation_Select | PlainMessage | undefined, b: Operation_Select | PlainMessage | undefined): boolean { + return proto3.util.equals(Operation_Select, a, b); + } +} + +/** + * @generated from message yorkie.v1.Operation.Style + */ +export class Operation_Style extends Message { + /** + * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1; + */ + parentCreatedAt?: TimeTicket; + + /** + * @generated from field: yorkie.v1.TextNodePos from = 2; + */ + from?: TextNodePos; + + /** + * @generated from field: yorkie.v1.TextNodePos to = 3; + */ + to?: TextNodePos; + + /** + * @generated from field: map attributes = 4; + */ + attributes: { [key: string]: string } = {}; + + /** + * @generated from field: yorkie.v1.TimeTicket executed_at = 5; + */ + executedAt?: TimeTicket; + + /** + * @generated from field: map created_at_map_by_actor = 6; + */ + createdAtMapByActor: { [key: string]: TimeTicket } = {}; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.Operation.Style"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "parent_created_at", kind: "message", T: TimeTicket }, + { no: 2, name: "from", kind: "message", T: TextNodePos }, + { no: 3, name: "to", kind: "message", T: TextNodePos }, + { no: 4, name: "attributes", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "scalar", T: 9 /* ScalarType.STRING */} }, + { no: 5, name: "executed_at", kind: "message", T: TimeTicket }, + { no: 6, name: "created_at_map_by_actor", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: TimeTicket} }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): Operation_Style { + return new Operation_Style().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): Operation_Style { + return new Operation_Style().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): Operation_Style { + return new Operation_Style().fromJsonString(jsonString, options); + } + + static equals(a: Operation_Style | PlainMessage | undefined, b: Operation_Style | PlainMessage | undefined): boolean { + return proto3.util.equals(Operation_Style, a, b); + } +} + +/** + * @generated from message yorkie.v1.Operation.Increase + */ +export class Operation_Increase extends Message { + /** + * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1; + */ + parentCreatedAt?: TimeTicket; + + /** + * @generated from field: yorkie.v1.JSONElementSimple value = 2; + */ + value?: JSONElementSimple; + + /** + * @generated from field: yorkie.v1.TimeTicket executed_at = 3; + */ + executedAt?: TimeTicket; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.Operation.Increase"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "parent_created_at", kind: "message", T: TimeTicket }, + { no: 2, name: "value", kind: "message", T: JSONElementSimple }, + { no: 3, name: "executed_at", kind: "message", T: TimeTicket }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): Operation_Increase { + return new Operation_Increase().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): Operation_Increase { + return new Operation_Increase().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): Operation_Increase { + return new Operation_Increase().fromJsonString(jsonString, options); + } + + static equals(a: Operation_Increase | PlainMessage | undefined, b: Operation_Increase | PlainMessage | undefined): boolean { + return proto3.util.equals(Operation_Increase, a, b); + } +} + +/** + * @generated from message yorkie.v1.Operation.TreeEdit + */ +export class Operation_TreeEdit extends Message { + /** + * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1; + */ + parentCreatedAt?: TimeTicket; + + /** + * @generated from field: yorkie.v1.TreePos from = 2; + */ + from?: TreePos; + + /** + * @generated from field: yorkie.v1.TreePos to = 3; + */ + to?: TreePos; + + /** + * @generated from field: map created_at_map_by_actor = 4; + */ + createdAtMapByActor: { [key: string]: TimeTicket } = {}; + + /** + * @generated from field: repeated yorkie.v1.TreeNodes contents = 5; + */ + contents: TreeNodes[] = []; + + /** + * @generated from field: int32 split_level = 7; + */ + splitLevel = 0; + + /** + * @generated from field: yorkie.v1.TimeTicket executed_at = 6; + */ + executedAt?: TimeTicket; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.Operation.TreeEdit"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "parent_created_at", kind: "message", T: TimeTicket }, + { no: 2, name: "from", kind: "message", T: TreePos }, + { no: 3, name: "to", kind: "message", T: TreePos }, + { no: 4, name: "created_at_map_by_actor", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: TimeTicket} }, + { no: 5, name: "contents", kind: "message", T: TreeNodes, repeated: true }, + { no: 7, name: "split_level", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + { no: 6, name: "executed_at", kind: "message", T: TimeTicket }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): Operation_TreeEdit { + return new Operation_TreeEdit().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): Operation_TreeEdit { + return new Operation_TreeEdit().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): Operation_TreeEdit { + return new Operation_TreeEdit().fromJsonString(jsonString, options); + } + + static equals(a: Operation_TreeEdit | PlainMessage | undefined, b: Operation_TreeEdit | PlainMessage | undefined): boolean { + return proto3.util.equals(Operation_TreeEdit, a, b); + } +} + +/** + * @generated from message yorkie.v1.Operation.TreeStyle + */ +export class Operation_TreeStyle extends Message { + /** + * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1; + */ + parentCreatedAt?: TimeTicket; + + /** + * @generated from field: yorkie.v1.TreePos from = 2; + */ + from?: TreePos; + + /** + * @generated from field: yorkie.v1.TreePos to = 3; + */ + to?: TreePos; + + /** + * @generated from field: map attributes = 4; + */ + attributes: { [key: string]: string } = {}; + + /** + * @generated from field: yorkie.v1.TimeTicket executed_at = 5; + */ + executedAt?: TimeTicket; + + /** + * @generated from field: repeated string attributes_to_remove = 6; + */ + attributesToRemove: string[] = []; + + /** + * @generated from field: map created_at_map_by_actor = 7; + */ + createdAtMapByActor: { [key: string]: TimeTicket } = {}; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.Operation.TreeStyle"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "parent_created_at", kind: "message", T: TimeTicket }, + { no: 2, name: "from", kind: "message", T: TreePos }, + { no: 3, name: "to", kind: "message", T: TreePos }, + { no: 4, name: "attributes", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "scalar", T: 9 /* ScalarType.STRING */} }, + { no: 5, name: "executed_at", kind: "message", T: TimeTicket }, + { no: 6, name: "attributes_to_remove", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true }, + { no: 7, name: "created_at_map_by_actor", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: TimeTicket} }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): Operation_TreeStyle { + return new Operation_TreeStyle().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): Operation_TreeStyle { + return new Operation_TreeStyle().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): Operation_TreeStyle { + return new Operation_TreeStyle().fromJsonString(jsonString, options); + } + + static equals(a: Operation_TreeStyle | PlainMessage | undefined, b: Operation_TreeStyle | PlainMessage | undefined): boolean { + return proto3.util.equals(Operation_TreeStyle, a, b); + } +} + +/** + * @generated from message yorkie.v1.Operation.ArraySet + */ +export class Operation_ArraySet extends Message { + /** + * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1; + */ + parentCreatedAt?: TimeTicket; + + /** + * @generated from field: yorkie.v1.TimeTicket created_at = 2; + */ + createdAt?: TimeTicket; + + /** + * @generated from field: yorkie.v1.JSONElementSimple value = 3; + */ + value?: JSONElementSimple; + + /** + * @generated from field: yorkie.v1.TimeTicket executed_at = 4; + */ + executedAt?: TimeTicket; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.Operation.ArraySet"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "parent_created_at", kind: "message", T: TimeTicket }, + { no: 2, name: "created_at", kind: "message", T: TimeTicket }, + { no: 3, name: "value", kind: "message", T: JSONElementSimple }, + { no: 4, name: "executed_at", kind: "message", T: TimeTicket }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): Operation_ArraySet { + return new Operation_ArraySet().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): Operation_ArraySet { + return new Operation_ArraySet().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): Operation_ArraySet { + return new Operation_ArraySet().fromJsonString(jsonString, options); + } + + static equals(a: Operation_ArraySet | PlainMessage | undefined, b: Operation_ArraySet | PlainMessage | undefined): boolean { + return proto3.util.equals(Operation_ArraySet, a, b); + } +} + +/** + * @generated from message yorkie.v1.JSONElementSimple + */ +export class JSONElementSimple extends Message { + /** + * @generated from field: yorkie.v1.TimeTicket created_at = 1; + */ + createdAt?: TimeTicket; + + /** + * @generated from field: yorkie.v1.TimeTicket moved_at = 2; + */ + movedAt?: TimeTicket; + + /** + * @generated from field: yorkie.v1.TimeTicket removed_at = 3; + */ + removedAt?: TimeTicket; + + /** + * @generated from field: yorkie.v1.ValueType type = 4; + */ + type = ValueType.NULL; + + /** + * @generated from field: bytes value = 5; + */ + value = new Uint8Array(0); + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.JSONElementSimple"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "created_at", kind: "message", T: TimeTicket }, + { no: 2, name: "moved_at", kind: "message", T: TimeTicket }, + { no: 3, name: "removed_at", kind: "message", T: TimeTicket }, + { no: 4, name: "type", kind: "enum", T: proto3.getEnumType(ValueType) }, + { no: 5, name: "value", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): JSONElementSimple { + return new JSONElementSimple().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): JSONElementSimple { + return new JSONElementSimple().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): JSONElementSimple { + return new JSONElementSimple().fromJsonString(jsonString, options); + } + + static equals(a: JSONElementSimple | PlainMessage | undefined, b: JSONElementSimple | PlainMessage | undefined): boolean { + return proto3.util.equals(JSONElementSimple, a, b); + } +} + +/** + * @generated from message yorkie.v1.JSONElement + */ +export class JSONElement extends Message { + /** + * @generated from oneof yorkie.v1.JSONElement.body + */ + body: { + /** + * @generated from field: yorkie.v1.JSONElement.JSONObject json_object = 1; + */ + value: JSONElement_JSONObject; + case: "jsonObject"; + } | { + /** + * @generated from field: yorkie.v1.JSONElement.JSONArray json_array = 2; + */ + value: JSONElement_JSONArray; + case: "jsonArray"; + } | { + /** + * @generated from field: yorkie.v1.JSONElement.Primitive primitive = 3; + */ + value: JSONElement_Primitive; + case: "primitive"; + } | { + /** + * @generated from field: yorkie.v1.JSONElement.Text text = 5; + */ + value: JSONElement_Text; + case: "text"; + } | { + /** + * @generated from field: yorkie.v1.JSONElement.Counter counter = 6; + */ + value: JSONElement_Counter; + case: "counter"; + } | { + /** + * @generated from field: yorkie.v1.JSONElement.Tree tree = 7; + */ + value: JSONElement_Tree; + case: "tree"; + } | { case: undefined; value?: undefined } = { case: undefined }; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.JSONElement"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "json_object", kind: "message", T: JSONElement_JSONObject, oneof: "body" }, + { no: 2, name: "json_array", kind: "message", T: JSONElement_JSONArray, oneof: "body" }, + { no: 3, name: "primitive", kind: "message", T: JSONElement_Primitive, oneof: "body" }, + { no: 5, name: "text", kind: "message", T: JSONElement_Text, oneof: "body" }, + { no: 6, name: "counter", kind: "message", T: JSONElement_Counter, oneof: "body" }, + { no: 7, name: "tree", kind: "message", T: JSONElement_Tree, oneof: "body" }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): JSONElement { + return new JSONElement().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): JSONElement { + return new JSONElement().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): JSONElement { + return new JSONElement().fromJsonString(jsonString, options); + } + + static equals(a: JSONElement | PlainMessage | undefined, b: JSONElement | PlainMessage | undefined): boolean { + return proto3.util.equals(JSONElement, a, b); + } +} + +/** + * @generated from message yorkie.v1.JSONElement.JSONObject + */ +export class JSONElement_JSONObject extends Message { + /** + * @generated from field: repeated yorkie.v1.RHTNode nodes = 1; + */ + nodes: RHTNode[] = []; + + /** + * @generated from field: yorkie.v1.TimeTicket created_at = 2; + */ + createdAt?: TimeTicket; + + /** + * @generated from field: yorkie.v1.TimeTicket moved_at = 3; + */ + movedAt?: TimeTicket; + + /** + * @generated from field: yorkie.v1.TimeTicket removed_at = 4; + */ + removedAt?: TimeTicket; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.JSONElement.JSONObject"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "nodes", kind: "message", T: RHTNode, repeated: true }, + { no: 2, name: "created_at", kind: "message", T: TimeTicket }, + { no: 3, name: "moved_at", kind: "message", T: TimeTicket }, + { no: 4, name: "removed_at", kind: "message", T: TimeTicket }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): JSONElement_JSONObject { + return new JSONElement_JSONObject().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): JSONElement_JSONObject { + return new JSONElement_JSONObject().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): JSONElement_JSONObject { + return new JSONElement_JSONObject().fromJsonString(jsonString, options); + } + + static equals(a: JSONElement_JSONObject | PlainMessage | undefined, b: JSONElement_JSONObject | PlainMessage | undefined): boolean { + return proto3.util.equals(JSONElement_JSONObject, a, b); + } +} + +/** + * @generated from message yorkie.v1.JSONElement.JSONArray + */ +export class JSONElement_JSONArray extends Message { + /** + * @generated from field: repeated yorkie.v1.RGANode nodes = 1; + */ + nodes: RGANode[] = []; + + /** + * @generated from field: yorkie.v1.TimeTicket created_at = 2; + */ + createdAt?: TimeTicket; + + /** + * @generated from field: yorkie.v1.TimeTicket moved_at = 3; + */ + movedAt?: TimeTicket; + + /** + * @generated from field: yorkie.v1.TimeTicket removed_at = 4; + */ + removedAt?: TimeTicket; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.JSONElement.JSONArray"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "nodes", kind: "message", T: RGANode, repeated: true }, + { no: 2, name: "created_at", kind: "message", T: TimeTicket }, + { no: 3, name: "moved_at", kind: "message", T: TimeTicket }, + { no: 4, name: "removed_at", kind: "message", T: TimeTicket }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): JSONElement_JSONArray { + return new JSONElement_JSONArray().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): JSONElement_JSONArray { + return new JSONElement_JSONArray().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): JSONElement_JSONArray { + return new JSONElement_JSONArray().fromJsonString(jsonString, options); + } + + static equals(a: JSONElement_JSONArray | PlainMessage | undefined, b: JSONElement_JSONArray | PlainMessage | undefined): boolean { + return proto3.util.equals(JSONElement_JSONArray, a, b); + } +} + +/** + * @generated from message yorkie.v1.JSONElement.Primitive + */ +export class JSONElement_Primitive extends Message { + /** + * @generated from field: yorkie.v1.ValueType type = 1; + */ + type = ValueType.NULL; + + /** + * @generated from field: bytes value = 2; + */ + value = new Uint8Array(0); + + /** + * @generated from field: yorkie.v1.TimeTicket created_at = 3; + */ + createdAt?: TimeTicket; + + /** + * @generated from field: yorkie.v1.TimeTicket moved_at = 4; + */ + movedAt?: TimeTicket; + + /** + * @generated from field: yorkie.v1.TimeTicket removed_at = 5; + */ + removedAt?: TimeTicket; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.JSONElement.Primitive"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "type", kind: "enum", T: proto3.getEnumType(ValueType) }, + { no: 2, name: "value", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + { no: 3, name: "created_at", kind: "message", T: TimeTicket }, + { no: 4, name: "moved_at", kind: "message", T: TimeTicket }, + { no: 5, name: "removed_at", kind: "message", T: TimeTicket }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): JSONElement_Primitive { + return new JSONElement_Primitive().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): JSONElement_Primitive { + return new JSONElement_Primitive().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): JSONElement_Primitive { + return new JSONElement_Primitive().fromJsonString(jsonString, options); + } + + static equals(a: JSONElement_Primitive | PlainMessage | undefined, b: JSONElement_Primitive | PlainMessage | undefined): boolean { + return proto3.util.equals(JSONElement_Primitive, a, b); + } +} + +/** + * @generated from message yorkie.v1.JSONElement.Text + */ +export class JSONElement_Text extends Message { + /** + * @generated from field: repeated yorkie.v1.TextNode nodes = 1; + */ + nodes: TextNode[] = []; + + /** + * @generated from field: yorkie.v1.TimeTicket created_at = 2; + */ + createdAt?: TimeTicket; + + /** + * @generated from field: yorkie.v1.TimeTicket moved_at = 3; + */ + movedAt?: TimeTicket; + + /** + * @generated from field: yorkie.v1.TimeTicket removed_at = 4; + */ + removedAt?: TimeTicket; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.JSONElement.Text"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "nodes", kind: "message", T: TextNode, repeated: true }, + { no: 2, name: "created_at", kind: "message", T: TimeTicket }, + { no: 3, name: "moved_at", kind: "message", T: TimeTicket }, + { no: 4, name: "removed_at", kind: "message", T: TimeTicket }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): JSONElement_Text { + return new JSONElement_Text().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): JSONElement_Text { + return new JSONElement_Text().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): JSONElement_Text { + return new JSONElement_Text().fromJsonString(jsonString, options); + } + + static equals(a: JSONElement_Text | PlainMessage | undefined, b: JSONElement_Text | PlainMessage | undefined): boolean { + return proto3.util.equals(JSONElement_Text, a, b); + } +} + +/** + * @generated from message yorkie.v1.JSONElement.Counter + */ +export class JSONElement_Counter extends Message { + /** + * @generated from field: yorkie.v1.ValueType type = 1; + */ + type = ValueType.NULL; + + /** + * @generated from field: bytes value = 2; + */ + value = new Uint8Array(0); + + /** + * @generated from field: yorkie.v1.TimeTicket created_at = 3; + */ + createdAt?: TimeTicket; + + /** + * @generated from field: yorkie.v1.TimeTicket moved_at = 4; + */ + movedAt?: TimeTicket; + + /** + * @generated from field: yorkie.v1.TimeTicket removed_at = 5; + */ + removedAt?: TimeTicket; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.JSONElement.Counter"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "type", kind: "enum", T: proto3.getEnumType(ValueType) }, + { no: 2, name: "value", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + { no: 3, name: "created_at", kind: "message", T: TimeTicket }, + { no: 4, name: "moved_at", kind: "message", T: TimeTicket }, + { no: 5, name: "removed_at", kind: "message", T: TimeTicket }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): JSONElement_Counter { + return new JSONElement_Counter().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): JSONElement_Counter { + return new JSONElement_Counter().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): JSONElement_Counter { + return new JSONElement_Counter().fromJsonString(jsonString, options); + } + + static equals(a: JSONElement_Counter | PlainMessage | undefined, b: JSONElement_Counter | PlainMessage | undefined): boolean { + return proto3.util.equals(JSONElement_Counter, a, b); + } +} + +/** + * @generated from message yorkie.v1.JSONElement.Tree + */ +export class JSONElement_Tree extends Message { + /** + * @generated from field: repeated yorkie.v1.TreeNode nodes = 1; + */ + nodes: TreeNode[] = []; + + /** + * @generated from field: yorkie.v1.TimeTicket created_at = 2; + */ + createdAt?: TimeTicket; + + /** + * @generated from field: yorkie.v1.TimeTicket moved_at = 3; + */ + movedAt?: TimeTicket; + + /** + * @generated from field: yorkie.v1.TimeTicket removed_at = 4; + */ + removedAt?: TimeTicket; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.JSONElement.Tree"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "nodes", kind: "message", T: TreeNode, repeated: true }, + { no: 2, name: "created_at", kind: "message", T: TimeTicket }, + { no: 3, name: "moved_at", kind: "message", T: TimeTicket }, + { no: 4, name: "removed_at", kind: "message", T: TimeTicket }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): JSONElement_Tree { + return new JSONElement_Tree().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): JSONElement_Tree { + return new JSONElement_Tree().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): JSONElement_Tree { + return new JSONElement_Tree().fromJsonString(jsonString, options); + } + + static equals(a: JSONElement_Tree | PlainMessage | undefined, b: JSONElement_Tree | PlainMessage | undefined): boolean { + return proto3.util.equals(JSONElement_Tree, a, b); + } +} + +/** + * @generated from message yorkie.v1.RHTNode + */ +export class RHTNode extends Message { + /** + * @generated from field: string key = 1; + */ + key = ""; + + /** + * @generated from field: yorkie.v1.JSONElement element = 2; + */ + element?: JSONElement; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.RHTNode"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "key", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "element", kind: "message", T: JSONElement }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): RHTNode { + return new RHTNode().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): RHTNode { + return new RHTNode().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): RHTNode { + return new RHTNode().fromJsonString(jsonString, options); + } + + static equals(a: RHTNode | PlainMessage | undefined, b: RHTNode | PlainMessage | undefined): boolean { + return proto3.util.equals(RHTNode, a, b); + } +} + +/** + * @generated from message yorkie.v1.RGANode + */ +export class RGANode extends Message { + /** + * @generated from field: yorkie.v1.RGANode next = 1; + */ + next?: RGANode; + + /** + * @generated from field: yorkie.v1.JSONElement element = 2; + */ + element?: JSONElement; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.RGANode"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "next", kind: "message", T: RGANode }, + { no: 2, name: "element", kind: "message", T: JSONElement }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): RGANode { + return new RGANode().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): RGANode { + return new RGANode().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): RGANode { + return new RGANode().fromJsonString(jsonString, options); + } + + static equals(a: RGANode | PlainMessage | undefined, b: RGANode | PlainMessage | undefined): boolean { + return proto3.util.equals(RGANode, a, b); + } +} + +/** + * @generated from message yorkie.v1.NodeAttr + */ +export class NodeAttr extends Message { + /** + * @generated from field: string value = 1; + */ + value = ""; + + /** + * @generated from field: yorkie.v1.TimeTicket updated_at = 2; + */ + updatedAt?: TimeTicket; + + /** + * @generated from field: bool is_removed = 3; + */ + isRemoved = false; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.NodeAttr"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "value", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "updated_at", kind: "message", T: TimeTicket }, + { no: 3, name: "is_removed", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): NodeAttr { + return new NodeAttr().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): NodeAttr { + return new NodeAttr().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): NodeAttr { + return new NodeAttr().fromJsonString(jsonString, options); + } + + static equals(a: NodeAttr | PlainMessage | undefined, b: NodeAttr | PlainMessage | undefined): boolean { + return proto3.util.equals(NodeAttr, a, b); + } +} + +/** + * @generated from message yorkie.v1.TextNode + */ +export class TextNode extends Message { + /** + * @generated from field: yorkie.v1.TextNodeID id = 1; + */ + id?: TextNodeID; + + /** + * @generated from field: string value = 2; + */ + value = ""; + + /** + * @generated from field: yorkie.v1.TimeTicket removed_at = 3; + */ + removedAt?: TimeTicket; + + /** + * @generated from field: yorkie.v1.TextNodeID ins_prev_id = 4; + */ + insPrevId?: TextNodeID; + + /** + * @generated from field: map attributes = 5; + */ + attributes: { [key: string]: NodeAttr } = {}; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.TextNode"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "id", kind: "message", T: TextNodeID }, + { no: 2, name: "value", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "removed_at", kind: "message", T: TimeTicket }, + { no: 4, name: "ins_prev_id", kind: "message", T: TextNodeID }, + { no: 5, name: "attributes", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: NodeAttr} }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): TextNode { + return new TextNode().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): TextNode { + return new TextNode().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): TextNode { + return new TextNode().fromJsonString(jsonString, options); + } + + static equals(a: TextNode | PlainMessage | undefined, b: TextNode | PlainMessage | undefined): boolean { + return proto3.util.equals(TextNode, a, b); + } +} + +/** + * @generated from message yorkie.v1.TextNodeID + */ +export class TextNodeID extends Message { + /** + * @generated from field: yorkie.v1.TimeTicket created_at = 1; + */ + createdAt?: TimeTicket; + + /** + * @generated from field: int32 offset = 2; + */ + offset = 0; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.TextNodeID"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "created_at", kind: "message", T: TimeTicket }, + { no: 2, name: "offset", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): TextNodeID { + return new TextNodeID().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): TextNodeID { + return new TextNodeID().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): TextNodeID { + return new TextNodeID().fromJsonString(jsonString, options); + } + + static equals(a: TextNodeID | PlainMessage | undefined, b: TextNodeID | PlainMessage | undefined): boolean { + return proto3.util.equals(TextNodeID, a, b); + } +} + +/** + * @generated from message yorkie.v1.TreeNode + */ +export class TreeNode extends Message { + /** + * @generated from field: yorkie.v1.TreeNodeID id = 1; + */ + id?: TreeNodeID; + + /** + * @generated from field: string type = 2; + */ + type = ""; + + /** + * @generated from field: string value = 3; + */ + value = ""; + + /** + * @generated from field: yorkie.v1.TimeTicket removed_at = 4; + */ + removedAt?: TimeTicket; + + /** + * @generated from field: yorkie.v1.TreeNodeID ins_prev_id = 5; + */ + insPrevId?: TreeNodeID; + + /** + * @generated from field: yorkie.v1.TreeNodeID ins_next_id = 6; + */ + insNextId?: TreeNodeID; + + /** + * @generated from field: int32 depth = 7; + */ + depth = 0; + + /** + * @generated from field: map attributes = 8; + */ + attributes: { [key: string]: NodeAttr } = {}; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.TreeNode"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "id", kind: "message", T: TreeNodeID }, + { no: 2, name: "type", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "value", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 4, name: "removed_at", kind: "message", T: TimeTicket }, + { no: 5, name: "ins_prev_id", kind: "message", T: TreeNodeID }, + { no: 6, name: "ins_next_id", kind: "message", T: TreeNodeID }, + { no: 7, name: "depth", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + { no: 8, name: "attributes", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: NodeAttr} }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): TreeNode { + return new TreeNode().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): TreeNode { + return new TreeNode().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): TreeNode { + return new TreeNode().fromJsonString(jsonString, options); + } + + static equals(a: TreeNode | PlainMessage | undefined, b: TreeNode | PlainMessage | undefined): boolean { + return proto3.util.equals(TreeNode, a, b); + } +} + +/** + * @generated from message yorkie.v1.TreeNodes + */ +export class TreeNodes extends Message { + /** + * @generated from field: repeated yorkie.v1.TreeNode content = 1; + */ + content: TreeNode[] = []; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.TreeNodes"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "content", kind: "message", T: TreeNode, repeated: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): TreeNodes { + return new TreeNodes().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): TreeNodes { + return new TreeNodes().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): TreeNodes { + return new TreeNodes().fromJsonString(jsonString, options); + } + + static equals(a: TreeNodes | PlainMessage | undefined, b: TreeNodes | PlainMessage | undefined): boolean { + return proto3.util.equals(TreeNodes, a, b); + } +} + +/** + * @generated from message yorkie.v1.TreeNodeID + */ +export class TreeNodeID extends Message { + /** + * @generated from field: yorkie.v1.TimeTicket created_at = 1; + */ + createdAt?: TimeTicket; + + /** + * @generated from field: int32 offset = 2; + */ + offset = 0; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.TreeNodeID"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "created_at", kind: "message", T: TimeTicket }, + { no: 2, name: "offset", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): TreeNodeID { + return new TreeNodeID().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): TreeNodeID { + return new TreeNodeID().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): TreeNodeID { + return new TreeNodeID().fromJsonString(jsonString, options); + } + + static equals(a: TreeNodeID | PlainMessage | undefined, b: TreeNodeID | PlainMessage | undefined): boolean { + return proto3.util.equals(TreeNodeID, a, b); + } +} + +/** + * @generated from message yorkie.v1.TreePos + */ +export class TreePos extends Message { + /** + * @generated from field: yorkie.v1.TreeNodeID parent_id = 1; + */ + parentId?: TreeNodeID; + + /** + * @generated from field: yorkie.v1.TreeNodeID left_sibling_id = 2; + */ + leftSiblingId?: TreeNodeID; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.TreePos"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "parent_id", kind: "message", T: TreeNodeID }, + { no: 2, name: "left_sibling_id", kind: "message", T: TreeNodeID }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): TreePos { + return new TreePos().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): TreePos { + return new TreePos().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): TreePos { + return new TreePos().fromJsonString(jsonString, options); + } + + static equals(a: TreePos | PlainMessage | undefined, b: TreePos | PlainMessage | undefined): boolean { + return proto3.util.equals(TreePos, a, b); + } +} + +/** + * @generated from message yorkie.v1.User + */ +export class User extends Message { + /** + * @generated from field: string id = 1; + */ + id = ""; + + /** + * @generated from field: string username = 2; + */ + username = ""; + + /** + * @generated from field: google.protobuf.Timestamp created_at = 3; + */ + createdAt?: Timestamp; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.User"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "username", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "created_at", kind: "message", T: Timestamp }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): User { + return new User().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): User { + return new User().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): User { + return new User().fromJsonString(jsonString, options); + } + + static equals(a: User | PlainMessage | undefined, b: User | PlainMessage | undefined): boolean { + return proto3.util.equals(User, a, b); + } +} + +/** + * @generated from message yorkie.v1.Project + */ +export class Project extends Message { + /** + * @generated from field: string id = 1; + */ + id = ""; + + /** + * @generated from field: string name = 2; + */ + name = ""; + + /** + * @generated from field: string public_key = 3; + */ + publicKey = ""; + + /** + * @generated from field: string secret_key = 4; + */ + secretKey = ""; + + /** + * @generated from field: string auth_webhook_url = 5; + */ + authWebhookUrl = ""; + + /** + * @generated from field: repeated string auth_webhook_methods = 6; + */ + authWebhookMethods: string[] = []; + + /** + * @generated from field: string client_deactivate_threshold = 7; + */ + clientDeactivateThreshold = ""; + + /** + * @generated from field: google.protobuf.Timestamp created_at = 8; + */ + createdAt?: Timestamp; + + /** + * @generated from field: google.protobuf.Timestamp updated_at = 9; + */ + updatedAt?: Timestamp; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.Project"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "public_key", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 4, name: "secret_key", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 5, name: "auth_webhook_url", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 6, name: "auth_webhook_methods", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true }, + { no: 7, name: "client_deactivate_threshold", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 8, name: "created_at", kind: "message", T: Timestamp }, + { no: 9, name: "updated_at", kind: "message", T: Timestamp }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): Project { + return new Project().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): Project { + return new Project().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): Project { + return new Project().fromJsonString(jsonString, options); + } + + static equals(a: Project | PlainMessage | undefined, b: Project | PlainMessage | undefined): boolean { + return proto3.util.equals(Project, a, b); + } +} + +/** + * @generated from message yorkie.v1.UpdatableProjectFields + */ +export class UpdatableProjectFields extends Message { + /** + * @generated from field: google.protobuf.StringValue name = 1; + */ + name?: string; + + /** + * @generated from field: google.protobuf.StringValue auth_webhook_url = 2; + */ + authWebhookUrl?: string; + + /** + * @generated from field: yorkie.v1.UpdatableProjectFields.AuthWebhookMethods auth_webhook_methods = 3; + */ + authWebhookMethods?: UpdatableProjectFields_AuthWebhookMethods; + + /** + * @generated from field: google.protobuf.StringValue client_deactivate_threshold = 4; + */ + clientDeactivateThreshold?: string; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.UpdatableProjectFields"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "name", kind: "message", T: StringValue }, + { no: 2, name: "auth_webhook_url", kind: "message", T: StringValue }, + { no: 3, name: "auth_webhook_methods", kind: "message", T: UpdatableProjectFields_AuthWebhookMethods }, + { no: 4, name: "client_deactivate_threshold", kind: "message", T: StringValue }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): UpdatableProjectFields { + return new UpdatableProjectFields().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): UpdatableProjectFields { + return new UpdatableProjectFields().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): UpdatableProjectFields { + return new UpdatableProjectFields().fromJsonString(jsonString, options); + } + + static equals(a: UpdatableProjectFields | PlainMessage | undefined, b: UpdatableProjectFields | PlainMessage | undefined): boolean { + return proto3.util.equals(UpdatableProjectFields, a, b); + } +} + +/** + * @generated from message yorkie.v1.UpdatableProjectFields.AuthWebhookMethods + */ +export class UpdatableProjectFields_AuthWebhookMethods extends Message { + /** + * @generated from field: repeated string methods = 1; + */ + methods: string[] = []; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.UpdatableProjectFields.AuthWebhookMethods"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "methods", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): UpdatableProjectFields_AuthWebhookMethods { + return new UpdatableProjectFields_AuthWebhookMethods().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): UpdatableProjectFields_AuthWebhookMethods { + return new UpdatableProjectFields_AuthWebhookMethods().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): UpdatableProjectFields_AuthWebhookMethods { + return new UpdatableProjectFields_AuthWebhookMethods().fromJsonString(jsonString, options); + } + + static equals(a: UpdatableProjectFields_AuthWebhookMethods | PlainMessage | undefined, b: UpdatableProjectFields_AuthWebhookMethods | PlainMessage | undefined): boolean { + return proto3.util.equals(UpdatableProjectFields_AuthWebhookMethods, a, b); + } +} + +/** + * @generated from message yorkie.v1.DocumentSummary + */ +export class DocumentSummary extends Message { + /** + * @generated from field: string id = 1; + */ + id = ""; + + /** + * @generated from field: string key = 2; + */ + key = ""; + + /** + * @generated from field: string snapshot = 3; + */ + snapshot = ""; + + /** + * @generated from field: google.protobuf.Timestamp created_at = 4; + */ + createdAt?: Timestamp; + + /** + * @generated from field: google.protobuf.Timestamp accessed_at = 5; + */ + accessedAt?: Timestamp; + + /** + * @generated from field: google.protobuf.Timestamp updated_at = 6; + */ + updatedAt?: Timestamp; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.DocumentSummary"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "key", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "snapshot", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 4, name: "created_at", kind: "message", T: Timestamp }, + { no: 5, name: "accessed_at", kind: "message", T: Timestamp }, + { no: 6, name: "updated_at", kind: "message", T: Timestamp }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): DocumentSummary { + return new DocumentSummary().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): DocumentSummary { + return new DocumentSummary().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): DocumentSummary { + return new DocumentSummary().fromJsonString(jsonString, options); + } + + static equals(a: DocumentSummary | PlainMessage | undefined, b: DocumentSummary | PlainMessage | undefined): boolean { + return proto3.util.equals(DocumentSummary, a, b); + } +} + +/** + * @generated from message yorkie.v1.PresenceChange + */ +export class PresenceChange extends Message { + /** + * @generated from field: yorkie.v1.PresenceChange.ChangeType type = 1; + */ + type = PresenceChange_ChangeType.UNSPECIFIED; + + /** + * @generated from field: yorkie.v1.Presence presence = 2; + */ + presence?: Presence; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.PresenceChange"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "type", kind: "enum", T: proto3.getEnumType(PresenceChange_ChangeType) }, + { no: 2, name: "presence", kind: "message", T: Presence }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): PresenceChange { + return new PresenceChange().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): PresenceChange { + return new PresenceChange().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): PresenceChange { + return new PresenceChange().fromJsonString(jsonString, options); + } + + static equals(a: PresenceChange | PlainMessage | undefined, b: PresenceChange | PlainMessage | undefined): boolean { + return proto3.util.equals(PresenceChange, a, b); + } +} + +/** + * @generated from enum yorkie.v1.PresenceChange.ChangeType + */ +export enum PresenceChange_ChangeType { + /** + * @generated from enum value: CHANGE_TYPE_UNSPECIFIED = 0; + */ + UNSPECIFIED = 0, + + /** + * @generated from enum value: CHANGE_TYPE_PUT = 1; + */ + PUT = 1, + + /** + * @generated from enum value: CHANGE_TYPE_DELETE = 2; + */ + DELETE = 2, + + /** + * @generated from enum value: CHANGE_TYPE_CLEAR = 3; + */ + CLEAR = 3, +} +// Retrieve enum metadata with: proto3.getEnumType(PresenceChange_ChangeType) +proto3.util.setEnumType(PresenceChange_ChangeType, "yorkie.v1.PresenceChange.ChangeType", [ + { no: 0, name: "CHANGE_TYPE_UNSPECIFIED" }, + { no: 1, name: "CHANGE_TYPE_PUT" }, + { no: 2, name: "CHANGE_TYPE_DELETE" }, + { no: 3, name: "CHANGE_TYPE_CLEAR" }, +]); + +/** + * @generated from message yorkie.v1.Presence + */ +export class Presence extends Message { + /** + * @generated from field: map data = 1; + */ + data: { [key: string]: string } = {}; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.Presence"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "data", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "scalar", T: 9 /* ScalarType.STRING */} }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): Presence { + return new Presence().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): Presence { + return new Presence().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): Presence { + return new Presence().fromJsonString(jsonString, options); + } + + static equals(a: Presence | PlainMessage | undefined, b: Presence | PlainMessage | undefined): boolean { + return proto3.util.equals(Presence, a, b); + } +} + +/** + * @generated from message yorkie.v1.Checkpoint + */ +export class Checkpoint extends Message { + /** + * @generated from field: int64 server_seq = 1; + */ + serverSeq = protoInt64.zero; + + /** + * @generated from field: uint32 client_seq = 2; + */ + clientSeq = 0; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.Checkpoint"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "server_seq", kind: "scalar", T: 3 /* ScalarType.INT64 */ }, + { no: 2, name: "client_seq", kind: "scalar", T: 13 /* ScalarType.UINT32 */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): Checkpoint { + return new Checkpoint().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): Checkpoint { + return new Checkpoint().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): Checkpoint { + return new Checkpoint().fromJsonString(jsonString, options); + } + + static equals(a: Checkpoint | PlainMessage | undefined, b: Checkpoint | PlainMessage | undefined): boolean { + return proto3.util.equals(Checkpoint, a, b); + } +} + +/** + * @generated from message yorkie.v1.TextNodePos + */ +export class TextNodePos extends Message { + /** + * @generated from field: yorkie.v1.TimeTicket created_at = 1; + */ + createdAt?: TimeTicket; + + /** + * @generated from field: int32 offset = 2; + */ + offset = 0; + + /** + * @generated from field: int32 relative_offset = 3; + */ + relativeOffset = 0; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.TextNodePos"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "created_at", kind: "message", T: TimeTicket }, + { no: 2, name: "offset", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + { no: 3, name: "relative_offset", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): TextNodePos { + return new TextNodePos().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): TextNodePos { + return new TextNodePos().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): TextNodePos { + return new TextNodePos().fromJsonString(jsonString, options); + } + + static equals(a: TextNodePos | PlainMessage | undefined, b: TextNodePos | PlainMessage | undefined): boolean { + return proto3.util.equals(TextNodePos, a, b); + } +} + +/** + * @generated from message yorkie.v1.TimeTicket + */ +export class TimeTicket extends Message { + /** + * @generated from field: int64 lamport = 1; + */ + lamport = protoInt64.zero; + + /** + * @generated from field: uint32 delimiter = 2; + */ + delimiter = 0; + + /** + * @generated from field: bytes actor_id = 3; + */ + actorId = new Uint8Array(0); + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.TimeTicket"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "lamport", kind: "scalar", T: 3 /* ScalarType.INT64 */ }, + { no: 2, name: "delimiter", kind: "scalar", T: 13 /* ScalarType.UINT32 */ }, + { no: 3, name: "actor_id", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): TimeTicket { + return new TimeTicket().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): TimeTicket { + return new TimeTicket().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): TimeTicket { + return new TimeTicket().fromJsonString(jsonString, options); + } + + static equals(a: TimeTicket | PlainMessage | undefined, b: TimeTicket | PlainMessage | undefined): boolean { + return proto3.util.equals(TimeTicket, a, b); + } +} + +/** + * @generated from message yorkie.v1.DocEventBody + */ +export class DocEventBody extends Message { + /** + * @generated from field: string topic = 1; + */ + topic = ""; + + /** + * @generated from field: bytes payload = 2; + */ + payload = new Uint8Array(0); + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.DocEventBody"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "topic", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "payload", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): DocEventBody { + return new DocEventBody().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): DocEventBody { + return new DocEventBody().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): DocEventBody { + return new DocEventBody().fromJsonString(jsonString, options); + } + + static equals(a: DocEventBody | PlainMessage | undefined, b: DocEventBody | PlainMessage | undefined): boolean { + return proto3.util.equals(DocEventBody, a, b); + } +} + +/** + * @generated from message yorkie.v1.DocEvent + */ +export class DocEvent extends Message { + /** + * @generated from field: yorkie.v1.DocEventType type = 1; + */ + type = DocEventType.DOCUMENT_CHANGED; + + /** + * @generated from field: string publisher = 2; + */ + publisher = ""; + + /** + * @generated from field: yorkie.v1.DocEventBody body = 3; + */ + body?: DocEventBody; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.DocEvent"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "type", kind: "enum", T: proto3.getEnumType(DocEventType) }, + { no: 2, name: "publisher", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "body", kind: "message", T: DocEventBody }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): DocEvent { + return new DocEvent().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): DocEvent { + return new DocEvent().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): DocEvent { + return new DocEvent().fromJsonString(jsonString, options); + } + + static equals(a: DocEvent | PlainMessage | undefined, b: DocEvent | PlainMessage | undefined): boolean { + return proto3.util.equals(DocEvent, a, b); + } +} + diff --git a/packages/sdk/src/api/yorkie/v1/yorkie.proto b/packages/sdk/src/api/yorkie/v1/yorkie.proto index 279f96f98..34281d342 100644 --- a/packages/sdk/src/api/yorkie/v1/yorkie.proto +++ b/packages/sdk/src/api/yorkie/v1/yorkie.proto @@ -24,7 +24,7 @@ option go_package = "github.com/yorkie-team/yorkie/api/yorkie/v1;v1"; option java_multiple_files = true; option java_package = "dev.yorkie.api.v1"; -// Yorkie is a service that provides a API for SDKs. +// Yorkie is a service that provides an API for SDKs. service YorkieService { rpc ActivateClient (ActivateClientRequest) returns (ActivateClientResponse) {} rpc DeactivateClient (DeactivateClientRequest) returns (DeactivateClientResponse) {} diff --git a/packages/sdk/src/api/yorkie/v1/yorkie_connect.d.ts b/packages/sdk/src/api/yorkie/v1/yorkie_connect.d.ts deleted file mode 100644 index 3bb2e01ea..000000000 --- a/packages/sdk/src/api/yorkie/v1/yorkie_connect.d.ts +++ /dev/null @@ -1,106 +0,0 @@ -// -// Copyright 2020 The Yorkie Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// @generated by protoc-gen-connect-es v1.2.0 with parameter "target=js+dts,js_import_style=module" -// @generated from file src/api/yorkie/v1/yorkie.proto (package yorkie.v1, syntax proto3) -/* eslint-disable */ -// @ts-nocheck - -import { ActivateClientRequest, ActivateClientResponse, AttachDocumentRequest, AttachDocumentResponse, BroadcastRequest, BroadcastResponse, DeactivateClientRequest, DeactivateClientResponse, DetachDocumentRequest, DetachDocumentResponse, PushPullChangesRequest, PushPullChangesResponse, RemoveDocumentRequest, RemoveDocumentResponse, WatchDocumentRequest, WatchDocumentResponse } from "./yorkie_pb.js"; -import { MethodKind } from "@bufbuild/protobuf"; - -/** - * Yorkie is a service that provides a API for SDKs. - * - * @generated from service yorkie.v1.YorkieService - */ -export declare const YorkieService: { - readonly typeName: "yorkie.v1.YorkieService", - readonly methods: { - /** - * @generated from rpc yorkie.v1.YorkieService.ActivateClient - */ - readonly activateClient: { - readonly name: "ActivateClient", - readonly I: typeof ActivateClientRequest, - readonly O: typeof ActivateClientResponse, - readonly kind: MethodKind.Unary, - }, - /** - * @generated from rpc yorkie.v1.YorkieService.DeactivateClient - */ - readonly deactivateClient: { - readonly name: "DeactivateClient", - readonly I: typeof DeactivateClientRequest, - readonly O: typeof DeactivateClientResponse, - readonly kind: MethodKind.Unary, - }, - /** - * @generated from rpc yorkie.v1.YorkieService.AttachDocument - */ - readonly attachDocument: { - readonly name: "AttachDocument", - readonly I: typeof AttachDocumentRequest, - readonly O: typeof AttachDocumentResponse, - readonly kind: MethodKind.Unary, - }, - /** - * @generated from rpc yorkie.v1.YorkieService.DetachDocument - */ - readonly detachDocument: { - readonly name: "DetachDocument", - readonly I: typeof DetachDocumentRequest, - readonly O: typeof DetachDocumentResponse, - readonly kind: MethodKind.Unary, - }, - /** - * @generated from rpc yorkie.v1.YorkieService.RemoveDocument - */ - readonly removeDocument: { - readonly name: "RemoveDocument", - readonly I: typeof RemoveDocumentRequest, - readonly O: typeof RemoveDocumentResponse, - readonly kind: MethodKind.Unary, - }, - /** - * @generated from rpc yorkie.v1.YorkieService.PushPullChanges - */ - readonly pushPullChanges: { - readonly name: "PushPullChanges", - readonly I: typeof PushPullChangesRequest, - readonly O: typeof PushPullChangesResponse, - readonly kind: MethodKind.Unary, - }, - /** - * @generated from rpc yorkie.v1.YorkieService.WatchDocument - */ - readonly watchDocument: { - readonly name: "WatchDocument", - readonly I: typeof WatchDocumentRequest, - readonly O: typeof WatchDocumentResponse, - readonly kind: MethodKind.ServerStreaming, - }, - /** - * @generated from rpc yorkie.v1.YorkieService.Broadcast - */ - readonly broadcast: { - readonly name: "Broadcast", - readonly I: typeof BroadcastRequest, - readonly O: typeof BroadcastResponse, - readonly kind: MethodKind.Unary, - }, - } -}; - diff --git a/packages/sdk/src/api/yorkie/v1/yorkie_connect.js b/packages/sdk/src/api/yorkie/v1/yorkie_connect.ts similarity index 94% rename from packages/sdk/src/api/yorkie/v1/yorkie_connect.js rename to packages/sdk/src/api/yorkie/v1/yorkie_connect.ts index 49e24a07b..a02610c3e 100644 --- a/packages/sdk/src/api/yorkie/v1/yorkie_connect.js +++ b/packages/sdk/src/api/yorkie/v1/yorkie_connect.ts @@ -13,16 +13,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -// @generated by protoc-gen-connect-es v1.2.0 with parameter "target=js+dts,js_import_style=module" +// @generated by protoc-gen-connect-es v1.4.0 with parameter "target=ts,import_extension=none" // @generated from file src/api/yorkie/v1/yorkie.proto (package yorkie.v1, syntax proto3) /* eslint-disable */ // @ts-nocheck -import { ActivateClientRequest, ActivateClientResponse, AttachDocumentRequest, AttachDocumentResponse, BroadcastRequest, BroadcastResponse, DeactivateClientRequest, DeactivateClientResponse, DetachDocumentRequest, DetachDocumentResponse, PushPullChangesRequest, PushPullChangesResponse, RemoveDocumentRequest, RemoveDocumentResponse, WatchDocumentRequest, WatchDocumentResponse } from "./yorkie_pb.js"; +import { ActivateClientRequest, ActivateClientResponse, AttachDocumentRequest, AttachDocumentResponse, BroadcastRequest, BroadcastResponse, DeactivateClientRequest, DeactivateClientResponse, DetachDocumentRequest, DetachDocumentResponse, PushPullChangesRequest, PushPullChangesResponse, RemoveDocumentRequest, RemoveDocumentResponse, WatchDocumentRequest, WatchDocumentResponse } from "./yorkie_pb"; import { MethodKind } from "@bufbuild/protobuf"; /** - * Yorkie is a service that provides a API for SDKs. + * Yorkie is a service that provides an API for SDKs. * * @generated from service yorkie.v1.YorkieService */ @@ -102,5 +102,5 @@ export const YorkieService = { kind: MethodKind.Unary, }, } -}; +} as const; diff --git a/packages/sdk/src/api/yorkie/v1/yorkie_pb.d.ts b/packages/sdk/src/api/yorkie/v1/yorkie_pb.d.ts deleted file mode 100644 index fa54d0267..000000000 --- a/packages/sdk/src/api/yorkie/v1/yorkie_pb.d.ts +++ /dev/null @@ -1,504 +0,0 @@ -// -// Copyright 2020 The Yorkie Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// @generated by protoc-gen-es v1.6.0 with parameter "target=js+dts,js_import_style=module" -// @generated from file src/api/yorkie/v1/yorkie.proto (package yorkie.v1, syntax proto3) -/* eslint-disable */ -// @ts-nocheck - -import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; -import { Message, proto3 } from "@bufbuild/protobuf"; -import type { ChangePack, DocEvent } from "./resources_pb.js"; - -/** - * @generated from message yorkie.v1.ActivateClientRequest - */ -export declare class ActivateClientRequest extends Message { - /** - * @generated from field: string client_key = 1; - */ - clientKey: string; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.ActivateClientRequest"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): ActivateClientRequest; - - static fromJson(jsonValue: JsonValue, options?: Partial): ActivateClientRequest; - - static fromJsonString(jsonString: string, options?: Partial): ActivateClientRequest; - - static equals(a: ActivateClientRequest | PlainMessage | undefined, b: ActivateClientRequest | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.ActivateClientResponse - */ -export declare class ActivateClientResponse extends Message { - /** - * @generated from field: string client_id = 1; - */ - clientId: string; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.ActivateClientResponse"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): ActivateClientResponse; - - static fromJson(jsonValue: JsonValue, options?: Partial): ActivateClientResponse; - - static fromJsonString(jsonString: string, options?: Partial): ActivateClientResponse; - - static equals(a: ActivateClientResponse | PlainMessage | undefined, b: ActivateClientResponse | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.DeactivateClientRequest - */ -export declare class DeactivateClientRequest extends Message { - /** - * @generated from field: string client_id = 1; - */ - clientId: string; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.DeactivateClientRequest"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): DeactivateClientRequest; - - static fromJson(jsonValue: JsonValue, options?: Partial): DeactivateClientRequest; - - static fromJsonString(jsonString: string, options?: Partial): DeactivateClientRequest; - - static equals(a: DeactivateClientRequest | PlainMessage | undefined, b: DeactivateClientRequest | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.DeactivateClientResponse - */ -export declare class DeactivateClientResponse extends Message { - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.DeactivateClientResponse"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): DeactivateClientResponse; - - static fromJson(jsonValue: JsonValue, options?: Partial): DeactivateClientResponse; - - static fromJsonString(jsonString: string, options?: Partial): DeactivateClientResponse; - - static equals(a: DeactivateClientResponse | PlainMessage | undefined, b: DeactivateClientResponse | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.AttachDocumentRequest - */ -export declare class AttachDocumentRequest extends Message { - /** - * @generated from field: string client_id = 1; - */ - clientId: string; - - /** - * @generated from field: yorkie.v1.ChangePack change_pack = 2; - */ - changePack?: ChangePack; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.AttachDocumentRequest"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): AttachDocumentRequest; - - static fromJson(jsonValue: JsonValue, options?: Partial): AttachDocumentRequest; - - static fromJsonString(jsonString: string, options?: Partial): AttachDocumentRequest; - - static equals(a: AttachDocumentRequest | PlainMessage | undefined, b: AttachDocumentRequest | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.AttachDocumentResponse - */ -export declare class AttachDocumentResponse extends Message { - /** - * @generated from field: string document_id = 1; - */ - documentId: string; - - /** - * @generated from field: yorkie.v1.ChangePack change_pack = 2; - */ - changePack?: ChangePack; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.AttachDocumentResponse"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): AttachDocumentResponse; - - static fromJson(jsonValue: JsonValue, options?: Partial): AttachDocumentResponse; - - static fromJsonString(jsonString: string, options?: Partial): AttachDocumentResponse; - - static equals(a: AttachDocumentResponse | PlainMessage | undefined, b: AttachDocumentResponse | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.DetachDocumentRequest - */ -export declare class DetachDocumentRequest extends Message { - /** - * @generated from field: string client_id = 1; - */ - clientId: string; - - /** - * @generated from field: string document_id = 2; - */ - documentId: string; - - /** - * @generated from field: yorkie.v1.ChangePack change_pack = 3; - */ - changePack?: ChangePack; - - /** - * @generated from field: bool remove_if_not_attached = 4; - */ - removeIfNotAttached: boolean; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.DetachDocumentRequest"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): DetachDocumentRequest; - - static fromJson(jsonValue: JsonValue, options?: Partial): DetachDocumentRequest; - - static fromJsonString(jsonString: string, options?: Partial): DetachDocumentRequest; - - static equals(a: DetachDocumentRequest | PlainMessage | undefined, b: DetachDocumentRequest | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.DetachDocumentResponse - */ -export declare class DetachDocumentResponse extends Message { - /** - * @generated from field: yorkie.v1.ChangePack change_pack = 2; - */ - changePack?: ChangePack; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.DetachDocumentResponse"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): DetachDocumentResponse; - - static fromJson(jsonValue: JsonValue, options?: Partial): DetachDocumentResponse; - - static fromJsonString(jsonString: string, options?: Partial): DetachDocumentResponse; - - static equals(a: DetachDocumentResponse | PlainMessage | undefined, b: DetachDocumentResponse | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.WatchDocumentRequest - */ -export declare class WatchDocumentRequest extends Message { - /** - * @generated from field: string client_id = 1; - */ - clientId: string; - - /** - * @generated from field: string document_id = 2; - */ - documentId: string; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.WatchDocumentRequest"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): WatchDocumentRequest; - - static fromJson(jsonValue: JsonValue, options?: Partial): WatchDocumentRequest; - - static fromJsonString(jsonString: string, options?: Partial): WatchDocumentRequest; - - static equals(a: WatchDocumentRequest | PlainMessage | undefined, b: WatchDocumentRequest | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.WatchDocumentResponse - */ -export declare class WatchDocumentResponse extends Message { - /** - * @generated from oneof yorkie.v1.WatchDocumentResponse.body - */ - body: { - /** - * @generated from field: yorkie.v1.WatchDocumentResponse.Initialization initialization = 1; - */ - value: WatchDocumentResponse_Initialization; - case: "initialization"; - } | { - /** - * @generated from field: yorkie.v1.DocEvent event = 2; - */ - value: DocEvent; - case: "event"; - } | { case: undefined; value?: undefined }; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.WatchDocumentResponse"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): WatchDocumentResponse; - - static fromJson(jsonValue: JsonValue, options?: Partial): WatchDocumentResponse; - - static fromJsonString(jsonString: string, options?: Partial): WatchDocumentResponse; - - static equals(a: WatchDocumentResponse | PlainMessage | undefined, b: WatchDocumentResponse | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.WatchDocumentResponse.Initialization - */ -export declare class WatchDocumentResponse_Initialization extends Message { - /** - * @generated from field: repeated string client_ids = 1; - */ - clientIds: string[]; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.WatchDocumentResponse.Initialization"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): WatchDocumentResponse_Initialization; - - static fromJson(jsonValue: JsonValue, options?: Partial): WatchDocumentResponse_Initialization; - - static fromJsonString(jsonString: string, options?: Partial): WatchDocumentResponse_Initialization; - - static equals(a: WatchDocumentResponse_Initialization | PlainMessage | undefined, b: WatchDocumentResponse_Initialization | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.RemoveDocumentRequest - */ -export declare class RemoveDocumentRequest extends Message { - /** - * @generated from field: string client_id = 1; - */ - clientId: string; - - /** - * @generated from field: string document_id = 2; - */ - documentId: string; - - /** - * @generated from field: yorkie.v1.ChangePack change_pack = 3; - */ - changePack?: ChangePack; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.RemoveDocumentRequest"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): RemoveDocumentRequest; - - static fromJson(jsonValue: JsonValue, options?: Partial): RemoveDocumentRequest; - - static fromJsonString(jsonString: string, options?: Partial): RemoveDocumentRequest; - - static equals(a: RemoveDocumentRequest | PlainMessage | undefined, b: RemoveDocumentRequest | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.RemoveDocumentResponse - */ -export declare class RemoveDocumentResponse extends Message { - /** - * @generated from field: yorkie.v1.ChangePack change_pack = 1; - */ - changePack?: ChangePack; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.RemoveDocumentResponse"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): RemoveDocumentResponse; - - static fromJson(jsonValue: JsonValue, options?: Partial): RemoveDocumentResponse; - - static fromJsonString(jsonString: string, options?: Partial): RemoveDocumentResponse; - - static equals(a: RemoveDocumentResponse | PlainMessage | undefined, b: RemoveDocumentResponse | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.PushPullChangesRequest - */ -export declare class PushPullChangesRequest extends Message { - /** - * @generated from field: string client_id = 1; - */ - clientId: string; - - /** - * @generated from field: string document_id = 2; - */ - documentId: string; - - /** - * @generated from field: yorkie.v1.ChangePack change_pack = 3; - */ - changePack?: ChangePack; - - /** - * @generated from field: bool push_only = 4; - */ - pushOnly: boolean; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.PushPullChangesRequest"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): PushPullChangesRequest; - - static fromJson(jsonValue: JsonValue, options?: Partial): PushPullChangesRequest; - - static fromJsonString(jsonString: string, options?: Partial): PushPullChangesRequest; - - static equals(a: PushPullChangesRequest | PlainMessage | undefined, b: PushPullChangesRequest | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.PushPullChangesResponse - */ -export declare class PushPullChangesResponse extends Message { - /** - * @generated from field: yorkie.v1.ChangePack change_pack = 1; - */ - changePack?: ChangePack; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.PushPullChangesResponse"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): PushPullChangesResponse; - - static fromJson(jsonValue: JsonValue, options?: Partial): PushPullChangesResponse; - - static fromJsonString(jsonString: string, options?: Partial): PushPullChangesResponse; - - static equals(a: PushPullChangesResponse | PlainMessage | undefined, b: PushPullChangesResponse | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.BroadcastRequest - */ -export declare class BroadcastRequest extends Message { - /** - * @generated from field: string client_id = 1; - */ - clientId: string; - - /** - * @generated from field: string document_id = 2; - */ - documentId: string; - - /** - * @generated from field: string topic = 3; - */ - topic: string; - - /** - * @generated from field: bytes payload = 4; - */ - payload: Uint8Array; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.BroadcastRequest"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): BroadcastRequest; - - static fromJson(jsonValue: JsonValue, options?: Partial): BroadcastRequest; - - static fromJsonString(jsonString: string, options?: Partial): BroadcastRequest; - - static equals(a: BroadcastRequest | PlainMessage | undefined, b: BroadcastRequest | PlainMessage | undefined): boolean; -} - -/** - * @generated from message yorkie.v1.BroadcastResponse - */ -export declare class BroadcastResponse extends Message { - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "yorkie.v1.BroadcastResponse"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): BroadcastResponse; - - static fromJson(jsonValue: JsonValue, options?: Partial): BroadcastResponse; - - static fromJsonString(jsonString: string, options?: Partial): BroadcastResponse; - - static equals(a: BroadcastResponse | PlainMessage | undefined, b: BroadcastResponse | PlainMessage | undefined): boolean; -} - diff --git a/packages/sdk/src/api/yorkie/v1/yorkie_pb.js b/packages/sdk/src/api/yorkie/v1/yorkie_pb.js deleted file mode 100644 index 95abb98d2..000000000 --- a/packages/sdk/src/api/yorkie/v1/yorkie_pb.js +++ /dev/null @@ -1,205 +0,0 @@ -// -// Copyright 2020 The Yorkie Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// @generated by protoc-gen-es v1.6.0 with parameter "target=js+dts,js_import_style=module" -// @generated from file src/api/yorkie/v1/yorkie.proto (package yorkie.v1, syntax proto3) -/* eslint-disable */ -// @ts-nocheck - -import { proto3 } from "@bufbuild/protobuf"; -import { ChangePack, DocEvent } from "./resources_pb.js"; - -/** - * @generated from message yorkie.v1.ActivateClientRequest - */ -export const ActivateClientRequest = proto3.makeMessageType( - "yorkie.v1.ActivateClientRequest", - () => [ - { no: 1, name: "client_key", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - ], -); - -/** - * @generated from message yorkie.v1.ActivateClientResponse - */ -export const ActivateClientResponse = proto3.makeMessageType( - "yorkie.v1.ActivateClientResponse", - () => [ - { no: 1, name: "client_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - ], -); - -/** - * @generated from message yorkie.v1.DeactivateClientRequest - */ -export const DeactivateClientRequest = proto3.makeMessageType( - "yorkie.v1.DeactivateClientRequest", - () => [ - { no: 1, name: "client_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - ], -); - -/** - * @generated from message yorkie.v1.DeactivateClientResponse - */ -export const DeactivateClientResponse = proto3.makeMessageType( - "yorkie.v1.DeactivateClientResponse", - [], -); - -/** - * @generated from message yorkie.v1.AttachDocumentRequest - */ -export const AttachDocumentRequest = proto3.makeMessageType( - "yorkie.v1.AttachDocumentRequest", - () => [ - { no: 1, name: "client_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 2, name: "change_pack", kind: "message", T: ChangePack }, - ], -); - -/** - * @generated from message yorkie.v1.AttachDocumentResponse - */ -export const AttachDocumentResponse = proto3.makeMessageType( - "yorkie.v1.AttachDocumentResponse", - () => [ - { no: 1, name: "document_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 2, name: "change_pack", kind: "message", T: ChangePack }, - ], -); - -/** - * @generated from message yorkie.v1.DetachDocumentRequest - */ -export const DetachDocumentRequest = proto3.makeMessageType( - "yorkie.v1.DetachDocumentRequest", - () => [ - { no: 1, name: "client_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 2, name: "document_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 3, name: "change_pack", kind: "message", T: ChangePack }, - { no: 4, name: "remove_if_not_attached", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, - ], -); - -/** - * @generated from message yorkie.v1.DetachDocumentResponse - */ -export const DetachDocumentResponse = proto3.makeMessageType( - "yorkie.v1.DetachDocumentResponse", - () => [ - { no: 2, name: "change_pack", kind: "message", T: ChangePack }, - ], -); - -/** - * @generated from message yorkie.v1.WatchDocumentRequest - */ -export const WatchDocumentRequest = proto3.makeMessageType( - "yorkie.v1.WatchDocumentRequest", - () => [ - { no: 1, name: "client_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 2, name: "document_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - ], -); - -/** - * @generated from message yorkie.v1.WatchDocumentResponse - */ -export const WatchDocumentResponse = proto3.makeMessageType( - "yorkie.v1.WatchDocumentResponse", - () => [ - { no: 1, name: "initialization", kind: "message", T: WatchDocumentResponse_Initialization, oneof: "body" }, - { no: 2, name: "event", kind: "message", T: DocEvent, oneof: "body" }, - ], -); - -/** - * @generated from message yorkie.v1.WatchDocumentResponse.Initialization - */ -export const WatchDocumentResponse_Initialization = proto3.makeMessageType( - "yorkie.v1.WatchDocumentResponse.Initialization", - () => [ - { no: 1, name: "client_ids", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true }, - ], - {localName: "WatchDocumentResponse_Initialization"}, -); - -/** - * @generated from message yorkie.v1.RemoveDocumentRequest - */ -export const RemoveDocumentRequest = proto3.makeMessageType( - "yorkie.v1.RemoveDocumentRequest", - () => [ - { no: 1, name: "client_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 2, name: "document_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 3, name: "change_pack", kind: "message", T: ChangePack }, - ], -); - -/** - * @generated from message yorkie.v1.RemoveDocumentResponse - */ -export const RemoveDocumentResponse = proto3.makeMessageType( - "yorkie.v1.RemoveDocumentResponse", - () => [ - { no: 1, name: "change_pack", kind: "message", T: ChangePack }, - ], -); - -/** - * @generated from message yorkie.v1.PushPullChangesRequest - */ -export const PushPullChangesRequest = proto3.makeMessageType( - "yorkie.v1.PushPullChangesRequest", - () => [ - { no: 1, name: "client_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 2, name: "document_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 3, name: "change_pack", kind: "message", T: ChangePack }, - { no: 4, name: "push_only", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, - ], -); - -/** - * @generated from message yorkie.v1.PushPullChangesResponse - */ -export const PushPullChangesResponse = proto3.makeMessageType( - "yorkie.v1.PushPullChangesResponse", - () => [ - { no: 1, name: "change_pack", kind: "message", T: ChangePack }, - ], -); - -/** - * @generated from message yorkie.v1.BroadcastRequest - */ -export const BroadcastRequest = proto3.makeMessageType( - "yorkie.v1.BroadcastRequest", - () => [ - { no: 1, name: "client_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 2, name: "document_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 3, name: "topic", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 4, name: "payload", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, - ], -); - -/** - * @generated from message yorkie.v1.BroadcastResponse - */ -export const BroadcastResponse = proto3.makeMessageType( - "yorkie.v1.BroadcastResponse", - [], -); - diff --git a/packages/sdk/src/api/yorkie/v1/yorkie_pb.ts b/packages/sdk/src/api/yorkie/v1/yorkie_pb.ts new file mode 100644 index 000000000..3b006074a --- /dev/null +++ b/packages/sdk/src/api/yorkie/v1/yorkie_pb.ts @@ -0,0 +1,738 @@ +// +// Copyright 2020 The Yorkie Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// @generated by protoc-gen-es v1.10.0 with parameter "target=ts,import_extension=none" +// @generated from file src/api/yorkie/v1/yorkie.proto (package yorkie.v1, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3 } from "@bufbuild/protobuf"; +import { ChangePack, DocEvent } from "./resources_pb"; + +/** + * @generated from message yorkie.v1.ActivateClientRequest + */ +export class ActivateClientRequest extends Message { + /** + * @generated from field: string client_key = 1; + */ + clientKey = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.ActivateClientRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "client_key", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): ActivateClientRequest { + return new ActivateClientRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): ActivateClientRequest { + return new ActivateClientRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): ActivateClientRequest { + return new ActivateClientRequest().fromJsonString(jsonString, options); + } + + static equals(a: ActivateClientRequest | PlainMessage | undefined, b: ActivateClientRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(ActivateClientRequest, a, b); + } +} + +/** + * @generated from message yorkie.v1.ActivateClientResponse + */ +export class ActivateClientResponse extends Message { + /** + * @generated from field: string client_id = 1; + */ + clientId = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.ActivateClientResponse"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "client_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): ActivateClientResponse { + return new ActivateClientResponse().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): ActivateClientResponse { + return new ActivateClientResponse().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): ActivateClientResponse { + return new ActivateClientResponse().fromJsonString(jsonString, options); + } + + static equals(a: ActivateClientResponse | PlainMessage | undefined, b: ActivateClientResponse | PlainMessage | undefined): boolean { + return proto3.util.equals(ActivateClientResponse, a, b); + } +} + +/** + * @generated from message yorkie.v1.DeactivateClientRequest + */ +export class DeactivateClientRequest extends Message { + /** + * @generated from field: string client_id = 1; + */ + clientId = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.DeactivateClientRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "client_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): DeactivateClientRequest { + return new DeactivateClientRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): DeactivateClientRequest { + return new DeactivateClientRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): DeactivateClientRequest { + return new DeactivateClientRequest().fromJsonString(jsonString, options); + } + + static equals(a: DeactivateClientRequest | PlainMessage | undefined, b: DeactivateClientRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(DeactivateClientRequest, a, b); + } +} + +/** + * @generated from message yorkie.v1.DeactivateClientResponse + */ +export class DeactivateClientResponse extends Message { + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.DeactivateClientResponse"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): DeactivateClientResponse { + return new DeactivateClientResponse().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): DeactivateClientResponse { + return new DeactivateClientResponse().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): DeactivateClientResponse { + return new DeactivateClientResponse().fromJsonString(jsonString, options); + } + + static equals(a: DeactivateClientResponse | PlainMessage | undefined, b: DeactivateClientResponse | PlainMessage | undefined): boolean { + return proto3.util.equals(DeactivateClientResponse, a, b); + } +} + +/** + * @generated from message yorkie.v1.AttachDocumentRequest + */ +export class AttachDocumentRequest extends Message { + /** + * @generated from field: string client_id = 1; + */ + clientId = ""; + + /** + * @generated from field: yorkie.v1.ChangePack change_pack = 2; + */ + changePack?: ChangePack; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.AttachDocumentRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "client_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "change_pack", kind: "message", T: ChangePack }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): AttachDocumentRequest { + return new AttachDocumentRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): AttachDocumentRequest { + return new AttachDocumentRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): AttachDocumentRequest { + return new AttachDocumentRequest().fromJsonString(jsonString, options); + } + + static equals(a: AttachDocumentRequest | PlainMessage | undefined, b: AttachDocumentRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(AttachDocumentRequest, a, b); + } +} + +/** + * @generated from message yorkie.v1.AttachDocumentResponse + */ +export class AttachDocumentResponse extends Message { + /** + * @generated from field: string document_id = 1; + */ + documentId = ""; + + /** + * @generated from field: yorkie.v1.ChangePack change_pack = 2; + */ + changePack?: ChangePack; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.AttachDocumentResponse"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "document_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "change_pack", kind: "message", T: ChangePack }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): AttachDocumentResponse { + return new AttachDocumentResponse().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): AttachDocumentResponse { + return new AttachDocumentResponse().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): AttachDocumentResponse { + return new AttachDocumentResponse().fromJsonString(jsonString, options); + } + + static equals(a: AttachDocumentResponse | PlainMessage | undefined, b: AttachDocumentResponse | PlainMessage | undefined): boolean { + return proto3.util.equals(AttachDocumentResponse, a, b); + } +} + +/** + * @generated from message yorkie.v1.DetachDocumentRequest + */ +export class DetachDocumentRequest extends Message { + /** + * @generated from field: string client_id = 1; + */ + clientId = ""; + + /** + * @generated from field: string document_id = 2; + */ + documentId = ""; + + /** + * @generated from field: yorkie.v1.ChangePack change_pack = 3; + */ + changePack?: ChangePack; + + /** + * @generated from field: bool remove_if_not_attached = 4; + */ + removeIfNotAttached = false; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.DetachDocumentRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "client_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "document_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "change_pack", kind: "message", T: ChangePack }, + { no: 4, name: "remove_if_not_attached", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): DetachDocumentRequest { + return new DetachDocumentRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): DetachDocumentRequest { + return new DetachDocumentRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): DetachDocumentRequest { + return new DetachDocumentRequest().fromJsonString(jsonString, options); + } + + static equals(a: DetachDocumentRequest | PlainMessage | undefined, b: DetachDocumentRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(DetachDocumentRequest, a, b); + } +} + +/** + * @generated from message yorkie.v1.DetachDocumentResponse + */ +export class DetachDocumentResponse extends Message { + /** + * @generated from field: yorkie.v1.ChangePack change_pack = 2; + */ + changePack?: ChangePack; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.DetachDocumentResponse"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 2, name: "change_pack", kind: "message", T: ChangePack }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): DetachDocumentResponse { + return new DetachDocumentResponse().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): DetachDocumentResponse { + return new DetachDocumentResponse().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): DetachDocumentResponse { + return new DetachDocumentResponse().fromJsonString(jsonString, options); + } + + static equals(a: DetachDocumentResponse | PlainMessage | undefined, b: DetachDocumentResponse | PlainMessage | undefined): boolean { + return proto3.util.equals(DetachDocumentResponse, a, b); + } +} + +/** + * @generated from message yorkie.v1.WatchDocumentRequest + */ +export class WatchDocumentRequest extends Message { + /** + * @generated from field: string client_id = 1; + */ + clientId = ""; + + /** + * @generated from field: string document_id = 2; + */ + documentId = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.WatchDocumentRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "client_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "document_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): WatchDocumentRequest { + return new WatchDocumentRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): WatchDocumentRequest { + return new WatchDocumentRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): WatchDocumentRequest { + return new WatchDocumentRequest().fromJsonString(jsonString, options); + } + + static equals(a: WatchDocumentRequest | PlainMessage | undefined, b: WatchDocumentRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(WatchDocumentRequest, a, b); + } +} + +/** + * @generated from message yorkie.v1.WatchDocumentResponse + */ +export class WatchDocumentResponse extends Message { + /** + * @generated from oneof yorkie.v1.WatchDocumentResponse.body + */ + body: { + /** + * @generated from field: yorkie.v1.WatchDocumentResponse.Initialization initialization = 1; + */ + value: WatchDocumentResponse_Initialization; + case: "initialization"; + } | { + /** + * @generated from field: yorkie.v1.DocEvent event = 2; + */ + value: DocEvent; + case: "event"; + } | { case: undefined; value?: undefined } = { case: undefined }; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.WatchDocumentResponse"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "initialization", kind: "message", T: WatchDocumentResponse_Initialization, oneof: "body" }, + { no: 2, name: "event", kind: "message", T: DocEvent, oneof: "body" }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): WatchDocumentResponse { + return new WatchDocumentResponse().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): WatchDocumentResponse { + return new WatchDocumentResponse().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): WatchDocumentResponse { + return new WatchDocumentResponse().fromJsonString(jsonString, options); + } + + static equals(a: WatchDocumentResponse | PlainMessage | undefined, b: WatchDocumentResponse | PlainMessage | undefined): boolean { + return proto3.util.equals(WatchDocumentResponse, a, b); + } +} + +/** + * @generated from message yorkie.v1.WatchDocumentResponse.Initialization + */ +export class WatchDocumentResponse_Initialization extends Message { + /** + * @generated from field: repeated string client_ids = 1; + */ + clientIds: string[] = []; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.WatchDocumentResponse.Initialization"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "client_ids", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): WatchDocumentResponse_Initialization { + return new WatchDocumentResponse_Initialization().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): WatchDocumentResponse_Initialization { + return new WatchDocumentResponse_Initialization().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): WatchDocumentResponse_Initialization { + return new WatchDocumentResponse_Initialization().fromJsonString(jsonString, options); + } + + static equals(a: WatchDocumentResponse_Initialization | PlainMessage | undefined, b: WatchDocumentResponse_Initialization | PlainMessage | undefined): boolean { + return proto3.util.equals(WatchDocumentResponse_Initialization, a, b); + } +} + +/** + * @generated from message yorkie.v1.RemoveDocumentRequest + */ +export class RemoveDocumentRequest extends Message { + /** + * @generated from field: string client_id = 1; + */ + clientId = ""; + + /** + * @generated from field: string document_id = 2; + */ + documentId = ""; + + /** + * @generated from field: yorkie.v1.ChangePack change_pack = 3; + */ + changePack?: ChangePack; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.RemoveDocumentRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "client_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "document_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "change_pack", kind: "message", T: ChangePack }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): RemoveDocumentRequest { + return new RemoveDocumentRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): RemoveDocumentRequest { + return new RemoveDocumentRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): RemoveDocumentRequest { + return new RemoveDocumentRequest().fromJsonString(jsonString, options); + } + + static equals(a: RemoveDocumentRequest | PlainMessage | undefined, b: RemoveDocumentRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(RemoveDocumentRequest, a, b); + } +} + +/** + * @generated from message yorkie.v1.RemoveDocumentResponse + */ +export class RemoveDocumentResponse extends Message { + /** + * @generated from field: yorkie.v1.ChangePack change_pack = 1; + */ + changePack?: ChangePack; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.RemoveDocumentResponse"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "change_pack", kind: "message", T: ChangePack }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): RemoveDocumentResponse { + return new RemoveDocumentResponse().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): RemoveDocumentResponse { + return new RemoveDocumentResponse().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): RemoveDocumentResponse { + return new RemoveDocumentResponse().fromJsonString(jsonString, options); + } + + static equals(a: RemoveDocumentResponse | PlainMessage | undefined, b: RemoveDocumentResponse | PlainMessage | undefined): boolean { + return proto3.util.equals(RemoveDocumentResponse, a, b); + } +} + +/** + * @generated from message yorkie.v1.PushPullChangesRequest + */ +export class PushPullChangesRequest extends Message { + /** + * @generated from field: string client_id = 1; + */ + clientId = ""; + + /** + * @generated from field: string document_id = 2; + */ + documentId = ""; + + /** + * @generated from field: yorkie.v1.ChangePack change_pack = 3; + */ + changePack?: ChangePack; + + /** + * @generated from field: bool push_only = 4; + */ + pushOnly = false; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.PushPullChangesRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "client_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "document_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "change_pack", kind: "message", T: ChangePack }, + { no: 4, name: "push_only", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): PushPullChangesRequest { + return new PushPullChangesRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): PushPullChangesRequest { + return new PushPullChangesRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): PushPullChangesRequest { + return new PushPullChangesRequest().fromJsonString(jsonString, options); + } + + static equals(a: PushPullChangesRequest | PlainMessage | undefined, b: PushPullChangesRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(PushPullChangesRequest, a, b); + } +} + +/** + * @generated from message yorkie.v1.PushPullChangesResponse + */ +export class PushPullChangesResponse extends Message { + /** + * @generated from field: yorkie.v1.ChangePack change_pack = 1; + */ + changePack?: ChangePack; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.PushPullChangesResponse"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "change_pack", kind: "message", T: ChangePack }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): PushPullChangesResponse { + return new PushPullChangesResponse().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): PushPullChangesResponse { + return new PushPullChangesResponse().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): PushPullChangesResponse { + return new PushPullChangesResponse().fromJsonString(jsonString, options); + } + + static equals(a: PushPullChangesResponse | PlainMessage | undefined, b: PushPullChangesResponse | PlainMessage | undefined): boolean { + return proto3.util.equals(PushPullChangesResponse, a, b); + } +} + +/** + * @generated from message yorkie.v1.BroadcastRequest + */ +export class BroadcastRequest extends Message { + /** + * @generated from field: string client_id = 1; + */ + clientId = ""; + + /** + * @generated from field: string document_id = 2; + */ + documentId = ""; + + /** + * @generated from field: string topic = 3; + */ + topic = ""; + + /** + * @generated from field: bytes payload = 4; + */ + payload = new Uint8Array(0); + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.BroadcastRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "client_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "document_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "topic", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 4, name: "payload", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): BroadcastRequest { + return new BroadcastRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): BroadcastRequest { + return new BroadcastRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): BroadcastRequest { + return new BroadcastRequest().fromJsonString(jsonString, options); + } + + static equals(a: BroadcastRequest | PlainMessage | undefined, b: BroadcastRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(BroadcastRequest, a, b); + } +} + +/** + * @generated from message yorkie.v1.BroadcastResponse + */ +export class BroadcastResponse extends Message { + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "yorkie.v1.BroadcastResponse"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): BroadcastResponse { + return new BroadcastResponse().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): BroadcastResponse { + return new BroadcastResponse().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): BroadcastResponse { + return new BroadcastResponse().fromJsonString(jsonString, options); + } + + static equals(a: BroadcastResponse | PlainMessage | undefined, b: BroadcastResponse | PlainMessage | undefined): boolean { + return proto3.util.equals(BroadcastResponse, a, b); + } +} + diff --git a/packages/sdk/src/client/client.ts b/packages/sdk/src/client/client.ts index 24a9afab4..d46bf21f4 100644 --- a/packages/sdk/src/client/client.ts +++ b/packages/sdk/src/client/client.ts @@ -361,6 +361,7 @@ export class Client { public attach( doc: Document, options: { + initialRoot?: T; initialPresence?: P; syncMode?: SyncMode; } = {}, @@ -434,6 +435,20 @@ export class Client { logger.info( `[AD] c:"${this.getKey()}" attaches d:"${doc.getKey()}"`, ); + + const crdtObject = doc.getRootObject(); + if (options.initialRoot) { + const initialRoot = options.initialRoot; + doc.update((root) => { + for (const [k, v] of Object.entries(initialRoot)) { + if (!crdtObject.has(k)) { + const key = k as keyof T; + root[key] = v as any; + } + } + }); + } + return doc; }) .catch(async (err) => { @@ -1107,9 +1122,9 @@ export class Client { }, }, ]); + await delay(this.retryRequestDelay); + return requestPushPullChanges(retryCount + 1); } - await delay(this.retryRequestDelay); - return requestPushPullChanges(retryCount + 1); } doc.publish([ diff --git a/packages/sdk/src/document/change/change_id.ts b/packages/sdk/src/document/change/change_id.ts index d797eb602..fb7c53ae6 100644 --- a/packages/sdk/src/document/change/change_id.ts +++ b/packages/sdk/src/document/change/change_id.ts @@ -14,34 +14,40 @@ * limitations under the License. */ -import Long from 'long'; import { ActorID, InitialActorID, } from '@yorkie-js-sdk/src/document/time/actor_id'; import { TimeTicket } from '@yorkie-js-sdk/src/document/time/ticket'; +import { InitialVersionVector, VersionVector } from '../time/version_vector'; /** * `ChangeID` is for identifying the Change. This is immutable. */ export class ChangeID { + // `clientSeq` is the sequence number of the client that created this change. private clientSeq: number; - // `serverSeq` is optional and only present for changes stored on the server. - private serverSeq?: Long; - - private lamport: Long; + private serverSeq?: bigint; + // `lamport` and `actor` are the lamport clock and the actor of this change. + // This is used to determine the order of changes in logical time. + private lamport: bigint; private actor: ActorID; + // `versionVector` is the vector clock of this change. This is used to + // determine the relationship is causal or not between changes. + private versionVector: VersionVector; constructor( clientSeq: number, - lamport: Long, + lamport: bigint, actor: ActorID, - serverSeq?: Long, + vector: VersionVector, + serverSeq?: bigint, ) { this.clientSeq = clientSeq; this.serverSeq = serverSeq; this.lamport = lamport; + this.versionVector = vector; this.actor = actor; } @@ -50,31 +56,58 @@ export class ChangeID { */ public static of( clientSeq: number, - lamport: Long, + lamport: bigint, actor: ActorID, - serverSeq?: Long, + vector: VersionVector, + serverSeq?: bigint, ): ChangeID { - return new ChangeID(clientSeq, lamport, actor, serverSeq); + return new ChangeID(clientSeq, lamport, actor, vector, serverSeq); } /** * `next` creates a next ID of this ID. */ public next(): ChangeID { - return new ChangeID(this.clientSeq + 1, this.lamport.add(1), this.actor); + const vector = this.versionVector.deepcopy(); + vector.set(this.actor, this.lamport + 1n); + + return new ChangeID( + this.clientSeq + 1, + this.lamport + 1n, + this.actor, + vector, + ); } /** - * `syncLamport` syncs lamport timestamp with the given ID. - * - * {@link https://en.wikipedia.org/wiki/Lamport_timestamps#Algorithm} + * `syncClocks` syncs logical clocks with the given ID. */ - public syncLamport(otherLamport: Long): ChangeID { - if (otherLamport.greaterThan(this.lamport)) { - return new ChangeID(this.clientSeq, otherLamport, this.actor); - } + public syncClocks(other: ChangeID): ChangeID { + const lamport = + other.lamport > this.lamport ? other.lamport + 1n : this.lamport + 1n; + const maxVersionVector = this.versionVector.max(other.versionVector); + + const newID = new ChangeID( + this.clientSeq, + lamport, + this.actor, + maxVersionVector, + ); + newID.versionVector.set(this.actor, lamport); + return newID; + } - return new ChangeID(this.clientSeq, this.lamport.add(1), this.actor); + /** + * `setClocks` sets the given clocks to this ID. This is used when the snapshot + * is given from the server. + */ + public setClocks(otherLamport: bigint, vector: VersionVector): ChangeID { + const lamport = + otherLamport > this.lamport ? otherLamport : this.lamport + 1n; + const maxVersionVector = this.versionVector.max(vector); + maxVersionVector.set(this.actor, lamport); + + return ChangeID.of(this.clientSeq, lamport, this.actor, maxVersionVector); } /** @@ -88,7 +121,26 @@ export class ChangeID { * `setActor` sets the given actor. */ public setActor(actorID: ActorID): ChangeID { - return new ChangeID(this.clientSeq, this.lamport, actorID, this.serverSeq); + return new ChangeID( + this.clientSeq, + this.lamport, + actorID, + this.versionVector, + this.serverSeq, + ); + } + + /** + * `setVersionVector` sets the given version vector. + */ + public setVersionVector(versionVector: VersionVector): ChangeID { + return new ChangeID( + this.clientSeq, + this.lamport, + this.actor, + versionVector, + this.serverSeq, + ); } /** @@ -111,7 +163,7 @@ export class ChangeID { /** * `getLamport` returns the lamport clock of this ID. */ - public getLamport(): Long { + public getLamport(): bigint { return this.lamport; } @@ -129,6 +181,13 @@ export class ChangeID { return this.actor; } + /** + * `getVersionVector` returns the version vector of this ID. + */ + public getVersionVector(): VersionVector { + return this.versionVector; + } + /** * `toTestString` returns a string containing the meta data of this ID. */ @@ -145,6 +204,7 @@ export class ChangeID { */ export const InitialChangeID = new ChangeID( 0, - Long.fromInt(0, true), + 0n, InitialActorID, + InitialVersionVector, ); diff --git a/packages/sdk/src/document/change/change_pack.ts b/packages/sdk/src/document/change/change_pack.ts index e2fd3144c..15a0e104c 100644 --- a/packages/sdk/src/document/change/change_pack.ts +++ b/packages/sdk/src/document/change/change_pack.ts @@ -18,6 +18,7 @@ import { Indexable } from '@yorkie-js-sdk/src/document/document'; import { Checkpoint } from '@yorkie-js-sdk/src/document/change/checkpoint'; import { Change } from '@yorkie-js-sdk/src/document/change/change'; import { TimeTicket } from '@yorkie-js-sdk/src/document/time/ticket'; +import { VersionVector } from '../time/version_vector'; /** * `ChangePack` is a unit for delivering changes in a document to the remote. @@ -52,11 +53,17 @@ export class ChangePack

{ */ private minSyncedTicket?: TimeTicket; + /** + * `versionVector` is the version vector current document + */ + private versionVector?: VersionVector; + constructor( key: string, checkpoint: Checkpoint, isRemoved: boolean, changes: Array>, + versionVector?: VersionVector, snapshot?: Uint8Array, minSyncedTicket?: TimeTicket, ) { @@ -66,8 +73,8 @@ export class ChangePack

{ this.changes = changes; this.snapshot = snapshot; this.minSyncedTicket = minSyncedTicket; + this.versionVector = versionVector; } - /** * `create` creates a new instance of ChangePack. */ @@ -76,6 +83,7 @@ export class ChangePack

{ checkpoint: Checkpoint, isRemoved: boolean, changes: Array>, + versionVector?: VersionVector, snapshot?: Uint8Array, minSyncedTicket?: TimeTicket, ): ChangePack

{ @@ -84,6 +92,7 @@ export class ChangePack

{ checkpoint, isRemoved, changes, + versionVector, snapshot, minSyncedTicket, ); @@ -151,4 +160,11 @@ export class ChangePack

{ public getMinSyncedTicket(): TimeTicket | undefined { return this.minSyncedTicket; } + + /** + * `getVersionVector` returns the document's version vector of this pack + */ + public getVersionVector(): VersionVector | undefined { + return this.versionVector; + } } diff --git a/packages/sdk/src/document/change/checkpoint.ts b/packages/sdk/src/document/change/checkpoint.ts index 13077a7a7..50a4a7357 100644 --- a/packages/sdk/src/document/change/checkpoint.ts +++ b/packages/sdk/src/document/change/checkpoint.ts @@ -14,18 +14,16 @@ * limitations under the License. */ -import Long from 'long'; - /** * `Checkpoint` is used to determine the changes sent and received by the * client. This is immutable. * **/ export class Checkpoint { - private serverSeq: Long; + private serverSeq: bigint; private clientSeq: number; - constructor(serverSeq: Long, clientSeq: number) { + constructor(serverSeq: bigint, clientSeq: number) { this.serverSeq = serverSeq; this.clientSeq = clientSeq; } @@ -33,7 +31,7 @@ export class Checkpoint { /** * `of` creates a new instance of Checkpoint. */ - public static of(serverSeq: Long, clientSeq: number): Checkpoint { + public static of(serverSeq: bigint, clientSeq: number): Checkpoint { return new Checkpoint(serverSeq, clientSeq); } @@ -57,9 +55,8 @@ export class Checkpoint { return this; } - const serverSeq = this.serverSeq.greaterThan(other.serverSeq) - ? this.serverSeq - : other.serverSeq; + const serverSeq = + this.serverSeq > other.serverSeq ? this.serverSeq : other.serverSeq; const clientSeq = Math.max(this.clientSeq, other.clientSeq); return Checkpoint.of(serverSeq, clientSeq); } @@ -82,7 +79,7 @@ export class Checkpoint { /** * `getServerSeq` returns the server seq of this checkpoint. */ - public getServerSeq(): Long { + public getServerSeq(): bigint { return this.serverSeq; } @@ -92,8 +89,7 @@ export class Checkpoint { */ public equals(other: Checkpoint): boolean { return ( - this.clientSeq === other.clientSeq && - this.serverSeq.equals(other.serverSeq) + this.clientSeq === other.clientSeq && this.serverSeq == other.serverSeq ); } @@ -109,4 +105,4 @@ export class Checkpoint { /** * `InitialCheckpoint` is the initial value of the checkpoint. */ -export const InitialCheckpoint = new Checkpoint(Long.fromInt(0, true), 0); +export const InitialCheckpoint = new Checkpoint(0n, 0); diff --git a/packages/sdk/src/document/crdt/root.ts b/packages/sdk/src/document/crdt/root.ts index fe962f4b4..246d87d41 100644 --- a/packages/sdk/src/document/crdt/root.ts +++ b/packages/sdk/src/document/crdt/root.ts @@ -27,6 +27,7 @@ import { GCPair } from '@yorkie-js-sdk/src/document/crdt/gc'; import { CRDTText } from '@yorkie-js-sdk/src/document/crdt/text'; import { CRDTTree } from '@yorkie-js-sdk/src/document/crdt/tree'; import { Code, YorkieError } from '@yorkie-js-sdk/src/util/error'; +import { VersionVector } from '../time/version_vector'; /** * `CRDTElementPair` is a structure that represents a pair of element and its @@ -268,15 +269,14 @@ export class CRDTRoot { /** * `garbageCollect` purges elements that were removed before the given time. */ - public garbageCollect(ticket: TimeTicket): number { + public garbageCollect(minSyncedVersionVector: VersionVector): number { let count = 0; for (const createdAt of this.gcElementSetByCreatedAt) { const pair = this.elementPairMapByCreatedAt.get(createdAt)!; - if ( - pair.element.getRemovedAt() && - ticket.compare(pair.element.getRemovedAt()!) >= 0 - ) { + const removedAt = pair.element.getRemovedAt(); + + if (removedAt && minSyncedVersionVector?.afterOrEqual(removedAt)) { pair.parent!.purge(pair.element); count += this.deregisterElement(pair.element); } @@ -284,7 +284,7 @@ export class CRDTRoot { for (const [, pair] of this.gcPairMap) { const removedAt = pair.child.getRemovedAt(); - if (removedAt !== undefined && ticket.compare(removedAt) >= 0) { + if (removedAt && minSyncedVersionVector?.afterOrEqual(removedAt)) { pair.parent.purge(pair.child); this.gcPairMap.delete(pair.child.toIDString()); diff --git a/packages/sdk/src/document/document.ts b/packages/sdk/src/document/document.ts index 16d4c0728..ee8ef459b 100644 --- a/packages/sdk/src/document/document.ts +++ b/packages/sdk/src/document/document.ts @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import Long from 'long'; import type { WatchDocumentResponse } from '@yorkie-js-sdk/src/api/yorkie/v1/yorkie_pb'; import { DocEventType as PbDocEventType } from '@yorkie-js-sdk/src/api/yorkie/v1/resources_pb'; import { logger, LogLevel } from '@yorkie-js-sdk/src/util/logger'; @@ -56,7 +55,6 @@ import { Checkpoint, InitialCheckpoint, } from '@yorkie-js-sdk/src/document/change/checkpoint'; -import { TimeTicket } from '@yorkie-js-sdk/src/document/time/ticket'; import { OpSource, OperationInfo, @@ -78,6 +76,7 @@ import { import { History, HistoryOperation } from '@yorkie-js-sdk/src/document/history'; import { setupDevtools } from '@yorkie-js-sdk/src/devtools'; import * as Devtools from '@yorkie-js-sdk/src/devtools/types'; +import { VersionVector } from './time/version_vector'; /** * `BroadcastOptions` are the options to create a new document. @@ -328,7 +327,11 @@ export interface SnapshotEvent extends BaseDocEvent { */ type: DocEventType.Snapshot; source: OpSource.Remote; - value: { snapshot?: string; serverSeq: string }; + value: { + snapshot: string | undefined; + serverSeq: string; + snapshotVector: string; + }; } /** @@ -1188,10 +1191,13 @@ export class Document { * @internal */ public applyChangePack(pack: ChangePack

): void { - if (pack.hasSnapshot()) { + const hasSnapshot = pack.hasSnapshot(); + + if (hasSnapshot) { this.applySnapshot( pack.getCheckpoint().getServerSeq(), - pack.getSnapshot(), + pack.getVersionVector()!, + pack.getSnapshot()!, ); } else if (pack.hasChanges()) { this.applyChanges(pack.getChanges(), OpSource.Remote); @@ -1210,7 +1216,7 @@ export class Document { // them after applying the snapshot. We need to treat the local changes // as remote changes because the application should apply the local // changes to their own document. - if (pack.hasSnapshot()) { + if (hasSnapshot) { this.applyChanges(this.localChanges, OpSource.Remote); } @@ -1218,7 +1224,14 @@ export class Document { this.checkpoint = this.checkpoint.forward(pack.getCheckpoint()); // 04. Do Garbage collection. - this.garbageCollect(pack.getMinSyncedTicket()!); + if (!hasSnapshot) { + this.garbageCollect(pack.getVersionVector()!); + } + + // 05. Filter detached client's lamport from version vector + if (!hasSnapshot) { + this.filterVersionVector(pack.getVersionVector()!); + } // 05. Update the status. if (pack.getIsRemoved()) { @@ -1280,7 +1293,13 @@ export class Document { public createChangePack(): ChangePack

{ const changes = Array.from(this.localChanges); const checkpoint = this.checkpoint.increaseClientSeq(changes.length); - return ChangePack.create(this.key, checkpoint, false, changes); + return ChangePack.create( + this.key, + checkpoint, + false, + changes, + this.getVersionVector(), + ); } /** @@ -1352,15 +1371,15 @@ export class Document { * * @internal */ - public garbageCollect(ticket: TimeTicket): number { + public garbageCollect(minSyncedVersionVector: VersionVector): number { if (this.opts.disableGC) { return 0; } if (this.clone) { - this.clone.root.garbageCollect(ticket); + this.clone.root.garbageCollect(minSyncedVersionVector); } - return this.root.garbageCollect(ticket); + return this.root.garbageCollect(minSyncedVersionVector); } /** @@ -1415,11 +1434,15 @@ export class Document { /** * `applySnapshot` applies the given snapshot into this document. */ - public applySnapshot(serverSeq: Long, snapshot?: Uint8Array) { + public applySnapshot( + serverSeq: bigint, + snapshotVector: VersionVector, + snapshot?: Uint8Array, + ) { const { root, presences } = converter.bytesToSnapshot

(snapshot); this.root = new CRDTRoot(root); this.presences = presences; - this.changeID = this.changeID.syncLamport(serverSeq); + this.changeID = this.changeID.setClocks(serverSeq, snapshotVector); // drop clone because it is contaminated. this.clone = undefined; @@ -1429,10 +1452,11 @@ export class Document { type: DocEventType.Snapshot, source: OpSource.Remote, value: { + serverSeq: serverSeq.toString(), snapshot: this.isEnableDevtools() ? converter.bytesToHex(snapshot) : undefined, - serverSeq: serverSeq.toString(), + snapshotVector: converter.versionVectorToHex(snapshotVector), }, }, ]); @@ -1532,7 +1556,7 @@ export class Document { } const { opInfos } = change.execute(this.root, this.presences, source); - this.changeID = this.changeID.syncLamport(change.getID().getLamport()); + this.changeID = this.changeID.syncClocks(change.getID()); if (opInfos.length > 0) { const rawChange = this.isEnableDevtools() ? change.toStruct() : undefined; event.push( @@ -1685,10 +1709,11 @@ export class Document { } if (event.type === DocEventType.Snapshot) { - const { snapshot, serverSeq } = event.value; + const { snapshot, serverSeq, snapshotVector } = event.value; if (!snapshot) return; this.applySnapshot( - Long.fromString(serverSeq), + BigInt(serverSeq), + converter.hexToVersionVector(snapshotVector), converter.hexToBytes(snapshot), ); return; @@ -1897,6 +1922,15 @@ export class Document { return this.internalHistory.hasUndo() && !this.isUpdating; } + /** + * 'filterVersionVector' filters detached client's lamport from version vector. + */ + private filterVersionVector(minSyncedVersionVector: VersionVector) { + const versionVector = this.changeID.getVersionVector(); + const filteredVersionVector = versionVector.filter(minSyncedVersionVector); + + this.changeID = this.changeID.setVersionVector(filteredVersionVector); + } /** * `canRedo` returns whether there are any operations to redo. */ @@ -2129,4 +2163,11 @@ export class Document { this.publish([broadcastEvent]); } + + /** + * `getVersionVector` returns the version vector of document + */ + public getVersionVector() { + return this.changeID.getVersionVector(); + } } diff --git a/packages/sdk/src/document/time/ticket.ts b/packages/sdk/src/document/time/ticket.ts index fc4ae15be..f4bad2873 100644 --- a/packages/sdk/src/document/time/ticket.ts +++ b/packages/sdk/src/document/time/ticket.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -import Long from 'long'; import { Comparator } from '@yorkie-js-sdk/src/util/comparator'; import { ActorID, @@ -46,11 +45,11 @@ export type TimeTicketStruct = { * @public */ export class TimeTicket { - private lamport: Long; + private lamport: bigint; private delimiter: number; private actorID: ActorID; - constructor(lamport: Long, delimiter: number, actorID: string) { + constructor(lamport: bigint, delimiter: number, actorID: string) { this.lamport = lamport; this.delimiter = delimiter; this.actorID = actorID; @@ -60,7 +59,7 @@ export class TimeTicket { * `of` creates an instance of Ticket. */ public static of( - lamport: Long, + lamport: bigint, delimiter: number, actorID: string, ): TimeTicket { @@ -72,7 +71,7 @@ export class TimeTicket { */ public static fromStruct(struct: TimeTicketStruct): TimeTicket { return TimeTicket.of( - Long.fromString(struct.lamport, true), + BigInt(struct.lamport), struct.delimiter, struct.actorID, ); @@ -123,7 +122,7 @@ export class TimeTicket { /** * `getLamport` returns the lamport. */ - public getLamport(): Long { + public getLamport(): bigint { return this.lamport; } @@ -161,9 +160,9 @@ export class TimeTicket { * If the receiver or argument is nil, it would panic at runtime. */ public compare(other: TimeTicket): number { - if (this.lamport.greaterThan(other.lamport)) { + if (this.lamport > other.lamport) { return 1; - } else if (other.lamport.greaterThan(this.lamport)) { + } else if (other.lamport > this.lamport) { return -1; } @@ -184,20 +183,14 @@ export class TimeTicket { export const InitialDelimiter = 0; export const MaxDelemiter = 4294967295; // UInt32 MAX_VALUE -export const MaxLamport = Long.MAX_VALUE; +export const MaxLamport = 9223372036854775807n; // Int64 MAX_VALUE export const InitialTimeTicket = new TimeTicket( - Long.fromNumber(0), + 0n, InitialDelimiter, InitialActorID, ); -export const NextTimeTicket = new TimeTicket( - Long.fromNumber(1), - InitialDelimiter + 1, - InitialActorID, -); - export const MaxTimeTicket = new TimeTicket( MaxLamport, MaxDelemiter, diff --git a/packages/sdk/src/document/time/version_vector.ts b/packages/sdk/src/document/time/version_vector.ts new file mode 100644 index 000000000..97da9ae3b --- /dev/null +++ b/packages/sdk/src/document/time/version_vector.ts @@ -0,0 +1,151 @@ +/* + * Copyright 2024 The Yorkie Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { TimeTicket } from './ticket'; + +/** + * `VersionVector` is a vector clock that is used to detect the relationship + * between changes whether they are causally related or concurrent. It is + * similar to vector clocks, but it is synced with lamport timestamp of the + * change. + */ +export class VersionVector { + private vector: Map; + + constructor(vector?: Map) { + this.vector = vector || new Map(); + } + + /** + * `set` sets the lamport timestamp of the given actor. + */ + public set(actorID: string, lamport: bigint): void { + this.vector.set(actorID, lamport); + } + + /** + * `get` gets the lamport timestamp of the given actor. + */ + public get(actorID: string): bigint | undefined { + return this.vector.get(actorID); + } + + /** + * `maxLamport` returns max lamport value from vector + */ + public maxLamport() { + let max = BigInt(0); + + for (const [, lamport] of this) { + if (lamport > max) { + max = lamport; + } + } + + return max; + } + + /** + * `max` returns new version vector which consists of max value of each vector + */ + public max(other: VersionVector): VersionVector { + const maxVector = new Map(); + + for (const [actorID, lamport] of other) { + const currentLamport = this.vector.get(actorID); + const maxLamport = currentLamport + ? currentLamport > lamport + ? currentLamport + : lamport + : lamport; + + maxVector.set(actorID, maxLamport); + } + + for (const [actorID, lamport] of this) { + const otherLamport = other.get(actorID); + const maxLamport = otherLamport + ? otherLamport > lamport + ? otherLamport + : lamport + : lamport; + + maxVector.set(actorID, maxLamport); + } + + return new VersionVector(maxVector); + } + + /** + * `afterOrEqual` returns vector[other.actorID] is greaterOrEqual than given ticket's lamport + */ + public afterOrEqual(other: TimeTicket) { + const lamport = this.vector.get(other.getActorID()); + + if (lamport === undefined) { + return false; + } + + return lamport >= other.getLamport(); + } + + /** + * `deepcopy` returns a deep copy of this `VersionVector`. + */ + public deepcopy(): VersionVector { + const copied = new Map(); + for (const [key, value] of this.vector) { + copied.set(key, value); + } + return new VersionVector(copied); + } + + /** + * `filter` returns new version vector consist of filter's actorID. + */ + public filter(versionVector: VersionVector) { + const filtered = new Map(); + + for (const [actorID] of versionVector) { + const lamport = this.vector.get(actorID); + + if (lamport !== undefined) { + filtered.set(actorID, lamport); + } + } + + return new VersionVector(filtered); + } + + /** + * `size` returns size of version vector + */ + public size(): number { + return this.vector.size; + } + + // eslint-disable-next-line jsdoc/require-jsdoc + public *[Symbol.iterator](): IterableIterator<[string, bigint]> { + for (const [key, value] of this.vector) { + yield [key, value]; + } + } +} + +/** + * `InitialVersionVector` is the initial version vector. + */ +export const InitialVersionVector = new VersionVector(new Map()); diff --git a/packages/sdk/src/yorkie.ts b/packages/sdk/src/yorkie.ts index 8c9fda87f..7bce1537b 100644 --- a/packages/sdk/src/yorkie.ts +++ b/packages/sdk/src/yorkie.ts @@ -62,6 +62,7 @@ export { type TimeTicketStruct, } from '@yorkie-js-sdk/src/document/time/ticket'; export { type ActorID } from '@yorkie-js-sdk/src/document/time/actor_id'; +export { VersionVector } from '@yorkie-js-sdk/src/document/time/version_vector'; export type { OperationInfo, TextOperationInfo, diff --git a/packages/sdk/test/bench/document.bench.ts b/packages/sdk/test/bench/document.bench.ts index 4fc11a38c..17f53231c 100644 --- a/packages/sdk/test/bench/document.bench.ts +++ b/packages/sdk/test/bench/document.bench.ts @@ -1,8 +1,8 @@ import { Document, JSONArray } from '@yorkie-js-sdk/src/yorkie'; -import { MaxTimeTicket } from '@yorkie-js-sdk/src/document/time/ticket'; import { InitialCheckpoint } from '@yorkie-js-sdk/src/document/change/checkpoint'; import { DocumentStatus } from '@yorkie-js-sdk/src/document/document'; import { describe, bench, assert } from 'vitest'; +import { MaxVersionVector } from '../helper/helper'; const benchmarkObject = (size: number) => { const doc = new Document<{ k1: number }>('test-doc'); @@ -40,7 +40,10 @@ const benchmarkArrayGC = (size: number) => { delete root.k1; }); - assert.equal(size + 1, doc.garbageCollect(MaxTimeTicket)); + assert.equal( + size + 1, + doc.garbageCollect(MaxVersionVector([doc.getChangeID().getActorID()])), + ); }; describe('Document', () => { diff --git a/packages/sdk/test/bench/text.bench.ts b/packages/sdk/test/bench/text.bench.ts index 2f94ef4a7..9b91bbaca 100644 --- a/packages/sdk/test/bench/text.bench.ts +++ b/packages/sdk/test/bench/text.bench.ts @@ -1,6 +1,6 @@ import { Document, Text } from '@yorkie-js-sdk/src/yorkie'; -import { MaxTimeTicket } from '@yorkie-js-sdk/src/document/time/ticket'; import { assert, bench, describe } from 'vitest'; +import { MaxVersionVector } from '../helper/helper'; const benchmarkTextEditGC = (size: number) => { const doc = new Document<{ text: Text }>('test-doc'); @@ -22,7 +22,10 @@ const benchmarkTextEditGC = (size: number) => { }, `modify ${size} nodes`); // 03. GC assert.equal(size, doc.getGarbageLen()); - assert.equal(size, doc.garbageCollect(MaxTimeTicket)); + assert.equal( + size, + doc.garbageCollect(MaxVersionVector([doc.getChangeID().getActorID()])), + ); const empty = 0; assert.equal(empty, doc.getGarbageLen()); }; @@ -45,7 +48,10 @@ const benchmarkTextSplitGC = (size: number) => { }, 'Modify one node multiple times'); // 03. GC assert.equal(size, doc.getGarbageLen()); - assert.equal(size, doc.garbageCollect(MaxTimeTicket)); + assert.equal( + size, + doc.garbageCollect(MaxVersionVector([doc.getChangeID().getActorID()])), + ); const empty = 0; assert.equal(empty, doc.getGarbageLen()); }; diff --git a/packages/sdk/test/bench/tree.bench.ts b/packages/sdk/test/bench/tree.bench.ts index b8bb2f8ce..c03b3577e 100644 --- a/packages/sdk/test/bench/tree.bench.ts +++ b/packages/sdk/test/bench/tree.bench.ts @@ -1,6 +1,6 @@ import { converter, Document, Tree, TreeNode } from '@yorkie-js-sdk/src/yorkie'; -import { MaxTimeTicket } from '@yorkie-js-sdk/src/document/time/ticket'; import { describe, bench, assert } from 'vitest'; +import { MaxVersionVector } from '../helper/helper'; const benchmarkTreeEdit = (size: number) => { const doc = new Document<{ tree: Tree }>('test-doc'); @@ -56,7 +56,10 @@ const benchmarkTreeSplitGC = (size: number) => { }, `modify ${size} nodes`); // 03. GC assert.equal(size, doc.getGarbageLen()); - assert.equal(size, doc.garbageCollect(MaxTimeTicket)); + assert.equal( + size, + doc.garbageCollect(MaxVersionVector([doc.getChangeID().getActorID()])), + ); const empty = 0; assert.equal(empty, doc.getGarbageLen()); }; @@ -83,7 +86,10 @@ const benchmarkTreeEditGC = (size: number) => { }, `modify ${size} nodes`); // 03. GC assert.equal(size, doc.getGarbageLen()); - assert.equal(size, doc.garbageCollect(MaxTimeTicket)); + assert.equal( + size, + doc.garbageCollect(MaxVersionVector([doc.getChangeID().getActorID()])), + ); const empty = 0; assert.equal(empty, doc.getGarbageLen()); }; diff --git a/packages/sdk/test/helper/helper.ts b/packages/sdk/test/helper/helper.ts index 90db77201..07ff4b498 100644 --- a/packages/sdk/test/helper/helper.ts +++ b/packages/sdk/test/helper/helper.ts @@ -28,6 +28,7 @@ import { } from '@yorkie-js-sdk/src/document/operation/operation'; import { InitialTimeTicket as ITT, + MaxLamport, TimeTicket, } from '@yorkie-js-sdk/src/document/time/ticket'; import { HistoryOperation } from '@yorkie-js-sdk/src/document/history'; @@ -37,6 +38,8 @@ import { CRDTRoot } from '@yorkie-js-sdk/src/document/crdt/root'; import { CRDTObject } from '@yorkie-js-sdk/src/document/crdt/object'; import { ElementRHT } from '@yorkie-js-sdk/src/document/crdt/element_rht'; import { Code, YorkieError } from '@yorkie-js-sdk/src/util/error'; +import { InitialActorID } from '@yorkie-js-sdk/src/document/time/actor_id'; +import { VersionVector } from '@yorkie-js-sdk/src/document/time/version_vector'; export type Indexable = Record; @@ -285,3 +288,41 @@ export function posT(offset = 0): CRDTTreeNodeID { export function timeT(): TimeTicket { return dummyContext.issueTimeTicket(); } + +// MaxVersionVector return the SyncedVectorMap that contains the given actors as key and Max Lamport. +export function MaxVersionVector(actors: Array) { + if (!actors.length) { + actors = [InitialActorID]; + } + + const vector = new Map(); + + actors.forEach((actor) => { + vector.set(actor, MaxLamport); + }); + + return new VersionVector(vector); +} + +export function versionVectorHelper( + versionVector: VersionVector, + actorData: Array<{ actor: string; lamport: bigint }>, +) { + if (versionVector.size() !== actorData.length) { + return false; + } + + for (const { actor, lamport } of actorData) { + const vvLamport = versionVector.get(actor); + + if (!vvLamport) { + return false; + } + + if (vvLamport !== lamport) { + return false; + } + } + + return true; +} diff --git a/packages/sdk/test/integration/array_test.ts b/packages/sdk/test/integration/array_test.ts index 829eee0ab..5ba077f73 100644 --- a/packages/sdk/test/integration/array_test.ts +++ b/packages/sdk/test/integration/array_test.ts @@ -1,7 +1,5 @@ import { describe, it, assert } from 'vitest'; import { Document } from '@yorkie-js-sdk/src/document/document'; -import { MaxTimeTicket } from '@yorkie-js-sdk/src/document/time/ticket'; - import { withTwoClientsAndDocuments } from '@yorkie-js-sdk/test/integration/integration_helper'; import { JSONArray, @@ -9,6 +7,7 @@ import { Primitive, TimeTicket, } from '@yorkie-js-sdk/src/yorkie'; +import { MaxVersionVector } from '../helper/helper'; describe('Array', function () { it('should handle delete operations', function () { @@ -723,7 +722,7 @@ describe('Array', function () { assert.equal('{"list":[0,1]}', doc.toSortedJSON()); - doc.garbageCollect(MaxTimeTicket); + doc.garbageCollect(MaxVersionVector([doc.getChangeID().getActorID()])); doc.update((root) => { const elem = root.list.getElementByID!(targetID); assert.isUndefined(elem); diff --git a/packages/sdk/test/integration/client_test.ts b/packages/sdk/test/integration/client_test.ts index 9b9e1a994..a61b78a62 100644 --- a/packages/sdk/test/integration/client_test.ts +++ b/packages/sdk/test/integration/client_test.ts @@ -526,12 +526,12 @@ describe.sequential('Client', function () { let checkpoint = d1.getCheckpoint(); assert.equal(checkpoint.getClientSeq(), 1); - assert.equal(checkpoint.getServerSeq().toInt(), 1); + assert.equal(checkpoint.getServerSeq(), 1n); await c1.sync(); checkpoint = d1.getCheckpoint(); assert.equal(checkpoint.getClientSeq(), 2); - assert.equal(checkpoint.getServerSeq().toInt(), 2); + assert.equal(checkpoint.getServerSeq(), 2n); // 03. cli update the document with increasing the counter(0 -> 1) // and sync with push-only mode: CP(2, 2) -> CP(3, 2) @@ -548,7 +548,7 @@ describe.sequential('Client', function () { await eventCollector.waitFor(DocumentSyncStatus.Synced); checkpoint = d1.getCheckpoint(); assert.equal(checkpoint.getClientSeq(), 3); - assert.equal(checkpoint.getServerSeq().toInt(), 2); + assert.equal(checkpoint.getServerSeq(), 2n); await c1.changeSyncMode(d1, SyncMode.Manual); // 04. cli update the document with increasing the counter(1 -> 2) @@ -565,7 +565,7 @@ describe.sequential('Client', function () { await c1.sync(); checkpoint = d1.getCheckpoint(); assert.equal(checkpoint.getClientSeq(), 4); - assert.equal(checkpoint.getServerSeq().toInt(), 4); + assert.equal(checkpoint.getServerSeq(), 4n); assert.equal(d1.getRoot().counter.getValue(), 2); unsub(); @@ -897,6 +897,7 @@ describe.sequential('Client', function () { await cli.attach(doc); // broadcast unserializable payload + // eslint-disable-next-line @typescript-eslint/no-empty-function const payload = () => {}; const broadcastTopic = 'test'; const broadcastErrMessage = 'payload is not serializable'; diff --git a/packages/sdk/test/integration/document_test.ts b/packages/sdk/test/integration/document_test.ts index c14c1b8bd..b3df7b787 100644 --- a/packages/sdk/test/integration/document_test.ts +++ b/packages/sdk/test/integration/document_test.ts @@ -4,6 +4,8 @@ import yorkie, { Text, JSONArray, SyncMode, + Tree, + JSONElement, } from '@yorkie-js-sdk/src/yorkie'; import { testRPCAddr, @@ -12,6 +14,7 @@ import { import { EventCollector, assertThrowsAsync, + Indexable, } from '@yorkie-js-sdk/test/helper/helper'; import type { CRDTElement } from '@yorkie-js-sdk/src/document/crdt/element'; import { @@ -21,6 +24,8 @@ import { } from '@yorkie-js-sdk/src/document/document'; import { OperationInfo } from '@yorkie-js-sdk/src/document/operation/operation'; import { YorkieError } from '@yorkie-js-sdk/src/util/error'; +import { CounterType } from '@yorkie-js-sdk/src/document/crdt/counter'; +import Long from 'long'; describe('Document', function () { afterEach(() => { @@ -1097,4 +1102,188 @@ describe('Document', function () { assert.equal(doc.toSortedJSON(), '{"counter":100}'); }); }); + + describe('Document with InitialRoot', function () { + it('Can attach with InitialRoot', async function ({ task }) { + const c1 = new yorkie.Client(testRPCAddr); + const c2 = new yorkie.Client(testRPCAddr); + await c1.activate(); + await c2.activate(); + const docKey = toDocKey(`${task.name}-${new Date().getTime()}`); + + // 01. attach and initialize document + const doc1 = new yorkie.Document(docKey); + await c1.attach(doc1, { + initialRoot: { + counter: new Counter(CounterType.IntegerCnt, 0), + content: { x: 1, y: 1 }, + }, + }); + assert.equal( + doc1.toSortedJSON(), + '{"content":{"x":1,"y":1},"counter":0}', + ); + await c1.sync(); + + // 02. attach and initialize document with new fields and if key already exists, it will be discarded + const doc2 = new yorkie.Document(docKey); + await c2.attach(doc2, { + initialRoot: { + counter: new Counter(CounterType.IntegerCnt, 1), + content: { x: 1, y: 2 }, + new: { k: 'v' }, + }, + }); + assert.equal( + doc2.toSortedJSON(), + '{"content":{"x":1,"y":1},"counter":0,"new":{"k":"v"}}', + ); + + await c1.deactivate(); + await c2.deactivate(); + }); + + it('Can handle concurrent attach with InitialRoot', async function ({ + task, + }) { + const c1 = new yorkie.Client(testRPCAddr); + const c2 = new yorkie.Client(testRPCAddr); + await c1.activate(); + await c2.activate(); + + const docKey = toDocKey(`${task.name}-${new Date().getTime()}`); + + // 01. user1 attach with initialRoot and client doesn't sync + const doc1 = new yorkie.Document(docKey); + await c1.attach(doc1, { initialRoot: { writer: 'user1' } }); + assert.equal(doc1.toSortedJSON(), '{"writer":"user1"}'); + + // 02. user2 attach with initialRoot and client doesn't sync + const doc2 = new yorkie.Document(docKey); + await c2.attach(doc2, { initialRoot: { writer: 'user2' } }); + assert.equal(doc2.toSortedJSON(), '{"writer":"user2"}'); + + // 03. user1 sync first and user2 seconds + await c1.sync(); + await c2.sync(); + + // 04. user1's local document's writer was user1 + assert.equal(doc1.toSortedJSON(), '{"writer":"user1"}'); + assert.equal(doc2.toSortedJSON(), '{"writer":"user2"}'); + + // 05. user1's local document's writer is overwritten by user2 + await c1.sync(); + assert.equal(doc1.toSortedJSON(), '{"writer":"user2"}'); + + await c1.deactivate(); + await c2.deactivate(); + }); + + describe('With various types', () => { + interface TestCase { + name: string; + input: JSONElement | Indexable; + expectedJSON: string; + } + + const testCases: Array = [ + { + name: 'tree', + input: new Tree({ + type: 'doc', + children: [ + { type: 'p', children: [{ type: 'text', value: 'ab' }] }, + ], + }), + expectedJSON: `{"tree":{"type":"doc","children":[{"type":"p","children":[{"type":"text","value":"ab"}]}]}}`, + }, + { + name: 'text', + input: new Text(), + expectedJSON: `{"text":[]}`, + }, + { + name: 'counter', + input: new Counter(CounterType.IntegerCnt, 1), + expectedJSON: `{"counter":1}`, + }, + { + name: 'null', + input: null, + expectedJSON: `{"null":null}`, + }, + { + name: 'boolean', + input: true, + expectedJSON: `{"boolean":true}`, + }, + { + name: 'number', + input: 1, + expectedJSON: `{"number":1}`, + }, + { + name: 'long', + input: Long.MAX_VALUE, + expectedJSON: `{"long":9223372036854775807}`, + }, + { + name: 'object', + input: { k: 'v' }, + expectedJSON: `{"object":{"k":"v"}}`, + }, + { + name: 'array', + input: [1, 2], + expectedJSON: `{"array":[1,2]}`, + }, + // TODO(hackerwins): We need to consider the case where the value is + // a byte array and a date. + { + name: 'bytes', + input: new Uint8Array([1, 2]), + expectedJSON: `{"bytes":1,2}`, + }, + // { + // name: 'Date', + // input: new Date(0), + // expectedJSON: `{"k":"1970-01-01T00:00:00.000Z"}`, + // }, + ]; + + for (const { name: name, input, expectedJSON } of testCases) { + it(`Can support various types: ${name}`, async function ({ task }) { + const c1 = new yorkie.Client(testRPCAddr); + await c1.activate(); + const docKey = toDocKey( + `${task.name}-${name}-${new Date().getTime()}`, + ); + + type DocType = { + tree?: Tree; + text?: Text; + counter?: Counter; + null?: null; + boolean?: boolean; + number?: number; + long?: Long; + object?: { k: string }; + array?: Array; + bytes?: Uint8Array; + // date: Date; + }; + const doc = new yorkie.Document(docKey); + + await c1.attach(doc, { + initialRoot: { + [name]: input, + }, + }); + assert.equal(doc.toSortedJSON(), expectedJSON); + + await c1.deactivate(); + }); + } + }); + }); }); diff --git a/packages/sdk/test/integration/gc_test.ts b/packages/sdk/test/integration/gc_test.ts index 1da621683..99d5b88dd 100644 --- a/packages/sdk/test/integration/gc_test.ts +++ b/packages/sdk/test/integration/gc_test.ts @@ -1,10 +1,10 @@ import { describe, it, assert } from 'vitest'; -import { MaxTimeTicket } from '@yorkie-js-sdk/src/document/time/ticket'; import yorkie, { Text, Tree, SyncMode } from '@yorkie-js-sdk/src/yorkie'; import { testRPCAddr, toDocKey, } from '@yorkie-js-sdk/test/integration/integration_helper'; +import { MaxVersionVector, versionVectorHelper } from '../helper/helper'; describe('Garbage Collection', function () { it('getGarbageLen should return the actual number of elements garbage-collected', async function ({ @@ -48,8 +48,18 @@ describe('Garbage Collection', function () { assert.equal(doc2.getGarbageLen(), gcNodeLen); // Actual garbage-collected nodes - assert.equal(doc1.garbageCollect(MaxTimeTicket), gcNodeLen); - assert.equal(doc2.garbageCollect(MaxTimeTicket), gcNodeLen); + assert.equal( + doc1.garbageCollect( + MaxVersionVector([client1.getID()!, client2.getID()!]), + ), + gcNodeLen, + ); + assert.equal( + doc2.garbageCollect( + MaxVersionVector([client1.getID()!, client2.getID()!]), + ), + gcNodeLen, + ); await client1.deactivate(); await client2.deactivate(); @@ -69,7 +79,20 @@ describe('Garbage Collection', function () { await client2.activate(); await client1.attach(doc1, { syncMode: SyncMode.Manual }); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(1) }, + ]), + true, + ); await client2.attach(doc2, { syncMode: SyncMode.Manual }); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(1) }, + { actor: client2.getID()!, lamport: BigInt(2) }, + ]), + true, + ); doc1.update((root) => { root.t = new Tree({ @@ -91,44 +114,100 @@ describe('Garbage Collection', function () { ], }); }); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + ]), + true, + ); assert.equal(doc1.getGarbageLen(), 0); assert.equal(doc2.getGarbageLen(), 0); - // (0, 0) -> (1, 0): syncedseqs:(0, 0) await client1.sync(); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(3) }, + { actor: client2.getID()!, lamport: BigInt(1) }, + ]), + true, + ); - // (1, 0) -> (1, 1): syncedseqs:(0, 0) await client2.sync(); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + { actor: client2.getID()!, lamport: BigInt(3) }, + ]), + true, + ); doc2.update((root) => { root.t.editByPath([0, 0, 0], [0, 0, 2], { type: 'text', value: 'gh' }); }, 'removes 2'); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + { actor: client2.getID()!, lamport: BigInt(4) }, + ]), + true, + ); assert.equal(doc1.getGarbageLen(), 0); assert.equal(doc2.getGarbageLen(), 2); // (1, 1) -> (1, 2): syncedseqs:(0, 1) await client2.sync(); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + { actor: client2.getID()!, lamport: BigInt(4) }, + ]), + true, + ); assert.equal(doc1.getGarbageLen(), 0); assert.equal(doc2.getGarbageLen(), 2); - // (1, 2) -> (2, 2): syncedseqs:(1, 1) await client1.sync(); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(5) }, + { actor: client2.getID()!, lamport: BigInt(4) }, + ]), + true, + ); assert.equal(doc1.getGarbageLen(), 2); assert.equal(doc2.getGarbageLen(), 2); - // (2, 2) -> (2, 2): syncedseqs:(1, 2) await client2.sync(); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + { actor: client2.getID()!, lamport: BigInt(4) }, + ]), + true, + ); assert.equal(doc1.getGarbageLen(), 2); assert.equal(doc2.getGarbageLen(), 2); - // (2, 2) -> (2, 2): syncedseqs:(2, 2): meet GC condition await client1.sync(); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(5) }, + { actor: client2.getID()!, lamport: BigInt(4) }, + ]), + true, + ); assert.equal(doc1.getGarbageLen(), 0); assert.equal(doc2.getGarbageLen(), 2); - // (2, 2) -> (2, 2): syncedseqs:(2, 2): meet GC condition await client2.sync(); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + { actor: client2.getID()!, lamport: BigInt(4) }, + ]), + true, + ); assert.equal(doc1.getGarbageLen(), 0); assert.equal(doc2.getGarbageLen(), 0); @@ -154,51 +233,120 @@ describe('Garbage Collection', function () { await client2.activate(); await client1.attach(doc1, { syncMode: SyncMode.Manual }); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(1) }, + ]), + true, + ); await client2.attach(doc2, { syncMode: SyncMode.Manual }); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(1) }, + { actor: client2.getID()!, lamport: BigInt(2) }, + ]), + true, + ); doc1.update((root) => { root['1'] = 1; root['2'] = [1, 2, 3]; root['3'] = 3; }, 'sets 1, 2, 3'); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + ]), + true, + ); assert.equal(doc1.getGarbageLen(), 0); assert.equal(doc2.getGarbageLen(), 0); - // (0, 0) -> (1, 0): syncedseqs:(0, 0) await client1.sync(); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(3) }, + { actor: client2.getID()!, lamport: BigInt(1) }, + ]), + true, + ); - // (1, 0) -> (1, 1): syncedseqs:(0, 0) await client2.sync(); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + { actor: client2.getID()!, lamport: BigInt(3) }, + ]), + true, + ); doc2.update((root) => { delete root['2']; }, 'removes 2'); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + { actor: client2.getID()!, lamport: BigInt(4) }, + ]), + true, + ); assert.equal(doc1.getGarbageLen(), 0); assert.equal(doc2.getGarbageLen(), 4); - // (1, 1) -> (1, 2): syncedseqs:(0, 1) await client2.sync(); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + { actor: client2.getID()!, lamport: BigInt(4) }, + ]), + true, + ); assert.equal(doc1.getGarbageLen(), 0); assert.equal(doc2.getGarbageLen(), 4); - // (1, 2) -> (2, 2): syncedseqs:(1, 1) await client1.sync(); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(5) }, + { actor: client2.getID()!, lamport: BigInt(4) }, + ]), + true, + ); assert.equal(doc1.getGarbageLen(), 4); assert.equal(doc2.getGarbageLen(), 4); - // (2, 2) -> (2, 2): syncedseqs:(1, 2) await client2.sync(); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + { actor: client2.getID()!, lamport: BigInt(4) }, + ]), + true, + ); assert.equal(doc1.getGarbageLen(), 4); assert.equal(doc2.getGarbageLen(), 4); - // (2, 2) -> (2, 2): syncedseqs:(2, 2): meet GC condition await client1.sync(); + await client1.sync(); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(5) }, + { actor: client2.getID()!, lamport: BigInt(4) }, + ]), + true, + ); assert.equal(doc1.getGarbageLen(), 0); assert.equal(doc2.getGarbageLen(), 4); - // (2, 2) -> (2, 2): syncedseqs:(2, 2): meet GC condition await client2.sync(); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + { actor: client2.getID()!, lamport: BigInt(4) }, + ]), + true, + ); assert.equal(doc1.getGarbageLen(), 0); assert.equal(doc2.getGarbageLen(), 0); @@ -222,7 +370,20 @@ describe('Garbage Collection', function () { await client2.activate(); await client1.attach(doc1, { syncMode: SyncMode.Manual }); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(1) }, + ]), + true, + ); await client2.attach(doc2, { syncMode: SyncMode.Manual }); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(1) }, + { actor: client2.getID()!, lamport: BigInt(2) }, + ]), + true, + ); doc1.update((root) => { root.text = new Text(); @@ -230,46 +391,100 @@ describe('Garbage Collection', function () { root.textWithAttr = new Text(); root.textWithAttr.edit(0, 0, 'Hello World'); }, 'sets text'); - + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + ]), + true, + ); assert.equal(doc1.getGarbageLen(), 0); assert.equal(doc2.getGarbageLen(), 0); - // (0, 0) -> (1, 0): syncedseqs:(0, 0) await client1.sync(); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(3) }, + { actor: client2.getID()!, lamport: BigInt(1) }, + ]), + true, + ); - // (1, 0) -> (1, 1): syncedseqs:(0, 0) await client2.sync(); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + { actor: client2.getID()!, lamport: BigInt(3) }, + ]), + true, + ); doc2.update((root) => { root.text.edit(0, 1, 'a'); root.text.edit(1, 2, 'b'); root.textWithAttr.edit(0, 1, 'a', { b: '1' }); }, 'edit text type elements'); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + { actor: client2.getID()!, lamport: BigInt(4) }, + ]), + true, + ); assert.equal(doc1.getGarbageLen(), 0); assert.equal(doc2.getGarbageLen(), 3); - // (1, 1) -> (1, 2): syncedseqs:(0, 1) await client2.sync(); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + { actor: client2.getID()!, lamport: BigInt(4) }, + ]), + true, + ); assert.equal(doc1.getGarbageLen(), 0); assert.equal(doc2.getGarbageLen(), 3); - // (1, 2) -> (2, 2): syncedseqs:(1, 1) await client1.sync(); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(5) }, + { actor: client2.getID()!, lamport: BigInt(4) }, + ]), + true, + ); assert.equal(doc1.getGarbageLen(), 3); assert.equal(doc2.getGarbageLen(), 3); - // (2, 2) -> (2, 2): syncedseqs:(1, 2) await client2.sync(); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + { actor: client2.getID()!, lamport: BigInt(4) }, + ]), + true, + ); assert.equal(doc1.getGarbageLen(), 3); assert.equal(doc2.getGarbageLen(), 3); - // (2, 2) -> (2, 2): syncedseqs:(2, 2): meet GC condition await client1.sync(); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(5) }, + { actor: client2.getID()!, lamport: BigInt(4) }, + ]), + true, + ); assert.equal(doc1.getGarbageLen(), 0); assert.equal(doc2.getGarbageLen(), 3); - // (2, 2) -> (2, 2): syncedseqs:(2, 2): meet GC condition await client2.sync(); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + { actor: client2.getID()!, lamport: BigInt(4) }, + ]), + true, + ); assert.equal(doc1.getGarbageLen(), 0); assert.equal(doc2.getGarbageLen(), 0); @@ -301,7 +516,20 @@ describe('Garbage Collection', function () { await client2.activate(); await client1.attach(doc1, { syncMode: SyncMode.Manual }); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(1) }, + ]), + true, + ); await client2.attach(doc2, { syncMode: SyncMode.Manual }); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(1) }, + { actor: client2.getID()!, lamport: BigInt(2) }, + ]), + true, + ); doc1.update((root) => { root['1'] = 1; @@ -312,38 +540,73 @@ describe('Garbage Collection', function () { root['5'] = new Text(); root['5'].edit(0, 0, 'hi'); }, 'sets 1, 2, 3, 4, 5'); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + ]), + true, + ); assert.equal(doc1.getGarbageLen(), 0); assert.equal(doc2.getGarbageLen(), 0); - // (0, 0) -> (1, 0): syncedseqs:(0, 0) await client1.sync(); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(3) }, + { actor: client2.getID()!, lamport: BigInt(1) }, + ]), + true, + ); - // (1, 0) -> (1, 1): syncedseqs:(0, 0) await client2.sync(); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + { actor: client2.getID()!, lamport: BigInt(3) }, + ]), + true, + ); doc1.update((root) => { delete root['2']; root['4'].edit(0, 1, 'h'); root['5'].edit(0, 1, 'h', { b: '1' }); }, 'removes 2 and edit text type elements'); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(4) }, + { actor: client2.getID()!, lamport: BigInt(1) }, + ]), + true, + ); assert.equal(doc1.getGarbageLen(), 6); assert.equal(doc2.getGarbageLen(), 0); - // (1, 1) -> (2, 1): syncedseqs:(1, 0) await client1.sync(); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(4) }, + { actor: client2.getID()!, lamport: BigInt(1) }, + ]), + true, + ); assert.equal(doc1.getGarbageLen(), 6); assert.equal(doc2.getGarbageLen(), 0); await client2.detach(doc2); - // (2, 1) -> (2, 2): syncedseqs:(1, x) await client2.sync(); assert.equal(doc1.getGarbageLen(), 6); assert.equal(doc2.getGarbageLen(), 6); - // (2, 2) -> (2, 2): syncedseqs:(2, x): meet GC condition await client1.sync(); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(5) }, + ]), + true, + ); assert.equal(doc1.getGarbageLen(), 0); assert.equal(doc2.getGarbageLen(), 6); @@ -363,15 +626,39 @@ describe('Garbage Collection', function () { await cli.activate(); await cli.attach(doc, { syncMode: SyncMode.Manual }); + assert.equal( + versionVectorHelper(doc.getVersionVector(), [ + { actor: cli.getID()!, lamport: BigInt(1) }, + ]), + true, + ); doc.update((root) => { root.point = { x: 0, y: 0 }; }); + assert.equal( + versionVectorHelper(doc.getVersionVector(), [ + { actor: cli.getID()!, lamport: BigInt(2) }, + ]), + true, + ); doc.update((root) => { root.point = { x: 1, y: 1 }; }); + assert.equal( + versionVectorHelper(doc.getVersionVector(), [ + { actor: cli.getID()!, lamport: BigInt(3) }, + ]), + true, + ); doc.update((root) => { root.point = { x: 2, y: 2 }; }); + assert.equal( + versionVectorHelper(doc.getVersionVector(), [ + { actor: cli.getID()!, lamport: BigInt(4) }, + ]), + true, + ); assert.equal(doc.getGarbageLen(), 6); assert.equal(doc.getGarbageLenFromClone(), 6); }); @@ -383,21 +670,45 @@ describe('Garbage Collection', function () { const docKey = toDocKey(`${task.name}-${new Date().getTime()}`); const doc = new yorkie.Document(docKey); const cli = new yorkie.Client(testRPCAddr); - await cli.activate(); + await cli.activate(); await cli.attach(doc, { syncMode: SyncMode.Manual }); + assert.equal( + versionVectorHelper(doc.getVersionVector(), [ + { actor: cli.getID()!, lamport: BigInt(1) }, + ]), + true, + ); doc.update((root) => { root.list = [0, 1, 2]; root.list.push([3, 4, 5]); }); + assert.equal( + versionVectorHelper(doc.getVersionVector(), [ + { actor: cli.getID()!, lamport: BigInt(2) }, + ]), + true, + ); assert.equal('{"list":[0,1,2,[3,4,5]]}', doc.toJSON()); doc.update((root) => { delete root.list[1]; }); + assert.equal( + versionVectorHelper(doc.getVersionVector(), [ + { actor: cli.getID()!, lamport: BigInt(3) }, + ]), + true, + ); assert.equal('{"list":[0,2,[3,4,5]]}', doc.toJSON()); doc.update((root) => { delete (root.list[2] as Array)[1]; }); + assert.equal( + versionVectorHelper(doc.getVersionVector(), [ + { actor: cli.getID()!, lamport: BigInt(4) }, + ]), + true, + ); assert.equal('{"list":[0,2,[3,5]]}', doc.toJSON()); assert.equal(doc.getGarbageLen(), 2); @@ -419,32 +730,107 @@ describe('Garbage Collection', function () { await client2.activate(); await client1.attach(doc1, { syncMode: SyncMode.Manual }); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(1) }, + ]), + true, + ); doc1.update((root) => (root.point = { x: 0, y: 0 })); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + ]), + true, + ); doc1.update((root) => (root.point.x = 1)); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(3) }, + ]), + true, + ); assert.equal(doc1.getGarbageLen(), 1); await client1.sync(); + assert.equal(doc1.getGarbageLen(), 0); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(3) }, + ]), + true, + ); await client2.attach(doc2, { syncMode: SyncMode.Manual }); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(3) }, + { actor: client2.getID()!, lamport: BigInt(4) }, + ]), + true, + ); assert.equal(doc2.getGarbageLen(), 1); doc2.update((root) => (root.point.x = 2)); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(3) }, + { actor: client2.getID()!, lamport: BigInt(5) }, + ]), + true, + ); assert.equal(doc2.getGarbageLen(), 2); doc1.update((root) => (root.point = { x: 3, y: 3 })); - assert.equal(doc1.getGarbageLen(), 4); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(4) }, + ]), + true, + ); + assert.equal(doc1.getGarbageLen(), 3); await client1.sync(); - assert.equal(doc1.getGarbageLen(), 4); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(5) }, + { actor: client2.getID()!, lamport: BigInt(1) }, + ]), + true, + ); + assert.equal(doc1.getGarbageLen(), 3); await client1.sync(); - assert.equal(doc1.getGarbageLen(), 4); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(5) }, + { actor: client2.getID()!, lamport: BigInt(1) }, + ]), + true, + ); + assert.equal(doc1.getGarbageLen(), 3); await client2.sync(); - assert.equal(doc1.getGarbageLen(), 4); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(4) }, + { actor: client2.getID()!, lamport: BigInt(6) }, + ]), + true, + ); + assert.equal(doc1.getGarbageLen(), 3); await client1.sync(); - assert.equal(doc1.getGarbageLen(), 5); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(6) }, + { actor: client2.getID()!, lamport: BigInt(5) }, + ]), + true, + ); + assert.equal(doc1.getGarbageLen(), 4); await client2.sync(); - assert.equal(doc1.getGarbageLen(), 5); + assert.equal(doc1.getGarbageLen(), 4); await client1.sync(); assert.equal(doc1.getGarbageLen(), 0); + await client2.sync(); + assert.equal(doc2.getGarbageLen(), 0); await client1.deactivate(); await client2.deactivate(); @@ -460,7 +846,10 @@ describe('Garbage Collection', function () { delete root.shape; }); assert.equal(doc.getGarbageLen(), 4); // shape, point, x, y - assert.equal(doc.garbageCollect(MaxTimeTicket), 4); // The number of GC nodes must also be 4. + assert.equal( + doc.garbageCollect(MaxVersionVector([doc.getChangeID().getActorID()])), + 4, + ); // The number of GC nodes must also be 4. }); it('Should work properly when there are multiple nodes to be collected in text type', async function ({ @@ -475,23 +864,74 @@ describe('Garbage Collection', function () { await client1.activate(); await client2.activate(); await client1.attach(doc1, { syncMode: SyncMode.Manual }); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(1) }, + ]), + true, + ); await client2.attach(doc2, { syncMode: SyncMode.Manual }); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(1) }, + { actor: client2.getID()!, lamport: BigInt(2) }, + ]), + true, + ); doc1.update((root) => { root.t = new yorkie.Text(); root.t.edit(0, 0, 'z'); }); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + ]), + true, + ); doc1.update((root) => { root.t.edit(0, 1, 'a'); }); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(3) }, + ]), + true, + ); doc1.update((root) => { root.t.edit(1, 1, 'b'); }); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(4) }, + ]), + true, + ); doc1.update((root) => { root.t.edit(2, 2, 'd'); }); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(5) }, + ]), + true, + ); await client1.sync(); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(6) }, + { actor: client2.getID()!, lamport: BigInt(1) }, + ]), + true, + ); await client2.sync(); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(5) }, + { actor: client2.getID()!, lamport: BigInt(6) }, + ]), + true, + ); assert.equal(doc1.getRoot().t.toString(), 'abd'); assert.equal(doc2.getRoot().t.toString(), 'abd'); assert.equal(doc1.getGarbageLen(), 1); // z @@ -499,23 +939,82 @@ describe('Garbage Collection', function () { doc1.update((root) => { root.t.edit(2, 2, 'c'); }); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(7) }, + { actor: client2.getID()!, lamport: BigInt(1) }, + ]), + true, + ); await client1.sync(); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(7) }, + { actor: client2.getID()!, lamport: BigInt(1) }, + ]), + true, + ); await client2.sync(); - await client2.sync(); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(7) }, + { actor: client2.getID()!, lamport: BigInt(8) }, + ]), + true, + ); + await client1.sync(); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(7) }, + { actor: client2.getID()!, lamport: BigInt(1) }, + ]), + true, + ); + assert.equal(doc1.getRoot().t.toString(), 'abcd'); assert.equal(doc2.getRoot().t.toString(), 'abcd'); doc1.update((root) => { root.t.edit(1, 3, ''); }); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(8) }, + { actor: client2.getID()!, lamport: BigInt(1) }, + ]), + true, + ); await client1.sync(); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(8) }, + { actor: client2.getID()!, lamport: BigInt(1) }, + ]), + true, + ); assert.equal(doc1.getRoot().t.toString(), 'ad'); assert.equal(doc1.getGarbageLen(), 2); // b,c await client2.sync(); - await client2.sync(); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(8) }, + { actor: client2.getID()!, lamport: BigInt(9) }, + ]), + true, + ); await client1.sync(); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(8) }, + { actor: client2.getID()!, lamport: BigInt(1) }, + ]), + true, + ); + await client2.sync(); + assert.equal(doc2.getGarbageLen(), 0); assert.equal(doc2.getRoot().t.toString(), 'ad'); + await client1.sync(); assert.equal(doc1.getGarbageLen(), 0); await client1.deactivate(); @@ -534,7 +1033,20 @@ describe('Garbage Collection', function () { await client1.activate(); await client2.activate(); await client1.attach(doc1, { syncMode: SyncMode.Manual }); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(1) }, + ]), + true, + ); await client2.attach(doc2, { syncMode: SyncMode.Manual }); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(1) }, + { actor: client2.getID()!, lamport: BigInt(2) }, + ]), + true, + ); doc1.update((root) => { root.t = new yorkie.Tree({ @@ -547,26 +1059,64 @@ describe('Garbage Collection', function () { ], }); }); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + ]), + true, + ); doc1.update((root) => { root.t.editByPath([0], [1], { type: 'text', value: 'a', }); }); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(3) }, + ]), + true, + ); doc1.update((root) => { root.t.editByPath([1], [1], { type: 'text', value: 'b', }); }); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(4) }, + ]), + true, + ); doc1.update((root) => { root.t.editByPath([2], [2], { type: 'text', value: 'd', }); }); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(5) }, + ]), + true, + ); await client1.sync(); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(6) }, + { actor: client2.getID()!, lamport: BigInt(1) }, + ]), + true, + ); await client2.sync(); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(5) }, + { actor: client2.getID()!, lamport: BigInt(6) }, + ]), + true, + ); assert.equal(doc1.getRoot().t.toXML(), 'abd'); assert.equal(doc2.getRoot().t.toXML(), 'abd'); assert.equal(doc1.getGarbageLen(), 1); // z @@ -577,24 +1127,474 @@ describe('Garbage Collection', function () { value: 'c', }); }); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(7) }, + { actor: client2.getID()!, lamport: BigInt(1) }, + ]), + true, + ); await client1.sync(); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(7) }, + { actor: client2.getID()!, lamport: BigInt(1) }, + ]), + true, + ); await client2.sync(); - await client2.sync(); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(7) }, + { actor: client2.getID()!, lamport: BigInt(8) }, + ]), + true, + ); assert.equal(doc1.getRoot().t.toXML(), 'abcd'); assert.equal(doc2.getRoot().t.toXML(), 'abcd'); doc1.update((root) => { root.t.editByPath([1], [3]); }); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(8) }, + { actor: client2.getID()!, lamport: BigInt(1) }, + ]), + true, + ); await client1.sync(); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(8) }, + { actor: client2.getID()!, lamport: BigInt(1) }, + ]), + true, + ); assert.equal(doc1.getRoot().t.toXML(), 'ad'); assert.equal(doc1.getGarbageLen(), 2); // b,c await client2.sync(); - await client2.sync(); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(8) }, + { actor: client2.getID()!, lamport: BigInt(9) }, + ]), + true, + ); await client1.sync(); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(8) }, + { actor: client2.getID()!, lamport: BigInt(1) }, + ]), + true, + ); assert.equal(doc2.getRoot().t.toXML(), 'ad'); + assert.equal(doc1.getGarbageLen(), 2); + + await client2.sync(); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(8) }, + { actor: client2.getID()!, lamport: BigInt(9) }, + ]), + true, + ); + assert.equal(doc2.getRoot().t.toXML(), 'ad'); + assert.equal(doc2.getGarbageLen(), 0); + + await client1.sync(); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(8) }, + { actor: client2.getID()!, lamport: BigInt(1) }, + ]), + true, + ); + assert.equal(doc1.getRoot().t.toXML(), 'ad'); + assert.equal(doc1.getGarbageLen(), 0); + + await client1.deactivate(); + await client2.deactivate(); + }); + + it('concurrent garbage collection test', async function ({ task }) { + type TestDoc = { t: Text }; + const docKey = toDocKey(`${task.name}-${new Date().getTime()}`); + const doc1 = new yorkie.Document(docKey); + const doc2 = new yorkie.Document(docKey); + const client1 = new yorkie.Client(testRPCAddr); + const client2 = new yorkie.Client(testRPCAddr); + await client1.activate(); + await client2.activate(); + + await client1.attach(doc1, { syncMode: SyncMode.Manual }); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(1) }, + ]), + true, + ); + + await client2.attach(doc2, { syncMode: SyncMode.Manual }); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(1) }, + { actor: client2.getID()!, lamport: BigInt(2) }, + ]), + true, + ); + + doc1.update((root) => { + root.t = new Text(); + root.t.edit(0, 0, 'a'); + root.t.edit(1, 1, 'b'); + root.t.edit(2, 2, 'c'); + }, 'sets text'); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + ]), + true, + ); + + await client1.sync(); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(3) }, + { actor: client2.getID()!, lamport: BigInt(1) }, + ]), + true, + ); + + await client2.sync(); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + { actor: client2.getID()!, lamport: BigInt(3) }, + ]), + true, + ); + + doc2.update((root) => { + root.t.edit(2, 2, 'c'); + }, 'insert c'); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + { actor: client2.getID()!, lamport: BigInt(4) }, + ]), + true, + ); + + doc1.update((root) => { + root.t.edit(1, 3, ''); + }, 'delete bd'); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(4) }, + { actor: client2.getID()!, lamport: BigInt(1) }, + ]), + true, + ); + + assert.equal(doc1.getGarbageLen(), 2); + assert.equal(doc2.getGarbageLen(), 0); + + await client1.sync(); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(4) }, + { actor: client2.getID()!, lamport: BigInt(1) }, + ]), + true, + ); + + await client2.sync(); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(4) }, + { actor: client2.getID()!, lamport: BigInt(5) }, + ]), + true, + ); + + assert.equal(doc1.getGarbageLen(), 2); + assert.equal(doc2.getGarbageLen(), 2); + + doc2.update((root) => { + root.t.edit(2, 2, '1'); + }, 'insert 1'); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(4) }, + { actor: client2.getID()!, lamport: BigInt(6) }, + ]), + true, + ); + + await client2.sync(); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(4) }, + { actor: client2.getID()!, lamport: BigInt(6) }, + ]), + true, + ); + + assert.equal(doc1.getGarbageLen(), 2); + assert.equal(doc2.getGarbageLen(), 0); + + await client1.sync(); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(7) }, + { actor: client2.getID()!, lamport: BigInt(6) }, + ]), + true, + ); + + assert.equal(doc1.getGarbageLen(), 0); + assert.equal(doc2.getGarbageLen(), 0); + + await client1.deactivate(); + await client2.deactivate(); + }); + + it('concurrent garbage collection test(with pushonly)', async function ({ + task, + }) { + type TestDoc = { t: Text }; + const docKey = toDocKey(`${task.name}-${new Date().getTime()}`); + const doc1 = new yorkie.Document(docKey); + const doc2 = new yorkie.Document(docKey); + const client1 = new yorkie.Client(testRPCAddr); + const client2 = new yorkie.Client(testRPCAddr); + await client1.activate(); + await client2.activate(); + + await client1.attach(doc1, { syncMode: SyncMode.Manual }); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(1) }, + ]), + true, + ); + + await client2.attach(doc2, { syncMode: SyncMode.Manual }); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(1) }, + { actor: client2.getID()!, lamport: BigInt(2) }, + ]), + true, + ); + + // d1/vv = [c1:2] + doc1.update((root) => { + root.t = new Text(); + root.t.edit(0, 0, 'a'); + root.t.edit(1, 1, 'b'); + }, 'insert ab'); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + ]), + true, + ); + + await client1.sync(); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(3) }, + { actor: client2.getID()!, lamport: BigInt(1) }, + ]), + true, + ); + + await client2.sync(); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + { actor: client2.getID()!, lamport: BigInt(3) }, + ]), + true, + ); + + // d2/vv = [c1:2, c2:4] + doc2.update((root) => { + root.t.edit(2, 2, 'd'); + }, 'insert d'); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + { actor: client2.getID()!, lamport: BigInt(4) }, + ]), + true, + ); + + await client2.sync(); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + { actor: client2.getID()!, lamport: BigInt(4) }, + ]), + true, + ); + + await client1.sync(); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(5) }, + { actor: client2.getID()!, lamport: BigInt(4) }, + ]), + true, + ); + + // d2/vv = [c1:2, c2:5] + doc2.update((root) => { + root.t.edit(2, 2, 'c'); + }, 'insert c'); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + { actor: client2.getID()!, lamport: BigInt(5) }, + ]), + true, + ); + + // c1/vv = [c1:6, c2:4] + doc1.update((root) => { + root.t.edit(1, 3, ''); + }, 'remove ac'); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(6) }, + { actor: client2.getID()!, lamport: BigInt(4) }, + ]), + true, + ); + + // Sync with PushOnly + await client2.changeSyncMode(doc2, SyncMode.RealtimePushOnly); + await client2.sync(); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + { actor: client2.getID()!, lamport: BigInt(5) }, + ]), + true, + ); + + await client1.sync(); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(7) }, + { actor: client2.getID()!, lamport: BigInt(5) }, + ]), + true, + ); + + // d2/vv = [c1:2, c2:6] + doc2.update((root) => { + root.t.edit(2, 2, '1'); + }, 'insert 1 (pushonly)'); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + { actor: client2.getID()!, lamport: BigInt(6) }, + ]), + true, + ); + + await client2.sync(); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + { actor: client2.getID()!, lamport: BigInt(6) }, + ]), + true, + ); + + await client1.sync(); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(8) }, + { actor: client2.getID()!, lamport: BigInt(6) }, + ]), + true, + ); + + assert.equal(doc1.getGarbageLen(), 2); + assert.equal(doc2.getGarbageLen(), 0); + + // c2/vv = [c1:2, c2:7] + doc2.update((root) => { + root.t.edit(2, 2, '2'); + }, 'insert 2 (pushonly)'); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + { actor: client2.getID()!, lamport: BigInt(7) }, + ]), + true, + ); + + await client2.sync(); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(2) }, + { actor: client2.getID()!, lamport: BigInt(7) }, + ]), + true, + ); + + await client2.changeSyncMode(doc2, SyncMode.Manual); + await client2.sync(); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(6) }, + { actor: client2.getID()!, lamport: BigInt(8) }, + ]), + true, + ); + + await client1.sync(); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(9) }, + { actor: client2.getID()!, lamport: BigInt(7) }, + ]), + true, + ); + + assert.equal(doc1.getGarbageLen(), 2); + assert.equal(doc2.getGarbageLen(), 2); + + await client2.sync(); + assert.equal( + versionVectorHelper(doc2.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(6) }, + { actor: client2.getID()!, lamport: BigInt(8) }, + ]), + true, + ); + + assert.equal(doc1.getGarbageLen(), 2); + assert.equal(doc2.getGarbageLen(), 0); + + await client1.sync(); + assert.equal( + versionVectorHelper(doc1.getVersionVector(), [ + { actor: client1.getID()!, lamport: BigInt(9) }, + { actor: client2.getID()!, lamport: BigInt(7) }, + ]), + true, + ); + assert.equal(doc1.getGarbageLen(), 0); + assert.equal(doc2.getGarbageLen(), 0); await client1.deactivate(); await client2.deactivate(); diff --git a/packages/sdk/test/integration/object_test.ts b/packages/sdk/test/integration/object_test.ts index b033e100e..77ead77f5 100644 --- a/packages/sdk/test/integration/object_test.ts +++ b/packages/sdk/test/integration/object_test.ts @@ -656,7 +656,7 @@ describe('Object', function () { let doc1Checkpoint = doc1.getCheckpoint(); assert.equal(doc1ChangeID.getClientSeq(), 1); assert.equal(doc1Checkpoint.getClientSeq(), 1); - assert.equal(doc1Checkpoint.getServerSeq().toInt(), 1); + assert.equal(doc1Checkpoint.getServerSeq(), 1n); doc1.update((root) => { root.shape = { color: 'black' }; @@ -667,7 +667,7 @@ describe('Object', function () { doc1Checkpoint = doc1.getCheckpoint(); assert.equal(doc1ChangeID.getClientSeq(), 2); assert.equal(doc1Checkpoint.getClientSeq(), 2); - assert.equal(doc1Checkpoint.getServerSeq().toInt(), 2); + assert.equal(doc1Checkpoint.getServerSeq(), 2n); await client2.attach(doc2, { syncMode: SyncMode.Manual }); assert.equal(doc2.toSortedJSON(), '{"shape":{"color":"black"}}'); @@ -683,7 +683,7 @@ describe('Object', function () { doc1Checkpoint = doc1.getCheckpoint(); assert.equal(doc1ChangeID.getClientSeq(), 2); assert.equal(doc1Checkpoint.getClientSeq(), 2); - assert.equal(doc1Checkpoint.getServerSeq().toInt(), 4); + assert.equal(doc1Checkpoint.getServerSeq(), 4n); // c2 deleted the shape, so the reverse operation cannot be applied doc1.history.undo(); @@ -698,7 +698,7 @@ describe('Object', function () { doc1Checkpoint = doc1.getCheckpoint(); assert.equal(doc1ChangeID.getClientSeq(), 2); assert.equal(doc1Checkpoint.getClientSeq(), 2); - assert.equal(doc1Checkpoint.getServerSeq().toInt(), 4); + assert.equal(doc1Checkpoint.getServerSeq(), 4n); doc1.update((root) => { root.shape = { color: 'red' }; @@ -709,7 +709,7 @@ describe('Object', function () { doc1Checkpoint = doc1.getCheckpoint(); assert.equal(doc1ChangeID.getClientSeq(), 3); assert.equal(doc1Checkpoint.getClientSeq(), 3); - assert.equal(doc1Checkpoint.getServerSeq().toInt(), 5); + assert.equal(doc1Checkpoint.getServerSeq(), 5n); }); it(`Should not propagate changes when there is no applied undo operation`, async function ({ @@ -732,7 +732,7 @@ describe('Object', function () { let doc1Checkpoint = doc1.getCheckpoint(); assert.equal(doc1ChangeID.getClientSeq(), 1); assert.equal(doc1Checkpoint.getClientSeq(), 1); - assert.equal(doc1Checkpoint.getServerSeq().toInt(), 1); + assert.equal(doc1Checkpoint.getServerSeq(), 1n); doc1.update((root) => { root.shape = { color: 'black' }; @@ -743,7 +743,7 @@ describe('Object', function () { doc1Checkpoint = doc1.getCheckpoint(); assert.equal(doc1ChangeID.getClientSeq(), 2); assert.equal(doc1Checkpoint.getClientSeq(), 2); - assert.equal(doc1Checkpoint.getServerSeq().toInt(), 2); + assert.equal(doc1Checkpoint.getServerSeq(), 2n); await client2.attach(doc2, { syncMode: SyncMode.Manual }); assert.equal(doc2.toSortedJSON(), '{"shape":{"color":"black"}}'); @@ -759,7 +759,7 @@ describe('Object', function () { doc1Checkpoint = doc1.getCheckpoint(); assert.equal(doc1ChangeID.getClientSeq(), 2); assert.equal(doc1Checkpoint.getClientSeq(), 2); - assert.equal(doc1Checkpoint.getServerSeq().toInt(), 4); + assert.equal(doc1Checkpoint.getServerSeq(), 4n); // c2 deleted the shape, so the reverse operation cannot be applied doc1.history.undo(); @@ -774,7 +774,7 @@ describe('Object', function () { doc1Checkpoint = doc1.getCheckpoint(); assert.equal(doc1ChangeID.getClientSeq(), 2); assert.equal(doc1Checkpoint.getClientSeq(), 2); - assert.equal(doc1Checkpoint.getServerSeq().toInt(), 4); + assert.equal(doc1Checkpoint.getServerSeq(), 4n); doc1.update((root) => { root.shape = { color: 'red' }; @@ -785,7 +785,7 @@ describe('Object', function () { doc1Checkpoint = doc1.getCheckpoint(); assert.equal(doc1ChangeID.getClientSeq(), 3); assert.equal(doc1Checkpoint.getClientSeq(), 3); - assert.equal(doc1Checkpoint.getServerSeq().toInt(), 5); + assert.equal(doc1Checkpoint.getServerSeq(), 5n); }); it('Can handle concurrent undo/redo: local undo & global redo', async function ({ diff --git a/packages/sdk/test/unit/document/crdt/root_test.ts b/packages/sdk/test/unit/document/crdt/root_test.ts index 6e94776a0..042076750 100644 --- a/packages/sdk/test/unit/document/crdt/root_test.ts +++ b/packages/sdk/test/unit/document/crdt/root_test.ts @@ -13,6 +13,7 @@ import { CRDTArray } from '@yorkie-js-sdk/src/document/crdt/array'; import { CRDTText } from '@yorkie-js-sdk/src/document/crdt/text'; import { RGATreeSplit } from '@yorkie-js-sdk/src/document/crdt/rga_tree_split'; import { Text } from '@yorkie-js-sdk/src/yorkie'; +import { MaxVersionVector } from '@yorkie-js-sdk/test/helper/helper'; describe('ROOT', function () { it('basic test', function () { @@ -103,7 +104,7 @@ describe('ROOT', function () { assert.equal(0, arrJs2?.[0]); assert.equal(2, arrJs2?.[1]); - assert.equal(1, root.garbageCollect(MaxTimeTicket)); + assert.equal(1, root.garbageCollect(MaxVersionVector([]))); assert.equal(0, root.getGarbageLen()); }); @@ -129,7 +130,7 @@ describe('ROOT', function () { text.edit(0, 6, ''); assert.equal(2, root.getGarbageLen()); - assert.equal(2, root.garbageCollect(MaxTimeTicket)); + assert.equal(2, root.garbageCollect(MaxVersionVector([]))); assert.equal('[0:00:0:0 ][0:00:3:0 Yorkie]', text.toTestString()); assert.equal(0, root.getGarbageLen()); }); diff --git a/packages/sdk/test/unit/document/document_test.ts b/packages/sdk/test/unit/document/document_test.ts index e91b9286c..e0c3bac6e 100644 --- a/packages/sdk/test/unit/document/document_test.ts +++ b/packages/sdk/test/unit/document/document_test.ts @@ -15,9 +15,11 @@ */ import { describe, it, assert, vi, afterEach } from 'vitest'; -import { EventCollector } from '@yorkie-js-sdk/test/helper/helper'; +import { + EventCollector, + MaxVersionVector, +} from '@yorkie-js-sdk/test/helper/helper'; -import { MaxTimeTicket } from '@yorkie-js-sdk/src/document/time/ticket'; import { Document, DocEventType } from '@yorkie-js-sdk/src/document/document'; import { OperationInfo } from '@yorkie-js-sdk/src/document/operation/operation'; import { JSONArray, Text, Counter, Tree } from '@yorkie-js-sdk/src/yorkie'; @@ -1233,7 +1235,7 @@ describe.sequential('Document', function () { assert.equal('{}', doc.toSortedJSON()); assert.equal(2, doc.getGarbageLen()); - doc.garbageCollect(MaxTimeTicket); + doc.garbageCollect(MaxVersionVector([doc.getChangeID().getActorID()])); assert.equal('{}', doc.toSortedJSON()); assert.equal(0, doc.getGarbageLen()); }); @@ -1249,7 +1251,7 @@ describe.sequential('Document', function () { doc.update((root) => root.k1.edit(1, 3, '')); assert.equal(doc.getRoot().k1.getTreeByID().size(), 3); - doc.garbageCollect(MaxTimeTicket); + doc.garbageCollect(MaxVersionVector([doc.getChangeID().getActorID()])); assert.equal(doc.getRoot().k1.getTreeByID().size(), 2); }); diff --git a/packages/sdk/test/unit/document/gc_test.ts b/packages/sdk/test/unit/document/gc_test.ts index fa0aa2ab5..597b70d28 100644 --- a/packages/sdk/test/unit/document/gc_test.ts +++ b/packages/sdk/test/unit/document/gc_test.ts @@ -16,10 +16,9 @@ import { CRDTArray } from '@yorkie-js-sdk/src/document/crdt/array'; import { CRDTTreeNode } from '@yorkie-js-sdk/src/document/crdt/tree'; -import { MaxTimeTicket } from '@yorkie-js-sdk/src/document/time/ticket'; import { IndexTreeNode } from '@yorkie-js-sdk/src/util/index_tree'; import yorkie, { Tree, Text } from '@yorkie-js-sdk/src/yorkie'; -import { timeT } from '@yorkie-js-sdk/test/helper/helper'; +import { MaxVersionVector } from '@yorkie-js-sdk/test/helper/helper'; import { describe, it, assert } from 'vitest'; // `getNodeLength` returns the number of nodes in the given tree. @@ -58,7 +57,10 @@ describe('Garbage Collection', function () { }, 'deletes 2'); assert.equal(doc.toSortedJSON(), '{"1":1,"3":3}'); assert.equal(doc.getGarbageLen(), 4); - assert.equal(doc.garbageCollect(MaxTimeTicket), 4); + assert.equal( + doc.garbageCollect(MaxVersionVector([doc.getChangeID().getActorID()])), + 4, + ); assert.equal(doc.getGarbageLen(), 0); }); @@ -81,7 +83,10 @@ describe('Garbage Collection', function () { }, 'deletes 2'); assert.equal(doc.toSortedJSON(), '{"1":1,"3":3}'); assert.equal(doc.getGarbageLen(), 4); - assert.equal(doc.garbageCollect(MaxTimeTicket), 0); + assert.equal( + doc.garbageCollect(MaxVersionVector([doc.getChangeID().getActorID()])), + 0, + ); assert.equal(doc.getGarbageLen(), 4); }); @@ -96,7 +101,10 @@ describe('Garbage Collection', function () { delete root['1']; }, 'deletes the array'); - assert.equal(doc.garbageCollect(MaxTimeTicket), size + 1); + assert.equal( + doc.garbageCollect(MaxVersionVector([doc.getChangeID().getActorID()])), + size + 1, + ); }); it('should collect garbage for nested elements', function () { @@ -114,7 +122,10 @@ describe('Garbage Collection', function () { assert.equal(doc.toSortedJSON(), '{"list":[1,3]}'); assert.equal(doc.getGarbageLen(), 1); - assert.equal(doc.garbageCollect(MaxTimeTicket), 1); + assert.equal( + doc.garbageCollect(MaxVersionVector([doc.getChangeID().getActorID()])), + 1, + ); assert.equal(doc.getGarbageLen(), 0); const root = (doc.getRootObject().get('list') as CRDTArray) @@ -139,7 +150,7 @@ describe('Garbage Collection', function () { ); assert.equal(doc.getGarbageLen(), 1); - doc.garbageCollect(MaxTimeTicket); + doc.garbageCollect(MaxVersionVector([doc.getChangeID().getActorID()])); assert.equal(doc.getGarbageLen(), 0); assert.equal( @@ -174,7 +185,10 @@ describe('Garbage Collection', function () { assert.equal(doc.toSortedJSON(), '{"k1":[{"val":"c"},{"val":"d"}]}'); assert.equal(doc.getGarbageLen(), 2); - assert.equal(doc.garbageCollect(MaxTimeTicket), 2); + assert.equal( + doc.garbageCollect(MaxVersionVector([doc.getChangeID().getActorID()])), + 2, + ); assert.equal(doc.getGarbageLen(), 0); }); @@ -208,7 +222,10 @@ describe('Garbage Collection', function () { const expectedGarbageLen = 4; assert.equal(doc.getGarbageLen(), expectedGarbageLen); - assert.equal(doc.garbageCollect(MaxTimeTicket), expectedGarbageLen); + assert.equal( + doc.garbageCollect(MaxVersionVector([doc.getChangeID().getActorID()])), + expectedGarbageLen, + ); const empty = 0; assert.equal(doc.getGarbageLen(), empty); @@ -249,7 +266,10 @@ describe('Garbage Collection', function () { doc.getRoot().t.getIndexTree().getRoot(), ); assert.equal(doc.getGarbageLen(), 2); - assert.equal(doc.garbageCollect(MaxTimeTicket), 2); + assert.equal( + doc.garbageCollect(MaxVersionVector([doc.getChangeID().getActorID()])), + 2, + ); assert.equal(doc.getGarbageLen(), 0); let nodeLengthAfterGC = getNodeLength( doc.getRoot().t.getIndexTree().getRoot(), @@ -266,7 +286,10 @@ describe('Garbage Collection', function () { doc.getRoot().t.getIndexTree().getRoot(), ); assert.equal(doc.getGarbageLen(), 1); - assert.equal(doc.garbageCollect(MaxTimeTicket), 1); + assert.equal( + doc.garbageCollect(MaxVersionVector([doc.getChangeID().getActorID()])), + 1, + ); assert.equal(doc.getGarbageLen(), 0); nodeLengthAfterGC = getNodeLength(doc.getRoot().t.getIndexTree().getRoot()); assert.equal(nodeLengthBeforeGC - nodeLengthAfterGC, 1); @@ -284,7 +307,10 @@ describe('Garbage Collection', function () { doc.getRoot().t.getIndexTree().getRoot(), ); assert.equal(doc.getGarbageLen(), 5); - assert.equal(doc.garbageCollect(MaxTimeTicket), 5); + assert.equal( + doc.garbageCollect(MaxVersionVector([doc.getChangeID().getActorID()])), + 5, + ); assert.equal(doc.getGarbageLen(), 0); nodeLengthAfterGC = getNodeLength(doc.getRoot().t.getIndexTree().getRoot()); assert.equal(nodeLengthBeforeGC - nodeLengthAfterGC, 5); @@ -325,7 +351,10 @@ describe('Garbage Collection', function () { assert.equal(doc.getRoot().t.toXML(), `

`); assert.equal(doc.getGarbageLen(), 3); - assert.equal(doc.garbageCollect(MaxTimeTicket), 3); + assert.equal( + doc.garbageCollect(MaxVersionVector([doc.getChangeID().getActorID()])), + 3, + ); assert.equal(doc.getGarbageLen(), 0); }); @@ -338,7 +367,10 @@ describe('Garbage Collection', function () { delete root.shape; }); assert.equal(doc.getGarbageLen(), 4); // shape, point, x, y - assert.equal(doc.garbageCollect(MaxTimeTicket), 4); // The number of GC nodes must also be 4. + assert.equal( + doc.garbageCollect(MaxVersionVector([doc.getChangeID().getActorID()])), + 4, + ); // The number of GC nodes must also be 4. }); }); @@ -506,14 +538,16 @@ describe('Garbage Collection for tree', () => { } else if (code === OpCode.DeleteNode) { root.t.edit(0, 2, undefined, 0); } else if (code === OpCode.GC) { - doc.garbageCollect(MaxTimeTicket); + doc.garbageCollect( + MaxVersionVector([doc.getChangeID().getActorID()]), + ); } }); assert.equal(doc.getRoot().t.toXML(), expectXML); assert.equal(doc.getGarbageLen(), garbageLen); } - doc.garbageCollect(MaxTimeTicket); + doc.garbageCollect(MaxVersionVector([doc.getChangeID().getActorID()])); assert.equal(doc.getGarbageLen(), 0); }); }); @@ -597,14 +631,14 @@ describe('Garbage Collection for text', () => { } else if (code === OpCode.DeleteNode) { root.t.edit(0, 2, ''); } else if (code === OpCode.GC) { - doc.garbageCollect(timeT()); + doc.garbageCollect(doc.getChangeID().getVersionVector()); } }); assert.equal(doc.getRoot().t.toJSON(), expectXML); assert.equal(doc.getGarbageLen(), garbageLen); } - doc.garbageCollect(MaxTimeTicket); + doc.garbageCollect(MaxVersionVector([doc.getChangeID().getActorID()])); assert.equal(doc.getGarbageLen(), 0); }); }); diff --git a/packages/sdk/tsconfig.json b/packages/sdk/tsconfig.json index 6053b43d6..c1181df3e 100644 --- a/packages/sdk/tsconfig.json +++ b/packages/sdk/tsconfig.json @@ -1,9 +1,9 @@ { "compilerOptions": { - "target": "ES2019", + "target": "ES2020", "useDefineForClassFields": true, "module": "ESNext", - "lib": ["ES2019", "dom"], + "lib": ["ES2020", "dom"], "skipLibCheck": true, "outDir": "./lib", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3ec646ed9..b261a0b2e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -443,8 +443,8 @@ importers: specifier: ^3.9.1 version: 3.9.1(@types/node@20.4.2)(rollup@4.20.0)(typescript@5.3.3)(vite@5.3.5(@types/node@20.4.2)(less@4.2.0)(lightningcss@1.23.0)(sass@1.70.0)(terser@5.31.3)) vite-tsconfig-paths: - specifier: ^4.2.1 - version: 4.2.1(typescript@5.3.3)(vite@5.3.5(@types/node@20.4.2)(less@4.2.0)(lightningcss@1.23.0)(sass@1.70.0)(terser@5.31.3)) + specifier: ^4.3.1 + version: 4.3.2(typescript@5.3.3)(vite@5.3.5(@types/node@20.4.2)(less@4.2.0)(lightningcss@1.23.0)(sass@1.70.0)(terser@5.31.3)) vitest: specifier: ^0.34.5 version: 0.34.6(less@4.2.0)(lightningcss@1.23.0)(sass@1.70.0)(terser@5.31.3) @@ -6641,16 +6641,6 @@ packages: '@swc/wasm': optional: true - tsconfck@2.1.2: - resolution: {integrity: sha512-ghqN1b0puy3MhhviwO2kGF8SeMDNhEbnKxjK7h6+fvY9JAxqvXi8y5NAHSQv687OVboS2uZIByzGd45/YxrRHg==} - engines: {node: ^14.13.1 || ^16 || >=18} - hasBin: true - peerDependencies: - typescript: ^4.3.5 || ^5.0.0 - peerDependenciesMeta: - typescript: - optional: true - tsconfck@3.1.1: resolution: {integrity: sha512-00eoI6WY57SvZEVjm13stEVE90VkEdJAFGgpFLTsZbJyW/LwFQ7uQxJHWpZ2hzSWgCPKc9AnBnNP+0X7o3hAmQ==} engines: {node: ^18 || >=20} @@ -6913,14 +6903,6 @@ packages: vite-plugin-dynamic-import@1.5.0: resolution: {integrity: sha512-Qp85c+AVJmLa8MLni74U4BDiWpUeFNx7NJqbGZyR2XJOU7mgW0cb7nwlAMucFyM4arEd92Nfxp4j44xPi6Fu7g==} - vite-tsconfig-paths@4.2.1: - resolution: {integrity: sha512-GNUI6ZgPqT3oervkvzU+qtys83+75N/OuDaQl7HmOqFTb0pjZsuARrRipsyJhJ3enqV8beI1xhGbToR4o78nSQ==} - peerDependencies: - vite: '*' - peerDependenciesMeta: - vite: - optional: true - vite-tsconfig-paths@4.3.2: resolution: {integrity: sha512-0Vd/a6po6Q+86rPlntHye7F31zA2URZMbH8M3saAZ/xR9QoGN/L21bxEGfXdWmFdNkqPpRdxFT7nmNe12e9/uA==} peerDependencies: @@ -7864,7 +7846,7 @@ snapshots: '@eslint/eslintrc@1.3.0': dependencies: ajv: 6.12.6 - debug: 4.3.4 + debug: 4.3.6 espree: 9.3.2 globals: 13.16.0 ignore: 5.2.4 @@ -7962,7 +7944,7 @@ snapshots: '@humanwhocodes/config-array@0.9.5': dependencies: '@humanwhocodes/object-schema': 1.2.1 - debug: 4.3.4 + debug: 4.3.6 minimatch: 3.1.2 transitivePeerDependencies: - supports-color @@ -8004,7 +7986,7 @@ snapshots: '@jridgewell/source-map@0.3.5': dependencies: - '@jridgewell/gen-mapping': 0.3.2 + '@jridgewell/gen-mapping': 0.3.5 '@jridgewell/trace-mapping': 0.3.25 '@jridgewell/sourcemap-codec@1.4.14': {} @@ -11003,7 +10985,7 @@ snapshots: chokidar@3.5.3: dependencies: anymatch: 3.1.2 - braces: 3.0.2 + braces: 3.0.3 glob-parent: 5.1.2 is-binary-path: 2.1.0 is-glob: 4.0.3 @@ -11778,12 +11760,12 @@ snapshots: ajv: 6.12.6 chalk: 4.1.1 cross-spawn: 7.0.3 - debug: 4.3.4 + debug: 4.3.6 doctrine: 3.0.0 escape-string-regexp: 4.0.0 eslint-scope: 7.1.1 eslint-utils: 3.0.0(eslint@8.19.0) - eslint-visitor-keys: 3.3.0 + eslint-visitor-keys: 3.4.3 espree: 9.3.2 esquery: 1.4.0 esutils: 2.0.3 @@ -11815,7 +11797,7 @@ snapshots: dependencies: acorn: 8.10.0 acorn-jsx: 5.3.2(acorn@8.10.0) - eslint-visitor-keys: 3.3.0 + eslint-visitor-keys: 3.4.3 esquery@1.4.0: dependencies: @@ -14411,10 +14393,6 @@ snapshots: optionalDependencies: '@swc/core': 1.3.104(@swc/helpers@0.5.2) - tsconfck@2.1.2(typescript@5.3.3): - optionalDependencies: - typescript: 5.3.3 - tsconfck@3.1.1(typescript@5.3.3): optionalDependencies: typescript: 5.3.3 @@ -14680,11 +14658,11 @@ snapshots: fast-glob: 3.3.2 magic-string: 0.30.10 - vite-tsconfig-paths@4.2.1(typescript@5.3.3)(vite@5.3.5(@types/node@20.4.2)(less@4.2.0)(lightningcss@1.23.0)(sass@1.70.0)(terser@5.31.3)): + vite-tsconfig-paths@4.3.2(typescript@5.3.3)(vite@5.3.5(@types/node@20.4.2)(less@4.2.0)(lightningcss@1.23.0)(sass@1.70.0)(terser@5.31.3)): dependencies: debug: 4.3.4 globrex: 0.1.2 - tsconfck: 2.1.2(typescript@5.3.3) + tsconfck: 3.1.1(typescript@5.3.3) optionalDependencies: vite: 5.3.5(@types/node@20.4.2)(less@4.2.0)(lightningcss@1.23.0)(sass@1.70.0)(terser@5.31.3) transitivePeerDependencies: