syntax = "proto3";

package wix.devcenter.apps.components.enricher.upstream.wix.common;

option java_multiple_files = true;
option java_package = "com.wix.devcenter.apps.components.enricher.upstream.wix.common";

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

message BulkActionMetadata {
    option (.wix.api.decomposite_of) = "wix.common.BulkActionMetadata";
    // Number of items that were successfully processed.
    int32 total_successes = 1;
    // Number of items that couldn't be processed.
    int32 total_failures = 2;
    // Number of failures without details because detailed failure threshold was exceeded.
    int32 undetailed_failures = 3;
}

message ItemMetadata {
    option (.wix.api.decomposite_of) = "wix.common.ItemMetadata";
    // component id
    google.protobuf.StringValue id = 1 [(.wix.api.format) = GUID];
    // Index of the item within the request array. Allows for correlation between request and response items.
    int32 original_index = 2;
    // Whether the requested action was successful for this item. When `false`, the `error` field is populated.
    bool success = 3;
    // Details about the error in case of failure.
    .wix.api.ApplicationError error = 4;
}

/*

Example for using it in your service:

message BulkOrderResult {
    option (.wix.api.decomposite_of) = "wix.common.BulkOrderResult";
    ItemMetadata item_metadata = 1;
    Order item = 2;
}

message BulkArchiveOrdersResponse {
    option (.wix.api.decomposite_of) = "wix.common.BulkArchiveOrdersResponse";
    repeated BulkOrderResult results = 1;
    BulkActionMetadata bulk_action_metadata = 2;
}

*/
