1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
* The MIT License (MIT)
*
* Copyright (c) 2023 VaiTon <eyadlorenzo.issa@studio.unibo.it>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/// Adds a new note to a deck.
///
/// Creates a note using the given deck and model, with the provided field values and tags.
/// Returns the identifier of the created note created on success, and `null` on failure.
///
/// Anki-Connect can download audio, video, and picture files and embed them in newly created notes.
/// The corresponding `audio`, `video`, and `picture` note members are optional and can be omitted.
/// If you choose to include any of them, they should contain a single object or an array of objects with the mandatory `filename` field and one of `data`, `path` or `url`.
/// Refer to the documentation of [store_media_file] for an explanation of these fields.
///
/// The `skip_hash` field can be optionally provided to skip the inclusion of files with an MD5 hash that matches the provided value.
/// This is useful for avoiding the saving of error pages and stub files.
///
/// The `fields` member is a list of fields that should play audio or video or show a picture when the card is displayed in Anki.
///
/// The `allow_duplicate` member inside the `options` group can be set to true to enable adding duplicate cards.
/// Normally duplicate cards cannot be added and trigger exception.
///
/// The `duplicate_scope` member inside `options` can be used to specify the scope for which duplicates are checked.
/// A value of "`deck`" will only check for duplicates in the target deck; any other value will check the entire collection.
///
/// The `duplicate_scope_options` object can be used to specify some additional settings:
/// - `duplicate_scope_options.deck_name` will specify which deck to use for checking duplicates in. If undefined or `null`, the target deck will be used.
/// - `duplicate_scope_options.check_children` will change whether duplicate cards are checked in child decks. The default value is `false`.
/// - `duplicate_scope_options.check_all_models` specifies whether duplicate checks are performed across all note types. The default value is `false`.
///
/// [store_media_file]: crate::media_actions::store_media_file
/// Adds multiple new notes to a deck.
///
/// Creates multiple notes using the given deck and model, with the provided field values and tags.
/// Returns an array of identifiers of the created notes.
/// In the event of any errors, all errors are gathered and returned.
///
/// Please see the documentation for [add_note] for an explanation of objects in the `notes` array.
/// Adds tags to notes.
/// Checks if these notes can be created.
///
/// Accepts an array of objects which define parameters for candidate notes (see [add_note]) and returns an array of booleans indicating whether the parameters at the corresponding index could be used to create a new note.
/// Checks if these notes can be created, with detailed error messages.
///
/// Accepts an array of objects which define parameters for candidate notes (see [add_note]) and returns an array of objects with fields `can_add` and `error`.
/// Clears all the unused tags in the notes.
/// Deletes notes.
///
/// If a note has several cards associated with it, all associated cards will be deleted
/// Finds a list of notes that match a query.
///
/// Query syntax is documented [here](https://docs.ankiweb.net/searching.html).
/// Gets all tags added to a note.
/// Gets the complete list of tags.
/// Gets information about a note.
///
/// Returns a list of objects containing for each note ID the note fields, tags, note type, and the cards belonging to the note.
/// Gets the notes' last modified times.
///
/// Returns a list of objects containing for each note ID the modification time.
/// Removes all empty notes.
/// Removes a tag from notes.
/// Replaces a tag in notes.
/// Replaces a tag in all the notes.
/// Modify the fields and/or tags of an existing note.
///
/// In other words, combines [update_note_fields] and [update_note_tags].
/// Please see their documentation for an explanation of all properties.
///
/// Either `fields` or `tags` property can be omitted without affecting the other.
/// Thus valid requests to [update_note_fields] also work with [update_note].
/// The note must have the `fields` property to update the optional audio, video, or picture objects.
///
/// If neither `fields` nor `tags` are provided, the method will fail.
/// Fields are updated first and are not rolled back if updating tags fails.
/// Tags are not updated if updating the fields fails.
///
/// *Note:* These changes will not reflect in the note currently opened in the _Card Browser_ dialog.
/// See [this issue](https://github.com/FooSoft/anki-connect/issues/82) for further details.
/// As a workaround, [crate::graphical_actions::gui_browse] can be used to switch to an unrelated note and back for the new information to be reflected.
/// Modify the fields of an existing note.
///
/// You can also include audio, video, or picture files which will be added to the note.
/// Please see the documentation for [add_note] for an explanation of objects in the `audio`, `video`, or `picture` array.
///
/// *Note:* These changes will not reflect in the note currently opened in the _Card Browser_ dialog.
/// See [this issue](https://github.com/FooSoft/anki-connect/issues/82) for further details.
/// As a workaround, [crate::graphical_actions::gui_browse] can be used to switch to an unrelated note and back for the new information to be reflected.
/// Updates a note's model, fields, and tags.
///
/// This allows you to change the note's model, update its fields with new content, and set new tags.
/// Replaces a note's tags.
///
/// Old tags will be removed.