@ncukondo/reference-manager 0.27.2 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/chunks/{SearchableMultiSelect-0cyizees.js → SearchableMultiSelect-LIMpJm8A.js} +2 -2
  2. package/dist/chunks/{SearchableMultiSelect-0cyizees.js.map → SearchableMultiSelect-LIMpJm8A.js.map} +1 -1
  3. package/dist/chunks/{action-menu-Crcd5X1-.js → action-menu-CdJjcmdk.js} +3 -3
  4. package/dist/chunks/{action-menu-Crcd5X1-.js.map → action-menu-CdJjcmdk.js.map} +1 -1
  5. package/dist/chunks/{checker-gLAPe44T.js → checker-CP8vSC-S.js} +5 -5
  6. package/dist/chunks/{checker-gLAPe44T.js.map → checker-CP8vSC-S.js.map} +1 -1
  7. package/dist/chunks/{crossref-client-CXw0mw4n.js → crossref-client-C1HVx8LA.js} +2 -2
  8. package/dist/chunks/{crossref-client-CXw0mw4n.js.map → crossref-client-C1HVx8LA.js.map} +1 -1
  9. package/dist/chunks/{file-watcher-Dlx0PolG.js → file-watcher-CWHg1yol.js} +48 -2
  10. package/dist/chunks/file-watcher-CWHg1yol.js.map +1 -0
  11. package/dist/chunks/{fix-interaction-BCtx4Q9F.js → fix-interaction-BR3VVyHq.js} +5 -5
  12. package/dist/chunks/{fix-interaction-BCtx4Q9F.js.map → fix-interaction-BR3VVyHq.js.map} +1 -1
  13. package/dist/chunks/{index-Cf5bYLrr.js → index-BP_TPa_d.js} +4 -4
  14. package/dist/chunks/{index-Cf5bYLrr.js.map → index-BP_TPa_d.js.map} +1 -1
  15. package/dist/chunks/{index-DkJT7s7N.js → index-C9Gc8dcm.js} +54 -41
  16. package/dist/chunks/index-C9Gc8dcm.js.map +1 -0
  17. package/dist/chunks/{index-SwsAKyQr.js → index-CHe855EM.js} +3 -3
  18. package/dist/chunks/index-CHe855EM.js.map +1 -0
  19. package/dist/chunks/{index-BdLVfbj0.js → index-T-edKSzd.js} +198 -19
  20. package/dist/chunks/index-T-edKSzd.js.map +1 -0
  21. package/dist/chunks/{loader-B-fte1uv.js → loader-B6sytmQd.js} +2 -2
  22. package/dist/chunks/{loader-B-fte1uv.js.map → loader-B6sytmQd.js.map} +1 -1
  23. package/dist/chunks/{metadata-comparator-C5zfoYdK.js → metadata-comparator-DvqzC5tX.js} +5 -3
  24. package/dist/chunks/metadata-comparator-DvqzC5tX.js.map +1 -0
  25. package/dist/chunks/{pubmed-client-DH9y2tEZ.js → pubmed-client-DEo6eaH7.js} +2 -2
  26. package/dist/chunks/{pubmed-client-DH9y2tEZ.js.map → pubmed-client-DEo6eaH7.js.map} +1 -1
  27. package/dist/chunks/{reference-select-Ce9pG8cC.js → reference-select-B54Upu7p.js} +4 -4
  28. package/dist/chunks/{reference-select-Ce9pG8cC.js.map → reference-select-B54Upu7p.js.map} +1 -1
  29. package/dist/chunks/{style-select-AvDsSnlB.js → style-select-BUwM-Azt.js} +3 -3
  30. package/dist/chunks/{style-select-AvDsSnlB.js.map → style-select-BUwM-Azt.js.map} +1 -1
  31. package/dist/cli/completion.d.ts.map +1 -1
  32. package/dist/cli/index.d.ts.map +1 -1
  33. package/dist/cli.js +2 -2
  34. package/dist/core/csl-json/types.d.ts +67 -0
  35. package/dist/core/csl-json/types.d.ts.map +1 -1
  36. package/dist/features/attachments/types.d.ts +8 -16
  37. package/dist/features/attachments/types.d.ts.map +1 -1
  38. package/dist/features/check/metadata-similarity.d.ts +1 -0
  39. package/dist/features/check/metadata-similarity.d.ts.map +1 -1
  40. package/dist/features/duplicate/detector.d.ts.map +1 -1
  41. package/dist/features/duplicate/types.d.ts +2 -1
  42. package/dist/features/duplicate/types.d.ts.map +1 -1
  43. package/dist/features/format/citation-fallback.d.ts.map +1 -1
  44. package/dist/features/format/pretty.d.ts.map +1 -1
  45. package/dist/features/format/resource-indicators.d.ts.map +1 -1
  46. package/dist/features/import/cache.d.ts +7 -1
  47. package/dist/features/import/cache.d.ts.map +1 -1
  48. package/dist/features/import/detector.d.ts +15 -2
  49. package/dist/features/import/detector.d.ts.map +1 -1
  50. package/dist/features/import/fetcher.d.ts +7 -0
  51. package/dist/features/import/fetcher.d.ts.map +1 -1
  52. package/dist/features/import/importer.d.ts.map +1 -1
  53. package/dist/features/import/normalizer.d.ts +16 -0
  54. package/dist/features/import/normalizer.d.ts.map +1 -1
  55. package/dist/features/import/rate-limiter.d.ts +1 -1
  56. package/dist/features/import/rate-limiter.d.ts.map +1 -1
  57. package/dist/features/operations/attachments/get.d.ts.map +1 -1
  58. package/dist/features/operations/attachments/list.d.ts.map +1 -1
  59. package/dist/features/operations/attachments/open.d.ts.map +1 -1
  60. package/dist/features/operations/fulltext/convert.d.ts.map +1 -1
  61. package/dist/features/operations/fulltext/detach.d.ts.map +1 -1
  62. package/dist/features/operations/fulltext/discover.d.ts.map +1 -1
  63. package/dist/features/operations/fulltext/fetch.d.ts.map +1 -1
  64. package/dist/features/operations/fulltext/get.d.ts.map +1 -1
  65. package/dist/features/operations/fulltext/open.d.ts.map +1 -1
  66. package/dist/features/operations/remove.d.ts.map +1 -1
  67. package/dist/features/search/matcher.d.ts.map +1 -1
  68. package/dist/index.js +3 -3
  69. package/dist/server.js +2 -2
  70. package/package.json +1 -1
  71. package/dist/chunks/file-watcher-Dlx0PolG.js.map +0 -1
  72. package/dist/chunks/index-BdLVfbj0.js.map +0 -1
  73. package/dist/chunks/index-DkJT7s7N.js.map +0 -1
  74. package/dist/chunks/index-SwsAKyQr.js.map +0 -1
  75. package/dist/chunks/metadata-comparator-C5zfoYdK.js.map +0 -1
@@ -1,5 +1,5 @@
1
- import { a } from "./index-BdLVfbj0.js";
2
- import { d, g, l, o, s } from "./index-DkJT7s7N.js";
1
+ import { a } from "./index-T-edKSzd.js";
2
+ import { d, g, l, o, s } from "./index-C9Gc8dcm.js";
3
3
  export {
4
4
  a as addAttachment,
5
5
  d as detachAttachment,
@@ -8,4 +8,4 @@ export {
8
8
  o as openAttachment,
9
9
  s as syncAttachments
10
10
  };
11
- //# sourceMappingURL=index-SwsAKyQr.js.map
11
+ //# sourceMappingURL=index-CHe855EM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-CHe855EM.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -1,5 +1,5 @@
1
1
  import { Hono } from "hono";
2
- import { h as CslItemSchema, g as detectDuplicate, m as generateId, a as sortOrderSchema, b as sortFieldSchema, p as pickDefined, t as tokenize, s as search$1, f as sortResults, y as searchSortFieldSchema, L as Library, F as FileWatcher } from "./file-watcher-Dlx0PolG.js";
2
+ import { h as CslItemSchema, g as detectDuplicate, m as generateId, a as sortOrderSchema, b as sortFieldSchema, p as pickDefined, t as tokenize, s as search$1, f as sortResults, y as searchSortFieldSchema, L as Library, F as FileWatcher } from "./file-watcher-CWHg1yol.js";
3
3
  import * as fs from "node:fs";
4
4
  import { mkdtempSync, writeFileSync, existsSync, readFileSync } from "node:fs";
5
5
  import { Cite, plugins } from "@citation-js/core";
@@ -10270,6 +10270,7 @@ async function fulltextDiscover(library, options) {
10270
10270
  if (doi) article.doi = doi;
10271
10271
  if (pmid) article.pmid = pmid;
10272
10272
  if (pmcid) article.pmcid = pmcid;
10273
+ if (item.custom?.arxiv_id) article.arxivId = item.custom.arxiv_id;
10273
10274
  const config = {
10274
10275
  unpaywallEmail: fulltextConfig.sources.unpaywallEmail ?? "",
10275
10276
  coreApiKey: fulltextConfig.sources.coreApiKey ?? "",
@@ -10305,6 +10306,7 @@ function buildDiscoveryArticle(item) {
10305
10306
  if (item.DOI) article.doi = item.DOI;
10306
10307
  if (item.PMID) article.pmid = item.PMID;
10307
10308
  if (item.PMCID) article.pmcid = item.PMCID;
10309
+ if (item.custom?.arxiv_id) article.arxivId = item.custom.arxiv_id;
10308
10310
  return article;
10309
10311
  }
10310
10312
  function buildDiscoveryConfig(fulltextConfig) {
@@ -10646,6 +10648,7 @@ function formatFirstAuthor(item) {
10646
10648
  if (!firstAuthor) {
10647
10649
  return "Unknown";
10648
10650
  }
10651
+ if (firstAuthor.literal) return firstAuthor.literal;
10649
10652
  const family = firstAuthor.family || "Unknown";
10650
10653
  const givenInitial = firstAuthor.given ? firstAuthor.given[0] : "";
10651
10654
  if (givenInitial) {
@@ -10735,6 +10738,7 @@ function getFirstAuthorFamilyName(item) {
10735
10738
  if (!firstAuthor) {
10736
10739
  return "Unknown";
10737
10740
  }
10741
+ if (firstAuthor.literal) return firstAuthor.literal;
10738
10742
  return firstAuthor.family || "Unknown";
10739
10743
  }
10740
10744
  function formatInTextEntry(item) {
@@ -11085,6 +11089,13 @@ function getIsbnFromCache(isbn) {
11085
11089
  function cacheIsbnResult(isbn, item, config) {
11086
11090
  storeInCache(isbnCache, isbn, item);
11087
11091
  }
11092
+ const arxivCache = /* @__PURE__ */ new Map();
11093
+ function getArxivFromCache(arxivId) {
11094
+ return getFromCache(arxivCache, arxivId);
11095
+ }
11096
+ function cacheArxivResult(arxivId, item, config) {
11097
+ storeInCache(arxivCache, arxivId, item);
11098
+ }
11088
11099
  const DOI_URL_PREFIXES$1 = [
11089
11100
  "https://doi.org/",
11090
11101
  "http://doi.org/",
@@ -11125,6 +11136,28 @@ function normalizeIsbn(isbn) {
11125
11136
  normalized = normalized.toUpperCase();
11126
11137
  return normalized;
11127
11138
  }
11139
+ const ARXIV_URL_PREFIXES = [
11140
+ "https://arxiv.org/abs/",
11141
+ "http://arxiv.org/abs/",
11142
+ "https://arxiv.org/pdf/",
11143
+ "http://arxiv.org/pdf/",
11144
+ "https://arxiv.org/html/",
11145
+ "http://arxiv.org/html/"
11146
+ ];
11147
+ function normalizeArxiv(arxiv) {
11148
+ const trimmed = arxiv.trim();
11149
+ if (!trimmed) {
11150
+ return "";
11151
+ }
11152
+ const lowerInput = trimmed.toLowerCase();
11153
+ for (const prefix of ARXIV_URL_PREFIXES) {
11154
+ if (lowerInput.startsWith(prefix.toLowerCase())) {
11155
+ return trimmed.slice(prefix.length);
11156
+ }
11157
+ }
11158
+ const withoutPrefix = trimmed.replace(/^arxiv:\s*/i, "");
11159
+ return withoutPrefix;
11160
+ }
11128
11161
  const EXTENSION_MAP = {
11129
11162
  ".json": "json",
11130
11163
  ".bib": "bibtex",
@@ -11185,6 +11218,9 @@ function detectSingleIdentifier(input) {
11185
11218
  if (isDoi(input)) {
11186
11219
  return "doi";
11187
11220
  }
11221
+ if (isArxiv(input)) {
11222
+ return "arxiv";
11223
+ }
11188
11224
  if (isIsbn(input)) {
11189
11225
  return "isbn";
11190
11226
  }
@@ -11247,6 +11283,17 @@ function isIsbn(input) {
11247
11283
  }
11248
11284
  return true;
11249
11285
  }
11286
+ const ARXIV_ID_PATTERN = /^\d{4}\.\d{4,5}(v\d+)?$/;
11287
+ function isArxiv(input) {
11288
+ if (!input || input.length === 0) {
11289
+ return false;
11290
+ }
11291
+ const normalized = normalizeArxiv(input);
11292
+ if (!normalized) {
11293
+ return false;
11294
+ }
11295
+ return ARXIV_ID_PATTERN.test(normalized);
11296
+ }
11250
11297
  const RATE_LIMITS = {
11251
11298
  pubmed: {
11252
11299
  withoutApiKey: 3,
@@ -11256,8 +11303,10 @@ const RATE_LIMITS = {
11256
11303
  },
11257
11304
  crossref: 50,
11258
11305
  // 50 req/sec
11259
- isbn: 10
11306
+ isbn: 10,
11260
11307
  // 10 req/sec (conservative for Google Books API daily limit)
11308
+ arxiv: 1
11309
+ // 1 req/sec (arXiv API is strict about rate limiting)
11261
11310
  };
11262
11311
  class RateLimiterImpl {
11263
11312
  requestsPerSecond;
@@ -11310,6 +11359,8 @@ function getRequestsPerSecond(api, config) {
11310
11359
  return RATE_LIMITS.crossref;
11311
11360
  case "isbn":
11312
11361
  return RATE_LIMITS.isbn;
11362
+ case "arxiv":
11363
+ return RATE_LIMITS.arxiv;
11313
11364
  }
11314
11365
  }
11315
11366
  const PMC_API_BASE = "https://pmc.ncbi.nlm.nih.gov/api/ctxp/v1/pubmed/";
@@ -11489,8 +11540,108 @@ async function fetchIsbn(isbn) {
11489
11540
  };
11490
11541
  }
11491
11542
  }
11543
+ const ARXIV_API_BASE = "https://export.arxiv.org/api/query";
11544
+ function extractXmlText(xml, tagName) {
11545
+ const regex = new RegExp(`<${tagName}[^>]*>([\\s\\S]*?)</${tagName}>`);
11546
+ const match = regex.exec(xml);
11547
+ return match?.[1]?.trim() ?? "";
11548
+ }
11549
+ function extractAuthors(entryXml) {
11550
+ const authors = [];
11551
+ const matches = entryXml.matchAll(/<author>[\s\S]*?<name>([^<]+)<\/name>[\s\S]*?<\/author>/g);
11552
+ for (const match of matches) {
11553
+ const name = match[1]?.trim();
11554
+ if (name) {
11555
+ authors.push({ literal: name });
11556
+ }
11557
+ }
11558
+ return authors;
11559
+ }
11560
+ function extractJournalDoi(entryXml) {
11561
+ const match = /<arxiv:doi[^>]*>([^<]+)<\/arxiv:doi>/.exec(entryXml);
11562
+ return match?.[1]?.trim();
11563
+ }
11564
+ function parseIssuedDate(dateStr) {
11565
+ if (!dateStr) return void 0;
11566
+ const date = new Date(dateStr);
11567
+ if (Number.isNaN(date.getTime())) return void 0;
11568
+ return {
11569
+ "date-parts": [[date.getUTCFullYear(), date.getUTCMonth() + 1, date.getUTCDate()]]
11570
+ };
11571
+ }
11572
+ async function fetchArxiv(arxivId) {
11573
+ if (!ARXIV_ID_PATTERN.test(arxivId)) {
11574
+ return {
11575
+ success: false,
11576
+ error: `Invalid arXiv ID format: ${arxivId}`,
11577
+ reason: "validation_error"
11578
+ };
11579
+ }
11580
+ const rateLimiter = getRateLimiter("arxiv", {});
11581
+ await rateLimiter.acquire();
11582
+ try {
11583
+ const url = `${ARXIV_API_BASE}?id_list=${encodeURIComponent(arxivId)}`;
11584
+ const response = await fetch(url, {
11585
+ signal: AbortSignal.timeout(DEFAULT_TIMEOUT_MS)
11586
+ });
11587
+ if (!response.ok) {
11588
+ return {
11589
+ success: false,
11590
+ error: `arXiv API returned status ${response.status}`,
11591
+ reason: "fetch_error"
11592
+ };
11593
+ }
11594
+ const xml = await response.text();
11595
+ const entryMatch = /<entry>([\s\S]*?)<\/entry>/.exec(xml);
11596
+ if (!entryMatch) {
11597
+ return {
11598
+ success: false,
11599
+ error: `No results found for arXiv ID ${arxivId}`,
11600
+ reason: "not_found"
11601
+ };
11602
+ }
11603
+ const entryXml = entryMatch[1] ?? "";
11604
+ const title = extractXmlText(entryXml, "title");
11605
+ const summary = extractXmlText(entryXml, "summary");
11606
+ const published = extractXmlText(entryXml, "published");
11607
+ const authors = extractAuthors(entryXml);
11608
+ const journalDoi = extractJournalDoi(entryXml);
11609
+ const baseId = arxivId.replace(/v\d+$/, "");
11610
+ const doi = journalDoi ?? `10.48550/arXiv.${baseId}`;
11611
+ const item = {
11612
+ id: "",
11613
+ type: "article",
11614
+ title,
11615
+ author: authors,
11616
+ abstract: summary || void 0,
11617
+ issued: parseIssuedDate(published),
11618
+ DOI: doi,
11619
+ URL: `https://arxiv.org/abs/${arxivId}`,
11620
+ custom: {
11621
+ arxiv_id: arxivId
11622
+ }
11623
+ };
11624
+ const parseResult = CslItemSchema.safeParse(item);
11625
+ if (!parseResult.success) {
11626
+ return {
11627
+ success: false,
11628
+ error: `Invalid CSL-JSON data for arXiv ${arxivId}: ${parseResult.error.message}`,
11629
+ reason: "validation_error"
11630
+ };
11631
+ }
11632
+ return { success: true, item: parseResult.data };
11633
+ } catch (error) {
11634
+ const errorMsg = error instanceof Error ? error.message : String(error);
11635
+ return {
11636
+ success: false,
11637
+ error: errorMsg,
11638
+ reason: "fetch_error"
11639
+ };
11640
+ }
11641
+ }
11492
11642
  const fetcher = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
11493
11643
  __proto__: null,
11644
+ fetchArxiv,
11494
11645
  fetchDoi,
11495
11646
  fetchIsbn,
11496
11647
  fetchPmids
@@ -11685,19 +11836,22 @@ function classifyIdentifiers(identifiers) {
11685
11836
  const pmids = [];
11686
11837
  const dois = [];
11687
11838
  const isbns = [];
11839
+ const arxivs = [];
11688
11840
  const unknowns = [];
11689
11841
  for (const id of identifiers) {
11690
- if (isPmid(id)) {
11691
- pmids.push(normalizePmid(id));
11692
- } else if (isDoi(id)) {
11842
+ if (isDoi(id)) {
11693
11843
  dois.push(normalizeDoi(id));
11844
+ } else if (isArxiv(id)) {
11845
+ arxivs.push(normalizeArxiv(id));
11694
11846
  } else if (isIsbn(id)) {
11695
11847
  isbns.push(normalizeIsbn(id));
11848
+ } else if (isPmid(id)) {
11849
+ pmids.push(normalizePmid(id));
11696
11850
  } else {
11697
11851
  unknowns.push(id);
11698
11852
  }
11699
11853
  }
11700
- return { pmids, dois, isbns, unknowns };
11854
+ return { pmids, dois, isbns, arxivs, unknowns };
11701
11855
  }
11702
11856
  function buildUnknownResults(unknowns) {
11703
11857
  return unknowns.map((unknown) => ({
@@ -11790,6 +11944,29 @@ async function fetchIsbnsWithCache(isbns) {
11790
11944
  }
11791
11945
  return results;
11792
11946
  }
11947
+ async function fetchArxivsWithCache(arxivIds) {
11948
+ const results = [];
11949
+ for (const arxivId of arxivIds) {
11950
+ const cached = getArxivFromCache(arxivId);
11951
+ if (cached) {
11952
+ results.push({ success: true, item: clearItemId(cached), source: arxivId });
11953
+ continue;
11954
+ }
11955
+ const fetchResult = await fetchArxiv(arxivId);
11956
+ if (fetchResult.success) {
11957
+ cacheArxivResult(arxivId, fetchResult.item);
11958
+ results.push({ success: true, item: clearItemId(fetchResult.item), source: arxivId });
11959
+ } else {
11960
+ results.push({
11961
+ success: false,
11962
+ error: fetchResult.error,
11963
+ source: arxivId,
11964
+ reason: fetchResult.reason
11965
+ });
11966
+ }
11967
+ }
11968
+ return results;
11969
+ }
11793
11970
  function parseJsonContent(content) {
11794
11971
  try {
11795
11972
  const parsed = JSON.parse(content);
@@ -11946,7 +12123,7 @@ async function importFromIdentifiers(identifiers, options) {
11946
12123
  if (identifiers.length === 0) {
11947
12124
  return { results: [] };
11948
12125
  }
11949
- const { pmids, dois, isbns, unknowns } = classifyIdentifiers(identifiers);
12126
+ const { pmids, dois, isbns, arxivs, unknowns } = classifyIdentifiers(identifiers);
11950
12127
  const results = [];
11951
12128
  results.push(...buildUnknownResults(unknowns));
11952
12129
  const pmidResults = await fetchPmidsWithCache(pmids, options.pubmedConfig ?? {});
@@ -11955,6 +12132,8 @@ async function importFromIdentifiers(identifiers, options) {
11955
12132
  results.push(...doiResults);
11956
12133
  const isbnResults = await fetchIsbnsWithCache(isbns);
11957
12134
  results.push(...isbnResults);
12135
+ const arxivResults = await fetchArxivsWithCache(arxivs);
12136
+ results.push(...arxivResults);
11958
12137
  return { results };
11959
12138
  }
11960
12139
  function looksLikeFilePath(input) {
@@ -11996,13 +12175,14 @@ async function processIdentifiers(inputs, options) {
11996
12175
  const isValidPmid = isPmid(input);
11997
12176
  const isValidDoi = isDoi(input);
11998
12177
  const isValidIsbn = isIsbn(input);
11999
- if (isValidPmid || isValidDoi || isValidIsbn) {
12178
+ const isValidArxiv = isArxiv(input);
12179
+ if (isValidPmid || isValidDoi || isValidIsbn || isValidArxiv) {
12000
12180
  validIdentifiers.push(input);
12001
12181
  } else {
12002
12182
  const hint = looksLikeFilePath(input) ? " Hint: If this is a file path, check that the file exists." : "";
12003
12183
  results.push({
12004
12184
  success: false,
12005
- error: `Cannot interpret '${input}' as identifier (not a valid PMID, DOI, or ISBN).${hint}`,
12185
+ error: `Cannot interpret '${input}' as identifier (not a valid PMID, DOI, ISBN, or arXiv ID).${hint}`,
12006
12186
  source: input,
12007
12187
  reason: "validation_error"
12008
12188
  });
@@ -12046,7 +12226,7 @@ async function processStdinContent(content, options) {
12046
12226
  source: r.source === "content" ? "stdin" : r.source
12047
12227
  }));
12048
12228
  }
12049
- if (format === "pmid" || format === "doi" || format === "isbn") {
12229
+ if (format === "pmid" || format === "doi" || format === "isbn" || format === "arxiv") {
12050
12230
  const identifiers2 = content.split(/\s+/).filter((s) => s.length > 0);
12051
12231
  return processIdentifiers(identifiers2, options);
12052
12232
  }
@@ -12219,7 +12399,7 @@ function createAddRoute(library, config) {
12219
12399
  }
12220
12400
  const CHECK_CONCURRENCY = 5;
12221
12401
  async function checkReferences(library, options) {
12222
- const { checkReference } = await import("./checker-gLAPe44T.js");
12402
+ const { checkReference } = await import("./checker-CP8vSC-S.js");
12223
12403
  const save = options.save !== false;
12224
12404
  const skipDays = options.skipDays ?? 7;
12225
12405
  const items = await resolveItems(library, options);
@@ -12249,7 +12429,7 @@ function fillSkippedResults(tasks, results) {
12249
12429
  uuid: task.item.custom?.uuid ?? "",
12250
12430
  status: "skipped",
12251
12431
  findings: [],
12252
- checkedAt: task.item.custom?.check?.checked_at,
12432
+ checkedAt: task.item.custom?.check?.checked_at ?? "",
12253
12433
  checkedSources: []
12254
12434
  };
12255
12435
  }
@@ -12311,11 +12491,11 @@ async function resolveItems(library, options) {
12311
12491
  }
12312
12492
  function shouldSkipRecentCheck(item, skipDays) {
12313
12493
  if (skipDays <= 0) return false;
12314
- const check2 = item.custom?.check;
12315
- if (!check2?.checked_at) return false;
12316
- const checkedAt = new Date(check2.checked_at);
12494
+ const checkedAt = item.custom?.check?.checked_at;
12495
+ if (!checkedAt) return false;
12496
+ const checkedAtDate = new Date(checkedAt);
12317
12497
  const now = /* @__PURE__ */ new Date();
12318
- const daysSince = (now.getTime() - checkedAt.getTime()) / (1e3 * 60 * 60 * 24);
12498
+ const daysSince = (now.getTime() - checkedAtDate.getTime()) / (1e3 * 60 * 60 * 24);
12319
12499
  return daysSince < skipDays;
12320
12500
  }
12321
12501
  async function saveCheckResult(library, item, result) {
@@ -12328,9 +12508,8 @@ async function saveCheckResult(library, item, result) {
12328
12508
  ...f.details ? { details: snakeCaseKeys(f.details) } : {}
12329
12509
  }))
12330
12510
  };
12331
- const existingCustom = item.custom ?? {};
12332
12511
  await library.update(item.id, {
12333
- custom: { ...existingCustom, check: checkData }
12512
+ custom: { ...item.custom, check: checkData }
12334
12513
  });
12335
12514
  }
12336
12515
  function snakeCaseKeys(obj) {
@@ -12899,4 +13078,4 @@ export {
12899
13078
  fetcher as y,
12900
13079
  add as z
12901
13080
  };
12902
- //# sourceMappingURL=index-BdLVfbj0.js.map
13081
+ //# sourceMappingURL=index-T-edKSzd.js.map