diff --git a/.gitignore b/.gitignore index c91d94c..891461a 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,4 @@ vendor/ minio_data/* logs/logs*.json coverage.out* -./protobuf/gen/es/protobuf/node_modules +protobuf/gen/es/protobuf/node_modules diff --git a/cmd/server/server.go b/cmd/server/server.go index 55e829a..43af9a6 100644 --- a/cmd/server/server.go +++ b/cmd/server/server.go @@ -22,7 +22,8 @@ import ( "github.com/kavkaco/Kavka-Core/protobuf/gen/go/protobuf/auth/v1/authv1connect" "github.com/kavkaco/Kavka-Core/protobuf/gen/go/protobuf/chat/v1/chatv1connect" "github.com/kavkaco/Kavka-Core/protobuf/gen/go/protobuf/events/v1/eventsv1connect" - "github.com/kavkaco/Kavka-Core/protobuf/gen/go/protobuf/message/messagev1connect" + "github.com/kavkaco/Kavka-Core/protobuf/gen/go/protobuf/message/v1/messagev1connect" + "github.com/kavkaco/Kavka-Core/protobuf/gen/go/protobuf/search/v1/searchv1connect" "github.com/kavkaco/Kavka-Core/utils/hash" "github.com/rs/cors" diff --git a/config/config.go b/config/config.go index 1bbaaf2..0106303 100644 --- a/config/config.go +++ b/config/config.go @@ -21,13 +21,9 @@ type Env int const ( Development Env = iota Production - Test ) -var ( - CurrentEnv Env = Development - filename string -) +var CurrentEnv Env = Development type ( Config struct { @@ -108,25 +104,24 @@ func ConfigsDirPath() string { } func Read() *Config { + var fileName string + // Load KAVKA ENV env := strings.ToLower(os.Getenv("KAVKA_ENV")) if len(strings.TrimSpace(env)) == 0 || env == "development" { CurrentEnv = Development - filename = "config.development.yml" + fileName = "config.development.yml" } else if env == "production" { CurrentEnv = Production - filename = "config.production.yml" - } else if env == "test" { - CurrentEnv = Test - filename = "config.test.yml" + fileName = "config.production.yml" } else { - panic(errors.New("Invalid env value set for variable KAVKA_ENV: " + env)) + log.Fatalln(errors.New("Invalid env value set for variable KAVKA_ENV: " + env)) } // Load YAML configs k := koanf.New(ConfigsDirPath()) - if err := k.Load(file.Provider(fmt.Sprintf("%s/%s", ConfigsDirPath(), filename)), yaml.Parser()); err != nil { + if err := k.Load(file.Provider(fmt.Sprintf("%s/%s", ConfigsDirPath(), fileName)), yaml.Parser()); err != nil { log.Fatalf("error loading config: %v", err) } config := &Config{} diff --git a/config/config.test.yml b/config/config.test.yml deleted file mode 100644 index 73c3b3f..0000000 --- a/config/config.test.yml +++ /dev/null @@ -1,39 +0,0 @@ -app_name: "kavka" - -http: - host: "0.0.0.0" - port: 3000 - cors: - allow_origins: "*" - -mongo: - host: "127.0.0.1" - username: "test" - password: "test" - port: 27017 - db_name: "kavka" - -redis: - host: "127.0.0.1" - username: "redis" - password: - port: 6379 - db: 0 - -minio: - endpoint: 127.0.0.1:9000 - access_key: uD3h2W3CONpYe8Tb4nbp - secret_key: fKF98iAk1eDSpdtdJWcJHgivjpF4Su4HCdgkpYvQ - -sms: - -logger: - file_name: kavka.logs - level: debug - targets: [console, file] - max_size: 10 - max_backups: 1 - compress: false - -nats: - url: 127.0.0.1:4222 diff --git a/config/config_test.go b/config/config_test.go index c7887c1..adee4ba 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -1,7 +1,6 @@ package config import ( - "errors" "os" "testing" @@ -20,22 +19,3 @@ func TestDevelopmentConfig(t *testing.T) { require.NotEmpty(t, configs) require.Equal(t, CurrentEnv, Development) } - -func TestTestConfig(t *testing.T) { - os.Setenv("KAVKA_ENV", "test") - - Read() - require.Equal(t, CurrentEnv, Test) -} - -func TestFunctionPanics(t *testing.T) { - os.Setenv("KAVKA_ENV", "panic") - - defer func() { - if r := recover(); r == nil { - require.Error(t, errors.New("Expected panic but did not panic")) - } - }() - - Read() -} diff --git a/delivery/grpc/handlers/auth_handler.go b/delivery/grpc/handlers/auth_handler.go index 7442013..bf255c9 100644 --- a/delivery/grpc/handlers/auth_handler.go +++ b/delivery/grpc/handlers/auth_handler.go @@ -9,7 +9,6 @@ import ( "github.com/kavkaco/Kavka-Core/internal/service/auth" authv1 "github.com/kavkaco/Kavka-Core/protobuf/gen/go/protobuf/auth/v1" "github.com/kavkaco/Kavka-Core/protobuf/proto_model_transformer" - "google.golang.org/genproto/googleapis/rpc/code" "google.golang.org/protobuf/types/known/durationpb" ) @@ -24,7 +23,7 @@ func NewAuthGrpcHandler(authService auth.AuthService) AuthGrpcServer { func (a AuthGrpcServer) Login(ctx context.Context, req *connect.Request[authv1.LoginRequest]) (*connect.Response[authv1.LoginResponse], error) { user, accessToken, refreshToken, varror := a.authService.Login(ctx, req.Msg.Email, req.Msg.Password) if varror != nil { - return nil, grpc_helpers.GrpcVarror(varror, connect.Code(code.Code_INTERNAL)) + return nil, grpc_helpers.GrpcVarror(varror, connect.CodePermissionDenied) } res := connect.NewResponse(&authv1.LoginResponse{ @@ -39,7 +38,7 @@ func (a AuthGrpcServer) Login(ctx context.Context, req *connect.Request[authv1.L func (a AuthGrpcServer) Register(ctx context.Context, req *connect.Request[authv1.RegisterRequest]) (*connect.Response[authv1.RegisterResponse], error) { _, varror := a.authService.Register(ctx, req.Msg.Name, req.Msg.LastName, req.Msg.Username, req.Msg.Email, req.Msg.Password, req.Msg.VerifyEmailRedirectUrl) if varror != nil { - return nil, grpc_helpers.GrpcVarror(varror, connect.Code(code.Code_INVALID_ARGUMENT)) + return nil, grpc_helpers.GrpcVarror(varror, connect.CodeInvalidArgument) } res := connect.NewResponse(&authv1.RegisterResponse{}) @@ -50,7 +49,7 @@ func (a AuthGrpcServer) Register(ctx context.Context, req *connect.Request[authv func (a AuthGrpcServer) Authenticate(ctx context.Context, req *connect.Request[authv1.AuthenticateRequest]) (*connect.Response[authv1.AuthenticateResponse], error) { user, varror := a.authService.Authenticate(ctx, req.Msg.AccessToken) if varror != nil { - return nil, grpc_helpers.GrpcVarror(varror, connect.Code(code.Code_PERMISSION_DENIED)) + return nil, grpc_helpers.GrpcVarror(varror, connect.CodePermissionDenied) } res := connect.NewResponse(&authv1.AuthenticateResponse{ @@ -63,7 +62,7 @@ func (a AuthGrpcServer) Authenticate(ctx context.Context, req *connect.Request[a func (a AuthGrpcServer) ChangePassword(ctx context.Context, req *connect.Request[authv1.ChangePasswordRequest]) (*connect.Response[authv1.ChangePasswordResponse], error) { varror := a.authService.ChangePassword(ctx, req.Msg.AccessToken, req.Msg.OldPassword, req.Msg.NewPassword) if varror != nil { - return nil, grpc_helpers.GrpcVarror(varror, connect.CodeUnavailable) + return nil, grpc_helpers.GrpcVarror(varror, connect.CodePermissionDenied) } res := connect.NewResponse(&authv1.ChangePasswordResponse{}) @@ -73,7 +72,7 @@ func (a AuthGrpcServer) ChangePassword(ctx context.Context, req *connect.Request func (a AuthGrpcServer) RefreshToken(ctx context.Context, req *connect.Request[authv1.RefreshTokenRequest]) (*connect.Response[authv1.RefreshTokenResponse], error) { newAccessToken, varror := a.authService.RefreshToken(ctx, req.Msg.UserId, req.Msg.RefreshToken) if varror != nil { - return nil, grpc_helpers.GrpcVarror(varror, connect.Code(code.Code_UNAVAILABLE)) + return nil, grpc_helpers.GrpcVarror(varror, connect.CodePermissionDenied) } res := connect.NewResponse(&authv1.RefreshTokenResponse{ @@ -86,7 +85,7 @@ func (a AuthGrpcServer) RefreshToken(ctx context.Context, req *connect.Request[a func (a AuthGrpcServer) SendResetPassword(ctx context.Context, req *connect.Request[authv1.SendResetPasswordRequest]) (*connect.Response[authv1.SendResetPasswordResponse], error) { resetPasswordToken, timeout, varror := a.authService.SendResetPassword(ctx, req.Msg.Email, req.Msg.ResetPasswordRedirectUrl) if varror != nil { - return nil, grpc_helpers.GrpcVarror(varror, connect.Code(code.Code_UNAVAILABLE)) + return nil, grpc_helpers.GrpcVarror(varror, connect.CodePermissionDenied) } timeoutProto := durationpb.New(timeout) @@ -101,7 +100,7 @@ func (a AuthGrpcServer) SendResetPassword(ctx context.Context, req *connect.Requ func (a AuthGrpcServer) SubmitResetPassword(ctx context.Context, req *connect.Request[authv1.SubmitResetPasswordRequest]) (*connect.Response[authv1.SubmitResetPasswordResponse], error) { varror := a.authService.SubmitResetPassword(ctx, req.Msg.ResetPasswordToken, req.Msg.NewPassword) if varror != nil { - return nil, grpc_helpers.GrpcVarror(varror, connect.Code(code.Code_UNAVAILABLE)) + return nil, grpc_helpers.GrpcVarror(varror, connect.CodePermissionDenied) } res := connect.NewResponse(&authv1.SubmitResetPasswordResponse{}) @@ -111,7 +110,7 @@ func (a AuthGrpcServer) SubmitResetPassword(ctx context.Context, req *connect.Re func (a AuthGrpcServer) VerifyEmail(ctx context.Context, req *connect.Request[authv1.VerifyEmailRequest]) (*connect.Response[authv1.VerifyEmailResponse], error) { varror := a.authService.VerifyEmail(ctx, req.Msg.VerifyEmailToken) if varror != nil { - return nil, grpc_helpers.GrpcVarror(varror, connect.Code(code.Code_UNAVAILABLE)) + return nil, grpc_helpers.GrpcVarror(varror, connect.CodePermissionDenied) } res := connect.NewResponse(&authv1.VerifyEmailResponse{}) diff --git a/delivery/grpc/handlers/chat_handler.go b/delivery/grpc/handlers/chat_handler.go index 9533dae..f01c225 100644 --- a/delivery/grpc/handlers/chat_handler.go +++ b/delivery/grpc/handlers/chat_handler.go @@ -14,7 +14,6 @@ import ( chatv1 "github.com/kavkaco/Kavka-Core/protobuf/gen/go/protobuf/chat/v1" "github.com/kavkaco/Kavka-Core/protobuf/gen/go/protobuf/chat/v1/chatv1connect" "github.com/kavkaco/Kavka-Core/protobuf/proto_model_transformer" - "google.golang.org/genproto/googleapis/rpc/code" ) type chatHandler struct { @@ -34,7 +33,7 @@ func (h chatHandler) CreateChannel(ctx context.Context, req *connect.Request[cha chat, varror := h.chatService.CreateChannel(ctx, userID, req.Msg.Title, req.Msg.Username, req.Msg.Description) if varror != nil { - return nil, grpc_helpers.GrpcVarror(varror, connect.Code(code.Code_UNAVAILABLE)) + return nil, grpc_helpers.GrpcVarror(varror, connect.CodeUnavailable) } chatProto, err := proto_model_transformer.ChatToProto(*chat) @@ -69,7 +68,7 @@ func (h chatHandler) CreateGroup(ctx context.Context, req *connect.Request[chatv chat, varror := h.chatService.CreateGroup(ctx, userID, req.Msg.Title, req.Msg.Username, req.Msg.Description) if varror != nil { - return nil, grpc_helpers.GrpcVarror(varror, connect.Code(code.Code_INTERNAL)) + return nil, grpc_helpers.GrpcVarror(varror, connect.CodeUnavailable) } chatProto, err := proto_model_transformer.ChatToProto(*chat) @@ -148,7 +147,7 @@ func (h chatHandler) JoinChat(ctx context.Context, req *connect.Request[chatv1.J joinResult, varror := h.chatService.JoinChat(ctx, chatID, userID) if varror != nil { - return nil, grpc_helpers.GrpcVarror(varror, connect.Code(code.Code_INTERNAL)) + return nil, grpc_helpers.GrpcVarror(varror, connect.CodeInternal) } if !joinResult.Joined { @@ -157,7 +156,7 @@ func (h chatHandler) JoinChat(ctx context.Context, req *connect.Request[chatv1.J protoChat, err := proto_model_transformer.ChatToProto(*joinResult.UpdatedChat) if err != nil { - return nil, grpc_helpers.GrpcVarror(varror, connect.Code(code.Code_INTERNAL)) + return nil, grpc_helpers.GrpcVarror(varror, connect.CodeInternal) } res := &connect.Response[chatv1.JoinChatResponse]{Msg: &chatv1.JoinChatResponse{ diff --git a/delivery/grpc/handlers/events_handler.go b/delivery/grpc/handlers/events_handler.go index ac2892a..0f2d242 100644 --- a/delivery/grpc/handlers/events_handler.go +++ b/delivery/grpc/handlers/events_handler.go @@ -2,8 +2,10 @@ package grpc_handlers import ( "context" + "time" "connectrpc.com/connect" + "github.com/kavkaco/Kavka-Core/config" "github.com/kavkaco/Kavka-Core/delivery/grpc/interceptor" "github.com/kavkaco/Kavka-Core/infra/stream" "github.com/kavkaco/Kavka-Core/internal/model" @@ -21,24 +23,24 @@ func NewEventsGrpcHandler(logger *log.SubLogger, streamer stream.StreamSubscribe return &eventsHandler{logger, streamer} } -func (e *eventsHandler) SubscribeEventsStream(ctx context.Context, req *connect.Request[eventsv1.SubscribeEventsStreamRequest], str *connect.ServerStream[eventsv1.SubscribeEventsStreamResponse]) error { +func (e *eventsHandler) SubscribeEventsStream(ctx context.Context, req *connect.Request[eventsv1.SubscribeEventsStreamRequest], stream *connect.ServerStream[eventsv1.SubscribeEventsStreamResponse]) error { userID := ctx.Value(interceptor.UserID{}).(model.UserID) done := ctx.Done() userCh := make(chan *eventsv1.SubscribeEventsStreamResponse) e.streamer.UserSubscribe(userID, userCh) - e.logger.Debug("user stream established") + e.logger.Trace("user stream established") for { - if str == nil { + if stream == nil { e.logger.Error("user stream is closed") return nil } select { case <-done: - e.logger.Debug("user disconnected!") + e.logger.Trace("user disconnected!") e.streamer.UserUnsubscribe(userID) return nil case event, ok := <-userCh: @@ -47,9 +49,11 @@ func (e *eventsHandler) SubscribeEventsStream(ctx context.Context, req *connect. continue } - e.logger.Debug("events-handler", "event-name", event.Name) + if config.CurrentEnv == config.Development { + time.Sleep(500 * time.Millisecond) + } - err := str.Send(event) + err := stream.Send(event) if err != nil { log.Error("unable to send message with grpc: " + err.Error()) continue diff --git a/delivery/grpc/handlers/message_handler.go b/delivery/grpc/handlers/message_handler.go index 5c1e10d..787715b 100644 --- a/delivery/grpc/handlers/message_handler.go +++ b/delivery/grpc/handlers/message_handler.go @@ -9,8 +9,9 @@ import ( "github.com/kavkaco/Kavka-Core/internal/model" "github.com/kavkaco/Kavka-Core/internal/service/message" "github.com/kavkaco/Kavka-Core/log" - messagev1 "github.com/kavkaco/Kavka-Core/protobuf/gen/go/protobuf/message" - "github.com/kavkaco/Kavka-Core/protobuf/gen/go/protobuf/message/messagev1connect" + + messagev1 "github.com/kavkaco/Kavka-Core/protobuf/gen/go/protobuf/message/v1" + "github.com/kavkaco/Kavka-Core/protobuf/gen/go/protobuf/message/v1/messagev1connect" "github.com/kavkaco/Kavka-Core/protobuf/proto_model_transformer" "github.com/kavkaco/Kavka-Core/utils/vali" "google.golang.org/genproto/googleapis/rpc/code" @@ -18,10 +19,10 @@ import ( type MessageGrpcServer struct { logger *log.SubLogger - messageService message.MessageService + messageService *message.MessageService } -func NewMessageGrpcHandler(logger *log.SubLogger, messageService message.MessageService) messagev1connect.MessageServiceHandler { +func NewMessageGrpcHandler(logger *log.SubLogger, messageService *message.MessageService) messagev1connect.MessageServiceHandler { return MessageGrpcServer{logger, messageService} } diff --git a/delivery/grpc/handlers/search_handler.go b/delivery/grpc/handlers/search_handler.go index b6c9b39..30216fb 100644 --- a/delivery/grpc/handlers/search_handler.go +++ b/delivery/grpc/handlers/search_handler.go @@ -10,7 +10,6 @@ import ( searchv1 "github.com/kavkaco/Kavka-Core/protobuf/gen/go/protobuf/search/v1" "github.com/kavkaco/Kavka-Core/protobuf/gen/go/protobuf/search/v1/searchv1connect" "github.com/kavkaco/Kavka-Core/protobuf/proto_model_transformer" - "google.golang.org/genproto/googleapis/rpc/code" ) type searchHandler struct { @@ -25,7 +24,7 @@ func NewSearchGrpcHandler(logger *log.SubLogger, searchService search.SearchServ func (s *searchHandler) Search(ctx context.Context, req *connect.Request[searchv1.SearchRequest]) (*connect.Response[searchv1.SearchResponse], error) { result, varror := s.searchService.Search(ctx, req.Msg.Input) if varror != nil { - return nil, grpc_helpers.GrpcVarror(varror, connect.Code(code.Code_INTERNAL)) + return nil, grpc_helpers.GrpcVarror(varror, connect.CodeUnavailable) } chats, err := proto_model_transformer.ChatsToProto(result.Chats) diff --git a/delivery/grpc/helpers/errdetail.go b/delivery/grpc/helpers/error_detail.go similarity index 90% rename from delivery/grpc/helpers/errdetail.go rename to delivery/grpc/helpers/error_detail.go index dbbbbd6..e8de9d5 100644 --- a/delivery/grpc/helpers/errdetail.go +++ b/delivery/grpc/helpers/error_detail.go @@ -23,7 +23,10 @@ func VarrorAsGrpcErrDetails(varror *vali.Varror) (*connect.ErrorDetail, error) { func GrpcVarror(varror *vali.Varror, code connect.Code) error { connectErr := connect.NewError(code, varror.Error) - varrorDetail, _ := VarrorAsGrpcErrDetails(varror) + varrorDetail, err := VarrorAsGrpcErrDetails(varror) + if err != nil { + return err + } if len(varror.ValidationErrors) > 0 { connectErr.AddDetail(varrorDetail) diff --git a/docker-compose.yml b/docker-compose.yml index 0414955..9a1467e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -51,6 +51,7 @@ services: image: nats ports: - "4222:4222" + restart: always networks: default_network: diff --git a/internal/service/message/message_service.go b/internal/service/message/message_service.go index 0e08b51..11849fc 100644 --- a/internal/service/message/message_service.go +++ b/internal/service/message/message_service.go @@ -14,14 +14,7 @@ import ( "google.golang.org/protobuf/proto" ) -type MessageService interface { - FetchMessages(ctx context.Context, chatID model.ChatID) ([]*model.MessageGetter, *vali.Varror) - UpdateTextMessage(ctx context.Context, chatID model.ChatID, newMessageContent string) *vali.Varror - SendTextMessage(ctx context.Context, chatID model.ChatID, userID model.UserID, messageContent string) (*model.MessageGetter, *vali.Varror) - DeleteMessage(ctx context.Context, chatID model.ChatID, userID model.UserID, messageID model.MessageID) *vali.Varror -} - -type service struct { +type MessageService struct { logger *log.SubLogger messageRepo repository.MessageRepository chatRepo repository.ChatRepository @@ -30,11 +23,11 @@ type service struct { eventPublisher stream.StreamPublisher } -func NewMessageService(logger *log.SubLogger, messageRepo repository.MessageRepository, chatRepo repository.ChatRepository, userRepo repository.UserRepository, eventPublisher stream.StreamPublisher) MessageService { - return &service{logger, messageRepo, chatRepo, userRepo, vali.Validator(), eventPublisher} +func NewMessageService(logger *log.SubLogger, messageRepo repository.MessageRepository, chatRepo repository.ChatRepository, userRepo repository.UserRepository, eventPublisher stream.StreamPublisher) *MessageService { + return &MessageService{logger, messageRepo, chatRepo, userRepo, vali.Validator(), eventPublisher} } -func (s *service) FetchMessages(ctx context.Context, chatID model.ChatID) ([]*model.MessageGetter, *vali.Varror) { +func (s *MessageService) FetchMessages(ctx context.Context, chatID model.ChatID) ([]*model.MessageGetter, *vali.Varror) { messages, err := s.messageRepo.FetchMessages(ctx, chatID) if err != nil { return nil, &vali.Varror{Error: err} @@ -43,7 +36,7 @@ func (s *service) FetchMessages(ctx context.Context, chatID model.ChatID) ([]*mo return messages, nil } -func (s *service) SendTextMessage(ctx context.Context, chatID model.ChatID, userID model.UserID, messageContent string) (*model.MessageGetter, *vali.Varror) { +func (s *MessageService) SendTextMessage(ctx context.Context, chatID model.ChatID, userID model.UserID, messageContent string) (*model.MessageGetter, *vali.Varror) { varrors := s.validator.Validate(InsertTextMessageValidation{chatID, userID, messageContent}) if len(varrors) > 0 { return nil, &vali.Varror{ValidationErrors: varrors} @@ -116,7 +109,7 @@ func (s *service) SendTextMessage(ctx context.Context, chatID model.ChatID, user return messageGetter, nil } -func (s *service) DeleteMessage(ctx context.Context, chatID model.ChatID, userID model.UserID, messageID model.MessageID) *vali.Varror { +func (s *MessageService) DeleteMessage(ctx context.Context, chatID model.ChatID, userID model.UserID, messageID model.MessageID) *vali.Varror { varrors := s.validator.Validate(DeleteMessageValidation{chatID, userID, messageID}) if len(varrors) > 0 { return &vali.Varror{ValidationErrors: varrors} @@ -145,6 +138,6 @@ func (s *service) DeleteMessage(ctx context.Context, chatID model.ChatID, userID } // TODO - Implement UpdateTextMessage Method For MessageService -func (s *service) UpdateTextMessage(ctx context.Context, chatID primitive.ObjectID, newMessageContent string) *vali.Varror { +func (s *MessageService) UpdateTextMessage(ctx context.Context, chatID primitive.ObjectID, newMessageContent string) *vali.Varror { panic("unimplemented") } diff --git a/protobuf/gen/es/protobuf/message/message_connect.ts b/protobuf/gen/es/protobuf/message/message_connect.ts deleted file mode 100644 index 2388dc9..0000000 --- a/protobuf/gen/es/protobuf/message/message_connect.ts +++ /dev/null @@ -1,35 +0,0 @@ -// @generated by protoc-gen-connect-es v1.4.0 with parameter "target=ts,import_extension=.ts" -// @generated from file protobuf/message/message.proto (package protobuf.message.v1, syntax proto3) -/* eslint-disable */ -// @ts-nocheck - -import { FetchMessagesRequest, FetchMessagesResponse, SendTextMessageRequest, SendTextMessageResponse } from "./message_pb.ts"; -import { MethodKind } from "@bufbuild/protobuf"; - -/** - * @generated from service protobuf.message.v1.MessageService - */ -export const MessageService = { - typeName: "protobuf.message.v1.MessageService", - methods: { - /** - * @generated from rpc protobuf.message.v1.MessageService.FetchMessages - */ - fetchMessages: { - name: "FetchMessages", - I: FetchMessagesRequest, - O: FetchMessagesResponse, - kind: MethodKind.Unary, - }, - /** - * @generated from rpc protobuf.message.v1.MessageService.SendTextMessage - */ - sendTextMessage: { - name: "SendTextMessage", - I: SendTextMessageRequest, - O: SendTextMessageResponse, - kind: MethodKind.Unary, - }, - } -} as const; - diff --git a/protobuf/gen/es/protobuf/message/message_pb.ts b/protobuf/gen/es/protobuf/message/message_pb.ts deleted file mode 100644 index 9538de7..0000000 --- a/protobuf/gen/es/protobuf/message/message_pb.ts +++ /dev/null @@ -1,163 +0,0 @@ -// @generated by protoc-gen-es v1.10.0 with parameter "target=ts,import_extension=.ts" -// @generated from file protobuf/message/message.proto (package protobuf.message.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 { Message as Message$1 } from "../model/message/v1/message_pb.ts"; - -/** - * @generated from message protobuf.message.v1.FetchMessagesRequest - */ -export class FetchMessagesRequest extends Message { - /** - * @generated from field: string chat_id = 1; - */ - chatId = ""; - - constructor(data?: PartialMessage) { - super(); - proto3.util.initPartial(data, this); - } - - static readonly runtime: typeof proto3 = proto3; - static readonly typeName = "protobuf.message.v1.FetchMessagesRequest"; - static readonly fields: FieldList = proto3.util.newFieldList(() => [ - { no: 1, name: "chat_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - ]); - - static fromBinary(bytes: Uint8Array, options?: Partial): FetchMessagesRequest { - return new FetchMessagesRequest().fromBinary(bytes, options); - } - - static fromJson(jsonValue: JsonValue, options?: Partial): FetchMessagesRequest { - return new FetchMessagesRequest().fromJson(jsonValue, options); - } - - static fromJsonString(jsonString: string, options?: Partial): FetchMessagesRequest { - return new FetchMessagesRequest().fromJsonString(jsonString, options); - } - - static equals(a: FetchMessagesRequest | PlainMessage | undefined, b: FetchMessagesRequest | PlainMessage | undefined): boolean { - return proto3.util.equals(FetchMessagesRequest, a, b); - } -} - -/** - * @generated from message protobuf.message.v1.FetchMessagesResponse - */ -export class FetchMessagesResponse extends Message { - /** - * @generated from field: repeated protobuf.model.message.v1.Message messages = 1; - */ - messages: Message$1[] = []; - - constructor(data?: PartialMessage) { - super(); - proto3.util.initPartial(data, this); - } - - static readonly runtime: typeof proto3 = proto3; - static readonly typeName = "protobuf.message.v1.FetchMessagesResponse"; - static readonly fields: FieldList = proto3.util.newFieldList(() => [ - { no: 1, name: "messages", kind: "message", T: Message$1, repeated: true }, - ]); - - static fromBinary(bytes: Uint8Array, options?: Partial): FetchMessagesResponse { - return new FetchMessagesResponse().fromBinary(bytes, options); - } - - static fromJson(jsonValue: JsonValue, options?: Partial): FetchMessagesResponse { - return new FetchMessagesResponse().fromJson(jsonValue, options); - } - - static fromJsonString(jsonString: string, options?: Partial): FetchMessagesResponse { - return new FetchMessagesResponse().fromJsonString(jsonString, options); - } - - static equals(a: FetchMessagesResponse | PlainMessage | undefined, b: FetchMessagesResponse | PlainMessage | undefined): boolean { - return proto3.util.equals(FetchMessagesResponse, a, b); - } -} - -/** - * @generated from message protobuf.message.v1.SendTextMessageRequest - */ -export class SendTextMessageRequest extends Message { - /** - * @generated from field: string chat_id = 1; - */ - chatId = ""; - - /** - * @generated from field: string text = 2; - */ - text = ""; - - constructor(data?: PartialMessage) { - super(); - proto3.util.initPartial(data, this); - } - - static readonly runtime: typeof proto3 = proto3; - static readonly typeName = "protobuf.message.v1.SendTextMessageRequest"; - static readonly fields: FieldList = proto3.util.newFieldList(() => [ - { no: 1, name: "chat_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 2, name: "text", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - ]); - - static fromBinary(bytes: Uint8Array, options?: Partial): SendTextMessageRequest { - return new SendTextMessageRequest().fromBinary(bytes, options); - } - - static fromJson(jsonValue: JsonValue, options?: Partial): SendTextMessageRequest { - return new SendTextMessageRequest().fromJson(jsonValue, options); - } - - static fromJsonString(jsonString: string, options?: Partial): SendTextMessageRequest { - return new SendTextMessageRequest().fromJsonString(jsonString, options); - } - - static equals(a: SendTextMessageRequest | PlainMessage | undefined, b: SendTextMessageRequest | PlainMessage | undefined): boolean { - return proto3.util.equals(SendTextMessageRequest, a, b); - } -} - -/** - * @generated from message protobuf.message.v1.SendTextMessageResponse - */ -export class SendTextMessageResponse extends Message { - /** - * @generated from field: protobuf.model.message.v1.Message message = 1; - */ - message?: Message$1; - - constructor(data?: PartialMessage) { - super(); - proto3.util.initPartial(data, this); - } - - static readonly runtime: typeof proto3 = proto3; - static readonly typeName = "protobuf.message.v1.SendTextMessageResponse"; - static readonly fields: FieldList = proto3.util.newFieldList(() => [ - { no: 1, name: "message", kind: "message", T: Message$1 }, - ]); - - static fromBinary(bytes: Uint8Array, options?: Partial): SendTextMessageResponse { - return new SendTextMessageResponse().fromBinary(bytes, options); - } - - static fromJson(jsonValue: JsonValue, options?: Partial): SendTextMessageResponse { - return new SendTextMessageResponse().fromJson(jsonValue, options); - } - - static fromJsonString(jsonString: string, options?: Partial): SendTextMessageResponse { - return new SendTextMessageResponse().fromJsonString(jsonString, options); - } - - static equals(a: SendTextMessageResponse | PlainMessage | undefined, b: SendTextMessageResponse | PlainMessage | undefined): boolean { - return proto3.util.equals(SendTextMessageResponse, a, b); - } -} - diff --git a/protobuf/gen/es/protobuf/package.json b/protobuf/gen/es/protobuf/package.json index 78c1bc0..1dfd68e 100644 --- a/protobuf/gen/es/protobuf/package.json +++ b/protobuf/gen/es/protobuf/package.json @@ -1,6 +1,6 @@ { "name": "kavka-core", - "version": "1.1.83", + "version": "1.1.86", "main": "index.js", "keywords": [ "kavka", diff --git a/protobuf/gen/es/protobuf/pnpm-lock.yaml b/protobuf/gen/es/protobuf/pnpm-lock.yaml deleted file mode 100644 index 0759441..0000000 --- a/protobuf/gen/es/protobuf/pnpm-lock.yaml +++ /dev/null @@ -1,33 +0,0 @@ -lockfileVersion: '9.0' - -settings: - autoInstallPeers: true - excludeLinksFromLockfile: false - -importers: - - .: - dependencies: - '@bufbuild/protobuf': - specifier: ^1.10.0 - version: 1.10.0 - devDependencies: - typescript: - specifier: ~5.4.5 - version: 5.4.5 - -packages: - - '@bufbuild/protobuf@1.10.0': - resolution: {integrity: sha512-QDdVFLoN93Zjg36NoQPZfsVH9tZew7wKDKyV5qRdj8ntT4wQCOradQjRaTdwMhWUYsgKsvCINKKm87FdEk96Ag==} - - typescript@5.4.5: - resolution: {integrity: sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==} - engines: {node: '>=14.17'} - hasBin: true - -snapshots: - - '@bufbuild/protobuf@1.10.0': {} - - typescript@5.4.5: {} diff --git a/protobuf/gen/go/protobuf/message/message.pb.go b/protobuf/gen/go/protobuf/message/message.pb.go deleted file mode 100644 index 2fdbd74..0000000 --- a/protobuf/gen/go/protobuf/message/message.pb.go +++ /dev/null @@ -1,386 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.34.2 -// protoc (unknown) -// source: protobuf/message/message.proto - -package messagev1 - -import ( - v1 "github.com/kavkaco/Kavka-Core/protobuf/gen/go/protobuf/model/message/v1" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type FetchMessagesRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - ChatId string `protobuf:"bytes,1,opt,name=chat_id,json=chatId,proto3" json:"chat_id,omitempty"` -} - -func (x *FetchMessagesRequest) Reset() { - *x = FetchMessagesRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_protobuf_message_message_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *FetchMessagesRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*FetchMessagesRequest) ProtoMessage() {} - -func (x *FetchMessagesRequest) ProtoReflect() protoreflect.Message { - mi := &file_protobuf_message_message_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use FetchMessagesRequest.ProtoReflect.Descriptor instead. -func (*FetchMessagesRequest) Descriptor() ([]byte, []int) { - return file_protobuf_message_message_proto_rawDescGZIP(), []int{0} -} - -func (x *FetchMessagesRequest) GetChatId() string { - if x != nil { - return x.ChatId - } - return "" -} - -type FetchMessagesResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Messages []*v1.Message `protobuf:"bytes,1,rep,name=messages,proto3" json:"messages,omitempty"` -} - -func (x *FetchMessagesResponse) Reset() { - *x = FetchMessagesResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_protobuf_message_message_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *FetchMessagesResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*FetchMessagesResponse) ProtoMessage() {} - -func (x *FetchMessagesResponse) ProtoReflect() protoreflect.Message { - mi := &file_protobuf_message_message_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use FetchMessagesResponse.ProtoReflect.Descriptor instead. -func (*FetchMessagesResponse) Descriptor() ([]byte, []int) { - return file_protobuf_message_message_proto_rawDescGZIP(), []int{1} -} - -func (x *FetchMessagesResponse) GetMessages() []*v1.Message { - if x != nil { - return x.Messages - } - return nil -} - -type SendTextMessageRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - ChatId string `protobuf:"bytes,1,opt,name=chat_id,json=chatId,proto3" json:"chat_id,omitempty"` - Text string `protobuf:"bytes,2,opt,name=text,proto3" json:"text,omitempty"` -} - -func (x *SendTextMessageRequest) Reset() { - *x = SendTextMessageRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_protobuf_message_message_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SendTextMessageRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SendTextMessageRequest) ProtoMessage() {} - -func (x *SendTextMessageRequest) ProtoReflect() protoreflect.Message { - mi := &file_protobuf_message_message_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SendTextMessageRequest.ProtoReflect.Descriptor instead. -func (*SendTextMessageRequest) Descriptor() ([]byte, []int) { - return file_protobuf_message_message_proto_rawDescGZIP(), []int{2} -} - -func (x *SendTextMessageRequest) GetChatId() string { - if x != nil { - return x.ChatId - } - return "" -} - -func (x *SendTextMessageRequest) GetText() string { - if x != nil { - return x.Text - } - return "" -} - -type SendTextMessageResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Message *v1.Message `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` -} - -func (x *SendTextMessageResponse) Reset() { - *x = SendTextMessageResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_protobuf_message_message_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SendTextMessageResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SendTextMessageResponse) ProtoMessage() {} - -func (x *SendTextMessageResponse) ProtoReflect() protoreflect.Message { - mi := &file_protobuf_message_message_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SendTextMessageResponse.ProtoReflect.Descriptor instead. -func (*SendTextMessageResponse) Descriptor() ([]byte, []int) { - return file_protobuf_message_message_proto_rawDescGZIP(), []int{3} -} - -func (x *SendTextMessageResponse) GetMessage() *v1.Message { - if x != nil { - return x.Message - } - return nil -} - -var File_protobuf_message_message_proto protoreflect.FileDescriptor - -var file_protobuf_message_message_proto_rawDesc = []byte{ - 0x0a, 0x1e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, - 0x67, 0x65, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x12, 0x13, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, - 0x67, 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x27, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, - 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2f, 0x76, 0x31, - 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x2f, - 0x0a, 0x14, 0x46, 0x65, 0x74, 0x63, 0x68, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x63, 0x68, 0x61, 0x74, 0x5f, 0x69, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x68, 0x61, 0x74, 0x49, 0x64, 0x22, - 0x57, 0x0a, 0x15, 0x46, 0x65, 0x74, 0x63, 0x68, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3e, 0x0a, 0x08, 0x6d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x6d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x08, - 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x22, 0x45, 0x0a, 0x16, 0x53, 0x65, 0x6e, 0x64, - 0x54, 0x65, 0x78, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x63, 0x68, 0x61, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x68, 0x61, 0x74, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, - 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x22, - 0x57, 0x0a, 0x17, 0x53, 0x65, 0x6e, 0x64, 0x54, 0x65, 0x78, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, - 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3c, 0x0a, 0x07, 0x6d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x6d, 0x65, 0x73, - 0x73, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, - 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0xea, 0x01, 0x0a, 0x0e, 0x4d, 0x65, 0x73, - 0x73, 0x61, 0x67, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x68, 0x0a, 0x0d, 0x46, - 0x65, 0x74, 0x63, 0x68, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x12, 0x29, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, - 0x76, 0x31, 0x2e, 0x46, 0x65, 0x74, 0x63, 0x68, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x46, 0x65, - 0x74, 0x63, 0x68, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x6e, 0x0a, 0x0f, 0x53, 0x65, 0x6e, 0x64, 0x54, 0x65, 0x78, - 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x2b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, - 0x65, 0x6e, 0x64, 0x54, 0x65, 0x78, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x6e, 0x64, - 0x54, 0x65, 0x78, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0xdf, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x76, - 0x31, 0x42, 0x0c, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, - 0x01, 0x5a, 0x48, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x61, - 0x76, 0x6b, 0x61, 0x63, 0x6f, 0x2f, 0x4b, 0x61, 0x76, 0x6b, 0x61, 0x2d, 0x43, 0x6f, 0x72, 0x65, - 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x67, 0x6f, - 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x3b, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x50, 0x4d, - 0x58, 0xaa, 0x02, 0x13, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x73, - 0x73, 0x61, 0x67, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x13, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x5c, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1f, - 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x5c, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, - 0x02, 0x15, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x3a, 0x3a, 0x4d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_protobuf_message_message_proto_rawDescOnce sync.Once - file_protobuf_message_message_proto_rawDescData = file_protobuf_message_message_proto_rawDesc -) - -func file_protobuf_message_message_proto_rawDescGZIP() []byte { - file_protobuf_message_message_proto_rawDescOnce.Do(func() { - file_protobuf_message_message_proto_rawDescData = protoimpl.X.CompressGZIP(file_protobuf_message_message_proto_rawDescData) - }) - return file_protobuf_message_message_proto_rawDescData -} - -var file_protobuf_message_message_proto_msgTypes = make([]protoimpl.MessageInfo, 4) -var file_protobuf_message_message_proto_goTypes = []any{ - (*FetchMessagesRequest)(nil), // 0: protobuf.message.v1.FetchMessagesRequest - (*FetchMessagesResponse)(nil), // 1: protobuf.message.v1.FetchMessagesResponse - (*SendTextMessageRequest)(nil), // 2: protobuf.message.v1.SendTextMessageRequest - (*SendTextMessageResponse)(nil), // 3: protobuf.message.v1.SendTextMessageResponse - (*v1.Message)(nil), // 4: protobuf.model.message.v1.Message -} -var file_protobuf_message_message_proto_depIdxs = []int32{ - 4, // 0: protobuf.message.v1.FetchMessagesResponse.messages:type_name -> protobuf.model.message.v1.Message - 4, // 1: protobuf.message.v1.SendTextMessageResponse.message:type_name -> protobuf.model.message.v1.Message - 0, // 2: protobuf.message.v1.MessageService.FetchMessages:input_type -> protobuf.message.v1.FetchMessagesRequest - 2, // 3: protobuf.message.v1.MessageService.SendTextMessage:input_type -> protobuf.message.v1.SendTextMessageRequest - 1, // 4: protobuf.message.v1.MessageService.FetchMessages:output_type -> protobuf.message.v1.FetchMessagesResponse - 3, // 5: protobuf.message.v1.MessageService.SendTextMessage:output_type -> protobuf.message.v1.SendTextMessageResponse - 4, // [4:6] is the sub-list for method output_type - 2, // [2:4] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name -} - -func init() { file_protobuf_message_message_proto_init() } -func file_protobuf_message_message_proto_init() { - if File_protobuf_message_message_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_protobuf_message_message_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*FetchMessagesRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_protobuf_message_message_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*FetchMessagesResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_protobuf_message_message_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*SendTextMessageRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_protobuf_message_message_proto_msgTypes[3].Exporter = func(v any, i int) any { - switch v := v.(*SendTextMessageResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_protobuf_message_message_proto_rawDesc, - NumEnums: 0, - NumMessages: 4, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_protobuf_message_message_proto_goTypes, - DependencyIndexes: file_protobuf_message_message_proto_depIdxs, - MessageInfos: file_protobuf_message_message_proto_msgTypes, - }.Build() - File_protobuf_message_message_proto = out.File - file_protobuf_message_message_proto_rawDesc = nil - file_protobuf_message_message_proto_goTypes = nil - file_protobuf_message_message_proto_depIdxs = nil -} diff --git a/protobuf/gen/go/protobuf/message/messagev1connect/message.connect.go b/protobuf/gen/go/protobuf/message/messagev1connect/message.connect.go deleted file mode 100644 index b17e646..0000000 --- a/protobuf/gen/go/protobuf/message/messagev1connect/message.connect.go +++ /dev/null @@ -1,143 +0,0 @@ -// Code generated by protoc-gen-connect-go. DO NOT EDIT. -// -// Source: protobuf/message/message.proto - -package messagev1connect - -import ( - connect "connectrpc.com/connect" - context "context" - errors "errors" - message "github.com/kavkaco/Kavka-Core/protobuf/gen/go/protobuf/message" - http "net/http" - strings "strings" -) - -// This is a compile-time assertion to ensure that this generated file and the connect package are -// compatible. If you get a compiler error that this constant is not defined, this code was -// generated with a version of connect newer than the one compiled into your binary. You can fix the -// problem by either regenerating this code with an older version of connect or updating the connect -// version compiled into your binary. -const _ = connect.IsAtLeastVersion1_13_0 - -const ( - // MessageServiceName is the fully-qualified name of the MessageService service. - MessageServiceName = "protobuf.message.v1.MessageService" -) - -// These constants are the fully-qualified names of the RPCs defined in this package. They're -// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. -// -// Note that these are different from the fully-qualified method names used by -// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to -// reflection-formatted method names, remove the leading slash and convert the remaining slash to a -// period. -const ( - // MessageServiceFetchMessagesProcedure is the fully-qualified name of the MessageService's - // FetchMessages RPC. - MessageServiceFetchMessagesProcedure = "/protobuf.message.v1.MessageService/FetchMessages" - // MessageServiceSendTextMessageProcedure is the fully-qualified name of the MessageService's - // SendTextMessage RPC. - MessageServiceSendTextMessageProcedure = "/protobuf.message.v1.MessageService/SendTextMessage" -) - -// These variables are the protoreflect.Descriptor objects for the RPCs defined in this package. -var ( - messageServiceServiceDescriptor = message.File_protobuf_message_message_proto.Services().ByName("MessageService") - messageServiceFetchMessagesMethodDescriptor = messageServiceServiceDescriptor.Methods().ByName("FetchMessages") - messageServiceSendTextMessageMethodDescriptor = messageServiceServiceDescriptor.Methods().ByName("SendTextMessage") -) - -// MessageServiceClient is a client for the protobuf.message.v1.MessageService service. -type MessageServiceClient interface { - FetchMessages(context.Context, *connect.Request[message.FetchMessagesRequest]) (*connect.Response[message.FetchMessagesResponse], error) - SendTextMessage(context.Context, *connect.Request[message.SendTextMessageRequest]) (*connect.Response[message.SendTextMessageResponse], error) -} - -// NewMessageServiceClient constructs a client for the protobuf.message.v1.MessageService service. -// By default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped -// responses, and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the -// connect.WithGRPC() or connect.WithGRPCWeb() options. -// -// The URL supplied here should be the base URL for the Connect or gRPC server (for example, -// http://api.acme.com or https://acme.com/grpc). -func NewMessageServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) MessageServiceClient { - baseURL = strings.TrimRight(baseURL, "/") - return &messageServiceClient{ - fetchMessages: connect.NewClient[message.FetchMessagesRequest, message.FetchMessagesResponse]( - httpClient, - baseURL+MessageServiceFetchMessagesProcedure, - connect.WithSchema(messageServiceFetchMessagesMethodDescriptor), - connect.WithClientOptions(opts...), - ), - sendTextMessage: connect.NewClient[message.SendTextMessageRequest, message.SendTextMessageResponse]( - httpClient, - baseURL+MessageServiceSendTextMessageProcedure, - connect.WithSchema(messageServiceSendTextMessageMethodDescriptor), - connect.WithClientOptions(opts...), - ), - } -} - -// messageServiceClient implements MessageServiceClient. -type messageServiceClient struct { - fetchMessages *connect.Client[message.FetchMessagesRequest, message.FetchMessagesResponse] - sendTextMessage *connect.Client[message.SendTextMessageRequest, message.SendTextMessageResponse] -} - -// FetchMessages calls protobuf.message.v1.MessageService.FetchMessages. -func (c *messageServiceClient) FetchMessages(ctx context.Context, req *connect.Request[message.FetchMessagesRequest]) (*connect.Response[message.FetchMessagesResponse], error) { - return c.fetchMessages.CallUnary(ctx, req) -} - -// SendTextMessage calls protobuf.message.v1.MessageService.SendTextMessage. -func (c *messageServiceClient) SendTextMessage(ctx context.Context, req *connect.Request[message.SendTextMessageRequest]) (*connect.Response[message.SendTextMessageResponse], error) { - return c.sendTextMessage.CallUnary(ctx, req) -} - -// MessageServiceHandler is an implementation of the protobuf.message.v1.MessageService service. -type MessageServiceHandler interface { - FetchMessages(context.Context, *connect.Request[message.FetchMessagesRequest]) (*connect.Response[message.FetchMessagesResponse], error) - SendTextMessage(context.Context, *connect.Request[message.SendTextMessageRequest]) (*connect.Response[message.SendTextMessageResponse], error) -} - -// NewMessageServiceHandler builds an HTTP handler from the service implementation. It returns the -// path on which to mount the handler and the handler itself. -// -// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf -// and JSON codecs. They also support gzip compression. -func NewMessageServiceHandler(svc MessageServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { - messageServiceFetchMessagesHandler := connect.NewUnaryHandler( - MessageServiceFetchMessagesProcedure, - svc.FetchMessages, - connect.WithSchema(messageServiceFetchMessagesMethodDescriptor), - connect.WithHandlerOptions(opts...), - ) - messageServiceSendTextMessageHandler := connect.NewUnaryHandler( - MessageServiceSendTextMessageProcedure, - svc.SendTextMessage, - connect.WithSchema(messageServiceSendTextMessageMethodDescriptor), - connect.WithHandlerOptions(opts...), - ) - return "/protobuf.message.v1.MessageService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - switch r.URL.Path { - case MessageServiceFetchMessagesProcedure: - messageServiceFetchMessagesHandler.ServeHTTP(w, r) - case MessageServiceSendTextMessageProcedure: - messageServiceSendTextMessageHandler.ServeHTTP(w, r) - default: - http.NotFound(w, r) - } - }) -} - -// UnimplementedMessageServiceHandler returns CodeUnimplemented from all methods. -type UnimplementedMessageServiceHandler struct{} - -func (UnimplementedMessageServiceHandler) FetchMessages(context.Context, *connect.Request[message.FetchMessagesRequest]) (*connect.Response[message.FetchMessagesResponse], error) { - return nil, connect.NewError(connect.CodeUnimplemented, errors.New("protobuf.message.v1.MessageService.FetchMessages is not implemented")) -} - -func (UnimplementedMessageServiceHandler) SendTextMessage(context.Context, *connect.Request[message.SendTextMessageRequest]) (*connect.Response[message.SendTextMessageResponse], error) { - return nil, connect.NewError(connect.CodeUnimplemented, errors.New("protobuf.message.v1.MessageService.SendTextMessage is not implemented")) -} diff --git a/tests/integration/service/message_service_test.go b/tests/integration/service/message_service_test.go index b420cfc..d01d9b4 100644 --- a/tests/integration/service/message_service_test.go +++ b/tests/integration/service/message_service_test.go @@ -18,7 +18,7 @@ import ( type MessageTestSuite struct { suite.Suite - service service.MessageService + service *service.MessageService userID model.UserID chatID model.ChatID diff --git a/tests/integration/service/user_service_test.go b/tests/integration/service/user_service_test.go index c139130..cdedea1 100644 --- a/tests/integration/service/user_service_test.go +++ b/tests/integration/service/user_service_test.go @@ -102,25 +102,6 @@ func (s *UserTestSuite) TestA_UpdateProfile() { } } -// func (s *UserTestSuite) TestB_InvalidInputUpdateProfile() { -// ctx := context.TODO() - -// varror := s.service.UpdateProfile(ctx, s.userID, "", "", "", "") -// require.NotNil(s.T(), varror) -// } - -// func (s *UserTestSuite) TestC_InvalidUserIDUpdateProfile() { -// ctx := context.TODO() - -// name := "User5:NameChanged" -// lastName := "User5:LastNameChanged" -// username := "user5_changed" -// biography := "User5:Biography changed" - -// varror := s.service.UpdateProfile(ctx, "invalid", name, lastName, username, biography) -// require.Equal(s.T(), varror.Error, service.ErrNotFound) -// } - func TestUserSuite(t *testing.T) { t.Helper() suite.Run(t, new(UserTestSuite))