syntax = "proto3";
// flynt-disable package-matches-structure
package com.wixpress.appservice.api.upstream.wix.segments.spi.v2;
option java_package = "com.wixpress.appservice.api.upstream.wix.segments.spi.v2";

import "wix/api/validations.proto";
import "google/protobuf/wrappers.proto";
import "google/protobuf/timestamp.proto";
import "components_catalog_data/contacts_segments_v2_filter_provider/com/wixpress/appservice/api/upstream/wix/segments/v2/common/segments_common.proto";
import "wix/api/annotations.proto";


message Predicate {
    option (.wix.api.decomposite_of) = "wix.segments.spi.v2.Predicate";
  oneof kind {
    // A single atomic predicate
    AtomicPredicate atomic = 1;
    // A composite predicate that combines multiple predicates with logical operators.
    CompositePredicate composite = 2;
  }

}

message CompositePredicate {
    option (.wix.api.decomposite_of) = "wix.segments.spi.v2.CompositePredicate";
  // List of predicates to be combined using the logical operator.
  // if the operator is NOT, this list should contain only one predicate.
  repeated Predicate predicates = 1 [(.wix.api.maxSize) = 5, (.wix.api.minSize) = 1];
  // Logical operator (AND/OR/NOT) used to combine the predicates.
  LogicalOperator operator = 2;
}

enum LogicalOperator {
  UNKNOWN_OPERATOR = 0 [(.wix.api.enum_maturity) = NOT_IMPLEMENTED];
  AND = 1;
  OR = 2;
  NOT = 3;
}

message AtomicPredicate {
    option (.wix.api.decomposite_of) = "wix.segments.spi.v2.AtomicPredicate";
  // Identifier of the provider (e.g., app's spi_identifier) that offers this filter capability.
  string provider_id = 1 [(.wix.api.maxLength) = 50];

  // Name of the attribute to filter on (e.g., "email", "age", "last_purchase_date").
  string attribute_name = 2 [(.wix.api.maxLength) = 50];

  // translated display name for the attribute. readonly
  .google.protobuf.StringValue display_name = 3 [(.wix.api.maxLength) = 100, (.wix.api.readOnly) = true];

  // Operator to apply
  com.wixpress.appservice.api.upstream.wix.segments.v2.common.OperatorEnum.Operator operator = 4;
  // Values to use in the filter operation
  repeated ParameterValue parameter_values = 5 [(.wix.api.maxSize) = 5];
  // Optional time constraint to limit when applying the predicate.
  TimeConstraint time_constraint = 6;
}

// List wrapper messages for supporting multiple values
message StringList {
    option (.wix.api.decomposite_of) = "wix.segments.spi.v2.StringList";
  // List of string values. Max 100 items, each with max length 100 characters.
  repeated string values = 1 [(.wix.api.maxSize) = 100, (.wix.api.maxLength) = 100];
}

message IntList {
    option (.wix.api.decomposite_of) = "wix.segments.spi.v2.IntList";
  // List of integer values. Max 100 items.
  repeated int64 values = 1 [(.wix.api.maxSize) = 100];
}

message DecimalList {
    option (.wix.api.decomposite_of) = "wix.segments.spi.v2.DecimalList";
  // List of decimal values represented as strings to preserve precision. Max 100 items, each with max length 20 characters.
  repeated string values = 1 [(.wix.api.maxSize) = 100, (.wix.api.maxLength) = 20, (.wix.api.format) = DECIMAL_VALUE, (.wix.api.decimalValue) = {maxScale : 5}];
}

message BoolList {
    option (.wix.api.decomposite_of) = "wix.segments.spi.v2.BoolList";
  // List of boolean values. Max 2 items (typically true/false options).
  repeated bool values = 1 [(.wix.api.maxSize) = 2];
}

message CurrencyList {
    option (.wix.api.decomposite_of) = "wix.segments.spi.v2.CurrencyList";
  // List of ISO 4217 currency codes. Max 100 items, each with max length 10 characters.
  repeated string values = 1 [(.wix.api.maxSize) = 100, (.wix.api.maxLength) = 10, (.wix.api.format) = CURRENCY];
}

message CountrySubdivisionList {
    option (.wix.api.decomposite_of) = "wix.segments.spi.v2.CountrySubdivisionList";
  // List of ISO 3166-2 country subdivision codes (states, provinces). Max 100 items, each with max length 10 characters.
  repeated string values = 1 [(.wix.api.maxSize) = 100, (.wix.api.maxLength) = 10, (.wix.api.format) = SUBDIVISION];
}

message LanguageTagList {
    option (.wix.api.decomposite_of) = "wix.segments.spi.v2.LanguageTagList";
  // List of ISO 639 language codes. Max 100 items, each with max length 10 characters.
  repeated string values = 1 [(.wix.api.maxSize) = 100, (.wix.api.maxLength) = 10, (.wix.api.format) = LANGUAGE_TAG];
}

// Supported kinds for PredicateParameterValue
message ParameterValueKindEnum {
    option (.wix.api.decomposite_of) = "wix.segments.spi.v2.ParameterValueKindEnum";
  enum ParameterValueKind {
    UNKNOWN_PARAMETER_VALUE_KIND = 0 [(.wix.api.enum_maturity) = NOT_IMPLEMENTED];
    STRING_VALUE = 1;
    INT_VALUE = 2;
    DECIMAL_VALUE = 3;
    BOOL_VALUE = 4;
    CURRENCY_VALUE = 5;
    COUNTRY_SUBDIVISION_VALUE = 6;
    LANGUAGE_TAG_VALUE = 7;
    STRING_LIST = 8;
    INT_LIST = 9;
    DECIMAL_LIST = 10;
    BOOL_LIST = 11;
    CURRENCY_LIST = 12;
    COUNTRY_SUBDIVISION_LIST = 13;
    LANGUAGE_TAG_LIST = 14;
  }
}

message ParameterValue {
    option (.wix.api.decomposite_of) = "wix.segments.spi.v2.ParameterValue";
  // Name or identifier of the parameter.
  string name = 1 [(.wix.api.minLength) = 1, (.wix.api.maxLength) = 50];

  // Human-readable display name for the parameter. readonly
  .google.protobuf.StringValue display_name = 2 [(.wix.api.maxLength) = 100, (.wix.api.readOnly) = true];

  // Discriminator specifying which value is set in the 'value' oneof.
  ParameterValueKindEnum.ParameterValueKind kind = 16;

  oneof value {
    option (.wix.api.aligned_with_enum).field = "kind";
    // String value
    string string_value_options = 3 [(.wix.api.maxLength) = 200];
    // Integer value
    int64 int_value_options = 4;
    // Decimal value, represented as a string to preserve precision.
    string decimal_value_options = 5 [(.wix.api.maxLength) = 20, (.wix.api.format) = DECIMAL_VALUE, (.wix.api.decimalValue) = {maxScale : 5}];
    // Boolean value
    bool bool_value_options = 6;
    // Currency code value in ISO 4217 alphabetic codes format (e.g., "USD", "EUR").
    string currency_value_options = 7 [(.wix.api.maxLength) = 10, (.wix.api.format) = CURRENCY] ;
    // Country subdivision code value in ISO 3166-2 format (e.g., state, province).
    string country_subdivision_value_options = 8 [(.wix.api.maxLength) = 10, (.wix.api.format) = SUBDIVISION];
    // Language code value in ISO 639 format(e.g., "en", "es", "fr").
    string language_tag_value_options = 9 [(.wix.api.maxLength) = 10, (.wix.api.format) = LANGUAGE_TAG];
    
    // List values
    // List of string values for multi-value string parameters
    StringList string_list_options = 10;
    // List of integer values for multi-value numeric parameters
    IntList int_list_options = 11;
    // List of decimal values for multi-value decimal parameters, represented as strings to preserve precision
    DecimalList decimal_list_options = 12;
    // List of boolean values for multi-value boolean parameters
    BoolList bool_list_options = 13;
    // List of ISO 4217 currency code values for multi-value currency parameters
    CurrencyList currency_list_options = 14;
    // List of ISO 3166-2 country subdivision code values for multi-value location parameters
    CountrySubdivisionList country_subdivision_list_options = 15;
    // List of ISO 639 language code values for multi-value language parameters
    LanguageTagList language_tag_list_options = 17;
  }
}

message TimeConstraint {
    option (.wix.api.decomposite_of) = "wix.segments.spi.v2.TimeConstraint";
  // Type of time constraint to apply
  wix.segments.v2.common.TimeConstraintTypeEnum.TimeConstraintType type = 1;

  // required for LAST_DAYS, LAST_HOURS, NEXT_DAYS, NEXT_HOURS
  .google.protobuf.Int32Value value = 2[(.wix.api.min) = 1];

  // start date, required for BETWEEN time constraint type
  .google.protobuf.Timestamp from_date = 3;
  // End date, required for BETWEEN time constraint type.
  .google.protobuf.Timestamp to_date = 4;
}
;