syntax = "proto3";

package wix.catalog.api.v1.event;

import "google/protobuf/struct.proto";
import "google/protobuf/wrappers.proto";
import "wix/catalog/api/v1/costAndProfit.proto";
import "wix/catalog/api/v1/media.proto";
import "wix/catalog/api/v1/pageUrl.proto";
import "wix/catalog/api/v1/price.proto";
import "wix/api/annotations.proto";
import "wix/stores/catalog/provision/v1/provision.proto";

option java_package = "com.wix.ecommerce.catalog.api.v1";

message ProductCreated {
    // Product ID (generated automatically by the catalog).
    string product_id = 1;
    // Product name.
    string name = 2;
    // Product price.
    PriceData price = 3;
    // Whether the product is visible to customers.
    bool visible = 4;
    // Media items (images, videos, etc.) associated with this product.
    Media media = 5;
    // Product stock keeping unit (SKU). If variants are being managed, this will be empty.
    string sku = 6;
    // Product page URL for this product (generated automatically by the server).
    PageUrl product_page_url = 7;
    // Product brand.
    google.protobuf.StringValue brand = 8;
    // Cost and profit data
    CostAndProfitData cost_and_profit_data = 9;
    // Information about the version of the catalog from where this event was triggered.
    wix.stores.catalog.provision.v1.Version originated_from_version = 10;
    // Event slug. A human readable identifier of the event.
    string slug = 11;
}

message PriceChanged {
    string product_id = 1;
    // Price before change.
    PriceDataV2 old_price = 3;
    // Price after change.
    PriceDataV2 new_price = 4;
    // Information about the version of the catalog from where this event was triggered.
    wix.stores.catalog.provision.v1.Version originated_from_version = 5;
}

message ProductChanged {
    // Product ID.
    string product_id = 1;
    // List of product fields that were changed.
    repeated string changed_fields = 2;
    // product revision
    int64 revision = 3 [(.wix.api.field_exposure) = INTERNAL];
    // Information about the version of the catalog from where this event was triggered.
    wix.stores.catalog.provision.v1.Version originated_from_version = 4;
}

message ProductDeleted {
    // ID of the product that was deleted.
    string product_id = 1;
    // Information about the version of the catalog from where this event was triggered.
    wix.stores.catalog.provision.v1.Version originated_from_version = 2;
}

message VariantsChanged {
    // Product ID.
    string product_id = 1;
    // List of variants that were changed. 
    repeated VariantChanged variants = 2;
    // Information about the version of the catalog from where this event was triggered.
    wix.stores.catalog.provision.v1.Version originated_from_version = 3;
}

message VariantChanged {
    // Variant ID.
    string variant_id = 1;
    map<string, string> choices = 2;
    // List of variant fields that were changed.
    repeated string changed_fields = 3;
    // Information about the version of the catalog from where this event was triggered.
    wix.stores.catalog.provision.v1.Version originated_from_version = 4;
}

message CollectionCreated {
    // Collection ID (generated automatically by the catalog).
    string collection_Id = 1;
    // Collection name.
    string name = 2;
    // Media items (images, videos, etc.) associated with this collection.
    Media media = 3;
    // Collection slug
    string slug = 4;
    // Collection visible status
    bool visible = 5;
    // Information about the version of the catalog from where this event was triggered.
    wix.stores.catalog.provision.v1.Version originated_from_version = 6;
}

message CollectionChanged {
    // Collection ID (generated automatically by the catalog).
    string collection_Id = 1;
    // List of collection fields that were changed.
    repeated string changed_fields = 2;
    // Information about the version of the catalog from where this event was triggered.
    wix.stores.catalog.provision.v1.Version originated_from_version = 3;
}

message CollectionDeleted {
    // ID of the collection that was deleted.
    string collection_Id = 1;
    // Information about the version of the catalog from where this event was triggered.
    wix.stores.catalog.provision.v1.Version originated_from_version = 2;
}

//internal
message CustomFieldChanged {
    string product_id = 1;
    string field_name = 2;
    google.protobuf.Value old_value = 3;
    google.protobuf.Value new_value = 4;
    // Information about the version of the catalog from where this event was triggered.
    wix.stores.catalog.provision.v1.Version originated_from_version = 5;
}