syntax = "proto3";

package exa.reactive_component_pb;

enum TestEnum {
  TEST_ENUM_UNSPECIFIED = 0;
  TEST_ENUM_ONE = 1;
  TEST_ENUM_TWO = 2;
}

message StreamReactiveUpdatesRequest {
  uint32 protocol_version = 1;
  string id = 2;
}

message StreamReactiveUpdatesResponse {
  uint64 version = 1;
  .exa.reactive_component_pb.MessageDiff diff = 2;
  bytes full_state = 3;
}

message TestProto {
  int32 counter = 1;
  repeated int32 values = 2;
  .exa.reactive_component_pb.TestProto nested = 3;
  repeated .exa.reactive_component_pb.TestProto nested_repeated = 4;
}

message MessageDiff {
  repeated .exa.reactive_component_pb.FieldDiff field_diffs = 1;
}

message FieldDiff {
  uint32 field_number = 1;
  oneof diff {
    .exa.reactive_component_pb.SingularValue update_singular = 2;
    .exa.reactive_component_pb.RepeatedDiff update_repeated = 3;
    .exa.reactive_component_pb.MapDiff update_map = 4;
    bool clear = 5;
  }
}

message RepeatedDiff {
  uint32 new_length = 1;
  repeated .exa.reactive_component_pb.SingularValue update_values = 2;
  repeated uint32 update_indices = 3;
}

message MapDiff {
  repeated .exa.reactive_component_pb.MapKeyDiff map_key_diffs = 1;
}

message MapKeyDiff {
  .exa.reactive_component_pb.SingularValue map_key = 1;
  oneof diff {
    .exa.reactive_component_pb.SingularValue update_singular = 2;
    bool clear = 3;
  }
}

message SingularValue {
  oneof value {
    double double_value = 1;
    float float_value = 2;
    int32 int32_value = 3;
    int64 int64_value = 4;
    uint32 uint32_value = 5;
    uint64 uint64_value = 6;
    sint32 sint32_value = 7;
    sint64 sint64_value = 8;
    fixed32 fixed32_value = 9;
    fixed64 fixed64_value = 10;
    sfixed32 sfixed32_value = 11;
    sfixed64 sfixed64_value = 12;
    bool bool_value = 13;
    uint32 enum_value = 14;
    string string_value = 15;
    bytes bytes_value = 16;
    .exa.reactive_component_pb.MessageDiff message_value = 17;
  }
}

message TestDiffProto {
  double singular_scalar_value = 1;
  .exa.reactive_component_pb.TestProto singular_message_value = 2;
  optional double optional_scalar_value = 10;
  repeated double repeated_scalar_value = 3;
  repeated .exa.reactive_component_pb.TestProto repeated_message_value = 4;
  map<int32, double> map_scalar_value = 5;
  map<string, .exa.reactive_component_pb.TestProto> map_message_value = 6;
  oneof oneof_test {
    double oneof_scalar_value = 7;
    .exa.reactive_component_pb.TestProto oneof_message_value = 8;
  }
  .exa.reactive_component_pb.TestEnum enum_value = 9;
}
