@fre4x/yahoo-finance 1.0.64 → 1.0.65-beta.1

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 (2) hide show
  1. package/dist/index.js +30 -19
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -38358,9 +38358,11 @@ import * as crypto from "node:crypto";
38358
38358
  var PersistentCache = class {
38359
38359
  cacheDir;
38360
38360
  memoryCache = /* @__PURE__ */ new Map();
38361
- constructor(namespace) {
38362
- const baseDir = process.env.FRE4X_CACHE_DIR || path.join(os.homedir(), ".fre4x-cache");
38361
+ onDiskWriteError;
38362
+ constructor(namespace, options3 = {}) {
38363
+ const baseDir = options3.dir ?? process.env.FRE4X_CACHE_DIR ?? path.join(os.homedir(), ".fre4x-cache");
38363
38364
  this.cacheDir = path.join(baseDir, namespace);
38365
+ this.onDiskWriteError = options3.onDiskWriteError;
38364
38366
  }
38365
38367
  async ensureDir() {
38366
38368
  await fs.mkdir(this.cacheDir, { recursive: true });
@@ -38404,7 +38406,7 @@ var PersistentCache = class {
38404
38406
  const fpath = this.getFilePath(key);
38405
38407
  await fs.writeFile(fpath, JSON.stringify(entry), "utf8");
38406
38408
  } catch (error48) {
38407
- console.error(`[Cache] Failed to save to disk: ${error48}`);
38409
+ this.onDiskWriteError?.(error48);
38408
38410
  }
38409
38411
  }
38410
38412
  async wrap(key, ttlMs, fetchFn) {
@@ -38437,21 +38439,26 @@ function ensureNewestFirst(items, dateKey) {
38437
38439
  if (items.length < 2)
38438
38440
  return items;
38439
38441
  const keys = Array.isArray(dateKey) ? dateKey : [dateKey];
38440
- return [...items].sort((a, b) => {
38441
- const getVal = (obj) => {
38442
- for (const key of keys) {
38443
- const v = obj[key];
38444
- if (v !== void 0 && v !== null)
38445
- return v;
38442
+ return items.map((obj) => {
38443
+ let val;
38444
+ for (const key of keys) {
38445
+ const v = obj[key];
38446
+ if (v !== void 0 && v !== null) {
38447
+ val = v;
38448
+ break;
38446
38449
  }
38447
- return void 0;
38448
- };
38449
- const ad = getVal(a);
38450
- const bd = getVal(b);
38451
- const at = ad instanceof Date ? ad.getTime() : typeof ad === "number" ? ad : ad ? new Date(String(ad)).getTime() : 0;
38452
- const bt = bd instanceof Date ? bd.getTime() : typeof bd === "number" ? bd : bd ? new Date(String(bd)).getTime() : 0;
38453
- return (Number.isNaN(bt) ? 0 : bt) - (Number.isNaN(at) ? 0 : at);
38454
- });
38450
+ }
38451
+ let t = 0;
38452
+ if (val instanceof Date) {
38453
+ t = val.getTime();
38454
+ } else if (typeof val === "number") {
38455
+ t = val;
38456
+ } else if (val) {
38457
+ t = new Date(String(val)).getTime();
38458
+ }
38459
+ t = Number.isNaN(t) ? 0 : t;
38460
+ return { obj, t };
38461
+ }).sort((a, b) => b.t - a.t).map((item) => item.obj);
38455
38462
  }
38456
38463
 
38457
38464
  // ../node_modules/yahoo-finance2/esm/_dnt.shims.js
@@ -69195,7 +69202,9 @@ server.registerTool(
69195
69202
  description: "Get calls or puts option chain for a ticker and expiration date.",
69196
69203
  inputSchema: external_exports3.object({
69197
69204
  ticker: external_exports3.string().describe("Ticker symbol e.g. 'AAPL'"),
69198
- expiration_date: external_exports3.string().describe("Expiration date YYYY-MM-DD"),
69205
+ expiration_date: external_exports3.string().describe(
69206
+ "Expiration date in YYYY-MM-DD format, e.g. 2026-06-19"
69207
+ ),
69199
69208
  option_type: external_exports3.enum(["calls", "puts"]).describe("Option type"),
69200
69209
  ...paginationSchema.shape
69201
69210
  }).strict(),
@@ -69244,7 +69253,9 @@ server.registerTool(
69244
69253
  inputSchema: external_exports3.object({
69245
69254
  ticker: external_exports3.string().describe("Ticker symbol e.g. 'AAPL'"),
69246
69255
  recommendation_type: external_exports3.enum(["recommendations", "upgrades_downgrades"]).default("recommendations").describe("Type of recommendation data"),
69247
- months_back: external_exports3.number().int().min(1).max(120).default(12).describe("Months back for upgrades/downgrades"),
69256
+ months_back: external_exports3.number().int().min(1).max(120).default(12).describe(
69257
+ "How many trailing months of upgrade/downgrade history to include"
69258
+ ),
69248
69259
  ...paginationSchema.shape
69249
69260
  }).strict(),
69250
69261
  annotations: { readOnlyHint: true, openWorldHint: true }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fre4x/yahoo-finance",
3
- "version": "1.0.64",
3
+ "version": "1.0.65-beta.1",
4
4
  "description": "A Yahoo Finance MCP server for LLMs.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -17,7 +17,7 @@
17
17
  "dev": "tsx src/index.ts",
18
18
  "watch": "tsc -w",
19
19
  "inspector": "npm run build && node ../scripts/run-official-inspector.mjs node dist/index.js",
20
- "test": "vitest run --passWithNoTests --exclude dist"
20
+ "test": "node ../scripts/run-vitest.mjs run --passWithNoTests --exclude dist"
21
21
  },
22
22
  "keywords": [
23
23
  "mcp",