syntax = "proto3";

package wix.inventory.api.v1;

import "google/protobuf/timestamp.proto";
import "google/protobuf/wrappers.proto";
import "wix/api/annotations.proto";
import "wix/api/entity.proto";
import "wix/api/validations.proto";
import "wix/inventory/api/v1/preOrderInfo.proto";

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

/**
 * An inventory item is the record of inventory for a product and its variants at a given location
 */
message LocationInventoryItem {
  option (.wix.api.entity) = {
    fqdn: "wix.stores.v1.location_inventory"
    segment: USERS
  };

  /**
   * The ID of the inventory record for a given product.
   * The value matches the ID of the product itself.
   */
  .google.protobuf.StringValue id = 1 [(.wix.api.readOnly) = true, (.wix.api.maxLength) = 36];

  // The ID of the product that this inventory item is against
  string product_id = 2 [
    (.wix.api.immutable) = true,
    (.wix.api.minLength) = 1,
    (.wix.api.maxLength) = 36,
    (.wix.api.referenced_entity) = "wix.stores.catalog.v1.product"
  ];

  // Variants associated with this inventory item.
  repeated LocationInventoryVariant variants = 3 [(.wix.api.maxSize) = 1000000];

  // The timestamp of when this record was last updated
  .google.protobuf.Timestamp updated_date = 4 [(.wix.api.readOnly) = true];

  // Inventory’s unique numeric ID (assigned in ascending order).
  // Primarily for sorting and filtering when crawling all inventories.
  //flynt-disable unsigned-integers-not-allowed
  uint64 numeric_id = 5 [(.wix.api.readOnly) = true];

  // Preorder information. Not supported for location-inventory
  reserved 6;
}

message LocationInventoryVariant {
  // The ID of the related product-variant.
  string variant_id = 1 [(.wix.api.format) = GUID, (.wix.api.immutable) = true];

  // The location that this variant-inventory is for.
  string location_id = 2 [
    (.wix.api.format) = GUID,
    (.wix.api.immutable) = true,
    (.wix.api.referenced_entity) = "wix.stores.catalog.v3.stores_location"
  ];

  // Whether the product is listed as in stock.
  bool in_stock = 3;

  // Quantity currently left in inventory.
  .google.protobuf.Int32Value quantity = 4;

  // Whether quantity is being tracked.
  bool track_quantity = 5;

  // Preorder information. Not supported for location-inventory
  reserved 6;
}
