// common/proto/tables_data.proto
syntax = "proto3";
package komp_ac.tables_data;

import "common.proto";
import "google/protobuf/struct.proto";

service TablesData {
  rpc PostTableData (PostTableDataRequest) returns (PostTableDataResponse);
  rpc PutTableData (PutTableDataRequest) returns (PutTableDataResponse);
  rpc DeleteTableData (DeleteTableDataRequest) returns (DeleteTableDataResponse);
  rpc GetTableData(GetTableDataRequest) returns (GetTableDataResponse);
  rpc GetTableDataCount(GetTableDataCountRequest) returns (komp_ac.common.CountResponse);
  rpc GetTableDataByPosition(GetTableDataByPositionRequest) returns (GetTableDataResponse);
}

message PostTableDataRequest {
  string profile_name = 1;
  string table_name = 2;
  map<string, google.protobuf.Value> data = 3;
}

message PostTableDataResponse {
  bool success = 1;
  string message = 2;
  int64 inserted_id = 3;
}

message PutTableDataRequest {
  string profile_name = 1;
  string table_name = 2;
  int64 id = 3;
  map<string, google.protobuf.Value> data = 4;
}

message PutTableDataResponse {
  bool success = 1;
  string message = 2;
  int64 updated_id = 3;
}

message DeleteTableDataRequest {
  string profile_name = 1;
  string table_name = 2;
  int64 record_id = 3;
}

message DeleteTableDataResponse {
  bool success = 1;
}

message GetTableDataRequest {
  string profile_name = 1;
  string table_name = 2;
  int64 id = 3;
}

message GetTableDataResponse {
  map<string, string> data = 1;
}

message GetTableDataCountRequest {
    string profile_name = 1;
    string table_name = 2;
}

message GetTableDataByPositionRequest {
  string profile_name = 1;
  string table_name = 2;
  int32 position = 3;
}
