fastmcp 4.16.11 → 4.16.13

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/FastMCP.cjs CHANGED
@@ -11,7 +11,7 @@
11
11
 
12
12
 
13
13
 
14
- var _chunkOL3Y5BJXcjs = require('./chunk-OL3Y5BJX.cjs');
14
+ var _chunkQHGRXJLWcjs = require('./chunk-QHGRXJLW.cjs');
15
15
 
16
16
 
17
17
 
@@ -49,5 +49,5 @@ var _chunkQKDEME2Fcjs = require('./chunk-QKDEME2F.cjs');
49
49
 
50
50
 
51
51
 
52
- exports.AuthProvider = _chunkQKDEME2Fcjs.AuthProvider; exports.AzureProvider = _chunkQKDEME2Fcjs.AzureProvider; exports.DiscoveryDocumentCache = _chunkOL3Y5BJXcjs.DiscoveryDocumentCache; exports.FastMCP = _chunkOL3Y5BJXcjs.FastMCP; exports.FastMCPError = _chunkOL3Y5BJXcjs.FastMCPError; exports.FastMCPSession = _chunkOL3Y5BJXcjs.FastMCPSession; exports.GitHubProvider = _chunkQKDEME2Fcjs.GitHubProvider; exports.GoogleProvider = _chunkQKDEME2Fcjs.GoogleProvider; exports.MEDIA_FETCH_TIMEOUT_MS = _chunkOL3Y5BJXcjs.MEDIA_FETCH_TIMEOUT_MS; exports.OAuthProvider = _chunkQKDEME2Fcjs.OAuthProvider; exports.ServerState = _chunkOL3Y5BJXcjs.ServerState; exports.SessionError = _chunkOL3Y5BJXcjs.SessionError; exports.UnexpectedStateError = _chunkOL3Y5BJXcjs.UnexpectedStateError; exports.UserError = _chunkOL3Y5BJXcjs.UserError; exports.audioContent = _chunkOL3Y5BJXcjs.audioContent; exports.getAuthSession = _chunkQKDEME2Fcjs.getAuthSession; exports.imageContent = _chunkOL3Y5BJXcjs.imageContent; exports.jsonSchemaAdapter = _chunkOL3Y5BJXcjs.jsonSchemaAdapter; exports.requireAll = _chunkQKDEME2Fcjs.requireAll; exports.requireAny = _chunkQKDEME2Fcjs.requireAny; exports.requireAuth = _chunkQKDEME2Fcjs.requireAuth; exports.requireRole = _chunkQKDEME2Fcjs.requireRole; exports.requireScopes = _chunkQKDEME2Fcjs.requireScopes;
52
+ exports.AuthProvider = _chunkQKDEME2Fcjs.AuthProvider; exports.AzureProvider = _chunkQKDEME2Fcjs.AzureProvider; exports.DiscoveryDocumentCache = _chunkQHGRXJLWcjs.DiscoveryDocumentCache; exports.FastMCP = _chunkQHGRXJLWcjs.FastMCP; exports.FastMCPError = _chunkQHGRXJLWcjs.FastMCPError; exports.FastMCPSession = _chunkQHGRXJLWcjs.FastMCPSession; exports.GitHubProvider = _chunkQKDEME2Fcjs.GitHubProvider; exports.GoogleProvider = _chunkQKDEME2Fcjs.GoogleProvider; exports.MEDIA_FETCH_TIMEOUT_MS = _chunkQHGRXJLWcjs.MEDIA_FETCH_TIMEOUT_MS; exports.OAuthProvider = _chunkQKDEME2Fcjs.OAuthProvider; exports.ServerState = _chunkQHGRXJLWcjs.ServerState; exports.SessionError = _chunkQHGRXJLWcjs.SessionError; exports.UnexpectedStateError = _chunkQHGRXJLWcjs.UnexpectedStateError; exports.UserError = _chunkQHGRXJLWcjs.UserError; exports.audioContent = _chunkQHGRXJLWcjs.audioContent; exports.getAuthSession = _chunkQKDEME2Fcjs.getAuthSession; exports.imageContent = _chunkQHGRXJLWcjs.imageContent; exports.jsonSchemaAdapter = _chunkQHGRXJLWcjs.jsonSchemaAdapter; exports.requireAll = _chunkQKDEME2Fcjs.requireAll; exports.requireAny = _chunkQKDEME2Fcjs.requireAny; exports.requireAuth = _chunkQKDEME2Fcjs.requireAuth; exports.requireRole = _chunkQKDEME2Fcjs.requireRole; exports.requireScopes = _chunkQKDEME2Fcjs.requireScopes;
53
53
  //# sourceMappingURL=FastMCP.cjs.map
package/dist/FastMCP.js CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  audioContent,
12
12
  imageContent,
13
13
  jsonSchemaAdapter
14
- } from "./chunk-ZAPIC4RI.js";
14
+ } from "./chunk-CFPNOSVW.js";
15
15
  import {
16
16
  AuthProvider,
17
17
  AzureProvider,
@@ -44,9 +44,11 @@ var DiscoveryDocumentCache = class {
44
44
  return this.#cache.size;
45
45
  }
46
46
  #cache = /* @__PURE__ */ new Map();
47
+ #generation = 0;
47
48
  #inFlight = /* @__PURE__ */ new Map();
48
49
  #timeoutMs;
49
50
  #ttl;
51
+ #urlGenerations = /* @__PURE__ */ new Map();
50
52
  /**
51
53
  * @param options - configuration options
52
54
  * @param options.timeoutMs - timeout in miliseconds for the upstream fetch
@@ -62,8 +64,13 @@ var DiscoveryDocumentCache = class {
62
64
  clear(url) {
63
65
  if (url) {
64
66
  this.#cache.delete(url);
67
+ this.#inFlight.delete(url);
68
+ this.#urlGenerations.set(url, (this.#urlGenerations.get(url) ?? 0) + 1);
65
69
  } else {
66
70
  this.#cache.clear();
71
+ this.#inFlight.clear();
72
+ this.#urlGenerations.clear();
73
+ this.#generation++;
67
74
  }
68
75
  }
69
76
  /**
@@ -85,13 +92,19 @@ var DiscoveryDocumentCache = class {
85
92
  if (inFlight) {
86
93
  return inFlight;
87
94
  }
88
- const fetchPromise = this.#fetchAndCache(url);
95
+ const fetchPromise = this.#fetchAndCache(
96
+ url,
97
+ this.#generation,
98
+ this.#urlGenerations.get(url) ?? 0
99
+ );
89
100
  this.#inFlight.set(url, fetchPromise);
90
101
  try {
91
102
  const data = await fetchPromise;
92
103
  return data;
93
104
  } finally {
94
- this.#inFlight.delete(url);
105
+ if (this.#inFlight.get(url) === fetchPromise) {
106
+ this.#inFlight.delete(url);
107
+ }
95
108
  }
96
109
  }
97
110
  /**
@@ -110,7 +123,7 @@ var DiscoveryDocumentCache = class {
110
123
  }
111
124
  return true;
112
125
  }
113
- async #fetchAndCache(url) {
126
+ async #fetchAndCache(url, generation, urlGeneration) {
114
127
  let res;
115
128
  try {
116
129
  res = await fetch(url, {
@@ -132,10 +145,12 @@ var DiscoveryDocumentCache = class {
132
145
  }
133
146
  const data = await res.json();
134
147
  const expiresAt = Date.now() + this.#ttl;
135
- this.#cache.set(url, {
136
- data,
137
- expiresAt
138
- });
148
+ if (this.#generation === generation && (this.#urlGenerations.get(url) ?? 0) === urlGeneration) {
149
+ this.#cache.set(url, {
150
+ data,
151
+ expiresAt
152
+ });
153
+ }
139
154
  return data;
140
155
  }
141
156
  };
@@ -192,7 +207,7 @@ async function compileSchema(schema) {
192
207
  function toIssue(error) {
193
208
  const path = error.instancePath.split("/").filter(Boolean).map((segment) => segment.replaceAll("~1", "/").replaceAll("~0", "~")).map((segment) => {
194
209
  const index = Number(segment);
195
- return Number.isInteger(index) && segment !== "" ? index : segment;
210
+ return /^(?:0|[1-9]\d*)$/.test(segment) && Number.isSafeInteger(index) ? index : segment;
196
211
  });
197
212
  const missingProperty = error.params?.missingProperty;
198
213
  if (error.keyword === "required" && typeof missingProperty === "string") {
@@ -2845,4 +2860,4 @@ export {
2845
2860
  FastMCPSession,
2846
2861
  FastMCP
2847
2862
  };
2848
- //# sourceMappingURL=chunk-ZAPIC4RI.js.map
2863
+ //# sourceMappingURL=chunk-CFPNOSVW.js.map