syntax = "proto3";

package com.wix.components.overrides.upstream.wix.common;

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

option java_multiple_files = true;
option java_outer_classname = "QueryProto";
option java_package = "com.wix.components.overrides.upstream.wix.common";

message QueryV2 {
    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: "cursor_paging"
    };
    //Filter object in the following format:
    //`"filter" : {
    //              "fieldName1": "value1",
    //              "fieldName2":{"$operator":"value2"}
    //  }`
    //Example of operators: `$eq`, `$ne`, `$lt`, `$lte`, `$gt`, `$gte`, `$in`, `$hasSome`, `$hasAll`, `$startsWith`, `$contains`
    google.protobuf.Struct filter = 1;
    //Sort object in the following format:
    //`[{"fieldName":"sortField1","order":"ASC"},{"fieldName":"sortField2","order":"DESC"}]`
    repeated Sorting sort = 2 [(.wix.api.maxSize) = 20];
    //Array of projected fields. A list of specific field names to return. If `fieldsets` are also specified, the union of `fieldsets` and `fields` is returned.
    repeated string fields = 4 [(.wix.api.maxSize) = 20, (.wix.api.maxLength) = 30];
    //Array of named, predefined sets of projected fields. A array of predefined named sets of fields to be returned. Specifying multiple `fieldsets` will return the union of fields from all sets. If `fields` are also specified, the union of `fieldsets` and `fields` is returned.
    repeated string fieldsets = 5 [(.wix.api.maxSize) = 20, (.wix.api.maxLength) = 30];
    oneof pagingMethod {
        //Paging options to limit and skip the number of items.
        Paging paging = 3;
        //Cursor token pointing to a page of results. Not used in the first request. Following requests use the cursor token and not `filter` or `sort`.
        CursorPaging cursor_paging = 6;
    }
}
