@h3ravel/http 11.4.3 → 11.5.1

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/index.d.ts CHANGED
@@ -1,10 +1,460 @@
1
1
  /// <reference path="./app.globals.d.ts" />
2
2
  import { Command } from "@h3ravel/musket";
3
3
  import { DotNestedKeys, DotNestedValue, HttpContext, HttpContext as HttpContext$1, IMiddleware, IRequest, IResponse } from "@h3ravel/shared";
4
- import { EventHandlerRequest, H3Event } from "h3";
5
- import { ResponseHeaderMap, TypedHeaders } from "fetchdts";
4
+ import { EventHandlerRequest, H3Event, HTTPResponse } from "h3";
6
5
  import { Application } from "@h3ravel/core";
6
+ import { Url } from "@h3ravel/url";
7
7
 
8
+ //#region src/Contracts/HttpContract.d.ts
9
+ type RequestMethod = 'HEAD' | 'GET' | 'PUT' | 'DELETE' | 'TRACE' | 'OPTIONS' | 'PURGE' | 'POST' | 'CONNECT' | 'PATCH';
10
+ type RequestObject = Record<string, any>;
11
+ //#endregion
12
+ //#region src/Bags/ParamBag.d.ts
13
+ /**
14
+ * ParamBag is a container for key/value pairs
15
+ * for Node/H3 environments.
16
+ */
17
+ declare class ParamBag implements Iterable<[string, any]> {
18
+ protected parameters: RequestObject;
19
+ /**
20
+ * The current H3 H3Event instance
21
+ */
22
+ readonly event: H3Event;
23
+ constructor(parameters: RequestObject | undefined,
24
+ /**
25
+ * The current H3 H3Event instance
26
+ */
27
+ event: H3Event);
28
+ /**
29
+ * Returns the parameters.
30
+ * @
31
+ * @param key The name of the parameter to return or null to get them all
32
+ *
33
+ * @throws BadRequestException if the value is not an array
34
+ */
35
+ all(key?: string): any;
36
+ get(key: string, defaultValue?: any): any;
37
+ set(key: string, value: any): void;
38
+ /**
39
+ * Returns true if the parameter is defined.
40
+ *
41
+ * @param key
42
+ */
43
+ has(key: string): boolean;
44
+ /**
45
+ * Removes a parameter.
46
+ *
47
+ * @param key
48
+ */
49
+ remove(key: string): void;
50
+ /**
51
+ *
52
+ * Returns the parameter as string.
53
+ *
54
+ * @param key
55
+ * @param defaultValue
56
+ * @throws UnexpectedValueException if the value cannot be converted to string
57
+ * @returns
58
+ */
59
+ getString(key: string, defaultValue?: string): string;
60
+ /**
61
+ * Returns the parameter value converted to integer.
62
+ *
63
+ * @param key
64
+ * @param defaultValue
65
+ * @throws UnexpectedValueException if the value cannot be converted to integer
66
+ */
67
+ getInt(key: string, defaultValue?: number): number;
68
+ /**
69
+ * Returns the parameter value converted to boolean.
70
+ *
71
+ * @param key
72
+ * @param defaultValue
73
+ * @throws UnexpectedValueException if the value cannot be converted to a boolean
74
+ */
75
+ getBoolean(key: string, defaultValue?: boolean): boolean;
76
+ /**
77
+ * Returns the alphabetic characters of the parameter value.
78
+ *
79
+ * @param key
80
+ * @param defaultValue
81
+ * @throws UnexpectedValueException if the value cannot be converted to string
82
+ */
83
+ getAlpha(key: string, defaultValue?: string): string;
84
+ /**
85
+ * Returns the alphabetic characters and digits of the parameter value.
86
+ *
87
+ * @param key
88
+ * @param defaultValue
89
+ * @throws UnexpectedValueException if the value cannot be converted to string
90
+ */
91
+ getAlnum(key: string, defaultValue?: string): string;
92
+ /**
93
+ * Returns the digits of the parameter value.
94
+ *
95
+ * @param key
96
+ * @param defaultValue
97
+ * @throws UnexpectedValueException if the value cannot be converted to string
98
+ * @returns
99
+ **/
100
+ getDigits(key: string, defaultValue?: string): string;
101
+ /**
102
+ * Returns the parameter keys.
103
+ */
104
+ keys(): string[];
105
+ /**
106
+ * Replaces the current parameters by a new set.
107
+ */
108
+ replace(parameters?: RequestObject): void;
109
+ /**
110
+ * Adds parameters.
111
+ */
112
+ add(parameters?: RequestObject): void;
113
+ /**
114
+ * Returns the number of parameters.
115
+ */
116
+ count(): number;
117
+ /**
118
+ * Returns an iterator for parameters.
119
+ *
120
+ * @returns
121
+ */
122
+ [Symbol.iterator](): ArrayIterator<[string, any]>;
123
+ }
124
+ //#endregion
125
+ //#region src/UploadedFile.d.ts
126
+ declare class UploadedFile {
127
+ originalName: string;
128
+ mimeType: string;
129
+ size: number;
130
+ content: File;
131
+ constructor(originalName: string, mimeType: string, size: number, content: File);
132
+ static createFromBase(file: File): UploadedFile;
133
+ /**
134
+ * Save to disk (Node environment only)
135
+ */
136
+ moveTo(destination: string): Promise<void>;
137
+ }
138
+ //#endregion
139
+ //#region src/Bags/FileBag.d.ts
140
+ type FileInput = UploadedFile | File | null | undefined;
141
+ /**
142
+ * FileBag is a container for uploaded files
143
+ * for Node/H3 environments.
144
+ */
145
+ declare class FileBag extends ParamBag {
146
+ protected parameters: Record<string, UploadedFile | UploadedFile[] | null>;
147
+ constructor(parameters: Record<string, FileInput | FileInput[]> | undefined,
148
+ /**
149
+ * The current H3 H3Event instance
150
+ */
151
+ event: H3Event);
152
+ /**
153
+ * Replace all stored files.
154
+ */
155
+ replace(files?: Record<string, FileInput | FileInput[]>): void;
156
+ /**
157
+ * Set a file or array of files.
158
+ */
159
+ set(key: string, value: FileInput | FileInput[]): void;
160
+ /**
161
+ * Add multiple files.
162
+ */
163
+ add(files?: Record<string, FileInput | FileInput[]>): void;
164
+ /**
165
+ * Get all stored files.
166
+ */
167
+ all(): Record<string, UploadedFile | UploadedFile[] | null>;
168
+ /**
169
+ * Normalize file input into UploadedFile instances.
170
+ */
171
+ protected convertFileInformation(file: FileInput): UploadedFile | null;
172
+ }
173
+ //#endregion
174
+ //#region src/Bags/HeaderBag.d.ts
175
+ /**
176
+ * HeaderBag — A container for HTTP headers
177
+ * for Node/H3 environments.
178
+ */
179
+ declare class HeaderBag implements Iterable<[string, (string | null)[]]> {
180
+ protected static readonly UPPER = "_ABCDEFGHIJKLMNOPQRSTUVWXYZ";
181
+ protected static readonly LOWER = "-abcdefghijklmnopqrstuvwxyz";
182
+ protected headers: Record<string, (string | null)[]>;
183
+ protected cacheControl: Record<string, string | boolean>;
184
+ constructor(headers?: Record<string, string | string[] | null>);
185
+ /**
186
+ * Returns all headers as string (for debugging / toString)
187
+ *
188
+ * @returns
189
+ */
190
+ toString(): string;
191
+ /**
192
+ * Returns all headers or specific header list
193
+ *
194
+ * @param key
195
+ * @returns
196
+ */
197
+ all(key?: string): Record<string, (string | null)[]> | (string | null)[];
198
+ /**
199
+ * Returns header keys
200
+ *
201
+ * @returns
202
+ */
203
+ keys(): string[];
204
+ /**
205
+ * Replace all headers with new set
206
+ *
207
+ * @param headers
208
+ */
209
+ replace(headers?: Record<string, string | string[] | null>): void;
210
+ /**
211
+ * Add multiple headers
212
+ *
213
+ * @param headers
214
+ */
215
+ add(headers: Record<string, string | string[] | null>): void;
216
+ /**
217
+ * Returns first header value by name or default
218
+ *
219
+ * @param key
220
+ * @param defaultValue
221
+ * @returns
222
+ */
223
+ get<R = undefined>(key: string, defaultValue?: string | null): R extends undefined ? string | null : R;
224
+ /**
225
+ * Sets a header by name.
226
+ *
227
+ * @param replace Whether to replace existing values (default true)
228
+ */
229
+ set(key: string, values: string | string[] | null, replace?: boolean): void;
230
+ /**
231
+ * Returns true if header exists
232
+ *
233
+ * @param key
234
+ * @returns
235
+ */
236
+ has(key: string): boolean;
237
+ /**
238
+ * Returns true if header contains value
239
+ *
240
+ * @param key
241
+ * @param value
242
+ * @returns
243
+ */
244
+ contains(key: string, value: string): boolean;
245
+ /**
246
+ * Removes a header
247
+ *
248
+ * @param key
249
+ */
250
+ remove(key: string): void;
251
+ /**
252
+ * Returns parsed date from header
253
+ *
254
+ * @param key
255
+ * @param defaultValue
256
+ * @returns
257
+ */
258
+ getDate(key: string, defaultValue?: Date | null): Date | null;
259
+ /**
260
+ * Adds a Cache-Control directive
261
+ *
262
+ * @param key
263
+ * @param value
264
+ */
265
+ addCacheControlDirective(key: string, value?: string | boolean): void;
266
+ /**
267
+ * Returns true if Cache-Control directive is defined
268
+ *
269
+ * @param key
270
+ * @returns
271
+ */
272
+ hasCacheControlDirective(key: string): boolean;
273
+ /**
274
+ * Returns a Cache-Control directive value by name
275
+ *
276
+ * @param key
277
+ * @returns
278
+ */
279
+ getCacheControlDirective(key: string): string | boolean | null;
280
+ /**
281
+ * Removes a Cache-Control directive
282
+ *
283
+ * @param key
284
+ * @returns
285
+ */
286
+ removeCacheControlDirective(key: string): void;
287
+ /**
288
+ * Number of headers
289
+ *
290
+ * @param key
291
+ * @returns
292
+ */
293
+ count(): number;
294
+ /**
295
+ * Normalize header name to lowercase with hyphens
296
+ *
297
+ * @param key
298
+ * @returns
299
+ */
300
+ protected normalizeKey(key: string): string;
301
+ /**
302
+ * Generates Cache-Control header string
303
+ *
304
+ * @param header
305
+ * @returns
306
+ */
307
+ protected getCacheControlHeader(): string;
308
+ /**
309
+ * Parses Cache-Control header
310
+ *
311
+ * @param header
312
+ * @returns
313
+ */
314
+ protected parseCacheControl(header: string): Record<string, string | boolean>;
315
+ /**
316
+ * Iterator support
317
+ * @returns
318
+ */
319
+ [Symbol.iterator](): Iterator<[string, (string | null)[]]>;
320
+ }
321
+ //#endregion
322
+ //#region src/Bags/InputBag.d.ts
323
+ /**
324
+ * InputBag is a container for user input values
325
+ * (e.g., query params, body, cookies)
326
+ * for Node/H3 environments.
327
+ */
328
+ declare class InputBag extends ParamBag {
329
+ constructor(inputs: RequestObject | undefined,
330
+ /**
331
+ * The current H3 H3Event instance
332
+ */
333
+ event: H3Event);
334
+ /**
335
+ * Returns a scalar input value by name.
336
+ *
337
+ * @param key
338
+ * @param defaultValue
339
+ * @throws BadRequestException if the input contains a non-scalar value
340
+ * @returns
341
+ */
342
+ get<T extends string | number | boolean | null>(key: string, defaultValue?: T | null): T | string | number | boolean | null;
343
+ /**
344
+ * Replaces all current input values.
345
+ *
346
+ * @param inputs
347
+ * @returns
348
+ */
349
+ replace(inputs?: RequestObject): void;
350
+ /**
351
+ * Adds multiple input values.
352
+ *
353
+ * @param inputs
354
+ * @returns
355
+ */
356
+ add(inputs?: RequestObject): void;
357
+ /**
358
+ * Sets an input by name.
359
+ *
360
+ * @param key
361
+ * @param value
362
+ * @throws TypeError if value is not scalar or array
363
+ * @returns
364
+ */
365
+ set(key: string, value: any): void;
366
+ /**
367
+ * Returns true if a key exists.
368
+ *
369
+ * @param key
370
+ * @returns
371
+ */
372
+ has(key: string): boolean;
373
+ /**
374
+ * Returns all parameters.
375
+ *
376
+ * @returns
377
+ */
378
+ all(): RequestObject;
379
+ /**
380
+ * Converts a parameter value to string.
381
+ *
382
+ * @param key
383
+ * @param defaultValue
384
+ * @throws BadRequestException if input contains a non-scalar value
385
+ * @returns
386
+ */
387
+ getString(key: string, defaultValue?: string): string;
388
+ /**
389
+ * Filters input value with a predicate.
390
+ * Mimics PHP’s filter_var() in spirit, but simpler.
391
+ *
392
+ * @param key
393
+ * @param defaultValue
394
+ * @param filterFn
395
+ * @throws BadRequestException if validation fails
396
+ * @returns
397
+ */
398
+ filter<T = any>(key: string, defaultValue?: T | null, filterFn?: (value: any) => boolean): T | null;
399
+ /**
400
+ * Returns an enum value by key.
401
+ *
402
+ * @param key
403
+ * @param EnumClass
404
+ * @param defaultValue
405
+ * @throws BadRequestException if conversion fails
406
+ * @returns
407
+ */
408
+ getEnum<T extends Record<string, string | number>>(key: string, EnumClass: T, defaultValue?: T[keyof T] | null): T[keyof T] | null;
409
+ /**
410
+ * Removes a key.
411
+ *
412
+ * @param key
413
+ */
414
+ remove(key: string): void;
415
+ /**
416
+ * Returns all keys.
417
+ *
418
+ * @returns
419
+ */
420
+ keys(): string[];
421
+ /**
422
+ * Returns number of parameters.
423
+ *
424
+ * @returns
425
+ */
426
+ count(): number;
427
+ }
428
+ //#endregion
429
+ //#region src/Bags/ServerBag.d.ts
430
+ /**
431
+ * ServerBag — a simplified version of Symfony's ServerBag
432
+ * for Node/H3 environments.
433
+ *
434
+ * Responsible for extracting and normalizing HTTP headers
435
+ * from the incoming request.
436
+ */
437
+ declare class ServerBag extends ParamBag {
438
+ constructor(parameters: Record<string, string | undefined> | undefined,
439
+ /**
440
+ * The current H3 H3Event instance
441
+ */
442
+ event: H3Event);
443
+ /**
444
+ * Returns all request headers, normalized to uppercase with underscores.
445
+ * Example: content-type → CONTENT_TYPE
446
+ */
447
+ getHeaders(): Record<string, string>;
448
+ /**
449
+ * Returns a specific header by name, case-insensitive.
450
+ */
451
+ get(name: string): string | undefined;
452
+ /**
453
+ * Returns true if a header exists.
454
+ */
455
+ has(name: string): boolean;
456
+ }
457
+ //#endregion
8
458
  //#region src/Commands/FireCommand.d.ts
9
459
  declare class FireCommand extends Command {
10
460
  /**
@@ -23,6 +473,48 @@ declare class FireCommand extends Command {
23
473
  protected fire(): Promise<void>;
24
474
  }
25
475
  //#endregion
476
+ //#region src/Exceptions/BadRequestException.d.ts
477
+ declare class BadRequestException extends Error {
478
+ constructor(message: string);
479
+ }
480
+ //#endregion
481
+ //#region src/Exceptions/SuspiciousOperationException.d.ts
482
+ declare class SuspiciousOperationException extends Error {
483
+ constructor(message: string);
484
+ }
485
+ //#endregion
486
+ //#region src/Exceptions/UnexpectedValueException.d.ts
487
+ declare class UnexpectedValueException extends Error {
488
+ constructor(message: string);
489
+ }
490
+ //#endregion
491
+ //#region src/FormRequest.d.ts
492
+ declare class FormRequest {
493
+ protected dataset: {
494
+ files: Record<string, File | UploadedFile | (File | UploadedFile)[]>;
495
+ input: Record<string, any>;
496
+ };
497
+ constructor(data: FormData);
498
+ /**
499
+ * Initialize the data
500
+ * @param data
501
+ */
502
+ initialize(data: FormData): void;
503
+ /**
504
+ * Get all uploaded files
505
+ */
506
+ files(): Record<string, File | UploadedFile | (File | UploadedFile)[]>;
507
+ /**
508
+ * Get all input fields
509
+ */
510
+ input(): Record<string, any>;
511
+ /**
512
+ * Get combined input and files
513
+ * File entries take precedence if names overlap.
514
+ */
515
+ all(): Record<string, any>;
516
+ }
517
+ //#endregion
26
518
  //#region src/Middleware.d.ts
27
519
  declare abstract class Middleware implements IMiddleware {
28
520
  abstract handle(context: HttpContext, next: () => Promise<unknown>): Promise<unknown>;
@@ -56,42 +548,352 @@ declare class HttpServiceProvider {
56
548
  //#endregion
57
549
  //#region src/Request.d.ts
58
550
  declare class Request implements IRequest {
551
+ #private;
552
+ /**
553
+ * The current H3 H3Event instance
554
+ */
555
+ private readonly event;
59
556
  /**
60
557
  * The current app instance
61
558
  */
62
559
  app: Application;
560
+ /**
561
+ * Parsed request body
562
+ */
563
+ body: unknown;
63
564
  /**
64
565
  * Gets route parameters.
65
566
  * @returns An object containing route parameters.
66
567
  */
67
- readonly params: NonNullable<H3Event['context']['params']>;
568
+ params: NonNullable<H3Event['context']['params']>;
68
569
  /**
69
- * Gets query parameters.
70
- * @returns An object containing query parameters.
570
+ * All of the converted files for the request.
71
571
  */
72
- readonly query: Record<string, string>;
572
+ protected convertedFiles?: Record<string, UploadedFile | UploadedFile[]>;
573
+ /**
574
+ * Form data from incoming request.
575
+ * @returns The FormRequest object.
576
+ */
577
+ protected formData: FormRequest;
578
+ /**
579
+ * Request body parameters (POST).
580
+ *
581
+ * @see getPayload() for portability between content types
582
+ */
583
+ protected request: InputBag;
584
+ /**
585
+ * Query string parameters (GET).
586
+ */
587
+ query: InputBag;
588
+ /**
589
+ * Server and execution environment parameters
590
+ */
591
+ server: ServerBag;
592
+ /**
593
+ * Cookies
594
+ */
595
+ cookies: InputBag;
596
+ /**
597
+ * The request attributes (parameters parsed from the PATH_INFO, ...).
598
+ */
599
+ attributes: ParamBag;
73
600
  /**
74
601
  * Gets the request headers.
75
602
  * @returns An object containing request headers.
76
603
  */
77
- readonly headers: TypedHeaders<Record<keyof ResponseHeaderMap, string>>;
604
+ headers: HeaderBag;
605
+ protected content?: ReadableStream | string | false | null;
606
+ protected static formats?: Record<string, string[]> | undefined | null;
607
+ protected static httpMethodParameterOverride: boolean;
608
+ /**
609
+ * List of Acceptable Content Types
610
+ */
611
+ private acceptableContentTypes;
612
+ constructor(
78
613
  /**
79
614
  * The current H3 H3Event instance
80
615
  */
81
- private readonly event;
82
- constructor(event: H3Event,
616
+ event: H3Event,
83
617
  /**
84
618
  * The current app instance
85
619
  */
86
620
  app: Application);
87
621
  /**
88
- * Get all input data (query + body).
622
+ * Factory method to create a Request instance from an H3Event.
623
+ */
624
+ static create(
625
+ /**
626
+ * The current H3 H3Event instance
627
+ */
628
+ event: H3Event,
629
+ /**
630
+ * The current app instance
631
+ */
632
+ app: Application): Promise<Request>;
633
+ /**
634
+ * Sets the parameters for this request.
635
+ *
636
+ * This method also re-initializes all properties.
637
+ *
638
+ * @param attributes
639
+ * @param cookies The COOKIE parameters
640
+ * @param files The FILES parameters
641
+ * @param server The SERVER parameters
642
+ * @param content The raw body data
643
+ */
644
+ initialize(): Promise<void>;
645
+ private setBody;
646
+ /**
647
+ * Retrieve all data from the instance (query + body).
648
+ */
649
+ all<T = Record<string, any>>(keys?: string | string[]): T;
650
+ /**
651
+ * Retrieve an input item from the request.
652
+ *
653
+ * @param key
654
+ * @param defaultValue
655
+ * @returns
656
+ */
657
+ input<K extends string | undefined>(key?: K, defaultValue?: any): K extends undefined ? RequestObject : any;
658
+ /**
659
+ * Retrieve a file from the request.
660
+ *
661
+ * @param key
662
+ * @param defaultValue
663
+ * @param expectArray
664
+ * @returns
665
+ */
666
+ file<K extends string | undefined = undefined, E extends boolean | undefined = undefined>(key?: K, defaultValue?: any, expectArray?: E): K extends undefined ? Record<string, E extends true ? UploadedFile[] : UploadedFile> : E extends true ? UploadedFile[] : UploadedFile;
667
+ /**
668
+ * Determine if the uploaded data contains a file.
669
+ *
670
+ * @param key
671
+ * @return boolean
672
+ */
673
+ hasFile(key: string): boolean;
674
+ /**
675
+ * Check that the given file is a valid file instance.
676
+ *
677
+ * @param file
678
+ * @return boolean
679
+ */
680
+ protected isValidFile(file: UploadedFile): boolean;
681
+ /**
682
+ * Get an object with all the files on the request.
89
683
  */
90
- all<T = Record<string, unknown>>(): Promise<T>;
684
+ allFiles(): Record<string, UploadedFile | UploadedFile[]>;
91
685
  /**
92
- * Get a single input field from query or body.
686
+ * Extract and convert uploaded files from FormData.
687
+ */
688
+ convertUploadedFiles(files: Record<string, UploadedFile | UploadedFile[]>): Record<string, UploadedFile | UploadedFile[]>;
689
+ /**
690
+ * Determine if the data contains a given key.
691
+ *
692
+ * @param keys
693
+ * @returns
694
+ */
695
+ has(keys: string[] | string): boolean;
696
+ /**
697
+ * Determine if the instance is missing a given key.
698
+ */
699
+ missing(key: string | string[]): boolean;
700
+ /**
701
+ * Get a subset containing the provided keys with values from the instance data.
702
+ *
703
+ * @param keys
704
+ * @returns
705
+ */
706
+ only<T = Record<string, any>>(keys: string[]): T;
707
+ /**
708
+ * Get all of the data except for a specified array of items.
709
+ *
710
+ * @param keys
711
+ * @returns
712
+ */
713
+ except<T = Record<string, any>>(keys: string[]): T;
714
+ /**
715
+ * Merges new input data into the current request's input source.
716
+ *
717
+ * @param input - An object containing key-value pairs to merge.
718
+ * @returns this - For fluent chaining.
719
+ */
720
+ merge(input: Record<string, any>): this;
721
+ /**
722
+ * Merge new input into the request's input, but only when that key is missing from the request.
723
+ *
724
+ * @param input
725
+ */
726
+ mergeIfMissing(input: Record<string, any>): this;
727
+ /**
728
+ * Get the keys for all of the input and files.
729
+ */
730
+ keys(): string[];
731
+ /**
732
+ * Determine if the request is sending JSON.
733
+ *
734
+ * @return bool
735
+ */
736
+ isJson(): boolean;
737
+ /**
738
+ * Determine if the current request probably expects a JSON response.
739
+ *
740
+ * @returns
741
+ */
742
+ expectsJson(): boolean;
743
+ /**
744
+ * Determine if the current request is asking for JSON.
745
+ *
746
+ * @returns
747
+ */
748
+ wantsJson(): boolean;
749
+ /**
750
+ * Gets a list of content types acceptable by the client browser in preferable order.
751
+ * @returns {string[]}
752
+ */
753
+ getAcceptableContentTypes(): string[];
754
+ /**
755
+ * Determine if the request is the result of a PJAX call.
756
+ *
757
+ * @return bool
758
+ */
759
+ pjax(): boolean;
760
+ /**
761
+ * Returns true if the request is an XMLHttpRequest (AJAX).
762
+ *
763
+ * @alias isXmlHttpRequest()
764
+ * @returns {boolean}
765
+ */
766
+ ajax(): boolean;
767
+ /**
768
+ * Returns true if the request is an XMLHttpRequest (AJAX).
769
+ */
770
+ isXmlHttpRequest(): boolean;
771
+ /**
772
+ * Returns the value of the requested header.
773
+ */
774
+ getHeader(name: string): string | undefined | null;
775
+ /**
776
+ * Checks if the request method is of specified type.
777
+ *
778
+ * @param method Uppercase request method (GET, POST etc)
779
+ */
780
+ isMethod(method: string): boolean;
781
+ /**
782
+ * Checks whether or not the method is safe.
783
+ *
784
+ * @see https://tools.ietf.org/html/rfc7231#section-4.2.1
785
+ */
786
+ isMethodSafe(): boolean;
787
+ /**
788
+ * Checks whether or not the method is idempotent.
789
+ */
790
+ isMethodIdempotent(): boolean;
791
+ /**
792
+ * Checks whether the method is cacheable or not.
793
+ *
794
+ * @see https://tools.ietf.org/html/rfc7231#section-4.2.3
795
+ */
796
+ isMethodCacheable(): boolean;
797
+ /**
798
+ * Initializes HTTP request formats.
799
+ */
800
+ protected static initializeFormats(): void;
801
+ /**
802
+ * Gets the request "intended" method.
803
+ *
804
+ * If the X-HTTP-Method-Override header is set, and if the method is a POST,
805
+ * then it is used to determine the "real" intended HTTP method.
806
+ *
807
+ * The _method request parameter can also be used to determine the HTTP method,
808
+ * but only if enableHttpMethodParameterOverride() has been called.
809
+ *
810
+ * The method is always an uppercased string.
811
+ *
812
+ * @see getRealMethod()
813
+ */
814
+ getMethod(): RequestMethod;
815
+ /**
816
+ * Gets the "real" request method.
817
+ *
818
+ * @see getMethod()
819
+ */
820
+ getRealMethod(): RequestMethod;
821
+ /**
822
+ * Get the client IP address.
823
+ */
824
+ ip(): string | undefined;
825
+ /**
826
+ * Get a URI instance for the request.
827
+ */
828
+ uri(): Url;
829
+ /**
830
+ * Get the full URL for the request.
831
+ */
832
+ fullUrl(): string;
833
+ /**
834
+ * Return the Request instance.
835
+ */
836
+ instance(): this;
837
+ /**
838
+ * Get the request method.
839
+ */
840
+ method(): RequestMethod;
841
+ /**
842
+ * Get the JSON payload for the request.
843
+ *
844
+ * @param key
845
+ * @param defaultValue
846
+ * @return {InputBag}
847
+ */
848
+ json<K extends string | undefined = undefined>(key?: string, defaultValue?: any): K extends undefined ? InputBag : any;
849
+ /**
850
+ * Get the input source for the request.
851
+ *
852
+ * @return {InputBag}
853
+ */
854
+ protected getInputSource(): InputBag;
855
+ /**
856
+ * Returns the request body content.
857
+ *
858
+ * @param asStream If true, returns a ReadableStream instead of the parsed string
859
+ * @return {string | ReadableStream | Promise<string | ReadableStream>}
860
+ */
861
+ getContent(asStream?: boolean): string | ReadableStream;
862
+ /**
863
+ * Gets a "parameter" value from any bag.
864
+ *
865
+ * This method is mainly useful for libraries that want to provide some flexibility. If you don't need the
866
+ * flexibility in controllers, it is better to explicitly get request parameters from the appropriate
867
+ * public property instead (attributes, query, request).
868
+ *
869
+ * Order of precedence: PATH (routing placeholders or custom attributes), GET, POST
870
+ *
871
+ * @internal use explicit input sources instead
872
+ */
873
+ get(key: string, defaultValue?: any): any;
874
+ /**
875
+ * Enables support for the _method request parameter to determine the intended HTTP method.
876
+ *
877
+ * Be warned that enabling this feature might lead to CSRF issues in your code.
878
+ * Check that you are using CSRF tokens when required.
879
+ * If the HTTP method parameter override is enabled, an html-form with method "POST" can be altered
880
+ * and used to send a "PUT" or "DELETE" request via the _method request parameter.
881
+ * If these methods are not protected against CSRF, this presents a possible vulnerability.
882
+ *
883
+ * The HTTP method can only be overridden when the real HTTP method is POST.
884
+ */
885
+ static enableHttpMethodParameterOverride(): void;
886
+ /**
887
+ * Checks whether support for the _method request parameter is enabled.
888
+ */
889
+ static getHttpMethodParameterOverride(): boolean;
890
+ /**
891
+ * Dump the items.
892
+ *
893
+ * @param keys
894
+ * @return this
93
895
  */
94
- input<T = unknown>(key: string, defaultValue?: T): Promise<T>;
896
+ dump(...keys: any[]): this;
95
897
  /**
96
898
  * Get the base event
97
899
  */
@@ -118,7 +920,7 @@ type BodyResource = Resource & {
118
920
  /**
119
921
  * Class to render API resource
120
922
  */
121
- declare class JsonResource<R extends Resource = any> {
923
+ declare class JsonResource<R$1 extends Resource = any> {
122
924
  #private;
123
925
  protected event: H3Event;
124
926
  /**
@@ -132,7 +934,7 @@ declare class JsonResource<R extends Resource = any> {
132
934
  /**
133
935
  * The data to send to the client
134
936
  */
135
- resource: R;
937
+ resource: R$1;
136
938
  /**
137
939
  * The final response data object
138
940
  */
@@ -154,7 +956,7 @@ declare class JsonResource<R extends Resource = any> {
154
956
  * @param res The response instance
155
957
  * @param rsc The data to send to the client
156
958
  */
157
- constructor(event: H3Event, rsc: R);
959
+ constructor(event: H3Event, rsc: R$1);
158
960
  /**
159
961
  * Return the data in the expected format
160
962
  *
@@ -219,7 +1021,7 @@ declare class Response implements IResponse {
219
1021
  * Set a header.
220
1022
  */
221
1023
  setHeader(name: string, value: string): this;
222
- html(content: string): string;
1024
+ html(content: string): HTTPResponse;
223
1025
  /**
224
1026
  * Send a JSON response.
225
1027
  */
@@ -231,7 +1033,7 @@ declare class Response implements IResponse {
231
1033
  /**
232
1034
  * Redirect to another URL.
233
1035
  */
234
- redirect(url: string, status?: number): string;
1036
+ redirect(location: string, status?: number, statusText?: string | undefined): HTTPResponse;
235
1037
  /**
236
1038
  * Apply headers before sending response.
237
1039
  */
@@ -243,4 +1045,4 @@ declare class Response implements IResponse {
243
1045
  getEvent<K extends DotNestedKeys<H3Event>>(key: K): DotNestedValue<H3Event, K>;
244
1046
  }
245
1047
  //#endregion
246
- export { ApiResource, FireCommand, HttpContext, HttpServiceProvider, JsonResource, LogRequests, Middleware, Request, Resource, Response };
1048
+ export { ApiResource, BadRequestException, FileBag, FireCommand, FormRequest, HeaderBag, HttpContext, HttpServiceProvider, InputBag, JsonResource, LogRequests, Middleware, ParamBag, Request, RequestMethod, RequestObject, Resource, Response, ServerBag, SuspiciousOperationException, UnexpectedValueException, UploadedFile };