syntax = "proto3";

package com.wixpress.appservice.api;

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

// A component that enables extending Wix Dashboard Functionality, as defined by ExtendingComponentType.
// Currently this supports extending menus and extending widget slots (for Wix apps that expose such menus and slots)
message BackOfficeExtension {
  // ID of the slot that hosts the extension.
  string extends = 1 [(wix.api.format) = GUID];
  // Extension title. This is how the extension is referred to in the Wix Dev Center.
  string title = 2 [(wix.api.translatable) = {
    type: SHORT_TEXT
    grouping: "title"
  }];
  // Extension description. This is how the extension is described in the Wix Dev Center.
  google.protobuf.StringValue description = 3;
  // Type of extension.
  com.wixpress.appservice.api.Extendable.ExtendingComponentType extension_type = 4;
  // Information relevant to the extension, depending on the type.
  oneof extension {
    // Information about a widget extension.
    LegacyBackOfficeExtensionWidget widget = 5;
    // Information about a menu item extension.
    LegacyBackOfficeMenuItem menu_item = 6;
  }
  // Platform that hosts the extension.
  //
  // Must be `"BUSINESS_MANAGER"`.
  BackOfficeHostingPlatforms hosting_platform = 7;
  // Required permission to view the extension.
  string required_permission = 8 [(wix.api.field_exposure) = INTERNAL];
  // Sentry error reporting DSN (internal)
  ErrorReporting error_reporting = 9 [(wix.api.field_exposure) = INTERNAL];
}

// flynt-disable field-type-breaking-change
// The schema of a widget extending a slot exposed in a page in the Wix Dashboard
message LegacyBackOfficeExtensionWidget {
  oneof asset {
    // Iframe URL that hosts the widget's content.
    string iframe_url = 1 [(wix.api.format) = WEB_URL];

    // Wix script asset to use in this widget
    BackOfficeScriptAsset script_asset = 2 [(wix.api.field_exposure) = INTERNAL];
  }

  // Initial width of the widget while loading, in pixels.
  // Width may be adjusted dynamically based on the content of the widget or limited by the size of the widget's container.
  google.protobuf.Int32Value width = 3 [(wix.api.min) = 0, (wix.api.max) = 9999];

  // Initial height of the widget while loading, in pixels.
  // Height may be adjusted dynamically based on the content of the widget or limited by the size of the widget's container.
  google.protobuf.Int32Value height = 4 [(wix.api.min) = 0, (wix.api.max) = 9999];
}

// flynt-disable field-type-breaking-change
// The schema of a menu extension of a slot exposed in a page in the Wix Dashboard
message LegacyBackOfficeMenuItem {
  // [Wix Design System icon key](https://www.wix-pages.com/wix-design-system-employees/?path=/story/foundations-icons--icons).
  // Use the full-size key. The icon will be rendered in an appropriate size.
  google.protobuf.StringValue icon_key = 1 [(wix.api.minLength) = 3, (wix.api.maxLength) = 50];
  // Action that takes places when the menu item is clicked.
  Action action = 4;
  // Menu item subtitle.
  google.protobuf.StringValue subtitle = 5 [(wix.api.translatable) = {
    type: SHORT_TEXT
    grouping: "subtitle"
  }, (wix.api.maxLength) = 200];

  // The schema of an action that is onvoked from menu extensions
  message Action {
    // Component that opens when the menu item is clicked.
    OpenComponent open_component = 1;

    // the schema of the data needed to open a component from menu extensions
    message OpenComponent {
      // ID of the component to open.
      string component_id = 1 [(wix.api.format) = GUID];
      // flynt-disable field-type-breaking-change
      // How the component is opened.
      ViewMode view_mode = 2;
      // Parameters to navigate to a page or as props for a modal. 
      map<string, string> component_params = 3;

      // View modes for how to open a component.
      enum ViewMode {
        // Opens a page in place of the current page.
        PAGE = 0;
        // Opens as a modal on the current page.
        MODAL = 1;
      }
    }
  }

  reserved 2, 3;
  reserved "icon_url", "label";
}
