syntax = "proto3";

package com.wixpress.appservice.api.upstream.src.main.proto.com.wixpress.items_selection.spi.v1;

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

message ItemsSelectionProviderConfig {
    option (.wix.api.decomposite_of) = "com.wixpress.items_selection.spi.v1.ItemsSelectionProviderConfig";
  // Base URI which Wix calls to retrieve the selected items. For example, `"deploymentUri": "https://my-items.com"`.
  string deployment_uri = 1 [(.wix.spi.base_uri) = true, (wix.api.minLength) = 1];

  // A unique identifier for the provider.
  string key = 2 [(wix.api.minLength) = 3, (wix.api.maxLength) = 250];

  // Supported search parameters.
  SearchParams search_params = 3;

  // Display data such as provider name and icon.
  ContentData content_data = 4;

  // Optional additional step taken after the initial item selection.
  AdditionalStepInfo additional_step_info = 5 [(.wix.api.field_exposure) = INTERNAL];

  // An array of strings representing the Wix UI pages supported by your SPI implementation. If no tags are listed, Wix assumes that the implementation supports all eligible pages.
  repeated Tag supported_tags = 6 [(wix.api.maxSize) = 50];

  // Optional create new item option, to define a widget that will be opened to create a new item
  CreateNewItemInfo create_new_item_info = 7 [(.wix.api.field_exposure) = INTERNAL];

  // Configuration settings for how the thumbnail is displayed.
  ItemThumbnail item_thumbnail = 8;

  reserved 9; // exposure_and_maturity on dev-center side

  // Pagination Mode
  PaginationMode pagination_mode = 10;

  // Additional fields associated with the provider
  repeated TagOverridesEntry tags_overrides = 11 [(.wix.api.maxSize) = 100, (.wix.api.field_exposure) = INTERNAL];

  // Optional render overrides for the provider.
  RenderOverrides render_overrides = 12;

  //flynt-disable deleted-field-enum-reserved
  enum Tag {
    UNKNOWN_TAG = 0;
    EMBEDDABLE = 1;
    ECOM_EDIT_ORDER = 2;
    ECOM_CREATE_ORDER = 3;
    INBOX = 4;
    ECOM_CREATE_PAY_LINK = 5;
    ECOM_DELIVERY_PROFILES = 6;
    ADD_TO_CATEGORY = 7;
    MY_BUSINESS = 8;
    PIPELINE_LINKED_ENTITY = 9;
    GET_PAID = 10;
    PIPELINE_CARD_CATALOG_ITEM = 11;
  }

  enum PaginationMode {
    UNKNOWN_PAGINATION_MODE = 0;
    CURSOR = 1;
    OFFSET = 2;
  }

  message AdditionalStepInfo {
    option (.wix.api.decomposite_of) = "com.wixpress.items_selection.spi.v1.AdditionalStepInfo";
    // ID of the widget associated with the step.
    string widget_id = 1;
    // one app (mobile) component id that will be opened to show additional step
    google.protobuf.StringValue mobile_component_id = 5 [(.wix.api.field_exposure) = INTERNAL, (wix.api.minLength) = 1, (wix.api.maxLength) = 50];

    // Title of the additional step.
    string title = 2 [(wix.api.minLength) = 1, (wix.api.maxLength) = 100, (wix.api.translatable) = {
      type: SHORT_TEXT
      name: "Additional Step Title"
      grouping: "metadata"
    }];

    // Subtitle of the additional step.
    google.protobuf.StringValue subtitle = 3 [(wix.api.maxLength) = 100, (wix.api.translatable) = {
      type: SHORT_TEXT
      name: "Additional Step Subtitle"
      grouping: "metadata"
    }];

    // Hide item note if exists when showing selected item on additional step header, default: false.
    google.protobuf.BoolValue hide_item_note = 4;
  }

  message CreateNewItemInfo {
    option (.wix.api.decomposite_of) = "com.wixpress.items_selection.spi.v1.CreateNewItemInfo";
    // ID of the widget associated with the new item modal.
    string widget_id = 1;
    // one app (mobile) component id that will be opened to create a new item
    google.protobuf.StringValue mobile_component_id = 2 [(.wix.api.field_exposure) = INTERNAL, (wix.api.minLength) = 1, (wix.api.maxLength) = 50];
    // Button label for creating a new item
    google.protobuf.StringValue button_text = 3 [(wix.api.minLength) = 1, (wix.api.maxLength) = 50, (wix.api.translatable) = {
      type: SHORT_TEXT
      name: "Create New Item Button"
      grouping: "metadata"
    }];
  }

  message ContentData {
    option (.wix.api.decomposite_of) = "com.wixpress.items_selection.spi.v1.ContentData";
    // Provider icon. Choose an icon name from the [Wix Design System](https://www.wixdesignsystem.com/).
    google.protobuf.StringValue icon_key = 1 [(wix.api.minLength) = 3, (wix.api.maxLength) = 50];

    // Provider name.
    string provider_name = 2 [(wix.api.minLength) = 1, (wix.api.maxLength) = 100, (wix.api.translatable) = {
      type: SHORT_TEXT
      name: "Provider Name"
      grouping: "metadata"
    }];

    // Item title.
    string title = 3 [(wix.api.minLength) = 1, (wix.api.maxLength) = 100, (wix.api.translatable) = {
      type: SHORT_TEXT
      name: "Picker Title"
      grouping: "metadata"
    }];

    // Button label.
    string button = 4 [(wix.api.minLength) = 1, (wix.api.maxLength) = 50, (wix.api.translatable) = {
      type: SHORT_TEXT
      name: "Select Button"
      grouping: "metadata"
    }];

    // Item description.
    google.protobuf.StringValue subtitle = 5 [(wix.api.minLength) = 1, (wix.api.maxLength) = 100, (wix.api.translatable) = {
      type: SHORT_TEXT
      name: "Picker Subtitle"
      grouping: "metadata"
    }];

    // Learn more link.
    LearnMore learn_more = 6;
  }

  message ContentDataOverrides {
    option (.wix.api.decomposite_of) = "com.wixpress.items_selection.spi.v1.ContentDataOverrides";
    // Provider name.
    google.protobuf.StringValue provider_name = 1 [(wix.api.minLength) = 1, (wix.api.maxLength) = 100, (wix.api.translatable) = {
      type: SHORT_TEXT
      name: "Provider Name"
      grouping: "metadata"
    }];
  }

  message ItemThumbnail {
    option (.wix.api.decomposite_of) = "com.wixpress.items_selection.spi.v1.ItemThumbnail";
    // Thumbnail type
    ThumbnailType type = 1;

    // Whether the thumbnail is hidden from the UI.
    google.protobuf.BoolValue hidden = 2;

    oneof options {
      option (.wix.api.aligned_with_enum) = {
        field: "type";
        suffix: "config";
      };
      // Configuration specific to images.
      ImageConfig image_config = 3;

      // Configuration specific to avatars.
      AvatarConfig avatar_config = 4;
    }
  }

  enum ThumbnailType {
    UNKNOWN_THUMBNAIL_TYPE = 0;
    IMAGE = 1;
    AVATAR = 2;
  }

  message ImageConfig {
    option (.wix.api.decomposite_of) = "com.wixpress.items_selection.spi.v1.ImageConfig";
    ImageShape shape = 1;

    enum ImageShape {
      UNKNOWN_SHAPE = 0;
      // Circle
      CIRCLE = 1;
      // Square
      SQUARE = 2;
      // Rectangle
      RECTANGLE = 3;
    }
  }

  message AvatarConfig {
    option (.wix.api.decomposite_of) = "com.wixpress.items_selection.spi.v1.AvatarConfig";
    AvatarShape shape = 1;

    enum AvatarShape {
      UNKNOWN_SHAPE = 0;
      // Circle
      CIRCLE = 1;
      // Square
      SQUARE = 2;
    }
  }

  message SearchParams {
    option (.wix.api.decomposite_of) = "com.wixpress.items_selection.spi.v1.SearchParams";
    // Supported search parameters.
    repeated SearchField fields = 1 [(.wix.api.maxSize) = 50];

    reserved 2;

    // Filters for viewing only part of the items. Maximum one filter per tag.
    repeated FilterInfo filters = 3 [(.wix.api.maxSize) = 100];
  }

  message SearchField {
    option (.wix.api.decomposite_of) = "com.wixpress.items_selection.spi.v1.SearchField";
    // Supported searchable fields.
    string key = 1;

    // Item description.
    string description = 2 [(wix.api.minLength) = 1, (wix.api.maxLength) = 100];
  }

  message FilterInfo {
    option (.wix.api.decomposite_of) = "com.wixpress.items_selection.spi.v1.FilterInfo";
    option (.wix.api.unique) = {field: "key"};
    // Key of the filter
    string key = 1 [(wix.api.minLength) = 1, (wix.api.maxLength) = 100];

    // Optional filter will be shown only for consumers with this tag. Only one filter is allowed per tag.
    Tag tag = 2;

    // The filter selection type.
    FilterSelectionType selection_type = 3;

     // Filter options type. For now only static options are supported
     FilterOptionsType options_type = 4;
     oneof options {
       option (.wix.api.aligned_with_enum).field = "options_type";
       // Static hardcoded options
       StaticFilterOptions static_options = 5;
       // The filter options are items of another provider
       ProviderFilterOptions provider_options = 6;
     }
     
    // Optional placeholder text to display on the filter 
    google.protobuf.StringValue placeholder = 7 [(wix.api.maxLength) = 500, (wix.api.translatable) = {
      type: SHORT_TEXT
      name: "Filter Placeholder"
      grouping: "metadata"
    }];
  }

  message ProviderFilterOptions {
    option (.wix.api.decomposite_of) = "com.wixpress.items_selection.spi.v1.ProviderFilterOptions";
    // Provider identifier for fetching filter options
    string key = 1 [(wix.api.minLength) = 3, (wix.api.maxLength) = 250];
  }

  message StaticFilterOptions {
    option (.wix.api.decomposite_of) = "com.wixpress.items_selection.spi.v1.StaticFilterOptions";
    // List of hardcoded options for a filter
    repeated StaticFilterOption data = 1 [(.wix.api.maxSize) = 50];
  }

  message StaticFilterOption {
    option (.wix.api.decomposite_of) = "com.wixpress.items_selection.spi.v1.StaticFilterOption";
    option (.wix.api.unique) = {field: "value"};
    // Title of a filter option
    string label = 1 [(wix.api.minLength) = 1, (wix.api.maxLength) = 500, (wix.api.translatable) = {
      type: SHORT_TEXT
      name: "Filter Option Label"
      grouping: "metadata"
    }];
    // Value of a filter option
    string value = 2 [(wix.api.minLength) = 1, (.wix.api.maxLength) = 100];
  }

  message LearnMore {
    option (.wix.api.decomposite_of) = "com.wixpress.items_selection.spi.v1.LearnMore";
    // The url of the learn more link. If you want a dynamic url according to the user locale, you can add {{locale}} variable within the string.
    string url = 1 [(.wix.api.maxLength) = 2048];
    // Optional link label.
    google.protobuf.StringValue label = 2 [(wix.api.maxLength) = 500, (wix.api.translatable) = {
      type: SHORT_TEXT
      name: "Learn More Label"
      grouping: "metadata"
    }];
  }

  enum FilterSelectionType {
    UNKNOWN_SELECTION = 0;
    // Allow to select only a single item
    SINGLE_SELECTION = 1;
     // Allow to select multiple items
    MULTIPLE_SELECTION = 2;
  }

  enum FilterOptionsType {
    UNKNOWN_FILTER_OPTIONS = 0;
    // Static hardcoded options
    STATIC = 1;
    PROVIDER = 2;
  }

  message TagOverrides {
    option (.wix.api.decomposite_of) = "com.wixpress.items_selection.spi.v1.TagOverrides";
    // Additional fields associated with the provider.
    google.protobuf.Struct additional_fields = 1;

    // Display data such as provider name.
    ContentDataOverrides content_data = 2;
  }

  message RenderOverrides {
    option (.wix.api.decomposite_of) = "com.wixpress.items_selection.spi.v1.RenderOverrides";
    // Whether to hide the search bar in the picker UI
    google.protobuf.BoolValue hide_search = 1;
  }

  message TagOverridesEntry {
    option (.wix.api.decomposite_of) = "com.wixpress.items_selection.spi.v1.TagOverridesEntry";
    // The tag associated with the overrides.
    Tag tag = 1;
    // The overrides for the tag.
    TagOverrides overrides = 2;
  }
}
