ani-client 2.1.2 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/dist/cache/redis.d.mts +1 -0
- package/dist/cache/redis.d.ts +1 -0
- package/dist/cache/redis.js +94 -0
- package/dist/cache/redis.js.map +1 -0
- package/dist/cache/redis.mjs +92 -0
- package/dist/cache/redis.mjs.map +1 -0
- package/dist/index.d.mts +18 -243
- package/dist/index.d.ts +18 -243
- package/dist/index.js +47 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -8
- package/dist/index.mjs.map +1 -1
- package/dist/redis-AFbnh0Xa.d.mts +243 -0
- package/dist/redis-AFbnh0Xa.d.ts +243 -0
- package/package.json +6 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,170 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
perPage: number;
|
|
4
|
-
currentPage: number;
|
|
5
|
-
lastPage: number;
|
|
6
|
-
hasNextPage: boolean;
|
|
7
|
-
}
|
|
8
|
-
interface PagedResult<T> {
|
|
9
|
-
pageInfo: PageInfo;
|
|
10
|
-
results: T[];
|
|
11
|
-
}
|
|
12
|
-
interface FuzzyDate {
|
|
13
|
-
year: number | null;
|
|
14
|
-
month: number | null;
|
|
15
|
-
day: number | null;
|
|
16
|
-
}
|
|
17
|
-
interface ExternalLink {
|
|
18
|
-
id: number;
|
|
19
|
-
url: string | null;
|
|
20
|
-
site: string;
|
|
21
|
-
type: string | null;
|
|
22
|
-
icon: string | null;
|
|
23
|
-
color: string | null;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Interface that all cache adapters must implement.
|
|
27
|
-
* Methods may return sync values or Promises — the client awaits all calls.
|
|
28
|
-
*/
|
|
29
|
-
interface CacheAdapter {
|
|
30
|
-
/** Retrieve a cached value, or `undefined` if missing / expired. */
|
|
31
|
-
get<T>(key: string): T | undefined | Promise<T | undefined>;
|
|
32
|
-
/**
|
|
33
|
-
* Retrieve a cached value along with its stale status (for stale-while-revalidate).
|
|
34
|
-
* If implemented, the client will use this to trigger background revalidation.
|
|
35
|
-
*/
|
|
36
|
-
getWithMeta?<T>(key: string): {
|
|
37
|
-
data: T;
|
|
38
|
-
stale: boolean;
|
|
39
|
-
} | undefined | Promise<{
|
|
40
|
-
data: T;
|
|
41
|
-
stale: boolean;
|
|
42
|
-
} | undefined>;
|
|
43
|
-
/** Store a value in the cache. */
|
|
44
|
-
set<T>(key: string, data: T): void | Promise<void>;
|
|
45
|
-
/** Remove a specific entry. Returns `true` if the key existed. */
|
|
46
|
-
delete(key: string): boolean | Promise<boolean>;
|
|
47
|
-
/** Clear the entire cache. */
|
|
48
|
-
clear(): void | Promise<void>;
|
|
49
|
-
/** Number of entries currently stored. */
|
|
50
|
-
readonly size: number | Promise<number>;
|
|
51
|
-
/** Return all cache keys. */
|
|
52
|
-
keys(): string[] | Promise<string[]>;
|
|
53
|
-
/** Bulk-remove entries matching a pattern. Optional — the client provides a fallback. */
|
|
54
|
-
invalidate?(pattern: string | RegExp): number | Promise<number>;
|
|
55
|
-
}
|
|
56
|
-
/** Cache configuration options. */
|
|
57
|
-
interface CacheOptions {
|
|
58
|
-
/** Time-to-live in milliseconds (default: 86 400 000 = 24h) */
|
|
59
|
-
ttl?: number;
|
|
60
|
-
/** Maximum number of cached entries (default: 500, 0 = unlimited) */
|
|
61
|
-
maxSize?: number;
|
|
62
|
-
/** Set to false to disable caching entirely */
|
|
63
|
-
enabled?: boolean;
|
|
64
|
-
/**
|
|
65
|
-
* Stale-while-revalidate grace period in milliseconds (default: 0 = disabled).
|
|
66
|
-
* When set, expired entries are still returned within the grace window,
|
|
67
|
-
* allowing the caller to refresh in the background.
|
|
68
|
-
*/
|
|
69
|
-
staleWhileRevalidateMs?: number;
|
|
70
|
-
}
|
|
71
|
-
/** Rate limiter configuration options. */
|
|
72
|
-
interface RateLimitOptions {
|
|
73
|
-
/** Max requests per window (default: 25) */
|
|
74
|
-
maxRequests?: number;
|
|
75
|
-
/** Window size in ms (default: 60 000) */
|
|
76
|
-
windowMs?: number;
|
|
77
|
-
/** Max retries on 429 (default: 3) */
|
|
78
|
-
maxRetries?: number;
|
|
79
|
-
/** Retry delay in ms when Retry-After header is absent (default: 2000) */
|
|
80
|
-
retryDelayMs?: number;
|
|
81
|
-
/** Set to false to disable rate limiting entirely */
|
|
82
|
-
enabled?: boolean;
|
|
83
|
-
/** Timeout per request in ms (default: 30 000). 0 = no timeout. */
|
|
84
|
-
timeoutMs?: number;
|
|
85
|
-
/** Retry on network errors like ECONNRESET / ETIMEDOUT (default: true) */
|
|
86
|
-
retryOnNetworkError?: boolean;
|
|
87
|
-
/**
|
|
88
|
-
* Custom retry delay strategy. Receives the attempt number (0-based) and the base delay,
|
|
89
|
-
* and should return the delay in ms before retrying.
|
|
90
|
-
* When omitted, the default exponential backoff with jitter is used.
|
|
91
|
-
*
|
|
92
|
-
* @example
|
|
93
|
-
* // Linear backoff: 1s, 2s, 3s, ...
|
|
94
|
-
* retryStrategy: (attempt) => (attempt + 1) * 1000
|
|
95
|
-
*/
|
|
96
|
-
retryStrategy?: (attempt: number, baseDelayMs: number) => number;
|
|
97
|
-
}
|
|
98
|
-
/** Event hooks for logging, debugging, and monitoring. */
|
|
99
|
-
interface AniListHooks {
|
|
100
|
-
/** Called before every API request. */
|
|
101
|
-
onRequest?: (query: string, variables: Record<string, unknown>) => void;
|
|
102
|
-
/** Called when a response is served from cache. */
|
|
103
|
-
onCacheHit?: (key: string) => void;
|
|
104
|
-
/** Called when the rate limiter enforces a wait (429 received). */
|
|
105
|
-
onRateLimit?: (retryAfterMs: number) => void;
|
|
106
|
-
/** Called when a request is retried (429 or network error). */
|
|
107
|
-
onRetry?: (attempt: number, reason: string, delayMs: number) => void;
|
|
108
|
-
/** Called when a request completes. */
|
|
109
|
-
onResponse?: (query: string, durationMs: number, fromCache: boolean, rateLimitInfo?: RateLimitInfo) => void;
|
|
110
|
-
/** Called when a request fails with an error. */
|
|
111
|
-
onError?: (error: Error, query: string, variables: Record<string, unknown>) => void;
|
|
112
|
-
}
|
|
113
|
-
/** Rate limit information parsed from AniList API response headers. */
|
|
114
|
-
interface RateLimitInfo {
|
|
115
|
-
/** Maximum number of requests allowed per window. */
|
|
116
|
-
limit: number;
|
|
117
|
-
/** Remaining requests in the current window. */
|
|
118
|
-
remaining: number;
|
|
119
|
-
/** UNIX timestamp (seconds) when the rate limit window resets. */
|
|
120
|
-
reset: number;
|
|
121
|
-
}
|
|
122
|
-
/** Metadata about the last request, useful for debugging and monitoring. */
|
|
123
|
-
interface ResponseMeta {
|
|
124
|
-
/** Duration of the request in milliseconds. */
|
|
125
|
-
durationMs: number;
|
|
126
|
-
/** Whether the response was served from cache. */
|
|
127
|
-
fromCache: boolean;
|
|
128
|
-
/** Rate limit information from the API response headers (not present for cached responses). */
|
|
129
|
-
rateLimitInfo?: RateLimitInfo;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Minimal logger interface for structured log output.
|
|
133
|
-
* Compatible with `console`, `pino`, `winston`, etc.
|
|
134
|
-
*/
|
|
135
|
-
interface Logger {
|
|
136
|
-
debug(message: string, ...args: unknown[]): void;
|
|
137
|
-
info(message: string, ...args: unknown[]): void;
|
|
138
|
-
warn(message: string, ...args: unknown[]): void;
|
|
139
|
-
error(message: string, ...args: unknown[]): void;
|
|
140
|
-
}
|
|
141
|
-
interface AniListClientOptions {
|
|
142
|
-
/** Optional AniList OAuth token for authenticated requests */
|
|
143
|
-
token?: string;
|
|
144
|
-
/** Custom API endpoint (defaults to https://graphql.anilist.co) */
|
|
145
|
-
apiUrl?: string;
|
|
146
|
-
/** Cache configuration (enabled by default, 24h TTL) */
|
|
147
|
-
cache?: CacheOptions;
|
|
148
|
-
/** Custom cache adapter (e.g. RedisCache). Takes precedence over `cache`. */
|
|
149
|
-
cacheAdapter?: CacheAdapter;
|
|
150
|
-
/** Rate limiter configuration (enabled by default, 85 req/min) */
|
|
151
|
-
rateLimit?: RateLimitOptions;
|
|
152
|
-
/** Event hooks for logging, debugging, and monitoring */
|
|
153
|
-
hooks?: AniListHooks;
|
|
154
|
-
/** Optional AbortSignal to cancel all requests made by this client */
|
|
155
|
-
signal?: AbortSignal;
|
|
156
|
-
/**
|
|
157
|
-
* Optional logger for structured log output.
|
|
158
|
-
* Accepts any object with `debug`, `info`, `warn`, `error` methods.
|
|
159
|
-
* Compatible with `console`, `pino`, `winston`, etc.
|
|
160
|
-
*
|
|
161
|
-
* @example
|
|
162
|
-
* ```ts
|
|
163
|
-
* const client = new AniListClient({ logger: console });
|
|
164
|
-
* ```
|
|
165
|
-
*/
|
|
166
|
-
logger?: Logger;
|
|
167
|
-
}
|
|
1
|
+
import { F as FuzzyDate, P as PageInfo, E as ExternalLink, C as CacheAdapter, a as CacheOptions, b as PagedResult, A as AniListClientOptions, R as RateLimitInfo, c as ResponseMeta, d as RateLimitOptions } from './redis-AFbnh0Xa.js';
|
|
2
|
+
export { e as AniListHooks, L as Logger, f as RedisCache, g as RedisCacheOptions, h as RedisLikeClient } from './redis-AFbnh0Xa.js';
|
|
168
3
|
|
|
169
4
|
declare enum MediaListStatus {
|
|
170
5
|
CURRENT = "CURRENT",
|
|
@@ -1120,6 +955,11 @@ declare class NormalizedCache implements CacheAdapter {
|
|
|
1120
955
|
entitiesCount: number;
|
|
1121
956
|
};
|
|
1122
957
|
resetStats(): void;
|
|
958
|
+
/**
|
|
959
|
+
* Garbage-collect orphaned entities that are no longer referenced by any query.
|
|
960
|
+
* Called automatically on LRU eviction to prevent unbounded entity store growth.
|
|
961
|
+
*/
|
|
962
|
+
gc(): number;
|
|
1123
963
|
}
|
|
1124
964
|
|
|
1125
965
|
/** Cache performance statistics. */
|
|
@@ -1146,13 +986,10 @@ declare class MemoryCache implements CacheAdapter {
|
|
|
1146
986
|
/** Build a deterministic cache key from a query + variables pair. */
|
|
1147
987
|
static key(query: string, variables: Record<string, unknown>): string;
|
|
1148
988
|
/**
|
|
1149
|
-
* Retrieve a cached value
|
|
989
|
+
* Retrieve a cached value and its stale status.
|
|
1150
990
|
* With stale-while-revalidate enabled, returns stale data within the grace window
|
|
1151
991
|
* and flags it so the caller can refresh in the background.
|
|
1152
992
|
*/
|
|
1153
|
-
/**
|
|
1154
|
-
* Retrieve a cached value and its stale status.
|
|
1155
|
-
*/
|
|
1156
993
|
getWithMeta<T>(key: string): {
|
|
1157
994
|
data: T;
|
|
1158
995
|
stale: boolean;
|
|
@@ -1195,77 +1032,15 @@ declare class MemoryCache implements CacheAdapter {
|
|
|
1195
1032
|
}
|
|
1196
1033
|
|
|
1197
1034
|
/**
|
|
1198
|
-
*
|
|
1199
|
-
*
|
|
1200
|
-
*/
|
|
1201
|
-
interface RedisLikeClient {
|
|
1202
|
-
get(key: string): Promise<string | null>;
|
|
1203
|
-
set(key: string, value: string, ...args: unknown[]): Promise<unknown>;
|
|
1204
|
-
del(...keys: (string | string[])[]): Promise<number>;
|
|
1205
|
-
keys(pattern: string): Promise<string[]>;
|
|
1206
|
-
/** Optional SCAN-based iteration — used when available to avoid blocking the server. */
|
|
1207
|
-
scanIterator?(options: {
|
|
1208
|
-
MATCH: string;
|
|
1209
|
-
COUNT?: number;
|
|
1210
|
-
}): AsyncIterable<string>;
|
|
1211
|
-
}
|
|
1212
|
-
interface RedisCacheOptions {
|
|
1213
|
-
/** A Redis client instance (ioredis or node-redis). */
|
|
1214
|
-
client: RedisLikeClient;
|
|
1215
|
-
/** Key prefix to namespace ani-client entries (default: `"ani:"`) */
|
|
1216
|
-
prefix?: string;
|
|
1217
|
-
/** TTL in seconds (default: 86 400 = 24 h) */
|
|
1218
|
-
ttl?: number;
|
|
1219
|
-
}
|
|
1220
|
-
/**
|
|
1221
|
-
* Redis-backed cache adapter for AniListClient.
|
|
1035
|
+
* Base interface for the client context shared by all domain method modules.
|
|
1036
|
+
* Exposes only the internal request methods that domain functions need.
|
|
1222
1037
|
*
|
|
1223
|
-
* @
|
|
1224
|
-
* ```ts
|
|
1225
|
-
* import Redis from "ioredis";
|
|
1226
|
-
* import { AniListClient, RedisCache } from "ani-client";
|
|
1227
|
-
*
|
|
1228
|
-
* const redis = new Redis();
|
|
1229
|
-
* const client = new AniListClient({
|
|
1230
|
-
* cacheAdapter: new RedisCache({ client: redis }),
|
|
1231
|
-
* });
|
|
1232
|
-
* ```
|
|
1038
|
+
* @internal
|
|
1233
1039
|
*/
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
constructor(options: RedisCacheOptions);
|
|
1239
|
-
private prefixedKey;
|
|
1240
|
-
get<T>(key: string): Promise<T | undefined>;
|
|
1241
|
-
set<T>(key: string, data: T): Promise<void>;
|
|
1242
|
-
delete(key: string): Promise<boolean>;
|
|
1243
|
-
/**
|
|
1244
|
-
* Collect keys matching a pattern. Uses SCAN when available, falls back to KEYS.
|
|
1245
|
-
*
|
|
1246
|
-
* **Warning:** The `KEYS` fallback is O(N) and blocks the Redis server.
|
|
1247
|
-
* Provide a client with `scanIterator` support for production use.
|
|
1248
|
-
* @internal
|
|
1249
|
-
*/
|
|
1250
|
-
private collectKeys;
|
|
1251
|
-
clear(): Promise<void>;
|
|
1252
|
-
/**
|
|
1253
|
-
* Get the actual number of keys with this prefix in Redis.
|
|
1254
|
-
*/
|
|
1255
|
-
get size(): Promise<number>;
|
|
1256
|
-
/** @internal */
|
|
1257
|
-
private getSize;
|
|
1258
|
-
keys(): Promise<string[]>;
|
|
1259
|
-
/**
|
|
1260
|
-
* Remove all entries whose key matches the given pattern.
|
|
1261
|
-
*
|
|
1262
|
-
* - **String**: treated as a substring match (e.g. `"Media"` removes all keys containing `"Media"`).
|
|
1263
|
-
* - **RegExp**: tested against each key directly.
|
|
1264
|
-
*
|
|
1265
|
-
* @param pattern — A string (substring match) or RegExp.
|
|
1266
|
-
* @returns Number of entries removed.
|
|
1267
|
-
*/
|
|
1268
|
-
invalidate(pattern: string | RegExp): Promise<number>;
|
|
1040
|
+
interface ClientBase {
|
|
1041
|
+
request<T>(query: string, variables?: Record<string, unknown>): Promise<T>;
|
|
1042
|
+
pagedRequest<T>(query: string, variables: Record<string, unknown>, field: string): Promise<PagedResult<T>>;
|
|
1043
|
+
paginate<T>(fetchPage: (page: number) => Promise<PagedResult<T>>, maxPages?: number): AsyncGenerator<T, void, undefined>;
|
|
1269
1044
|
}
|
|
1270
1045
|
|
|
1271
1046
|
/**
|
|
@@ -1286,7 +1061,7 @@ declare class RedisCache implements CacheAdapter {
|
|
|
1286
1061
|
* });
|
|
1287
1062
|
* ```
|
|
1288
1063
|
*/
|
|
1289
|
-
declare class AniListClient {
|
|
1064
|
+
declare class AniListClient implements ClientBase {
|
|
1290
1065
|
private readonly apiUrl;
|
|
1291
1066
|
private readonly headers;
|
|
1292
1067
|
private readonly cacheAdapter;
|
|
@@ -1358,7 +1133,7 @@ declare class AniListClient {
|
|
|
1358
1133
|
*/
|
|
1359
1134
|
getMediaByMalId(malId: number, type?: MediaType): Promise<Media>;
|
|
1360
1135
|
/** Get the detailed schedule for the current week, sorted by day. */
|
|
1361
|
-
getWeeklySchedule(date?: Date): Promise<WeeklySchedule>;
|
|
1136
|
+
getWeeklySchedule(date?: Date, idNotIn?: number[]): Promise<WeeklySchedule>;
|
|
1362
1137
|
/** Get upcoming (not yet released) media. */
|
|
1363
1138
|
getPlanning(options?: GetPlanningOptions): Promise<PagedResult<Media>>;
|
|
1364
1139
|
/** Get recommendations for a specific media. */
|
|
@@ -1532,4 +1307,4 @@ declare class RateLimiter {
|
|
|
1532
1307
|
|
|
1533
1308
|
declare function parseAniListMarkdown(text: string): string;
|
|
1534
1309
|
|
|
1535
|
-
export { type AiringSchedule, AiringSort, AniListClient,
|
|
1310
|
+
export { type AiringSchedule, AiringSort, AniListClient, AniListClientOptions, AniListError, CacheAdapter, CacheOptions, type CacheStats, type Character, type CharacterImage, type CharacterIncludeOptions, type CharacterMediaEdge, type CharacterName, CharacterRole, CharacterSort, type DayOfWeek, ExternalLink, type FavoriteCharacterNode, type FavoriteMediaNode, type FavoriteStaffNode, type FavoriteStudioNode, FuzzyDate, type GetAiringOptions, type GetMediaCharactersOptions, type GetMediaStaffOptions, type GetPlanningOptions, type GetRecentChaptersOptions, type GetRecommendationsOptions, type GetSeasonOptions, type GetUserMediaListOptions, type Media, type MediaCharacterConnection, type MediaCharacterEdge, type MediaConnection, type MediaCoverImage, type MediaEdge, MediaFormat, type MediaIncludeOptions, type MediaListEntry, MediaListSort, MediaListStatus, type MediaRecommendationNode, MediaRelationType, MediaSeason, MediaSort, MediaSource, type MediaStaffConnection, type MediaStaffEdge, type MediaStats, MediaStatus, type MediaTag, type MediaTitle, type MediaTrailer, MediaType, MemoryCache, type NextAiringEpisode, NormalizedCache, PageInfo, PagedResult, RateLimitInfo, RateLimitOptions, RateLimiter, type Recommendation, RecommendationSort, ResponseMeta, type Review, ReviewSort, type ScoreDistribution, type SearchCharacterOptions, type SearchMediaOptions, type SearchReviewOptions, type SearchStaffOptions, type SearchStudioOptions, type SearchThreadOptions, type SearchUserOptions, type Staff, type StaffImage, type StaffIncludeOptions, type StaffMediaNode, type StaffName, StaffSort, type StatusDistribution, type StreamingEpisode, type Studio, type StudioConnection, type StudioIncludeOptions, StudioSort, type Thread, type ThreadCategory, type ThreadMediaCategory, ThreadSort, type User, type UserAvatar, type UserFavorites, type UserFavoritesOptions, UserSort, type UserStatistics, type VoiceActor, type WeeklySchedule, parseAniListMarkdown };
|
package/dist/index.js
CHANGED
|
@@ -247,6 +247,7 @@ var NormalizedCache = class {
|
|
|
247
247
|
if (this.maxSize > 0 && this.queryStore.size >= this.maxSize) {
|
|
248
248
|
const firstKey = this.queryStore.keys().next().value;
|
|
249
249
|
if (firstKey !== void 0) this.queryStore.delete(firstKey);
|
|
250
|
+
this.gc();
|
|
250
251
|
}
|
|
251
252
|
this.queryStore.set(key, { data: normalizedData, expiresAt: Date.now() + this.ttl });
|
|
252
253
|
}
|
|
@@ -290,6 +291,43 @@ var NormalizedCache = class {
|
|
|
290
291
|
this._misses = 0;
|
|
291
292
|
this._stales = 0;
|
|
292
293
|
}
|
|
294
|
+
/**
|
|
295
|
+
* Garbage-collect orphaned entities that are no longer referenced by any query.
|
|
296
|
+
* Called automatically on LRU eviction to prevent unbounded entity store growth.
|
|
297
|
+
*/
|
|
298
|
+
gc() {
|
|
299
|
+
const referencedRefs = /* @__PURE__ */ new Set();
|
|
300
|
+
const collectRefs = (data) => {
|
|
301
|
+
if (Array.isArray(data)) {
|
|
302
|
+
for (const item of data) collectRefs(item);
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
if (data !== null && typeof data === "object") {
|
|
306
|
+
const obj = data;
|
|
307
|
+
if (typeof obj.__ref === "string") {
|
|
308
|
+
referencedRefs.add(obj.__ref);
|
|
309
|
+
const entity = this.entityStore.get(obj.__ref);
|
|
310
|
+
if (entity && !referencedRefs.has(`_visited:${obj.__ref}`)) {
|
|
311
|
+
referencedRefs.add(`_visited:${obj.__ref}`);
|
|
312
|
+
collectRefs(entity);
|
|
313
|
+
}
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
for (const v of Object.values(obj)) collectRefs(v);
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
for (const entry of this.queryStore.values()) {
|
|
320
|
+
collectRefs(entry.data);
|
|
321
|
+
}
|
|
322
|
+
let removed = 0;
|
|
323
|
+
for (const ref of this.entityStore.keys()) {
|
|
324
|
+
if (!referencedRefs.has(ref)) {
|
|
325
|
+
this.entityStore.delete(ref);
|
|
326
|
+
removed++;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
return removed;
|
|
330
|
+
}
|
|
293
331
|
};
|
|
294
332
|
|
|
295
333
|
// src/cache/index.ts
|
|
@@ -315,13 +353,10 @@ var MemoryCache = class {
|
|
|
315
353
|
return `${normalized}|${JSON.stringify(sortObjectKeys(variables))}`;
|
|
316
354
|
}
|
|
317
355
|
/**
|
|
318
|
-
* Retrieve a cached value
|
|
356
|
+
* Retrieve a cached value and its stale status.
|
|
319
357
|
* With stale-while-revalidate enabled, returns stale data within the grace window
|
|
320
358
|
* and flags it so the caller can refresh in the background.
|
|
321
359
|
*/
|
|
322
|
-
/**
|
|
323
|
-
* Retrieve a cached value and its stale status.
|
|
324
|
-
*/
|
|
325
360
|
getWithMeta(key) {
|
|
326
361
|
if (!this.enabled) return void 0;
|
|
327
362
|
const entry = this.store.get(key);
|
|
@@ -2190,7 +2225,11 @@ async function getReview(client, id) {
|
|
|
2190
2225
|
}
|
|
2191
2226
|
async function searchReviews(client, options = {}) {
|
|
2192
2227
|
const { mediaId, userId, sort, page = 1, perPage = 20 } = options;
|
|
2193
|
-
return client.pagedRequest(
|
|
2228
|
+
return client.pagedRequest(
|
|
2229
|
+
QUERY_REVIEWS,
|
|
2230
|
+
{ mediaId, userId, sort, page, perPage: clampPerPage(perPage) },
|
|
2231
|
+
"reviews"
|
|
2232
|
+
);
|
|
2194
2233
|
}
|
|
2195
2234
|
|
|
2196
2235
|
// src/client/staff.ts
|
|
@@ -2324,7 +2363,7 @@ function mapFavorites(fav) {
|
|
|
2324
2363
|
|
|
2325
2364
|
// src/client/index.ts
|
|
2326
2365
|
var DEFAULT_API_URL = "https://graphql.anilist.co";
|
|
2327
|
-
var LIB_VERSION = "2.1.
|
|
2366
|
+
var LIB_VERSION = "2.1.3" ;
|
|
2328
2367
|
var AniListClient = class {
|
|
2329
2368
|
apiUrl;
|
|
2330
2369
|
headers;
|
|
@@ -2537,8 +2576,8 @@ var AniListClient = class {
|
|
|
2537
2576
|
return getMediaByMalId(this, malId, type);
|
|
2538
2577
|
}
|
|
2539
2578
|
/** Get the detailed schedule for the current week, sorted by day. */
|
|
2540
|
-
async getWeeklySchedule(date) {
|
|
2541
|
-
return getWeeklySchedule(this, date);
|
|
2579
|
+
async getWeeklySchedule(date, idNotIn) {
|
|
2580
|
+
return getWeeklySchedule(this, date, idNotIn);
|
|
2542
2581
|
}
|
|
2543
2582
|
/** Get upcoming (not yet released) media. */
|
|
2544
2583
|
async getPlanning(options = {}) {
|