Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rendering.proto is Under-defined #122

Open
bugerry87 opened this issue Nov 6, 2024 · 0 comments
Open

Rendering.proto is Under-defined #122

bugerry87 opened this issue Nov 6, 2024 · 0 comments

Comments

@bugerry87
Copy link
Contributor

bugerry87 commented Nov 6, 2024

The rendering message type is very much under-defined.
It declares Any where a certain known structure is requested such as for templates i.e.:

{
  [template_name]: {
    "body": (Buffer | String),
    "layout": (Buffer | String),
  }
}

Instead there should be a dedicated repeated message to describe these templates such as:

message Template {
  optional string name = 1;
  optional uint32 ordinal = 2; // sort number - just in case if the list order can't be preserved, but should
  optional string body = 3; // or bytes -  then we should provide charset coding, however!
  optional string layout = 4; // or bytes - then we should provide charset coding, however!
  optional string style_url = 5; // Why is style (css) just a URL while the others payload data?
}

Furthermore, the response is no more than an Any with id while in case of an error the keyword error shares the same layer as the render results! Errors and render results should be separated, rather use Status and/or OperationStatus like all the other services.

packages/protos/io/restorecommerce/rendering.proto

message Payload {
  // json with <key, template> pairs
  // e.g. { 'subject': ..., 'message':....}
  optional google.protobuf.Any templates = 1;
  optional google.protobuf.Any data = 2;  // data to fill template with
  optional string style_url = 3; // stylesheet URL

  enum Strategy { // style-applying 'strategy'
    INLINE = 0;
    COPY = 1;
  }
  optional Strategy strategy = 4;  // inlining, copying CSS into <style>, etc...
  // rendering options JSON object
  optional google.protobuf.Any options = 5;
  // content type for rendering such as 'application/html' or 'application/text'
  optional string content_type = 6;
}

message RenderResponse {
  optional string id = 1;
  repeated google.protobuf.Any responses = 2;  // error or HTML contents
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant