balda 0.0.68 → 0.0.70
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/lib/cli.js +15 -15
- package/lib/cli.js.map +1 -1
- package/lib/index.cjs +14 -14
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +21 -3
- package/lib/index.d.ts +21 -3
- package/lib/index.js +14 -14
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.d.cts
CHANGED
|
@@ -346,12 +346,29 @@ declare class Request<Params extends Record<string, string> = Record<string, str
|
|
|
346
346
|
* @internal
|
|
347
347
|
*/
|
|
348
348
|
private static getOrCompileSchema;
|
|
349
|
+
/**
|
|
350
|
+
* Maps Zod validation issues to AJV-compatible ErrorObject[] so that the
|
|
351
|
+
* existing catch blocks (which check `error instanceof ValidationError`)
|
|
352
|
+
* produce structured, JSON-serializable error responses instead of `{}`.
|
|
353
|
+
*
|
|
354
|
+
* @internal
|
|
355
|
+
*/
|
|
356
|
+
private static zodIssuesToAjvErrors;
|
|
349
357
|
/**
|
|
350
358
|
* Compiles and validates the request data against the input schema.
|
|
359
|
+
*
|
|
360
|
+
* **Zod schemas** are validated with Zod's native `safeParse()` instead of
|
|
361
|
+
* the AJV path. This correctly applies transforms (`.transform(Number)`),
|
|
362
|
+
* coercions (`z.coerce.number()`, `z.coerce.date()`), and refinements — all
|
|
363
|
+
* of which the AJV path cannot handle because `z.toJSONSchema()` throws for
|
|
364
|
+
* these constructs. The returned `data` is the fully parsed/coerced value.
|
|
365
|
+
*
|
|
366
|
+
* **TypeBox and plain JSON schemas** continue to use the AJV path.
|
|
367
|
+
*
|
|
351
368
|
* @param inputSchema - The schema to validate the request data against (Zod, TypeBox, or plain JSON schema).
|
|
352
369
|
* @param data - The request data to validate.
|
|
353
370
|
* @param throwErrorOnValidationFail - If true, throws ValidationError on validation failure. If false, returns the original data.
|
|
354
|
-
* @returns The validated data.
|
|
371
|
+
* @returns The validated (and potentially transformed/coerced) data.
|
|
355
372
|
*/
|
|
356
373
|
private static compileAndValidate;
|
|
357
374
|
/**
|
|
@@ -2328,8 +2345,9 @@ interface JsonOptions {
|
|
|
2328
2345
|
*/
|
|
2329
2346
|
sizeLimit?: `${number}mb` | `${number}kb`;
|
|
2330
2347
|
/**
|
|
2331
|
-
* If true, the JSON body will be parsed as an empty object if it is empty.
|
|
2332
|
-
*
|
|
2348
|
+
* If true, the JSON body will be parsed as an empty object (`{}`) if it is empty.
|
|
2349
|
+
* If false, an empty body leaves `req.body` as `undefined`.
|
|
2350
|
+
* Default: true
|
|
2333
2351
|
*/
|
|
2334
2352
|
parseEmptyBodyAsObject?: boolean;
|
|
2335
2353
|
/**
|
package/lib/index.d.ts
CHANGED
|
@@ -346,12 +346,29 @@ declare class Request<Params extends Record<string, string> = Record<string, str
|
|
|
346
346
|
* @internal
|
|
347
347
|
*/
|
|
348
348
|
private static getOrCompileSchema;
|
|
349
|
+
/**
|
|
350
|
+
* Maps Zod validation issues to AJV-compatible ErrorObject[] so that the
|
|
351
|
+
* existing catch blocks (which check `error instanceof ValidationError`)
|
|
352
|
+
* produce structured, JSON-serializable error responses instead of `{}`.
|
|
353
|
+
*
|
|
354
|
+
* @internal
|
|
355
|
+
*/
|
|
356
|
+
private static zodIssuesToAjvErrors;
|
|
349
357
|
/**
|
|
350
358
|
* Compiles and validates the request data against the input schema.
|
|
359
|
+
*
|
|
360
|
+
* **Zod schemas** are validated with Zod's native `safeParse()` instead of
|
|
361
|
+
* the AJV path. This correctly applies transforms (`.transform(Number)`),
|
|
362
|
+
* coercions (`z.coerce.number()`, `z.coerce.date()`), and refinements — all
|
|
363
|
+
* of which the AJV path cannot handle because `z.toJSONSchema()` throws for
|
|
364
|
+
* these constructs. The returned `data` is the fully parsed/coerced value.
|
|
365
|
+
*
|
|
366
|
+
* **TypeBox and plain JSON schemas** continue to use the AJV path.
|
|
367
|
+
*
|
|
351
368
|
* @param inputSchema - The schema to validate the request data against (Zod, TypeBox, or plain JSON schema).
|
|
352
369
|
* @param data - The request data to validate.
|
|
353
370
|
* @param throwErrorOnValidationFail - If true, throws ValidationError on validation failure. If false, returns the original data.
|
|
354
|
-
* @returns The validated data.
|
|
371
|
+
* @returns The validated (and potentially transformed/coerced) data.
|
|
355
372
|
*/
|
|
356
373
|
private static compileAndValidate;
|
|
357
374
|
/**
|
|
@@ -2328,8 +2345,9 @@ interface JsonOptions {
|
|
|
2328
2345
|
*/
|
|
2329
2346
|
sizeLimit?: `${number}mb` | `${number}kb`;
|
|
2330
2347
|
/**
|
|
2331
|
-
* If true, the JSON body will be parsed as an empty object if it is empty.
|
|
2332
|
-
*
|
|
2348
|
+
* If true, the JSON body will be parsed as an empty object (`{}`) if it is empty.
|
|
2349
|
+
* If false, an empty body leaves `req.body` as `undefined`.
|
|
2350
|
+
* Default: true
|
|
2333
2351
|
*/
|
|
2334
2352
|
parseEmptyBodyAsObject?: boolean;
|
|
2335
2353
|
/**
|