diff --git a/src/api/yorkie/v1/yorkie.proto b/src/api/yorkie/v1/yorkie.proto index 279f96f98..0d4736778 100644 --- a/src/api/yorkie/v1/yorkie.proto +++ b/src/api/yorkie/v1/yorkie.proto @@ -48,6 +48,7 @@ message ActivateClientResponse { } message DeactivateClientRequest { + string client_key = 2; string client_id = 1; } @@ -55,6 +56,7 @@ message DeactivateClientResponse { } message AttachDocumentRequest { + string client_key = 3; string client_id = 1; ChangePack change_pack = 2; } @@ -65,6 +67,7 @@ message AttachDocumentResponse { } message DetachDocumentRequest { + string client_key = 5; string client_id = 1; string document_id = 2; ChangePack change_pack = 3; @@ -76,7 +79,9 @@ message DetachDocumentResponse { } message WatchDocumentRequest { + string client_key = 4; string client_id = 1; + string document_key = 3; string document_id = 2; } @@ -92,6 +97,7 @@ message WatchDocumentResponse { } message RemoveDocumentRequest { + string client_key = 4; string client_id = 1; string document_id = 2; ChangePack change_pack = 3; @@ -102,6 +108,7 @@ message RemoveDocumentResponse { } message PushPullChangesRequest { + string client_key = 5; string client_id = 1; string document_id = 2; ChangePack change_pack = 3; @@ -113,7 +120,9 @@ message PushPullChangesResponse { } message BroadcastRequest { + string client_key = 6; string client_id = 1; + string document_key = 5; string document_id = 2; string topic = 3; bytes payload = 4; diff --git a/src/api/yorkie/v1/yorkie_pb.d.ts b/src/api/yorkie/v1/yorkie_pb.d.ts index 0c685f6ad..18552637f 100644 --- a/src/api/yorkie/v1/yorkie_pb.d.ts +++ b/src/api/yorkie/v1/yorkie_pb.d.ts @@ -74,6 +74,11 @@ export declare class ActivateClientResponse extends Message { + /** + * @generated from field: string client_key = 2; + */ + clientKey: string; + /** * @generated from field: string client_id = 1; */ @@ -117,6 +122,11 @@ export declare class DeactivateClientResponse extends Message { + /** + * @generated from field: string client_key = 3; + */ + clientKey: string; + /** * @generated from field: string client_id = 1; */ @@ -175,6 +185,11 @@ export declare class AttachDocumentResponse extends Message { + /** + * @generated from field: string client_key = 5; + */ + clientKey: string; + /** * @generated from field: string client_id = 1; */ @@ -238,11 +253,21 @@ export declare class DetachDocumentResponse extends Message { + /** + * @generated from field: string client_key = 4; + */ + clientKey: string; + /** * @generated from field: string client_id = 1; */ clientId: string; + /** + * @generated from field: string document_key = 3; + */ + documentKey: string; + /** * @generated from field: string document_id = 2; */ @@ -327,6 +352,11 @@ export declare class WatchDocumentResponse_Initialization extends Message { + /** + * @generated from field: string client_key = 4; + */ + clientKey: string; + /** * @generated from field: string client_id = 1; */ @@ -385,6 +415,11 @@ export declare class RemoveDocumentResponse extends Message { + /** + * @generated from field: string client_key = 5; + */ + clientKey: string; + /** * @generated from field: string client_id = 1; */ @@ -448,11 +483,21 @@ export declare class PushPullChangesResponse extends Message { + /** + * @generated from field: string client_key = 6; + */ + clientKey: string; + /** * @generated from field: string client_id = 1; */ clientId: string; + /** + * @generated from field: string document_key = 5; + */ + documentKey: string; + /** * @generated from field: string document_id = 2; */ diff --git a/src/api/yorkie/v1/yorkie_pb.js b/src/api/yorkie/v1/yorkie_pb.js index 97b8ad6e8..2e00b36b5 100644 --- a/src/api/yorkie/v1/yorkie_pb.js +++ b/src/api/yorkie/v1/yorkie_pb.js @@ -50,6 +50,7 @@ const ActivateClientResponse = proto3.makeMessageType( const DeactivateClientRequest = proto3.makeMessageType( "yorkie.v1.DeactivateClientRequest", () => [ + { no: 2, name: "client_key", kind: "scalar", T: 9 /* ScalarType.STRING */ }, { no: 1, name: "client_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, ], ); @@ -68,6 +69,7 @@ const DeactivateClientResponse = proto3.makeMessageType( const AttachDocumentRequest = proto3.makeMessageType( "yorkie.v1.AttachDocumentRequest", () => [ + { no: 3, name: "client_key", kind: "scalar", T: 9 /* ScalarType.STRING */ }, { no: 1, name: "client_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, { no: 2, name: "change_pack", kind: "message", T: ChangePack }, ], @@ -90,6 +92,7 @@ const AttachDocumentResponse = proto3.makeMessageType( const DetachDocumentRequest = proto3.makeMessageType( "yorkie.v1.DetachDocumentRequest", () => [ + { no: 5, name: "client_key", kind: "scalar", T: 9 /* ScalarType.STRING */ }, { 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 }, @@ -113,7 +116,9 @@ const DetachDocumentResponse = proto3.makeMessageType( const WatchDocumentRequest = proto3.makeMessageType( "yorkie.v1.WatchDocumentRequest", () => [ + { no: 4, name: "client_key", kind: "scalar", T: 9 /* ScalarType.STRING */ }, { no: 1, name: "client_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "document_key", kind: "scalar", T: 9 /* ScalarType.STRING */ }, { no: 2, name: "document_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, ], ); @@ -146,6 +151,7 @@ const WatchDocumentResponse_Initialization = proto3.makeMessageType( const RemoveDocumentRequest = proto3.makeMessageType( "yorkie.v1.RemoveDocumentRequest", () => [ + { no: 4, name: "client_key", kind: "scalar", T: 9 /* ScalarType.STRING */ }, { 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 }, @@ -168,6 +174,7 @@ const RemoveDocumentResponse = proto3.makeMessageType( const PushPullChangesRequest = proto3.makeMessageType( "yorkie.v1.PushPullChangesRequest", () => [ + { no: 5, name: "client_key", kind: "scalar", T: 9 /* ScalarType.STRING */ }, { 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 }, @@ -191,7 +198,9 @@ const PushPullChangesResponse = proto3.makeMessageType( const BroadcastRequest = proto3.makeMessageType( "yorkie.v1.BroadcastRequest", () => [ + { no: 6, name: "client_key", kind: "scalar", T: 9 /* ScalarType.STRING */ }, { no: 1, name: "client_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 5, name: "document_key", 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 */ }, diff --git a/src/client/client.ts b/src/client/client.ts index b29b64d20..3ad744e5c 100644 --- a/src/client/client.ts +++ b/src/client/client.ts @@ -388,6 +388,7 @@ export class Client implements Observable { return this.rpcClient .deactivateClient( { + clientKey: this.key!, clientId: this.id!, }, { headers: { 'x-shard-key': this.apiKey } }, @@ -435,6 +436,7 @@ export class Client implements Observable { return this.rpcClient .attachDocument( { + clientKey: this.key!, clientId: this.id!, changePack: converter.toChangePack(doc.createChangePack()), }, @@ -502,6 +504,7 @@ export class Client implements Observable { return this.rpcClient .detachDocument( { + clientKey: this.key!, clientId: this.id!, documentId: attachment.docID, changePack: converter.toChangePack(doc.createChangePack()), @@ -691,6 +694,7 @@ export class Client implements Observable { return this.rpcClient .removeDocument( { + clientKey: this.key!, clientId: this.id!, documentId: attachment.docID, changePack: pbChangePack, @@ -806,7 +810,9 @@ export class Client implements Observable { const ac = new AbortController(); const stream = this.rpcClient.watchDocument( { + clientKey: this.key!, clientId: this.id!, + documentKey: docKey, documentId: attachment.docID, }, { @@ -942,6 +948,7 @@ export class Client implements Observable { return this.rpcClient .pushPullChanges( { + clientKey: this.key!, clientId: this.id!, documentId: docID, changePack: converter.toChangePack(reqPack), diff --git a/test/integration/document_test.ts b/test/integration/document_test.ts index 7d7e4884b..ff106e1b4 100644 --- a/test/integration/document_test.ts +++ b/test/integration/document_test.ts @@ -629,19 +629,22 @@ describe('Document', function () { d1.update((root) => { root['k1'] = [1, 2]; }, 'set array'); - await c1.attach(d1); + await c1.attach(d1, { isRealtimeSync: false }); assert.equal(d1.toSortedJSON(), '{"k1":[1,2]}'); const c2 = new yorkie.Client(testRPCAddr); await c2.activate(); const d2 = new yorkie.Document(docKey); - await c2.attach(d2); + await c2.attach(d2, { isRealtimeSync: false }); assert.equal(d2.toSortedJSON(), '{"k1":[1,2]}'); // 02. c1 removes d1 and c2 detaches d2. await c1.remove(d1); await c2.detach(d2); + await c1.sync(); + await c2.sync(); + assert.equal(d1.getStatus(), DocumentStatus.Removed); assert.equal(d2.getStatus(), DocumentStatus.Removed); @@ -660,18 +663,22 @@ describe('Document', function () { d1.update((root) => { root['k1'] = [1, 2]; }, 'set array'); - await c1.attach(d1); + await c1.attach(d1, { isRealtimeSync: false }); assert.equal(d1.toSortedJSON(), '{"k1":[1,2]}'); const c2 = new yorkie.Client(testRPCAddr); await c2.activate(); const d2 = new yorkie.Document(docKey); - await c2.attach(d2); + await c2.attach(d2, { isRealtimeSync: false }); assert.equal(d2.toSortedJSON(), '{"k1":[1,2]}'); // 02. c1 removes d1 and c2 removes d2. await c1.remove(d1); await c2.remove(d2); + + await c1.sync(); + await c2.sync(); + assert.equal(d1.getStatus(), DocumentStatus.Removed); assert.equal(d2.getStatus(), DocumentStatus.Removed);