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