syntax = "proto3";
// flynt-disable package-matches-structure
package com.wixpress.appservice.api.upstream.wix.segments.spi.v2;
import "components_catalog_data/contacts_segments_v2_filter_provider/com/wixpress/appservice/api/upstream/wix/segments/v2/common/segments_common.proto";
import "google/protobuf/wrappers.proto";
import "wix/api/validations.proto";
import "wix/api/annotations.proto";

// TimeConstraintCapability and related messages for detailed time constraint validation
message TimeConstraintConfiguration {
    option (.wix.api.decomposite_of) = "wix.segments.spi.v2.TimeConstraintConfiguration";
  
  // Reserved field IDs for deleted fields
  reserved 4, 5;
  reserved "min_max_range_options", "range_options";
  
  // Enum for the different types of value constraints
  enum ValueConstraintType {
    UNKNOWN_VALUE_CONSTRAINT_TYPE = 0 [(.wix.api.enum_maturity) = NOT_IMPLEMENTED];
    // Reserved enum values for deleted types
    reserved 1, 3, 4;
    reserved "NONE", "MIN_MAX_RANGE", "RANGE";
    
    // Provider supports only specific predefined values
    PREDEFINED_VALUES = 2;
  }

  // The type of time constraint
  wix.segments.v2.common.TimeConstraintTypeEnum.TimeConstraintType type = 1;

  // The type of value constraint to apply
  ValueConstraintType value_constraint_type = 2;

  // Validation rules specific to the constraint type
  // This oneof is optional - when value_constraint_type is NONE, no options are set
  oneof value_constraints {
    option (.wix.api.aligned_with_enum).field = "value_constraint_type";

    // For LAST_DAYS, NEXT_DAYS - only specific allowed values
    PredefinedValues predefined_values_options = 3;
  }
}

// List of specific allowed values (e.g., [1, 3, 7, 30])
message PredefinedValues {
    option (.wix.api.decomposite_of) = "wix.segments.spi.v2.PredefinedValues";
  // List of allowed values for the constraint
  repeated int32 allowed_values = 1 [(.wix.api.maxSize) = 10, (.wix.api.min) = 1];
}

// Minimum and maximum allowed value (inclusive)
message MinMaxRange {
    option (.wix.api.decomposite_of) = "wix.segments.spi.v2.MinMaxRange";
  // Minimum value for the constraint
  int32 min_value = 1 [(.wix.api.min) = 1];
  // Maximum value for the constraint
  int32 max_value = 2 [(.wix.api.min) = 1];
}

// Constraints for TIME_CONSTRAINT_BETWEEN (date range selection)
message RangeConstraints {
    option (.wix.api.decomposite_of) = "wix.segments.spi.v2.RangeConstraints";
  // Maximum allowed range in days (e.g., max 365 days between start and end)
  google.protobuf.Int32Value max_range_days = 1 [(.wix.api.min) = 1];
}
