@h3ravel/http 11.0.0 → 11.1.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.
package/dist/index.d.ts CHANGED
@@ -1,18 +1,21 @@
1
- import { IMiddleware, HttpContext, IRequest, IResponse } from '@h3ravel/shared';
2
- export { HttpContext } from '@h3ravel/shared';
3
- import { ServiceProvider, Application } from '@h3ravel/core';
4
- import { H3Event, EventHandlerRequest } from 'h3';
5
- import { DotNestedKeys, DotNestedValue } from '@h3ravel/support';
6
- import { TypedHeaders, ResponseHeaderMap } from 'fetchdts';
1
+ import { DotNestedKeys, DotNestedValue, HttpContext, HttpContext as HttpContext$1, IMiddleware, IRequest, IResponse } from "@h3ravel/shared";
2
+ import { EventHandlerRequest, H3Event } from "h3";
3
+ import { Application, ServiceProvider } from "@h3ravel/core";
4
+ import { ResponseHeaderMap, TypedHeaders } from "fetchdts";
7
5
 
6
+ //#region src/Middleware.d.ts
8
7
  declare abstract class Middleware implements IMiddleware {
9
- abstract handle(context: HttpContext, next: () => Promise<unknown>): Promise<unknown>;
8
+ abstract handle(context: HttpContext, next: () => Promise<unknown>): Promise<unknown>;
10
9
  }
11
-
10
+ //#endregion
11
+ //#region src/Middleware/LogRequests.d.ts
12
12
  declare class LogRequests extends Middleware {
13
- handle({ request }: HttpContext, next: () => Promise<unknown>): Promise<unknown>;
13
+ handle({
14
+ request
15
+ }: HttpContext$1, next: () => Promise<unknown>): Promise<unknown>;
14
16
  }
15
-
17
+ //#endregion
18
+ //#region src/Providers/HttpServiceProvider.d.ts
16
19
  /**
17
20
  * Sets up HTTP kernel and request lifecycle.
18
21
  *
@@ -23,193 +26,198 @@ declare class LogRequests extends Middleware {
23
26
  * Auto-Registered
24
27
  */
25
28
  declare class HttpServiceProvider extends ServiceProvider {
26
- static priority: number;
27
- register(): void;
29
+ static priority: number;
30
+ register(): void;
28
31
  }
29
-
32
+ //#endregion
33
+ //#region src/Request.d.ts
30
34
  declare class Request implements IRequest {
31
- /**
32
- * The current app instance
33
- */
34
- app: Application;
35
- /**
36
- * Gets route parameters.
37
- * @returns An object containing route parameters.
38
- */
39
- readonly params: NonNullable<H3Event["context"]["params"]>;
40
- /**
41
- * Gets query parameters.
42
- * @returns An object containing query parameters.
43
- */
44
- readonly query: Record<string, string>;
45
- /**
46
- * Gets the request headers.
47
- * @returns An object containing request headers.
48
- */
49
- readonly headers: TypedHeaders<Record<keyof ResponseHeaderMap, string>>;
50
- /**
51
- * The current H3 H3Event instance
52
- */
53
- private readonly event;
54
- constructor(event: H3Event,
55
- /**
56
- * The current app instance
57
- */
58
- app: Application);
59
- /**
60
- * Get all input data (query + body).
61
- */
62
- all<T = Record<string, unknown>>(): Promise<T>;
63
- /**
64
- * Get a single input field from query or body.
65
- */
66
- input<T = unknown>(key: string, defaultValue?: T): Promise<T>;
67
- /**
68
- * Get the base event
69
- */
70
- getEvent(): H3Event;
71
- getEvent<K extends DotNestedKeys<H3Event>>(key: K): DotNestedValue<H3Event, K>;
35
+ /**
36
+ * The current app instance
37
+ */
38
+ app: Application;
39
+ /**
40
+ * Gets route parameters.
41
+ * @returns An object containing route parameters.
42
+ */
43
+ readonly params: NonNullable<H3Event["context"]["params"]>;
44
+ /**
45
+ * Gets query parameters.
46
+ * @returns An object containing query parameters.
47
+ */
48
+ readonly query: Record<string, string>;
49
+ /**
50
+ * Gets the request headers.
51
+ * @returns An object containing request headers.
52
+ */
53
+ readonly headers: TypedHeaders<Record<keyof ResponseHeaderMap, string>>;
54
+ /**
55
+ * The current H3 H3Event instance
56
+ */
57
+ private readonly event;
58
+ constructor(event: H3Event,
59
+ /**
60
+ * The current app instance
61
+ */
62
+ app: Application);
63
+ /**
64
+ * Get all input data (query + body).
65
+ */
66
+ all<T = Record<string, unknown>>(): Promise<T>;
67
+ /**
68
+ * Get a single input field from query or body.
69
+ */
70
+ input<T = unknown>(key: string, defaultValue?: T): Promise<T>;
71
+ /**
72
+ * Get the base event
73
+ */
74
+ getEvent(): H3Event;
75
+ getEvent<K extends DotNestedKeys<H3Event>>(key: K): DotNestedValue<H3Event, K>;
72
76
  }
73
-
77
+ //#endregion
78
+ //#region src/Resources/JsonResource.d.ts
74
79
  interface Resource {
75
- [key: string]: any;
76
- pagination?: {
77
- from?: number | undefined;
78
- to?: number | undefined;
79
- perPage?: number | undefined;
80
- total?: number | undefined;
81
- } | undefined;
80
+ [key: string]: any;
81
+ pagination?: {
82
+ from?: number | undefined;
83
+ to?: number | undefined;
84
+ perPage?: number | undefined;
85
+ total?: number | undefined;
86
+ } | undefined;
82
87
  }
83
88
  type BodyResource = Resource & {
84
- data: Omit<Resource, 'pagination'>;
85
- meta?: {
86
- pagination?: Resource['pagination'];
87
- } | undefined;
89
+ data: Omit<Resource, 'pagination'>;
90
+ meta?: {
91
+ pagination?: Resource['pagination'];
92
+ } | undefined;
88
93
  };
89
94
  /**
90
95
  * Class to render API resource
91
96
  */
92
97
  declare class JsonResource<R extends Resource = any> {
93
- #private;
94
- protected event: H3Event;
95
- /**
96
- * The request instance
97
- */
98
- request: H3Event<EventHandlerRequest>['req'];
99
- /**
100
- * The response instance
101
- */
102
- response: H3Event['res'];
103
- /**
104
- * The data to send to the client
105
- */
106
- resource: R;
107
- /**
108
- * The final response data object
109
- */
110
- body: BodyResource;
111
- /**
112
- * Flag to track if response should be sent automatically
113
- */
114
- private shouldSend;
115
- /**
116
- * Flag to track if response has been sent
117
- */
118
- private responseSent;
119
- /**
120
- * Declare that this includes R's properties
121
- */
98
+ #private;
99
+ protected event: H3Event;
100
+ /**
101
+ * The request instance
102
+ */
103
+ request: H3Event<EventHandlerRequest>['req'];
104
+ /**
105
+ * The response instance
106
+ */
107
+ response: H3Event['res'];
108
+ /**
109
+ * The data to send to the client
110
+ */
111
+ resource: R;
112
+ /**
113
+ * The final response data object
114
+ */
115
+ body: BodyResource;
116
+ /**
117
+ * Flag to track if response should be sent automatically
118
+ */
119
+ private shouldSend;
120
+ /**
121
+ * Flag to track if response has been sent
122
+ */
123
+ private responseSent;
124
+ /**
125
+ * Declare that this includes R's properties
126
+ */
127
+ [key: string]: any;
128
+ /**
129
+ * @param req The request instance
130
+ * @param res The response instance
131
+ * @param rsc The data to send to the client
132
+ */
133
+ constructor(event: H3Event, rsc: R);
134
+ /**
135
+ * Return the data in the expected format
136
+ *
137
+ * @returns
138
+ */
139
+ data(): Resource;
140
+ /**
141
+ * Build the response object
142
+ * @returns this
143
+ */
144
+ json(): this;
145
+ /**
146
+ * Add context data to the response object
147
+ * @param data Context data
148
+ * @returns this
149
+ */
150
+ additional<X extends {
122
151
  [key: string]: any;
123
- /**
124
- * @param req The request instance
125
- * @param res The response instance
126
- * @param rsc The data to send to the client
127
- */
128
- constructor(event: H3Event, rsc: R);
129
- /**
130
- * Return the data in the expected format
131
- *
132
- * @returns
133
- */
134
- data(): Resource;
135
- /**
136
- * Build the response object
137
- * @returns this
138
- */
139
- json(): this;
140
- /**
141
- * Add context data to the response object
142
- * @param data Context data
143
- * @returns this
144
- */
145
- additional<X extends {
146
- [key: string]: any;
147
- }>(data: X): this;
148
- /**
149
- * Send the output to the client
150
- * @returns this
151
- */
152
- send(): this;
153
- /**
154
- * Set the status code for this response
155
- * @param code Status code
156
- * @returns this
157
- */
158
- status(code: number): this;
159
- /**
160
- * Check if send should be triggered automatically
161
- */
162
- private checkSend;
152
+ }>(data: X): this;
153
+ /**
154
+ * Send the output to the client
155
+ * @returns this
156
+ */
157
+ send(): this;
158
+ /**
159
+ * Set the status code for this response
160
+ * @param code Status code
161
+ * @returns this
162
+ */
163
+ status(code: number): this;
164
+ /**
165
+ * Check if send should be triggered automatically
166
+ */
167
+ private checkSend;
163
168
  }
164
-
169
+ //#endregion
170
+ //#region src/Resources/ApiResource.d.ts
165
171
  declare function ApiResource(instance: JsonResource): JsonResource<any>;
166
-
172
+ //#endregion
173
+ //#region src/Response.d.ts
167
174
  declare class Response implements IResponse {
168
- /**
169
- * The current app instance
170
- */
171
- app: Application;
172
- /**
173
- * The current H3 H3Event instance
174
- */
175
- private readonly event;
176
- private statusCode;
177
- private headers;
178
- constructor(event: H3Event,
179
- /**
180
- * The current app instance
181
- */
182
- app: Application);
183
- /**
184
- * Set HTTP status code.
185
- */
186
- setStatusCode(code: number): this;
187
- /**
188
- * Set a header.
189
- */
190
- setHeader(name: string, value: string): this;
191
- html(content: string): string;
192
- /**
193
- * Send a JSON response.
194
- */
195
- json<T = unknown>(data: T): T;
196
- /**
197
- * Send plain text.
198
- */
199
- text(data: string): string;
200
- /**
201
- * Redirect to another URL.
202
- */
203
- redirect(url: string, status?: number): string;
204
- /**
205
- * Apply headers before sending response.
206
- */
207
- private applyHeaders;
208
- /**
209
- * Get the base event
210
- */
211
- getEvent(): H3Event;
212
- getEvent<K extends DotNestedKeys<H3Event>>(key: K): DotNestedValue<H3Event, K>;
175
+ /**
176
+ * The current app instance
177
+ */
178
+ app: Application;
179
+ /**
180
+ * The current H3 H3Event instance
181
+ */
182
+ private readonly event;
183
+ private statusCode;
184
+ private headers;
185
+ constructor(event: H3Event,
186
+ /**
187
+ * The current app instance
188
+ */
189
+ app: Application);
190
+ /**
191
+ * Set HTTP status code.
192
+ */
193
+ setStatusCode(code: number): this;
194
+ /**
195
+ * Set a header.
196
+ */
197
+ setHeader(name: string, value: string): this;
198
+ html(content: string): string;
199
+ /**
200
+ * Send a JSON response.
201
+ */
202
+ json<T = unknown>(data: T): T;
203
+ /**
204
+ * Send plain text.
205
+ */
206
+ text(data: string): string;
207
+ /**
208
+ * Redirect to another URL.
209
+ */
210
+ redirect(url: string, status?: number): string;
211
+ /**
212
+ * Apply headers before sending response.
213
+ */
214
+ private applyHeaders;
215
+ /**
216
+ * Get the base event
217
+ */
218
+ getEvent(): H3Event;
219
+ getEvent<K extends DotNestedKeys<H3Event>>(key: K): DotNestedValue<H3Event, K>;
213
220
  }
214
-
215
- export { ApiResource, HttpServiceProvider, JsonResource, LogRequests, Middleware, Request, type Resource, Response };
221
+ //#endregion
222
+ export { ApiResource, HttpContext, HttpServiceProvider, JsonResource, LogRequests, Middleware, Request, Resource, Response };
223
+ //# sourceMappingURL=index.d.ts.map