@spacholski1225/anki-connect-mcp 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +198 -0
- package/dist/index.js +362 -0
- package/dist/methods/anki.js +22 -0
- package/dist/tools/cards.js +118 -0
- package/dist/tools/decks.js +139 -0
- package/dist/tools/graphical.js +133 -0
- package/dist/tools/media.js +48 -0
- package/dist/tools/misc.js +171 -0
- package/dist/tools/models.js +50 -0
- package/dist/tools/notes.js +120 -0
- package/dist/types/anki/base.js +12 -0
- package/dist/types/anki/cards.js +1 -0
- package/dist/types/anki/decks.js +1 -0
- package/dist/types/anki/index.js +9 -0
- package/dist/types/anki/media.js +1 -0
- package/dist/types/anki/misc.js +1 -0
- package/dist/types/anki/models.js +1 -0
- package/dist/types/anki/notes.js +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { callAnkiConnect } from '../methods/anki.js';
|
|
2
|
+
/**
|
|
3
|
+
* Suspend cards by card ID; returns true if successful (at least one card wasn't already suspended) or false otherwise.
|
|
4
|
+
* @param cards - Array of card IDs to suspend
|
|
5
|
+
*/
|
|
6
|
+
export async function suspend(cards) {
|
|
7
|
+
const request = {
|
|
8
|
+
action: 'suspend',
|
|
9
|
+
version: 6,
|
|
10
|
+
params: {
|
|
11
|
+
cards
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
return await callAnkiConnect(request);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Unsuspend cards by card ID; returns true if successful (at least one card was previously suspended) or false otherwise.
|
|
18
|
+
* @param cards - Array of card IDs to unsuspend
|
|
19
|
+
*/
|
|
20
|
+
export async function unsuspend(cards) {
|
|
21
|
+
const request = {
|
|
22
|
+
action: 'unsuspend',
|
|
23
|
+
version: 6,
|
|
24
|
+
params: {
|
|
25
|
+
cards
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
return await callAnkiConnect(request);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Returns an array indicating whether each of the given cards is suspended (in the same order).
|
|
32
|
+
* @param cards - Array of card IDs to check
|
|
33
|
+
*/
|
|
34
|
+
export async function areSuspended(cards) {
|
|
35
|
+
const request = {
|
|
36
|
+
action: 'areSuspended',
|
|
37
|
+
version: 6,
|
|
38
|
+
params: {
|
|
39
|
+
cards
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
return await callAnkiConnect(request);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Returns an array indicating whether each of the given cards is due (in the same order).
|
|
46
|
+
* Note: cards in the learning queue with a large interval (over 20 minutes) are treated as not due
|
|
47
|
+
* until the time of their interval has passed, to match the way Anki treats them when reviewing.
|
|
48
|
+
* @param cards - Array of card IDs to check
|
|
49
|
+
*/
|
|
50
|
+
export async function areDue(cards) {
|
|
51
|
+
const request = {
|
|
52
|
+
action: 'areDue',
|
|
53
|
+
version: 6,
|
|
54
|
+
params: {
|
|
55
|
+
cards
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
return await callAnkiConnect(request);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Returns an array of the most recent intervals for each given card ID, or a 2-dimensional array
|
|
62
|
+
* of all the intervals for each given card ID when complete is true.
|
|
63
|
+
* Negative intervals are in seconds and positive intervals in days.
|
|
64
|
+
* @param cards - Array of card IDs to get intervals for
|
|
65
|
+
* @param complete - If true, returns all intervals; if false, returns only the most recent interval
|
|
66
|
+
*/
|
|
67
|
+
export async function getIntervals(cards, complete) {
|
|
68
|
+
const request = {
|
|
69
|
+
action: 'getIntervals',
|
|
70
|
+
version: 6,
|
|
71
|
+
params: Object.assign({ cards }, (complete !== undefined && { complete }))
|
|
72
|
+
};
|
|
73
|
+
return await callAnkiConnect(request);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Returns an array of card IDs for a given query. Functionally identical to guiBrowse but doesn't use the GUI for better performance.
|
|
77
|
+
* @param query - Search query string
|
|
78
|
+
*/
|
|
79
|
+
export async function findCards(query) {
|
|
80
|
+
const request = {
|
|
81
|
+
action: 'findCards',
|
|
82
|
+
version: 6,
|
|
83
|
+
params: {
|
|
84
|
+
query
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
return await callAnkiConnect(request);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Returns an unordered array of note IDs for the given card IDs.
|
|
91
|
+
* For cards with the same note, the ID is only given once in the array.
|
|
92
|
+
* @param cards - Array of card IDs to convert to note IDs
|
|
93
|
+
*/
|
|
94
|
+
export async function cardsToNotes(cards) {
|
|
95
|
+
const request = {
|
|
96
|
+
action: 'cardsToNotes',
|
|
97
|
+
version: 6,
|
|
98
|
+
params: {
|
|
99
|
+
cards
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
return await callAnkiConnect(request);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Returns a list of objects containing for each card ID the card fields, front and back sides including CSS,
|
|
106
|
+
* note type, the note that the card belongs to, and deck name, as well as ease and interval.
|
|
107
|
+
* @param cards - Array of card IDs to get information for
|
|
108
|
+
*/
|
|
109
|
+
export async function cardsInfo(cards) {
|
|
110
|
+
const request = {
|
|
111
|
+
action: 'cardsInfo',
|
|
112
|
+
version: 6,
|
|
113
|
+
params: {
|
|
114
|
+
cards
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
return await callAnkiConnect(request);
|
|
118
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { callAnkiConnect } from '../methods/anki.js';
|
|
2
|
+
/**
|
|
3
|
+
* Get the complete list of deck names for the current user
|
|
4
|
+
*/
|
|
5
|
+
export async function deckNames() {
|
|
6
|
+
const request = {
|
|
7
|
+
action: 'deckNames',
|
|
8
|
+
version: 6
|
|
9
|
+
};
|
|
10
|
+
return await callAnkiConnect(request);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Get the complete list of deck names and their respective IDs for the current user
|
|
14
|
+
*/
|
|
15
|
+
export async function deckNamesAndIds() {
|
|
16
|
+
const request = {
|
|
17
|
+
action: 'deckNamesAndIds',
|
|
18
|
+
version: 6
|
|
19
|
+
};
|
|
20
|
+
return await callAnkiConnect(request);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Accept an array of card IDs and return an object with each deck name as a key,
|
|
24
|
+
* and its value an array of the given cards which belong to it
|
|
25
|
+
* @param cards - Array of card IDs
|
|
26
|
+
*/
|
|
27
|
+
export async function getDecks(cards) {
|
|
28
|
+
const request = {
|
|
29
|
+
action: 'getDecks',
|
|
30
|
+
version: 6,
|
|
31
|
+
params: {
|
|
32
|
+
cards
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
return await callAnkiConnect(request);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Move cards with the given IDs to a different deck, creating the deck if it doesn't exist yet
|
|
39
|
+
* @param cards - Array of card IDs to move
|
|
40
|
+
* @param deck - Name of the target deck
|
|
41
|
+
*/
|
|
42
|
+
export async function changeDeck(cards, deck) {
|
|
43
|
+
const request = {
|
|
44
|
+
action: 'changeDeck',
|
|
45
|
+
version: 6,
|
|
46
|
+
params: {
|
|
47
|
+
cards,
|
|
48
|
+
deck
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
return await callAnkiConnect(request);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Delete decks with the given names
|
|
55
|
+
* @param decks - Array of deck names to delete
|
|
56
|
+
* @param cardsToo - If true, cards within deleted decks will also be deleted; otherwise moved to default deck
|
|
57
|
+
*/
|
|
58
|
+
export async function deleteDecks(decks, cardsToo = false) {
|
|
59
|
+
const request = {
|
|
60
|
+
action: 'deleteDecks',
|
|
61
|
+
version: 6,
|
|
62
|
+
params: {
|
|
63
|
+
decks,
|
|
64
|
+
cardsToo
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
return await callAnkiConnect(request);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Get the configuration group object for the given deck
|
|
71
|
+
* @param deck - Name of the deck
|
|
72
|
+
*/
|
|
73
|
+
export async function getDeckConfig(deck) {
|
|
74
|
+
const request = {
|
|
75
|
+
action: 'getDeckConfig',
|
|
76
|
+
version: 6,
|
|
77
|
+
params: {
|
|
78
|
+
deck
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
return await callAnkiConnect(request);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Save the given configuration group, returning true on success or false if the ID is invalid
|
|
85
|
+
* @param config - Deck configuration object
|
|
86
|
+
*/
|
|
87
|
+
export async function saveDeckConfig(config) {
|
|
88
|
+
const request = {
|
|
89
|
+
action: 'saveDeckConfig',
|
|
90
|
+
version: 6,
|
|
91
|
+
params: {
|
|
92
|
+
config
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
return await callAnkiConnect(request);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Change the configuration group for the given decks to the one with the given ID
|
|
99
|
+
* @param decks - Array of deck names
|
|
100
|
+
* @param configId - Configuration group ID
|
|
101
|
+
*/
|
|
102
|
+
export async function setDeckConfigId(decks, configId) {
|
|
103
|
+
const request = {
|
|
104
|
+
action: 'setDeckConfigId',
|
|
105
|
+
version: 6,
|
|
106
|
+
params: {
|
|
107
|
+
decks,
|
|
108
|
+
configId
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
return await callAnkiConnect(request);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Create a new configuration group with the given name, cloning from the group with the given ID
|
|
115
|
+
* @param name - Name for the new configuration group
|
|
116
|
+
* @param cloneFrom - ID of the configuration group to clone from (optional, defaults to default group)
|
|
117
|
+
*/
|
|
118
|
+
export async function cloneDeckConfigId(name, cloneFrom) {
|
|
119
|
+
const request = {
|
|
120
|
+
action: 'cloneDeckConfigId',
|
|
121
|
+
version: 6,
|
|
122
|
+
params: Object.assign({ name }, (cloneFrom !== undefined && { cloneFrom }))
|
|
123
|
+
};
|
|
124
|
+
return await callAnkiConnect(request);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Remove the configuration group with the given ID
|
|
128
|
+
* @param configId - ID of the configuration group to remove
|
|
129
|
+
*/
|
|
130
|
+
export async function removeDeckConfigId(configId) {
|
|
131
|
+
const request = {
|
|
132
|
+
action: 'removeDeckConfigId',
|
|
133
|
+
version: 6,
|
|
134
|
+
params: {
|
|
135
|
+
configId
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
return await callAnkiConnect(request);
|
|
139
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { callAnkiConnect } from '../methods/anki.js';
|
|
2
|
+
/**
|
|
3
|
+
* Invokes the Card Browser dialog and searches for a given query.
|
|
4
|
+
* Returns an array of identifiers of the cards that were found.
|
|
5
|
+
* @param query - Search query for browsing cards
|
|
6
|
+
*/
|
|
7
|
+
export async function guiBrowse(query) {
|
|
8
|
+
const request = {
|
|
9
|
+
action: 'guiBrowse',
|
|
10
|
+
version: 5,
|
|
11
|
+
params: {
|
|
12
|
+
query
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
return await callAnkiConnect(request);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Invokes the Add Cards dialog.
|
|
19
|
+
*/
|
|
20
|
+
export async function guiAddCards() {
|
|
21
|
+
const request = {
|
|
22
|
+
action: 'guiAddCards',
|
|
23
|
+
version: 5
|
|
24
|
+
};
|
|
25
|
+
return await callAnkiConnect(request);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Returns information about the current card or null if not in review mode.
|
|
29
|
+
*/
|
|
30
|
+
export async function guiCurrentCard() {
|
|
31
|
+
const request = {
|
|
32
|
+
action: 'guiCurrentCard',
|
|
33
|
+
version: 5
|
|
34
|
+
};
|
|
35
|
+
return await callAnkiConnect(request);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Starts or resets the timerStarted value for the current card.
|
|
39
|
+
* This is useful for deferring the start time to when it is displayed via the API,
|
|
40
|
+
* allowing the recorded time taken to answer the card to be more accurate when calling guiAnswerCard.
|
|
41
|
+
*/
|
|
42
|
+
export async function guiStartCardTimer() {
|
|
43
|
+
const request = {
|
|
44
|
+
action: 'guiStartCardTimer',
|
|
45
|
+
version: 5
|
|
46
|
+
};
|
|
47
|
+
return await callAnkiConnect(request);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Shows question text for the current card; returns true if in review mode or false otherwise.
|
|
51
|
+
*/
|
|
52
|
+
export async function guiShowQuestion() {
|
|
53
|
+
const request = {
|
|
54
|
+
action: 'guiShowQuestion',
|
|
55
|
+
version: 5
|
|
56
|
+
};
|
|
57
|
+
return await callAnkiConnect(request);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Shows answer text for the current card; returns true if in review mode or false otherwise.
|
|
61
|
+
*/
|
|
62
|
+
export async function guiShowAnswer() {
|
|
63
|
+
const request = {
|
|
64
|
+
action: 'guiShowAnswer',
|
|
65
|
+
version: 5
|
|
66
|
+
};
|
|
67
|
+
return await callAnkiConnect(request);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Answers the current card; returns true if succeeded or false otherwise.
|
|
71
|
+
* Note that the answer for the current card must be displayed before any answer can be accepted by Anki.
|
|
72
|
+
* @param ease - Answer ease (1-4: Again, Hard, Good, Easy)
|
|
73
|
+
*/
|
|
74
|
+
export async function guiAnswerCard(ease) {
|
|
75
|
+
const request = {
|
|
76
|
+
action: 'guiAnswerCard',
|
|
77
|
+
version: 5,
|
|
78
|
+
params: {
|
|
79
|
+
ease
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
return await callAnkiConnect(request);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Opens the Deck Overview dialog for the deck with the given name;
|
|
86
|
+
* returns true if succeeded or false otherwise.
|
|
87
|
+
* @param name - Name of the deck to open overview for
|
|
88
|
+
*/
|
|
89
|
+
export async function guiDeckOverview(name) {
|
|
90
|
+
const request = {
|
|
91
|
+
action: 'guiDeckOverview',
|
|
92
|
+
version: 5,
|
|
93
|
+
params: {
|
|
94
|
+
name
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
return await callAnkiConnect(request);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Opens the Deck Browser dialog.
|
|
101
|
+
*/
|
|
102
|
+
export async function guiDeckBrowser() {
|
|
103
|
+
const request = {
|
|
104
|
+
action: 'guiDeckBrowser',
|
|
105
|
+
version: 5
|
|
106
|
+
};
|
|
107
|
+
return await callAnkiConnect(request);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Starts review for the deck with the given name; returns true if succeeded or false otherwise.
|
|
111
|
+
* @param name - Name of the deck to start review for
|
|
112
|
+
*/
|
|
113
|
+
export async function guiDeckReview(name) {
|
|
114
|
+
const request = {
|
|
115
|
+
action: 'guiDeckReview',
|
|
116
|
+
version: 5,
|
|
117
|
+
params: {
|
|
118
|
+
name
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
return await callAnkiConnect(request);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Schedules a request to gracefully close Anki.
|
|
125
|
+
* This operation is asynchronous, so it will return immediately and won't wait until the Anki process actually terminates.
|
|
126
|
+
*/
|
|
127
|
+
export async function guiExitAnki() {
|
|
128
|
+
const request = {
|
|
129
|
+
action: 'guiExitAnki',
|
|
130
|
+
version: 5
|
|
131
|
+
};
|
|
132
|
+
return await callAnkiConnect(request);
|
|
133
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { callAnkiConnect } from '../methods/anki.js';
|
|
2
|
+
/**
|
|
3
|
+
* Store a file with the specified base64-encoded contents inside the media folder.
|
|
4
|
+
* To prevent Anki from removing files not used by any cards (e.g. for configuration files),
|
|
5
|
+
* prefix the filename with an underscore. These files are still synchronized to AnkiWeb.
|
|
6
|
+
* @param filename - Name of the file to store
|
|
7
|
+
* @param data - Base64-encoded file contents
|
|
8
|
+
*/
|
|
9
|
+
export async function storeMediaFile(filename, data) {
|
|
10
|
+
const request = {
|
|
11
|
+
action: 'storeMediaFile',
|
|
12
|
+
version: 6,
|
|
13
|
+
params: {
|
|
14
|
+
filename,
|
|
15
|
+
data
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
return await callAnkiConnect(request);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Retrieve the base64-encoded contents of the specified file.
|
|
22
|
+
* Returns false if the file does not exist.
|
|
23
|
+
* @param filename - Name of the file to retrieve
|
|
24
|
+
*/
|
|
25
|
+
export async function retrieveMediaFile(filename) {
|
|
26
|
+
const request = {
|
|
27
|
+
action: 'retrieveMediaFile',
|
|
28
|
+
version: 6,
|
|
29
|
+
params: {
|
|
30
|
+
filename
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
return await callAnkiConnect(request);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Delete the specified file inside the media folder.
|
|
37
|
+
* @param filename - Name of the file to delete
|
|
38
|
+
*/
|
|
39
|
+
export async function deleteMediaFile(filename) {
|
|
40
|
+
const request = {
|
|
41
|
+
action: 'deleteMediaFile',
|
|
42
|
+
version: 6,
|
|
43
|
+
params: {
|
|
44
|
+
filename
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
return await callAnkiConnect(request);
|
|
48
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { callAnkiConnect } from '../methods/anki.js';
|
|
2
|
+
/**
|
|
3
|
+
* Get Anki Connect API version
|
|
4
|
+
*/
|
|
5
|
+
export async function getVersion() {
|
|
6
|
+
const request = {
|
|
7
|
+
action: 'version',
|
|
8
|
+
version: 6
|
|
9
|
+
};
|
|
10
|
+
return await callAnkiConnect(request);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Get all tags from Anki
|
|
14
|
+
*/
|
|
15
|
+
export async function getTags() {
|
|
16
|
+
const request = {
|
|
17
|
+
action: 'getTags',
|
|
18
|
+
version: 6
|
|
19
|
+
};
|
|
20
|
+
return await callAnkiConnect(request);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Get current card information from GUI
|
|
24
|
+
*/
|
|
25
|
+
export async function guiCurrentCard() {
|
|
26
|
+
const request = {
|
|
27
|
+
action: 'guiCurrentCard',
|
|
28
|
+
version: 6
|
|
29
|
+
};
|
|
30
|
+
return await callAnkiConnect(request);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Start card timer in GUI
|
|
34
|
+
*/
|
|
35
|
+
export async function guiStartCardTimer() {
|
|
36
|
+
const request = {
|
|
37
|
+
action: 'guiStartCardTimer',
|
|
38
|
+
version: 6
|
|
39
|
+
};
|
|
40
|
+
return await callAnkiConnect(request);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Show question in GUI
|
|
44
|
+
*/
|
|
45
|
+
export async function guiShowQuestion() {
|
|
46
|
+
const request = {
|
|
47
|
+
action: 'guiShowQuestion',
|
|
48
|
+
version: 6
|
|
49
|
+
};
|
|
50
|
+
return await callAnkiConnect(request);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Show answer in GUI
|
|
54
|
+
*/
|
|
55
|
+
export async function guiShowAnswer() {
|
|
56
|
+
const request = {
|
|
57
|
+
action: 'guiShowAnswer',
|
|
58
|
+
version: 6
|
|
59
|
+
};
|
|
60
|
+
return await callAnkiConnect(request);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Answer card in GUI
|
|
64
|
+
* @param ease - Answer ease (1-4: Again, Hard, Good, Easy)
|
|
65
|
+
*/
|
|
66
|
+
export async function guiAnswerCard(ease) {
|
|
67
|
+
const request = {
|
|
68
|
+
action: 'guiAnswerCard',
|
|
69
|
+
version: 6,
|
|
70
|
+
params: {
|
|
71
|
+
ease
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
return await callAnkiConnect(request);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Open deck overview in GUI
|
|
78
|
+
* @param deckName - Name of the deck to open
|
|
79
|
+
*/
|
|
80
|
+
export async function guiDeckOverview(deckName) {
|
|
81
|
+
const request = {
|
|
82
|
+
action: 'guiDeckOverview',
|
|
83
|
+
version: 6,
|
|
84
|
+
params: {
|
|
85
|
+
name: deckName
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
return await callAnkiConnect(request);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Open deck browser in GUI
|
|
92
|
+
*/
|
|
93
|
+
export async function guiDeckBrowser() {
|
|
94
|
+
const request = {
|
|
95
|
+
action: 'guiDeckBrowser',
|
|
96
|
+
version: 6
|
|
97
|
+
};
|
|
98
|
+
return await callAnkiConnect(request);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Start deck review in GUI
|
|
102
|
+
* @param deckName - Name of the deck to review
|
|
103
|
+
*/
|
|
104
|
+
export async function guiDeckReview(deckName) {
|
|
105
|
+
const request = {
|
|
106
|
+
action: 'guiDeckReview',
|
|
107
|
+
version: 6,
|
|
108
|
+
params: {
|
|
109
|
+
name: deckName
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
return await callAnkiConnect(request);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Open browse window with query
|
|
116
|
+
* @param query - Search query for browsing
|
|
117
|
+
*/
|
|
118
|
+
export async function guiBrowse(query) {
|
|
119
|
+
const request = {
|
|
120
|
+
action: 'guiBrowse',
|
|
121
|
+
version: 6,
|
|
122
|
+
params: {
|
|
123
|
+
query
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
return await callAnkiConnect(request);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Open add cards dialog in GUI
|
|
130
|
+
*/
|
|
131
|
+
export async function guiAddCards() {
|
|
132
|
+
const request = {
|
|
133
|
+
action: 'guiAddCards',
|
|
134
|
+
version: 6
|
|
135
|
+
};
|
|
136
|
+
return await callAnkiConnect(request);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Exit Anki application
|
|
140
|
+
*/
|
|
141
|
+
export async function guiExitAnki() {
|
|
142
|
+
const request = {
|
|
143
|
+
action: 'guiExitAnki',
|
|
144
|
+
version: 6
|
|
145
|
+
};
|
|
146
|
+
return await callAnkiConnect(request);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Execute multiple actions in a single request
|
|
150
|
+
* @param actions - Array of AnkiConnect requests to execute
|
|
151
|
+
*/
|
|
152
|
+
export async function multi(actions) {
|
|
153
|
+
const request = {
|
|
154
|
+
action: 'multi',
|
|
155
|
+
version: 6,
|
|
156
|
+
params: {
|
|
157
|
+
actions
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
return await callAnkiConnect(request);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Upgrade Anki Connect (if available)
|
|
164
|
+
*/
|
|
165
|
+
export async function upgrade() {
|
|
166
|
+
const request = {
|
|
167
|
+
action: 'upgrade',
|
|
168
|
+
version: 6
|
|
169
|
+
};
|
|
170
|
+
return await callAnkiConnect(request);
|
|
171
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { callAnkiConnect } from '../methods/anki.js';
|
|
2
|
+
/**
|
|
3
|
+
* Get the complete list of model names for the current user
|
|
4
|
+
*/
|
|
5
|
+
export async function modelNames() {
|
|
6
|
+
const request = {
|
|
7
|
+
action: 'modelNames',
|
|
8
|
+
version: 6
|
|
9
|
+
};
|
|
10
|
+
return await callAnkiConnect(request);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Get the complete list of model names and their corresponding IDs for the current user
|
|
14
|
+
*/
|
|
15
|
+
export async function modelNamesAndIds() {
|
|
16
|
+
const request = {
|
|
17
|
+
action: 'modelNamesAndIds',
|
|
18
|
+
version: 6
|
|
19
|
+
};
|
|
20
|
+
return await callAnkiConnect(request);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Get the complete list of field names for the provided model name
|
|
24
|
+
* @param modelName - Name of the model to get field names for
|
|
25
|
+
*/
|
|
26
|
+
export async function modelFieldNames(modelName) {
|
|
27
|
+
const request = {
|
|
28
|
+
action: 'modelFieldNames',
|
|
29
|
+
version: 6,
|
|
30
|
+
params: {
|
|
31
|
+
modelName
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
return await callAnkiConnect(request);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Returns an object indicating the fields on the question and answer side of each card template for the given model name.
|
|
38
|
+
* The question side is given first in each array.
|
|
39
|
+
* @param modelName - Name of the model to get template fields for
|
|
40
|
+
*/
|
|
41
|
+
export async function modelFieldsOnTemplates(modelName) {
|
|
42
|
+
const request = {
|
|
43
|
+
action: 'modelFieldsOnTemplates',
|
|
44
|
+
version: 6,
|
|
45
|
+
params: {
|
|
46
|
+
modelName
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
return await callAnkiConnect(request);
|
|
50
|
+
}
|