syntax = "proto3";
package com.wixpress.appservice.api.upstream.wix.multilingual.translation.schema.v1;
option java_package = "com.wixpress.appservice.api.upstream.wix.multilingual.translation.schema.v1";

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

message Schema {
    option (.wix.api.decomposite_of) = "wix.multilingual.translation.schema.v1.Schema";
  google.protobuf.StringValue id = 1 [(.wix.api.readOnly) = true, (.wix.api.format) = GUID]; // Translation schema ID.
  SchemaKey key = 2; // Translation schema unique key identifier.
  map<string, SchemaField> fields = 3 [(.wix.api.minSize) = 1, (.wix.api.maxSize) = 1000]; // List of fields for the translation schema. This property uses a string to map to a `SchemaField` (`Map<string, SchemaField>`). The string serves as a key, which you'll need to access each field in the schema and when adding translation content.
  PreviewFields preview_fields = 4; // Fields displayed in content previews. For example, a product name for a product translation schema.
  /*
   Whether the translation schema is hidden from the site.

   Default: `false`
  */
  google.protobuf.BoolValue hidden = 5; 
  google.protobuf.StringValue display_name = 6 [(.wix.api.maxLength) = 100, (.wix.api.translatable) = {type: SHORT_TEXT, grouping: "General", name: "Schema name"}]; // Translation schema name displayed in the [Translation Manager](https://support.wix.com/en/article/wix-multilingual-using-the-translation-manager).
  google.protobuf.StringValue parent_id = 7 [(.wix.api.referenced_entity) = "wix.multilingual.translation.v1.schema", (.wix.api.format) = GUID]; // A reference to the parent schema. For example, if the schema is for a menu item, this property would contain the schema ID of the menu it belongs to.
  google.protobuf.Int64Value revision = 9 [(.wix.api.readOnly) = true]; // Revision number, which increments by 1 each time the schema is updated. To prevent conflicting changes, the existing `revision` must be used when updating a schema.
  google.protobuf.Timestamp created_date = 10 [(.wix.api.readOnly) = true]; // Date and time the translation schema was created.
  google.protobuf.Timestamp updated_date = 11 [(.wix.api.readOnly) = true]; // Date and time the translation schema was updated.
  /*
   Whether to duplicate the translated content when a site containing the translation schema and content is duplicated.

   Default: `false`
  */
  google.protobuf.BoolValue duplicate_content = 12;

  // Indicate if this schema should be grouped under a custom group in the Translation Manager
  // For more info about this field check dev-center extension `Multilingual Schema Group`
  google.protobuf.StringValue schema_group_id = 13 [
    (.wix.api.format) = GUID,
    (.wix.api.referenced_entity) = "wix.translation.schema_group.v1.schema_group",
    (.wix.api.field_exposure) = INTERNAL
  ];
}

message SchemaKey {
  option (.wix.api.decomposite_of) = "wix.multilingual.translation.schema.v1.SchemaKey";
  string app_id = 1 [(.wix.api.format) = GUID, (.wix.api.readOnly) = true]; // ID of the app that created the schema.
  string entity_type = 2 [(.wix.api.minLength) = 1, (.wix.api.maxLength) = 80, (.wix.api.immutable) = true]; // A unique name defined by the app developer to differentiate translation schemas for various entities within their app. For example, if an app developer is creating a translation schema for blog posts, the `entityType` can be `'blog-posts'`.
  /* Scope of the translation schema. 
  Supported values:
    + `GLOBAL`: A global schema for all sites.
    + `SITE`: A custom schema for a specific site. 
  */
  SchemaScope scope = 3 [(.wix.api.immutable) = true]; 
}

message SchemaField {
    option (.wix.api.decomposite_of) = "wix.multilingual.translation.schema.v1.SchemaField";
  /* Field ID. Validated according to Regex `^[A-Za-z0-9-_)(]+$`. Field IDs may contain parentheses to reference repeated items, such as images. These parentheses can't be nested and each opening parenthesis must be followed by a closing one. For example, `title()()` is valid, while `title)(` and `title(())` aren't valid. The value inside the parenthesis is validated according to Regex `^[^)(\\]\\[\\.]+$`.
  */
  string id = 1 [(.wix.api.minLength) = 1, (.wix.api.maxLength) = 1000, (.wix.api.custom_validation) = {rule_name: "validate with regax `a-zA-Z0-9_-)(`"}, (.wix.api.readOnly) = true]; 
  /* 
   * **Required.** Field type.
   */
  FieldType type = 2; 
  google.protobuf.StringValue display_name = 3 [(.wix.api.maxLength) = 1000, (.wix.api.translatable) = {type: SHORT_TEXT, grouping: "Fields", name: "Field name"}]; // Field name displayed in the [Translation Manager](https://support.wix.com/en/article/wix-multilingual-using-the-translation-manager).
  google.protobuf.StringValue group_name = 4 [(.wix.api.maxLength) = 1000, (.wix.api.translatable) = {type: SHORT_TEXT, grouping: "Fields", name: "Field group name"}]; // Field group name.
  google.protobuf.Int32Value min_length = 5 [(.wix.api.min) = 1]; // Field minimum text length.
  google.protobuf.Int32Value max_length = 6 [(.wix.api.min) = 1]; // Field maximum text length.
  google.protobuf.StringValue format = 7 [(.wix.api.minLength) = 2, (.wix.api.maxLength) = 20]; // Field format. Content is validated based on the format set here in the field schema. For example, if the format is `EMAIL`, then the content for this field must be a valid email address.
  bool hidden = 8; // Whether the field is hidden from the site. Hidden fields are still validated.
  bool display_only = 9; // Whether the field is read-only, and not intended to be translated. For example, an image. Use this field when you want an image to remain in the [Translation Manager](https://support.wix.com/en/article/wix-multilingual-using-the-translation-manager) for context, but without being translated.
  google.protobuf.DoubleValue index = 10 [(.wix.api.min) = 0]; // Field index. Use for cases where the order of the fields are relevant. 

  enum FieldType {
    UNDEFINED_TYPE = 0 [(.wix.api.enum_maturity) = NOT_IMPLEMENTED];  // Undefined field type
    SHORT_TEXT = 1;  // Short plain text displayed as a single line in the UI.
    LONG_TEXT = 2;  // Long plain text displayed as multiple lines in the UI.
    HTML = 3;  // Long text including styles, images, and links.
    RICH_CONTENT = 4;  // Rich-Content using the Wix Ricos format.
    IMAGE = 5;  // Wix Media Manager image.
    IMAGE_LINK = 6; // Image URL without metadata.
    JSON = 7 [(.wix.api.enum_exposure) = PRIVATE]; // Contains an XML representation of an entity or part of it.
    VIDEO = 8; // Wix Media Manager video.
    DOCUMENT = 9; // Wix Media Manager document.
  }
}

enum SchemaScope {
  UNKNOWN_SCOPE = 0 [(.wix.api.enum_maturity) = NOT_IMPLEMENTED];
  GLOBAL = 1; // Global schema for all sites.
  SITE = 2; // Custom schema for a specific site.
}

message PreviewFields {
    option (.wix.api.decomposite_of) = "wix.multilingual.translation.schema.v1.PreviewFields";
  google.protobuf.StringValue title_field_id = 1 [(.wix.api.maxLength) = 1000]; // ID of the field representing the schema's title.
  google.protobuf.StringValue image_field_id = 2 [(.wix.api.maxLength) = 1000]; // ID of the field representing the schema's image.
}
