balda 0.0.10 → 0.0.11

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/index.d.cts CHANGED
@@ -301,6 +301,35 @@ type OpenIdConnectOptions = {
301
301
  */
302
302
  declare const controller: (path?: string, swaggerOptions?: SwaggerRouteOptions) => (target: any) => void;
303
303
 
304
+ type AjvInstance = InstanceType<typeof Ajv>;
305
+ type AjvCompileParams = Parameters<AjvInstance["compile"]>;
306
+
307
+ type RequestSchema = ZodType | TSchema | AjvCompileParams[0];
308
+ type ValidatedData<T extends RequestSchema> = T extends ZodType ? z.infer<T> : T extends TSchema ? Static<T> : T extends AjvCompileParams[0] ? any : any;
309
+ interface CustomValidationError {
310
+ status?: number;
311
+ message?: string;
312
+ }
313
+ interface ValidationOptions {
314
+ /**
315
+ * The schema to validate the request body against (Zod, TypeBox, or plain JSON schema)
316
+ */
317
+ body?: RequestSchema;
318
+ /**
319
+ * The schema to validate the query parameters against (Zod, TypeBox, or plain JSON schema)
320
+ */
321
+ query?: RequestSchema;
322
+ /**
323
+ * The schema to validate both body and query against (Zod, TypeBox, or plain JSON schema)
324
+ */
325
+ all?: RequestSchema;
326
+ /**
327
+ * Whether to use safe validation (returns original data if validation fails instead of throwing)
328
+ * @default false
329
+ */
330
+ safe?: boolean;
331
+ }
332
+
304
333
  type SyncOrAsync<T = void> = T | Promise<T>;
305
334
 
306
335
  interface AsyncLocalStorageContext {
@@ -364,35 +393,6 @@ type FilePluginOptions = {
364
393
  allowedMimeTypes?: (FileAllowedMimeType | (string & {}))[];
365
394
  };
366
395
 
367
- type AjvInstance = InstanceType<typeof Ajv>;
368
- type AjvCompileParams = Parameters<AjvInstance["compile"]>;
369
-
370
- type RequestSchema = ZodType | TSchema | AjvCompileParams[0];
371
- type ValidatedData<T extends RequestSchema> = T extends ZodType ? z.infer<T> : T extends TSchema ? Static<T> : T extends AjvCompileParams[0] ? any : any;
372
- interface CustomValidationError {
373
- status?: number;
374
- message?: string;
375
- }
376
- interface ValidationOptions {
377
- /**
378
- * The schema to validate the request body against (Zod, TypeBox, or plain JSON schema)
379
- */
380
- body?: RequestSchema;
381
- /**
382
- * The schema to validate the query parameters against (Zod, TypeBox, or plain JSON schema)
383
- */
384
- query?: RequestSchema;
385
- /**
386
- * The schema to validate both body and query against (Zod, TypeBox, or plain JSON schema)
387
- */
388
- all?: RequestSchema;
389
- /**
390
- * Whether to use safe validation (returns original data if validation fails instead of throwing)
391
- * @default false
392
- */
393
- safe?: boolean;
394
- }
395
-
396
396
  /**
397
397
  * The request object.
398
398
  * This is the main object that is passed to the handler function.
@@ -400,6 +400,7 @@ interface ValidationOptions {
400
400
  * It also contains the validation methods.
401
401
  */
402
402
  declare class Request<Params extends Record<string, string> = any> extends globalThis.Request {
403
+ #private;
403
404
  /**
404
405
  * Creates a new request object from a Web API Request object.
405
406
  * @param request - The Web API Request object to create a new request object from.
@@ -493,9 +494,15 @@ declare class Request<Params extends Record<string, string> = any> extends globa
493
494
  params: Params;
494
495
  /**
495
496
  * The query parameters of the request.
497
+ * Lazy parsed - only parses URLSearchParams when accessed
498
+ */
499
+ get query(): Record<string, string>;
500
+ set query(value: Record<string, string>);
501
+ /**
502
+ * Set the raw query string (called by server implementations)
503
+ * @internal
496
504
  */
497
- query: Record<string, string>;
498
- private _id;
505
+ setQueryString(queryString: string): void;
499
506
  /**
500
507
  * The id of the request.
501
508
  */
package/lib/index.d.ts CHANGED
@@ -301,6 +301,35 @@ type OpenIdConnectOptions = {
301
301
  */
302
302
  declare const controller: (path?: string, swaggerOptions?: SwaggerRouteOptions) => (target: any) => void;
303
303
 
304
+ type AjvInstance = InstanceType<typeof Ajv>;
305
+ type AjvCompileParams = Parameters<AjvInstance["compile"]>;
306
+
307
+ type RequestSchema = ZodType | TSchema | AjvCompileParams[0];
308
+ type ValidatedData<T extends RequestSchema> = T extends ZodType ? z.infer<T> : T extends TSchema ? Static<T> : T extends AjvCompileParams[0] ? any : any;
309
+ interface CustomValidationError {
310
+ status?: number;
311
+ message?: string;
312
+ }
313
+ interface ValidationOptions {
314
+ /**
315
+ * The schema to validate the request body against (Zod, TypeBox, or plain JSON schema)
316
+ */
317
+ body?: RequestSchema;
318
+ /**
319
+ * The schema to validate the query parameters against (Zod, TypeBox, or plain JSON schema)
320
+ */
321
+ query?: RequestSchema;
322
+ /**
323
+ * The schema to validate both body and query against (Zod, TypeBox, or plain JSON schema)
324
+ */
325
+ all?: RequestSchema;
326
+ /**
327
+ * Whether to use safe validation (returns original data if validation fails instead of throwing)
328
+ * @default false
329
+ */
330
+ safe?: boolean;
331
+ }
332
+
304
333
  type SyncOrAsync<T = void> = T | Promise<T>;
305
334
 
306
335
  interface AsyncLocalStorageContext {
@@ -364,35 +393,6 @@ type FilePluginOptions = {
364
393
  allowedMimeTypes?: (FileAllowedMimeType | (string & {}))[];
365
394
  };
366
395
 
367
- type AjvInstance = InstanceType<typeof Ajv>;
368
- type AjvCompileParams = Parameters<AjvInstance["compile"]>;
369
-
370
- type RequestSchema = ZodType | TSchema | AjvCompileParams[0];
371
- type ValidatedData<T extends RequestSchema> = T extends ZodType ? z.infer<T> : T extends TSchema ? Static<T> : T extends AjvCompileParams[0] ? any : any;
372
- interface CustomValidationError {
373
- status?: number;
374
- message?: string;
375
- }
376
- interface ValidationOptions {
377
- /**
378
- * The schema to validate the request body against (Zod, TypeBox, or plain JSON schema)
379
- */
380
- body?: RequestSchema;
381
- /**
382
- * The schema to validate the query parameters against (Zod, TypeBox, or plain JSON schema)
383
- */
384
- query?: RequestSchema;
385
- /**
386
- * The schema to validate both body and query against (Zod, TypeBox, or plain JSON schema)
387
- */
388
- all?: RequestSchema;
389
- /**
390
- * Whether to use safe validation (returns original data if validation fails instead of throwing)
391
- * @default false
392
- */
393
- safe?: boolean;
394
- }
395
-
396
396
  /**
397
397
  * The request object.
398
398
  * This is the main object that is passed to the handler function.
@@ -400,6 +400,7 @@ interface ValidationOptions {
400
400
  * It also contains the validation methods.
401
401
  */
402
402
  declare class Request<Params extends Record<string, string> = any> extends globalThis.Request {
403
+ #private;
403
404
  /**
404
405
  * Creates a new request object from a Web API Request object.
405
406
  * @param request - The Web API Request object to create a new request object from.
@@ -493,9 +494,15 @@ declare class Request<Params extends Record<string, string> = any> extends globa
493
494
  params: Params;
494
495
  /**
495
496
  * The query parameters of the request.
497
+ * Lazy parsed - only parses URLSearchParams when accessed
498
+ */
499
+ get query(): Record<string, string>;
500
+ set query(value: Record<string, string>);
501
+ /**
502
+ * Set the raw query string (called by server implementations)
503
+ * @internal
496
504
  */
497
- query: Record<string, string>;
498
- private _id;
505
+ setQueryString(queryString: string): void;
499
506
  /**
500
507
  * The id of the request.
501
508
  */