syntax = "proto3";

package com.wix.ecommerce.commons.api;

import "google/protobuf/struct.proto";
import "wix/common/paging.proto";
import "wix/common/sorting.proto";
import "wix/api/annotations.proto";
import "google/protobuf/wrappers.proto";
import "wix/api/validations.proto";

option java_multiple_files = true;
option java_outer_classname = "QueryProto";
option java_package = "com.wix.ecommerce.commons.api";

//Don't use it unless you have to and know what you do. Prefer PlatformQuery other than this.
//It doesn't have max validation for limit but we still MUST have it so implement required validation in your code.
message UnlimitedPlatformQuery {
    option (.wix.api.decomposite_of) = "wix.common.QueryV2";
    option (.wix.api.decomposition_minimum_fields) = {
        field: "filter"
        field: "sort"
        field: "paging"
    };
    option (.wix.api.decomposition_minimum_fields) = {
        field: "filter"
        field: "sort"
        field: "cursorPaging"
    };
    // Filter object.
    google.protobuf.Struct filter = 1;
    // Sorting options. For example, `[{"fieldName":"sortField1"},{"fieldName":"sortField2","direction":"DESC"}]`.
    repeated .wix.common.Sorting sort = 2;
    oneof pagingMethod {
        // Pointer to page of results using offset. Cannot be used together with `cursorPaging`.
        UnlimitedPlatformPaging paging = 3;
        // Cursor pointing to page of results. Cannot be used together with `paging`. `cursorPaging.cursor` can not be used together with `filter` or `sort`.
        UnlimitedPlatformCursorPaging cursorPaging = 6;
     }
}

//Don't use it unless you have to and know what you do. Prefer PlatformPaging or wix.common.Paging other than this.
//It doesn't have max validation for limit but we still MUST have it so implement required validation in your code.
message UnlimitedPlatformPaging {
    option (.wix.api.decomposite_of) = "wix.common.Paging";
    option (.wix.api.decomposition_minimum_fields) = {
        field: "limit"
        field: "offset"
    };
    // Number of items to load.
    google.protobuf.Int32Value limit = 1 [(.wix.api.min) = 0];
    // Number of items to skip in the current sort order.
    google.protobuf.Int32Value offset = 2 [(.wix.api.min) = 0];
}

//Don't use it unless you have to and know what you do. Prefer PlatformCursorPaging or wix.common.CursorPaging other than this.
//It doesn't have max validation for limit but we still MUST have it so implement required validation in your code.
message UnlimitedPlatformCursorPaging {
    option (.wix.api.decomposite_of) = "wix.common.CursorPaging";
    option (.wix.api.decomposition_minimum_fields) = {
        field: "limit"
        field: "cursor"
    };
    // The number of items to load.
    // Cursor token returned in the query response. To be used on the next query request, but not the first query request.
    google.protobuf.Int32Value limit = 1 [(.wix.api.min) = 0];
    // Cursor returned in last query response. Should not be provided on first page request
    google.protobuf.StringValue cursor = 2;
}