Skip to content

Commit

Permalink
fix: ts-proto snake_case to camelCase, Chat.gRPC.createRoom() empty i…
Browse files Browse the repository at this point in the history
…d res field (#770)
  • Loading branch information
kon14 authored Oct 26, 2023
1 parent 1f7d31f commit 510b2be
Show file tree
Hide file tree
Showing 17 changed files with 40 additions and 25 deletions.
1 change: 1 addition & 0 deletions libraries/grpc-sdk/build.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ protoc \
--ts_proto_opt=esModuleInterop=true \
--ts_proto_opt=outputServices=generic-definitions,exportCommonSymbols=false,useExactTypes=false \
--ts_proto_out=./ \
--ts_proto_opt=snakeToCamel=false \
./*.proto

# Initialize the content of the index.ts file
Expand Down
8 changes: 6 additions & 2 deletions libraries/grpc-sdk/src/modules/chat/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import { ConduitModule } from '../../classes/ConduitModule';
import { ChatDefinition, Room, SendMessageRequest } from '../../protoUtils/chat';

export class Chat extends ConduitModule<typeof ChatDefinition> {
constructor(private readonly moduleName: string, url: string, grpcToken?: string) {
constructor(
private readonly moduleName: string,
url: string,
grpcToken?: string,
) {
super(moduleName, 'chat', url, grpcToken);
this.initializeClient(ChatDefinition);
}
Expand All @@ -16,6 +20,6 @@ export class Chat extends ConduitModule<typeof ChatDefinition> {
}

deleteRoom(id: string): Promise<Room> {
return this.client!.deleteRoom({ id });
return this.client!.deleteRoom({ _id: id });
}
}
1 change: 1 addition & 0 deletions libraries/testing-tools/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ protoc \
--ts_proto_opt=esModuleInterop=true \
--ts_proto_opt=outputServices=generic-definitions,useExactTypes=false \
--ts_proto_out=./ \
--ts_proto_opt=snakeToCamel=false \
./*.proto

echo "Cleaning up protofiles"
Expand Down
3 changes: 2 additions & 1 deletion modules/authentication/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ protoc \
--plugin=../../node_modules/.bin/protoc-gen-ts_proto\
--ts_proto_opt=esModuleInterop=true \
--ts_proto_out=./ \
--ts_proto_opt=outputServices=generic-definitions,useExactTypes=false\
--ts_proto_opt=outputServices=generic-definitions,useExactTypes=false \
--ts_proto_opt=snakeToCamel=false \
./*.proto

echo "Cleaning up folders"
Expand Down
3 changes: 2 additions & 1 deletion modules/authorization/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ protoc \
--plugin=../../node_modules/.bin/protoc-gen-ts_proto\
--ts_proto_opt=esModuleInterop=true \
--ts_proto_out=./ \
--ts_proto_opt=outputServices=generic-definitions,useExactTypes=false\
--ts_proto_opt=outputServices=generic-definitions,useExactTypes=false \
--ts_proto_opt=snakeToCamel=false \
./*.proto

echo "Cleaning up folders"
Expand Down
8 changes: 4 additions & 4 deletions modules/authorization/src/authorization.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ package authorization;

message Resource {
string name = 1;
repeated _Relation relations = 2;
repeated _Permission permissions = 3;
message _Relation {
repeated Relation relations = 2;
repeated Permission permissions = 3;
message Relation {
string name = 1;
repeated string resourceType = 2;
}
message _Permission {
message Permission {
string name = 1;
repeated string roles = 2;
}
Expand Down
3 changes: 2 additions & 1 deletion modules/chat/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ protoc \
--plugin=../../node_modules/.bin/protoc-gen-ts_proto\
--ts_proto_opt=esModuleInterop=true \
--ts_proto_out=./ \
--ts_proto_opt=outputServices=generic-definitions,useExactTypes=false\
--ts_proto_opt=outputServices=generic-definitions,useExactTypes=false \
--ts_proto_opt=snakeToCamel=false \
./*.proto

echo "Cleaning up folders"
Expand Down
12 changes: 5 additions & 7 deletions modules/chat/src/Chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export default class Chat extends ManagedModule<Config> {
}),
);
callback(null, {
Id: room._id,
_id: room._id,
name: room.name,
participants: room.participants as string[],
});
Expand Down Expand Up @@ -203,13 +203,11 @@ export default class Chat extends ManagedModule<Config> {
}

async deleteRoom(call: GrpcRequest<DeleteRoomRequest>, callback: GrpcCallback<Room>) {
const { id } = call.request;
const { _id } = call.request;

let errorMessage: string | null = null;
const room: models.ChatRoom = await models.ChatRoom.getInstance()
.deleteOne({
_id: id,
})
.deleteOne({ _id })
.catch((e: Error) => {
errorMessage = e.message;
});
Expand All @@ -219,7 +217,7 @@ export default class Chat extends ManagedModule<Config> {

models.ChatMessage.getInstance()
.deleteMany({
room: id,
room: _id,
})
.catch((e: Error) => {
errorMessage = e.message;
Expand All @@ -237,7 +235,7 @@ export default class Chat extends ManagedModule<Config> {
}),
);
callback(null, {
Id: room._id,
_id: room._id,
name: room.name,
participants: room.participants as string[],
});
Expand Down
2 changes: 1 addition & 1 deletion modules/chat/src/chat.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ message SendMessageRequest {
}

message DeleteRoomRequest {
string id = 1;
string _id = 1;
}

message Room {
Expand Down
3 changes: 2 additions & 1 deletion modules/database/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ protoc \
--plugin=../../node_modules/.bin/protoc-gen-ts_proto\
--ts_proto_opt=esModuleInterop=true \
--ts_proto_out=./ \
--ts_proto_opt=outputServices=generic-definitions,useExactTypes=false\
--ts_proto_opt=outputServices=generic-definitions,useExactTypes=false \
--ts_proto_opt=snakeToCamel=false \
./*.proto

echo "Cleaning up folders"
Expand Down
3 changes: 2 additions & 1 deletion modules/email/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ protoc \
--plugin=../../node_modules/.bin/protoc-gen-ts_proto\
--ts_proto_opt=esModuleInterop=true \
--ts_proto_out=./ \
--ts_proto_opt=outputServices=generic-definitions,useExactTypes=false\
--ts_proto_opt=outputServices=generic-definitions,useExactTypes=false \
--ts_proto_opt=snakeToCamel=false \
./*.proto

echo "Cleaning up folders"
Expand Down
3 changes: 2 additions & 1 deletion modules/functions/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ protoc \
--plugin=../../node_modules/.bin/protoc-gen-ts_proto\
--ts_proto_opt=esModuleInterop=true \
--ts_proto_out=./ \
--ts_proto_opt=outputServices=generic-definitions,useExactTypes=false\
--ts_proto_opt=outputServices=generic-definitions,useExactTypes=false \
--ts_proto_opt=snakeToCamel=false \
./*.proto

echo "Cleaning up folders"
Expand Down
3 changes: 2 additions & 1 deletion modules/push-notifications/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ protoc \
--plugin=../../node_modules/.bin/protoc-gen-ts_proto\
--ts_proto_opt=esModuleInterop=true \
--ts_proto_out=./ \
--ts_proto_opt=outputServices=generic-definitions,useExactTypes=false\
--ts_proto_opt=outputServices=generic-definitions,useExactTypes=false \
--ts_proto_opt=snakeToCamel=false \
./*.proto

echo "Cleaning up folders"
Expand Down
3 changes: 2 additions & 1 deletion modules/router/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ protoc \
--plugin=../../node_modules/.bin/protoc-gen-ts_proto\
--ts_proto_opt=esModuleInterop=true \
--ts_proto_out=./ \
--ts_proto_opt=outputServices=generic-definitions,useExactTypes=false\
--ts_proto_opt=outputServices=generic-definitions,useExactTypes=false \
--ts_proto_opt=snakeToCamel=false \
./*.proto

echo "Cleaning up folders"
Expand Down
3 changes: 2 additions & 1 deletion modules/sms/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ protoc \
--plugin=../../node_modules/.bin/protoc-gen-ts_proto\
--ts_proto_opt=esModuleInterop=true \
--ts_proto_out=./ \
--ts_proto_opt=outputServices=generic-definitions,useExactTypes=false\
--ts_proto_opt=outputServices=generic-definitions,useExactTypes=false \
--ts_proto_opt=snakeToCamel=false \
./*.proto

echo "Cleaning up folders"
Expand Down
3 changes: 2 additions & 1 deletion modules/storage/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ protoc \
--plugin=../../node_modules/.bin/protoc-gen-ts_proto\
--ts_proto_opt=esModuleInterop=true \
--ts_proto_out=./ \
--ts_proto_opt=outputServices=generic-definitions,useExactTypes=false\
--ts_proto_opt=outputServices=generic-definitions,useExactTypes=false \
--ts_proto_opt=snakeToCamel=false \
./*.proto

echo "Cleaning up folders"
Expand Down
3 changes: 2 additions & 1 deletion packages/commons/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ protoc \
--plugin=../../node_modules/.bin/protoc-gen-ts_proto\
--ts_proto_opt=esModuleInterop=true \
--ts_proto_out=./ \
--ts_proto_opt=outputServices=generic-definitions,useExactTypes=false\
--ts_proto_opt=outputServices=generic-definitions,useExactTypes=false \
--ts_proto_opt=snakeToCamel=false \
./*.proto

echo "Cleaning up folders"
Expand Down

0 comments on commit 510b2be

Please sign in to comment.