Skip to content
This repository has been archived by the owner on Dec 31, 2023. It is now read-only.

Add an endpoint for retrieving model info in its entirety #400

Open
pattontim opened this issue Aug 26, 2023 · 0 comments
Open

Add an endpoint for retrieving model info in its entirety #400

pattontim opened this issue Aug 26, 2023 · 0 comments

Comments

@pattontim
Copy link

pattontim commented Aug 26, 2023

When you create a model, all of its info in its entirety is available to you.

"result":{
        "sortf":0,
        "did":1,
        "latexPre":"\\documentclass[12pt]{article}\n\\special{papersize=3in,5in}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amssymb,amsmath}\n\\pagestyle{empty}\n\\setlength{\\parindent}{0in}\n\\begin{document}\n",
        "latexPost":"\\end{document}",
        "mod":1551462107,
        "usn":-1,
        "vers":[

        ],
        "type":0,
        "css":".card {\n font-family: arial;\n font-size: 20px;\n text-align: center;\n color: black;\n background-color: white;\n}\n",
        "name":"TestApiModel",
        "flds":[
            {
                "name":"Field1",
                "ord":0,
         [...]

However, if you want to retrieve information by model ID it is necessary to make several requests and attempt to reconstruct the information-

chain('modelFieldNames', { "modelName": modelName })
            .add('modelTemplates', { "modelName": modelName })
            .add('modelFieldFonts', { "modelName": modelName })
            .add('modelStyling', { "modelName": modelName })
            .add('modelFieldsOnTemplates', { "modelName": modelName })

const [fieldNames, templates, fonts, styling, fieldsOnTemplates] = modelBuilder.commit() as 
        [
            fieldNames: string[], templates: { [templateName: string]: { [fieldName: string]: string } }, 
            fonts: { [fieldName: string]: { font: string, size: number } }, styling: { css: string }, 
            fieldsOnTemplates: { [templateName: string]: [string][] }
        ]

Even more calls would be needed to recreate all of the info

A simplified endpoint might look like...

modelInfo: {
   params: {
     modelName: string;
   };
   result: {
     sortf: number;
     did: number;
     latexPre: string;
     latexPost: string;
     mod: number;
     usn: number;
     vers: unknown[];
     type: number;
     css: string;
     name: string;
     flds: AnkiField[];
     tmpls: AnkiTemplate[];
     tags: string[];
     id: number;
     req: unknown[];
   }
 };
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant