//flynt-disable missing-array-limits, missing-string-validations
syntax = "proto3";

package wix.common.data;

option java_multiple_files = true;
option java_package = "com.wix.common.data";

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

message FilterErrorDetails {
    oneof details {
        IllegalOperandType illegal_operand_type = 1;
        NotSupportedForPii not_supported_for_pii = 2;
        ExceedsAllowedDepth exceeds_allowed_depth = 3;
        ExceedsAllowedNumberOfOperands exceeds_allowed_number_of_operands = 4;
        UnknownOperator unknown_operator = 5;
        UnexpectedFieldType unexpected_field_type = 6;
        MismatchedFieldType mismatched_field_type = 7;
        InvalidDate invalid_date = 8;
        UnknownField unknown_field = 9;
        IllegalFilterOnCustomType illegal_filter_on_custom_type = 10;
        InvalidFilterValue invalid_filter_value = 11;
        WrongType wrong_type = 12;
        InvalidUUID invalid_uuid = 13;
        RevisionViolation revision_violation = 14;
        IllegalFieldTypeForStartsWith illegal_field_type_for_starts_with = 15;
        ArrayFieldExpectedForArrayOperator array_field_expected_for_array_operator = 16;
        PiiPredicateUnderNotPredicate pii_predicate_under_not_predicate = 17;
        UnknownEnumValues unknown_enum_values = 18;
        ExistsNotAllowedForWildcardPath exists_not_allowed_for_wildcard_path = 19;
        TwoFieldsPredicateTypeMismatch two_fields_predicate_type_mismatch = 20;
        TwoFieldsPredicateUnsupportedType two_fields_predicate_unsupported_type = 21;
        TwoFieldsPredicatePiiNotSupported two_fields_predicate_pii_not_supported = 22;
    }

    message IllegalOperandType {
        string operator = 1;
        string filter_part = 2;
        string additional_data = 3;
    }

    message NotSupportedForPii {
        string operator = 1;
        string field_path = 2;
    }

    message ExceedsAllowedDepth {
        int32 depth = 1;
        int32 allowed_depth = 2;
        string filter_part = 3;
    }

    message ExceedsAllowedNumberOfOperands {
        string operator = 1;
        int32 size = 2;
        int32 allowed_size = 3;
        repeated string values = 4 [(.wix.api.field_exposure) = PRIVATE, deprecated = true];
    }

    message UnknownOperator {
        string operator = 1;
    }

    message UnexpectedFieldType {
        string field_path = 1;
        string expected_type = 2;
        google.protobuf.StringValue operator = 3;
        google.protobuf.StringValue value = 4;
    }

    message MismatchedFieldType {
        string field_path = 1;
        string mismatched_type = 2;
        string operator = 3;
    }

    message InvalidDate {
        string field_path = 1;
        string field_value = 2;
    }

    message UnknownField {
        string field_path = 1;
    }

    message IllegalFilterOnCustomType {
        string field_path = 1;
    }

    message InvalidFilterValue {
        string json_filter = 1;
    }

    message WrongType {
        string path = 1;
        string passed = 2;
        string expected = 3;
    }

    message InvalidUUID {
        string path = 1;
        string value = 2;
    }

    message RevisionViolation {
        string entity_id = 1;
    }

    message IllegalFieldTypeForStartsWith {
        string field_path = 1;
        string fieldType = 2;
    }

    message ArrayFieldExpectedForArrayOperator {
        string field_path = 1;
    }

    message PiiPredicateUnderNotPredicate {
        string path = 1;
    }

    message UnknownEnumValues {
        string field_path = 1;
        string enum_type = 2;
        repeated string unknown_values = 3;
    }

    message ExistsNotAllowedForWildcardPath {
        string field_path = 1;
    }

    message TwoFieldsPredicateTypeMismatch {
        string left_path = 1;
        string left_type = 2;
        string right_path = 3;
        string right_type = 4;
    }

    message TwoFieldsPredicateUnsupportedType {
        string field_path = 1;
        string field_type = 2;
    }

    message TwoFieldsPredicatePiiNotSupported {
        string field_path = 1;
    }
}

message PatchErrorDetails {
    oneof details {
        IllegalFieldRemoved illegal_field_removed = 1;
        InvalidPatch invalid_patch = 2;
        IllegalPatchSystemFields illegal_patch_system_fields = 3;
        PatchFailed patch_failed = 4;
        ChangeByOperationIsNotSupported change_by_operation_is_not_supported = 5;
        WrongType wrong_type = 6;
        IllegalPath illegal_path = 7;
        NonInteger non_integer = 8;
        ValueExceeded value_exceeded = 9;
        InvalidUUID invalid_uuid = 10;
        SystemFieldNotAllowed system_field_not_allowed = 11;
        FailedToWriteType failed_to_write_type = 12;
    }

    message IllegalFieldRemoved {
        string field_path = 1;
    }

    message InvalidPatch {
        string patch_json = 1;
    }

    message IllegalPatchSystemFields {
        repeated string fields = 1;
    }

    message PatchFailed {
        string entity_id = 1;
    }

    message ChangeByOperationIsNotSupported {
        string path = 1;
    }

    message WrongType {
        string path = 1;
        string passed = 2;
        string expected = 3;
    }

    message FailedToWriteType {
        string path = 1;
        string expected_type = 2;
        string value = 3;
    }

    message IllegalPath {
        string path = 1;
    }

    message NonInteger {
        string path = 1;
        double value = 2;
    }

    message ValueExceeded {
        string path = 1;
        double value = 2;
    }

    message InvalidUUID {
        string path = 1;
        string value = 2;
    }

    message SystemFieldNotAllowed {
        string field_path = 1;
    }
}

message SortErrorDetails {
    oneof details {
        PiiFieldNotSortable pii_field_not_sortable = 1;
        SortByCustomTypeNotSupported sort_by_custom_type_not_supported = 2;
        SortByUnknownPathNotSupported sort_by_unknown_path_not_supported = 3;
        SortByUntypedPathNotSupported sort_by_untyped_path_not_supported = 4;
        SortByObjectTypeNotSupported sort_by_object_type_not_supported = 5;
        SortByArrayTypeNotSupported sort_by_array_type_not_supported = 6;
    }

    message PiiFieldNotSortable {
        string field_path = 1;
    }

    message SortByCustomTypeNotSupported {
        string field_path = 1;
    }

    message SortByUnknownPathNotSupported {
        string field_path = 1;
    }

    message SortByUntypedPathNotSupported {
        string field_path = 1;
    }

    message SortByObjectTypeNotSupported {
        string field_path = 1;
    }

    message SortByArrayTypeNotSupported {
        string field_path = 1;
    }
}

message ErrorDetails {
    oneof details {
        BulkSizeExceedsMaximum bulk_size_exceeds_maximum = 1;
        NotFound not_found = 2;
        InsertFailed insert_failed = 3;
        InsertOrUpdateFailed insert_or_update_failed = 4;
        DeleteFailed delete_failed = 5;
        UpdateFailed update_failed = 6;
        AlreadyExists already_exists = 7;
        PersistenceConstraintViolation persistence_constraint_violation = 8;
        IllegalJson illegal_json = 9;
        PiiFieldsNotFilterable pii_fields_not_filterable = 10;
        PiiFieldsNotCountable pii_fields_not_countable = 11;
        PiiFieldsNotFilterableAndNotCountable pii_fields_not_filterable_and_not_countable = 12;
        IllegalCollectionName illegal_collection_name = 13;
        SystemFieldNotAllowed system_field_not_allowed = 14;
        RevisionViolation revision_violation = 15;
        ConstraintsViolation constraints_violation = 16;
        DataCorruption data_corruption = 17;
        AppNotInstalled app_not_installed = 18;
        UniqueConstraintViolation unique_constraint_violation = 19;
        MaxStringLengthViolation max_string_length_violation = 20;
        PersistenceConstraintViolations persistence_constraint_violations = 21;
        MaxStringLengthViolations max_string_length_violations = 22;
        AggregationDuplicateResultFields aggregation_duplicate_result_fields = 23;
        AggregationGroupAndAggregateSameField aggregation_froup_and_aggregate_same_field = 24;
        AggregationIllegalGroupFieldType aggregation_illegal_group_field_type = 25;
        AggregationIllegalAggregationFieldType aggregation_illegal_aggregation_field_type = 26;
        UniqueKeyNotFound unique_key_not_found = 27;
        InvalidUniqueKey invalid_unique_key = 29;
        MaxSizeViolations max_size_violations = 30;
        PageSizeExceedsMaximum page_size_exceeds_maximum = 31;
    }

    message BulkSizeExceedsMaximum {
        int32 size = 1;
        int32 max_batch_size = 2;
    }

    message NotFound {
        string entity_id = 1;
    }
    
    message UniqueKeyNotFound {
        google.protobuf.Struct filter = 1;
    }

    message InvalidUniqueKey {
        repeated string keys = 1;
    }

    message InsertFailed {
        string entity_id = 1;
    }

    message InsertOrUpdateFailed {
        string entity_id = 1;
    }

    message DeleteFailed {
        string entity_id = 1;
    }

    message UpdateFailed {
        string entity_id = 1;
    }

    message AlreadyExists {
        google.protobuf.StringValue entity_id = 1;
    }

    message PersistenceConstraintViolation {
        google.protobuf.StringValue entity_id = 1;
    }

    message PersistenceConstraintViolations {
        repeated google.protobuf.StringValue entity_ids = 1;
    }

    message IllegalJson {
        string json = 1;
    }

    message PiiFieldsNotFilterable {
        string operation = 1;
        repeated string field_paths = 2;
    }

    message PiiFieldsNotCountable {
        repeated string field_paths = 1;
    }

    message PiiFieldsNotFilterableAndNotCountable {
        repeated string non_filterable_fields = 1;
        repeated string non_supported_fields = 2;
    }

    message IllegalCollectionName {
        string collection_name = 1;
        string table_name = 2;
    }

    message SystemFieldNotAllowed {
        string original_path = 1;
    }

    message RevisionViolation {
        string entity_id = 1;
    }

    message ConstraintsViolation {
        string entity_id = 1;
    }

    message DataCorruption {
        string entity_id = 1;
    }

    message AppNotInstalled {
        string app_id = 1;
    }

    message UniqueConstraintViolation {
        message FieldPath {
            repeated string paths = 1;
        }
        repeated FieldPath field_paths = 1;
    }

    message MaxStringLengthViolation {
        message FieldPath {
            repeated string paths = 1;
        }
        repeated FieldPath field_paths = 1;
        string entity_id = 2;
    }
    message MaxStringLengthViolations {
        repeated MaxStringLengthViolation violations = 1;
    }

    message MaxSizeViolation {
        message FieldPath {
            repeated string paths = 1;
        }
        repeated FieldPath field_paths = 1;
        string entity_id = 2;
    }
    
    message MaxSizeViolations {
        repeated MaxSizeViolation violations = 1;
    }


    message AggregationDuplicateResultFields {
        string field = 1;
    }

    message AggregationGroupAndAggregateSameField {
        string field_path = 1;
    }

    message AggregationIllegalGroupFieldType {
        string field_path = 1;
        string field_type = 2;
    }

    message AggregationIllegalAggregationFieldType {
        string field_path = 1;
        string field_type = 2;
    }

    message PageSizeExceedsMaximum {
        int32 size = 1;
        int32 max_page_size = 2;
    }
}

