ani-client 2.1.2 → 2.1.4
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 +10 -2
- 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 +20 -245
- package/dist/index.d.ts +20 -245
- package/dist/index.js +50 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +50 -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.mjs
CHANGED
|
@@ -245,6 +245,7 @@ var NormalizedCache = class {
|
|
|
245
245
|
if (this.maxSize > 0 && this.queryStore.size >= this.maxSize) {
|
|
246
246
|
const firstKey = this.queryStore.keys().next().value;
|
|
247
247
|
if (firstKey !== void 0) this.queryStore.delete(firstKey);
|
|
248
|
+
this.gc();
|
|
248
249
|
}
|
|
249
250
|
this.queryStore.set(key, { data: normalizedData, expiresAt: Date.now() + this.ttl });
|
|
250
251
|
}
|
|
@@ -288,6 +289,43 @@ var NormalizedCache = class {
|
|
|
288
289
|
this._misses = 0;
|
|
289
290
|
this._stales = 0;
|
|
290
291
|
}
|
|
292
|
+
/**
|
|
293
|
+
* Garbage-collect orphaned entities that are no longer referenced by any query.
|
|
294
|
+
* Called automatically on LRU eviction to prevent unbounded entity store growth.
|
|
295
|
+
*/
|
|
296
|
+
gc() {
|
|
297
|
+
const referencedRefs = /* @__PURE__ */ new Set();
|
|
298
|
+
const collectRefs = (data) => {
|
|
299
|
+
if (Array.isArray(data)) {
|
|
300
|
+
for (const item of data) collectRefs(item);
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
if (data !== null && typeof data === "object") {
|
|
304
|
+
const obj = data;
|
|
305
|
+
if (typeof obj.__ref === "string") {
|
|
306
|
+
referencedRefs.add(obj.__ref);
|
|
307
|
+
const entity = this.entityStore.get(obj.__ref);
|
|
308
|
+
if (entity && !referencedRefs.has(`_visited:${obj.__ref}`)) {
|
|
309
|
+
referencedRefs.add(`_visited:${obj.__ref}`);
|
|
310
|
+
collectRefs(entity);
|
|
311
|
+
}
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
for (const v of Object.values(obj)) collectRefs(v);
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
for (const entry of this.queryStore.values()) {
|
|
318
|
+
collectRefs(entry.data);
|
|
319
|
+
}
|
|
320
|
+
let removed = 0;
|
|
321
|
+
for (const ref of this.entityStore.keys()) {
|
|
322
|
+
if (!referencedRefs.has(ref)) {
|
|
323
|
+
this.entityStore.delete(ref);
|
|
324
|
+
removed++;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return removed;
|
|
328
|
+
}
|
|
291
329
|
};
|
|
292
330
|
|
|
293
331
|
// src/cache/index.ts
|
|
@@ -313,13 +351,10 @@ var MemoryCache = class {
|
|
|
313
351
|
return `${normalized}|${JSON.stringify(sortObjectKeys(variables))}`;
|
|
314
352
|
}
|
|
315
353
|
/**
|
|
316
|
-
* Retrieve a cached value
|
|
354
|
+
* Retrieve a cached value and its stale status.
|
|
317
355
|
* With stale-while-revalidate enabled, returns stale data within the grace window
|
|
318
356
|
* and flags it so the caller can refresh in the background.
|
|
319
357
|
*/
|
|
320
|
-
/**
|
|
321
|
-
* Retrieve a cached value and its stale status.
|
|
322
|
-
*/
|
|
323
358
|
getWithMeta(key) {
|
|
324
359
|
if (!this.enabled) return void 0;
|
|
325
360
|
const entry = this.store.get(key);
|
|
@@ -612,6 +647,7 @@ var RELATIONS_FIELDS = `
|
|
|
612
647
|
type
|
|
613
648
|
format
|
|
614
649
|
status
|
|
650
|
+
description(asHtml: false)
|
|
615
651
|
startDate { year month day }
|
|
616
652
|
endDate { year month day }
|
|
617
653
|
season
|
|
@@ -646,6 +682,8 @@ var MEDIA_RECOMMENDATION_FIELDS = `
|
|
|
646
682
|
title { romaji english native userPreferred }
|
|
647
683
|
type
|
|
648
684
|
format
|
|
685
|
+
status
|
|
686
|
+
description(asHtml: false)
|
|
649
687
|
coverImage { extraLarge large medium color }
|
|
650
688
|
averageScore
|
|
651
689
|
meanScore
|
|
@@ -2188,7 +2226,11 @@ async function getReview(client, id) {
|
|
|
2188
2226
|
}
|
|
2189
2227
|
async function searchReviews(client, options = {}) {
|
|
2190
2228
|
const { mediaId, userId, sort, page = 1, perPage = 20 } = options;
|
|
2191
|
-
return client.pagedRequest(
|
|
2229
|
+
return client.pagedRequest(
|
|
2230
|
+
QUERY_REVIEWS,
|
|
2231
|
+
{ mediaId, userId, sort, page, perPage: clampPerPage(perPage) },
|
|
2232
|
+
"reviews"
|
|
2233
|
+
);
|
|
2192
2234
|
}
|
|
2193
2235
|
|
|
2194
2236
|
// src/client/staff.ts
|
|
@@ -2322,7 +2364,7 @@ function mapFavorites(fav) {
|
|
|
2322
2364
|
|
|
2323
2365
|
// src/client/index.ts
|
|
2324
2366
|
var DEFAULT_API_URL = "https://graphql.anilist.co";
|
|
2325
|
-
var LIB_VERSION = "2.1.
|
|
2367
|
+
var LIB_VERSION = "2.1.4" ;
|
|
2326
2368
|
var AniListClient = class {
|
|
2327
2369
|
apiUrl;
|
|
2328
2370
|
headers;
|
|
@@ -2535,8 +2577,8 @@ var AniListClient = class {
|
|
|
2535
2577
|
return getMediaByMalId(this, malId, type);
|
|
2536
2578
|
}
|
|
2537
2579
|
/** Get the detailed schedule for the current week, sorted by day. */
|
|
2538
|
-
async getWeeklySchedule(date) {
|
|
2539
|
-
return getWeeklySchedule(this, date);
|
|
2580
|
+
async getWeeklySchedule(date, idNotIn) {
|
|
2581
|
+
return getWeeklySchedule(this, date, idNotIn);
|
|
2540
2582
|
}
|
|
2541
2583
|
/** Get upcoming (not yet released) media. */
|
|
2542
2584
|
async getPlanning(options = {}) {
|