@vitemcp/server 1.10.1 → 1.10.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.
Files changed (35) hide show
  1. package/dist/{OAuthProvider-STkC4R2N.d.cts → OAuthProvider-DN--f3j1.d.cts} +35 -4
  2. package/dist/{OAuthProvider-STkC4R2N.d.ts → OAuthProvider-DN--f3j1.d.ts} +35 -4
  3. package/dist/ViteMCP.cjs +4 -4
  4. package/dist/ViteMCP.d.cts +2 -2
  5. package/dist/ViteMCP.d.ts +2 -2
  6. package/dist/ViteMCP.js +3 -3
  7. package/dist/auth/index.cjs +2 -2
  8. package/dist/auth/index.d.cts +2 -2
  9. package/dist/auth/index.d.ts +2 -2
  10. package/dist/auth/index.js +1 -1
  11. package/dist/{chunk-3W6VP3KX.js → chunk-EJVIGLUY.js} +3 -3
  12. package/dist/{chunk-4LU4AXU4.cjs → chunk-IWNTAHGZ.cjs} +70 -17
  13. package/dist/chunk-IWNTAHGZ.cjs.map +1 -0
  14. package/dist/{chunk-NLBRDP5F.js → chunk-KRS3VHYI.js} +62 -9
  15. package/dist/chunk-KRS3VHYI.js.map +1 -0
  16. package/dist/{chunk-FSPSPB7Y.cjs → chunk-PH2BAR5I.cjs} +9 -9
  17. package/dist/{chunk-FSPSPB7Y.cjs.map → chunk-PH2BAR5I.cjs.map} +1 -1
  18. package/dist/{chunk-NZGRSB2D.cjs → chunk-R4RK2DR2.cjs} +147 -3
  19. package/dist/chunk-R4RK2DR2.cjs.map +1 -0
  20. package/dist/{chunk-BLXUZUZ4.js → chunk-YDEROYNS.js} +147 -3
  21. package/dist/chunk-YDEROYNS.js.map +1 -0
  22. package/dist/edge/index.cjs +6 -6
  23. package/dist/edge/index.js +1 -1
  24. package/dist/openapi/index.cjs +27 -19
  25. package/dist/openapi/index.cjs.map +1 -1
  26. package/dist/openapi/index.d.cts +3 -3
  27. package/dist/openapi/index.d.ts +3 -3
  28. package/dist/openapi/index.js +17 -9
  29. package/dist/openapi/index.js.map +1 -1
  30. package/package.json +1 -1
  31. package/dist/chunk-4LU4AXU4.cjs.map +0 -1
  32. package/dist/chunk-BLXUZUZ4.js.map +0 -1
  33. package/dist/chunk-NLBRDP5F.js.map +0 -1
  34. package/dist/chunk-NZGRSB2D.cjs.map +0 -1
  35. /package/dist/{chunk-3W6VP3KX.js.map → chunk-EJVIGLUY.js.map} +0 -0
@@ -4,7 +4,7 @@ import '@standard-schema/spec';
4
4
  import 'hono';
5
5
  import 'hono/cors';
6
6
  import 'timers/promises';
7
- import '../OAuthProvider-STkC4R2N.cjs';
7
+ import '../OAuthProvider-DN--f3j1.cjs';
8
8
 
9
9
  /**
10
10
  * A value that may depend on the calling request — a bearer token derived from
@@ -19,8 +19,8 @@ type ContextualHeaders<T extends ViteMCPAuth> = ((context: Context<T>) => Promis
19
19
  type FromOpenAPIOptions<T extends ViteMCPAuth = ViteMCPAuth> = {
20
20
  /**
21
21
  * Overrides the base URL resolved from the document's `servers`. Required
22
- * when the document has no `servers` entry, or has a relative one and was
23
- * not loaded from an http(s) URL.
22
+ * when the document was not loaded from an http(s) URL and has no `servers`
23
+ * entry, or a relative one.
24
24
  */
25
25
  baseUrl?: string;
26
26
  /** Drops operations for which this returns `true`. Applied after `include`. */
@@ -4,7 +4,7 @@ import '@standard-schema/spec';
4
4
  import 'hono';
5
5
  import 'hono/cors';
6
6
  import 'timers/promises';
7
- import '../OAuthProvider-STkC4R2N.js';
7
+ import '../OAuthProvider-DN--f3j1.js';
8
8
 
9
9
  /**
10
10
  * A value that may depend on the calling request — a bearer token derived from
@@ -19,8 +19,8 @@ type ContextualHeaders<T extends ViteMCPAuth> = ((context: Context<T>) => Promis
19
19
  type FromOpenAPIOptions<T extends ViteMCPAuth = ViteMCPAuth> = {
20
20
  /**
21
21
  * Overrides the base URL resolved from the document's `servers`. Required
22
- * when the document has no `servers` entry, or has a relative one and was
23
- * not loaded from an http(s) URL.
22
+ * when the document was not loaded from an http(s) URL and has no `servers`
23
+ * entry, or a relative one.
24
24
  */
25
25
  baseUrl?: string;
26
26
  /** Drops operations for which this returns `true`. Applied after `include`. */
@@ -3,9 +3,9 @@ import {
3
3
  ViteMCP,
4
4
  cancelResponseBody,
5
5
  jsonSchemaAdapter
6
- } from "../chunk-3W6VP3KX.js";
7
- import "../chunk-NLBRDP5F.js";
8
- import "../chunk-BLXUZUZ4.js";
6
+ } from "../chunk-EJVIGLUY.js";
7
+ import "../chunk-KRS3VHYI.js";
8
+ import "../chunk-YDEROYNS.js";
9
9
 
10
10
  // src/openapi/parameters.ts
11
11
  var appendQueryParameter = (query, parameter, given) => {
@@ -216,8 +216,11 @@ var resolveBaseUrl = (servers, origin, override) => {
216
216
  }
217
217
  const server = servers?.[0];
218
218
  if (!server?.url) {
219
+ if (origin) {
220
+ return trimSlash(new URL("/", origin).toString());
221
+ }
219
222
  throw new Error(
220
- "The OpenAPI document declares no `servers`, so there is no address to call. Pass `baseUrl` to fromOpenAPI()."
223
+ "The OpenAPI document declares no `servers`, and was not loaded from an http(s) URL, so there is no address to call. Pass `baseUrl` to fromOpenAPI()."
221
224
  );
222
225
  }
223
226
  let url = server.url;
@@ -236,14 +239,15 @@ var resolveBaseUrl = (servers, origin, override) => {
236
239
  }
237
240
  };
238
241
  var appendFormValue = (form, name, value) => {
239
- if (value === void 0) {
242
+ if (value === void 0 || value === null) {
240
243
  return;
241
244
  }
242
245
  if (Array.isArray(value)) {
243
- const nested = value.some(
246
+ const entries = value.filter((entry) => entry !== null);
247
+ const nested = entries.some(
244
248
  (entry) => typeof entry === "object" && entry !== null
245
249
  );
246
- for (const [index, entry] of value.entries()) {
250
+ for (const [index, entry] of entries.entries()) {
247
251
  appendFormValue(form, nested ? `${name}[${index}]` : name, entry);
248
252
  }
249
253
  return;
@@ -520,7 +524,11 @@ var extractRoutes = (document) => {
520
524
  path,
521
525
  requestBody: operation.requestBody ? resolve2(document, operation.requestBody) : void 0,
522
526
  responses,
523
- servers: operation.servers ?? pathItem.servers,
527
+ // An empty override is no override: taken as one, `servers: []` on an
528
+ // operation hid the servers its path item or document names.
529
+ servers: [operation.servers, pathItem.servers].find(
530
+ (candidate) => candidate !== void 0 && candidate.length > 0
531
+ ),
524
532
  summary: operation.summary,
525
533
  tags: operation.tags ?? []
526
534
  });
@@ -950,7 +958,7 @@ var describeBody = (route, normalizer) => {
950
958
  };
951
959
  var MAX_OUTPUT_SCHEMA_DEFINITIONS = 100;
952
960
  var buildOutputSchema = (route, normalizer) => {
953
- const statuses = Object.keys(route.responses).filter((code) => /^2\d\d$/.test(code)).sort();
961
+ const statuses = Object.keys(route.responses).filter((code) => /^2(?:\d\d|XX)$/.test(code)).sort();
954
962
  const alternatives = /* @__PURE__ */ new Map();
955
963
  for (const status of statuses) {
956
964
  const content = route.responses[status]?.content;