// flynt-disable missing-string-validations

syntax = "proto3";

package wix.wix_rich_content.v1;

import "google/protobuf/struct.proto";
import "google/api/annotations.proto";
import "google/protobuf/wrappers.proto";
import "wix/rich_content/v1/rich_content.proto";
import "wix/api/entity.proto";
import "wix/api/validations.proto";
import "wix/api/permissions.proto";

service RichContentService {
  option (wix.api.service_entity) = {
    message: ".wix.rich_content.v1.RichContent"
    namespace: "RichContentService"
  };
  rpc GetContent (GetContentRequest) returns (GetContentResponse) {
    option (google.api.http).post = "/get-content";

    option (wix.api.permission) = {
      name: "WIX_RICOS.CONTENT_GET"
      type: MANUAL
    };
  }

  rpc ConvertContents (ConvertContentsRequest) returns (ConvertContentsResponse) {
    option (google.api.http).post = "/convert-contents";

    option (wix.api.permission) = {
      name: "WIX_RICOS.CONTENT_CONVERT"
      type: MANUAL
    };
  }

  rpc ValidateContent (ValidateContentRequest) returns (ValidateContentResponse) {
    option (google.api.http).post = "/validate-content";

    option (wix.api.permission) = {
      name: "WIX_RICOS.CONTENT_VALIDATE"
      type: MANUAL
    };
  }

  rpc GetContentFeatures(GetContentFeaturesRequest) returns (GetContentFeaturesResponse) {
    option (google.api.http).post = "/get-content-features";

    option (wix.api.permission) = {
      name: "WIX_RICOS.CONTENT_READ_FEATURES"
      type: MANUAL
    };
  }
}

enum ContentTypes {
  RICH_CONTENT = 0;
  DRAFT_CONTENT = 1;
  PLAIN_TEXT = 2;
  HTML = 3;
  MEDIA = 4;
  RICH_CONTENT_STRING = 5;
  HASHTAGS = 6;
  DRAFT_CONTENT_STRING = 7;
}

message PlainTextOptions {
  // Removes links from text
  google.protobuf.BoolValue remove_links = 1;
  // Removes image link from text
  google.protobuf.BoolValue remove_image_links = 2;
}

message HtmlOptions {
  google.protobuf.BoolValue enable_advanced_conversion = 1;
}

message ContentTemplate {
  string title = 1;
  string description = 2;
}

message ContentBlueprint {
  oneof source {
    google.protobuf.Struct draft_content = 1;
    wix.rich_content.v1.RichContent rich_content = 2;
    string html = 3;
    string markdown = 4;
    string plain_text = 5;
    string rich_content_string = 6;
    string draft_content_string = 7;
  }
}

message GetContentRequest {
  ContentBlueprint blueprint = 1;
  ContentTypes target = 2;
  oneof options {
    option (.wix.api.aligned_with_enum) = {
      field: "target"
    };
    PlainTextOptions plain_text_options = 10;
    HtmlOptions html_options = 11;
  }
}

message Media {
  repeated google.protobuf.Struct items = 1;
}

message Hashtags {
  repeated string hashtags = 1 [(.wix.api.maxSize) = 100, (wix.api.maxLength) = 100];
}

message GetContentResponse {

  enum Status {
    INVALID = 0;
    VALID = 1;
  }

  Status status = 1;
  string error = 2;
  oneof content {
    google.protobuf.Struct draft_content = 3;
    wix.rich_content.v1.RichContent rich_content = 4;
    string plain_text = 5;
    string html = 6;
    string markdown = 7;
    Media media = 8;
    string rich_content_string = 9;
    Hashtags hashtags = 10;
    string draft_content_string = 11;
  }
}

message ValidateContentRequest {
  google.protobuf.Struct content = 1;
}

message ValidateContentResponse {
  enum Status {
    INVALID = 0;
    VALID = 1;
  }

  Status status = 1;
  wix.rich_content.v1.RichContent content = 2;
  google.protobuf.StringValue error = 3;
}

message ConvertContentsRequest {
  repeated GetContentRequest contents = 1;
}

message ConvertContentsResponse {
  repeated GetContentResponse converted_contents = 1;
}

message GetContentFeaturesRequest {
  ContentBlueprint blueprint = 1;
}

message GetContentFeaturesResponse {
  enum Status {
    INVALID = 0;
    VALID = 1;
  }

  Status status = 1;
  google.protobuf.StringValue error = 2 [(wix.api.maxLength) = 500];

  ContentFeatures features = 3;
}

message ContentFeatures {
  bool image = 1;
  bool video = 2;
  bool file = 3;
  bool link = 4;
  bool email = 5;
  bool phone_number = 6;
  bool instant_messaging_address = 7;
}
