syntax = "proto3";

package wix.devcenter.components.translation.v1.spi;

import "wix/spi/definitions.proto";
import "wix/api/validations.proto";
import "google/protobuf/wrappers.proto";
import "wix/api/api_errors.proto";
import "google/api/annotations.proto";
import "wix/devcenter/apps/components/v1/component.proto";
import "wix/devcenter/components/translation/v1/spi/component_additional_fields_translation_config.proto";
import "wix/coreservices/businessschema/v1/schema.proto";

service ComponentsAdditionalFieldsProvider {
  option (.wix.spi.service) = {
    spi_identifier: "com.wixpress.appservice.api.ComponentType.COMPONENTS_TRANSLATIONS_ADDITIONAL_FIELDS_PROVIDER",
    config_message: "wix.devcenter.components.translation.v1.spi.ComponentTranslationAdditionalFieldsConfig",
    host_service: "wix.devcenter.components.translation.v1.ComponentsTranslationService",
    fqdn: "wix.interfaces.components_translation.v1.translations_provider",
    app_id: "efd5ae1c-9e71-4ba8-9678-5306a0b61f0d"
  };

  // Gets the additional keys for the created component.
  rpc GetAdditionalKeys (GetAdditionalKeysRequest) returns (GetAdditionalKeysResponse) {
    option (.google.api.http).post = "/v1/get-additional-keys";
  };
}

message GetAdditionalKeysRequest {
  wix.devcenter.apps.components.v1.Component component = 1; // components that have been created or have been modified
}

message GetAdditionalKeysResponse {
  map<string, TranslationData> additional_keys = 1; // The additional keys for the component translation
}

message TranslationData {
  string english_value = 1 [(.wix.api.minLength) = 1]; // value of the field in the original component
  string display_name = 2 [(.wix.api.minLength) = 1]; // name to be displayed in DevCenter UI
  wix.coreservices.businessschema.v1.Translatable.Type text_type = 3; // translation text box type - Short or Long only
  google.protobuf.Int32Value text_max_size = 4 [(wix.api.min) = 1]; // translation max size
}
