vanta-auditor-api-sdk 0.2.0 → 0.3.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 (153) hide show
  1. package/FUNCTIONS.md +5 -22
  2. package/README.md +36 -51
  3. package/bin/mcp-server.js +1159 -1023
  4. package/bin/mcp-server.js.map +39 -29
  5. package/docs/sdks/auditors/README.md +7 -11
  6. package/docs/sdks/audits/README.md +67 -101
  7. package/examples/README.md +31 -0
  8. package/examples/auditsList.example.ts +26 -0
  9. package/examples/package-lock.json +626 -0
  10. package/examples/package.json +18 -0
  11. package/funcs/auditorsCreate.d.ts +3 -2
  12. package/funcs/auditorsCreate.d.ts.map +1 -1
  13. package/funcs/auditorsCreate.js +3 -1
  14. package/funcs/auditorsCreate.js.map +1 -1
  15. package/funcs/auditsCreateCommentForEvidence.d.ts +3 -2
  16. package/funcs/auditsCreateCommentForEvidence.d.ts.map +1 -1
  17. package/funcs/auditsCreateCommentForEvidence.js +3 -1
  18. package/funcs/auditsCreateCommentForEvidence.js.map +1 -1
  19. package/funcs/auditsCreateCustomControl.d.ts +3 -2
  20. package/funcs/auditsCreateCustomControl.d.ts.map +1 -1
  21. package/funcs/auditsCreateCustomControl.js +3 -1
  22. package/funcs/auditsCreateCustomControl.js.map +1 -1
  23. package/funcs/auditsCreateCustomEvidenceRequest.d.ts +3 -2
  24. package/funcs/auditsCreateCustomEvidenceRequest.d.ts.map +1 -1
  25. package/funcs/auditsCreateCustomEvidenceRequest.js +3 -1
  26. package/funcs/auditsCreateCustomEvidenceRequest.js.map +1 -1
  27. package/funcs/auditsGetEvidenceUrls.d.ts +3 -2
  28. package/funcs/auditsGetEvidenceUrls.d.ts.map +1 -1
  29. package/funcs/auditsGetEvidenceUrls.js +3 -1
  30. package/funcs/auditsGetEvidenceUrls.js.map +1 -1
  31. package/funcs/auditsList.d.ts +3 -2
  32. package/funcs/auditsList.d.ts.map +1 -1
  33. package/funcs/auditsList.js +4 -1
  34. package/funcs/auditsList.js.map +1 -1
  35. package/funcs/auditsListComments.d.ts +3 -2
  36. package/funcs/auditsListComments.d.ts.map +1 -1
  37. package/funcs/auditsListComments.js +3 -1
  38. package/funcs/auditsListComments.js.map +1 -1
  39. package/funcs/auditsListControls.d.ts +3 -2
  40. package/funcs/auditsListControls.d.ts.map +1 -1
  41. package/funcs/auditsListControls.js +3 -1
  42. package/funcs/auditsListControls.js.map +1 -1
  43. package/funcs/auditsListEvidence.d.ts +3 -2
  44. package/funcs/auditsListEvidence.d.ts.map +1 -1
  45. package/funcs/auditsListEvidence.js +3 -1
  46. package/funcs/auditsListEvidence.js.map +1 -1
  47. package/funcs/auditsUpdateEvidence.d.ts +3 -2
  48. package/funcs/auditsUpdateEvidence.d.ts.map +1 -1
  49. package/funcs/auditsUpdateEvidence.js +3 -1
  50. package/funcs/auditsUpdateEvidence.js.map +1 -1
  51. package/hooks/types.d.ts +2 -0
  52. package/hooks/types.d.ts.map +1 -1
  53. package/index.d.ts +2 -0
  54. package/index.d.ts.map +1 -1
  55. package/index.js +3 -1
  56. package/index.js.map +1 -1
  57. package/jsr.json +1 -1
  58. package/lib/config.d.ts +7 -3
  59. package/lib/config.d.ts.map +1 -1
  60. package/lib/config.js +3 -3
  61. package/lib/config.js.map +1 -1
  62. package/lib/files.d.ts +5 -0
  63. package/lib/files.d.ts.map +1 -1
  64. package/lib/files.js +41 -0
  65. package/lib/files.js.map +1 -1
  66. package/lib/matchers.d.ts +3 -10
  67. package/lib/matchers.d.ts.map +1 -1
  68. package/lib/matchers.js +33 -31
  69. package/lib/matchers.js.map +1 -1
  70. package/lib/sdks.d.ts +4 -1
  71. package/lib/sdks.d.ts.map +1 -1
  72. package/lib/sdks.js +9 -14
  73. package/lib/sdks.js.map +1 -1
  74. package/lib/security.d.ts +2 -2
  75. package/lib/security.d.ts.map +1 -1
  76. package/mcp-server/cli/start/command.d.ts.map +1 -1
  77. package/mcp-server/cli/start/command.js +0 -12
  78. package/mcp-server/cli/start/command.js.map +1 -1
  79. package/mcp-server/cli/start/impl.d.ts +0 -2
  80. package/mcp-server/cli/start/impl.d.ts.map +1 -1
  81. package/mcp-server/cli/start/impl.js +2 -4
  82. package/mcp-server/cli/start/impl.js.map +1 -1
  83. package/mcp-server/mcp-server.js +1 -1
  84. package/mcp-server/server.js +1 -1
  85. package/models/components/audit.d.ts +5 -2
  86. package/models/components/audit.d.ts.map +1 -1
  87. package/models/components/audit.js +5 -2
  88. package/models/components/audit.js.map +1 -1
  89. package/models/components/auditfocus.d.ts +28 -0
  90. package/models/components/auditfocus.d.ts.map +1 -0
  91. package/models/components/auditfocus.js +61 -0
  92. package/models/components/auditfocus.js.map +1 -0
  93. package/models/components/index.d.ts +1 -0
  94. package/models/components/index.d.ts.map +1 -1
  95. package/models/components/index.js +1 -0
  96. package/models/components/index.js.map +1 -1
  97. package/models/errors/apierror.d.ts +8 -6
  98. package/models/errors/apierror.d.ts.map +1 -1
  99. package/models/errors/apierror.js +23 -10
  100. package/models/errors/apierror.js.map +1 -1
  101. package/models/errors/index.d.ts +1 -0
  102. package/models/errors/index.d.ts.map +1 -1
  103. package/models/errors/index.js +1 -0
  104. package/models/errors/index.js.map +1 -1
  105. package/models/errors/responsevalidationerror.d.ts +26 -0
  106. package/models/errors/responsevalidationerror.d.ts.map +1 -0
  107. package/models/errors/responsevalidationerror.js +66 -0
  108. package/models/errors/responsevalidationerror.js.map +1 -0
  109. package/models/errors/sdkvalidationerror.d.ts +1 -0
  110. package/models/errors/sdkvalidationerror.d.ts.map +1 -1
  111. package/models/errors/sdkvalidationerror.js +14 -0
  112. package/models/errors/sdkvalidationerror.js.map +1 -1
  113. package/models/errors/vantaerror.d.ts +19 -0
  114. package/models/errors/vantaerror.d.ts.map +1 -0
  115. package/models/errors/vantaerror.js +20 -0
  116. package/models/errors/vantaerror.js.map +1 -0
  117. package/models/operations/listaudits.d.ts +5 -0
  118. package/models/operations/listaudits.d.ts.map +1 -1
  119. package/models/operations/listaudits.js +2 -0
  120. package/models/operations/listaudits.js.map +1 -1
  121. package/package.json +7 -7
  122. package/src/funcs/auditorsCreate.ts +23 -17
  123. package/src/funcs/auditsCreateCommentForEvidence.ts +23 -17
  124. package/src/funcs/auditsCreateCustomControl.ts +23 -17
  125. package/src/funcs/auditsCreateCustomEvidenceRequest.ts +23 -17
  126. package/src/funcs/auditsGetEvidenceUrls.ts +23 -17
  127. package/src/funcs/auditsList.ts +24 -17
  128. package/src/funcs/auditsListComments.ts +23 -17
  129. package/src/funcs/auditsListControls.ts +23 -17
  130. package/src/funcs/auditsListEvidence.ts +23 -17
  131. package/src/funcs/auditsUpdateEvidence.ts +23 -17
  132. package/src/hooks/types.ts +2 -0
  133. package/src/index.ts +2 -0
  134. package/src/lib/config.ts +7 -3
  135. package/src/lib/files.ts +42 -0
  136. package/src/lib/matchers.ts +44 -41
  137. package/src/lib/sdks.ts +21 -15
  138. package/src/lib/security.ts +2 -2
  139. package/src/mcp-server/cli/start/command.ts +0 -13
  140. package/src/mcp-server/cli/start/impl.ts +2 -6
  141. package/src/mcp-server/mcp-server.ts +1 -1
  142. package/src/mcp-server/server.ts +1 -1
  143. package/src/models/components/audit.ts +13 -4
  144. package/src/models/components/auditfocus.ts +31 -0
  145. package/src/models/components/index.ts +1 -0
  146. package/src/models/errors/apierror.ts +29 -16
  147. package/src/models/errors/index.ts +1 -0
  148. package/src/models/errors/responsevalidationerror.ts +50 -0
  149. package/src/models/errors/sdkvalidationerror.ts +12 -0
  150. package/src/models/errors/vantaerror.ts +35 -0
  151. package/src/models/operations/listaudits.ts +7 -0
  152. package/src/types/constdatetime.ts +1 -1
  153. package/types/constdatetime.js +1 -1
@@ -2,6 +2,7 @@
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
3
  */
4
4
 
5
+ import { SDKOptions } from "../lib/config.js";
5
6
  import { HTTPClient, RequestInput } from "../lib/http.js";
6
7
  import { RetryConfig } from "../lib/retries.js";
7
8
  import { SecurityState } from "../lib/security.js";
@@ -13,6 +14,7 @@ export type HookContext = {
13
14
  securitySource?: any | (() => Promise<any>);
14
15
  retryConfig: RetryConfig;
15
16
  resolvedSecurity: SecurityState | null;
17
+ options: SDKOptions;
16
18
  };
17
19
 
18
20
  export type Awaitable<T> = T | Promise<T>;
package/src/index.ts CHANGED
@@ -4,4 +4,6 @@
4
4
 
5
5
  export * from "./lib/config.js";
6
6
  export * as files from "./lib/files.js";
7
+ export { HTTPClient } from "./lib/http.js";
8
+ export type { Fetcher, HTTPClientOptions } from "./lib/http.js";
7
9
  export * from "./sdk/sdk.js";
package/src/lib/config.ts CHANGED
@@ -37,6 +37,10 @@ export type SDKOptions = {
37
37
  * Allows overriding the default server URL used by the SDK
38
38
  */
39
39
  serverURL?: string | undefined;
40
+ /**
41
+ * Allows overriding the default user agent used by the SDK
42
+ */
43
+ userAgent?: string | undefined;
40
44
  /**
41
45
  * Allows overriding the default retry config used by the SDK
42
46
  */
@@ -65,8 +69,8 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
65
69
  export const SDK_METADATA = {
66
70
  language: "typescript",
67
71
  openapiDocVersion: "1.0.0",
68
- sdkVersion: "0.2.0",
69
- genVersion: "2.578.0",
72
+ sdkVersion: "0.3.0",
73
+ genVersion: "2.658.3",
70
74
  userAgent:
71
- "speakeasy-sdk/typescript 0.2.0 2.578.0 1.0.0 vanta-auditor-api-sdk",
75
+ "speakeasy-sdk/typescript 0.3.0 2.658.3 1.0.0 vanta-auditor-api-sdk",
72
76
  } as const;
package/src/lib/files.ts CHANGED
@@ -38,3 +38,45 @@ export async function readableStreamToArrayBuffer(
38
38
 
39
39
  return concatenatedChunks.buffer as ArrayBuffer;
40
40
  }
41
+
42
+ /**
43
+ * Determines the MIME content type based on a file's extension.
44
+ * Returns null if the extension is not recognized.
45
+ */
46
+ export function getContentTypeFromFileName(fileName: string): string | null {
47
+ if (!fileName) return null;
48
+
49
+ const ext = fileName.toLowerCase().split(".").pop();
50
+ if (!ext) return null;
51
+
52
+ const mimeTypes: Record<string, string> = {
53
+ json: "application/json",
54
+ xml: "application/xml",
55
+ html: "text/html",
56
+ htm: "text/html",
57
+ txt: "text/plain",
58
+ csv: "text/csv",
59
+ pdf: "application/pdf",
60
+ png: "image/png",
61
+ jpg: "image/jpeg",
62
+ jpeg: "image/jpeg",
63
+ gif: "image/gif",
64
+ svg: "image/svg+xml",
65
+ js: "application/javascript",
66
+ css: "text/css",
67
+ zip: "application/zip",
68
+ tar: "application/x-tar",
69
+ gz: "application/gzip",
70
+ mp4: "video/mp4",
71
+ mp3: "audio/mpeg",
72
+ wav: "audio/wav",
73
+ webp: "image/webp",
74
+ ico: "image/x-icon",
75
+ woff: "font/woff",
76
+ woff2: "font/woff2",
77
+ ttf: "font/ttf",
78
+ otf: "font/otf",
79
+ };
80
+
81
+ return mimeTypes[ext] || null;
82
+ }
@@ -3,11 +3,10 @@
3
3
  */
4
4
 
5
5
  import { APIError } from "../models/errors/apierror.js";
6
- import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
7
- import { Result } from "../types/fp.js";
6
+ import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
7
+ import { ERR, OK, Result } from "../types/fp.js";
8
8
  import { matchResponse, matchStatusCode, StatusCodePredicate } from "./http.js";
9
9
  import { isPlainObject } from "./is-plain-object.js";
10
- import { safeParse } from "./schemas.js";
11
10
 
12
11
  export type Encoding =
13
12
  | "jsonl"
@@ -176,17 +175,19 @@ export type MatchedError<Matchers> = Matchers extends Matcher<any, infer E>[]
176
175
  : never;
177
176
  export type MatchFunc<T, E> = (
178
177
  response: Response,
178
+ request: Request,
179
179
  options?: { resultKey?: string; extraFields?: Record<string, unknown> },
180
180
  ) => Promise<[result: Result<T, E>, raw: unknown]>;
181
181
 
182
182
  export function match<T, E>(
183
183
  ...matchers: Array<Matcher<T, E>>
184
- ): MatchFunc<T, E | APIError | SDKValidationError> {
184
+ ): MatchFunc<T, E | APIError | ResponseValidationError> {
185
185
  return async function matchFunc(
186
186
  response: Response,
187
+ request: Request,
187
188
  options?: { resultKey?: string; extraFields?: Record<string, unknown> },
188
189
  ): Promise<
189
- [result: Result<T, E | APIError | SDKValidationError>, raw: unknown]
190
+ [result: Result<T, E | APIError | ResponseValidationError>, raw: unknown]
190
191
  > {
191
192
  let raw: unknown;
192
193
  let matcher: Matcher<T, E> | undefined;
@@ -205,21 +206,22 @@ export function match<T, E>(
205
206
  }
206
207
 
207
208
  if (!matcher) {
208
- const responseBody = await response.text();
209
209
  return [{
210
210
  ok: false,
211
- error: new APIError(
212
- "Unexpected API response status or content-type",
211
+ error: new APIError("Unexpected Status or Content-Type", {
213
212
  response,
214
- responseBody,
215
- ),
216
- }, responseBody];
213
+ request,
214
+ body: await response.text().catch(() => ""),
215
+ }),
216
+ }, raw];
217
217
  }
218
218
 
219
219
  const encoding = matcher.enc;
220
+ let body = "";
220
221
  switch (encoding) {
221
222
  case "json":
222
- raw = await response.json();
223
+ body = await response.text();
224
+ raw = JSON.parse(body);
223
225
  break;
224
226
  case "jsonl":
225
227
  raw = response.body;
@@ -231,16 +233,19 @@ export function match<T, E>(
231
233
  raw = response.body;
232
234
  break;
233
235
  case "text":
234
- raw = await response.text();
236
+ body = await response.text();
237
+ raw = body;
235
238
  break;
236
239
  case "sse":
237
240
  raw = response.body;
238
241
  break;
239
242
  case "nil":
240
- raw = await discardResponseBody(response);
243
+ body = await response.text();
244
+ raw = undefined;
241
245
  break;
242
246
  case "fail":
243
- raw = await response.text();
247
+ body = await response.text();
248
+ raw = body;
244
249
  break;
245
250
  default:
246
251
  encoding satisfies never;
@@ -250,11 +255,7 @@ export function match<T, E>(
250
255
  if (matcher.enc === "fail") {
251
256
  return [{
252
257
  ok: false,
253
- error: new APIError(
254
- "API error occurred",
255
- response,
256
- typeof raw === "string" ? raw : "",
257
- ),
258
+ error: new APIError("API error occurred", { request, response, body }),
258
259
  }, raw];
259
260
  }
260
261
 
@@ -266,6 +267,9 @@ export function match<T, E>(
266
267
  ...options?.extraFields,
267
268
  ...(matcher.hdrs ? { Headers: unpackHeaders(response.headers) } : null),
268
269
  ...(isPlainObject(raw) ? raw : null),
270
+ request$: request,
271
+ response$: response,
272
+ body$: body,
269
273
  };
270
274
  } else if (resultKey) {
271
275
  data = {
@@ -284,18 +288,20 @@ export function match<T, E>(
284
288
  }
285
289
 
286
290
  if ("err" in matcher) {
287
- const result = safeParse(
291
+ const result = safeParseResponse(
288
292
  data,
289
293
  (v: unknown) => matcher.schema.parse(v),
290
294
  "Response validation failed",
295
+ { request, response, body },
291
296
  );
292
297
  return [result.ok ? { ok: false, error: result.value } : result, raw];
293
298
  } else {
294
299
  return [
295
- safeParse(
300
+ safeParseResponse(
296
301
  data,
297
302
  (v: unknown) => matcher.schema.parse(v),
298
303
  "Response validation failed",
304
+ { request, response, body },
299
305
  ),
300
306
  raw,
301
307
  ];
@@ -318,25 +324,22 @@ export function unpackHeaders(headers: Headers): Record<string, string[]> {
318
324
  return out;
319
325
  }
320
326
 
321
- /**
322
- * Discards the response body to free up resources.
323
- *
324
- * To learn why this is need, see the undici docs:
325
- * https://undici.nodejs.org/#/?id=garbage-collection
326
- */
327
- export async function discardResponseBody(res: Response) {
328
- const reader = res.body?.getReader();
329
- if (reader == null) {
330
- return;
331
- }
332
-
327
+ function safeParseResponse<Inp, Out>(
328
+ rawValue: Inp,
329
+ fn: (value: Inp) => Out,
330
+ errorMessage: string,
331
+ httpMeta: { response: Response; request: Request; body: string },
332
+ ): Result<Out, ResponseValidationError> {
333
333
  try {
334
- let done = false;
335
- while (!done) {
336
- const res = await reader.read();
337
- done = res.done;
338
- }
339
- } finally {
340
- reader.releaseLock();
334
+ return OK(fn(rawValue));
335
+ } catch (err) {
336
+ return ERR(
337
+ new ResponseValidationError(errorMessage, {
338
+ cause: err,
339
+ rawValue,
340
+ rawMessage: errorMessage,
341
+ ...httpMeta,
342
+ }),
343
+ );
341
344
  }
342
345
  }
package/src/lib/sdks.ts CHANGED
@@ -47,12 +47,14 @@ export type RequestOptions = {
47
47
  */
48
48
  serverURL?: string | URL;
49
49
  /**
50
+ * @deprecated `fetchOptions` has been flattened into `RequestOptions`.
51
+ *
50
52
  * Sets various request options on the `fetch` call made by an SDK method.
51
53
  *
52
54
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options|Request}
53
55
  */
54
56
  fetchOptions?: Omit<RequestInit, "method" | "body">;
55
- };
57
+ } & Omit<RequestInit, "method" | "body">;
56
58
 
57
59
  type RequestConfig = {
58
60
  method: string;
@@ -63,6 +65,7 @@ type RequestConfig = {
63
65
  headers?: HeadersInit;
64
66
  security?: SecurityState | null;
65
67
  uaHeader?: string;
68
+ userAgent?: string | undefined;
66
69
  timeoutMs?: number;
67
70
  };
68
71
 
@@ -94,19 +97,21 @@ export class ClientSDK {
94
97
  } else {
95
98
  this.#hooks = new SDKHooks();
96
99
  }
97
- this._options = { ...options, hooks: this.#hooks };
98
-
99
100
  const url = serverURLFromOptions(options);
100
101
  if (url) {
101
102
  url.pathname = url.pathname.replace(/\/+$/, "") + "/";
102
103
  }
104
+
103
105
  const { baseURL, client } = this.#hooks.sdkInit({
104
106
  baseURL: url,
105
107
  client: options.httpClient || new HTTPClient(),
106
108
  });
107
109
  this._baseURL = baseURL;
108
110
  this.#httpClient = client;
109
- this.#logger = options.debugLogger;
111
+
112
+ this._options = { ...options, hooks: this.#hooks };
113
+
114
+ this.#logger = this._options.debugLogger;
110
115
  if (!this.#logger && env().VANTA_DEBUG) {
111
116
  this.#logger = console;
112
117
  }
@@ -172,7 +177,9 @@ export class ClientSDK {
172
177
  cookie = cookie.startsWith("; ") ? cookie.slice(2) : cookie;
173
178
  headers.set("cookie", cookie);
174
179
 
175
- const userHeaders = new Headers(options?.fetchOptions?.headers);
180
+ const userHeaders = new Headers(
181
+ options?.headers ?? options?.fetchOptions?.headers,
182
+ );
176
183
  for (const [k, v] of userHeaders) {
177
184
  headers.set(k, v);
178
185
  }
@@ -180,23 +187,22 @@ export class ClientSDK {
180
187
  // Only set user agent header in non-browser-like environments since CORS
181
188
  // policy disallows setting it in browsers e.g. Chrome throws an error.
182
189
  if (!isBrowserLike) {
183
- headers.set(conf.uaHeader ?? "user-agent", SDK_METADATA.userAgent);
190
+ headers.set(
191
+ conf.uaHeader ?? "user-agent",
192
+ conf.userAgent ?? SDK_METADATA.userAgent,
193
+ );
184
194
  }
185
195
 
186
- let fetchOptions = options?.fetchOptions;
196
+ const fetchOptions: Omit<RequestInit, "method" | "body"> = {
197
+ ...options?.fetchOptions,
198
+ ...options,
199
+ };
187
200
  if (!fetchOptions?.signal && conf.timeoutMs && conf.timeoutMs > 0) {
188
201
  const timeoutSignal = AbortSignal.timeout(conf.timeoutMs);
189
- if (!fetchOptions) {
190
- fetchOptions = { signal: timeoutSignal };
191
- } else {
192
- fetchOptions.signal = timeoutSignal;
193
- }
202
+ fetchOptions.signal = timeoutSignal;
194
203
  }
195
204
 
196
205
  if (conf.body instanceof ReadableStream) {
197
- if (!fetchOptions) {
198
- fetchOptions = {};
199
- }
200
206
  Object.assign(fetchOptions, { duplex: "half" });
201
207
  }
202
208
 
@@ -7,8 +7,8 @@ import { env } from "./env.js";
7
7
 
8
8
  type OAuth2PasswordFlow = {
9
9
  username: string;
10
- password?: string | undefined;
11
- clientID: string;
10
+ password: string;
11
+ clientID?: string | undefined;
12
12
  clientSecret?: string | undefined;
13
13
  tokenURL: string;
14
14
  };
@@ -6,7 +6,6 @@ import { buildCommand } from "@stricli/core";
6
6
  import { numberParser } from "@stricli/core";
7
7
  import * as z from "zod";
8
8
  import { consoleLoggerLevels } from "../../console-logger.js";
9
- import { mcpScopes } from "../../scopes.js";
10
9
 
11
10
  export const startCommand = buildCommand({
12
11
  loader: async () => {
@@ -37,18 +36,6 @@ export const startCommand = buildCommand({
37
36
  return z.string().parse(value);
38
37
  },
39
38
  },
40
- ...(mcpScopes.length
41
- ? {
42
- scope: {
43
- kind: "enum",
44
- brief:
45
- "Mount tools/resources that match given scope (repeatable flag)",
46
- values: mcpScopes,
47
- variadic: true,
48
- optional: true,
49
- },
50
- }
51
- : {}),
52
39
  "bearer-auth": {
53
40
  kind: "parsed",
54
41
  brief: "Sets the bearerAuth auth field for the API",
@@ -11,14 +11,12 @@ import {
11
11
  ConsoleLoggerLevel,
12
12
  createConsoleLogger,
13
13
  } from "../../console-logger.js";
14
- import { MCPScope } from "../../scopes.js";
15
14
  import { createMCPServer } from "../../server.js";
16
15
 
17
16
  interface StartCommandFlags {
18
17
  readonly transport: "stdio" | "sse";
19
18
  readonly port: number;
20
19
  readonly tool?: string[];
21
- readonly scope?: MCPScope[];
22
20
  readonly "bearer-auth"?: string | undefined;
23
21
  readonly "server-url"?: string;
24
22
  readonly "server-index"?: SDKOptions["serverIdx"];
@@ -49,8 +47,7 @@ async function startStdio(flags: StartCommandFlags) {
49
47
  const server = createMCPServer({
50
48
  logger,
51
49
  allowedTools: flags.tool,
52
- scopes: flags.scope,
53
- ...{ bearerAuth: flags["bearer-auth"] },
50
+ ...{ bearerAuth: flags["bearer-auth"] ?? "" },
54
51
  serverURL: flags["server-url"],
55
52
  serverIdx: flags["server-index"],
56
53
  });
@@ -70,8 +67,7 @@ async function startSSE(flags: StartCommandFlags) {
70
67
  const mcpServer = createMCPServer({
71
68
  logger,
72
69
  allowedTools: flags.tool,
73
- scopes: flags.scope,
74
- ...{ bearerAuth: flags["bearer-auth"] },
70
+ ...{ bearerAuth: flags["bearer-auth"] ?? "" },
75
71
  serverURL: flags["server-url"],
76
72
  serverIdx: flags["server-index"],
77
73
  });
@@ -19,7 +19,7 @@ const routes = buildRouteMap({
19
19
  export const app = buildApplication(routes, {
20
20
  name: "mcp",
21
21
  versionInfo: {
22
- currentVersion: "0.2.0",
22
+ currentVersion: "0.3.0",
23
23
  },
24
24
  });
25
25
 
@@ -34,7 +34,7 @@ export function createMCPServer(deps: {
34
34
  }) {
35
35
  const server = new McpServer({
36
36
  name: "Vanta",
37
- version: "0.2.0",
37
+ version: "0.3.0",
38
38
  });
39
39
 
40
40
  const client = new VantaCore({
@@ -6,6 +6,11 @@ import * as z from "zod";
6
6
  import { safeParse } from "../../lib/schemas.js";
7
7
  import { Result as SafeParseResult } from "../../types/fp.js";
8
8
  import { SDKValidationError } from "../errors/sdkvalidationerror.js";
9
+ import {
10
+ AuditFocus,
11
+ AuditFocus$inboundSchema,
12
+ AuditFocus$outboundSchema,
13
+ } from "./auditfocus.js";
9
14
 
10
15
  export type Audit = {
11
16
  /**
@@ -35,7 +40,7 @@ export type Audit = {
35
40
  /**
36
41
  * Timestamp at which auditors gain access to the audit. Occurs before the audit window begins
37
42
  */
38
- earlyAccessStartsDate: Date | null;
43
+ earlyAccessStartsAt: Date | null;
39
44
  /**
40
45
  * The name of the framework for the audit
41
46
  */
@@ -64,6 +69,7 @@ export type Audit = {
64
69
  * Timestamp when the audit was marked completed, and report was uploaded
65
70
  */
66
71
  completionDate: Date | null;
72
+ auditFocus: AuditFocus;
67
73
  };
68
74
 
69
75
  /** @internal */
@@ -79,7 +85,7 @@ export const Audit$inboundSchema: z.ZodType<Audit, z.ZodTypeDef, unknown> = z
79
85
  auditEndDate: z.string().datetime({ offset: true }).transform(v =>
80
86
  new Date(v)
81
87
  ),
82
- earlyAccessStartsDate: z.nullable(
88
+ earlyAccessStartsAt: z.nullable(
83
89
  z.string().datetime({ offset: true }).transform(v => new Date(v)),
84
90
  ),
85
91
  framework: z.string(),
@@ -97,6 +103,7 @@ export const Audit$inboundSchema: z.ZodType<Audit, z.ZodTypeDef, unknown> = z
97
103
  completionDate: z.nullable(
98
104
  z.string().datetime({ offset: true }).transform(v => new Date(v)),
99
105
  ),
106
+ auditFocus: AuditFocus$inboundSchema,
100
107
  });
101
108
 
102
109
  /** @internal */
@@ -107,7 +114,7 @@ export type Audit$Outbound = {
107
114
  customerOrganizationId: string;
108
115
  auditStartDate: string;
109
116
  auditEndDate: string;
110
- earlyAccessStartsDate: string | null;
117
+ earlyAccessStartsAt: string | null;
111
118
  framework: string;
112
119
  allowAuditorEmails: Array<string>;
113
120
  allowAllAuditors: boolean;
@@ -115,6 +122,7 @@ export type Audit$Outbound = {
115
122
  creationDate: string;
116
123
  modificationDate: string | null;
117
124
  completionDate: string | null;
125
+ auditFocus: string;
118
126
  };
119
127
 
120
128
  /** @internal */
@@ -129,7 +137,7 @@ export const Audit$outboundSchema: z.ZodType<
129
137
  customerOrganizationId: z.string(),
130
138
  auditStartDate: z.date().transform(v => v.toISOString()),
131
139
  auditEndDate: z.date().transform(v => v.toISOString()),
132
- earlyAccessStartsDate: z.nullable(z.date().transform(v => v.toISOString())),
140
+ earlyAccessStartsAt: z.nullable(z.date().transform(v => v.toISOString())),
133
141
  framework: z.string(),
134
142
  allowAuditorEmails: z.array(z.string()),
135
143
  allowAllAuditors: z.boolean(),
@@ -137,6 +145,7 @@ export const Audit$outboundSchema: z.ZodType<
137
145
  creationDate: z.date().transform(v => v.toISOString()),
138
146
  modificationDate: z.nullable(z.date().transform(v => v.toISOString())),
139
147
  completionDate: z.nullable(z.date().transform(v => v.toISOString())),
148
+ auditFocus: AuditFocus$outboundSchema,
140
149
  });
141
150
 
142
151
  /**
@@ -0,0 +1,31 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod";
6
+ import { ClosedEnum } from "../../types/enums.js";
7
+
8
+ export const AuditFocus = {
9
+ External: "EXTERNAL",
10
+ Internal: "INTERNAL",
11
+ } as const;
12
+ export type AuditFocus = ClosedEnum<typeof AuditFocus>;
13
+
14
+ /** @internal */
15
+ export const AuditFocus$inboundSchema: z.ZodNativeEnum<typeof AuditFocus> = z
16
+ .nativeEnum(AuditFocus);
17
+
18
+ /** @internal */
19
+ export const AuditFocus$outboundSchema: z.ZodNativeEnum<typeof AuditFocus> =
20
+ AuditFocus$inboundSchema;
21
+
22
+ /**
23
+ * @internal
24
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
25
+ */
26
+ export namespace AuditFocus$ {
27
+ /** @deprecated use `AuditFocus$inboundSchema` instead. */
28
+ export const inboundSchema = AuditFocus$inboundSchema;
29
+ /** @deprecated use `AuditFocus$outboundSchema` instead. */
30
+ export const outboundSchema = AuditFocus$outboundSchema;
31
+ }
@@ -8,6 +8,7 @@ export * from "./audit.js";
8
8
  export * from "./auditevidencestate.js";
9
9
  export * from "./auditevidencetype.js";
10
10
  export * from "./auditevidenceupdateinput.js";
11
+ export * from "./auditfocus.js";
11
12
  export * from "./auditor.js";
12
13
  export * from "./auditorcontrol.js";
13
14
  export * from "./auditorenabledstatetransition.js";
@@ -2,26 +2,39 @@
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
3
  */
4
4
 
5
- export class APIError extends Error {
6
- public readonly statusCode: number;
7
- public readonly contentType: string;
5
+ import { VantaError } from "./vantaerror.js";
8
6
 
7
+ /** The fallback error class if no more specific error class is matched */
8
+ export class APIError extends VantaError {
9
9
  constructor(
10
10
  message: string,
11
- public readonly rawResponse: Response,
12
- public readonly body: string = "",
11
+ httpMeta: {
12
+ response: Response;
13
+ request: Request;
14
+ body: string;
15
+ },
13
16
  ) {
14
- const statusCode = rawResponse.status;
15
- const contentType = rawResponse.headers.get("content-type") || "";
16
- const bodyString = body.length > 0 ? `\n${body}` : "";
17
-
18
- super(
19
- `${message}: Status ${statusCode} Content-Type ${contentType} Body ${bodyString}`,
20
- );
21
-
22
- this.statusCode = statusCode;
23
- this.contentType = contentType;
24
-
17
+ if (message) {
18
+ message += `: `;
19
+ }
20
+ message += `Status ${httpMeta.response.status}`;
21
+ const contentType = httpMeta.response.headers.get("content-type") || `""`;
22
+ if (contentType !== "application/json") {
23
+ message += ` Content-Type ${
24
+ contentType.includes(" ") ? `"${contentType}"` : contentType
25
+ }`;
26
+ }
27
+ const body = httpMeta.body || `""`;
28
+ message += body.length > 100 ? "\n" : ". ";
29
+ let bodyDisplay = body;
30
+ if (body.length > 10000) {
31
+ const truncated = body.substring(0, 10000);
32
+ const remaining = body.length - 10000;
33
+ bodyDisplay = `${truncated}...and ${remaining} more chars`;
34
+ }
35
+ message += `Body: ${bodyDisplay}`;
36
+ message = message.trim();
37
+ super(message, httpMeta);
25
38
  this.name = "APIError";
26
39
  }
27
40
  }
@@ -4,4 +4,5 @@
4
4
 
5
5
  export * from "./apierror.js";
6
6
  export * from "./httpclienterrors.js";
7
+ export * from "./responsevalidationerror.js";
7
8
  export * from "./sdkvalidationerror.js";