syntax = "proto3";

package wix.dealerPriority.api.v1;

import "wix/api/permissions.proto";
import "google/api/annotations.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/wrappers.proto";
import "google/protobuf/struct.proto";

import "wix/api/annotations.proto";
import "wix/api/validations.proto";
import "wix/api/entity.proto";

option java_package = "com.wix.dealerPriority.api.v1";

message PriorityItem {
  option (wix.api.entity) = {fqdn:"wix.dealer.v1.priority_item", segment: USERS};

  google.protobuf.StringValue item_id = 1 [(wix.api.format) = GUID];

  google.protobuf.Int32Value weight = 2;
}

message ItemPrioritized {
  google.protobuf.StringValue item_id = 1 [(wix.api.format) = GUID];

  google.protobuf.Int32Value priority = 2;

  google.protobuf.Struct metadata = 3;
}

enum PrioritizationStrategy {
  UNKNOWN = 0;

  // Manual - Prioritize by weight of the items.
  // - The items with the largest weight will have the highest priority
  // - Undefined weights will have the lowest priority
  MANUAL = 1;

  // CTR based, item prioritized from highest CTR to the lowest
  CTR = 2;

  // Random based item prioritization
  RANDOM = 3;

  // AB test based item prioritization
  ABCTR = 4;

  // Premium based item prioritization
  PremiumCTR = 5;

  // ML Model item prioritization
  MLModel = 6;

  // LLM Model item prioritization
  reserved 7;

  // Whats Next item prioritization
  reserved 8;

  // Advices item prioritization
  ADVICES = 9;

  // Collections based item prioritization
  COLLECTIONS = 10;
}

message PrioritizationStrategyParams {
  PrioritizationStrategy strategy = 1;

  // Learning rate for the supporting strategy
  // should be between 0 and 1
  google.protobuf.StringValue learning_allocation = 2 [(.wix.api.decimalValue) = { gte: "0.000", lte: "1", maxScale: 3 }];

  //flynt-disable field-type-breaking-change
  repeated FixedItem fixed_items = 5 [(.wix.api.maxSize) = 20];

  message FixedItem {
    string item_id = 1 [(wix.api.format) = GUID];
    int32 priority = 2;
  }

  oneof Configuration {
    ABCTRConfig ab_ctr_config = 3;

    WHATSNEXTConfig whats_next_config = 4;

    AdvicesConfig advices_config = 6;
  }

  message ABCTRConfig {
    google.protobuf.StringValue spec_name = 1;
  }

  message WHATSNEXTConfig {
    google.protobuf.Struct custom_params = 1;
  }

  message AdvicesConfig {
    reserved 1;

    google.protobuf.StringValue vespa_threshold = 2 [(.wix.api.decimalValue) = { gte: "0.000", lte: "1", maxScale: 3 }];

    PrioritizationStrategy fallback_strategy = 3;

    oneof AdvicesCustomConfig {
      WhatsNextConfiguration whats_next_custom_params = 4;

      Advices advices = 5;
    }

    message Advices {
      repeated string advices = 1 [(.wix.api.maxSize) = 20];
    }

    message WhatsNextConfiguration {
      // customParams - Custom parameters to be used for the WhatsNext Completion.
      google.protobuf.Struct custom_params = 1;

      // The fixed number of advices to be returned.
      // Default: 5
      // flynt-disable field-type-breaking-change
      google.protobuf.Int32Value total_advices = 2;

      // llmTimeout - The maximum time to wait for the WhatsNext Completion.
      // Maximum 10 seconds, WIX Cancels requests after 10 seconds.
      // Represented in milliseconds.
      int32 llm_timeout_in_ms = 3 [(.wix.api.min) = 0, (.wix.api.max) = 10000];
    }
  }
}
