syntax = "proto3";

package wix.devcenter.components.overrides.v1;
option java_package = "com.wixpress.devcenter.components.overrides.v1";

import "wix/api/validations.proto";
import "wix/api/entity.proto";
import "wix/api/annotations.proto";
import "google/protobuf/wrappers.proto";
import "google/protobuf/timestamp.proto";
import "components_catalog_data.proto";
import "com/wixpress/appservice/api/components_catalog_type.proto";
import "wix/common/data/dataextensions/extended-fields.proto";
import "wix/devcenter/components/experiments/v1/component_experiment.proto";


message ComponentsOverride {
  option (wix.api.entity) = {
    fqdn: "wix.devcenter.components_overrides.v1.components_override"
    segment: USERS
    appendix_files: {
      type: DOCS_CONF
      path: "appendices/docs"
    };
  };

  string id = 1 [(wix.api.minLength) = 1, (wix.api.maxLength) = 50]; // ComponentsOverride ID. Unique string given by the caller
  string app_id = 2 [(.wix.api.format) = GUID]; // The app id of the application which this override belongs to
  int32 app_version = 3 [(.wix.api.min) = 0]; // The app version which this override belongs to
  repeated ModifiedComponent modified_components = 4 [(wix.api.minSize) = 0, (.wix.api.maxSize) = 100]; // The modified components that are a part of this override
  string external_id = 5 [(wix.api.minLength) = 1, (wix.api.maxLength) = 64]; // The external id which this override belongs to
  google.protobuf.Timestamp created_date = 6 [(wix.api.readOnly) = true];  // Date and time the ComponentsOverride was created.
  repeated ComponentExperiment experiments = 7 [(.wix.api.maxSize) = 100]; // Experiments must be on components that appear in modified_components field
  repeated com.wixpress.appservice.api.ComponentType contained_component_types = 8 [(wix.api.readOnly) = true, (.wix.api.maxSize) = 100]; // The component types in the override
  google.protobuf.StringValue external_version = 9 [(wix.api.maxLength) = 64]; // The external version of the component, if exists. Related to the component's external_id.
}

message ModifiedComponent {
  string component_id = 1 [(.wix.api.format) = GUID]; // Component Id
  google.protobuf.StringValue name = 2; //The name of the component
  com.wixpress.appservice.api.ComponentType type = 3 [(wix.api.readOnly) = true]; // The type of the component
  com.wixpress.appservice.api.ComponentData data = 4; // The data of the component
  google.protobuf.Int64Value base_version = 5 [(.wix.api.min) = 0]; // The component's version which was modified
}

message ComponentExperiment {
  string component_id = 1 [(.wix.api.format) = GUID]; // component id of the component experiment
  string spec = 2 [(.wix.api.maxLength) = 128]; // Spec to conduct on the component
  google.protobuf.StringValue variant_value = 3 [(.wix.api.maxLength) = 128]; // Value the spec should return in order to return the newer component version
  devcenter.components.experiments.v1.ExperimentActionType experiment_action_type = 4; // The type of the experiment
  oneof experiment_action {
    option (.wix.api.aligned_with_enum).field = "experiment_action_type";
    devcenter.components.experiments.v1.CreateComponent create_component_options = 5; // Experiment result is to create a component
    devcenter.components.experiments.v1.UpdateComponent update_component_options = 6; // Experiment result is to update specific fields in the component
    devcenter.components.experiments.v1.DeleteComponent delete_component_options = 7; // Experiment result is to delete a component
  }
}
