Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tahadostifam committed Sep 20, 2024
0 parents commit 1d6c71a
Show file tree
Hide file tree
Showing 45 changed files with 9,449 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vscode
node_modules**
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
generate:
buf generate --path ./protobuf

publish:
cd ./protobuf/gen/es/protobuf; npm publish
25 changes: 25 additions & 0 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: v2
managed:
enabled: true
override:
- file_option: go_package_prefix
value: github.com/kavkaco/Kavka-Core/protobuf/gen/go
plugins:
# Generate GoLang
- local: protoc-gen-go
out: protobuf/gen/go
opt: paths=source_relative
- local: protoc-gen-connect-go
out: protobuf/gen/go
opt: paths=source_relative
# Generate TypeScript
- local: protoc-gen-es
out: protobuf/gen/es
opt:
- target=ts
- import_extension=.ts
- local: protoc-gen-connect-es
out: protobuf/gen/es
opt:
- target=ts
- import_extension=.ts
2 changes: 2 additions & 0 deletions buf.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Generated by buf. DO NOT EDIT.
version: v2
3 changes: 3 additions & 0 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
version: v2

name: buf.build/kavkaco/kavka
88 changes: 88 additions & 0 deletions protobuf/auth/v1/auth.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
syntax = "proto3";
package auth.v1;

import "google/protobuf/duration.proto";
import "protobuf/model/user/v1/user.proto";

option go_package = "auth/v1";

service AuthService {
rpc Login(LoginRequest) returns (LoginResponse);
rpc Register(RegisterRequest) returns (RegisterResponse);
rpc VerifyEmail(VerifyEmailRequest) returns (VerifyEmailResponse);
rpc SendResetPassword(SendResetPasswordRequest) returns (SendResetPasswordResponse);
rpc SubmitResetPassword(SubmitResetPasswordRequest) returns (SubmitResetPasswordResponse);
rpc ChangePassword(ChangePasswordRequest) returns (ChangePasswordResponse);
rpc Authenticate(AuthenticateRequest) returns (AuthenticateResponse);
rpc RefreshToken(RefreshTokenRequest) returns (RefreshTokenResponse);
}

message LoginRequest {
string email = 1;
string password = 2;
}

message LoginResponse {
model.user.v1.User user = 1;
string access_token = 2;
string refresh_token = 3;
}

message RegisterRequest {
string name = 1;
string last_name = 2;
string username = 3;
string email = 4;
string password = 5;
string verify_email_redirect_url = 6;
}

message RegisterResponse {}

message VerifyEmailRequest {
string verify_email_token = 1;
}

message VerifyEmailResponse {}

message SendResetPasswordRequest {
string email = 1;
string reset_password_redirect_url = 2;
}

message SendResetPasswordResponse {
string reset_password_token = 1;
google.protobuf.Duration timeout = 2;
}

message SubmitResetPasswordRequest {
string reset_password_token = 1;
string new_password = 2;
}

message SubmitResetPasswordResponse {}

message ChangePasswordRequest {
string access_token = 1;
string old_password = 2;
string new_password = 3;
}

message ChangePasswordResponse {}

message AuthenticateRequest {
string access_token = 1;
}

message AuthenticateResponse {
model.user.v1.User user = 1;
}

message RefreshTokenRequest {
string refresh_token = 1;
string user_id = 2;
}

message RefreshTokenResponse {
string access_token = 1;
}
76 changes: 76 additions & 0 deletions protobuf/chat/v1/chat.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
syntax = "proto3";
package chat.v1;

import "protobuf/model/chat/v1/chat.proto";

option go_package = "protobuf/chat/v1";

service ChatService {
rpc GetChat(GetChatRequest) returns (GetChatResponse) {}
rpc GetDirectChat(GetDirectChatRequest) returns (GetDirectChatResponse) {}
rpc GetUserChats(GetUserChatsRequest) returns (GetUserChatsResponse) {}
rpc CreateDirect(CreateDirectRequest) returns (CreateDirectResponse) {}
rpc CreateGroup(CreateGroupRequest) returns (CreateGroupResponse) {}
rpc CreateChannel(CreateChannelRequest) returns (CreateChannelResponse) {}
rpc JoinChat(JoinChatRequest) returns (JoinChatResponse) {}
}

message GetDirectChatRequest {
string recipient_user_id = 1;
}

message GetDirectChatResponse {
model.chat.v1.Chat chat = 1;
}

message GetChatRequest {
string chat_id = 1;
}

message GetChatResponse {
model.chat.v1.Chat chat = 1;
}

message GetUserChatsRequest {
string user_id = 1;
}

message GetUserChatsResponse {
repeated model.chat.v1.Chat chats = 1;
}

message CreateDirectRequest {
string recipient_user_id = 1;
}

message CreateDirectResponse {
model.chat.v1.Chat chat = 1;
}

message CreateGroupRequest {
string title = 1;
string username = 2;
string description = 3;
}

message CreateGroupResponse {
model.chat.v1.Chat chat = 1;
}

message CreateChannelRequest {
string title = 1;
string username = 2;
string description = 3;
}

message CreateChannelResponse {
model.chat.v1.Chat chat = 1;
}

message JoinChatRequest {
string chat_id = 1;
}

message JoinChatResponse {
model.chat.v1.Chat chat = 1;
}
50 changes: 50 additions & 0 deletions protobuf/events/v1/events.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
syntax = "proto3";
package events.v1;

import "protobuf/model/chat/v1/chat.proto";
import "protobuf/model/message/v1/message.proto";

option go_package = "events/v1";

message StreamEvent {
string sender_user_id = 1;
repeated string receivers_user_id = 2;
bytes payload = 3;
}

service EventsService {
rpc SubscribeEventsStream(SubscribeEventsStreamRequest) returns (stream SubscribeEventsStreamResponse) {}
}

message SubscribeEventsStreamRequest {}

message SubscribeEventsStreamResponse {
enum Type {
TYPE_UNSPECIFIED = 0;
TYPE_ADD_CHAT = 1;
TYPE_REMOVE_CHAT = 2;
TYPE_UPDATE_CHAT = 3;
TYPE_ADD_MESSAGE = 4;
TYPE_REMOVE_MESSAGE = 5;
TYPE_UPDATE_MESSAGE = 6;
TYPE_CLEAR_CHAT = 7;
TYPE_MESSAGE_SEEN = 8;
}

string name = 1;
Type type = 2;

oneof payload {
AddChat add_chat = 3;
AddMessage add_message = 4;
}
}

message AddChat {
model.chat.v1.Chat chat = 1;
}

message AddMessage {
string chat_id = 1;
model.message.v1.Message message = 2;
}
89 changes: 89 additions & 0 deletions protobuf/gen/es/protobuf/auth/v1/auth_connect.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// @generated by protoc-gen-connect-es v1.4.0 with parameter "target=ts,import_extension=.ts"
// @generated from file protobuf/auth/v1/auth.proto (package auth.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck

import { AuthenticateRequest, AuthenticateResponse, ChangePasswordRequest, ChangePasswordResponse, LoginRequest, LoginResponse, RefreshTokenRequest, RefreshTokenResponse, RegisterRequest, RegisterResponse, SendResetPasswordRequest, SendResetPasswordResponse, SubmitResetPasswordRequest, SubmitResetPasswordResponse, VerifyEmailRequest, VerifyEmailResponse } from "./auth_pb.ts";
import { MethodKind } from "@bufbuild/protobuf";

/**
* @generated from service auth.v1.AuthService
*/
export const AuthService = {
typeName: "auth.v1.AuthService",
methods: {
/**
* @generated from rpc auth.v1.AuthService.Login
*/
login: {
name: "Login",
I: LoginRequest,
O: LoginResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc auth.v1.AuthService.Register
*/
register: {
name: "Register",
I: RegisterRequest,
O: RegisterResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc auth.v1.AuthService.VerifyEmail
*/
verifyEmail: {
name: "VerifyEmail",
I: VerifyEmailRequest,
O: VerifyEmailResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc auth.v1.AuthService.SendResetPassword
*/
sendResetPassword: {
name: "SendResetPassword",
I: SendResetPasswordRequest,
O: SendResetPasswordResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc auth.v1.AuthService.SubmitResetPassword
*/
submitResetPassword: {
name: "SubmitResetPassword",
I: SubmitResetPasswordRequest,
O: SubmitResetPasswordResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc auth.v1.AuthService.ChangePassword
*/
changePassword: {
name: "ChangePassword",
I: ChangePasswordRequest,
O: ChangePasswordResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc auth.v1.AuthService.Authenticate
*/
authenticate: {
name: "Authenticate",
I: AuthenticateRequest,
O: AuthenticateResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc auth.v1.AuthService.RefreshToken
*/
refreshToken: {
name: "RefreshToken",
I: RefreshTokenRequest,
O: RefreshTokenResponse,
kind: MethodKind.Unary,
},
}
} as const;

Loading

0 comments on commit 1d6c71a

Please sign in to comment.