mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
328 lines
7.7 KiB
Protocol Buffer
328 lines
7.7 KiB
Protocol Buffer
// Copyright: Ankitects Pty Ltd and contributors
|
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
syntax = "proto3";
|
|
|
|
package anki.backend;
|
|
|
|
import "anki/generic.proto";
|
|
import "anki/cards.proto";
|
|
import "anki/collection.proto";
|
|
import "anki/notes.proto";
|
|
import "anki/notetypes.proto";
|
|
|
|
// Backend methods
|
|
///////////////////////////////////////////////////////////
|
|
|
|
/// while the protobuf descriptors expose the order services are defined in,
|
|
/// that information is not available in prost, so we define an enum to make
|
|
/// sure all clients agree on the service index
|
|
enum ServiceIndex {
|
|
SERVICE_INDEX_SCHEDULER = 0;
|
|
SERVICE_INDEX_DECKS = 1;
|
|
SERVICE_INDEX_NOTES = 2;
|
|
SERVICE_INDEX_SYNC = 3;
|
|
SERVICE_INDEX_NOTETYPES = 4;
|
|
SERVICE_INDEX_CONFIGS = 5;
|
|
SERVICE_INDEX_CARD_RENDERING = 6;
|
|
SERVICE_INDEX_DECK_CONFIG = 7;
|
|
SERVICE_INDEX_TAGS = 8;
|
|
SERVICE_INDEX_SEARCH = 9;
|
|
SERVICE_INDEX_STATS = 10;
|
|
SERVICE_INDEX_MEDIA = 11;
|
|
SERVICE_INDEX_I18N = 12;
|
|
SERVICE_INDEX_COLLECTION = 13;
|
|
SERVICE_INDEX_CARDS = 14;
|
|
}
|
|
|
|
service CardRenderingService {
|
|
rpc ExtractAVTags(ExtractAVTagsRequest) returns (ExtractAVTagsResponse);
|
|
rpc ExtractLatex(ExtractLatexRequest) returns (ExtractLatexResponse);
|
|
rpc GetEmptyCards(generic.Empty) returns (EmptyCardsReport);
|
|
rpc RenderExistingCard(RenderExistingCardRequest)
|
|
returns (RenderCardResponse);
|
|
rpc RenderUncommittedCard(RenderUncommittedCardRequest)
|
|
returns (RenderCardResponse);
|
|
rpc RenderUncommittedCardLegacy(RenderUncommittedCardLegacyRequest)
|
|
returns (RenderCardResponse);
|
|
rpc StripAVTags(generic.String) returns (generic.String);
|
|
rpc RenderMarkdown(RenderMarkdownRequest) returns (generic.String);
|
|
}
|
|
|
|
service TagsService {
|
|
rpc ClearUnusedTags(generic.Empty) returns (collection.OpChangesWithCount);
|
|
rpc AllTags(generic.Empty) returns (generic.StringList);
|
|
rpc RemoveTags(generic.String) returns (collection.OpChangesWithCount);
|
|
rpc SetTagCollapsed(SetTagCollapsedRequest) returns (collection.OpChanges);
|
|
rpc TagTree(generic.Empty) returns (TagTreeNode);
|
|
rpc ReparentTags(ReparentTagsRequest) returns (collection.OpChangesWithCount);
|
|
rpc RenameTags(RenameTagsRequest) returns (collection.OpChangesWithCount);
|
|
rpc AddNoteTags(NoteIdsAndTagsRequest)
|
|
returns (collection.OpChangesWithCount);
|
|
rpc RemoveNoteTags(NoteIdsAndTagsRequest)
|
|
returns (collection.OpChangesWithCount);
|
|
rpc FindAndReplaceTag(FindAndReplaceTagRequest)
|
|
returns (collection.OpChangesWithCount);
|
|
}
|
|
|
|
service StatsService {
|
|
rpc CardStats(cards.CardId) returns (generic.String);
|
|
rpc Graphs(GraphsRequest) returns (GraphsResponse);
|
|
rpc GetGraphPreferences(generic.Empty) returns (GraphPreferences);
|
|
rpc SetGraphPreferences(GraphPreferences) returns (generic.Empty);
|
|
}
|
|
|
|
service MediaService {
|
|
rpc CheckMedia(generic.Empty) returns (CheckMediaResponse);
|
|
rpc TrashMediaFiles(TrashMediaFilesRequest) returns (generic.Empty);
|
|
rpc AddMediaFile(AddMediaFileRequest) returns (generic.String);
|
|
rpc EmptyTrash(generic.Empty) returns (generic.Empty);
|
|
rpc RestoreTrash(generic.Empty) returns (generic.Empty);
|
|
}
|
|
|
|
// Backend
|
|
///////////////////////////////////////////////////////////
|
|
|
|
message BackendInit {
|
|
repeated string preferred_langs = 1;
|
|
string locale_folder_path = 2;
|
|
bool server = 3;
|
|
}
|
|
|
|
message I18nBackendInit {
|
|
repeated string preferred_langs = 4;
|
|
string locale_folder_path = 5;
|
|
}
|
|
|
|
// Errors
|
|
///////////////////////////////////////////////////////////
|
|
|
|
message BackendError {
|
|
enum Kind {
|
|
INVALID_INPUT = 0;
|
|
UNDO_EMPTY = 1;
|
|
INTERRUPTED = 2;
|
|
TEMPLATE_PARSE = 3;
|
|
IO_ERROR = 4;
|
|
DB_ERROR = 5;
|
|
NETWORK_ERROR = 6;
|
|
SYNC_AUTH_ERROR = 7;
|
|
SYNC_OTHER_ERROR = 8;
|
|
JSON_ERROR = 9;
|
|
PROTO_ERROR = 10;
|
|
NOT_FOUND_ERROR = 11;
|
|
EXISTS = 12;
|
|
FILTERED_DECK_ERROR = 13;
|
|
SEARCH_ERROR = 14;
|
|
}
|
|
|
|
// localized error description suitable for displaying to the user
|
|
string localized = 1;
|
|
// the error subtype
|
|
Kind kind = 2;
|
|
}
|
|
|
|
// Messages
|
|
///////////////////////////////////////////////////////////
|
|
|
|
message RenderExistingCardRequest {
|
|
int64 card_id = 1;
|
|
bool browser = 2;
|
|
}
|
|
|
|
message RenderUncommittedCardRequest {
|
|
notes.Note note = 1;
|
|
uint32 card_ord = 2;
|
|
notetypes.Notetype.Template template = 3;
|
|
bool fill_empty = 4;
|
|
}
|
|
|
|
message RenderUncommittedCardLegacyRequest {
|
|
notes.Note note = 1;
|
|
uint32 card_ord = 2;
|
|
bytes template = 3;
|
|
bool fill_empty = 4;
|
|
}
|
|
|
|
message RenderCardResponse {
|
|
repeated RenderedTemplateNode question_nodes = 1;
|
|
repeated RenderedTemplateNode answer_nodes = 2;
|
|
string css = 3;
|
|
bool latex_svg = 4;
|
|
}
|
|
|
|
message RenderedTemplateNode {
|
|
oneof value {
|
|
string text = 1;
|
|
RenderedTemplateReplacement replacement = 2;
|
|
}
|
|
}
|
|
|
|
message RenderedTemplateReplacement {
|
|
string field_name = 1;
|
|
string current_text = 2;
|
|
repeated string filters = 3;
|
|
}
|
|
|
|
message ExtractAVTagsRequest {
|
|
string text = 1;
|
|
bool question_side = 2;
|
|
}
|
|
|
|
message ExtractAVTagsResponse {
|
|
string text = 1;
|
|
repeated AVTag av_tags = 2;
|
|
}
|
|
|
|
message AVTag {
|
|
oneof value {
|
|
string sound_or_video = 1;
|
|
TTSTag tts = 2;
|
|
}
|
|
}
|
|
|
|
message TTSTag {
|
|
string field_text = 1;
|
|
string lang = 2;
|
|
repeated string voices = 3;
|
|
float speed = 4;
|
|
repeated string other_args = 5;
|
|
}
|
|
|
|
message ExtractLatexRequest {
|
|
string text = 1;
|
|
bool svg = 2;
|
|
bool expand_clozes = 3;
|
|
}
|
|
|
|
message ExtractLatexResponse {
|
|
string text = 1;
|
|
repeated ExtractedLatex latex = 2;
|
|
}
|
|
|
|
message ExtractedLatex {
|
|
string filename = 1;
|
|
string latex_body = 2;
|
|
}
|
|
|
|
message AddMediaFileRequest {
|
|
string desired_name = 1;
|
|
bytes data = 2;
|
|
}
|
|
|
|
message CheckMediaResponse {
|
|
repeated string unused = 1;
|
|
repeated string missing = 2;
|
|
string report = 3;
|
|
bool have_trash = 4;
|
|
}
|
|
|
|
message TrashMediaFilesRequest {
|
|
repeated string fnames = 1;
|
|
}
|
|
|
|
message CongratsLearnMessageRequest {
|
|
float next_due = 1;
|
|
uint32 remaining = 2;
|
|
}
|
|
|
|
message SetTagCollapsedRequest {
|
|
string name = 1;
|
|
bool collapsed = 2;
|
|
}
|
|
|
|
message GetChangedTagsResponse {
|
|
repeated string tags = 1;
|
|
}
|
|
|
|
message TagTreeNode {
|
|
string name = 1;
|
|
repeated TagTreeNode children = 2;
|
|
uint32 level = 3;
|
|
bool collapsed = 4;
|
|
}
|
|
|
|
message ReparentTagsRequest {
|
|
repeated string tags = 1;
|
|
string new_parent = 2;
|
|
}
|
|
|
|
message RenameTagsRequest {
|
|
string current_prefix = 1;
|
|
string new_prefix = 2;
|
|
}
|
|
|
|
message EmptyCardsReport {
|
|
message NoteWithEmptyCards {
|
|
int64 note_id = 1;
|
|
repeated int64 card_ids = 2;
|
|
bool will_delete_note = 3;
|
|
}
|
|
string report = 1;
|
|
repeated NoteWithEmptyCards notes = 2;
|
|
}
|
|
|
|
message NoteIdsAndTagsRequest {
|
|
repeated int64 note_ids = 1;
|
|
string tags = 2;
|
|
}
|
|
|
|
message FindAndReplaceTagRequest {
|
|
repeated int64 note_ids = 1;
|
|
string search = 2;
|
|
string replacement = 3;
|
|
bool regex = 4;
|
|
bool match_case = 5;
|
|
}
|
|
|
|
message GraphsRequest {
|
|
string search = 1;
|
|
uint32 days = 2;
|
|
}
|
|
|
|
message GraphsResponse {
|
|
repeated cards.Card cards = 1;
|
|
repeated RevlogEntry revlog = 2;
|
|
uint32 days_elapsed = 3;
|
|
// Based on rollover hour
|
|
uint32 next_day_at_secs = 4;
|
|
uint32 scheduler_version = 5;
|
|
/// Seconds to add to UTC timestamps to get local time.
|
|
int32 local_offset_secs = 7;
|
|
}
|
|
|
|
message GraphPreferences {
|
|
enum Weekday {
|
|
SUNDAY = 0;
|
|
MONDAY = 1;
|
|
FRIDAY = 5;
|
|
SATURDAY = 6;
|
|
}
|
|
Weekday calendar_first_day_of_week = 1;
|
|
bool card_counts_separate_inactive = 2;
|
|
bool browser_links_supported = 3;
|
|
bool future_due_show_backlog = 4;
|
|
}
|
|
|
|
message RevlogEntry {
|
|
enum ReviewKind {
|
|
LEARNING = 0;
|
|
REVIEW = 1;
|
|
RELEARNING = 2;
|
|
EARLY_REVIEW = 3;
|
|
MANUAL = 4;
|
|
}
|
|
int64 id = 1;
|
|
int64 cid = 2;
|
|
int32 usn = 3;
|
|
uint32 button_chosen = 4;
|
|
int32 interval = 5;
|
|
int32 last_interval = 6;
|
|
uint32 ease_factor = 7;
|
|
uint32 taken_millis = 8;
|
|
ReviewKind review_kind = 9;
|
|
}
|
|
message RenderMarkdownRequest {
|
|
string markdown = 1;
|
|
bool sanitize = 2;
|
|
}
|