From 2bc4708f313ff8a441fa6fc699ddc04b379b565c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?= Date: Sat, 11 Apr 2026 14:16:12 +0300 Subject: [PATCH] feat: refactors all proto files --- package.json | 2 +- proto/admin/admin-account.proto | 122 ++++++++++++++++++++++++++++++++ proto/{sso => admin}/rbac.proto | 0 proto/sso/account.proto | 112 ----------------------------- proto/{sso => users}/ldap.proto | 0 proto/users/users.proto | 60 ++++++++++++++++ src/proto/paths.ts | 5 +- 7 files changed, 186 insertions(+), 115 deletions(-) create mode 100644 proto/admin/admin-account.proto rename proto/{sso => admin}/rbac.proto (100%) rename proto/{sso => users}/ldap.proto (100%) create mode 100644 proto/users/users.proto diff --git a/package.json b/package.json index 42bad0c..68615f0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lendry-erp/contracts", - "version": "1.1.10", + "version": "1.2.10", "description": "Protobuf definitions and generated TypeScript types", "type": "commonjs", "main": "./dist/index.js", diff --git a/proto/admin/admin-account.proto b/proto/admin/admin-account.proto new file mode 100644 index 0000000..e50c074 --- /dev/null +++ b/proto/admin/admin-account.proto @@ -0,0 +1,122 @@ +syntax = "proto3"; + +package admin.account.v1; + +option go_package = "git.lendry.ru/lendry-erp/proto.git/go;pb"; + +service AdminAccountService { + rpc AdminResetPassword (AdminResetPasswordRequest) returns (AdminResetPasswordResponse); + rpc CreateUser(CreateUserRequest) returns (CreateUserResponse); + rpc DeleteUser(DeleteUserRequest) returns (DeleteUserResponse); + rpc ChangeData(ChangeDataRequest) returns (ChangeDataResponse); + rpc AssignRole (AssignRoleRequest) returns (AssignRoleResponse); + rpc RevokeRole (RevokeRoleRequest) returns (RevokeRoleResponse); + + rpc BlockUser(BlockUserRequest) returns (BlockUserResponse); + rpc UnblockUser(UnblockUserRequest) returns (UnblockUserResponse); + rpc BlockIp(BlockIpRequest) returns (BlockIpResponse); + rpc UnblockIp(UnblockIpRequest) returns (UnblockIpResponse); + + rpc SyncUsersToSearch (SyncUsersToSearchRequest) returns (SyncUsersToSearchResponse); +} + +message AdminResetPasswordRequest { + string user_id = 1; + string new_password = 2; +} + +message AdminResetPasswordResponse { + bool success = 1; + string message = 2; +} + +message CreateUserRequest { + string username = 1; + string password = 2; + repeated string roles = 3; +} + +message CreateUserResponse { + bool success = 1; + string message = 2; +} + +message DeleteUserRequest { + string user_id = 1; +} + +message DeleteUserResponse { + bool success = 1; + string message = 2; +} + +message ChangeDataRequest { + string user_id = 1; + string session_id = 2; + optional string email = 3; + optional string phone = 4; + optional string full_name = 5; + optional string avatar_url = 6; + optional string custom_status_text = 7; + optional string custom_status_emoji = 8; + optional string timezone = 9; + optional string language = 10; + optional bool is_public = 11; +} + +message ChangeDataResponse { + bool success = 1; + string message = 2; +} + +message AssignRoleRequest { + string user_id = 1; + string role_id = 2; // В gRPC передаем как string, внутри преобразуем в Int +} +message AssignRoleResponse { + bool success = 1; + string message = 2; +} +message RevokeRoleRequest { + string user_id = 1; + string role_id = 2; +} +message RevokeRoleResponse { + bool success = 1; + string message = 2; +} + +message BlockUserRequest { + string user_id = 1; // Кого блокируем + string admin_id = 2; // Кто блокирует + optional string reason = 3; +} +message BlockUserResponse { bool success = 1; string message = 2; } + +message UnblockUserRequest { + string user_id = 1; + string admin_id = 2; +} +message UnblockUserResponse { bool success = 1; string message = 2; } + +message BlockIpRequest { + string ip_address = 1; + string admin_id = 2; + optional string reason = 3; +} +message BlockIpResponse { bool success = 1; string message = 2; } + +message UnblockIpRequest { + string ip_address = 1; + string admin_id = 2; +} +message UnblockIpResponse { bool success = 1; string message = 2; } + +message SyncUsersToSearchRequest { + // Можно оставить пустым, так как нам не нужны входные данные +} + +message SyncUsersToSearchResponse { + bool success = 1; + string message = 2; +} diff --git a/proto/sso/rbac.proto b/proto/admin/rbac.proto similarity index 100% rename from proto/sso/rbac.proto rename to proto/admin/rbac.proto diff --git a/proto/sso/account.proto b/proto/sso/account.proto index a67d48c..6b743e5 100644 --- a/proto/sso/account.proto +++ b/proto/sso/account.proto @@ -7,23 +7,10 @@ option go_package = "git.lendry.ru/lendry-erp/proto.git/go;pb"; service AccountService { rpc GetAccount(GetAccountRequest) returns (GetAccountResponse); rpc ChangePassword (ChangePasswordRequest) returns (ChangePasswordResponse); - rpc AdminResetPassword (AdminResetPasswordRequest) returns (AdminResetPasswordResponse); - rpc CreateUser(CreateUserRequest) returns (CreateUserResponse); - rpc DeleteUser(DeleteUserRequest) returns (DeleteUserResponse); - rpc ChangeData(ChangeDataRequest) returns (ChangeDataResponse); - rpc AssignRole (AssignRoleRequest) returns (AssignRoleResponse); - rpc RevokeRole (RevokeRoleRequest) returns (RevokeRoleResponse); rpc SetPin (SetPinRequest) returns (SetPinResponse); rpc UnlockPin (UnlockPinRequest) returns (UnlockPinResponse); rpc GetPinStatus (GetPinStatusRequest) returns (GetPinStatusResponse); rpc RemovePin (RemovePinRequest) returns (RemovePinResponse); - - rpc BlockUser(BlockUserRequest) returns (BlockUserResponse); - rpc UnblockUser(UnblockUserRequest) returns (UnblockUserResponse); - rpc BlockIp(BlockIpRequest) returns (BlockIpResponse); - rpc UnblockIp(UnblockIpRequest) returns (UnblockIpResponse); - - rpc SyncUsersToSearch (SyncUsersToSearchRequest) returns (SyncUsersToSearchResponse); } message GetAccountRequest { @@ -64,71 +51,6 @@ message ChangePasswordResponse { string message = 2; } -message CreateUserRequest { - string username = 1; - string password = 2; - repeated string roles = 3; -} - -message CreateUserResponse { - bool success = 1; - string message = 2; -} - -message DeleteUserRequest { - string user_id = 1; -} - -message DeleteUserResponse { - bool success = 1; - string message = 2; -} - -message ChangeDataRequest { - string user_id = 1; - string session_id = 2; - optional string email = 3; - optional string phone = 4; - optional string full_name = 5; - optional string avatar_url = 6; - optional string custom_status_text = 7; - optional string custom_status_emoji = 8; - optional string timezone = 9; - optional string language = 10; - optional bool is_public = 11; -} - -message ChangeDataResponse { - bool success = 1; - string message = 2; -} - -message AssignRoleRequest { - string user_id = 1; - string role_id = 2; // В gRPC передаем как string, внутри преобразуем в Int -} -message AssignRoleResponse { - bool success = 1; - string message = 2; -} -message RevokeRoleRequest { - string user_id = 1; - string role_id = 2; -} -message RevokeRoleResponse { - bool success = 1; - string message = 2; -} - -message AdminResetPasswordRequest { - string user_id = 1; - string new_password = 2; -} - -message AdminResetPasswordResponse { - bool success = 1; - string message = 2; -} message SetPinRequest { string user_id = 1; @@ -174,37 +96,3 @@ message RemovePinResponse { } -message BlockUserRequest { - string user_id = 1; // Кого блокируем - string admin_id = 2; // Кто блокирует - optional string reason = 3; -} -message BlockUserResponse { bool success = 1; string message = 2; } - -message UnblockUserRequest { - string user_id = 1; - string admin_id = 2; -} -message UnblockUserResponse { bool success = 1; string message = 2; } - -message BlockIpRequest { - string ip_address = 1; - string admin_id = 2; - optional string reason = 3; -} -message BlockIpResponse { bool success = 1; string message = 2; } - -message UnblockIpRequest { - string ip_address = 1; - string admin_id = 2; -} -message UnblockIpResponse { bool success = 1; string message = 2; } - -message SyncUsersToSearchRequest { - // Можно оставить пустым, так как нам не нужны входные данные -} - -message SyncUsersToSearchResponse { - bool success = 1; - string message = 2; -} \ No newline at end of file diff --git a/proto/sso/ldap.proto b/proto/users/ldap.proto similarity index 100% rename from proto/sso/ldap.proto rename to proto/users/ldap.proto diff --git a/proto/users/users.proto b/proto/users/users.proto new file mode 100644 index 0000000..09645e9 --- /dev/null +++ b/proto/users/users.proto @@ -0,0 +1,60 @@ +syntax = "proto3"; + +package users.v1; + +option go_package = "git.lendry.ru/lendry-erp/proto.git/go;pb"; + +service UsersService { + rpc GetMe(GetMeRequest) returns (GetMeResponse); + rpc ChangeMe(ChangeMeRequest) returns (ChangeMeResponse); + rpc CreateUserRequest (CreateUserRequest) returns (CreateUserResponse); +} +message GetMeRequest { + string id = 1; +} +message GetMeResponse { + User user = 1; +} +message CreateUserRequest { + string id = 1; +} +message CreateUserResponse { + string success = 1; +} +message ChangeMeRequest { + string user_id = 1; + string session_id = 2; + optional string email = 3; + optional string phone = 4; + optional string full_name = 5; + optional string avatar_url = 6; + optional string custom_status_text = 7; + optional string custom_status_emoji = 8; + optional string timezone = 9; + optional string language = 10; + optional bool is_public = 11; +} +message ChangeMeResponse { + bool success = 1; + string message = 2; +} +message User { + string id = 1; + optional string username = 2; + optional string email = 3; + optional string phone = 4; + optional string full_name = 5; + bool is_ldap = 6; + optional string status = 7; + repeated string roles = 8; + optional string avatar_url = 9; + optional string employee_id = 10; + optional string presence = 11; + optional string last_active = 12; + optional string custom_status_text = 13; + optional string custom_status_emoji = 14; + optional string timezone = 15; + optional string language = 16; + bool two_fa_enabled = 17; + bool has_pin = 18; +} \ No newline at end of file diff --git a/src/proto/paths.ts b/src/proto/paths.ts index c6429ab..7eb37ad 100644 --- a/src/proto/paths.ts +++ b/src/proto/paths.ts @@ -4,8 +4,9 @@ export const PROTO_PATHS = { AUTH: join(__dirname, "../../proto/sso/auth.proto"), LDAP_AUTH: join(__dirname, "../../proto/sso/ldap-auth.proto"), ACCOUNT: join(__dirname, "../../proto/sso/account.proto"), - RBAC: join(__dirname, "../../proto/sso/rbac.proto"), TWOFA: join(__dirname, "../../proto/sso/twofa.proto"), - LDAP: join(__dirname, "../../proto/sso/ldap.proto"), + RBAC: join(__dirname, "../../proto/admin/rbac.proto"), + USERS: join(__dirname, "../../proto/users/users.proto"), + LDAP: join(__dirname, "../../proto/users/ldap.proto"), SEARCH: join(__dirname, "../../proto/search/search.proto"), } as const;