Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 0 additions & 49 deletions packages/sdk/src/api/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,6 @@ function toOperation(operation: Operation): PbOperation {
);
pbEditOperation.from = toTextNodePos(editOperation.getFromPos());
pbEditOperation.to = toTextNodePos(editOperation.getToPos());
const pbCreatedAtMapByActor = pbEditOperation.createdAtMapByActor;
for (const [key, value] of editOperation.getMaxCreatedAtMapByActor()) {
pbCreatedAtMapByActor[key] = toTimeTicket(value)!;
}
pbEditOperation.content = editOperation.getContent();
const pbAttributes = pbEditOperation.attributes;
for (const [key, value] of editOperation.getAttributes()) {
Expand All @@ -416,10 +412,6 @@ function toOperation(operation: Operation): PbOperation {
);
pbStyleOperation.from = toTextNodePos(styleOperation.getFromPos());
pbStyleOperation.to = toTextNodePos(styleOperation.getToPos());
const pbCreatedAtMapByActor = pbStyleOperation.createdAtMapByActor;
for (const [key, value] of styleOperation.getMaxCreatedAtMapByActor()) {
pbCreatedAtMapByActor[key] = toTimeTicket(value)!;
}
const pbAttributes = pbStyleOperation.attributes;
for (const [key, value] of styleOperation.getAttributes()) {
pbAttributes[key] = value;
Expand All @@ -442,10 +434,6 @@ function toOperation(operation: Operation): PbOperation {
} else if (operation instanceof TreeEditOperation) {
const treeEditOperation = operation as TreeEditOperation;
const pbTreeEditOperation = new PbOperation_TreeEdit();
const pbCreatedAtMapByActor = pbTreeEditOperation.createdAtMapByActor;
for (const [key, value] of treeEditOperation.getMaxCreatedAtMapByActor()) {
pbCreatedAtMapByActor[key] = toTimeTicket(value)!;
}
pbTreeEditOperation.parentCreatedAt = toTimeTicket(
treeEditOperation.getParentCreatedAt(),
);
Expand All @@ -469,10 +457,6 @@ function toOperation(operation: Operation): PbOperation {
);
pbTreeStyleOperation.from = toTreePos(treeStyleOperation.getFromPos());
pbTreeStyleOperation.to = toTreePos(treeStyleOperation.getToPos());
const pbCreatedAtMapByActor = pbTreeStyleOperation.createdAtMapByActor;
for (const [key, value] of treeStyleOperation.getMaxCreatedAtMapByActor()) {
pbCreatedAtMapByActor[key] = toTimeTicket(value)!;
}

const attributesToRemove = treeStyleOperation.getAttributesToRemove();
if (attributesToRemove.length > 0) {
Expand Down Expand Up @@ -799,7 +783,6 @@ function toChangePack(pack: ChangePack<Indexable>): PbChangePack {
changes: toChanges(pack.getChanges()),
snapshot: pack.getSnapshot(),
versionVector: toVersionVector(pack.getVersionVector()),
minSyncedTicket: toTimeTicket(pack.getMinSyncedTicket()),
});
}

Expand Down Expand Up @@ -1206,12 +1189,6 @@ function fromOperation(pbOperation: PbOperation): Operation | undefined {
);
} else if (pbOperation.body.case === 'edit') {
const pbEditOperation = pbOperation.body.value;
const createdAtMapByActor = new Map();
Object.entries(pbEditOperation!.createdAtMapByActor).forEach(
([key, value]) => {
createdAtMapByActor.set(key, fromTimeTicket(value));
},
);
const attributes = new Map();
Object.entries(pbEditOperation!.attributes).forEach(([key, value]) => {
attributes.set(key, value);
Expand All @@ -1220,19 +1197,12 @@ function fromOperation(pbOperation: PbOperation): Operation | undefined {
fromTimeTicket(pbEditOperation!.parentCreatedAt)!,
fromTextNodePos(pbEditOperation!.from!),
fromTextNodePos(pbEditOperation!.to!),
createdAtMapByActor,
pbEditOperation!.content,
attributes,
fromTimeTicket(pbEditOperation!.executedAt)!,
);
} else if (pbOperation.body.case === 'style') {
const pbStyleOperation = pbOperation.body.value;
const createdAtMapByActor = new Map();
Object.entries(pbStyleOperation!.createdAtMapByActor).forEach(
([key, value]) => {
createdAtMapByActor.set(key, fromTimeTicket(value));
},
);
const attributes = new Map();
Object.entries(pbStyleOperation!.attributes).forEach(([key, value]) => {
attributes.set(key, value);
Expand All @@ -1241,7 +1211,6 @@ function fromOperation(pbOperation: PbOperation): Operation | undefined {
fromTimeTicket(pbStyleOperation!.parentCreatedAt)!,
fromTextNodePos(pbStyleOperation!.from!),
fromTextNodePos(pbStyleOperation!.to!),
createdAtMapByActor,
attributes,
fromTimeTicket(pbStyleOperation!.executedAt)!,
);
Expand All @@ -1257,40 +1226,24 @@ function fromOperation(pbOperation: PbOperation): Operation | undefined {
);
} else if (pbOperation.body.case === 'treeEdit') {
const pbTreeEditOperation = pbOperation.body.value;
const createdAtMapByActor = new Map();
Object.entries(pbTreeEditOperation!.createdAtMapByActor).forEach(
([key, value]) => {
createdAtMapByActor.set(key, fromTimeTicket(value));
},
);
return TreeEditOperation.create(
fromTimeTicket(pbTreeEditOperation!.parentCreatedAt)!,
fromTreePos(pbTreeEditOperation!.from!),
fromTreePos(pbTreeEditOperation!.to!),
fromTreeNodesWhenEdit(pbTreeEditOperation!.contents),
pbTreeEditOperation!.splitLevel,
createdAtMapByActor,
fromTimeTicket(pbTreeEditOperation!.executedAt)!,
);
} else if (pbOperation.body.case === 'treeStyle') {
const pbTreeStyleOperation = pbOperation.body.value;
const attributes = new Map();
const attributesToRemove = pbTreeStyleOperation.attributesToRemove;
const createdAtMapByActor = new Map();
if (pbTreeStyleOperation?.createdAtMapByActor) {
Object.entries(pbTreeStyleOperation!.createdAtMapByActor).forEach(
([key, value]) => {
createdAtMapByActor.set(key, fromTimeTicket(value));
},
);
}

if (attributesToRemove?.length > 0) {
return TreeStyleOperation.createTreeRemoveStyleOperation(
fromTimeTicket(pbTreeStyleOperation!.parentCreatedAt)!,
fromTreePos(pbTreeStyleOperation!.from!),
fromTreePos(pbTreeStyleOperation!.to!),
createdAtMapByActor,
attributesToRemove,
fromTimeTicket(pbTreeStyleOperation!.executedAt)!,
);
Expand All @@ -1304,7 +1257,6 @@ function fromOperation(pbOperation: PbOperation): Operation | undefined {
fromTimeTicket(pbTreeStyleOperation!.parentCreatedAt)!,
fromTreePos(pbTreeStyleOperation!.from!),
fromTreePos(pbTreeStyleOperation!.to!),
createdAtMapByActor,
attributes,
fromTimeTicket(pbTreeStyleOperation!.executedAt)!,
);
Expand Down Expand Up @@ -1372,7 +1324,6 @@ function fromChangePack<P extends Indexable>(
fromChanges(pbPack.changes),
fromVersionVector(pbPack.versionVector),
pbPack.snapshot,
fromTimeTicket(pbPack.minSyncedTicket),
);
}

Expand Down
10 changes: 5 additions & 5 deletions packages/sdk/src/api/yorkie/v1/resources.proto
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ message ChangePack {
Checkpoint checkpoint = 2;
bytes snapshot = 3;
repeated Change changes = 4;
TimeTicket min_synced_ticket = 5;
TimeTicket min_synced_ticket = 5; // deprecated
bool is_removed = 6;
VersionVector version_vector = 7;
}
Expand Down Expand Up @@ -96,7 +96,7 @@ message Operation {
TimeTicket parent_created_at = 1;
TextNodePos from = 2;
TextNodePos to = 3;
map<string, TimeTicket> created_at_map_by_actor = 4;
map<string, TimeTicket> created_at_map_by_actor = 4; // deprecated
string content = 5;
TimeTicket executed_at = 6;
map<string, string> attributes = 7;
Expand All @@ -117,7 +117,7 @@ message Operation {
TextNodePos to = 3;
map<string, string> attributes = 4;
TimeTicket executed_at = 5;
map<string, TimeTicket> created_at_map_by_actor = 6;
map<string, TimeTicket> created_at_map_by_actor = 6; // deprecated
}
message Increase {
TimeTicket parent_created_at = 1;
Expand All @@ -128,7 +128,7 @@ message Operation {
TimeTicket parent_created_at = 1;
TreePos from = 2;
TreePos to = 3;
map<string, TimeTicket> created_at_map_by_actor = 4;
map<string, TimeTicket> created_at_map_by_actor = 4; // deprecated
repeated TreeNodes contents = 5;
int32 split_level = 7;
TimeTicket executed_at = 6;
Expand All @@ -140,7 +140,7 @@ message Operation {
map<string, string> attributes = 4;
TimeTicket executed_at = 5;
repeated string attributes_to_remove = 6;
map<string, TimeTicket> created_at_map_by_actor = 7;
map<string, TimeTicket> created_at_map_by_actor = 7; // deprecated
}
message ArraySet {
TimeTicket parent_created_at = 1;
Expand Down
10 changes: 10 additions & 0 deletions packages/sdk/src/api/yorkie/v1/resources_pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ export class ChangePack extends Message<ChangePack> {
changes: Change[] = [];

/**
* deprecated
*
* @generated from field: yorkie.v1.TimeTicket min_synced_ticket = 5;
*/
minSyncedTicket?: TimeTicket;
Expand Down Expand Up @@ -768,6 +770,8 @@ export class Operation_Edit extends Message<Operation_Edit> {
to?: TextNodePos;

/**
* deprecated
*
* @generated from field: map<string, yorkie.v1.TimeTicket> created_at_map_by_actor = 4;
*/
createdAtMapByActor: { [key: string]: TimeTicket } = {};
Expand Down Expand Up @@ -911,6 +915,8 @@ export class Operation_Style extends Message<Operation_Style> {
executedAt?: TimeTicket;

/**
* deprecated
*
* @generated from field: map<string, yorkie.v1.TimeTicket> created_at_map_by_actor = 6;
*/
createdAtMapByActor: { [key: string]: TimeTicket } = {};
Expand Down Expand Up @@ -1017,6 +1023,8 @@ export class Operation_TreeEdit extends Message<Operation_TreeEdit> {
to?: TreePos;

/**
* deprecated
*
* @generated from field: map<string, yorkie.v1.TimeTicket> created_at_map_by_actor = 4;
*/
createdAtMapByActor: { [key: string]: TimeTicket } = {};
Expand Down Expand Up @@ -1105,6 +1113,8 @@ export class Operation_TreeStyle extends Message<Operation_TreeStyle> {
attributesToRemove: string[] = [];

/**
* deprecated
*
* @generated from field: map<string, yorkie.v1.TimeTicket> created_at_map_by_actor = 7;
*/
createdAtMapByActor: { [key: string]: TimeTicket } = {};
Expand Down
11 changes: 1 addition & 10 deletions packages/sdk/src/document/change/change_id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,7 @@ export class ChangeID {
const lamport =
other.lamport > this.lamport ? other.lamport + 1n : this.lamport + 1n;

// NOTE(chacha912): For changes created by legacy SDK prior to v0.5.2 that lack version
// vectors, document's version vector was not being properly accumlated. To address this,
// we generate a version vector using the lamport timestamp when no version vector exists.
let otherVV = other.versionVector;
if (otherVV.size() === 0) {
otherVV = otherVV.deepcopy();
otherVV.set(other.actor, other.lamport);
}

const maxVersionVector = this.versionVector.max(otherVV);
const maxVersionVector = this.versionVector.max(other.versionVector);
const newID = new ChangeID(
this.clientSeq,
lamport,
Expand Down
19 changes: 0 additions & 19 deletions packages/sdk/src/document/change/change_pack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
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';

/**
Expand Down Expand Up @@ -46,13 +45,6 @@ export class ChangePack<P extends Indexable> {
*/
private snapshot?: Uint8Array;

/**
* `minSyncedTicket` is the minimum logical time taken by clients who attach
* to the document. It is used to collect garbage on the replica on the
* client.
*/
private minSyncedTicket?: TimeTicket;

/**
* `versionVector` is the version vector current document
*/
Expand All @@ -65,14 +57,12 @@ export class ChangePack<P extends Indexable> {
changes: Array<Change<P>>,
versionVector?: VersionVector,
snapshot?: Uint8Array,
minSyncedTicket?: TimeTicket,
) {
this.documentKey = key;
this.checkpoint = checkpoint;
this.isRemoved = isRemoved;
this.changes = changes;
this.snapshot = snapshot;
this.minSyncedTicket = minSyncedTicket;
this.versionVector = versionVector;
}
/**
Expand All @@ -85,7 +75,6 @@ export class ChangePack<P extends Indexable> {
changes: Array<Change<P>>,
versionVector?: VersionVector,
snapshot?: Uint8Array,
minSyncedTicket?: TimeTicket,
): ChangePack<P> {
return new ChangePack<P>(
key,
Expand All @@ -94,7 +83,6 @@ export class ChangePack<P extends Indexable> {
changes,
versionVector,
snapshot,
minSyncedTicket,
);
}

Expand Down Expand Up @@ -154,13 +142,6 @@ export class ChangePack<P extends Indexable> {
return this.snapshot;
}

/**
* `getMinSyncedTicket` returns the minimum synced ticket of this pack.
*/
public getMinSyncedTicket(): TimeTicket | undefined {
return this.minSyncedTicket;
}

/**
* `getVersionVector` returns the document's version vector of this pack
*/
Expand Down
Loading