9bb0348fdd
- The front and back are rendered in one call now. If the front side contains no custom filters, we can bake {{FrontSide}} into the rear side. If it did contain custom filters, we return the partially complete rear template instead, and the calling code can inject the FrontSide in after it has been fully rendered. - Instead of modifying "cloze" into something like "cq-2", the card ordinal and whether we're rendering the question or answer are now passed in to the rendering filters as context. - The Rust code doesn't need to support filter names split on '-' anymore. - Drop the "Show" part of hint descriptions so i18n support can be deferred. - Ignore blank filter names caused by user using two colons instead of one. - Fixed hint field and text transposition.
155 lines
3.1 KiB
Protocol Buffer
155 lines
3.1 KiB
Protocol Buffer
syntax = "proto3";
|
|
|
|
package backend_proto;
|
|
|
|
message Empty {}
|
|
|
|
// 1-15 reserved for future use; 2047 for errors
|
|
|
|
message BackendInput {
|
|
reserved 2047;
|
|
oneof value {
|
|
TemplateRequirementsIn template_requirements = 16;
|
|
SchedTimingTodayIn sched_timing_today = 17;
|
|
Empty deck_tree = 18;
|
|
FindCardsIn find_cards = 19;
|
|
BrowserRowsIn browser_rows = 20;
|
|
RenderCardIn render_card = 21;
|
|
|
|
PlusOneIn plus_one = 2046; // temporary, for testing
|
|
}
|
|
}
|
|
|
|
message BackendOutput {
|
|
oneof value {
|
|
TemplateRequirementsOut template_requirements = 16;
|
|
SchedTimingTodayOut sched_timing_today = 17;
|
|
DeckTreeOut deck_tree = 18;
|
|
FindCardsOut find_cards = 19;
|
|
BrowserRowsOut browser_rows = 20;
|
|
RenderCardOut render_card = 21;
|
|
|
|
PlusOneOut plus_one = 2046; // temporary, for testing
|
|
|
|
BackendError error = 2047;
|
|
}
|
|
}
|
|
|
|
message BackendError {
|
|
oneof value {
|
|
InvalidInputError invalid_input = 1;
|
|
TemplateParseError template_parse = 2;
|
|
}
|
|
}
|
|
|
|
message InvalidInputError {
|
|
string info = 1;
|
|
}
|
|
|
|
message PlusOneIn {
|
|
int32 num = 1;
|
|
}
|
|
|
|
message PlusOneOut {
|
|
int32 num = 1;
|
|
}
|
|
|
|
message TemplateParseError {
|
|
string info = 1;
|
|
}
|
|
|
|
message TemplateRequirementsIn {
|
|
repeated string template_front = 1;
|
|
map<string, uint32> field_names_to_ordinals = 2;
|
|
}
|
|
|
|
message TemplateRequirementsOut {
|
|
repeated TemplateRequirement requirements = 1;
|
|
}
|
|
|
|
message TemplateRequirement {
|
|
oneof value {
|
|
TemplateRequirementAll all = 1;
|
|
TemplateRequirementAny any = 2;
|
|
Empty none = 3;
|
|
}
|
|
}
|
|
|
|
message TemplateRequirementAll {
|
|
repeated uint32 ords = 1;
|
|
}
|
|
|
|
message TemplateRequirementAny {
|
|
repeated uint32 ords = 1;
|
|
}
|
|
|
|
message SchedTimingTodayIn {
|
|
int64 created_secs = 1;
|
|
sint32 created_mins_west = 2;
|
|
int64 now_secs = 3;
|
|
sint32 now_mins_west = 4;
|
|
sint32 rollover_hour = 5;
|
|
}
|
|
|
|
message SchedTimingTodayOut {
|
|
uint32 days_elapsed = 1;
|
|
int64 next_day_at = 2;
|
|
}
|
|
|
|
message DeckTreeOut {
|
|
DeckTreeNode top = 1;
|
|
}
|
|
|
|
message DeckTreeNode {
|
|
// the components of a deck, split on ::
|
|
repeated string names = 1;
|
|
int64 deck_id = 2;
|
|
uint32 review_count = 3;
|
|
uint32 learn_count = 4;
|
|
uint32 new_count = 5;
|
|
repeated DeckTreeNode children = 6;
|
|
bool collapsed = 7;
|
|
}
|
|
|
|
message FindCardsIn {
|
|
string search = 1;
|
|
}
|
|
|
|
message FindCardsOut {
|
|
repeated int64 card_ids = 1;
|
|
}
|
|
|
|
message BrowserRowsIn {
|
|
repeated int64 card_ids = 1;
|
|
}
|
|
|
|
message BrowserRowsOut {
|
|
// just sort fields for proof of concept
|
|
repeated string sort_fields = 1;
|
|
}
|
|
|
|
message RenderCardIn {
|
|
string question_template = 1;
|
|
string answer_template = 2;
|
|
map<string,string> fields = 3;
|
|
int32 card_ordinal = 4;
|
|
}
|
|
|
|
message RenderCardOut {
|
|
repeated RenderedTemplateNode question_nodes = 1;
|
|
repeated RenderedTemplateNode answer_nodes = 2;
|
|
}
|
|
|
|
message RenderedTemplateNode {
|
|
oneof value {
|
|
string text = 1;
|
|
RenderedTemplateReplacement replacement = 2;
|
|
}
|
|
}
|
|
|
|
message RenderedTemplateReplacement {
|
|
string field_name = 1;
|
|
string current_text = 2;
|
|
repeated string filters = 3;
|
|
}
|