@book000/pixivts 0.60.0 → 0.60.2

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.cts 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,60 @@ 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;
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;
709
686
  }
710
687
  /** Original-image URL for a single-page illust. */
711
688
  interface MetaSinglePage {
712
- /** Direct URL to the original-resolution image. */
713
- originalImageUrl: string;
689
+ /** Direct URL to the original-resolution image. */
690
+ originalImageUrl: string;
714
691
  }
715
692
  /** Per-page image URLs for a multi-page work (manga). */
716
693
  interface MetaPages {
717
- /** Full set of image URLs for this page, including the original. */
718
- imageUrls: Required<ImageUrls>;
694
+ /** Full set of image URLs for this page, including the original. */
695
+ imageUrls: Required<ImageUrls>;
719
696
  }
720
697
  /**
721
698
  * A pixiv illust or manga work item as returned by the API.
@@ -724,95 +701,95 @@ interface MetaPages {
724
701
  * GET /v1/illust/ranking, GET /v1/illust/recommended, etc.
725
702
  */
726
703
  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[];
704
+ /**
705
+ * Work ID.
706
+ *
707
+ * Illusts and novels are numbered in separate sequences — the same ID
708
+ * can appear in both.
709
+ */
710
+ id: number;
711
+ /** Title of the work. */
712
+ title: string;
713
+ /** Work category: illustration, manga, or animated illustration. */
714
+ type: 'illust' | 'manga' | 'ugoira';
715
+ /** Thumbnail image URLs at various sizes. */
716
+ imageUrls: ImageUrls;
717
+ /** Work caption / description (may contain HTML). */
718
+ caption: string;
719
+ /** Content restriction level (0 = public, 1 = mypixiv-only, 2 = private). */
720
+ restrict: number;
721
+ /** Author of the work. */
722
+ user: PixivUser;
723
+ /** Tags attached to the work. */
724
+ tags: Tag[];
725
+ /** Creation tools listed by the author (e.g. "Photoshop"). */
726
+ tools: string[];
727
+ /** ISO 8601 date-time string of when the work was posted. */
728
+ createDate: string;
729
+ /** Number of images in a multi-page work (1 for single-page). */
730
+ pageCount: number;
731
+ /** Canvas width in pixels. */
732
+ width: number;
733
+ /** Canvas height in pixels. */
734
+ height: number;
735
+ /** Sanity / sensitivity level assigned by the pixiv content filter. */
736
+ sanityLevel: number;
737
+ /** Age restriction: 0 = all-ages, 1 = R-18, 2 = R-18G */
738
+ xRestrict: number;
739
+ /** Series this work belongs to, or `null` if not part of a series. */
740
+ series: Series | null;
741
+ /**
742
+ * For single-page works: `{ originalImageUrl: string }`.
743
+ * For multi-page works: `{}` (empty object).
744
+ */
745
+ metaSinglePage: MetaSinglePage | Record<string, never>;
746
+ /** Per-page image URLs for multi-page works (empty array for single-page). */
747
+ metaPages: MetaPages[];
748
+ /** Total number of views. */
749
+ totalView: number;
750
+ /** Total number of bookmarks. */
751
+ totalBookmarks: number;
752
+ /** Whether the authenticated user has bookmarked this work. */
753
+ isBookmarked: boolean;
754
+ /** Whether the work is publicly visible. */
755
+ visible: boolean;
756
+ /** Whether the work is muted for the authenticated user. */
757
+ isMuted: boolean;
758
+ /** Total number of comments (may be absent on some endpoints). */
759
+ totalComments?: number;
760
+ /** AI-generated content flag: 0 = no AI, 1 = partial AI, 2 = fully AI */
761
+ illustAiType: number;
762
+ /** Book-style rendering flag (0 = normal, 1 = book). */
763
+ illustBookStyle: number;
764
+ /** Controls who can post comments (may be absent). */
765
+ commentAccessControl?: number;
766
+ /** Additional access-restriction attributes (may be absent). */
767
+ restrictionAttributes?: string[];
791
768
  }
792
769
  /** Illust series metadata returned by GET /v1/illust/series. */
793
770
  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;
771
+ /** Series ID. */
772
+ id: number;
773
+ /** Series title. */
774
+ title: string;
775
+ /** Series description / caption. */
776
+ caption: string;
777
+ /** Cover image URLs. */
778
+ coverImageUrls: {
779
+ medium: string;
780
+ };
781
+ /** Number of works in the series. */
782
+ seriesWorkCount: number;
783
+ /** ISO 8601 date-time string of when the series was created. */
784
+ createDate: string;
785
+ /** Canvas width of the cover image in pixels. */
786
+ width: number;
787
+ /** Canvas height of the cover image in pixels. */
788
+ height: number;
789
+ /** Author of the series. */
790
+ user: PixivUser;
791
+ /** Whether the authenticated user has added this series to their watchlist. */
792
+ watchlistAdded: boolean;
816
793
  }
817
794
  /**
818
795
  * A pixiv novel work item as returned by the API.
@@ -820,188 +797,187 @@ interface IllustSeriesDetail {
820
797
  * Returned by GET /v2/novel/detail, GET /v1/search/novel, etc.
821
798
  */
822
799
  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;
800
+ /**
801
+ * Work ID.
802
+ *
803
+ * Novels and illusts are numbered in separate sequences — the same ID
804
+ * can appear in both.
805
+ */
806
+ id: number;
807
+ /** Title of the novel. */
808
+ title: string;
809
+ /** Synopsis / caption (may contain HTML). */
810
+ caption: string;
811
+ /** Content restriction level (0 = public, 1 = mypixiv-only, 2 = private). */
812
+ restrict: number;
813
+ /** Age restriction: 0 = all-ages, 1 = R-18, 2 = R-18G */
814
+ xRestrict: number;
815
+ /** Whether the novel is an original work (not fan fiction). */
816
+ isOriginal: boolean;
817
+ /** Cover image URLs. */
818
+ imageUrls: ImageUrls;
819
+ /** ISO 8601 date-time string of when the novel was posted. */
820
+ createDate: string;
821
+ /** Tags attached to the novel. */
822
+ tags: Tag[];
823
+ /** Number of pages (word-count chunks). */
824
+ pageCount: number;
825
+ /** Total character count of the novel body. */
826
+ textLength: number;
827
+ /** Author of the novel. */
828
+ user: PixivUser;
829
+ /**
830
+ * Series information.
831
+ *
832
+ * `{}` (empty object) if the novel does not belong to a series.
833
+ */
834
+ series: Series | Record<string, never>;
835
+ /** Whether the authenticated user has bookmarked this novel. */
836
+ isBookmarked: boolean;
837
+ /** Total number of bookmarks. */
838
+ totalBookmarks: number;
839
+ /** Total number of views. */
840
+ totalView: number;
841
+ /** Whether the novel is publicly visible. */
842
+ visible: boolean;
843
+ /** Total number of comments. */
844
+ totalComments: number;
845
+ /** Whether the novel is muted for the authenticated user. */
846
+ isMuted: boolean;
847
+ /** Whether the novel is restricted to mutual followers (mypixiv). */
848
+ isMypixivOnly: boolean;
849
+ /** Whether the novel contains explicit content beyond the `xRestrict` flag. */
850
+ isXRestricted: boolean;
851
+ /** AI-generated content flag: 0 = no AI, 1 = partial AI, 2 = fully AI */
852
+ novelAiType: number;
853
+ /** Controls who can post comments (may be absent). */
854
+ commentAccessControl?: number;
878
855
  }
879
856
  /** Novel series details returned by GET /v2/novel/series. */
880
857
  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;
858
+ /** Series ID. */
859
+ id: number;
860
+ /** Series title. */
861
+ title: string;
862
+ /** Series description / caption. */
863
+ caption: string;
864
+ /** Whether every novel in the series is original (not fan fiction). */
865
+ isOriginal: boolean;
866
+ /** Whether the series has been marked as concluded by the author. */
867
+ isConcluded: boolean;
868
+ /** Number of novels in the series. */
869
+ contentCount: number;
870
+ /** Total character count across all novels in the series. */
871
+ totalCharacterCount: number;
872
+ /** Author of the series. */
873
+ user: PixivUser;
874
+ /** Human-readable series label / tagline. */
875
+ displayText: string;
876
+ /** AI-generated content flag: 0 = no AI, 1 = partial AI, 2 = fully AI */
877
+ novelAiType: number;
878
+ /** Whether the authenticated user has added this series to their watchlist. */
879
+ watchlistAdded: boolean;
903
880
  }
904
881
  /** User item with self-introduction; embedded in GET /v1/user/detail. */
905
882
  type PixivUserItem = PixivUser & {
906
- /** Self-introduction text (line endings are \r\n) */
907
- comment: string;
883
+ /** Self-introduction text (line endings are \r\n) */comment: string;
908
884
  };
909
885
  /** Visibility setting for a user profile field. */
910
886
  type Publicity = 'public' | 'private' | 'mypixiv';
911
887
  /** Detailed profile information for a user. */
912
888
  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;
889
+ /** Personal website URL, or `null` if not set. */
890
+ webpage: string | null;
891
+ /** Disclosed gender. */
892
+ gender: 'male' | 'female' | 'unknown';
893
+ /** Birth date string (YYYY-MM-DD format, may be partial). */
894
+ birth: string;
895
+ /** Birth day portion (MM-DD format). */
896
+ birthDay: string;
897
+ /** Birth year. */
898
+ birthYear: number;
899
+ /** Region / prefecture. */
900
+ region: string;
901
+ /** Internal address ID. */
902
+ addressId: number;
903
+ /** Two-letter country code (ISO 3166-1 alpha-2). */
904
+ countryCode: string;
905
+ /** Occupation / job description. */
906
+ job: string;
907
+ /** Internal job category ID. */
908
+ jobId: number;
909
+ /** Number of users this user follows. */
910
+ totalFollowUsers: number;
911
+ /** Number of mutual-follow (mypixiv) connections. */
912
+ totalMypixivUsers: number;
913
+ /** Total number of public illusts. */
914
+ totalIllusts: number;
915
+ /** Total number of public manga works. */
916
+ totalManga: number;
917
+ /** Total number of public novels. */
918
+ totalNovels: number;
919
+ /** Total number of publicly bookmarked illusts. */
920
+ totalIllustBookmarksPublic: number;
921
+ /** Total number of illust series. */
922
+ totalIllustSeries: number;
923
+ /** Total number of novel series. */
924
+ totalNovelSeries: number;
925
+ /** Profile background image URL, or `null` if not set. */
926
+ backgroundImageUrl: string | null;
927
+ /** Linked Twitter/X account name (without @). */
928
+ twitterAccount: string;
929
+ /** Twitter/X profile URL, or `null` if not set. */
930
+ twitterUrl: string | null;
931
+ /** Pawoo profile URL, or `null` if not set. */
932
+ pawooUrl: string | null;
933
+ /** Whether the user has a premium (paid) account. */
934
+ isPremium: boolean;
935
+ /** Whether the user has set a custom profile image. */
936
+ isUsingCustomProfileImage: boolean;
961
937
  }
962
938
  /** Visibility settings for a user's profile fields. */
963
939
  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;
940
+ /** Visibility of the gender field. */
941
+ gender: Publicity;
942
+ /** Visibility of the region field. */
943
+ region: Publicity;
944
+ /** Visibility of the birth-day field. */
945
+ birthDay: Publicity;
946
+ /** Visibility of the birth-year field. */
947
+ birthYear: Publicity;
948
+ /** Visibility of the job field. */
949
+ job: Publicity;
950
+ /** Whether the Pawoo account link is visible. */
951
+ pawoo: boolean;
976
952
  }
977
953
  /** Workspace / desk setup information from a user's profile. */
978
954
  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;
955
+ /** PC / computer specs. */
956
+ pc: string;
957
+ /** Monitor model. */
958
+ monitor: string;
959
+ /** Drawing software / tool. */
960
+ tool: string;
961
+ /** Scanner model. */
962
+ scanner: string;
963
+ /** Tablet model. */
964
+ tablet: string;
965
+ /** Mouse model. */
966
+ mouse: string;
967
+ /** Printer model. */
968
+ printer: string;
969
+ /** Desktop wallpaper or environment description. */
970
+ desktop: string;
971
+ /** Music / background audio description. */
972
+ music: string;
973
+ /** Desk description. */
974
+ desk: string;
975
+ /** Chair description. */
976
+ chair: string;
977
+ /** Free-text comment about the workspace. */
978
+ comment: string;
979
+ /** Workspace image URL, or `null` if not set. */
980
+ workspaceImageUrl: string | null;
1005
981
  }
1006
982
  /**
1007
983
  * Preview item for a user in the GET /v1/user/following response.
@@ -1009,33 +985,33 @@ interface PixivUserProfileWorkspace {
1009
985
  * Contains a few sample illusts and novels from that user.
1010
986
  */
1011
987
  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;
988
+ /** The user being previewed. */
989
+ user: PixivUser;
990
+ /** A small sample of the user's recent illusts. */
991
+ illusts: PixivIllustItem[];
992
+ /** A small sample of the user's recent novels. */
993
+ novels: PixivNovelItem[];
994
+ /** Whether this user is muted by the authenticated user. */
995
+ isMuted: boolean;
1020
996
  }
1021
997
  /** URLs for ugoira frame archives (ZIP files). */
1022
998
  interface ZipUrls {
1023
- /** URL for the 600 px-long-side archive. */
1024
- medium: string;
999
+ /** URL for the 600 px-long-side archive. */
1000
+ medium: string;
1025
1001
  }
1026
1002
  /** Timing info for a single ugoira frame. */
1027
1003
  interface Frame {
1028
- /** File name within the ZIP archive */
1029
- file: string;
1030
- /** Display duration in milliseconds */
1031
- delay: number;
1004
+ /** File name within the ZIP archive */
1005
+ file: string;
1006
+ /** Display duration in milliseconds */
1007
+ delay: number;
1032
1008
  }
1033
1009
  /** Ugoira metadata as returned by GET /v1/ugoira/metadata. */
1034
1010
  interface PixivUgoiraItem {
1035
- /** Archive URLs for the frame ZIP. */
1036
- zipUrls: ZipUrls;
1037
- /** Per-frame timing data (in order). */
1038
- frames: Frame[];
1011
+ /** Archive URLs for the frame ZIP. */
1012
+ zipUrls: ZipUrls;
1013
+ /** Per-frame timing data (in order). */
1014
+ frames: Frame[];
1039
1015
  }
1040
1016
  /**
1041
1017
  * Camelized shape of the JSON error body returned by the pixiv API.
@@ -1045,785 +1021,753 @@ interface PixivUgoiraItem {
1045
1021
  * are `lowerCamelCase`.
1046
1022
  */
1047
1023
  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
- };
1024
+ /** Error payload returned by the pixiv API (keys camelized). */
1025
+ error: {
1026
+ /** Localised error message intended for end users. */userMessage: string; /** Internal error message. */
1027
+ message: string; /** Short error reason / code. */
1028
+ reason: string; /** Additional details for the user-facing message (may be absent). */
1029
+ userMessageDetails?: Record<string, unknown>;
1030
+ };
1059
1031
  }
1060
1032
  /** Response shape for GET /v1/illust/detail. */
1061
1033
  interface IllustDetailResponse {
1062
- /** The requested illust. */
1063
- illust: PixivIllustItem;
1034
+ /** The requested illust. */
1035
+ illust: PixivIllustItem;
1064
1036
  }
1065
1037
  /** Page response for illust list endpoints (search, related, ranking, etc.). */
1066
1038
  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;
1039
+ /** Illusts on this page. */
1040
+ illusts: PixivIllustItem[];
1041
+ /**
1042
+ * Whether AI-generated works are shown in the results.
1043
+ *
1044
+ * Only present on search responses; absent on related/ranking/recommended endpoints.
1045
+ */
1046
+ showAi?: boolean;
1047
+ /** URL to the next page, or `null` when this is the last page. */
1048
+ nextUrl: string | null;
1077
1049
  }
1078
1050
  /** Page response for GET /v1/illust/recommended. */
1079
1051
  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;
1052
+ /** Recommended illusts. */
1053
+ illusts: PixivIllustItem[];
1054
+ /** Ranking illusts included alongside recommendations. */
1055
+ rankingIllusts: PixivIllustItem[];
1056
+ /** Whether an ongoing contest exists. */
1057
+ contestExists: boolean;
1058
+ /** Privacy-policy notice (present on the first page). */
1059
+ privacyPolicy?: PrivacyPolicy;
1060
+ /** URL to the next page, or `null` when this is the last page. */
1061
+ nextUrl: string | null;
1090
1062
  }
1091
1063
  /** Page response for GET /v1/illust/series. */
1092
1064
  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;
1065
+ /** Metadata for the series. */
1066
+ illustSeriesDetail: IllustSeriesDetail;
1067
+ /** First illust in the series. */
1068
+ illustSeriesFirstIllust: PixivIllustItem;
1069
+ /** Illusts on this page. */
1070
+ illusts: PixivIllustItem[];
1071
+ /** URL to the next page, or `null` when this is the last page. */
1072
+ nextUrl: string | null;
1101
1073
  }
1102
1074
  /** Page response for GET /v1/manga/recommended. */
1103
1075
  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;
1076
+ /** Recommended manga works. */
1077
+ illusts: PixivIllustItem[];
1078
+ /** Ranking manga works included alongside recommendations. */
1079
+ rankingIllusts: PixivIllustItem[];
1080
+ /** Privacy-policy notice (present on the first page). */
1081
+ privacyPolicy?: PrivacyPolicy;
1082
+ /** URL to the next page, or `null` when this is the last page. */
1083
+ nextUrl: string | null;
1112
1084
  }
1113
1085
  /** Response shape for GET /v1/ugoira/metadata. */
1114
1086
  interface UgoiraMetadataResponse {
1115
- /** Ugoira metadata (ZIP URLs and per-frame timings). */
1116
- ugoiraMetadata: PixivUgoiraItem;
1087
+ /** Ugoira metadata (ZIP URLs and per-frame timings). */
1088
+ ugoiraMetadata: PixivUgoiraItem;
1117
1089
  }
1118
1090
  /** Response shape for GET /v2/novel/detail. */
1119
1091
  interface NovelDetailResponse {
1120
- /** The requested novel. */
1121
- novel: PixivNovelItem;
1092
+ /** The requested novel. */
1093
+ novel: PixivNovelItem;
1122
1094
  }
1123
1095
  /** Page response for novel list endpoints (search, related, ranking, etc.). */
1124
1096
  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;
1097
+ /** Novels on this page. */
1098
+ novels: PixivNovelItem[];
1099
+ /**
1100
+ * Whether AI-generated works are shown in the results.
1101
+ *
1102
+ * Only present on search responses; absent on related/ranking/recommended endpoints.
1103
+ */
1104
+ showAi?: boolean;
1105
+ /** URL to the next page, or `null` when this is the last page. */
1106
+ nextUrl: string | null;
1135
1107
  }
1136
1108
  /** Page response for GET /v1/novel/recommended. */
1137
1109
  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;
1110
+ /** Recommended novels. */
1111
+ novels: PixivNovelItem[];
1112
+ /** Ranking novels included alongside recommendations. */
1113
+ rankingNovels: PixivNovelItem[];
1114
+ /** Privacy-policy notice (present on the first page). */
1115
+ privacyPolicy?: PrivacyPolicy;
1116
+ /** URL to the next page, or `null` when this is the last page. */
1117
+ nextUrl: string | null;
1146
1118
  }
1147
1119
  /** Page response for GET /v2/novel/series. */
1148
1120
  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;
1121
+ /** Metadata for the series. */
1122
+ novelSeriesDetail: NovelSeriesDetail;
1123
+ /** First novel in the series. */
1124
+ novelSeriesFirstNovel: PixivNovelItem;
1125
+ /** Most recently published novel in the series. */
1126
+ novelSeriesLatestNovel: PixivNovelItem;
1127
+ /** Novels on this page. */
1128
+ novels: PixivNovelItem[];
1129
+ /** URL to the next page, or `null` when this is the last page. */
1130
+ nextUrl: string | null;
1159
1131
  }
1160
1132
  /** Response shape for GET /v1/user/detail. */
1161
1133
  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;
1134
+ /** Basic user info with self-introduction. */
1135
+ user: PixivUserItem;
1136
+ /** Detailed profile data. */
1137
+ profile: PixivUserProfile;
1138
+ /** Visibility settings for profile fields. */
1139
+ profilePublicity: PixivUserProfilePublicity;
1140
+ /** Workspace / desk-setup information. */
1141
+ workspace: PixivUserProfileWorkspace;
1170
1142
  }
1171
1143
  /** Page response for GET /v1/user/illusts. */
1172
1144
  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;
1145
+ /** The user whose illusts are listed. */
1146
+ user: PixivUser;
1147
+ /** Illusts on this page. */
1148
+ illusts: PixivIllustItem[];
1149
+ /** URL to the next page, or `null` when this is the last page. */
1150
+ nextUrl: string | null;
1179
1151
  }
1180
1152
  /** Page response for GET /v1/user/novels. */
1181
1153
  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;
1154
+ /** The user whose novels are listed. */
1155
+ user: PixivUser;
1156
+ /** Novels on this page. */
1157
+ novels: PixivNovelItem[];
1158
+ /** URL to the next page, or `null` when this is the last page. */
1159
+ nextUrl: string | null;
1188
1160
  }
1189
1161
  /** Page response for GET /v1/user/bookmarks/illust. */
1190
1162
  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;
1163
+ /** Bookmarked illusts on this page. */
1164
+ illusts: PixivIllustItem[];
1165
+ /** URL to the next page, or `null` when this is the last page. */
1166
+ nextUrl: string | null;
1195
1167
  }
1196
1168
  /** Page response for GET /v1/user/bookmarks/novel. */
1197
1169
  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;
1170
+ /** Bookmarked novels on this page. */
1171
+ novels: PixivNovelItem[];
1172
+ /** URL to the next page, or `null` when this is the last page. */
1173
+ nextUrl: string | null;
1202
1174
  }
1203
1175
  /** Page response for GET /v1/user/following. */
1204
1176
  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;
1177
+ /** User preview items on this page. */
1178
+ userPreviews: PixivUserPreviewItem[];
1179
+ /** URL to the next page, or `null` when this is the last page. */
1180
+ nextUrl: string | null;
1209
1181
  }
1210
-
1211
- /**
1212
- * IllustResource — methods for the illust API namespace.
1213
- */
1214
-
1182
+ //#endregion
1183
+ //#region src/resources/illusts.d.ts
1215
1184
  /** Parameters for fetching a single illust by ID. */
1216
1185
  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];
1186
+ /** ID of the illust to fetch. */
1187
+ illustId: number;
1188
+ /** OS filter to apply (default: `"for_ios"`). */
1189
+ filter?: (typeof OSFilter)[keyof typeof OSFilter];
1221
1190
  }
1222
1191
  /** Parameters for fetching related illusts. */
1223
1192
  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];
1193
+ /** ID of the illust for which to fetch related works. */
1194
+ illustId: number;
1195
+ /** Additional seed illust IDs to influence recommendations. */
1196
+ seedIllustIds?: number[];
1197
+ /** OS filter to apply (default: `"for_ios"`). */
1198
+ filter?: (typeof OSFilter)[keyof typeof OSFilter];
1230
1199
  }
1231
1200
  /** Parameters for searching illusts. */
1232
1201
  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;
1202
+ /** Search keyword. */
1203
+ word: string;
1204
+ /** How to match the keyword against works (default: `"partial_match_for_tags"`). */
1205
+ searchTarget?: (typeof SearchTarget)[keyof typeof SearchTarget];
1206
+ /** Sort order for results (default: `"date_desc"`). */
1207
+ sort?: (typeof SearchSort)[keyof typeof SearchSort];
1208
+ /** Date range preset filter (omit for no restriction). */
1209
+ duration?: (typeof SearchDuration)[keyof typeof SearchDuration];
1210
+ /** Start date for a custom date range (YYYY-MM-DD; requires `endDate`). */
1211
+ startDate?: string;
1212
+ /** End date for a custom date range (YYYY-MM-DD; requires `startDate`). */
1213
+ endDate?: string;
1214
+ /** OS filter to apply (default: `"for_ios"`). */
1215
+ filter?: (typeof OSFilter)[keyof typeof OSFilter];
1216
+ /** AI-generated content filter: `0` = hide AI works, `1` = show only AI works. */
1217
+ searchAiType?: 0 | 1;
1218
+ /** Zero-based offset for pagination. */
1219
+ offset?: number;
1251
1220
  }
1252
1221
  /** Parameters for fetching the illust ranking. */
1253
1222
  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;
1223
+ /** Ranking category (default: `"day"`). */
1224
+ mode?: (typeof RankingMode)[keyof typeof RankingMode];
1225
+ /** OS filter to apply (default: `"for_ios"`). */
1226
+ filter?: (typeof OSFilter)[keyof typeof OSFilter];
1227
+ /** Specific date to fetch rankings for (YYYY-MM-DD; omit for the latest). */
1228
+ date?: string;
1229
+ /** Zero-based offset for pagination. */
1230
+ offset?: number;
1262
1231
  }
1263
1232
  /** Parameters for fetching recommended illusts. */
1264
1233
  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;
1234
+ /** OS filter to apply (default: `"for_ios"`). */
1235
+ filter?: (typeof OSFilter)[keyof typeof OSFilter];
1236
+ /** Zero-based offset for pagination. */
1237
+ offset?: number;
1238
+ /**
1239
+ * Cursor for resuming pagination: the `maxBookmarkIdForRecommend` value
1240
+ * extracted from a previous page's `next_url` via {@link parseNextUrl}.
1241
+ */
1242
+ maxBookmarkIdForRecommend?: number;
1243
+ /**
1244
+ * Secondary cursor for resuming pagination: the `minBookmarkIdForRecentIllust`
1245
+ * value extracted from a previous page's `next_url` via {@link parseNextUrl}.
1246
+ */
1247
+ minBookmarkIdForRecentIllust?: number;
1279
1248
  }
1280
1249
  /** Parameters for fetching an illust series. */
1281
1250
  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];
1251
+ /** ID of the illust series to fetch. */
1252
+ illustSeriesId: number;
1253
+ /** OS filter to apply (default: `"for_ios"`). */
1254
+ filter?: (typeof OSFilter)[keyof typeof OSFilter];
1286
1255
  }
1287
1256
  /** Parameters for adding an illust bookmark. */
1288
1257
  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[];
1258
+ /** ID of the illust to bookmark. */
1259
+ illustId: number;
1260
+ /** Bookmark visibility (default: `"public"`). */
1261
+ restrict?: (typeof BookmarkRestrict)[keyof typeof BookmarkRestrict];
1262
+ /** Tags to attach to the bookmark. */
1263
+ tags?: string[];
1295
1264
  }
1296
1265
  /** Parameters for removing an illust bookmark. */
1297
1266
  interface IllustBookmarkDeleteParams {
1298
- /** ID of the illust to remove from bookmarks. */
1299
- illustId: number;
1267
+ /** ID of the illust to remove from bookmarks. */
1268
+ illustId: number;
1300
1269
  }
1301
1270
  /** Methods for the illust API namespace. */
1302
1271
  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
-
1272
+ #private;
1273
+ constructor(http: HttpClient);
1274
+ /**
1275
+ * Fetches a single illust by ID.
1276
+ * GET /v1/illust/detail
1277
+ *
1278
+ * @param params - Request parameters
1279
+ *
1280
+ * @example
1281
+ * ```ts
1282
+ * const result = await client.illusts.detail({ illustId: 12345 })
1283
+ * if (result.isOk) {
1284
+ * console.log(result.value.illust.title)
1285
+ * } else {
1286
+ * console.error(result.error)
1287
+ * }
1288
+ * ```
1289
+ */
1290
+ detail(params: IllustDetailParams): ResultAsync<IllustDetailResponse, PixivError>;
1291
+ /**
1292
+ * Fetches related illusts for a given illust.
1293
+ * GET /v2/illust/related
1294
+ *
1295
+ * @param params - Request parameters
1296
+ */
1297
+ related(params: IllustRelatedParams): PaginatedResultAsync<IllustListPage, IllustListPage['illusts'][number]>;
1298
+ /**
1299
+ * Searches for illusts.
1300
+ * GET /v1/search/illust
1301
+ *
1302
+ * @param params - Request parameters
1303
+ *
1304
+ * @example
1305
+ * ```ts
1306
+ * // Iterate all results across pages
1307
+ * for await (const illust of client.illusts.search({ word: 'cat' }).items()) {
1308
+ * console.log(illust.title)
1309
+ * }
1310
+ *
1311
+ * // Fetch only the first page
1312
+ * const page = await client.illusts.search({ word: 'cat' })
1313
+ * if (page.isOk) {
1314
+ * console.log(page.value.illusts.length)
1315
+ * }
1316
+ * ```
1317
+ */
1318
+ search(params: IllustSearchParams): PaginatedResultAsync<IllustListPage, IllustListPage['illusts'][number]>;
1319
+ /**
1320
+ * Fetches the illust ranking.
1321
+ * GET /v1/illust/ranking
1322
+ *
1323
+ * @param params - Request parameters
1324
+ */
1325
+ ranking(params?: IllustRankingParams): PaginatedResultAsync<IllustListPage, IllustListPage['illusts'][number]>;
1326
+ /**
1327
+ * Fetches recommended illusts.
1328
+ * GET /v1/illust/recommended
1329
+ *
1330
+ * @param params - Request parameters
1331
+ */
1332
+ recommended(params?: IllustRecommendedParams): PaginatedResultAsync<IllustRecommendedPage, IllustRecommendedPage['illusts'][number]>;
1333
+ /**
1334
+ * Fetches an illust series.
1335
+ * GET /v1/illust/series
1336
+ *
1337
+ * @param params - Request parameters
1338
+ */
1339
+ series(params: IllustSeriesParams): PaginatedResultAsync<IllustSeriesPage, IllustSeriesPage['illusts'][number]>;
1340
+ /**
1341
+ * Adds an illust bookmark.
1342
+ * POST /v2/illust/bookmark/add
1343
+ *
1344
+ * @param params - Request parameters
1345
+ */
1346
+ bookmarkAdd(params: IllustBookmarkAddParams): ResultAsync<Record<string, never>, PixivError>;
1347
+ /**
1348
+ * Removes an illust bookmark.
1349
+ * POST /v1/illust/bookmark/delete
1350
+ *
1351
+ * @param params - Request parameters
1352
+ */
1353
+ bookmarkDelete(params: IllustBookmarkDeleteParams): ResultAsync<Record<string, never>, PixivError>;
1354
+ }
1355
+ //#endregion
1356
+ //#region src/resources/novels.d.ts
1391
1357
  /** Parameters for fetching a single novel by ID. */
1392
1358
  interface NovelDetailParams {
1393
- /** ID of the novel to fetch. */
1394
- novelId: number;
1359
+ /** ID of the novel to fetch. */
1360
+ novelId: number;
1395
1361
  }
1396
1362
  /** Parameters for fetching the WebView HTML of a novel. */
1397
1363
  interface NovelTextParams {
1398
- /** ID of the novel whose WebView HTML to fetch. */
1399
- novelId: number;
1364
+ /** ID of the novel whose WebView HTML to fetch. */
1365
+ novelId: number;
1400
1366
  }
1401
1367
  /** Parameters for fetching related novels. */
1402
1368
  interface NovelRelatedParams {
1403
- /** ID of the novel for which to fetch related works. */
1404
- novelId: number;
1369
+ /** ID of the novel for which to fetch related works. */
1370
+ novelId: number;
1405
1371
  }
1406
1372
  /** Parameters for searching novels. */
1407
1373
  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;
1374
+ /** Search keyword. */
1375
+ word: string;
1376
+ /** How to match the keyword against works (default: `"partial_match_for_tags"`). */
1377
+ searchTarget?: (typeof SearchTarget)[keyof typeof SearchTarget];
1378
+ /** Sort order for results (default: `"date_desc"`). */
1379
+ sort?: (typeof SearchSort)[keyof typeof SearchSort];
1380
+ /** OS filter to apply (default: `"for_ios"`). */
1381
+ filter?: (typeof OSFilter)[keyof typeof OSFilter];
1382
+ /** Date range preset filter (omit for no restriction). */
1383
+ duration?: (typeof SearchDuration)[keyof typeof SearchDuration];
1384
+ /** Start date for a custom date range (YYYY-MM-DD; requires `endDate`). */
1385
+ startDate?: string;
1386
+ /** End date for a custom date range (YYYY-MM-DD; requires `startDate`). */
1387
+ endDate?: string;
1388
+ /** AI-generated content filter: `0` = hide AI works, `1` = show only AI works. */
1389
+ searchAiType?: 0 | 1;
1390
+ /** Zero-based offset for pagination. */
1391
+ offset?: number;
1426
1392
  }
1427
1393
  /** Parameters for fetching the novel ranking. */
1428
1394
  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;
1395
+ /** Ranking category (default: `"day"`). */
1396
+ mode?: (typeof NovelRankingMode)[keyof typeof NovelRankingMode];
1397
+ /** OS filter to apply (default: `"for_ios"`). */
1398
+ filter?: (typeof OSFilter)[keyof typeof OSFilter];
1399
+ /** Specific date to fetch rankings for (YYYY-MM-DD; omit for the latest). */
1400
+ date?: string;
1401
+ /** Zero-based offset for pagination. */
1402
+ offset?: number;
1437
1403
  }
1438
1404
  /** Parameters for fetching recommended novels. */
1439
1405
  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;
1406
+ /** OS filter to apply (default: `"for_ios"`). */
1407
+ filter?: (typeof OSFilter)[keyof typeof OSFilter];
1408
+ /** Zero-based offset for pagination. */
1409
+ offset?: number;
1410
+ /**
1411
+ * Cursor for resuming pagination: the `maxBookmarkIdForRecommend` value
1412
+ * extracted from a previous page's `next_url` via {@link parseNextUrl}.
1413
+ */
1414
+ maxBookmarkIdForRecommend?: number;
1449
1415
  }
1450
1416
  /** Parameters for fetching a novel series. */
1451
1417
  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;
1418
+ /** ID of the novel series to fetch. */
1419
+ seriesId: number;
1420
+ /** Order of the last novel already seen; used for cursor-based pagination. */
1421
+ lastOrder?: number;
1456
1422
  }
1457
1423
  /** Parameters for adding a novel bookmark. */
1458
1424
  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[];
1425
+ /** ID of the novel to bookmark. */
1426
+ novelId: number;
1427
+ /** Bookmark visibility (default: `"public"`). */
1428
+ restrict?: (typeof BookmarkRestrict)[keyof typeof BookmarkRestrict];
1429
+ /** Tags to attach to the bookmark. */
1430
+ tags?: string[];
1465
1431
  }
1466
1432
  /** Parameters for removing a novel bookmark. */
1467
1433
  interface NovelBookmarkDeleteParams {
1468
- /** ID of the novel to remove from bookmarks. */
1469
- novelId: number;
1434
+ /** ID of the novel to remove from bookmarks. */
1435
+ novelId: number;
1470
1436
  }
1471
1437
  /** Methods for the novel API namespace. */
1472
1438
  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
-
1439
+ #private;
1440
+ constructor(http: HttpClient);
1441
+ /**
1442
+ * Fetches a single novel by ID.
1443
+ * GET /v2/novel/detail
1444
+ *
1445
+ * @param params - Request parameters
1446
+ *
1447
+ * @example
1448
+ * ```ts
1449
+ * const result = await client.novels.detail({ novelId: 67890 })
1450
+ * if (result.isOk) {
1451
+ * console.log(result.value.novel.title)
1452
+ * } else {
1453
+ * console.error(result.error)
1454
+ * }
1455
+ * ```
1456
+ */
1457
+ detail(params: NovelDetailParams): ResultAsync<NovelDetailResponse, PixivError>;
1458
+ /**
1459
+ * Fetches the WebView HTML for a novel.
1460
+ * GET /webview/v2/novel
1461
+ *
1462
+ * Returns the raw HTML page that the pixiv app renders in a WebView.
1463
+ * To extract the plain text, parse the returned HTML (e.g. strip tags).
1464
+ *
1465
+ * @param params - Request parameters
1466
+ */
1467
+ text(params: NovelTextParams): ResultAsync<string, PixivError>;
1468
+ /**
1469
+ * Fetches related novels for a given novel.
1470
+ * GET /v1/novel/related
1471
+ *
1472
+ * @param params - Request parameters
1473
+ */
1474
+ related(params: NovelRelatedParams): PaginatedResultAsync<NovelListPage, PixivNovelItem>;
1475
+ /**
1476
+ * Searches for novels.
1477
+ * GET /v1/search/novel
1478
+ *
1479
+ * @param params - Request parameters
1480
+ *
1481
+ * @example
1482
+ * ```ts
1483
+ * // Iterate all results across pages
1484
+ * for await (const novel of client.novels.search({ word: 'fantasy' }).items()) {
1485
+ * console.log(novel.title)
1486
+ * }
1487
+ *
1488
+ * // Fetch only the first page
1489
+ * const page = await client.novels.search({ word: 'fantasy' })
1490
+ * if (page.isOk) {
1491
+ * console.log(page.value.novels.length)
1492
+ * }
1493
+ * ```
1494
+ */
1495
+ search(params: NovelSearchParams): PaginatedResultAsync<NovelListPage, PixivNovelItem>;
1496
+ /**
1497
+ * Fetches the novel ranking.
1498
+ * GET /v1/novel/ranking
1499
+ *
1500
+ * @param params - Request parameters
1501
+ */
1502
+ ranking(params?: NovelRankingParams): PaginatedResultAsync<NovelListPage, PixivNovelItem>;
1503
+ /**
1504
+ * Fetches recommended novels.
1505
+ * GET /v1/novel/recommended
1506
+ *
1507
+ * @param params - Request parameters
1508
+ */
1509
+ recommended(params?: NovelRecommendedParams): PaginatedResultAsync<NovelRecommendedPage, PixivNovelItem>;
1510
+ /**
1511
+ * Fetches a novel series.
1512
+ * GET /v2/novel/series
1513
+ *
1514
+ * @param params - Request parameters
1515
+ */
1516
+ series(params: NovelSeriesParams): PaginatedResultAsync<NovelSeriesPage, PixivNovelItem>;
1517
+ /**
1518
+ * Adds a novel bookmark.
1519
+ * POST /v2/novel/bookmark/add
1520
+ *
1521
+ * @param params - Request parameters
1522
+ */
1523
+ bookmarkAdd(params: NovelBookmarkAddParams): ResultAsync<Record<string, never>, PixivError>;
1524
+ /**
1525
+ * Removes a novel bookmark.
1526
+ * POST /v1/novel/bookmark/delete
1527
+ *
1528
+ * @param params - Request parameters
1529
+ */
1530
+ bookmarkDelete(params: NovelBookmarkDeleteParams): ResultAsync<Record<string, never>, PixivError>;
1531
+ }
1532
+ //#endregion
1533
+ //#region src/resources/users.d.ts
1571
1534
  /** Parameters for fetching a user's bookmarked illusts. */
1572
1535
  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;
1536
+ /** ID of the user whose bookmarks to fetch. */
1537
+ userId: number;
1538
+ /** Visibility of the bookmarks to return (default: `"public"`). */
1539
+ restrict?: (typeof BookmarkRestrict)[keyof typeof BookmarkRestrict];
1540
+ /** OS filter to apply (default: `"for_ios"`). */
1541
+ filter?: (typeof OSFilter)[keyof typeof OSFilter];
1542
+ /** Limit results to bookmarks with this tag. */
1543
+ tag?: string;
1544
+ /** Fetch bookmarks older than this bookmark ID (cursor-based pagination). */
1545
+ maxBookmarkId?: number;
1546
+ /** Zero-based offset for pagination. */
1547
+ offset?: number;
1585
1548
  }
1586
1549
  /** Parameters for fetching a user's bookmarked novels. */
1587
1550
  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;
1551
+ /** ID of the user whose bookmarks to fetch. */
1552
+ userId: number;
1553
+ /** Visibility of the bookmarks to return (default: `"public"`). */
1554
+ restrict?: (typeof BookmarkRestrict)[keyof typeof BookmarkRestrict];
1555
+ /** OS filter to apply (default: `"for_ios"`). */
1556
+ filter?: (typeof OSFilter)[keyof typeof OSFilter];
1557
+ /** Limit results to bookmarks with this tag. */
1558
+ tag?: string;
1559
+ /** Fetch bookmarks older than this bookmark ID (cursor-based pagination). */
1560
+ maxBookmarkId?: number;
1561
+ /** Zero-based offset for pagination. */
1562
+ offset?: number;
1600
1563
  }
1601
1564
  /** Parameters for fetching a user's detail. */
1602
1565
  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];
1566
+ /** ID of the user to fetch. */
1567
+ userId: number;
1568
+ /** OS filter to apply (default: `"for_ios"`). */
1569
+ filter?: (typeof OSFilter)[keyof typeof OSFilter];
1607
1570
  }
1608
1571
  /** Parameters for fetching a user's illusts. */
1609
1572
  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;
1573
+ /** ID of the user whose illusts to fetch. */
1574
+ userId: number;
1575
+ /** Work type to filter by (omit to return both illusts and manga). */
1576
+ type?: (typeof UserIllustType)[keyof typeof UserIllustType];
1577
+ /** OS filter to apply (default: `"for_ios"`). */
1578
+ filter?: (typeof OSFilter)[keyof typeof OSFilter];
1579
+ /** Zero-based offset for pagination. */
1580
+ offset?: number;
1618
1581
  }
1619
1582
  /** Parameters for fetching a user's novels. */
1620
1583
  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;
1584
+ /** ID of the user whose novels to fetch. */
1585
+ userId: number;
1586
+ /** OS filter to apply (default: `"for_ios"`). */
1587
+ filter?: (typeof OSFilter)[keyof typeof OSFilter];
1588
+ /** Zero-based offset for pagination. */
1589
+ offset?: number;
1627
1590
  }
1628
1591
  /** Parameters for fetching a user's following list. */
1629
1592
  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;
1593
+ /** ID of the user whose following list to fetch. */
1594
+ userId: number;
1595
+ /** Visibility of the follows to return (default: `"public"`). */
1596
+ restrict?: (typeof FollowRestrict)[keyof typeof FollowRestrict];
1597
+ /** Zero-based offset for pagination. */
1598
+ offset?: number;
1636
1599
  }
1637
1600
  /** Parameters for following a user. */
1638
1601
  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];
1602
+ /** ID of the user to follow. */
1603
+ userId: number;
1604
+ /** Visibility of the follow (default: `"public"`). */
1605
+ restrict?: (typeof FollowRestrict)[keyof typeof FollowRestrict];
1643
1606
  }
1644
1607
  /** Parameters for unfollowing a user. */
1645
1608
  interface UserFollowDeleteParams {
1646
- /** ID of the user to unfollow. */
1647
- userId: number;
1609
+ /** ID of the user to unfollow. */
1610
+ userId: number;
1648
1611
  }
1649
1612
  /** Methods for the user bookmarks sub-namespace. */
1650
1613
  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>;
1614
+ #private;
1615
+ constructor(http: HttpClient);
1616
+ /**
1617
+ * Fetches a user's bookmarked illusts.
1618
+ * GET /v1/user/bookmarks/illust
1619
+ *
1620
+ * @param params - Request parameters
1621
+ *
1622
+ * @example
1623
+ * ```ts
1624
+ * // Iterate all bookmarked illusts across pages
1625
+ * for await (const illust of client.users.bookmarks.illusts({ userId: client.userId }).items()) {
1626
+ * console.log(illust.title)
1627
+ * }
1628
+ *
1629
+ * // Resume from a saved cursor
1630
+ * import { parseNextUrl } from '@book000/pixivts'
1631
+ * const page = await client.users.bookmarks.illusts({ userId: client.userId })
1632
+ * if (page.isOk && page.value.nextUrl) {
1633
+ * const cursor = parseNextUrl(page.value.nextUrl)
1634
+ * const next = await client.users.bookmarks.illusts({
1635
+ * userId: client.userId,
1636
+ * maxBookmarkId: cursor.maxBookmarkId,
1637
+ * })
1638
+ * }
1639
+ * ```
1640
+ */
1641
+ illusts(params: UserBookmarksIllustParams): PaginatedResultAsync<UserBookmarksIllustPage, PixivIllustItem>;
1642
+ /**
1643
+ * Fetches a user's bookmarked novels.
1644
+ * GET /v1/user/bookmarks/novel
1645
+ *
1646
+ * @param params - Request parameters
1647
+ *
1648
+ * @example
1649
+ * ```ts
1650
+ * // Iterate all bookmarked novels across pages
1651
+ * for await (const novel of client.users.bookmarks.novels({ userId: client.userId }).items()) {
1652
+ * console.log(novel.title)
1653
+ * }
1654
+ * ```
1655
+ */
1656
+ novels(params: UserBookmarksNovelParams): PaginatedResultAsync<UserBookmarksNovelPage, PixivNovelItem>;
1694
1657
  }
1695
1658
  /** Methods for the user API namespace. */
1696
1659
  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
-
1660
+ #private;
1661
+ /** User bookmarks sub-namespace. */
1662
+ readonly bookmarks: UserBookmarksResource;
1663
+ constructor(http: HttpClient);
1664
+ /**
1665
+ * Fetches detailed profile information for a user.
1666
+ * GET /v1/user/detail
1667
+ *
1668
+ * @param params - Request parameters
1669
+ */
1670
+ detail(params: UserDetailParams): ResultAsync<UserDetailResponse, PixivError>;
1671
+ /**
1672
+ * Fetches illusts posted by a user.
1673
+ * GET /v1/user/illusts
1674
+ *
1675
+ * @param params - Request parameters
1676
+ */
1677
+ illusts(params: UserIllustsParams): PaginatedResultAsync<UserIllustsPage, PixivIllustItem>;
1678
+ /**
1679
+ * Fetches novels posted by a user.
1680
+ * GET /v1/user/novels
1681
+ *
1682
+ * @param params - Request parameters
1683
+ */
1684
+ novels(params: UserNovelsParams): PaginatedResultAsync<UserNovelsPage, PixivNovelItem>;
1685
+ /**
1686
+ * Fetches the list of users that a user is following.
1687
+ * GET /v1/user/following
1688
+ *
1689
+ * @param params - Request parameters
1690
+ */
1691
+ following(params: UserFollowingParams): PaginatedResultAsync<UserFollowingPage, PixivUserPreviewItem>;
1692
+ /**
1693
+ * Follows a user.
1694
+ * POST /v1/user/follow/add
1695
+ *
1696
+ * @param params - Request parameters
1697
+ */
1698
+ followAdd(params: UserFollowAddParams): ResultAsync<Record<string, never>, PixivError>;
1699
+ /**
1700
+ * Unfollows a user.
1701
+ * POST /v1/user/follow/delete
1702
+ *
1703
+ * @param params - Request parameters
1704
+ */
1705
+ followDelete(params: UserFollowDeleteParams): ResultAsync<Record<string, never>, PixivError>;
1706
+ }
1707
+ //#endregion
1708
+ //#region src/resources/manga.d.ts
1749
1709
  /** Parameters for fetching recommended manga. */
1750
1710
  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;
1711
+ /** OS filter to apply (default: `"for_ios"`). */
1712
+ filter?: (typeof OSFilter)[keyof typeof OSFilter];
1713
+ /** Zero-based offset for pagination. */
1714
+ offset?: number;
1755
1715
  }
1756
1716
  /** Methods for the manga API namespace. */
1757
1717
  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
-
1718
+ #private;
1719
+ constructor(http: HttpClient);
1720
+ /**
1721
+ * Fetches recommended manga.
1722
+ * GET /v1/manga/recommended
1723
+ *
1724
+ * @param params - Request parameters
1725
+ */
1726
+ recommended(params?: MangaRecommendedParams): PaginatedResultAsync<MangaRecommendedPage, PixivIllustItem>;
1727
+ }
1728
+ //#endregion
1729
+ //#region src/resources/ugoira.d.ts
1773
1730
  /** Parameters for fetching ugoira metadata. */
1774
1731
  interface UgoiraMetadataParams {
1775
- /** ID of the ugoira illust whose metadata to fetch. */
1776
- illustId: number;
1732
+ /** ID of the ugoira illust whose metadata to fetch. */
1733
+ illustId: number;
1777
1734
  }
1778
1735
  /** Methods for the ugoira API namespace. */
1779
1736
  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
-
1737
+ #private;
1738
+ constructor(http: HttpClient);
1739
+ /**
1740
+ * Fetches ugoira metadata (ZIP URL and per-frame timings).
1741
+ * GET /v1/ugoira/metadata
1742
+ *
1743
+ * @param params - Request parameters
1744
+ */
1745
+ metadata(params: UgoiraMetadataParams): ResultAsync<UgoiraMetadataResponse, PixivError>;
1746
+ }
1747
+ //#endregion
1748
+ //#region src/resources/images.d.ts
1795
1749
  /** Methods for fetching pixiv images. */
1796
1750
  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
-
1751
+ #private;
1752
+ constructor(http: HttpClient);
1753
+ /**
1754
+ * Fetches a pixiv image.
1755
+ *
1756
+ * Uses a browser User-Agent and Referer (required for pixiv CDN).
1757
+ * No Authorization header is sent.
1758
+ *
1759
+ * @param imageUrl - Full CDN image URL
1760
+ */
1761
+ fetch(imageUrl: string): ResultAsync<Response, PixivError>;
1762
+ }
1763
+ //#endregion
1764
+ //#region src/client.d.ts
1821
1765
  /** Options for constructing a {@link PixivClient}. */
1822
1766
  interface PixivClientOptions {
1823
- /** Rate-limit retry configuration. */
1824
- retry?: Partial<RateLimitRetryOptions>;
1825
- /** Optional interceptor called after each successful response (DB seam). */
1826
- onResponse?: ResponseInterceptor;
1767
+ /** Rate-limit retry configuration. */
1768
+ retry?: Partial<RateLimitRetryOptions>;
1769
+ /** Optional interceptor called after each successful response (DB seam). */
1770
+ onResponse?: ResponseInterceptor;
1827
1771
  }
1828
1772
  /**
1829
1773
  * Main client for the pixiv API.
@@ -1832,62 +1776,63 @@ interface PixivClientOptions {
1832
1776
  * because initialisation requires an async token refresh.
1833
1777
  */
1834
1778
  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
-
1779
+ #private;
1780
+ /** Illust API namespace. */
1781
+ readonly illusts: IllustResource;
1782
+ /** Novel API namespace. */
1783
+ readonly novels: NovelResource;
1784
+ /** User API namespace. */
1785
+ readonly users: UserResource;
1786
+ /** Manga API namespace. */
1787
+ readonly manga: MangaResource;
1788
+ /** Ugoira API namespace. */
1789
+ readonly ugoira: UgoiraResource;
1790
+ /** Image fetch helpers. */
1791
+ readonly images: ImageResource;
1792
+ private constructor();
1793
+ /**
1794
+ * Numeric user ID of the authenticated account.
1795
+ *
1796
+ * Available immediately after {@link PixivClient.of} resolves.
1797
+ * The pixiv OAuth endpoint returns the ID as a string; this getter
1798
+ * normalises it to `number` for consistency with resource method params
1799
+ * (e.g. `UserBookmarksIllustParams.userId`).
1800
+ *
1801
+ * @example
1802
+ * ```ts
1803
+ * const client = await PixivClient.of(refreshToken)
1804
+ * const bookmarks = await client.users.bookmarks.illusts({ userId: client.userId })
1805
+ * ```
1806
+ */
1807
+ get userId(): number;
1808
+ /**
1809
+ * Returns the current OAuth access token.
1810
+ *
1811
+ * The access token is short-lived and changes after each call to
1812
+ * {@link PixivClient.of} and after each automatic token refresh triggered
1813
+ * by a 401 response.
1814
+ *
1815
+ * @returns The current bearer access token string
1816
+ */
1817
+ getAccessToken(): string;
1818
+ /**
1819
+ * Returns the current OAuth refresh token.
1820
+ *
1821
+ * The refresh token is long-lived and is used to obtain new access tokens.
1822
+ * It may rotate after a successful token refresh.
1823
+ *
1824
+ * @returns The current refresh token string
1825
+ */
1826
+ getRefreshToken(): string;
1827
+ /**
1828
+ * Creates a PixivClient by refreshing the given token.
1829
+ *
1830
+ * @param refreshToken - Pixiv refresh token
1831
+ * @param options - Optional retry and response interceptor configuration
1832
+ * @returns A fully initialised {@link PixivClient}
1833
+ */
1834
+ static of(refreshToken: string, options?: PixivClientOptions): Promise<PixivClient>;
1835
+ }
1836
+ //#endregion
1893
1837
  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 };
1838
+ //# sourceMappingURL=index.d.cts.map