@book000/pixivts 0.59.4 → 0.60.0-beta.10

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/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ //#region src/result.d.ts
1
2
  /**
2
3
  * Zero-dependency Result / ResultAsync implementation.
3
4
  *
@@ -17,41 +18,41 @@
17
18
  */
18
19
  /** Successful result carrying `value`. */
19
20
  interface OkResult<T> {
20
- /** Always `true` — use this to narrow the union to `OkResult<T>`. */
21
- readonly isOk: true;
22
- /** Always `false` — use this to narrow the union to `OkResult<T>`. */
23
- readonly isErr: false;
24
- /** The success value. */
25
- readonly value: T;
26
- /** Returns an `OkResult` with `fn(value)`. */
27
- map<U>(fn: (value: T) => U): OkResult<U>;
28
- /** Returns `this` unchanged. */
29
- mapErr<F>(_fn: (error: never) => F): OkResult<T>;
30
- /** Calls `fn(value)` and returns its Result. */
31
- andThen<U, F>(fn: (value: T) => Result<U, F>): Result<U, F>;
32
- /** Calls `onOk` and returns its result. */
33
- match<U>(onOk: (value: T) => U, _onErr: (error: never) => U): U;
34
- /** Returns `value`. */
35
- unwrapOr(_fallback: T): T;
21
+ /** Always `true` — use this to narrow the union to `OkResult<T>`. */
22
+ readonly isOk: true;
23
+ /** Always `false` — use this to narrow the union to `OkResult<T>`. */
24
+ readonly isErr: false;
25
+ /** The success value. */
26
+ readonly value: T;
27
+ /** Returns an `OkResult` with `fn(value)`. */
28
+ map<U>(fn: (value: T) => U): OkResult<U>;
29
+ /** Returns `this` unchanged. */
30
+ mapErr<F>(_fn: (error: never) => F): OkResult<T>;
31
+ /** Calls `fn(value)` and returns its Result. */
32
+ andThen<U, F>(fn: (value: T) => Result<U, F>): Result<U, F>;
33
+ /** Calls `onOk` and returns its result. */
34
+ match<U>(onOk: (value: T) => U, _onErr: (error: never) => U): U;
35
+ /** Returns `value`. */
36
+ unwrapOr(_fallback: T): T;
36
37
  }
37
38
  /** Failed result carrying `error`. */
38
39
  interface ErrResult<E> {
39
- /** Always `false` — use this to narrow the union to `ErrResult<E>`. */
40
- readonly isOk: false;
41
- /** Always `true` — use this to narrow the union to `ErrResult<E>`. */
42
- readonly isErr: true;
43
- /** The error value. */
44
- readonly error: E;
45
- /** Returns `this` unchanged. */
46
- map<U>(_fn: (value: never) => U): ErrResult<E>;
47
- /** Returns an `ErrResult` with `fn(error)`. */
48
- mapErr<F>(fn: (error: E) => F): ErrResult<F>;
49
- /** Returns `this` unchanged. */
50
- andThen<U, F>(_fn: (value: never) => Result<U, F>): ErrResult<E>;
51
- /** Calls `onErr` and returns its result. */
52
- match<U>(_onOk: (value: never) => U, onErr: (error: E) => U): U;
53
- /** Returns `fallback`. */
54
- unwrapOr<T>(fallback: T): T;
40
+ /** Always `false` — use this to narrow the union to `ErrResult<E>`. */
41
+ readonly isOk: false;
42
+ /** Always `true` — use this to narrow the union to `ErrResult<E>`. */
43
+ readonly isErr: true;
44
+ /** The error value. */
45
+ readonly error: E;
46
+ /** Returns `this` unchanged. */
47
+ map<U>(_fn: (value: never) => U): ErrResult<E>;
48
+ /** Returns an `ErrResult` with `fn(error)`. */
49
+ mapErr<F>(fn: (error: E) => F): ErrResult<F>;
50
+ /** Returns `this` unchanged. */
51
+ andThen<U, F>(_fn: (value: never) => Result<U, F>): ErrResult<E>;
52
+ /** Calls `onErr` and returns its result. */
53
+ match<U>(_onOk: (value: never) => U, onErr: (error: E) => U): U;
54
+ /** Returns `fallback`. */
55
+ unwrapOr<T>(fallback: T): T;
55
56
  }
56
57
  /** A value that is either `OkResult<T>` or `ErrResult<E>`. */
57
58
  type Result<T, E> = OkResult<T> | ErrResult<E>;
@@ -80,64 +81,65 @@ declare function err<E>(error: E): ErrResult<E>;
80
81
  * ```
81
82
  */
82
83
  declare class ResultAsync<T, E> implements PromiseLike<Result<T, E>> {
83
- private readonly _promise;
84
- constructor(promise: Promise<Result<T, E>>);
85
- then<TResult1 = Result<T, E>, TResult2 = never>(onfulfilled?: ((value: Result<T, E>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): PromiseLike<TResult1 | TResult2>;
86
- /**
87
- * Wraps a `Promise<T>` into a `ResultAsync<T, E>`.
88
- *
89
- * If the promise rejects, `onError` maps the rejection reason to `E`.
90
- *
91
- * @param promise - The promise to wrap
92
- * @param onError - Error mapper
93
- */
94
- static fromPromise<T, E>(promise: Promise<T>, onError: (reason: unknown) => E): ResultAsync<T, E>;
95
- /**
96
- * Wraps an already-resolved `Result<T, E>` into a `ResultAsync<T, E>`.
97
- *
98
- * @param result - The result to wrap
99
- */
100
- static fromResult<T, E>(result: Result<T, E>): ResultAsync<T, E>;
101
- /**
102
- * Transforms the success value.
103
- *
104
- * If the inner result is `Err`, `fn` is not called.
105
- *
106
- * @param fn - Synchronous mapper
107
- */
108
- map<U>(fn: (value: T) => U): ResultAsync<U, E>;
109
- /**
110
- * Transforms the error value.
111
- *
112
- * If the inner result is `Ok`, `fn` is not called.
113
- *
114
- * @param fn - Synchronous error mapper
115
- */
116
- mapErr<F>(fn: (error: E) => F): ResultAsync<T, F>;
117
- /**
118
- * Chains another async operation that may fail.
119
- *
120
- * If the inner result is `Err`, `fn` is not called.
121
- *
122
- * @param fn - Async mapper that returns a `ResultAsync<U, F>`
123
- */
124
- andThen<U, F>(fn: (value: T) => ResultAsync<U, F> | Result<U, F>): ResultAsync<U, E | F>;
125
- /**
126
- * Pattern-matches on success / failure.
127
- *
128
- * @param onOk - Called with the success value
129
- * @param onErr - Called with the error value
130
- * @returns A `Promise<U>`
131
- */
132
- match<U>(onOk: (value: T) => U | Promise<U>, onErr: (error: E) => U | Promise<U>): Promise<U>;
133
- /**
134
- * Returns the success value, or `fallback` if the result is `Err`.
135
- *
136
- * @param fallback - The fallback value
137
- */
138
- unwrapOr(fallback: T): Promise<T>;
139
- }
140
-
84
+ private readonly _promise;
85
+ constructor(promise: Promise<Result<T, E>>);
86
+ then<TResult1 = Result<T, E>, TResult2 = never>(onfulfilled?: ((value: Result<T, E>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): PromiseLike<TResult1 | TResult2>;
87
+ /**
88
+ * Wraps a `Promise<T>` into a `ResultAsync<T, E>`.
89
+ *
90
+ * If the promise rejects, `onError` maps the rejection reason to `E`.
91
+ *
92
+ * @param promise - The promise to wrap
93
+ * @param onError - Error mapper
94
+ */
95
+ static fromPromise<T, E>(promise: Promise<T>, onError: (reason: unknown) => E): ResultAsync<T, E>;
96
+ /**
97
+ * Wraps an already-resolved `Result<T, E>` into a `ResultAsync<T, E>`.
98
+ *
99
+ * @param result - The result to wrap
100
+ */
101
+ static fromResult<T, E>(result: Result<T, E>): ResultAsync<T, E>;
102
+ /**
103
+ * Transforms the success value.
104
+ *
105
+ * If the inner result is `Err`, `fn` is not called.
106
+ *
107
+ * @param fn - Synchronous mapper
108
+ */
109
+ map<U>(fn: (value: T) => U): ResultAsync<U, E>;
110
+ /**
111
+ * Transforms the error value.
112
+ *
113
+ * If the inner result is `Ok`, `fn` is not called.
114
+ *
115
+ * @param fn - Synchronous error mapper
116
+ */
117
+ mapErr<F>(fn: (error: E) => F): ResultAsync<T, F>;
118
+ /**
119
+ * Chains another async operation that may fail.
120
+ *
121
+ * If the inner result is `Err`, `fn` is not called.
122
+ *
123
+ * @param fn - Async mapper that returns a `ResultAsync<U, F>`
124
+ */
125
+ andThen<U, F>(fn: (value: T) => ResultAsync<U, F> | Result<U, F>): ResultAsync<U, E | F>;
126
+ /**
127
+ * Pattern-matches on success / failure.
128
+ *
129
+ * @param onOk - Called with the success value
130
+ * @param onErr - Called with the error value
131
+ * @returns A `Promise<U>`
132
+ */
133
+ match<U>(onOk: (value: T) => U | Promise<U>, onErr: (error: E) => U | Promise<U>): Promise<U>;
134
+ /**
135
+ * Returns the success value, or `fallback` if the result is `Err`.
136
+ *
137
+ * @param fallback - The fallback value
138
+ */
139
+ unwrapOr(fallback: T): Promise<T>;
140
+ }
141
+ //#endregion
142
+ //#region src/auth.d.ts
141
143
  /**
142
144
  * Authentication manager for the pixiv API.
143
145
  *
@@ -150,12 +152,12 @@ declare class ResultAsync<T, E> implements PromiseLike<Result<T, E>> {
150
152
  */
151
153
  /** Auth credentials returned by the pixiv token endpoint. */
152
154
  interface AuthCredentials {
153
- /** Numeric user ID returned as a string by the token endpoint. */
154
- userId: string;
155
- /** Short-lived bearer token for API requests. */
156
- accessToken: string;
157
- /** Long-lived token used to obtain new access tokens. */
158
- refreshToken: string;
155
+ /** Numeric user ID returned as a string by the token endpoint. */
156
+ userId: string;
157
+ /** Short-lived bearer token for API requests. */
158
+ accessToken: string;
159
+ /** Long-lived token used to obtain new access tokens. */
160
+ refreshToken: string;
159
161
  }
160
162
  /**
161
163
  * Manages access tokens for the pixiv API.
@@ -165,29 +167,30 @@ interface AuthCredentials {
165
167
  * via the pixiv OAuth endpoint.
166
168
  */
167
169
  declare class AuthManager {
168
- #private;
169
- userId: string;
170
- constructor(credentials: AuthCredentials);
171
- /** Returns the current access token. */
172
- get accessToken(): string;
173
- /** Returns the current refresh token. */
174
- get refreshToken(): string;
175
- /**
176
- * Exchanges the stored refresh token for a fresh access token.
177
- *
178
- * Updates the internal credentials on success.
179
- * Throws if the token endpoint returns a non-200 response.
180
- */
181
- refresh(): Promise<void>;
182
- /**
183
- * Creates an `AuthManager` by performing the initial token refresh.
184
- *
185
- * @param refreshToken - Pixiv refresh token
186
- * @returns Initialized `AuthManager`
187
- */
188
- static login(refreshToken: string): Promise<AuthManager>;
189
- }
190
-
170
+ #private;
171
+ userId: string;
172
+ constructor(credentials: AuthCredentials);
173
+ /** Returns the current access token. */
174
+ get accessToken(): string;
175
+ /** Returns the current refresh token. */
176
+ get refreshToken(): string;
177
+ /**
178
+ * Exchanges the stored refresh token for a fresh access token.
179
+ *
180
+ * Updates the internal credentials on success.
181
+ * Throws if the token endpoint returns a non-200 response.
182
+ */
183
+ refresh(): Promise<void>;
184
+ /**
185
+ * Creates an `AuthManager` by performing the initial token refresh.
186
+ *
187
+ * @param refreshToken - Pixiv refresh token
188
+ * @returns Initialized `AuthManager`
189
+ */
190
+ static login(refreshToken: string): Promise<AuthManager>;
191
+ }
192
+ //#endregion
193
+ //#region src/interceptor.d.ts
191
194
  /**
192
195
  * Response interceptor types for the pixiv API client.
193
196
  *
@@ -209,24 +212,24 @@ type HttpMethod = 'GET' | 'POST';
209
212
  * HTTP call made by the pixiv client.
210
213
  */
211
214
  interface ResponseRecord {
212
- /** HTTP method used for the request. */
213
- method: HttpMethod;
214
- /** API endpoint path (e.g. "/v1/illust/detail"). */
215
- endpoint: string;
216
- /** Full request URL including query string (null if unavailable). */
217
- url: string | null;
218
- /** JSON-serialized request headers (null if unavailable). */
219
- requestHeaders: string | null;
220
- /** URL-encoded request body for POST requests (null for GET). */
221
- requestBody: string | null;
222
- /** Whether the response body was parsed as JSON or left as plain text. */
223
- responseType: 'JSON' | 'TEXT';
224
- /** HTTP response status code. */
225
- statusCode: number;
226
- /** JSON-serialized response headers (null if unavailable). */
227
- responseHeaders: string | null;
228
- /** Serialized response body. */
229
- responseBody: string;
215
+ /** HTTP method used for the request. */
216
+ method: HttpMethod;
217
+ /** API endpoint path (e.g. "/v1/illust/detail"). */
218
+ endpoint: string;
219
+ /** Full request URL including query string (null if unavailable). */
220
+ url: string | null;
221
+ /** JSON-serialized request headers (null if unavailable). */
222
+ requestHeaders: string | null;
223
+ /** URL-encoded request body for POST requests (null for GET). */
224
+ requestBody: string | null;
225
+ /** Whether the response body was parsed as JSON or left as plain text. */
226
+ responseType: 'JSON' | 'TEXT';
227
+ /** HTTP response status code. */
228
+ statusCode: number;
229
+ /** JSON-serialized response headers (null if unavailable). */
230
+ responseHeaders: string | null;
231
+ /** Serialized response body. */
232
+ responseBody: string;
230
233
  }
231
234
  /**
232
235
  * A callback invoked after every successful API response.
@@ -236,7 +239,8 @@ interface ResponseRecord {
236
239
  * asynchronously if persistence latency matters.
237
240
  */
238
241
  type ResponseInterceptor = (record: ResponseRecord) => void | Promise<void>;
239
-
242
+ //#endregion
243
+ //#region src/errors.d.ts
240
244
  /**
241
245
  * Discriminated union of all errors that can occur when using the pixiv API client.
242
246
  *
@@ -249,27 +253,18 @@ type ResponseInterceptor = (record: ResponseRecord) => void | Promise<void>;
249
253
  * ```
250
254
  */
251
255
  type PixivError = {
252
- /** The request hit the rate limit and exhausted all retries. */
253
- type: 'rate_limit';
254
- /** Retry-After duration parsed from the last 429 response (milliseconds). */
255
- retryAfter: number;
256
+ /** The request hit the rate limit and exhausted all retries. */type: 'rate_limit'; /** Retry-After duration parsed from the last 429 response (milliseconds). */
257
+ retryAfter: number;
256
258
  } | {
257
- /** Authentication failed (401 response that could not be refreshed). */
258
- type: 'auth_failed';
259
- /** HTTP status code (always 401). */
260
- status: number;
259
+ /** Authentication failed (401 response that could not be refreshed). */type: 'auth_failed'; /** HTTP status code (always 401). */
260
+ status: number;
261
261
  } | {
262
- /** A network-level error occurred (fetch threw). */
263
- type: 'network';
264
- /** The underlying error thrown by fetch. */
265
- cause: unknown;
262
+ /** A network-level error occurred (fetch threw). */type: 'network'; /** The underlying error thrown by fetch. */
263
+ cause: unknown;
266
264
  } | {
267
- /** The API returned a non-2xx status code other than 401/429. */
268
- type: 'api_error';
269
- /** HTTP status code. */
270
- status: number;
271
- /** Parsed response body (object if JSON, string otherwise). */
272
- body: unknown;
265
+ /** The API returned a non-2xx status code other than 401/429. */type: 'api_error'; /** HTTP status code. */
266
+ status: number; /** Parsed response body (object if JSON, string otherwise). */
267
+ body: unknown;
273
268
  };
274
269
  /**
275
270
  * An `Error` subclass that wraps a `PixivError` for use in thrown contexts
@@ -290,9 +285,9 @@ type PixivError = {
290
285
  * ```
291
286
  */
292
287
  declare class PixivFetchError extends Error {
293
- /** The underlying structured `PixivError`. */
294
- readonly pixivError: PixivError;
295
- constructor(pixivError: PixivError);
288
+ /** The underlying structured `PixivError`. */
289
+ readonly pixivError: PixivError;
290
+ constructor(pixivError: PixivError);
296
291
  }
297
292
  /** Creates a rate-limit error. */
298
293
  declare function rateLimitError(retryAfter: number): PixivError;
@@ -302,23 +297,14 @@ declare function authFailedError(status: number): PixivError;
302
297
  declare function networkError(cause: unknown): PixivError;
303
298
  /** Creates an API error. */
304
299
  declare function apiError(status: number, body: unknown): PixivError;
305
-
306
- /**
307
- * HTTP client for the pixiv API.
308
- *
309
- * Wraps the global `fetch` API and adds:
310
- * - 429 retry with Retry-After header parsing
311
- * - 401 → token refresh → single retry
312
- * - Response interceptor hook (for optional DB recording)
313
- * - Image fetch helper (browser UA, Referer, no auth)
314
- */
315
-
300
+ //#endregion
301
+ //#region src/http.d.ts
316
302
  /** Options for controlling retry behaviour on rate-limited requests. */
317
303
  interface RateLimitRetryOptions {
318
- /** Maximum number of retries when a 429 response is received. Defaults to 3. */
319
- maxRetries: number;
320
- /** Default wait time (ms) used when no Retry-After header is present. Defaults to 10_000. */
321
- waitMs: number;
304
+ /** Maximum number of retries when a 429 response is received. Defaults to 3. */
305
+ maxRetries: number;
306
+ /** Default wait time (ms) used when no Retry-After header is present. Defaults to 10_000. */
307
+ waitMs: number;
322
308
  }
323
309
  /**
324
310
  * HTTP client for the pixiv API.
@@ -327,69 +313,57 @@ interface RateLimitRetryOptions {
327
313
  * A 429 → retry loop and a 401 → refresh → retry are handled internally.
328
314
  */
329
315
  declare class HttpClient {
330
- #private;
331
- constructor(auth: AuthManager, options?: {
332
- retry?: Partial<RateLimitRetryOptions>;
333
- onResponse?: ResponseInterceptor;
334
- });
335
- /**
336
- * Sends a GET request to the pixiv API.
337
- *
338
- * @param path - API endpoint path (e.g. "/v1/illust/detail")
339
- * @param params - Query parameters as a URLSearchParams instance
340
- * @returns `ResultAsync<T, PixivError>`
341
- */
342
- get<T>(path: string, params?: URLSearchParams): ResultAsync<T, PixivError>;
343
- /**
344
- * Sends a POST request to the pixiv API.
345
- *
346
- * @param path - API endpoint path (e.g. "/v2/illust/bookmark/add")
347
- * @param body - URL-encoded request body string
348
- * @returns `ResultAsync<T, PixivError>`
349
- */
350
- post<T>(path: string, body: string): ResultAsync<T, PixivError>;
351
- /**
352
- * Fetches a pixiv image URL without an Authorization header.
353
- *
354
- * Uses a browser User-Agent and the pixiv Referer, which are required for
355
- * image CDN access. Retry and interceptor are not applied here.
356
- *
357
- * @param imageUrl - Full image URL
358
- * @returns `ResultAsync<Response, PixivError>`
359
- */
360
- fetchImage(imageUrl: string): ResultAsync<Response, PixivError>;
361
- /**
362
- * Sends a request to an absolute URL returned in a `next_url` field.
363
- *
364
- * Applies the same retry / interceptor / auth logic as `get()`.
365
- *
366
- * @param absoluteUrl - Full URL including query string
367
- * @returns `ResultAsync<T, PixivError>`
368
- */
369
- getAbsolute<T>(absoluteUrl: string): ResultAsync<T, PixivError>;
370
- }
371
-
372
- /**
373
- * PaginatedResultAsync — pagination support for the pixiv API.
374
- *
375
- * Extends `ResultAsync<TPage, PixivError>` so that:
376
- * - `await paginated` returns the first-page `Result<TPage, PixivError>` directly
377
- * - `.pages()` is an async generator that yields each page
378
- * - `.items()` is an async generator that yields individual items across all pages
379
- *
380
- * Pagination uses the `nextUrl` field returned by list endpoints. The URL is
381
- * fetched via `HttpClient.getAbsolute()` which reuses the same auth / retry /
382
- * interceptor pipeline as regular requests.
383
- */
384
-
316
+ #private;
317
+ constructor(auth: AuthManager, options?: {
318
+ retry?: Partial<RateLimitRetryOptions>;
319
+ onResponse?: ResponseInterceptor;
320
+ });
321
+ /**
322
+ * Sends a GET request to the pixiv API.
323
+ *
324
+ * @param path - API endpoint path (e.g. "/v1/illust/detail")
325
+ * @param params - Query parameters as a URLSearchParams instance
326
+ * @returns `ResultAsync<T, PixivError>`
327
+ */
328
+ get<T>(path: string, params?: URLSearchParams): ResultAsync<T, PixivError>;
329
+ /**
330
+ * Sends a POST request to the pixiv API.
331
+ *
332
+ * @param path - API endpoint path (e.g. "/v2/illust/bookmark/add")
333
+ * @param body - URL-encoded request body string
334
+ * @returns `ResultAsync<T, PixivError>`
335
+ */
336
+ post<T>(path: string, body: string): ResultAsync<T, PixivError>;
337
+ /**
338
+ * Fetches a pixiv image URL without an Authorization header.
339
+ *
340
+ * Uses a browser User-Agent and the pixiv Referer, which are required for
341
+ * image CDN access. Retry and interceptor are not applied here.
342
+ *
343
+ * @param imageUrl - Full image URL
344
+ * @returns `ResultAsync<Response, PixivError>`
345
+ */
346
+ fetchImage(imageUrl: string): ResultAsync<Response, PixivError>;
347
+ /**
348
+ * Sends a request to an absolute URL returned in a `next_url` field.
349
+ *
350
+ * Applies the same retry / interceptor / auth logic as `get()`.
351
+ *
352
+ * @param absoluteUrl - Full URL including query string
353
+ * @returns `ResultAsync<T, PixivError>`
354
+ */
355
+ getAbsolute<T>(absoluteUrl: string): ResultAsync<T, PixivError>;
356
+ }
357
+ //#endregion
358
+ //#region src/paginated.d.ts
385
359
  /**
386
360
  * A page returned by a pixiv list endpoint.
387
361
  *
388
362
  * Must have a `nextUrl` field (null when there are no more pages).
389
363
  */
390
364
  interface PagedResponse {
391
- /** URL to the next page, or `null` when there are no more pages. */
392
- nextUrl: string | null;
365
+ /** URL to the next page, or `null` when there are no more pages. */
366
+ nextUrl: string | null;
393
367
  }
394
368
  /**
395
369
  * A `ResultAsync<TPage, PixivError>` with additional `.pages()` / `.items()`
@@ -398,42 +372,42 @@ interface PagedResponse {
398
372
  * Returned by all resource methods that produce a `nextUrl` field.
399
373
  */
400
374
  declare class PaginatedResultAsync<TPage extends PagedResponse, TItem> extends ResultAsync<TPage, PixivError> {
401
- #private;
402
- constructor(promise: Promise<Result<TPage, PixivError>>, http: HttpClient, getItems: (page: TPage) => TItem[]);
403
- /**
404
- * Creates a `PaginatedResultAsync` from a `ResultAsync`.
405
- *
406
- * @param inner - The first-page result
407
- * @param http - HTTP client for fetching subsequent pages
408
- * @param getItems - Extracts item array from a page
409
- */
410
- static fromResultAsync<TPage extends PagedResponse, TItem>(inner: ResultAsync<TPage, PixivError>, http: HttpClient, getItems: (page: TPage) => TItem[]): PaginatedResultAsync<TPage, TItem>;
411
- /**
412
- * Async generator that yields each page starting from the first.
413
- *
414
- * If any page fetch fails, the generator throws a `PixivFetchError`.
415
- *
416
- * @example
417
- * ```ts
418
- * for await (const page of client.illusts.search({ word: 'cat' }).pages()) {
419
- * console.log(page.illusts.length)
420
- * }
421
- * ```
422
- */
423
- pages(): AsyncGenerator<TPage, void, unknown>;
424
- /**
425
- * Async generator that yields individual items across all pages.
426
- *
427
- * If any page fetch fails, the generator throws a `PixivFetchError`.
428
- *
429
- * @example
430
- * ```ts
431
- * for await (const illust of client.illusts.search({ word: 'cat' }).items()) {
432
- * console.log(illust.title)
433
- * }
434
- * ```
435
- */
436
- items(): AsyncGenerator<TItem, void, unknown>;
375
+ #private;
376
+ constructor(promise: Promise<Result<TPage, PixivError>>, http: HttpClient, getItems: (page: TPage) => TItem[]);
377
+ /**
378
+ * Creates a `PaginatedResultAsync` from a `ResultAsync`.
379
+ *
380
+ * @param inner - The first-page result
381
+ * @param http - HTTP client for fetching subsequent pages
382
+ * @param getItems - Extracts item array from a page
383
+ */
384
+ static fromResultAsync<TPage extends PagedResponse, TItem>(inner: ResultAsync<TPage, PixivError>, http: HttpClient, getItems: (page: TPage) => TItem[]): PaginatedResultAsync<TPage, TItem>;
385
+ /**
386
+ * Async generator that yields each page starting from the first.
387
+ *
388
+ * If any page fetch fails, the generator throws a `PixivFetchError`.
389
+ *
390
+ * @example
391
+ * ```ts
392
+ * for await (const page of client.illusts.search({ word: 'cat' }).pages()) {
393
+ * console.log(page.illusts.length)
394
+ * }
395
+ * ```
396
+ */
397
+ pages(): AsyncGenerator<TPage, void, unknown>;
398
+ /**
399
+ * Async generator that yields individual items across all pages.
400
+ *
401
+ * If any page fetch fails, the generator throws a `PixivFetchError`.
402
+ *
403
+ * @example
404
+ * ```ts
405
+ * for await (const illust of client.illusts.search({ word: 'cat' }).items()) {
406
+ * console.log(illust.title)
407
+ * }
408
+ * ```
409
+ */
410
+ items(): AsyncGenerator<TItem, void, unknown>;
437
411
  }
438
412
  /**
439
413
  * Creates an immediately-failed `PaginatedResultAsync`.
@@ -445,7 +419,8 @@ declare class PaginatedResultAsync<TPage extends PagedResponse, TItem> extends R
445
419
  * @param getItems - Item extractor (used for signature compatibility)
446
420
  */
447
421
  declare function failedPaginated<TPage extends PagedResponse, TItem>(error: PixivError, http: HttpClient, getItems: (page: TPage) => TItem[]): PaginatedResultAsync<TPage, TItem>;
448
-
422
+ //#endregion
423
+ //#region src/params.d.ts
449
424
  /**
450
425
  * Typed cursor parameters extracted from a pixiv `next_url`.
451
426
  *
@@ -461,16 +436,16 @@ declare function failedPaginated<TPage extends PagedResponse, TItem>(error: Pixi
461
436
  * | `lastOrder` | `GET /v2/novel/series` |
462
437
  */
463
438
  interface ParsedNextUrl {
464
- /** Cursor for `GET /v1/user/bookmarks/illust`. */
465
- maxBookmarkId?: number;
466
- /** Cursor for `GET /v1/illust/recommended` and `GET /v1/novel/recommended`. */
467
- maxBookmarkIdForRecommend?: number;
468
- /** Secondary cursor for `GET /v1/illust/recommended`. */
469
- minBookmarkIdForRecentIllust?: number;
470
- /** Zero-based offset for general list endpoints. */
471
- offset?: number;
472
- /** Cursor for `GET /v2/novel/series`. */
473
- lastOrder?: number;
439
+ /** Cursor for `GET /v1/user/bookmarks/illust`. */
440
+ maxBookmarkId?: number;
441
+ /** Cursor for `GET /v1/illust/recommended` and `GET /v1/novel/recommended`. */
442
+ maxBookmarkIdForRecommend?: number;
443
+ /** Secondary cursor for `GET /v1/illust/recommended`. */
444
+ minBookmarkIdForRecentIllust?: number;
445
+ /** Zero-based offset for general list endpoints. */
446
+ offset?: number;
447
+ /** Cursor for `GET /v2/novel/series`. */
448
+ lastOrder?: number;
474
449
  }
475
450
  /**
476
451
  * Parses a pixiv `next_url` into a typed cursor object.
@@ -495,7 +470,8 @@ interface ParsedNextUrl {
495
470
  * @returns Typed cursor parameters; fields absent in the URL are `undefined`
496
471
  */
497
472
  declare function parseNextUrl(url: string): ParsedNextUrl;
498
-
473
+ //#endregion
474
+ //#region src/options.d.ts
499
475
  /**
500
476
  * Public option constants for @book000/pixivts.
501
477
  *
@@ -521,10 +497,10 @@ declare function parseNextUrl(url: string): ParsedNextUrl;
521
497
  * - `keyword` — general keyword search (novel only)
522
498
  */
523
499
  declare const SearchTarget: {
524
- readonly PARTIAL_MATCH_FOR_TAGS: "partial_match_for_tags";
525
- readonly EXACT_MATCH_FOR_TAGS: "exact_match_for_tags";
526
- readonly TITLE_AND_CAPTION: "title_and_caption";
527
- readonly KEYWORD: "keyword";
500
+ readonly PARTIAL_MATCH_FOR_TAGS: "partial_match_for_tags";
501
+ readonly EXACT_MATCH_FOR_TAGS: "exact_match_for_tags";
502
+ readonly TITLE_AND_CAPTION: "title_and_caption";
503
+ readonly KEYWORD: "keyword";
528
504
  };
529
505
  /**
530
506
  * Sort order for search results.
@@ -534,9 +510,9 @@ declare const SearchTarget: {
534
510
  * - `popular_desc` — most bookmarks first (premium only)
535
511
  */
536
512
  declare const SearchSort: {
537
- readonly DATE_DESC: "date_desc";
538
- readonly DATE_ASC: "date_asc";
539
- readonly POPULAR_DESC: "popular_desc";
513
+ readonly DATE_DESC: "date_desc";
514
+ readonly DATE_ASC: "date_asc";
515
+ readonly POPULAR_DESC: "popular_desc";
540
516
  };
541
517
  /**
542
518
  * Date range filter for search results.
@@ -546,9 +522,9 @@ declare const SearchSort: {
546
522
  * - `within_last_month` — past 30 days
547
523
  */
548
524
  declare const SearchDuration: {
549
- readonly WITHIN_LAST_DAY: "within_last_day";
550
- readonly WITHIN_LAST_WEEK: "within_last_week";
551
- readonly WITHIN_LAST_MONTH: "within_last_month";
525
+ readonly WITHIN_LAST_DAY: "within_last_day";
526
+ readonly WITHIN_LAST_WEEK: "within_last_week";
527
+ readonly WITHIN_LAST_MONTH: "within_last_month";
552
528
  };
553
529
  /**
554
530
  * Ranking mode for illust rankings.
@@ -556,19 +532,19 @@ declare const SearchDuration: {
556
532
  * R-18 modes require a premium account with R-18 content enabled.
557
533
  */
558
534
  declare const RankingMode: {
559
- readonly DAY: "day";
560
- readonly DAY_MALE: "day_male";
561
- readonly DAY_FEMALE: "day_female";
562
- readonly WEEK_ORIGINAL: "week_original";
563
- readonly WEEK_ROOKIE: "week_rookie";
564
- readonly WEEK: "week";
565
- readonly MONTH: "month";
566
- readonly DAY_AI: "day_ai";
567
- readonly DAY_R18: "day_r18";
568
- readonly WEEK_R18: "week_r18";
569
- readonly DAY_MALE_R18: "day_male_r18";
570
- readonly DAY_FEMALE_R18: "day_female_r18";
571
- readonly DAY_R18_AI: "day_r18_ai";
535
+ readonly DAY: "day";
536
+ readonly DAY_MALE: "day_male";
537
+ readonly DAY_FEMALE: "day_female";
538
+ readonly WEEK_ORIGINAL: "week_original";
539
+ readonly WEEK_ROOKIE: "week_rookie";
540
+ readonly WEEK: "week";
541
+ readonly MONTH: "month";
542
+ readonly DAY_AI: "day_ai";
543
+ readonly DAY_R18: "day_r18";
544
+ readonly WEEK_R18: "week_r18";
545
+ readonly DAY_MALE_R18: "day_male_r18";
546
+ readonly DAY_FEMALE_R18: "day_female_r18";
547
+ readonly DAY_R18_AI: "day_r18_ai";
572
548
  };
573
549
  /**
574
550
  * Ranking mode for novel rankings.
@@ -576,14 +552,14 @@ declare const RankingMode: {
576
552
  * R-18 modes require a premium account with R-18 content enabled.
577
553
  */
578
554
  declare const NovelRankingMode: {
579
- readonly DAY: "day";
580
- readonly WEEK: "week";
581
- readonly DAY_MALE: "day_male";
582
- readonly DAY_FEMALE: "day_female";
583
- readonly WEEK_ROOKIE: "week_rookie";
584
- readonly DAY_R18: "day_r18";
585
- readonly WEEK_R18: "week_r18";
586
- readonly DAY_R18_AI: "day_r18_ai";
555
+ readonly DAY: "day";
556
+ readonly WEEK: "week";
557
+ readonly DAY_MALE: "day_male";
558
+ readonly DAY_FEMALE: "day_female";
559
+ readonly WEEK_ROOKIE: "week_rookie";
560
+ readonly DAY_R18: "day_r18";
561
+ readonly WEEK_R18: "week_r18";
562
+ readonly DAY_R18_AI: "day_r18_ai";
587
563
  };
588
564
  /**
589
565
  * Visibility restriction for bookmarks.
@@ -592,8 +568,8 @@ declare const NovelRankingMode: {
592
568
  * - `private` — visible only to the owner
593
569
  */
594
570
  declare const BookmarkRestrict: {
595
- readonly PUBLIC: "public";
596
- readonly PRIVATE: "private";
571
+ readonly PUBLIC: "public";
572
+ readonly PRIVATE: "private";
597
573
  };
598
574
  /**
599
575
  * Visibility restriction for follows.
@@ -602,8 +578,8 @@ declare const BookmarkRestrict: {
602
578
  * - `private` — visible only to the owner
603
579
  */
604
580
  declare const FollowRestrict: {
605
- readonly PUBLIC: "public";
606
- readonly PRIVATE: "private";
581
+ readonly PUBLIC: "public";
582
+ readonly PRIVATE: "private";
607
583
  };
608
584
  /**
609
585
  * OS filter used to request works compatible with the given platform.
@@ -612,8 +588,8 @@ declare const FollowRestrict: {
612
588
  * - `for_android` — Android-compatible works
613
589
  */
614
590
  declare const OSFilter: {
615
- readonly FOR_IOS: "for_ios";
616
- readonly FOR_ANDROID: "for_android";
591
+ readonly FOR_IOS: "for_ios";
592
+ readonly FOR_ANDROID: "for_android";
617
593
  };
618
594
  /**
619
595
  * Work type filter for user illust listings.
@@ -622,10 +598,11 @@ declare const OSFilter: {
622
598
  * - `manga` — manga only
623
599
  */
624
600
  declare const UserIllustType: {
625
- readonly ILLUST: "illust";
626
- readonly MANGA: "manga";
601
+ readonly ILLUST: "illust";
602
+ readonly MANGA: "manga";
627
603
  };
628
-
604
+ //#endregion
605
+ //#region src/types.d.ts
629
606
  /**
630
607
  * Public types for @book000/pixivts.
631
608
  *
@@ -642,19 +619,19 @@ declare const UserIllustType: {
642
619
  * Accessing these URLs requires setting an appropriate `Referer` header.
643
620
  */
644
621
  interface ImageUrls {
645
- /** 360×360 thumbnail */
646
- squareMedium: string;
647
- /** Long side ≤ 540 px */
648
- medium: string;
649
- /** Width ≤ 600 px, height ≤ 1200 px */
650
- large: string;
651
- /** Original image (present in `metaPages` entries only) */
652
- original?: string;
622
+ /** 360×360 thumbnail */
623
+ squareMedium: string;
624
+ /** Long side ≤ 540 px */
625
+ medium: string;
626
+ /** Width ≤ 600 px, height ≤ 1200 px */
627
+ large: string;
628
+ /** Original image (present in `metaPages` entries only) */
629
+ original?: string;
653
630
  }
654
631
  /** Profile image URLs for a user. */
655
632
  interface ProfileImageUrls {
656
- /** Medium-size profile image URL. */
657
- medium: string;
633
+ /** Medium-size profile image URL. */
634
+ medium: string;
658
635
  }
659
636
  /**
660
637
  * Minimal user info embedded in works, search results, and preview lists.
@@ -662,60 +639,68 @@ interface ProfileImageUrls {
662
639
  * Full profile data is returned by GET /v1/user/detail.
663
640
  */
664
641
  interface PixivUser {
665
- /**
666
- * Internal numeric user ID.
667
- *
668
- * NOTE: certain API endpoints return this as a string. The core library
669
- * normalises it to `number` before returning it to callers.
670
- */
671
- id: number;
672
- /** Display name shown on the user's profile. */
673
- name: string;
674
- /** Login account name (distinct from the display `name`). */
675
- account: string;
676
- /** Set of profile image URLs at different sizes. */
677
- profileImageUrls: ProfileImageUrls;
678
- /** Whether the authenticated user follows this user. */
679
- isFollowed?: boolean;
680
- /** Whether this user has blocked access by the authenticated user. */
681
- isAccessBlockingUser?: boolean;
682
- /** Whether this user accepts illustration commission requests. */
683
- isAcceptRequest?: boolean;
642
+ /**
643
+ * Internal numeric user ID.
644
+ *
645
+ * NOTE: certain API endpoints return this as a string. The core library
646
+ * normalises it to `number` before returning it to callers.
647
+ */
648
+ id: number;
649
+ /** Display name shown on the user's profile. */
650
+ name: string;
651
+ /** Login account name (distinct from the display `name`). */
652
+ account: string;
653
+ /** Set of profile image URLs at different sizes. */
654
+ profileImageUrls: ProfileImageUrls;
655
+ /** Whether the authenticated user follows this user. */
656
+ isFollowed?: boolean;
657
+ /** Whether this user has blocked access by the authenticated user. */
658
+ isAccessBlockingUser?: boolean;
659
+ /** Whether this user accepts illustration commission requests. */
660
+ isAcceptRequest?: boolean;
684
661
  }
685
662
  /** Tag on a work. */
686
663
  interface Tag {
687
- /** Tag name in Japanese. */
688
- name: string;
689
- /** Translated tag name, or `null` if no translation is available. */
690
- translatedName: string | null;
691
- /** Whether the tag was added by the work's uploader. */
692
- addedByUploadedUser?: boolean;
664
+ /** Tag name in Japanese. */
665
+ name: string;
666
+ /** Translated tag name, or `null` if no translation is available. */
667
+ translatedName: string | null;
668
+ /** Whether the tag was added by the work's uploader. */
669
+ addedByUploadedUser?: boolean;
693
670
  }
694
671
  /** Series information embedded in a work item. */
695
672
  interface Series {
696
- /** Series ID. */
697
- id: number;
698
- /** Series title. */
699
- title: string;
673
+ /** Series ID. */
674
+ id: number;
675
+ /** Series title. */
676
+ title: string;
700
677
  }
701
678
  /** Privacy-policy blurb returned by recommended endpoints. */
702
679
  interface PrivacyPolicy {
703
- /** Policy version string. */
704
- version?: string;
705
- /** Human-readable policy notice. */
706
- message?: string;
707
- /** URL to the full privacy-policy page. */
708
- url?: string;
709
- }
710
- /** Original-image URL for a single-page illust. */
680
+ /** Policy version string. */
681
+ version?: string;
682
+ /** Human-readable policy notice. */
683
+ message?: string;
684
+ /** URL to the full privacy-policy page. */
685
+ url?: string;
686
+ }
687
+ /**
688
+ * Original-image URL for a single-page illust.
689
+ *
690
+ * For manga works the API returns `meta_single_page` as an empty object `{}`,
691
+ * so `originalImageUrl` may be absent even when the enclosing object is present.
692
+ */
711
693
  interface MetaSinglePage {
712
- /** Direct URL to the original-resolution image. */
713
- originalImageUrl: string;
694
+ /**
695
+ * Direct URL to the original-resolution image.
696
+ * Absent for manga works where `meta_single_page` is returned as `{}`.
697
+ */
698
+ originalImageUrl?: string;
714
699
  }
715
700
  /** Per-page image URLs for a multi-page work (manga). */
716
701
  interface MetaPages {
717
- /** Full set of image URLs for this page, including the original. */
718
- imageUrls: Required<ImageUrls>;
702
+ /** Full set of image URLs for this page, including the original. */
703
+ imageUrls: Required<ImageUrls>;
719
704
  }
720
705
  /**
721
706
  * A pixiv illust or manga work item as returned by the API.
@@ -724,95 +709,95 @@ interface MetaPages {
724
709
  * GET /v1/illust/ranking, GET /v1/illust/recommended, etc.
725
710
  */
726
711
  interface PixivIllustItem {
727
- /**
728
- * Work ID.
729
- *
730
- * Illusts and novels are numbered in separate sequences — the same ID
731
- * can appear in both.
732
- */
733
- id: number;
734
- /** Title of the work. */
735
- title: string;
736
- /** Work category: illustration, manga, or animated illustration. */
737
- type: 'illust' | 'manga' | 'ugoira';
738
- /** Thumbnail image URLs at various sizes. */
739
- imageUrls: ImageUrls;
740
- /** Work caption / description (may contain HTML). */
741
- caption: string;
742
- /** Content restriction level (0 = public, 1 = mypixiv-only, 2 = private). */
743
- restrict: number;
744
- /** Author of the work. */
745
- user: PixivUser;
746
- /** Tags attached to the work. */
747
- tags: Tag[];
748
- /** Creation tools listed by the author (e.g. "Photoshop"). */
749
- tools: string[];
750
- /** ISO 8601 date-time string of when the work was posted. */
751
- createDate: string;
752
- /** Number of images in a multi-page work (1 for single-page). */
753
- pageCount: number;
754
- /** Canvas width in pixels. */
755
- width: number;
756
- /** Canvas height in pixels. */
757
- height: number;
758
- /** Sanity / sensitivity level assigned by the pixiv content filter. */
759
- sanityLevel: number;
760
- /** Age restriction: 0 = all-ages, 1 = R-18, 2 = R-18G */
761
- xRestrict: number;
762
- /** Series this work belongs to, or `null` if not part of a series. */
763
- series: Series | null;
764
- /**
765
- * For single-page works: `{ originalImageUrl: string }`.
766
- * For multi-page works: `{}` (empty object).
767
- */
768
- metaSinglePage: MetaSinglePage | Record<string, never>;
769
- /** Per-page image URLs for multi-page works (empty array for single-page). */
770
- metaPages: MetaPages[];
771
- /** Total number of views. */
772
- totalView: number;
773
- /** Total number of bookmarks. */
774
- totalBookmarks: number;
775
- /** Whether the authenticated user has bookmarked this work. */
776
- isBookmarked: boolean;
777
- /** Whether the work is publicly visible. */
778
- visible: boolean;
779
- /** Whether the work is muted for the authenticated user. */
780
- isMuted: boolean;
781
- /** Total number of comments (may be absent on some endpoints). */
782
- totalComments?: number;
783
- /** AI-generated content flag: 0 = no AI, 1 = partial AI, 2 = fully AI */
784
- illustAiType: number;
785
- /** Book-style rendering flag (0 = normal, 1 = book). */
786
- illustBookStyle: number;
787
- /** Controls who can post comments (may be absent). */
788
- commentAccessControl?: number;
789
- /** Additional access-restriction attributes (may be absent). */
790
- restrictionAttributes?: string[];
712
+ /**
713
+ * Work ID.
714
+ *
715
+ * Illusts and novels are numbered in separate sequences — the same ID
716
+ * can appear in both.
717
+ */
718
+ id: number;
719
+ /** Title of the work. */
720
+ title: string;
721
+ /** Work category: illustration, manga, or animated illustration. */
722
+ type: 'illust' | 'manga' | 'ugoira';
723
+ /** Thumbnail image URLs at various sizes. */
724
+ imageUrls: ImageUrls;
725
+ /** Work caption / description (may contain HTML). */
726
+ caption: string;
727
+ /** Content restriction level (0 = public, 1 = mypixiv-only, 2 = private). */
728
+ restrict: number;
729
+ /** Author of the work. */
730
+ user: PixivUser;
731
+ /** Tags attached to the work. */
732
+ tags: Tag[];
733
+ /** Creation tools listed by the author (e.g. "Photoshop"). */
734
+ tools: string[];
735
+ /** ISO 8601 date-time string of when the work was posted. */
736
+ createDate: string;
737
+ /** Number of images in a multi-page work (1 for single-page). */
738
+ pageCount: number;
739
+ /** Canvas width in pixels. */
740
+ width: number;
741
+ /** Canvas height in pixels. */
742
+ height: number;
743
+ /** Sanity / sensitivity level assigned by the pixiv content filter. */
744
+ sanityLevel: number;
745
+ /** Age restriction: 0 = all-ages, 1 = R-18, 2 = R-18G */
746
+ xRestrict: number;
747
+ /** Series this work belongs to, or `null` if not part of a series. */
748
+ series: Series | null;
749
+ /**
750
+ * For single-page works: `{ originalImageUrl: string }`.
751
+ * For multi-page works (manga): `{}` (empty object; `originalImageUrl` will be `undefined`).
752
+ */
753
+ metaSinglePage: MetaSinglePage | Record<string, never>;
754
+ /** Per-page image URLs for multi-page works (empty array for single-page). */
755
+ metaPages: MetaPages[];
756
+ /** Total number of views. */
757
+ totalView: number;
758
+ /** Total number of bookmarks. */
759
+ totalBookmarks: number;
760
+ /** Whether the authenticated user has bookmarked this work. */
761
+ isBookmarked: boolean;
762
+ /** Whether the work is publicly visible. */
763
+ visible: boolean;
764
+ /** Whether the work is muted for the authenticated user. */
765
+ isMuted: boolean;
766
+ /** Total number of comments (may be absent on some endpoints). */
767
+ totalComments?: number;
768
+ /** AI-generated content flag: 0 = no AI, 1 = partial AI, 2 = fully AI */
769
+ illustAiType: number;
770
+ /** Book-style rendering flag (0 = normal, 1 = book). */
771
+ illustBookStyle: number;
772
+ /** Controls who can post comments (may be absent). */
773
+ commentAccessControl?: number;
774
+ /** Additional access-restriction attributes (may be absent). */
775
+ restrictionAttributes?: string[];
791
776
  }
792
777
  /** Illust series metadata returned by GET /v1/illust/series. */
793
778
  interface IllustSeriesDetail {
794
- /** Series ID. */
795
- id: number;
796
- /** Series title. */
797
- title: string;
798
- /** Series description / caption. */
799
- caption: string;
800
- /** Cover image URLs. */
801
- coverImageUrls: {
802
- medium: string;
803
- };
804
- /** Number of works in the series. */
805
- seriesWorkCount: number;
806
- /** ISO 8601 date-time string of when the series was created. */
807
- createDate: string;
808
- /** Canvas width of the cover image in pixels. */
809
- width: number;
810
- /** Canvas height of the cover image in pixels. */
811
- height: number;
812
- /** Author of the series. */
813
- user: PixivUser;
814
- /** Whether the authenticated user has added this series to their watchlist. */
815
- watchlistAdded: boolean;
779
+ /** Series ID. */
780
+ id: number;
781
+ /** Series title. */
782
+ title: string;
783
+ /** Series description / caption. */
784
+ caption: string;
785
+ /** Cover image URLs. */
786
+ coverImageUrls: {
787
+ medium: string;
788
+ };
789
+ /** Number of works in the series. */
790
+ seriesWorkCount: number;
791
+ /** ISO 8601 date-time string of when the series was created. */
792
+ createDate: string;
793
+ /** Canvas width of the cover image in pixels. */
794
+ width: number;
795
+ /** Canvas height of the cover image in pixels. */
796
+ height: number;
797
+ /** Author of the series. */
798
+ user: PixivUser;
799
+ /** Whether the authenticated user has added this series to their watchlist. */
800
+ watchlistAdded: boolean;
816
801
  }
817
802
  /**
818
803
  * A pixiv novel work item as returned by the API.
@@ -820,188 +805,187 @@ interface IllustSeriesDetail {
820
805
  * Returned by GET /v2/novel/detail, GET /v1/search/novel, etc.
821
806
  */
822
807
  interface PixivNovelItem {
823
- /**
824
- * Work ID.
825
- *
826
- * Novels and illusts are numbered in separate sequences — the same ID
827
- * can appear in both.
828
- */
829
- id: number;
830
- /** Title of the novel. */
831
- title: string;
832
- /** Synopsis / caption (may contain HTML). */
833
- caption: string;
834
- /** Content restriction level (0 = public, 1 = mypixiv-only, 2 = private). */
835
- restrict: number;
836
- /** Age restriction: 0 = all-ages, 1 = R-18, 2 = R-18G */
837
- xRestrict: number;
838
- /** Whether the novel is an original work (not fan fiction). */
839
- isOriginal: boolean;
840
- /** Cover image URLs. */
841
- imageUrls: ImageUrls;
842
- /** ISO 8601 date-time string of when the novel was posted. */
843
- createDate: string;
844
- /** Tags attached to the novel. */
845
- tags: Tag[];
846
- /** Number of pages (word-count chunks). */
847
- pageCount: number;
848
- /** Total character count of the novel body. */
849
- textLength: number;
850
- /** Author of the novel. */
851
- user: PixivUser;
852
- /**
853
- * Series information.
854
- *
855
- * `{}` (empty object) if the novel does not belong to a series.
856
- */
857
- series: Series | Record<string, never>;
858
- /** Whether the authenticated user has bookmarked this novel. */
859
- isBookmarked: boolean;
860
- /** Total number of bookmarks. */
861
- totalBookmarks: number;
862
- /** Total number of views. */
863
- totalView: number;
864
- /** Whether the novel is publicly visible. */
865
- visible: boolean;
866
- /** Total number of comments. */
867
- totalComments: number;
868
- /** Whether the novel is muted for the authenticated user. */
869
- isMuted: boolean;
870
- /** Whether the novel is restricted to mutual followers (mypixiv). */
871
- isMypixivOnly: boolean;
872
- /** Whether the novel contains explicit content beyond the `xRestrict` flag. */
873
- isXRestricted: boolean;
874
- /** AI-generated content flag: 0 = no AI, 1 = partial AI, 2 = fully AI */
875
- novelAiType: number;
876
- /** Controls who can post comments (may be absent). */
877
- commentAccessControl?: number;
808
+ /**
809
+ * Work ID.
810
+ *
811
+ * Novels and illusts are numbered in separate sequences — the same ID
812
+ * can appear in both.
813
+ */
814
+ id: number;
815
+ /** Title of the novel. */
816
+ title: string;
817
+ /** Synopsis / caption (may contain HTML). */
818
+ caption: string;
819
+ /** Content restriction level (0 = public, 1 = mypixiv-only, 2 = private). */
820
+ restrict: number;
821
+ /** Age restriction: 0 = all-ages, 1 = R-18, 2 = R-18G */
822
+ xRestrict: number;
823
+ /** Whether the novel is an original work (not fan fiction). */
824
+ isOriginal: boolean;
825
+ /** Cover image URLs. */
826
+ imageUrls: ImageUrls;
827
+ /** ISO 8601 date-time string of when the novel was posted. */
828
+ createDate: string;
829
+ /** Tags attached to the novel. */
830
+ tags: Tag[];
831
+ /** Number of pages (word-count chunks). */
832
+ pageCount: number;
833
+ /** Total character count of the novel body. */
834
+ textLength: number;
835
+ /** Author of the novel. */
836
+ user: PixivUser;
837
+ /**
838
+ * Series information.
839
+ *
840
+ * `{}` (empty object) if the novel does not belong to a series.
841
+ */
842
+ series: Series | Record<string, never>;
843
+ /** Whether the authenticated user has bookmarked this novel. */
844
+ isBookmarked: boolean;
845
+ /** Total number of bookmarks. */
846
+ totalBookmarks: number;
847
+ /** Total number of views. */
848
+ totalView: number;
849
+ /** Whether the novel is publicly visible. */
850
+ visible: boolean;
851
+ /** Total number of comments. */
852
+ totalComments: number;
853
+ /** Whether the novel is muted for the authenticated user. */
854
+ isMuted: boolean;
855
+ /** Whether the novel is restricted to mutual followers (mypixiv). */
856
+ isMypixivOnly: boolean;
857
+ /** Whether the novel contains explicit content beyond the `xRestrict` flag. */
858
+ isXRestricted: boolean;
859
+ /** AI-generated content flag: 0 = no AI, 1 = partial AI, 2 = fully AI */
860
+ novelAiType: number;
861
+ /** Controls who can post comments (may be absent). */
862
+ commentAccessControl?: number;
878
863
  }
879
864
  /** Novel series details returned by GET /v2/novel/series. */
880
865
  interface NovelSeriesDetail {
881
- /** Series ID. */
882
- id: number;
883
- /** Series title. */
884
- title: string;
885
- /** Series description / caption. */
886
- caption: string;
887
- /** Whether every novel in the series is original (not fan fiction). */
888
- isOriginal: boolean;
889
- /** Whether the series has been marked as concluded by the author. */
890
- isConcluded: boolean;
891
- /** Number of novels in the series. */
892
- contentCount: number;
893
- /** Total character count across all novels in the series. */
894
- totalCharacterCount: number;
895
- /** Author of the series. */
896
- user: PixivUser;
897
- /** Human-readable series label / tagline. */
898
- displayText: string;
899
- /** AI-generated content flag: 0 = no AI, 1 = partial AI, 2 = fully AI */
900
- novelAiType: number;
901
- /** Whether the authenticated user has added this series to their watchlist. */
902
- watchlistAdded: boolean;
866
+ /** Series ID. */
867
+ id: number;
868
+ /** Series title. */
869
+ title: string;
870
+ /** Series description / caption. */
871
+ caption: string;
872
+ /** Whether every novel in the series is original (not fan fiction). */
873
+ isOriginal: boolean;
874
+ /** Whether the series has been marked as concluded by the author. */
875
+ isConcluded: boolean;
876
+ /** Number of novels in the series. */
877
+ contentCount: number;
878
+ /** Total character count across all novels in the series. */
879
+ totalCharacterCount: number;
880
+ /** Author of the series. */
881
+ user: PixivUser;
882
+ /** Human-readable series label / tagline. */
883
+ displayText: string;
884
+ /** AI-generated content flag: 0 = no AI, 1 = partial AI, 2 = fully AI */
885
+ novelAiType: number;
886
+ /** Whether the authenticated user has added this series to their watchlist. */
887
+ watchlistAdded: boolean;
903
888
  }
904
889
  /** User item with self-introduction; embedded in GET /v1/user/detail. */
905
890
  type PixivUserItem = PixivUser & {
906
- /** Self-introduction text (line endings are \r\n) */
907
- comment: string;
891
+ /** Self-introduction text (line endings are \r\n) */comment: string;
908
892
  };
909
893
  /** Visibility setting for a user profile field. */
910
894
  type Publicity = 'public' | 'private' | 'mypixiv';
911
895
  /** Detailed profile information for a user. */
912
896
  interface PixivUserProfile {
913
- /** Personal website URL, or `null` if not set. */
914
- webpage: string | null;
915
- /** Disclosed gender. */
916
- gender: 'male' | 'female' | 'unknown';
917
- /** Birth date string (YYYY-MM-DD format, may be partial). */
918
- birth: string;
919
- /** Birth day portion (MM-DD format). */
920
- birthDay: string;
921
- /** Birth year. */
922
- birthYear: number;
923
- /** Region / prefecture. */
924
- region: string;
925
- /** Internal address ID. */
926
- addressId: number;
927
- /** Two-letter country code (ISO 3166-1 alpha-2). */
928
- countryCode: string;
929
- /** Occupation / job description. */
930
- job: string;
931
- /** Internal job category ID. */
932
- jobId: number;
933
- /** Number of users this user follows. */
934
- totalFollowUsers: number;
935
- /** Number of mutual-follow (mypixiv) connections. */
936
- totalMypixivUsers: number;
937
- /** Total number of public illusts. */
938
- totalIllusts: number;
939
- /** Total number of public manga works. */
940
- totalManga: number;
941
- /** Total number of public novels. */
942
- totalNovels: number;
943
- /** Total number of publicly bookmarked illusts. */
944
- totalIllustBookmarksPublic: number;
945
- /** Total number of illust series. */
946
- totalIllustSeries: number;
947
- /** Total number of novel series. */
948
- totalNovelSeries: number;
949
- /** Profile background image URL, or `null` if not set. */
950
- backgroundImageUrl: string | null;
951
- /** Linked Twitter/X account name (without @). */
952
- twitterAccount: string;
953
- /** Twitter/X profile URL, or `null` if not set. */
954
- twitterUrl: string | null;
955
- /** Pawoo profile URL, or `null` if not set. */
956
- pawooUrl: string | null;
957
- /** Whether the user has a premium (paid) account. */
958
- isPremium: boolean;
959
- /** Whether the user has set a custom profile image. */
960
- isUsingCustomProfileImage: boolean;
897
+ /** Personal website URL, or `null` if not set. */
898
+ webpage: string | null;
899
+ /** Disclosed gender. */
900
+ gender: 'male' | 'female' | 'unknown';
901
+ /** Birth date string (YYYY-MM-DD format, may be partial). */
902
+ birth: string;
903
+ /** Birth day portion (MM-DD format). */
904
+ birthDay: string;
905
+ /** Birth year. */
906
+ birthYear: number;
907
+ /** Region / prefecture. */
908
+ region: string;
909
+ /** Internal address ID. */
910
+ addressId: number;
911
+ /** Two-letter country code (ISO 3166-1 alpha-2). */
912
+ countryCode: string;
913
+ /** Occupation / job description. */
914
+ job: string;
915
+ /** Internal job category ID. */
916
+ jobId: number;
917
+ /** Number of users this user follows. */
918
+ totalFollowUsers: number;
919
+ /** Number of mutual-follow (mypixiv) connections. */
920
+ totalMypixivUsers: number;
921
+ /** Total number of public illusts. */
922
+ totalIllusts: number;
923
+ /** Total number of public manga works. */
924
+ totalManga: number;
925
+ /** Total number of public novels. */
926
+ totalNovels: number;
927
+ /** Total number of publicly bookmarked illusts. */
928
+ totalIllustBookmarksPublic: number;
929
+ /** Total number of illust series. */
930
+ totalIllustSeries: number;
931
+ /** Total number of novel series. */
932
+ totalNovelSeries: number;
933
+ /** Profile background image URL, or `null` if not set. */
934
+ backgroundImageUrl: string | null;
935
+ /** Linked Twitter/X account name (without @). */
936
+ twitterAccount: string;
937
+ /** Twitter/X profile URL, or `null` if not set. */
938
+ twitterUrl: string | null;
939
+ /** Pawoo profile URL, or `null` if not set. */
940
+ pawooUrl: string | null;
941
+ /** Whether the user has a premium (paid) account. */
942
+ isPremium: boolean;
943
+ /** Whether the user has set a custom profile image. */
944
+ isUsingCustomProfileImage: boolean;
961
945
  }
962
946
  /** Visibility settings for a user's profile fields. */
963
947
  interface PixivUserProfilePublicity {
964
- /** Visibility of the gender field. */
965
- gender: Publicity;
966
- /** Visibility of the region field. */
967
- region: Publicity;
968
- /** Visibility of the birth-day field. */
969
- birthDay: Publicity;
970
- /** Visibility of the birth-year field. */
971
- birthYear: Publicity;
972
- /** Visibility of the job field. */
973
- job: Publicity;
974
- /** Whether the Pawoo account link is visible. */
975
- pawoo: boolean;
948
+ /** Visibility of the gender field. */
949
+ gender: Publicity;
950
+ /** Visibility of the region field. */
951
+ region: Publicity;
952
+ /** Visibility of the birth-day field. */
953
+ birthDay: Publicity;
954
+ /** Visibility of the birth-year field. */
955
+ birthYear: Publicity;
956
+ /** Visibility of the job field. */
957
+ job: Publicity;
958
+ /** Whether the Pawoo account link is visible. */
959
+ pawoo: boolean;
976
960
  }
977
961
  /** Workspace / desk setup information from a user's profile. */
978
962
  interface PixivUserProfileWorkspace {
979
- /** PC / computer specs. */
980
- pc: string;
981
- /** Monitor model. */
982
- monitor: string;
983
- /** Drawing software / tool. */
984
- tool: string;
985
- /** Scanner model. */
986
- scanner: string;
987
- /** Tablet model. */
988
- tablet: string;
989
- /** Mouse model. */
990
- mouse: string;
991
- /** Printer model. */
992
- printer: string;
993
- /** Desktop wallpaper or environment description. */
994
- desktop: string;
995
- /** Music / background audio description. */
996
- music: string;
997
- /** Desk description. */
998
- desk: string;
999
- /** Chair description. */
1000
- chair: string;
1001
- /** Free-text comment about the workspace. */
1002
- comment: string;
1003
- /** Workspace image URL, or `null` if not set. */
1004
- workspaceImageUrl: string | null;
963
+ /** PC / computer specs. */
964
+ pc: string;
965
+ /** Monitor model. */
966
+ monitor: string;
967
+ /** Drawing software / tool. */
968
+ tool: string;
969
+ /** Scanner model. */
970
+ scanner: string;
971
+ /** Tablet model. */
972
+ tablet: string;
973
+ /** Mouse model. */
974
+ mouse: string;
975
+ /** Printer model. */
976
+ printer: string;
977
+ /** Desktop wallpaper or environment description. */
978
+ desktop: string;
979
+ /** Music / background audio description. */
980
+ music: string;
981
+ /** Desk description. */
982
+ desk: string;
983
+ /** Chair description. */
984
+ chair: string;
985
+ /** Free-text comment about the workspace. */
986
+ comment: string;
987
+ /** Workspace image URL, or `null` if not set. */
988
+ workspaceImageUrl: string | null;
1005
989
  }
1006
990
  /**
1007
991
  * Preview item for a user in the GET /v1/user/following response.
@@ -1009,33 +993,33 @@ interface PixivUserProfileWorkspace {
1009
993
  * Contains a few sample illusts and novels from that user.
1010
994
  */
1011
995
  interface PixivUserPreviewItem {
1012
- /** The user being previewed. */
1013
- user: PixivUser;
1014
- /** A small sample of the user's recent illusts. */
1015
- illusts: PixivIllustItem[];
1016
- /** A small sample of the user's recent novels. */
1017
- novels: PixivNovelItem[];
1018
- /** Whether this user is muted by the authenticated user. */
1019
- isMuted: boolean;
996
+ /** The user being previewed. */
997
+ user: PixivUser;
998
+ /** A small sample of the user's recent illusts. */
999
+ illusts: PixivIllustItem[];
1000
+ /** A small sample of the user's recent novels. */
1001
+ novels: PixivNovelItem[];
1002
+ /** Whether this user is muted by the authenticated user. */
1003
+ isMuted: boolean;
1020
1004
  }
1021
1005
  /** URLs for ugoira frame archives (ZIP files). */
1022
1006
  interface ZipUrls {
1023
- /** URL for the 600 px-long-side archive. */
1024
- medium: string;
1007
+ /** URL for the 600 px-long-side archive. */
1008
+ medium: string;
1025
1009
  }
1026
1010
  /** Timing info for a single ugoira frame. */
1027
1011
  interface Frame {
1028
- /** File name within the ZIP archive */
1029
- file: string;
1030
- /** Display duration in milliseconds */
1031
- delay: number;
1012
+ /** File name within the ZIP archive */
1013
+ file: string;
1014
+ /** Display duration in milliseconds */
1015
+ delay: number;
1032
1016
  }
1033
1017
  /** Ugoira metadata as returned by GET /v1/ugoira/metadata. */
1034
1018
  interface PixivUgoiraItem {
1035
- /** Archive URLs for the frame ZIP. */
1036
- zipUrls: ZipUrls;
1037
- /** Per-frame timing data (in order). */
1038
- frames: Frame[];
1019
+ /** Archive URLs for the frame ZIP. */
1020
+ zipUrls: ZipUrls;
1021
+ /** Per-frame timing data (in order). */
1022
+ frames: Frame[];
1039
1023
  }
1040
1024
  /**
1041
1025
  * Camelized shape of the JSON error body returned by the pixiv API.
@@ -1045,785 +1029,771 @@ interface PixivUgoiraItem {
1045
1029
  * are `lowerCamelCase`.
1046
1030
  */
1047
1031
  interface PixivApiErrorBody {
1048
- /** Error payload returned by the pixiv API (keys camelized). */
1049
- error: {
1050
- /** Localised error message intended for end users. */
1051
- userMessage: string;
1052
- /** Internal error message. */
1053
- message: string;
1054
- /** Short error reason / code. */
1055
- reason: string;
1056
- /** Additional details for the user-facing message (may be absent). */
1057
- userMessageDetails?: Record<string, unknown>;
1058
- };
1032
+ /** Error payload returned by the pixiv API (keys camelized). */
1033
+ error: {
1034
+ /** Localised error message intended for end users. */userMessage: string; /** Internal error message. */
1035
+ message: string; /** Short error reason / code. */
1036
+ reason: string; /** Additional details for the user-facing message (may be absent). */
1037
+ userMessageDetails?: Record<string, unknown>;
1038
+ };
1059
1039
  }
1060
1040
  /** Response shape for GET /v1/illust/detail. */
1061
1041
  interface IllustDetailResponse {
1062
- /** The requested illust. */
1063
- illust: PixivIllustItem;
1042
+ /** The requested illust. */
1043
+ illust: PixivIllustItem;
1064
1044
  }
1065
1045
  /** Page response for illust list endpoints (search, related, ranking, etc.). */
1066
1046
  interface IllustListPage {
1067
- /** Illusts on this page. */
1068
- illusts: PixivIllustItem[];
1069
- /**
1070
- * Whether AI-generated works are shown in the results.
1071
- *
1072
- * Only present on search responses; absent on related/ranking/recommended endpoints.
1073
- */
1074
- showAi?: boolean;
1075
- /** URL to the next page, or `null` when this is the last page. */
1076
- nextUrl: string | null;
1047
+ /** Illusts on this page. */
1048
+ illusts: PixivIllustItem[];
1049
+ /**
1050
+ * Whether AI-generated works are shown in the results.
1051
+ *
1052
+ * Only present on search responses; absent on related/ranking/recommended endpoints.
1053
+ */
1054
+ showAi?: boolean;
1055
+ /** URL to the next page, or `null` when this is the last page. */
1056
+ nextUrl: string | null;
1077
1057
  }
1078
1058
  /** Page response for GET /v1/illust/recommended. */
1079
1059
  interface IllustRecommendedPage {
1080
- /** Recommended illusts. */
1081
- illusts: PixivIllustItem[];
1082
- /** Ranking illusts included alongside recommendations. */
1083
- rankingIllusts: PixivIllustItem[];
1084
- /** Whether an ongoing contest exists. */
1085
- contestExists: boolean;
1086
- /** Privacy-policy notice (present on the first page). */
1087
- privacyPolicy?: PrivacyPolicy;
1088
- /** URL to the next page, or `null` when this is the last page. */
1089
- nextUrl: string | null;
1060
+ /** Recommended illusts. */
1061
+ illusts: PixivIllustItem[];
1062
+ /** Ranking illusts included alongside recommendations. */
1063
+ rankingIllusts: PixivIllustItem[];
1064
+ /** Whether an ongoing contest exists. */
1065
+ contestExists: boolean;
1066
+ /** Privacy-policy notice (present on the first page). */
1067
+ privacyPolicy?: PrivacyPolicy;
1068
+ /** URL to the next page, or `null` when this is the last page. */
1069
+ nextUrl: string | null;
1090
1070
  }
1091
1071
  /** Page response for GET /v1/illust/series. */
1092
1072
  interface IllustSeriesPage {
1093
- /** Metadata for the series. */
1094
- illustSeriesDetail: IllustSeriesDetail;
1095
- /** First illust in the series. */
1096
- illustSeriesFirstIllust: PixivIllustItem;
1097
- /** Illusts on this page. */
1098
- illusts: PixivIllustItem[];
1099
- /** URL to the next page, or `null` when this is the last page. */
1100
- nextUrl: string | null;
1073
+ /** Metadata for the series. */
1074
+ illustSeriesDetail: IllustSeriesDetail;
1075
+ /** First illust in the series. */
1076
+ illustSeriesFirstIllust: PixivIllustItem;
1077
+ /** Illusts on this page. */
1078
+ illusts: PixivIllustItem[];
1079
+ /** URL to the next page, or `null` when this is the last page. */
1080
+ nextUrl: string | null;
1101
1081
  }
1102
1082
  /** Page response for GET /v1/manga/recommended. */
1103
1083
  interface MangaRecommendedPage {
1104
- /** Recommended manga works. */
1105
- illusts: PixivIllustItem[];
1106
- /** Ranking manga works included alongside recommendations. */
1107
- rankingIllusts: PixivIllustItem[];
1108
- /** Privacy-policy notice (present on the first page). */
1109
- privacyPolicy?: PrivacyPolicy;
1110
- /** URL to the next page, or `null` when this is the last page. */
1111
- nextUrl: string | null;
1084
+ /** Recommended manga works. */
1085
+ illusts: PixivIllustItem[];
1086
+ /** Ranking manga works included alongside recommendations. */
1087
+ rankingIllusts: PixivIllustItem[];
1088
+ /** Privacy-policy notice (present on the first page). */
1089
+ privacyPolicy?: PrivacyPolicy;
1090
+ /** URL to the next page, or `null` when this is the last page. */
1091
+ nextUrl: string | null;
1112
1092
  }
1113
1093
  /** Response shape for GET /v1/ugoira/metadata. */
1114
1094
  interface UgoiraMetadataResponse {
1115
- /** Ugoira metadata (ZIP URLs and per-frame timings). */
1116
- ugoiraMetadata: PixivUgoiraItem;
1095
+ /** Ugoira metadata (ZIP URLs and per-frame timings). */
1096
+ ugoiraMetadata: PixivUgoiraItem;
1117
1097
  }
1118
1098
  /** Response shape for GET /v2/novel/detail. */
1119
1099
  interface NovelDetailResponse {
1120
- /** The requested novel. */
1121
- novel: PixivNovelItem;
1100
+ /** The requested novel. */
1101
+ novel: PixivNovelItem;
1122
1102
  }
1123
1103
  /** Page response for novel list endpoints (search, related, ranking, etc.). */
1124
1104
  interface NovelListPage {
1125
- /** Novels on this page. */
1126
- novels: PixivNovelItem[];
1127
- /**
1128
- * Whether AI-generated works are shown in the results.
1129
- *
1130
- * Only present on search responses; absent on related/ranking/recommended endpoints.
1131
- */
1132
- showAi?: boolean;
1133
- /** URL to the next page, or `null` when this is the last page. */
1134
- nextUrl: string | null;
1105
+ /** Novels on this page. */
1106
+ novels: PixivNovelItem[];
1107
+ /**
1108
+ * Whether AI-generated works are shown in the results.
1109
+ *
1110
+ * Only present on search responses; absent on related/ranking/recommended endpoints.
1111
+ */
1112
+ showAi?: boolean;
1113
+ /** URL to the next page, or `null` when this is the last page. */
1114
+ nextUrl: string | null;
1135
1115
  }
1136
1116
  /** Page response for GET /v1/novel/recommended. */
1137
1117
  interface NovelRecommendedPage {
1138
- /** Recommended novels. */
1139
- novels: PixivNovelItem[];
1140
- /** Ranking novels included alongside recommendations. */
1141
- rankingNovels: PixivNovelItem[];
1142
- /** Privacy-policy notice (present on the first page). */
1143
- privacyPolicy?: PrivacyPolicy;
1144
- /** URL to the next page, or `null` when this is the last page. */
1145
- nextUrl: string | null;
1118
+ /** Recommended novels. */
1119
+ novels: PixivNovelItem[];
1120
+ /** Ranking novels included alongside recommendations. */
1121
+ rankingNovels: PixivNovelItem[];
1122
+ /** Privacy-policy notice (present on the first page). */
1123
+ privacyPolicy?: PrivacyPolicy;
1124
+ /** URL to the next page, or `null` when this is the last page. */
1125
+ nextUrl: string | null;
1146
1126
  }
1147
1127
  /** Page response for GET /v2/novel/series. */
1148
1128
  interface NovelSeriesPage {
1149
- /** Metadata for the series. */
1150
- novelSeriesDetail: NovelSeriesDetail;
1151
- /** First novel in the series. */
1152
- novelSeriesFirstNovel: PixivNovelItem;
1153
- /** Most recently published novel in the series. */
1154
- novelSeriesLatestNovel: PixivNovelItem;
1155
- /** Novels on this page. */
1156
- novels: PixivNovelItem[];
1157
- /** URL to the next page, or `null` when this is the last page. */
1158
- nextUrl: string | null;
1129
+ /** Metadata for the series. */
1130
+ novelSeriesDetail: NovelSeriesDetail;
1131
+ /** First novel in the series. */
1132
+ novelSeriesFirstNovel: PixivNovelItem;
1133
+ /** Most recently published novel in the series. */
1134
+ novelSeriesLatestNovel: PixivNovelItem;
1135
+ /** Novels on this page. */
1136
+ novels: PixivNovelItem[];
1137
+ /** URL to the next page, or `null` when this is the last page. */
1138
+ nextUrl: string | null;
1159
1139
  }
1160
1140
  /** Response shape for GET /v1/user/detail. */
1161
1141
  interface UserDetailResponse {
1162
- /** Basic user info with self-introduction. */
1163
- user: PixivUserItem;
1164
- /** Detailed profile data. */
1165
- profile: PixivUserProfile;
1166
- /** Visibility settings for profile fields. */
1167
- profilePublicity: PixivUserProfilePublicity;
1168
- /** Workspace / desk-setup information. */
1169
- workspace: PixivUserProfileWorkspace;
1142
+ /** Basic user info with self-introduction. */
1143
+ user: PixivUserItem;
1144
+ /** Detailed profile data. */
1145
+ profile: PixivUserProfile;
1146
+ /** Visibility settings for profile fields. */
1147
+ profilePublicity: PixivUserProfilePublicity;
1148
+ /** Workspace / desk-setup information. */
1149
+ workspace: PixivUserProfileWorkspace;
1170
1150
  }
1171
1151
  /** Page response for GET /v1/user/illusts. */
1172
1152
  interface UserIllustsPage {
1173
- /** The user whose illusts are listed. */
1174
- user: PixivUser;
1175
- /** Illusts on this page. */
1176
- illusts: PixivIllustItem[];
1177
- /** URL to the next page, or `null` when this is the last page. */
1178
- nextUrl: string | null;
1153
+ /** The user whose illusts are listed. */
1154
+ user: PixivUser;
1155
+ /** Illusts on this page. */
1156
+ illusts: PixivIllustItem[];
1157
+ /** URL to the next page, or `null` when this is the last page. */
1158
+ nextUrl: string | null;
1179
1159
  }
1180
1160
  /** Page response for GET /v1/user/novels. */
1181
1161
  interface UserNovelsPage {
1182
- /** The user whose novels are listed. */
1183
- user: PixivUser;
1184
- /** Novels on this page. */
1185
- novels: PixivNovelItem[];
1186
- /** URL to the next page, or `null` when this is the last page. */
1187
- nextUrl: string | null;
1162
+ /** The user whose novels are listed. */
1163
+ user: PixivUser;
1164
+ /** Novels on this page. */
1165
+ novels: PixivNovelItem[];
1166
+ /** URL to the next page, or `null` when this is the last page. */
1167
+ nextUrl: string | null;
1188
1168
  }
1189
1169
  /** Page response for GET /v1/user/bookmarks/illust. */
1190
1170
  interface UserBookmarksIllustPage {
1191
- /** Bookmarked illusts on this page. */
1192
- illusts: PixivIllustItem[];
1193
- /** URL to the next page, or `null` when this is the last page. */
1194
- nextUrl: string | null;
1171
+ /** Bookmarked illusts on this page. */
1172
+ illusts: PixivIllustItem[];
1173
+ /** URL to the next page, or `null` when this is the last page. */
1174
+ nextUrl: string | null;
1195
1175
  }
1196
1176
  /** Page response for GET /v1/user/bookmarks/novel. */
1197
1177
  interface UserBookmarksNovelPage {
1198
- /** Bookmarked novels on this page. */
1199
- novels: PixivNovelItem[];
1200
- /** URL to the next page, or `null` when this is the last page. */
1201
- nextUrl: string | null;
1178
+ /** Bookmarked novels on this page. */
1179
+ novels: PixivNovelItem[];
1180
+ /** URL to the next page, or `null` when this is the last page. */
1181
+ nextUrl: string | null;
1202
1182
  }
1203
1183
  /** Page response for GET /v1/user/following. */
1204
1184
  interface UserFollowingPage {
1205
- /** User preview items on this page. */
1206
- userPreviews: PixivUserPreviewItem[];
1207
- /** URL to the next page, or `null` when this is the last page. */
1208
- nextUrl: string | null;
1185
+ /** User preview items on this page. */
1186
+ userPreviews: PixivUserPreviewItem[];
1187
+ /** URL to the next page, or `null` when this is the last page. */
1188
+ nextUrl: string | null;
1209
1189
  }
1210
-
1211
- /**
1212
- * IllustResource — methods for the illust API namespace.
1213
- */
1214
-
1190
+ //#endregion
1191
+ //#region src/resources/illusts.d.ts
1215
1192
  /** Parameters for fetching a single illust by ID. */
1216
1193
  interface IllustDetailParams {
1217
- /** ID of the illust to fetch. */
1218
- illustId: number;
1219
- /** OS filter to apply (default: `"for_ios"`). */
1220
- filter?: (typeof OSFilter)[keyof typeof OSFilter];
1194
+ /** ID of the illust to fetch. */
1195
+ illustId: number;
1196
+ /** OS filter to apply (default: `"for_ios"`). */
1197
+ filter?: (typeof OSFilter)[keyof typeof OSFilter];
1221
1198
  }
1222
1199
  /** Parameters for fetching related illusts. */
1223
1200
  interface IllustRelatedParams {
1224
- /** ID of the illust for which to fetch related works. */
1225
- illustId: number;
1226
- /** Additional seed illust IDs to influence recommendations. */
1227
- seedIllustIds?: number[];
1228
- /** OS filter to apply (default: `"for_ios"`). */
1229
- filter?: (typeof OSFilter)[keyof typeof OSFilter];
1201
+ /** ID of the illust for which to fetch related works. */
1202
+ illustId: number;
1203
+ /** Additional seed illust IDs to influence recommendations. */
1204
+ seedIllustIds?: number[];
1205
+ /** OS filter to apply (default: `"for_ios"`). */
1206
+ filter?: (typeof OSFilter)[keyof typeof OSFilter];
1230
1207
  }
1231
1208
  /** Parameters for searching illusts. */
1232
1209
  interface IllustSearchParams {
1233
- /** Search keyword. */
1234
- word: string;
1235
- /** How to match the keyword against works (default: `"partial_match_for_tags"`). */
1236
- searchTarget?: (typeof SearchTarget)[keyof typeof SearchTarget];
1237
- /** Sort order for results (default: `"date_desc"`). */
1238
- sort?: (typeof SearchSort)[keyof typeof SearchSort];
1239
- /** Date range preset filter (omit for no restriction). */
1240
- duration?: (typeof SearchDuration)[keyof typeof SearchDuration];
1241
- /** Start date for a custom date range (YYYY-MM-DD; requires `endDate`). */
1242
- startDate?: string;
1243
- /** End date for a custom date range (YYYY-MM-DD; requires `startDate`). */
1244
- endDate?: string;
1245
- /** OS filter to apply (default: `"for_ios"`). */
1246
- filter?: (typeof OSFilter)[keyof typeof OSFilter];
1247
- /** AI-generated content filter: `0` = hide AI works, `1` = show only AI works. */
1248
- searchAiType?: 0 | 1;
1249
- /** Zero-based offset for pagination. */
1250
- offset?: number;
1210
+ /** Search keyword. */
1211
+ word: string;
1212
+ /** How to match the keyword against works (default: `"partial_match_for_tags"`). */
1213
+ searchTarget?: (typeof SearchTarget)[keyof typeof SearchTarget];
1214
+ /** Sort order for results (default: `"date_desc"`). */
1215
+ sort?: (typeof SearchSort)[keyof typeof SearchSort];
1216
+ /** Date range preset filter (omit for no restriction). */
1217
+ duration?: (typeof SearchDuration)[keyof typeof SearchDuration];
1218
+ /** Start date for a custom date range (YYYY-MM-DD; requires `endDate`). */
1219
+ startDate?: string;
1220
+ /** End date for a custom date range (YYYY-MM-DD; requires `startDate`). */
1221
+ endDate?: string;
1222
+ /** OS filter to apply (default: `"for_ios"`). */
1223
+ filter?: (typeof OSFilter)[keyof typeof OSFilter];
1224
+ /** AI-generated content filter: `0` = hide AI works, `1` = show only AI works. */
1225
+ searchAiType?: 0 | 1;
1226
+ /** Zero-based offset for pagination. */
1227
+ offset?: number;
1251
1228
  }
1252
1229
  /** Parameters for fetching the illust ranking. */
1253
1230
  interface IllustRankingParams {
1254
- /** Ranking category (default: `"day"`). */
1255
- mode?: (typeof RankingMode)[keyof typeof RankingMode];
1256
- /** OS filter to apply (default: `"for_ios"`). */
1257
- filter?: (typeof OSFilter)[keyof typeof OSFilter];
1258
- /** Specific date to fetch rankings for (YYYY-MM-DD; omit for the latest). */
1259
- date?: string;
1260
- /** Zero-based offset for pagination. */
1261
- offset?: number;
1231
+ /** Ranking category (default: `"day"`). */
1232
+ mode?: (typeof RankingMode)[keyof typeof RankingMode];
1233
+ /** OS filter to apply (default: `"for_ios"`). */
1234
+ filter?: (typeof OSFilter)[keyof typeof OSFilter];
1235
+ /** Specific date to fetch rankings for (YYYY-MM-DD; omit for the latest). */
1236
+ date?: string;
1237
+ /** Zero-based offset for pagination. */
1238
+ offset?: number;
1262
1239
  }
1263
1240
  /** Parameters for fetching recommended illusts. */
1264
1241
  interface IllustRecommendedParams {
1265
- /** OS filter to apply (default: `"for_ios"`). */
1266
- filter?: (typeof OSFilter)[keyof typeof OSFilter];
1267
- /** Zero-based offset for pagination. */
1268
- offset?: number;
1269
- /**
1270
- * Cursor for resuming pagination: the `maxBookmarkIdForRecommend` value
1271
- * extracted from a previous page's `next_url` via {@link parseNextUrl}.
1272
- */
1273
- maxBookmarkIdForRecommend?: number;
1274
- /**
1275
- * Secondary cursor for resuming pagination: the `minBookmarkIdForRecentIllust`
1276
- * value extracted from a previous page's `next_url` via {@link parseNextUrl}.
1277
- */
1278
- minBookmarkIdForRecentIllust?: number;
1242
+ /** OS filter to apply (default: `"for_ios"`). */
1243
+ filter?: (typeof OSFilter)[keyof typeof OSFilter];
1244
+ /** Zero-based offset for pagination. */
1245
+ offset?: number;
1246
+ /**
1247
+ * Cursor for resuming pagination: the `maxBookmarkIdForRecommend` value
1248
+ * extracted from a previous page's `next_url` via {@link parseNextUrl}.
1249
+ */
1250
+ maxBookmarkIdForRecommend?: number;
1251
+ /**
1252
+ * Secondary cursor for resuming pagination: the `minBookmarkIdForRecentIllust`
1253
+ * value extracted from a previous page's `next_url` via {@link parseNextUrl}.
1254
+ */
1255
+ minBookmarkIdForRecentIllust?: number;
1256
+ /**
1257
+ * Content type filter for recommended works.
1258
+ * - `"illust"` — illustration works only
1259
+ * - `"manga"` — manga works only
1260
+ * Omit to receive both types.
1261
+ */
1262
+ contentType?: 'illust' | 'manga';
1263
+ /**
1264
+ * Whether to include ranking label information in the response.
1265
+ * Defaults to `true` when omitted.
1266
+ */
1267
+ includeRankingLabel?: boolean;
1268
+ /**
1269
+ * IDs of illusts already seen by the user.
1270
+ * The API will exclude these from the recommendations.
1271
+ * Serialised as repeated `viewed[]=<id>` query parameters.
1272
+ */
1273
+ viewed?: number[];
1279
1274
  }
1280
1275
  /** Parameters for fetching an illust series. */
1281
1276
  interface IllustSeriesParams {
1282
- /** ID of the illust series to fetch. */
1283
- illustSeriesId: number;
1284
- /** OS filter to apply (default: `"for_ios"`). */
1285
- filter?: (typeof OSFilter)[keyof typeof OSFilter];
1277
+ /** ID of the illust series to fetch. */
1278
+ illustSeriesId: number;
1279
+ /** OS filter to apply (default: `"for_ios"`). */
1280
+ filter?: (typeof OSFilter)[keyof typeof OSFilter];
1286
1281
  }
1287
1282
  /** Parameters for adding an illust bookmark. */
1288
1283
  interface IllustBookmarkAddParams {
1289
- /** ID of the illust to bookmark. */
1290
- illustId: number;
1291
- /** Bookmark visibility (default: `"public"`). */
1292
- restrict?: (typeof BookmarkRestrict)[keyof typeof BookmarkRestrict];
1293
- /** Tags to attach to the bookmark. */
1294
- tags?: string[];
1284
+ /** ID of the illust to bookmark. */
1285
+ illustId: number;
1286
+ /** Bookmark visibility (default: `"public"`). */
1287
+ restrict?: (typeof BookmarkRestrict)[keyof typeof BookmarkRestrict];
1288
+ /** Tags to attach to the bookmark. */
1289
+ tags?: string[];
1295
1290
  }
1296
1291
  /** Parameters for removing an illust bookmark. */
1297
1292
  interface IllustBookmarkDeleteParams {
1298
- /** ID of the illust to remove from bookmarks. */
1299
- illustId: number;
1293
+ /** ID of the illust to remove from bookmarks. */
1294
+ illustId: number;
1300
1295
  }
1301
1296
  /** Methods for the illust API namespace. */
1302
1297
  declare class IllustResource {
1303
- #private;
1304
- constructor(http: HttpClient);
1305
- /**
1306
- * Fetches a single illust by ID.
1307
- * GET /v1/illust/detail
1308
- *
1309
- * @param params - Request parameters
1310
- *
1311
- * @example
1312
- * ```ts
1313
- * const result = await client.illusts.detail({ illustId: 12345 })
1314
- * if (result.isOk) {
1315
- * console.log(result.value.illust.title)
1316
- * } else {
1317
- * console.error(result.error)
1318
- * }
1319
- * ```
1320
- */
1321
- detail(params: IllustDetailParams): ResultAsync<IllustDetailResponse, PixivError>;
1322
- /**
1323
- * Fetches related illusts for a given illust.
1324
- * GET /v2/illust/related
1325
- *
1326
- * @param params - Request parameters
1327
- */
1328
- related(params: IllustRelatedParams): PaginatedResultAsync<IllustListPage, IllustListPage['illusts'][number]>;
1329
- /**
1330
- * Searches for illusts.
1331
- * GET /v1/search/illust
1332
- *
1333
- * @param params - Request parameters
1334
- *
1335
- * @example
1336
- * ```ts
1337
- * // Iterate all results across pages
1338
- * for await (const illust of client.illusts.search({ word: 'cat' }).items()) {
1339
- * console.log(illust.title)
1340
- * }
1341
- *
1342
- * // Fetch only the first page
1343
- * const page = await client.illusts.search({ word: 'cat' })
1344
- * if (page.isOk) {
1345
- * console.log(page.value.illusts.length)
1346
- * }
1347
- * ```
1348
- */
1349
- search(params: IllustSearchParams): PaginatedResultAsync<IllustListPage, IllustListPage['illusts'][number]>;
1350
- /**
1351
- * Fetches the illust ranking.
1352
- * GET /v1/illust/ranking
1353
- *
1354
- * @param params - Request parameters
1355
- */
1356
- ranking(params?: IllustRankingParams): PaginatedResultAsync<IllustListPage, IllustListPage['illusts'][number]>;
1357
- /**
1358
- * Fetches recommended illusts.
1359
- * GET /v1/illust/recommended
1360
- *
1361
- * @param params - Request parameters
1362
- */
1363
- recommended(params?: IllustRecommendedParams): PaginatedResultAsync<IllustRecommendedPage, IllustRecommendedPage['illusts'][number]>;
1364
- /**
1365
- * Fetches an illust series.
1366
- * GET /v1/illust/series
1367
- *
1368
- * @param params - Request parameters
1369
- */
1370
- series(params: IllustSeriesParams): PaginatedResultAsync<IllustSeriesPage, IllustSeriesPage['illusts'][number]>;
1371
- /**
1372
- * Adds an illust bookmark.
1373
- * POST /v2/illust/bookmark/add
1374
- *
1375
- * @param params - Request parameters
1376
- */
1377
- bookmarkAdd(params: IllustBookmarkAddParams): ResultAsync<Record<string, never>, PixivError>;
1378
- /**
1379
- * Removes an illust bookmark.
1380
- * POST /v1/illust/bookmark/delete
1381
- *
1382
- * @param params - Request parameters
1383
- */
1384
- bookmarkDelete(params: IllustBookmarkDeleteParams): ResultAsync<Record<string, never>, PixivError>;
1385
- }
1386
-
1387
- /**
1388
- * NovelResource — methods for the novel API namespace.
1389
- */
1390
-
1298
+ #private;
1299
+ constructor(http: HttpClient);
1300
+ /**
1301
+ * Fetches a single illust by ID.
1302
+ * GET /v1/illust/detail
1303
+ *
1304
+ * @param params - Request parameters
1305
+ *
1306
+ * @example
1307
+ * ```ts
1308
+ * const result = await client.illusts.detail({ illustId: 12345 })
1309
+ * if (result.isOk) {
1310
+ * console.log(result.value.illust.title)
1311
+ * } else {
1312
+ * console.error(result.error)
1313
+ * }
1314
+ * ```
1315
+ */
1316
+ detail(params: IllustDetailParams): ResultAsync<IllustDetailResponse, PixivError>;
1317
+ /**
1318
+ * Fetches related illusts for a given illust.
1319
+ * GET /v2/illust/related
1320
+ *
1321
+ * @param params - Request parameters
1322
+ */
1323
+ related(params: IllustRelatedParams): PaginatedResultAsync<IllustListPage, IllustListPage['illusts'][number]>;
1324
+ /**
1325
+ * Searches for illusts.
1326
+ * GET /v1/search/illust
1327
+ *
1328
+ * @param params - Request parameters
1329
+ *
1330
+ * @example
1331
+ * ```ts
1332
+ * // Iterate all results across pages
1333
+ * for await (const illust of client.illusts.search({ word: 'cat' }).items()) {
1334
+ * console.log(illust.title)
1335
+ * }
1336
+ *
1337
+ * // Fetch only the first page
1338
+ * const page = await client.illusts.search({ word: 'cat' })
1339
+ * if (page.isOk) {
1340
+ * console.log(page.value.illusts.length)
1341
+ * }
1342
+ * ```
1343
+ */
1344
+ search(params: IllustSearchParams): PaginatedResultAsync<IllustListPage, IllustListPage['illusts'][number]>;
1345
+ /**
1346
+ * Fetches the illust ranking.
1347
+ * GET /v1/illust/ranking
1348
+ *
1349
+ * @param params - Request parameters
1350
+ */
1351
+ ranking(params?: IllustRankingParams): PaginatedResultAsync<IllustListPage, IllustListPage['illusts'][number]>;
1352
+ /**
1353
+ * Fetches recommended illusts.
1354
+ * GET /v1/illust/recommended
1355
+ *
1356
+ * @param params - Request parameters
1357
+ */
1358
+ recommended(params?: IllustRecommendedParams): PaginatedResultAsync<IllustRecommendedPage, IllustRecommendedPage['illusts'][number]>;
1359
+ /**
1360
+ * Fetches an illust series.
1361
+ * GET /v1/illust/series
1362
+ *
1363
+ * @param params - Request parameters
1364
+ */
1365
+ series(params: IllustSeriesParams): PaginatedResultAsync<IllustSeriesPage, IllustSeriesPage['illusts'][number]>;
1366
+ /**
1367
+ * Adds an illust bookmark.
1368
+ * POST /v2/illust/bookmark/add
1369
+ *
1370
+ * @param params - Request parameters
1371
+ */
1372
+ bookmarkAdd(params: IllustBookmarkAddParams): ResultAsync<Record<string, never>, PixivError>;
1373
+ /**
1374
+ * Removes an illust bookmark.
1375
+ * POST /v1/illust/bookmark/delete
1376
+ *
1377
+ * @param params - Request parameters
1378
+ */
1379
+ bookmarkDelete(params: IllustBookmarkDeleteParams): ResultAsync<Record<string, never>, PixivError>;
1380
+ }
1381
+ //#endregion
1382
+ //#region src/resources/novels.d.ts
1391
1383
  /** Parameters for fetching a single novel by ID. */
1392
1384
  interface NovelDetailParams {
1393
- /** ID of the novel to fetch. */
1394
- novelId: number;
1385
+ /** ID of the novel to fetch. */
1386
+ novelId: number;
1395
1387
  }
1396
1388
  /** Parameters for fetching the WebView HTML of a novel. */
1397
1389
  interface NovelTextParams {
1398
- /** ID of the novel whose WebView HTML to fetch. */
1399
- novelId: number;
1390
+ /** ID of the novel whose WebView HTML to fetch. */
1391
+ novelId: number;
1400
1392
  }
1401
1393
  /** Parameters for fetching related novels. */
1402
1394
  interface NovelRelatedParams {
1403
- /** ID of the novel for which to fetch related works. */
1404
- novelId: number;
1395
+ /** ID of the novel for which to fetch related works. */
1396
+ novelId: number;
1405
1397
  }
1406
1398
  /** Parameters for searching novels. */
1407
1399
  interface NovelSearchParams {
1408
- /** Search keyword. */
1409
- word: string;
1410
- /** How to match the keyword against works (default: `"partial_match_for_tags"`). */
1411
- searchTarget?: (typeof SearchTarget)[keyof typeof SearchTarget];
1412
- /** Sort order for results (default: `"date_desc"`). */
1413
- sort?: (typeof SearchSort)[keyof typeof SearchSort];
1414
- /** OS filter to apply (default: `"for_ios"`). */
1415
- filter?: (typeof OSFilter)[keyof typeof OSFilter];
1416
- /** Date range preset filter (omit for no restriction). */
1417
- duration?: (typeof SearchDuration)[keyof typeof SearchDuration];
1418
- /** Start date for a custom date range (YYYY-MM-DD; requires `endDate`). */
1419
- startDate?: string;
1420
- /** End date for a custom date range (YYYY-MM-DD; requires `startDate`). */
1421
- endDate?: string;
1422
- /** AI-generated content filter: `0` = hide AI works, `1` = show only AI works. */
1423
- searchAiType?: 0 | 1;
1424
- /** Zero-based offset for pagination. */
1425
- offset?: number;
1400
+ /** Search keyword. */
1401
+ word: string;
1402
+ /** How to match the keyword against works (default: `"partial_match_for_tags"`). */
1403
+ searchTarget?: (typeof SearchTarget)[keyof typeof SearchTarget];
1404
+ /** Sort order for results (default: `"date_desc"`). */
1405
+ sort?: (typeof SearchSort)[keyof typeof SearchSort];
1406
+ /** OS filter to apply (default: `"for_ios"`). */
1407
+ filter?: (typeof OSFilter)[keyof typeof OSFilter];
1408
+ /** Date range preset filter (omit for no restriction). */
1409
+ duration?: (typeof SearchDuration)[keyof typeof SearchDuration];
1410
+ /** Start date for a custom date range (YYYY-MM-DD; requires `endDate`). */
1411
+ startDate?: string;
1412
+ /** End date for a custom date range (YYYY-MM-DD; requires `startDate`). */
1413
+ endDate?: string;
1414
+ /** AI-generated content filter: `0` = hide AI works, `1` = show only AI works. */
1415
+ searchAiType?: 0 | 1;
1416
+ /** Zero-based offset for pagination. */
1417
+ offset?: number;
1426
1418
  }
1427
1419
  /** Parameters for fetching the novel ranking. */
1428
1420
  interface NovelRankingParams {
1429
- /** Ranking category (default: `"day"`). */
1430
- mode?: (typeof NovelRankingMode)[keyof typeof NovelRankingMode];
1431
- /** OS filter to apply (default: `"for_ios"`). */
1432
- filter?: (typeof OSFilter)[keyof typeof OSFilter];
1433
- /** Specific date to fetch rankings for (YYYY-MM-DD; omit for the latest). */
1434
- date?: string;
1435
- /** Zero-based offset for pagination. */
1436
- offset?: number;
1421
+ /** Ranking category (default: `"day"`). */
1422
+ mode?: (typeof NovelRankingMode)[keyof typeof NovelRankingMode];
1423
+ /** OS filter to apply (default: `"for_ios"`). */
1424
+ filter?: (typeof OSFilter)[keyof typeof OSFilter];
1425
+ /** Specific date to fetch rankings for (YYYY-MM-DD; omit for the latest). */
1426
+ date?: string;
1427
+ /** Zero-based offset for pagination. */
1428
+ offset?: number;
1437
1429
  }
1438
1430
  /** Parameters for fetching recommended novels. */
1439
1431
  interface NovelRecommendedParams {
1440
- /** OS filter to apply (default: `"for_ios"`). */
1441
- filter?: (typeof OSFilter)[keyof typeof OSFilter];
1442
- /** Zero-based offset for pagination. */
1443
- offset?: number;
1444
- /**
1445
- * Cursor for resuming pagination: the `maxBookmarkIdForRecommend` value
1446
- * extracted from a previous page's `next_url` via {@link parseNextUrl}.
1447
- */
1448
- maxBookmarkIdForRecommend?: number;
1432
+ /** OS filter to apply (default: `"for_ios"`). */
1433
+ filter?: (typeof OSFilter)[keyof typeof OSFilter];
1434
+ /** Zero-based offset for pagination. */
1435
+ offset?: number;
1436
+ /**
1437
+ * Cursor for resuming pagination: the `maxBookmarkIdForRecommend` value
1438
+ * extracted from a previous page's `next_url` via {@link parseNextUrl}.
1439
+ */
1440
+ maxBookmarkIdForRecommend?: number;
1449
1441
  }
1450
1442
  /** Parameters for fetching a novel series. */
1451
1443
  interface NovelSeriesParams {
1452
- /** ID of the novel series to fetch. */
1453
- seriesId: number;
1454
- /** Order of the last novel already seen; used for cursor-based pagination. */
1455
- lastOrder?: number;
1444
+ /** ID of the novel series to fetch. */
1445
+ seriesId: number;
1446
+ /** Order of the last novel already seen; used for cursor-based pagination. */
1447
+ lastOrder?: number;
1456
1448
  }
1457
1449
  /** Parameters for adding a novel bookmark. */
1458
1450
  interface NovelBookmarkAddParams {
1459
- /** ID of the novel to bookmark. */
1460
- novelId: number;
1461
- /** Bookmark visibility (default: `"public"`). */
1462
- restrict?: (typeof BookmarkRestrict)[keyof typeof BookmarkRestrict];
1463
- /** Tags to attach to the bookmark. */
1464
- tags?: string[];
1451
+ /** ID of the novel to bookmark. */
1452
+ novelId: number;
1453
+ /** Bookmark visibility (default: `"public"`). */
1454
+ restrict?: (typeof BookmarkRestrict)[keyof typeof BookmarkRestrict];
1455
+ /** Tags to attach to the bookmark. */
1456
+ tags?: string[];
1465
1457
  }
1466
1458
  /** Parameters for removing a novel bookmark. */
1467
1459
  interface NovelBookmarkDeleteParams {
1468
- /** ID of the novel to remove from bookmarks. */
1469
- novelId: number;
1460
+ /** ID of the novel to remove from bookmarks. */
1461
+ novelId: number;
1470
1462
  }
1471
1463
  /** Methods for the novel API namespace. */
1472
1464
  declare class NovelResource {
1473
- #private;
1474
- constructor(http: HttpClient);
1475
- /**
1476
- * Fetches a single novel by ID.
1477
- * GET /v2/novel/detail
1478
- *
1479
- * @param params - Request parameters
1480
- *
1481
- * @example
1482
- * ```ts
1483
- * const result = await client.novels.detail({ novelId: 67890 })
1484
- * if (result.isOk) {
1485
- * console.log(result.value.novel.title)
1486
- * } else {
1487
- * console.error(result.error)
1488
- * }
1489
- * ```
1490
- */
1491
- detail(params: NovelDetailParams): ResultAsync<NovelDetailResponse, PixivError>;
1492
- /**
1493
- * Fetches the WebView HTML for a novel.
1494
- * GET /webview/v2/novel
1495
- *
1496
- * Returns the raw HTML page that the pixiv app renders in a WebView.
1497
- * To extract the plain text, parse the returned HTML (e.g. strip tags).
1498
- *
1499
- * @param params - Request parameters
1500
- */
1501
- text(params: NovelTextParams): ResultAsync<string, PixivError>;
1502
- /**
1503
- * Fetches related novels for a given novel.
1504
- * GET /v1/novel/related
1505
- *
1506
- * @param params - Request parameters
1507
- */
1508
- related(params: NovelRelatedParams): PaginatedResultAsync<NovelListPage, PixivNovelItem>;
1509
- /**
1510
- * Searches for novels.
1511
- * GET /v1/search/novel
1512
- *
1513
- * @param params - Request parameters
1514
- *
1515
- * @example
1516
- * ```ts
1517
- * // Iterate all results across pages
1518
- * for await (const novel of client.novels.search({ word: 'fantasy' }).items()) {
1519
- * console.log(novel.title)
1520
- * }
1521
- *
1522
- * // Fetch only the first page
1523
- * const page = await client.novels.search({ word: 'fantasy' })
1524
- * if (page.isOk) {
1525
- * console.log(page.value.novels.length)
1526
- * }
1527
- * ```
1528
- */
1529
- search(params: NovelSearchParams): PaginatedResultAsync<NovelListPage, PixivNovelItem>;
1530
- /**
1531
- * Fetches the novel ranking.
1532
- * GET /v1/novel/ranking
1533
- *
1534
- * @param params - Request parameters
1535
- */
1536
- ranking(params?: NovelRankingParams): PaginatedResultAsync<NovelListPage, PixivNovelItem>;
1537
- /**
1538
- * Fetches recommended novels.
1539
- * GET /v1/novel/recommended
1540
- *
1541
- * @param params - Request parameters
1542
- */
1543
- recommended(params?: NovelRecommendedParams): PaginatedResultAsync<NovelRecommendedPage, PixivNovelItem>;
1544
- /**
1545
- * Fetches a novel series.
1546
- * GET /v2/novel/series
1547
- *
1548
- * @param params - Request parameters
1549
- */
1550
- series(params: NovelSeriesParams): PaginatedResultAsync<NovelSeriesPage, PixivNovelItem>;
1551
- /**
1552
- * Adds a novel bookmark.
1553
- * POST /v2/novel/bookmark/add
1554
- *
1555
- * @param params - Request parameters
1556
- */
1557
- bookmarkAdd(params: NovelBookmarkAddParams): ResultAsync<Record<string, never>, PixivError>;
1558
- /**
1559
- * Removes a novel bookmark.
1560
- * POST /v1/novel/bookmark/delete
1561
- *
1562
- * @param params - Request parameters
1563
- */
1564
- bookmarkDelete(params: NovelBookmarkDeleteParams): ResultAsync<Record<string, never>, PixivError>;
1565
- }
1566
-
1567
- /**
1568
- * UserResource — methods for the user API namespace.
1569
- */
1570
-
1465
+ #private;
1466
+ constructor(http: HttpClient);
1467
+ /**
1468
+ * Fetches a single novel by ID.
1469
+ * GET /v2/novel/detail
1470
+ *
1471
+ * @param params - Request parameters
1472
+ *
1473
+ * @example
1474
+ * ```ts
1475
+ * const result = await client.novels.detail({ novelId: 67890 })
1476
+ * if (result.isOk) {
1477
+ * console.log(result.value.novel.title)
1478
+ * } else {
1479
+ * console.error(result.error)
1480
+ * }
1481
+ * ```
1482
+ */
1483
+ detail(params: NovelDetailParams): ResultAsync<NovelDetailResponse, PixivError>;
1484
+ /**
1485
+ * Fetches the WebView HTML for a novel.
1486
+ * GET /webview/v2/novel
1487
+ *
1488
+ * Returns the raw HTML page that the pixiv app renders in a WebView.
1489
+ * To extract the plain text, parse the returned HTML (e.g. strip tags).
1490
+ *
1491
+ * @param params - Request parameters
1492
+ */
1493
+ text(params: NovelTextParams): ResultAsync<string, PixivError>;
1494
+ /**
1495
+ * Fetches related novels for a given novel.
1496
+ * GET /v1/novel/related
1497
+ *
1498
+ * @param params - Request parameters
1499
+ */
1500
+ related(params: NovelRelatedParams): PaginatedResultAsync<NovelListPage, PixivNovelItem>;
1501
+ /**
1502
+ * Searches for novels.
1503
+ * GET /v1/search/novel
1504
+ *
1505
+ * @param params - Request parameters
1506
+ *
1507
+ * @example
1508
+ * ```ts
1509
+ * // Iterate all results across pages
1510
+ * for await (const novel of client.novels.search({ word: 'fantasy' }).items()) {
1511
+ * console.log(novel.title)
1512
+ * }
1513
+ *
1514
+ * // Fetch only the first page
1515
+ * const page = await client.novels.search({ word: 'fantasy' })
1516
+ * if (page.isOk) {
1517
+ * console.log(page.value.novels.length)
1518
+ * }
1519
+ * ```
1520
+ */
1521
+ search(params: NovelSearchParams): PaginatedResultAsync<NovelListPage, PixivNovelItem>;
1522
+ /**
1523
+ * Fetches the novel ranking.
1524
+ * GET /v1/novel/ranking
1525
+ *
1526
+ * @param params - Request parameters
1527
+ */
1528
+ ranking(params?: NovelRankingParams): PaginatedResultAsync<NovelListPage, PixivNovelItem>;
1529
+ /**
1530
+ * Fetches recommended novels.
1531
+ * GET /v1/novel/recommended
1532
+ *
1533
+ * @param params - Request parameters
1534
+ */
1535
+ recommended(params?: NovelRecommendedParams): PaginatedResultAsync<NovelRecommendedPage, PixivNovelItem>;
1536
+ /**
1537
+ * Fetches a novel series.
1538
+ * GET /v2/novel/series
1539
+ *
1540
+ * @param params - Request parameters
1541
+ */
1542
+ series(params: NovelSeriesParams): PaginatedResultAsync<NovelSeriesPage, PixivNovelItem>;
1543
+ /**
1544
+ * Adds a novel bookmark.
1545
+ * POST /v2/novel/bookmark/add
1546
+ *
1547
+ * @param params - Request parameters
1548
+ */
1549
+ bookmarkAdd(params: NovelBookmarkAddParams): ResultAsync<Record<string, never>, PixivError>;
1550
+ /**
1551
+ * Removes a novel bookmark.
1552
+ * POST /v1/novel/bookmark/delete
1553
+ *
1554
+ * @param params - Request parameters
1555
+ */
1556
+ bookmarkDelete(params: NovelBookmarkDeleteParams): ResultAsync<Record<string, never>, PixivError>;
1557
+ }
1558
+ //#endregion
1559
+ //#region src/resources/users.d.ts
1571
1560
  /** Parameters for fetching a user's bookmarked illusts. */
1572
1561
  interface UserBookmarksIllustParams {
1573
- /** ID of the user whose bookmarks to fetch. */
1574
- userId: number;
1575
- /** Visibility of the bookmarks to return (default: `"public"`). */
1576
- restrict?: (typeof BookmarkRestrict)[keyof typeof BookmarkRestrict];
1577
- /** OS filter to apply (default: `"for_ios"`). */
1578
- filter?: (typeof OSFilter)[keyof typeof OSFilter];
1579
- /** Limit results to bookmarks with this tag. */
1580
- tag?: string;
1581
- /** Fetch bookmarks older than this bookmark ID (cursor-based pagination). */
1582
- maxBookmarkId?: number;
1583
- /** Zero-based offset for pagination. */
1584
- offset?: number;
1562
+ /** ID of the user whose bookmarks to fetch. */
1563
+ userId: number;
1564
+ /** Visibility of the bookmarks to return (default: `"public"`). */
1565
+ restrict?: (typeof BookmarkRestrict)[keyof typeof BookmarkRestrict];
1566
+ /** OS filter to apply (default: `"for_ios"`). */
1567
+ filter?: (typeof OSFilter)[keyof typeof OSFilter];
1568
+ /** Limit results to bookmarks with this tag. */
1569
+ tag?: string;
1570
+ /** Fetch bookmarks older than this bookmark ID (cursor-based pagination). */
1571
+ maxBookmarkId?: number;
1572
+ /** Zero-based offset for pagination. */
1573
+ offset?: number;
1585
1574
  }
1586
1575
  /** Parameters for fetching a user's bookmarked novels. */
1587
1576
  interface UserBookmarksNovelParams {
1588
- /** ID of the user whose bookmarks to fetch. */
1589
- userId: number;
1590
- /** Visibility of the bookmarks to return (default: `"public"`). */
1591
- restrict?: (typeof BookmarkRestrict)[keyof typeof BookmarkRestrict];
1592
- /** OS filter to apply (default: `"for_ios"`). */
1593
- filter?: (typeof OSFilter)[keyof typeof OSFilter];
1594
- /** Limit results to bookmarks with this tag. */
1595
- tag?: string;
1596
- /** Fetch bookmarks older than this bookmark ID (cursor-based pagination). */
1597
- maxBookmarkId?: number;
1598
- /** Zero-based offset for pagination. */
1599
- offset?: number;
1577
+ /** ID of the user whose bookmarks to fetch. */
1578
+ userId: number;
1579
+ /** Visibility of the bookmarks to return (default: `"public"`). */
1580
+ restrict?: (typeof BookmarkRestrict)[keyof typeof BookmarkRestrict];
1581
+ /** OS filter to apply (default: `"for_ios"`). */
1582
+ filter?: (typeof OSFilter)[keyof typeof OSFilter];
1583
+ /** Limit results to bookmarks with this tag. */
1584
+ tag?: string;
1585
+ /** Fetch bookmarks older than this bookmark ID (cursor-based pagination). */
1586
+ maxBookmarkId?: number;
1587
+ /** Zero-based offset for pagination. */
1588
+ offset?: number;
1600
1589
  }
1601
1590
  /** Parameters for fetching a user's detail. */
1602
1591
  interface UserDetailParams {
1603
- /** ID of the user to fetch. */
1604
- userId: number;
1605
- /** OS filter to apply (default: `"for_ios"`). */
1606
- filter?: (typeof OSFilter)[keyof typeof OSFilter];
1592
+ /** ID of the user to fetch. */
1593
+ userId: number;
1594
+ /** OS filter to apply (default: `"for_ios"`). */
1595
+ filter?: (typeof OSFilter)[keyof typeof OSFilter];
1607
1596
  }
1608
1597
  /** Parameters for fetching a user's illusts. */
1609
1598
  interface UserIllustsParams {
1610
- /** ID of the user whose illusts to fetch. */
1611
- userId: number;
1612
- /** Work type to filter by (omit to return both illusts and manga). */
1613
- type?: (typeof UserIllustType)[keyof typeof UserIllustType];
1614
- /** OS filter to apply (default: `"for_ios"`). */
1615
- filter?: (typeof OSFilter)[keyof typeof OSFilter];
1616
- /** Zero-based offset for pagination. */
1617
- offset?: number;
1599
+ /** ID of the user whose illusts to fetch. */
1600
+ userId: number;
1601
+ /** Work type to filter by (omit to return both illusts and manga). */
1602
+ type?: (typeof UserIllustType)[keyof typeof UserIllustType];
1603
+ /** OS filter to apply (default: `"for_ios"`). */
1604
+ filter?: (typeof OSFilter)[keyof typeof OSFilter];
1605
+ /** Zero-based offset for pagination. */
1606
+ offset?: number;
1618
1607
  }
1619
1608
  /** Parameters for fetching a user's novels. */
1620
1609
  interface UserNovelsParams {
1621
- /** ID of the user whose novels to fetch. */
1622
- userId: number;
1623
- /** OS filter to apply (default: `"for_ios"`). */
1624
- filter?: (typeof OSFilter)[keyof typeof OSFilter];
1625
- /** Zero-based offset for pagination. */
1626
- offset?: number;
1610
+ /** ID of the user whose novels to fetch. */
1611
+ userId: number;
1612
+ /** OS filter to apply (default: `"for_ios"`). */
1613
+ filter?: (typeof OSFilter)[keyof typeof OSFilter];
1614
+ /** Zero-based offset for pagination. */
1615
+ offset?: number;
1627
1616
  }
1628
1617
  /** Parameters for fetching a user's following list. */
1629
1618
  interface UserFollowingParams {
1630
- /** ID of the user whose following list to fetch. */
1631
- userId: number;
1632
- /** Visibility of the follows to return (default: `"public"`). */
1633
- restrict?: (typeof FollowRestrict)[keyof typeof FollowRestrict];
1634
- /** Zero-based offset for pagination. */
1635
- offset?: number;
1619
+ /** ID of the user whose following list to fetch. */
1620
+ userId: number;
1621
+ /** Visibility of the follows to return (default: `"public"`). */
1622
+ restrict?: (typeof FollowRestrict)[keyof typeof FollowRestrict];
1623
+ /** Zero-based offset for pagination. */
1624
+ offset?: number;
1636
1625
  }
1637
1626
  /** Parameters for following a user. */
1638
1627
  interface UserFollowAddParams {
1639
- /** ID of the user to follow. */
1640
- userId: number;
1641
- /** Visibility of the follow (default: `"public"`). */
1642
- restrict?: (typeof FollowRestrict)[keyof typeof FollowRestrict];
1628
+ /** ID of the user to follow. */
1629
+ userId: number;
1630
+ /** Visibility of the follow (default: `"public"`). */
1631
+ restrict?: (typeof FollowRestrict)[keyof typeof FollowRestrict];
1643
1632
  }
1644
1633
  /** Parameters for unfollowing a user. */
1645
1634
  interface UserFollowDeleteParams {
1646
- /** ID of the user to unfollow. */
1647
- userId: number;
1635
+ /** ID of the user to unfollow. */
1636
+ userId: number;
1648
1637
  }
1649
1638
  /** Methods for the user bookmarks sub-namespace. */
1650
1639
  declare class UserBookmarksResource {
1651
- #private;
1652
- constructor(http: HttpClient);
1653
- /**
1654
- * Fetches a user's bookmarked illusts.
1655
- * GET /v1/user/bookmarks/illust
1656
- *
1657
- * @param params - Request parameters
1658
- *
1659
- * @example
1660
- * ```ts
1661
- * // Iterate all bookmarked illusts across pages
1662
- * for await (const illust of client.users.bookmarks.illusts({ userId: client.userId }).items()) {
1663
- * console.log(illust.title)
1664
- * }
1665
- *
1666
- * // Resume from a saved cursor
1667
- * import { parseNextUrl } from '@book000/pixivts'
1668
- * const page = await client.users.bookmarks.illusts({ userId: client.userId })
1669
- * if (page.isOk && page.value.nextUrl) {
1670
- * const cursor = parseNextUrl(page.value.nextUrl)
1671
- * const next = await client.users.bookmarks.illusts({
1672
- * userId: client.userId,
1673
- * maxBookmarkId: cursor.maxBookmarkId,
1674
- * })
1675
- * }
1676
- * ```
1677
- */
1678
- illusts(params: UserBookmarksIllustParams): PaginatedResultAsync<UserBookmarksIllustPage, PixivIllustItem>;
1679
- /**
1680
- * Fetches a user's bookmarked novels.
1681
- * GET /v1/user/bookmarks/novel
1682
- *
1683
- * @param params - Request parameters
1684
- *
1685
- * @example
1686
- * ```ts
1687
- * // Iterate all bookmarked novels across pages
1688
- * for await (const novel of client.users.bookmarks.novels({ userId: client.userId }).items()) {
1689
- * console.log(novel.title)
1690
- * }
1691
- * ```
1692
- */
1693
- novels(params: UserBookmarksNovelParams): PaginatedResultAsync<UserBookmarksNovelPage, PixivNovelItem>;
1640
+ #private;
1641
+ constructor(http: HttpClient);
1642
+ /**
1643
+ * Fetches a user's bookmarked illusts.
1644
+ * GET /v1/user/bookmarks/illust
1645
+ *
1646
+ * @param params - Request parameters
1647
+ *
1648
+ * @example
1649
+ * ```ts
1650
+ * // Iterate all bookmarked illusts across pages
1651
+ * for await (const illust of client.users.bookmarks.illusts({ userId: client.userId }).items()) {
1652
+ * console.log(illust.title)
1653
+ * }
1654
+ *
1655
+ * // Resume from a saved cursor
1656
+ * import { parseNextUrl } from '@book000/pixivts'
1657
+ * const page = await client.users.bookmarks.illusts({ userId: client.userId })
1658
+ * if (page.isOk && page.value.nextUrl) {
1659
+ * const cursor = parseNextUrl(page.value.nextUrl)
1660
+ * const next = await client.users.bookmarks.illusts({
1661
+ * userId: client.userId,
1662
+ * maxBookmarkId: cursor.maxBookmarkId,
1663
+ * })
1664
+ * }
1665
+ * ```
1666
+ */
1667
+ illusts(params: UserBookmarksIllustParams): PaginatedResultAsync<UserBookmarksIllustPage, PixivIllustItem>;
1668
+ /**
1669
+ * Fetches a user's bookmarked novels.
1670
+ * GET /v1/user/bookmarks/novel
1671
+ *
1672
+ * @param params - Request parameters
1673
+ *
1674
+ * @example
1675
+ * ```ts
1676
+ * // Iterate all bookmarked novels across pages
1677
+ * for await (const novel of client.users.bookmarks.novels({ userId: client.userId }).items()) {
1678
+ * console.log(novel.title)
1679
+ * }
1680
+ * ```
1681
+ */
1682
+ novels(params: UserBookmarksNovelParams): PaginatedResultAsync<UserBookmarksNovelPage, PixivNovelItem>;
1694
1683
  }
1695
1684
  /** Methods for the user API namespace. */
1696
1685
  declare class UserResource {
1697
- #private;
1698
- /** User bookmarks sub-namespace. */
1699
- readonly bookmarks: UserBookmarksResource;
1700
- constructor(http: HttpClient);
1701
- /**
1702
- * Fetches detailed profile information for a user.
1703
- * GET /v1/user/detail
1704
- *
1705
- * @param params - Request parameters
1706
- */
1707
- detail(params: UserDetailParams): ResultAsync<UserDetailResponse, PixivError>;
1708
- /**
1709
- * Fetches illusts posted by a user.
1710
- * GET /v1/user/illusts
1711
- *
1712
- * @param params - Request parameters
1713
- */
1714
- illusts(params: UserIllustsParams): PaginatedResultAsync<UserIllustsPage, PixivIllustItem>;
1715
- /**
1716
- * Fetches novels posted by a user.
1717
- * GET /v1/user/novels
1718
- *
1719
- * @param params - Request parameters
1720
- */
1721
- novels(params: UserNovelsParams): PaginatedResultAsync<UserNovelsPage, PixivNovelItem>;
1722
- /**
1723
- * Fetches the list of users that a user is following.
1724
- * GET /v1/user/following
1725
- *
1726
- * @param params - Request parameters
1727
- */
1728
- following(params: UserFollowingParams): PaginatedResultAsync<UserFollowingPage, PixivUserPreviewItem>;
1729
- /**
1730
- * Follows a user.
1731
- * POST /v1/user/follow/add
1732
- *
1733
- * @param params - Request parameters
1734
- */
1735
- followAdd(params: UserFollowAddParams): ResultAsync<Record<string, never>, PixivError>;
1736
- /**
1737
- * Unfollows a user.
1738
- * POST /v1/user/follow/delete
1739
- *
1740
- * @param params - Request parameters
1741
- */
1742
- followDelete(params: UserFollowDeleteParams): ResultAsync<Record<string, never>, PixivError>;
1743
- }
1744
-
1745
- /**
1746
- * MangaResource — methods for the manga API namespace.
1747
- */
1748
-
1686
+ #private;
1687
+ /** User bookmarks sub-namespace. */
1688
+ readonly bookmarks: UserBookmarksResource;
1689
+ constructor(http: HttpClient);
1690
+ /**
1691
+ * Fetches detailed profile information for a user.
1692
+ * GET /v1/user/detail
1693
+ *
1694
+ * @param params - Request parameters
1695
+ */
1696
+ detail(params: UserDetailParams): ResultAsync<UserDetailResponse, PixivError>;
1697
+ /**
1698
+ * Fetches illusts posted by a user.
1699
+ * GET /v1/user/illusts
1700
+ *
1701
+ * @param params - Request parameters
1702
+ */
1703
+ illusts(params: UserIllustsParams): PaginatedResultAsync<UserIllustsPage, PixivIllustItem>;
1704
+ /**
1705
+ * Fetches novels posted by a user.
1706
+ * GET /v1/user/novels
1707
+ *
1708
+ * @param params - Request parameters
1709
+ */
1710
+ novels(params: UserNovelsParams): PaginatedResultAsync<UserNovelsPage, PixivNovelItem>;
1711
+ /**
1712
+ * Fetches the list of users that a user is following.
1713
+ * GET /v1/user/following
1714
+ *
1715
+ * @param params - Request parameters
1716
+ */
1717
+ following(params: UserFollowingParams): PaginatedResultAsync<UserFollowingPage, PixivUserPreviewItem>;
1718
+ /**
1719
+ * Follows a user.
1720
+ * POST /v1/user/follow/add
1721
+ *
1722
+ * @param params - Request parameters
1723
+ */
1724
+ followAdd(params: UserFollowAddParams): ResultAsync<Record<string, never>, PixivError>;
1725
+ /**
1726
+ * Unfollows a user.
1727
+ * POST /v1/user/follow/delete
1728
+ *
1729
+ * @param params - Request parameters
1730
+ */
1731
+ followDelete(params: UserFollowDeleteParams): ResultAsync<Record<string, never>, PixivError>;
1732
+ }
1733
+ //#endregion
1734
+ //#region src/resources/manga.d.ts
1749
1735
  /** Parameters for fetching recommended manga. */
1750
1736
  interface MangaRecommendedParams {
1751
- /** OS filter to apply (default: `"for_ios"`). */
1752
- filter?: (typeof OSFilter)[keyof typeof OSFilter];
1753
- /** Zero-based offset for pagination. */
1754
- offset?: number;
1737
+ /** OS filter to apply (default: `"for_ios"`). */
1738
+ filter?: (typeof OSFilter)[keyof typeof OSFilter];
1739
+ /** Zero-based offset for pagination. */
1740
+ offset?: number;
1755
1741
  }
1756
1742
  /** Methods for the manga API namespace. */
1757
1743
  declare class MangaResource {
1758
- #private;
1759
- constructor(http: HttpClient);
1760
- /**
1761
- * Fetches recommended manga.
1762
- * GET /v1/manga/recommended
1763
- *
1764
- * @param params - Request parameters
1765
- */
1766
- recommended(params?: MangaRecommendedParams): PaginatedResultAsync<MangaRecommendedPage, PixivIllustItem>;
1767
- }
1768
-
1769
- /**
1770
- * UgoiraResource — methods for the ugoira API namespace.
1771
- */
1772
-
1744
+ #private;
1745
+ constructor(http: HttpClient);
1746
+ /**
1747
+ * Fetches recommended manga.
1748
+ * GET /v1/manga/recommended
1749
+ *
1750
+ * @param params - Request parameters
1751
+ */
1752
+ recommended(params?: MangaRecommendedParams): PaginatedResultAsync<MangaRecommendedPage, PixivIllustItem>;
1753
+ }
1754
+ //#endregion
1755
+ //#region src/resources/ugoira.d.ts
1773
1756
  /** Parameters for fetching ugoira metadata. */
1774
1757
  interface UgoiraMetadataParams {
1775
- /** ID of the ugoira illust whose metadata to fetch. */
1776
- illustId: number;
1758
+ /** ID of the ugoira illust whose metadata to fetch. */
1759
+ illustId: number;
1777
1760
  }
1778
1761
  /** Methods for the ugoira API namespace. */
1779
1762
  declare class UgoiraResource {
1780
- #private;
1781
- constructor(http: HttpClient);
1782
- /**
1783
- * Fetches ugoira metadata (ZIP URL and per-frame timings).
1784
- * GET /v1/ugoira/metadata
1785
- *
1786
- * @param params - Request parameters
1787
- */
1788
- metadata(params: UgoiraMetadataParams): ResultAsync<UgoiraMetadataResponse, PixivError>;
1789
- }
1790
-
1791
- /**
1792
- * ImageResource — helpers for fetching pixiv CDN images.
1793
- */
1794
-
1763
+ #private;
1764
+ constructor(http: HttpClient);
1765
+ /**
1766
+ * Fetches ugoira metadata (ZIP URL and per-frame timings).
1767
+ * GET /v1/ugoira/metadata
1768
+ *
1769
+ * @param params - Request parameters
1770
+ */
1771
+ metadata(params: UgoiraMetadataParams): ResultAsync<UgoiraMetadataResponse, PixivError>;
1772
+ }
1773
+ //#endregion
1774
+ //#region src/resources/images.d.ts
1795
1775
  /** Methods for fetching pixiv images. */
1796
1776
  declare class ImageResource {
1797
- #private;
1798
- constructor(http: HttpClient);
1799
- /**
1800
- * Fetches a pixiv image.
1801
- *
1802
- * Uses a browser User-Agent and Referer (required for pixiv CDN).
1803
- * No Authorization header is sent.
1804
- *
1805
- * @param imageUrl - Full CDN image URL
1806
- */
1807
- fetch(imageUrl: string): ResultAsync<Response, PixivError>;
1808
- }
1809
-
1810
- /**
1811
- * PixivClient — main entry point for the @book000/pixivts library.
1812
- *
1813
- * @example
1814
- * ```ts
1815
- * const client = await PixivClient.of(process.env.PIXIV_REFRESH_TOKEN!)
1816
- * const result = await client.illusts.detail({ illustId: 12345 })
1817
- * if (result.isOk) console.log(result.value.illust.title)
1818
- * ```
1819
- */
1820
-
1777
+ #private;
1778
+ constructor(http: HttpClient);
1779
+ /**
1780
+ * Fetches a pixiv image.
1781
+ *
1782
+ * Uses a browser User-Agent and Referer (required for pixiv CDN).
1783
+ * No Authorization header is sent.
1784
+ *
1785
+ * @param imageUrl - Full CDN image URL
1786
+ */
1787
+ fetch(imageUrl: string): ResultAsync<Response, PixivError>;
1788
+ }
1789
+ //#endregion
1790
+ //#region src/client.d.ts
1821
1791
  /** Options for constructing a {@link PixivClient}. */
1822
1792
  interface PixivClientOptions {
1823
- /** Rate-limit retry configuration. */
1824
- retry?: Partial<RateLimitRetryOptions>;
1825
- /** Optional interceptor called after each successful response (DB seam). */
1826
- onResponse?: ResponseInterceptor;
1793
+ /** Rate-limit retry configuration. */
1794
+ retry?: Partial<RateLimitRetryOptions>;
1795
+ /** Optional interceptor called after each successful response (DB seam). */
1796
+ onResponse?: ResponseInterceptor;
1827
1797
  }
1828
1798
  /**
1829
1799
  * Main client for the pixiv API.
@@ -1832,62 +1802,63 @@ interface PixivClientOptions {
1832
1802
  * because initialisation requires an async token refresh.
1833
1803
  */
1834
1804
  declare class PixivClient {
1835
- #private;
1836
- /** Illust API namespace. */
1837
- readonly illusts: IllustResource;
1838
- /** Novel API namespace. */
1839
- readonly novels: NovelResource;
1840
- /** User API namespace. */
1841
- readonly users: UserResource;
1842
- /** Manga API namespace. */
1843
- readonly manga: MangaResource;
1844
- /** Ugoira API namespace. */
1845
- readonly ugoira: UgoiraResource;
1846
- /** Image fetch helpers. */
1847
- readonly images: ImageResource;
1848
- private constructor();
1849
- /**
1850
- * Numeric user ID of the authenticated account.
1851
- *
1852
- * Available immediately after {@link PixivClient.of} resolves.
1853
- * The pixiv OAuth endpoint returns the ID as a string; this getter
1854
- * normalises it to `number` for consistency with resource method params
1855
- * (e.g. `UserBookmarksIllustParams.userId`).
1856
- *
1857
- * @example
1858
- * ```ts
1859
- * const client = await PixivClient.of(refreshToken)
1860
- * const bookmarks = await client.users.bookmarks.illusts({ userId: client.userId })
1861
- * ```
1862
- */
1863
- get userId(): number;
1864
- /**
1865
- * Returns the current OAuth access token.
1866
- *
1867
- * The access token is short-lived and changes after each call to
1868
- * {@link PixivClient.of} and after each automatic token refresh triggered
1869
- * by a 401 response.
1870
- *
1871
- * @returns The current bearer access token string
1872
- */
1873
- getAccessToken(): string;
1874
- /**
1875
- * Returns the current OAuth refresh token.
1876
- *
1877
- * The refresh token is long-lived and is used to obtain new access tokens.
1878
- * It may rotate after a successful token refresh.
1879
- *
1880
- * @returns The current refresh token string
1881
- */
1882
- getRefreshToken(): string;
1883
- /**
1884
- * Creates a PixivClient by refreshing the given token.
1885
- *
1886
- * @param refreshToken - Pixiv refresh token
1887
- * @param options - Optional retry and response interceptor configuration
1888
- * @returns A fully initialised {@link PixivClient}
1889
- */
1890
- static of(refreshToken: string, options?: PixivClientOptions): Promise<PixivClient>;
1891
- }
1892
-
1805
+ #private;
1806
+ /** Illust API namespace. */
1807
+ readonly illusts: IllustResource;
1808
+ /** Novel API namespace. */
1809
+ readonly novels: NovelResource;
1810
+ /** User API namespace. */
1811
+ readonly users: UserResource;
1812
+ /** Manga API namespace. */
1813
+ readonly manga: MangaResource;
1814
+ /** Ugoira API namespace. */
1815
+ readonly ugoira: UgoiraResource;
1816
+ /** Image fetch helpers. */
1817
+ readonly images: ImageResource;
1818
+ private constructor();
1819
+ /**
1820
+ * Numeric user ID of the authenticated account.
1821
+ *
1822
+ * Available immediately after {@link PixivClient.of} resolves.
1823
+ * The pixiv OAuth endpoint returns the ID as a string; this getter
1824
+ * normalises it to `number` for consistency with resource method params
1825
+ * (e.g. `UserBookmarksIllustParams.userId`).
1826
+ *
1827
+ * @example
1828
+ * ```ts
1829
+ * const client = await PixivClient.of(refreshToken)
1830
+ * const bookmarks = await client.users.bookmarks.illusts({ userId: client.userId })
1831
+ * ```
1832
+ */
1833
+ get userId(): number;
1834
+ /**
1835
+ * Returns the current OAuth access token.
1836
+ *
1837
+ * The access token is short-lived and changes after each call to
1838
+ * {@link PixivClient.of} and after each automatic token refresh triggered
1839
+ * by a 401 response.
1840
+ *
1841
+ * @returns The current bearer access token string
1842
+ */
1843
+ getAccessToken(): string;
1844
+ /**
1845
+ * Returns the current OAuth refresh token.
1846
+ *
1847
+ * The refresh token is long-lived and is used to obtain new access tokens.
1848
+ * It may rotate after a successful token refresh.
1849
+ *
1850
+ * @returns The current refresh token string
1851
+ */
1852
+ getRefreshToken(): string;
1853
+ /**
1854
+ * Creates a PixivClient by refreshing the given token.
1855
+ *
1856
+ * @param refreshToken - Pixiv refresh token
1857
+ * @param options - Optional retry and response interceptor configuration
1858
+ * @returns A fully initialised {@link PixivClient}
1859
+ */
1860
+ static of(refreshToken: string, options?: PixivClientOptions): Promise<PixivClient>;
1861
+ }
1862
+ //#endregion
1893
1863
  export { BookmarkRestrict, type ErrResult, FollowRestrict, type Frame, type HttpMethod, type IllustBookmarkAddParams, type IllustBookmarkDeleteParams, type IllustDetailParams, type IllustDetailResponse, type IllustListPage, type IllustRankingParams, type IllustRecommendedPage, type IllustRecommendedParams, type IllustRelatedParams, type IllustSearchParams, type IllustSeriesDetail, type IllustSeriesPage, type IllustSeriesParams, type ImageUrls, type MangaRecommendedPage, type MetaPages, type MetaSinglePage, type NovelBookmarkAddParams, type NovelBookmarkDeleteParams, type NovelDetailParams, type NovelDetailResponse, type NovelListPage, NovelRankingMode, type NovelRankingParams, type NovelRecommendedPage, type NovelRecommendedParams, type NovelRelatedParams, type NovelSearchParams, type NovelSeriesDetail, type NovelSeriesPage, type NovelSeriesParams, type NovelTextParams, OSFilter, type OkResult, type PagedResponse, PaginatedResultAsync, type ParsedNextUrl, type PixivApiErrorBody, PixivClient, type PixivClientOptions, type PixivError, PixivFetchError, type PixivIllustItem, type PixivNovelItem, type PixivUgoiraItem, type PixivUser, type PixivUserItem, type PixivUserPreviewItem, type PixivUserProfile, type PixivUserProfilePublicity, type PixivUserProfileWorkspace, type PrivacyPolicy, type ProfileImageUrls, RankingMode, type ResponseInterceptor, type ResponseRecord, type Result, ResultAsync, SearchDuration, SearchSort, SearchTarget, type Series, type Tag, type UgoiraMetadataResponse, type UserBookmarksIllustPage, type UserBookmarksIllustParams, type UserBookmarksNovelPage, type UserBookmarksNovelParams, type UserDetailParams, type UserDetailResponse, type UserFollowAddParams, type UserFollowDeleteParams, type UserFollowingPage, type UserFollowingParams, UserIllustType, type UserIllustsPage, type UserIllustsParams, type UserNovelsPage, type UserNovelsParams, type ZipUrls, apiError, authFailedError, err, failedPaginated, networkError, ok, parseNextUrl, rateLimitError };
1864
+ //# sourceMappingURL=index.d.ts.map