syntax = "proto3";

package wix.devcenter.apps.dependencies.v2.upstream.wix.common;

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

option java_multiple_files = true;
option java_package = "com.wixpress.devcenter.apps.dependencies.v2.upstream.wix.common";

message Paging {
    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];
}

message CursorPaging {
    option (.wix.api.decomposite_of) = "wix.common.CursorPaging";
    option (.wix.api.decomposition_minimum_fields) = {
        field: "limit"
        field: "cursor"
    };

    // Maximum number of items to return in the results.
    google.protobuf.Int32Value limit = 1 [(.wix.api.min) = 0, (.wix.api.max) = 100];

    /*
    Pointer to the next or previous page in the list of results.

    Pass the relevant cursor token from the `pagingMetadata` object in the previous call's response.
    Not relevant for the first request.
    */
    google.protobuf.StringValue cursor = 2 [(.wix.api.maxLength) = 16000];
}

message PagingMetadata {
    option (.wix.api.decomposite_of) = "wix.common.PagingMetadata";
    option (.wix.api.decomposition_minimum_fields) = {
        field: "count"
        field: "offset"
    };
    // Number of items returned in the response.
    google.protobuf.Int32Value count = 1;
    // Offset that was requested.
    google.protobuf.Int32Value offset = 2;
    // Total number of items that match the query.
    google.protobuf.Int32Value total = 3;
    // Flag that indicates the server failed to calculate the `total` field.
    google.protobuf.BoolValue too_many_to_count = 4;
    // Indicates if there are more results after the current page.
    // If `true`, another page of results can be retrieved.
    // If `false`, this is the last page.
    google.protobuf.BoolValue has_next = 5 [(.wix.api.field_exposure) = PRIVATE];
}

message PagingMetadataV2 {
    option (.wix.api.decomposite_of) = "wix.common.PagingMetadataV2";
    option (.wix.api.decomposition_minimum_fields) = {
        field: "count"
        field: "offset"
    };
    option (.wix.api.decomposition_minimum_fields) = {
        field: "count"
        field: "cursors"
    };
    // Number of items returned in the response.
    google.protobuf.Int32Value count = 1;
    // Offset that was requested.
    google.protobuf.Int32Value offset = 2;
    // Total number of items that match the query. Returned if offset paging is used and the `tooManyToCount` flag is not set.
    google.protobuf.Int32Value total = 3;
    // Flag that indicates the server failed to calculate the `total` field.
    google.protobuf.BoolValue too_many_to_count = 4;
    // Cursors to navigate through the result pages using `next` and `prev`. Returned if cursor paging is used.
    Cursors cursors = 5;
    // Indicates if there are more results after the current page.
    // If `true`, another page of results can be retrieved.
    // If `false`, this is the last page.
    google.protobuf.BoolValue has_next = 6 [(.wix.api.field_exposure) = PRIVATE];
}


// This is the preferred message for cursor-paging enabled services

message CursorPagingMetadata {
    option (.wix.api.decomposite_of) = "wix.common.CursorPagingMetadata";

    // Number of items returned in current page.
    google.protobuf.Int32Value count = 1;

    // Cursor strings that point to the next page, previous page, or both.
    Cursors cursors = 2;

    /*
    Whether there are more pages to retrieve following the current page.

    + `true`: Another page of results can be retrieved.
    + `false`: This is the last page.
    */
    google.protobuf.BoolValue has_next = 3;
}

message Cursors {
    option (.wix.api.decomposite_of) = "wix.common.Cursors";
    option (.wix.api.decomposition_minimum_fields) = {
        field: "next"
    };

    // Cursor string pointing to the next page in the list of results.
    google.protobuf.StringValue next = 1 [(.wix.api.maxLength) = 16000];

    // Cursor pointing to the previous page in the list of results.
    google.protobuf.StringValue prev = 2 [(.wix.api.maxLength) = 16000];
}
