/**
Wrappers for representing changes in ___Update events.

These wrappers are intended to help deal with common problems in designing
change events and dealing with upgradeability in said events. That is, how
to easily represent partial updates and partial state changes, and also when
producer/consumer schema are versioned up, how to know how much is being
updated.

The pattern is a struct named <type>Change with the same layout:

  bool updated:
      must be `true` when a field has been updated in the new version.
  <type> value:
      The current value of the field.
  bool has_old_value:
      If set, then the publisher has elected to include the old value of the
      field in question. Otherwise, they are only including the updated value.
  <type> old_value:
      The old value of this field before the change. If `has_old_value` is 
      false, then this value will be the default value.

As a special case, we also have the `Change` struct which represents changes
where we want to signal _that_ a field changed but not what the new value is.
This can apply both in cases where restricted/PII data cannot be given, or in
a case the value is too large to sensibly include in an event but we still 
want to signal changes that have happened.
*/

syntax = "proto3";

package eventbus.change;

option go_package = "code.justin.tv/eventbus/schema/pkg/eventbus/change;change";

import "google/protobuf/timestamp.proto";
import "google/protobuf/wrappers.proto";

// Denotes a field that can change
message Change {
  bool updated = 1;
}

// Denotes a string that can change and allows for new values to be set.
message StringChange {
  bool updated = 1;
  string value = 2;
  bool has_old_value = 3;
  string old_value = 4;
}

// Denotes an integer value that can change and allows for new values to be set.
message Int64Change {
  bool updated = 1;
  int64 value = 2;
  bool has_old_value = 3;
  int64 old_value = 4;
}

// Denotes a boolean value that can change and allows for new values to be set.
message BoolChange {
  bool updated = 1;
  bool value = 2;
  bool has_old_value = 3;
  bool old_value = 4;
}

// Denotes a string array that can change and allows for new values to be set.
message StringArrayChange {
  bool updated = 1;
  repeated string value = 2;
  bool has_old_value = 3;
  repeated string old_value = 4;
}

// Denotes a timestamp that can change and allows for new values to be set.
message TimestampChange {
  bool updated = 1;
  google.protobuf.Timestamp value = 2;
  bool has_old_value = 3;
  google.protobuf.Timestamp old_value = 4;
}

// Denotes a wrapped integer value that can change and allows for new values to be set.
message Int64ValueChange {
  bool updated = 1;
  google.protobuf.Int64Value value = 2;
  bool has_old_value = 3;
  google.protobuf.Int64Value old_value = 4;
}

// Denotes a wrapped string value that can change and allows for new values to be set.
message StringValueChange {
  bool updated = 1;
  google.protobuf.StringValue value = 2;
  bool has_old_value = 3;
  google.protobuf.StringValue old_value = 4;
}
