@silverfish-app/sdk 1.0.0
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/README.md +61 -0
- package/dist/chunk-IUKKL5SW.js +997 -0
- package/dist/chunk-IUKKL5SW.js.map +1 -0
- package/dist/client/index.cjs +1006 -0
- package/dist/client/index.cjs.map +1 -0
- package/dist/client/index.d.cts +60 -0
- package/dist/client/index.d.ts +60 -0
- package/dist/client/index.js +3 -0
- package/dist/client/index.js.map +1 -0
- package/dist/index.cjs +1130 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1432 -0
- package/dist/index.d.ts +1432 -0
- package/dist/index.js +329 -0
- package/dist/index.js.map +1 -0
- package/dist/types.gen-Bfm1raMe.d.cts +347 -0
- package/dist/types.gen-Bfm1raMe.d.ts +347 -0
- package/openapi.json +2197 -0
- package/package.json +41 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import { createClient, createConfig, formDataBodySerializer } from './chunk-IUKKL5SW.js';
|
|
2
|
+
|
|
3
|
+
// src/client.gen.ts
|
|
4
|
+
var client = createClient(createConfig());
|
|
5
|
+
|
|
6
|
+
// src/sdk.gen.ts
|
|
7
|
+
var HeyApiClient = class {
|
|
8
|
+
client;
|
|
9
|
+
constructor(args) {
|
|
10
|
+
this.client = args?.client ?? client;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
var HeyApiRegistry = class {
|
|
14
|
+
defaultKey = "default";
|
|
15
|
+
instances = /* @__PURE__ */ new Map();
|
|
16
|
+
get(key) {
|
|
17
|
+
const instance = this.instances.get(key ?? this.defaultKey);
|
|
18
|
+
if (!instance) {
|
|
19
|
+
throw new Error(`No SDK client found. Create one with "new Sdk()" to fix this error.`);
|
|
20
|
+
}
|
|
21
|
+
return instance;
|
|
22
|
+
}
|
|
23
|
+
set(value, key) {
|
|
24
|
+
this.instances.set(key ?? this.defaultKey, value);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
var Sdk = class _Sdk extends HeyApiClient {
|
|
28
|
+
static __registry = new HeyApiRegistry();
|
|
29
|
+
constructor(args) {
|
|
30
|
+
super(args);
|
|
31
|
+
_Sdk.__registry.set(this, args?.key);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* List Books
|
|
35
|
+
*
|
|
36
|
+
* List books, paginated and sorted.
|
|
37
|
+
*
|
|
38
|
+
* Returns a page of books controlled by `page` and `page_size`, ordered by
|
|
39
|
+
* `sort` field in the given `direction`. Out-of-range pagination values are
|
|
40
|
+
* rejected with `422`.
|
|
41
|
+
*/
|
|
42
|
+
listBooks(options) {
|
|
43
|
+
return (options?.client ?? this.client).get({ url: "/books", ...options });
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Upload Book
|
|
47
|
+
*
|
|
48
|
+
* Upload a book file and create a new book.
|
|
49
|
+
*
|
|
50
|
+
* Accepts a multipart `file` whose extension must be one of the allowed
|
|
51
|
+
* upload formats; metadata is extracted from the file on import. Returns the
|
|
52
|
+
* created book with `201`, `400` if the file is rejected (unsupported
|
|
53
|
+
* extension or unreadable content), or `413` if it exceeds the upload size
|
|
54
|
+
* limit.
|
|
55
|
+
*/
|
|
56
|
+
uploadBook(options) {
|
|
57
|
+
return (options.client ?? this.client).post({
|
|
58
|
+
...formDataBodySerializer,
|
|
59
|
+
url: "/books",
|
|
60
|
+
...options,
|
|
61
|
+
headers: {
|
|
62
|
+
"Content-Type": null,
|
|
63
|
+
...options.headers
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Delete Book
|
|
69
|
+
*
|
|
70
|
+
* Delete a book and all of its files.
|
|
71
|
+
*
|
|
72
|
+
* Removes the book identified by `book_id` along with its stored formats and
|
|
73
|
+
* cover, returning `204` with no body on success. Responds with `404` when the
|
|
74
|
+
* book does not exist.
|
|
75
|
+
*/
|
|
76
|
+
deleteBook(options) {
|
|
77
|
+
return (options.client ?? this.client).delete({ url: "/books/{book_id}", ...options });
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get Book
|
|
81
|
+
*
|
|
82
|
+
* Get a single book by its public id.
|
|
83
|
+
*
|
|
84
|
+
* Looks up the book identified by `book_id` (the book's public id) and returns
|
|
85
|
+
* its full metadata. Responds with `404` when no such book exists.
|
|
86
|
+
*/
|
|
87
|
+
getBook(options) {
|
|
88
|
+
return (options.client ?? this.client).get({ url: "/books/{book_id}", ...options });
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Update Book
|
|
92
|
+
*
|
|
93
|
+
* Partially update a book's metadata.
|
|
94
|
+
*
|
|
95
|
+
* Applies only the fields explicitly set in the request body, leaving omitted
|
|
96
|
+
* fields untouched, and returns the updated book. Responds with `400` when the
|
|
97
|
+
* patch is empty or violates a domain rule (e.g. an out-of-range `rating`),
|
|
98
|
+
* and `404` when the book does not exist.
|
|
99
|
+
*/
|
|
100
|
+
updateBook(options) {
|
|
101
|
+
return (options.client ?? this.client).patch({
|
|
102
|
+
url: "/books/{book_id}",
|
|
103
|
+
...options,
|
|
104
|
+
headers: {
|
|
105
|
+
"Content-Type": "application/json",
|
|
106
|
+
...options.headers
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Convert Book
|
|
112
|
+
*
|
|
113
|
+
* Convert a book to another format.
|
|
114
|
+
*
|
|
115
|
+
* Enqueues a background conversion to `target_format`, optionally from an
|
|
116
|
+
* explicit `source_format` (otherwise the best available source is chosen), and
|
|
117
|
+
* returns `202` with a job to poll at `/jobs/{id}`. Responds with `404` if the
|
|
118
|
+
* book is missing, `503` if `ebook-convert` is unavailable, `409` if the target
|
|
119
|
+
* format already exists or an identical conversion is already in progress, and
|
|
120
|
+
* `400` if no suitable source format is available.
|
|
121
|
+
*/
|
|
122
|
+
convertBook(options) {
|
|
123
|
+
return (options.client ?? this.client).post({
|
|
124
|
+
url: "/books/{book_id}/convert",
|
|
125
|
+
...options,
|
|
126
|
+
headers: {
|
|
127
|
+
"Content-Type": "application/json",
|
|
128
|
+
...options.headers
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Get Book Cover
|
|
134
|
+
*
|
|
135
|
+
* Download a book's cover image.
|
|
136
|
+
*
|
|
137
|
+
* Returns the cover bytes as `image/jpeg` for the book identified by
|
|
138
|
+
* `book_id`. Responds with `404` when the book has no recorded cover or the
|
|
139
|
+
* cover file is missing from storage.
|
|
140
|
+
*/
|
|
141
|
+
getBookCover(options) {
|
|
142
|
+
return (options.client ?? this.client).get({ url: "/books/{book_id}/cover", ...options });
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Delete Book Format
|
|
146
|
+
*
|
|
147
|
+
* Delete one format of a book.
|
|
148
|
+
*
|
|
149
|
+
* Removes the file for the given `book_format` of the book identified by
|
|
150
|
+
* `book_id`, returning `204` with no body on success. Responds with `404` when
|
|
151
|
+
* the book does not exist or it has no such format.
|
|
152
|
+
*/
|
|
153
|
+
deleteBookFormat(options) {
|
|
154
|
+
return (options.client ?? this.client).delete({ url: "/books/{book_id}/formats/{book_format}", ...options });
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Download Book Format
|
|
158
|
+
*
|
|
159
|
+
* Download one format of a book.
|
|
160
|
+
*
|
|
161
|
+
* Returns the file for the given `book_format` of the book identified by
|
|
162
|
+
* `book_id` as an `application/octet-stream` attachment, with the stored
|
|
163
|
+
* filename in the `Content-Disposition` header. Responds with `404` when the
|
|
164
|
+
* book lacks that format or the file is missing from storage.
|
|
165
|
+
*/
|
|
166
|
+
downloadBookFormat(options) {
|
|
167
|
+
return (options.client ?? this.client).get({ url: "/books/{book_id}/formats/{book_format}", ...options });
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Refresh Metadata
|
|
171
|
+
*
|
|
172
|
+
* Re-extract metadata from a book file and return the updated book.
|
|
173
|
+
*
|
|
174
|
+
* Reads metadata afresh from the book's `source_format` file and merges it in:
|
|
175
|
+
* fields the extraction produced replace the current ones, fields it could not
|
|
176
|
+
* read are kept. Responds with `404` when the book or requested format is not
|
|
177
|
+
* found, and `400` for any other refresh failure.
|
|
178
|
+
*/
|
|
179
|
+
refreshMetadata(options) {
|
|
180
|
+
return (options.client ?? this.client).post({
|
|
181
|
+
url: "/books/{book_id}/refresh-metadata",
|
|
182
|
+
...options,
|
|
183
|
+
headers: {
|
|
184
|
+
"Content-Type": "application/json",
|
|
185
|
+
...options.headers
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Send Book
|
|
191
|
+
*
|
|
192
|
+
* Email a book to a recipient.
|
|
193
|
+
*
|
|
194
|
+
* Enqueues a background job to send the book to `to_email` in the requested
|
|
195
|
+
* `format` (or the best available sendable format if unspecified), and returns
|
|
196
|
+
* `202` with a job to poll at `/jobs/{id}`. Responds with `404` if the book is
|
|
197
|
+
* missing, `503` if SMTP is not configured, and `400` if the book has no
|
|
198
|
+
* matching or sendable format.
|
|
199
|
+
*/
|
|
200
|
+
sendBook(options) {
|
|
201
|
+
return (options.client ?? this.client).post({
|
|
202
|
+
url: "/books/{book_id}/send",
|
|
203
|
+
...options,
|
|
204
|
+
headers: {
|
|
205
|
+
"Content-Type": "application/json",
|
|
206
|
+
...options.headers
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Get Email Config
|
|
212
|
+
*
|
|
213
|
+
* Return the non-secret SMTP settings for display.
|
|
214
|
+
*
|
|
215
|
+
* Reports whether SMTP is `configured` along with `host`, `port`,
|
|
216
|
+
* `from_address` (falling back to the username when no explicit from is set)
|
|
217
|
+
* and `security`. The password is never read or returned.
|
|
218
|
+
*/
|
|
219
|
+
getEmailConfig(options) {
|
|
220
|
+
return (options?.client ?? this.client).get({ url: "/config/email", ...options });
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Test Email Config
|
|
224
|
+
*
|
|
225
|
+
* Send a test email to verify SMTP connectivity.
|
|
226
|
+
*
|
|
227
|
+
* Sends a test message to `to_email` and returns 204 on success. Responds 503
|
|
228
|
+
* if SMTP is not configured, or 502 if the connection, authentication or send
|
|
229
|
+
* fails.
|
|
230
|
+
*/
|
|
231
|
+
testEmailConfig(options) {
|
|
232
|
+
return (options.client ?? this.client).post({
|
|
233
|
+
url: "/config/email/test",
|
|
234
|
+
...options,
|
|
235
|
+
headers: {
|
|
236
|
+
"Content-Type": "application/json",
|
|
237
|
+
...options.headers
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Start Export
|
|
243
|
+
*
|
|
244
|
+
* Start an async Calibre export; the download link is emailed when ready.
|
|
245
|
+
*
|
|
246
|
+
* Enqueues a background job that snapshots the requested books (or the whole
|
|
247
|
+
* library when `book_ids` is omitted) to a zip and emails a time-limited link
|
|
248
|
+
* to `to_email`, returning 202 with the new job. Responds 503 when export is
|
|
249
|
+
* unavailable (the calibredb binary is missing, SMTP is not configured, or no
|
|
250
|
+
* public base URL is set for an absolute link), and 400 for a malformed book id.
|
|
251
|
+
*/
|
|
252
|
+
startExport(options) {
|
|
253
|
+
return (options.client ?? this.client).post({
|
|
254
|
+
url: "/export/calibre",
|
|
255
|
+
...options,
|
|
256
|
+
headers: {
|
|
257
|
+
"Content-Type": "application/json",
|
|
258
|
+
...options.headers
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Download Export
|
|
264
|
+
*
|
|
265
|
+
* Stream a finished export zip for a valid, unexpired token.
|
|
266
|
+
*
|
|
267
|
+
* Served via ``FileResponse``, which streams the file and honours HTTP Range
|
|
268
|
+
* requests, so a large download is memory-light and resumable.
|
|
269
|
+
*/
|
|
270
|
+
downloadExport(options) {
|
|
271
|
+
return (options.client ?? this.client).get({ url: "/export/download/{token}", ...options });
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Health
|
|
275
|
+
*
|
|
276
|
+
* Report liveness and the availability of optional dependencies.
|
|
277
|
+
*
|
|
278
|
+
* Always returns `status` ``"ok"`` and the API `version`, plus the
|
|
279
|
+
* Calibre binary availability (`convert_available`, `metadata_available`)
|
|
280
|
+
* and whether send-to-ereader is usable (`send_available`, true when SMTP
|
|
281
|
+
* is configured).
|
|
282
|
+
*/
|
|
283
|
+
health(options) {
|
|
284
|
+
return (options?.client ?? this.client).get({ url: "/health", ...options });
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Get Job
|
|
288
|
+
*
|
|
289
|
+
* Return the current status and progress of a single job.
|
|
290
|
+
*
|
|
291
|
+
* Looks up the job by `job_id` and returns its latest state for one-shot
|
|
292
|
+
* polling. Responds 404 if no job with that id exists; use `/jobs/{job_id}/stream`
|
|
293
|
+
* instead to follow progress live.
|
|
294
|
+
*/
|
|
295
|
+
getJob(options) {
|
|
296
|
+
return (options.client ?? this.client).get({ url: "/jobs/{job_id}", ...options });
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Stream Job
|
|
300
|
+
*
|
|
301
|
+
* Stream a job's status/progress as Server-Sent Events until it finishes.
|
|
302
|
+
*
|
|
303
|
+
* One open connection replaces repeated polling. Updates are event-driven: the
|
|
304
|
+
* stream blocks (in a threadpool, so the event loop stays free) until the job
|
|
305
|
+
* actually changes, then emits — so it reflects each new binary output, not a
|
|
306
|
+
* fixed tick.
|
|
307
|
+
*/
|
|
308
|
+
streamJob(options) {
|
|
309
|
+
return (options.client ?? this.client).get({ url: "/jobs/{job_id}/stream", ...options });
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Search Books
|
|
313
|
+
*
|
|
314
|
+
* Search books by a text query and filters.
|
|
315
|
+
*
|
|
316
|
+
* Returns a paginated page of books whose title, author, series or tags match
|
|
317
|
+
* the query `q` (case-insensitive substring match), narrowed by the optional
|
|
318
|
+
* `include_tags`, `exclude_tags`, `languages`, `formats`, and
|
|
319
|
+
* `rating_min`/`rating_max` filters. Out-of-range pagination or rating values
|
|
320
|
+
* are rejected with `422`.
|
|
321
|
+
*/
|
|
322
|
+
searchBooks(options) {
|
|
323
|
+
return (options?.client ?? this.client).get({ url: "/search", ...options });
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
export { Sdk };
|
|
328
|
+
//# sourceMappingURL=index.js.map
|
|
329
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/client.gen.ts","../src/sdk.gen.ts"],"names":[],"mappings":";;;AAeO,IAAM,MAAA,GAAiB,YAAA,CAAa,YAAA,EAA8B,CAAA;;;ACKzE,IAAM,eAAN,MAAmB;AAAA,EACL,MAAA;AAAA,EAEV,YAAY,IAAA,EAET;AACC,IAAA,IAAA,CAAK,MAAA,GAAS,MAAM,MAAA,IAAU,MAAA;AAAA,EAClC;AACJ,CAAA;AAEA,IAAM,iBAAN,MAAwB;AAAA,EACH,UAAA,GAAa,SAAA;AAAA,EAEb,SAAA,uBAAgC,GAAA,EAAI;AAAA,EAErD,IAAI,GAAA,EAAiB;AACjB,IAAA,MAAM,WAAW,IAAA,CAAK,SAAA,CAAU,GAAA,CAAI,GAAA,IAAO,KAAK,UAAU,CAAA;AAC1D,IAAA,IAAI,CAAC,QAAA,EAAU;AACX,MAAA,MAAM,IAAI,MAAM,CAAA,mEAAA,CAAqE,CAAA;AAAA,IACzF;AACA,IAAA,OAAO,QAAA;AAAA,EACX;AAAA,EAEA,GAAA,CAAI,OAAU,GAAA,EAAoB;AAC9B,IAAA,IAAA,CAAK,SAAA,CAAU,GAAA,CAAI,GAAA,IAAO,IAAA,CAAK,YAAY,KAAK,CAAA;AAAA,EACpD;AACJ,CAAA;AAEO,IAAM,GAAA,GAAN,MAAM,IAAA,SAAY,YAAA,CAA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,CAAA;AAAA,EAC3H;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWO,OAA6C,OAAA,EAAwG;AACxJ,IAAA,OAAA,CAAQ,OAAA,CAAQ,MAAA,IAAU,IAAA,CAAK,MAAA,EAAQ,GAAA,CAAiD,EAAE,GAAA,EAAK,gBAAA,EAAkB,GAAG,OAAA,EAAS,CAAA;AAAA,EACjI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYO,UAAgD,OAAA,EAAiH;AACpK,IAAA,OAAA,CAAQ,OAAA,CAAQ,MAAA,IAAU,IAAA,CAAK,MAAA,EAAQ,GAAA,CAAuD,EAAE,GAAA,EAAK,uBAAA,EAAyB,GAAG,OAAA,EAAS,CAAA;AAAA,EAC9I;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaO,YAAkD,OAAA,EAAwH;AAC7K,IAAA,OAAA,CAAQ,OAAA,EAAS,MAAA,IAAU,IAAA,CAAK,MAAA,EAAQ,GAAA,CAA2D,EAAE,GAAA,EAAK,SAAA,EAAW,GAAG,OAAA,EAAS,CAAA;AAAA,EACrI;AACJ","file":"index.js","sourcesContent":["// This file is auto-generated by @hey-api/openapi-ts\n\nimport { type Client, type ClientOptions, type Config, createClient, createConfig } from './client';\nimport type { ClientOptions as ClientOptions2 } from './types.gen';\n\n/**\n * The `createClientConfig()` function will be called on client initialization\n * and the returned object will become the client's initial configuration.\n *\n * You may want to initialize your client this way instead of calling\n * `setConfig()`. This is useful for example if you're using Next.js\n * to ensure your client always has the correct values.\n */\nexport type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;\n\nexport const client: Client = createClient(createConfig<ClientOptions2>());\n","// This file is auto-generated by @hey-api/openapi-ts\n\nimport { type Client, type ClientMeta, formDataBodySerializer, type Options as Options2, type RequestResult, type TDataShape } from './client';\nimport { client } from './client.gen';\nimport type { ConvertBookData, ConvertBookErrors, ConvertBookResponses, DeleteBookData, DeleteBookErrors, DeleteBookFormatData, DeleteBookFormatErrors, DeleteBookFormatResponses, DeleteBookResponses, DownloadBookFormatData, DownloadBookFormatErrors, DownloadBookFormatResponses, DownloadExportData, DownloadExportErrors, DownloadExportResponses, GetBookCoverData, GetBookCoverErrors, GetBookCoverResponses, GetBookData, GetBookErrors, GetBookResponses, GetEmailConfigData, GetEmailConfigErrors, GetEmailConfigResponses, GetJobData, GetJobErrors, GetJobResponses, HealthData, HealthErrors, HealthResponses, ListBooksData, ListBooksErrors, ListBooksResponses, RefreshMetadataData, RefreshMetadataErrors, RefreshMetadataResponses, SearchBooksData, SearchBooksErrors, SearchBooksResponses, SendBookData, SendBookErrors, SendBookResponses, StartExportData, StartExportErrors, StartExportResponses, StreamJobData, StreamJobErrors, StreamJobResponses, TestEmailConfigData, TestEmailConfigErrors, TestEmailConfigResponses, UpdateBookData, UpdateBookErrors, UpdateBookResponses, UploadBookData, UploadBookErrors, UploadBookResponses } from './types.gen';\n\nexport type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options2<TData, ThrowOnError, TResponse> & {\n /**\n * You can provide a client instance returned by `createClient()` instead of\n * individual options. This might be also useful if you want to implement a\n * custom client.\n */\n client?: Client;\n /**\n * You can pass arbitrary values through the `meta` object. This can be\n * used to access values that aren't defined as part of the SDK function.\n */\n meta?: keyof ClientMeta extends never ? Record<string, unknown> : ClientMeta;\n};\n\nclass HeyApiClient {\n protected client: Client;\n \n constructor(args?: {\n client?: Client;\n }) {\n this.client = args?.client ?? client;\n }\n}\n\nclass HeyApiRegistry<T> {\n private readonly defaultKey = 'default';\n \n private readonly instances: Map<string, T> = new Map();\n \n get(key?: string): T {\n const instance = this.instances.get(key ?? this.defaultKey);\n if (!instance) {\n throw new Error(`No SDK client found. Create one with \"new Sdk()\" to fix this error.`);\n }\n return instance;\n }\n \n set(value: T, key?: string): void {\n this.instances.set(key ?? this.defaultKey, value);\n }\n}\n\nexport class Sdk extends HeyApiClient {\n public static readonly __registry: HeyApiRegistry<Sdk> = new HeyApiRegistry<Sdk>();\n \n constructor(args?: {\n client?: Client;\n key?: string;\n }) {\n super(args);\n Sdk.__registry.set(this, args?.key);\n }\n \n /**\n * List Books\n *\n * List books, paginated and sorted.\n *\n * Returns a page of books controlled by `page` and `page_size`, ordered by\n * `sort` field in the given `direction`. Out-of-range pagination values are\n * rejected with `422`.\n */\n public listBooks<ThrowOnError extends boolean = false>(options?: Options<ListBooksData, ThrowOnError>): RequestResult<ListBooksResponses, ListBooksErrors, ThrowOnError> {\n return (options?.client ?? this.client).get<ListBooksResponses, ListBooksErrors, ThrowOnError>({ url: '/books', ...options });\n }\n \n /**\n * Upload Book\n *\n * Upload a book file and create a new book.\n *\n * Accepts a multipart `file` whose extension must be one of the allowed\n * upload formats; metadata is extracted from the file on import. Returns the\n * created book with `201`, `400` if the file is rejected (unsupported\n * extension or unreadable content), or `413` if it exceeds the upload size\n * limit.\n */\n public uploadBook<ThrowOnError extends boolean = false>(options: Options<UploadBookData, ThrowOnError>): RequestResult<UploadBookResponses, UploadBookErrors, ThrowOnError> {\n return (options.client ?? this.client).post<UploadBookResponses, UploadBookErrors, ThrowOnError>({\n ...formDataBodySerializer,\n url: '/books',\n ...options,\n headers: {\n 'Content-Type': null,\n ...options.headers\n }\n });\n }\n \n /**\n * Delete Book\n *\n * Delete a book and all of its files.\n *\n * Removes the book identified by `book_id` along with its stored formats and\n * cover, returning `204` with no body on success. Responds with `404` when the\n * book does not exist.\n */\n public deleteBook<ThrowOnError extends boolean = false>(options: Options<DeleteBookData, ThrowOnError>): RequestResult<DeleteBookResponses, DeleteBookErrors, ThrowOnError> {\n return (options.client ?? this.client).delete<DeleteBookResponses, DeleteBookErrors, ThrowOnError>({ url: '/books/{book_id}', ...options });\n }\n \n /**\n * Get Book\n *\n * Get a single book by its public id.\n *\n * Looks up the book identified by `book_id` (the book's public id) and returns\n * its full metadata. Responds with `404` when no such book exists.\n */\n public getBook<ThrowOnError extends boolean = false>(options: Options<GetBookData, ThrowOnError>): RequestResult<GetBookResponses, GetBookErrors, ThrowOnError> {\n return (options.client ?? this.client).get<GetBookResponses, GetBookErrors, ThrowOnError>({ url: '/books/{book_id}', ...options });\n }\n \n /**\n * Update Book\n *\n * Partially update a book's metadata.\n *\n * Applies only the fields explicitly set in the request body, leaving omitted\n * fields untouched, and returns the updated book. Responds with `400` when the\n * patch is empty or violates a domain rule (e.g. an out-of-range `rating`),\n * and `404` when the book does not exist.\n */\n public updateBook<ThrowOnError extends boolean = false>(options: Options<UpdateBookData, ThrowOnError>): RequestResult<UpdateBookResponses, UpdateBookErrors, ThrowOnError> {\n return (options.client ?? this.client).patch<UpdateBookResponses, UpdateBookErrors, ThrowOnError>({\n url: '/books/{book_id}',\n ...options,\n headers: {\n 'Content-Type': 'application/json',\n ...options.headers\n }\n });\n }\n \n /**\n * Convert Book\n *\n * Convert a book to another format.\n *\n * Enqueues a background conversion to `target_format`, optionally from an\n * explicit `source_format` (otherwise the best available source is chosen), and\n * returns `202` with a job to poll at `/jobs/{id}`. Responds with `404` if the\n * book is missing, `503` if `ebook-convert` is unavailable, `409` if the target\n * format already exists or an identical conversion is already in progress, and\n * `400` if no suitable source format is available.\n */\n public convertBook<ThrowOnError extends boolean = false>(options: Options<ConvertBookData, ThrowOnError>): RequestResult<ConvertBookResponses, ConvertBookErrors, ThrowOnError> {\n return (options.client ?? this.client).post<ConvertBookResponses, ConvertBookErrors, ThrowOnError>({\n url: '/books/{book_id}/convert',\n ...options,\n headers: {\n 'Content-Type': 'application/json',\n ...options.headers\n }\n });\n }\n \n /**\n * Get Book Cover\n *\n * Download a book's cover image.\n *\n * Returns the cover bytes as `image/jpeg` for the book identified by\n * `book_id`. Responds with `404` when the book has no recorded cover or the\n * cover file is missing from storage.\n */\n public getBookCover<ThrowOnError extends boolean = false>(options: Options<GetBookCoverData, ThrowOnError>): RequestResult<GetBookCoverResponses, GetBookCoverErrors, ThrowOnError> {\n return (options.client ?? this.client).get<GetBookCoverResponses, GetBookCoverErrors, ThrowOnError>({ url: '/books/{book_id}/cover', ...options });\n }\n \n /**\n * Delete Book Format\n *\n * Delete one format of a book.\n *\n * Removes the file for the given `book_format` of the book identified by\n * `book_id`, returning `204` with no body on success. Responds with `404` when\n * the book does not exist or it has no such format.\n */\n public deleteBookFormat<ThrowOnError extends boolean = false>(options: Options<DeleteBookFormatData, ThrowOnError>): RequestResult<DeleteBookFormatResponses, DeleteBookFormatErrors, ThrowOnError> {\n return (options.client ?? this.client).delete<DeleteBookFormatResponses, DeleteBookFormatErrors, ThrowOnError>({ url: '/books/{book_id}/formats/{book_format}', ...options });\n }\n \n /**\n * Download Book Format\n *\n * Download one format of a book.\n *\n * Returns the file for the given `book_format` of the book identified by\n * `book_id` as an `application/octet-stream` attachment, with the stored\n * filename in the `Content-Disposition` header. Responds with `404` when the\n * book lacks that format or the file is missing from storage.\n */\n public downloadBookFormat<ThrowOnError extends boolean = false>(options: Options<DownloadBookFormatData, ThrowOnError>): RequestResult<DownloadBookFormatResponses, DownloadBookFormatErrors, ThrowOnError> {\n return (options.client ?? this.client).get<DownloadBookFormatResponses, DownloadBookFormatErrors, ThrowOnError>({ url: '/books/{book_id}/formats/{book_format}', ...options });\n }\n \n /**\n * Refresh Metadata\n *\n * Re-extract metadata from a book file and return the updated book.\n *\n * Reads metadata afresh from the book's `source_format` file and merges it in:\n * fields the extraction produced replace the current ones, fields it could not\n * read are kept. Responds with `404` when the book or requested format is not\n * found, and `400` for any other refresh failure.\n */\n public refreshMetadata<ThrowOnError extends boolean = false>(options: Options<RefreshMetadataData, ThrowOnError>): RequestResult<RefreshMetadataResponses, RefreshMetadataErrors, ThrowOnError> {\n return (options.client ?? this.client).post<RefreshMetadataResponses, RefreshMetadataErrors, ThrowOnError>({\n url: '/books/{book_id}/refresh-metadata',\n ...options,\n headers: {\n 'Content-Type': 'application/json',\n ...options.headers\n }\n });\n }\n \n /**\n * Send Book\n *\n * Email a book to a recipient.\n *\n * Enqueues a background job to send the book to `to_email` in the requested\n * `format` (or the best available sendable format if unspecified), and returns\n * `202` with a job to poll at `/jobs/{id}`. Responds with `404` if the book is\n * missing, `503` if SMTP is not configured, and `400` if the book has no\n * matching or sendable format.\n */\n public sendBook<ThrowOnError extends boolean = false>(options: Options<SendBookData, ThrowOnError>): RequestResult<SendBookResponses, SendBookErrors, ThrowOnError> {\n return (options.client ?? this.client).post<SendBookResponses, SendBookErrors, ThrowOnError>({\n url: '/books/{book_id}/send',\n ...options,\n headers: {\n 'Content-Type': 'application/json',\n ...options.headers\n }\n });\n }\n \n /**\n * Get Email Config\n *\n * Return the non-secret SMTP settings for display.\n *\n * Reports whether SMTP is `configured` along with `host`, `port`,\n * `from_address` (falling back to the username when no explicit from is set)\n * and `security`. The password is never read or returned.\n */\n public getEmailConfig<ThrowOnError extends boolean = false>(options?: Options<GetEmailConfigData, ThrowOnError>): RequestResult<GetEmailConfigResponses, GetEmailConfigErrors, ThrowOnError> {\n return (options?.client ?? this.client).get<GetEmailConfigResponses, GetEmailConfigErrors, ThrowOnError>({ url: '/config/email', ...options });\n }\n \n /**\n * Test Email Config\n *\n * Send a test email to verify SMTP connectivity.\n *\n * Sends a test message to `to_email` and returns 204 on success. Responds 503\n * if SMTP is not configured, or 502 if the connection, authentication or send\n * fails.\n */\n public testEmailConfig<ThrowOnError extends boolean = false>(options: Options<TestEmailConfigData, ThrowOnError>): RequestResult<TestEmailConfigResponses, TestEmailConfigErrors, ThrowOnError> {\n return (options.client ?? this.client).post<TestEmailConfigResponses, TestEmailConfigErrors, ThrowOnError>({\n url: '/config/email/test',\n ...options,\n headers: {\n 'Content-Type': 'application/json',\n ...options.headers\n }\n });\n }\n \n /**\n * Start Export\n *\n * Start an async Calibre export; the download link is emailed when ready.\n *\n * Enqueues a background job that snapshots the requested books (or the whole\n * library when `book_ids` is omitted) to a zip and emails a time-limited link\n * to `to_email`, returning 202 with the new job. Responds 503 when export is\n * unavailable (the calibredb binary is missing, SMTP is not configured, or no\n * public base URL is set for an absolute link), and 400 for a malformed book id.\n */\n public startExport<ThrowOnError extends boolean = false>(options: Options<StartExportData, ThrowOnError>): RequestResult<StartExportResponses, StartExportErrors, ThrowOnError> {\n return (options.client ?? this.client).post<StartExportResponses, StartExportErrors, ThrowOnError>({\n url: '/export/calibre',\n ...options,\n headers: {\n 'Content-Type': 'application/json',\n ...options.headers\n }\n });\n }\n \n /**\n * Download Export\n *\n * Stream a finished export zip for a valid, unexpired token.\n *\n * Served via ``FileResponse``, which streams the file and honours HTTP Range\n * requests, so a large download is memory-light and resumable.\n */\n public downloadExport<ThrowOnError extends boolean = false>(options: Options<DownloadExportData, ThrowOnError>): RequestResult<DownloadExportResponses, DownloadExportErrors, ThrowOnError> {\n return (options.client ?? this.client).get<DownloadExportResponses, DownloadExportErrors, ThrowOnError>({ url: '/export/download/{token}', ...options });\n }\n \n /**\n * Health\n *\n * Report liveness and the availability of optional dependencies.\n *\n * Always returns `status` ``\"ok\"`` and the API `version`, plus the\n * Calibre binary availability (`convert_available`, `metadata_available`)\n * and whether send-to-ereader is usable (`send_available`, true when SMTP\n * is configured).\n */\n public health<ThrowOnError extends boolean = false>(options?: Options<HealthData, ThrowOnError>): RequestResult<HealthResponses, HealthErrors, ThrowOnError> {\n return (options?.client ?? this.client).get<HealthResponses, HealthErrors, ThrowOnError>({ url: '/health', ...options });\n }\n \n /**\n * Get Job\n *\n * Return the current status and progress of a single job.\n *\n * Looks up the job by `job_id` and returns its latest state for one-shot\n * polling. Responds 404 if no job with that id exists; use `/jobs/{job_id}/stream`\n * instead to follow progress live.\n */\n public getJob<ThrowOnError extends boolean = false>(options: Options<GetJobData, ThrowOnError>): RequestResult<GetJobResponses, GetJobErrors, ThrowOnError> {\n return (options.client ?? this.client).get<GetJobResponses, GetJobErrors, ThrowOnError>({ url: '/jobs/{job_id}', ...options });\n }\n \n /**\n * Stream Job\n *\n * Stream a job's status/progress as Server-Sent Events until it finishes.\n *\n * One open connection replaces repeated polling. Updates are event-driven: the\n * stream blocks (in a threadpool, so the event loop stays free) until the job\n * actually changes, then emits — so it reflects each new binary output, not a\n * fixed tick.\n */\n public streamJob<ThrowOnError extends boolean = false>(options: Options<StreamJobData, ThrowOnError>): RequestResult<StreamJobResponses, StreamJobErrors, ThrowOnError> {\n return (options.client ?? this.client).get<StreamJobResponses, StreamJobErrors, ThrowOnError>({ url: '/jobs/{job_id}/stream', ...options });\n }\n \n /**\n * Search Books\n *\n * Search books by a text query and filters.\n *\n * Returns a paginated page of books whose title, author, series or tags match\n * the query `q` (case-insensitive substring match), narrowed by the optional\n * `include_tags`, `exclude_tags`, `languages`, `formats`, and\n * `rating_min`/`rating_max` filters. Out-of-range pagination or rating values\n * are rejected with `422`.\n */\n public searchBooks<ThrowOnError extends boolean = false>(options?: Options<SearchBooksData, ThrowOnError>): RequestResult<SearchBooksResponses, SearchBooksErrors, ThrowOnError> {\n return (options?.client ?? this.client).get<SearchBooksResponses, SearchBooksErrors, ThrowOnError>({ url: '/search', ...options });\n }\n}\n"]}
|