@h3ravel/shared 0.11.0 → 0.12.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @h3ravel/shared
2
2
 
3
+ ## 0.12.1
4
+
5
+ ### Patch Changes
6
+
7
+ - chore: regularize all interfaces.
8
+
9
+ ## 0.12.0
10
+
11
+ ### Minor Changes
12
+
13
+ - feat: add the current app instance to the Request and Response object
14
+
3
15
  ## 0.11.0
4
16
 
5
17
  ### Minor Changes
package/dist/index.d.cts CHANGED
@@ -103,17 +103,9 @@ type DotNestedValue<T, Path extends string> = Path extends `${infer Key}.${infer
103
103
  */
104
104
  interface IRequest {
105
105
  /**
106
- * Gets all input data (query parameters, route parameters, and body).
107
- * @returns A promise resolving to an object containing all input data.
108
- */
109
- all<T = Record<string, unknown>>(): Promise<T>;
110
- /**
111
- * Gets a single input field from query or body.
112
- * @param key - The key of the input field.
113
- * @param defaultValue - Optional default value if the key is not found.
114
- * @returns A promise resolving to the value of the input field or the default value.
106
+ * The current app instance
115
107
  */
116
- input<T = unknown>(key: string, defaultValue?: T): Promise<T>;
108
+ app: IApplication;
117
109
  /**
118
110
  * Gets route parameters.
119
111
  * @returns An object containing route parameters.
@@ -129,6 +121,18 @@ interface IRequest {
129
121
  * @returns An object containing request headers.
130
122
  */
131
123
  headers: TypedHeaders<Record<keyof ResponseHeaderMap, string>>;
124
+ /**
125
+ * Gets all input data (query parameters, route parameters, and body).
126
+ * @returns A promise resolving to an object containing all input data.
127
+ */
128
+ all<T = Record<string, unknown>>(): Promise<T>;
129
+ /**
130
+ * Gets a single input field from query or body.
131
+ * @param key - The key of the input field.
132
+ * @param defaultValue - Optional default value if the key is not found.
133
+ * @returns A promise resolving to the value of the input field or the default value.
134
+ */
135
+ input<T = unknown>(key: string, defaultValue?: T): Promise<T>;
132
136
  /**
133
137
  * Gets the underlying event object or a specific property of it.
134
138
  * @param key - Optional key to access a nested property of the event.
@@ -142,6 +146,10 @@ interface IRequest {
142
146
  * Interface for the Response contract, defining methods for handling HTTP responses.
143
147
  */
144
148
  interface IResponse {
149
+ /**
150
+ * The current app instance
151
+ */
152
+ app: IApplication;
145
153
  /**
146
154
  * Sets the HTTP status code for the response.
147
155
  * @param code - The HTTP status code.
package/dist/index.d.ts CHANGED
@@ -103,17 +103,9 @@ type DotNestedValue<T, Path extends string> = Path extends `${infer Key}.${infer
103
103
  */
104
104
  interface IRequest {
105
105
  /**
106
- * Gets all input data (query parameters, route parameters, and body).
107
- * @returns A promise resolving to an object containing all input data.
108
- */
109
- all<T = Record<string, unknown>>(): Promise<T>;
110
- /**
111
- * Gets a single input field from query or body.
112
- * @param key - The key of the input field.
113
- * @param defaultValue - Optional default value if the key is not found.
114
- * @returns A promise resolving to the value of the input field or the default value.
106
+ * The current app instance
115
107
  */
116
- input<T = unknown>(key: string, defaultValue?: T): Promise<T>;
108
+ app: IApplication;
117
109
  /**
118
110
  * Gets route parameters.
119
111
  * @returns An object containing route parameters.
@@ -129,6 +121,18 @@ interface IRequest {
129
121
  * @returns An object containing request headers.
130
122
  */
131
123
  headers: TypedHeaders<Record<keyof ResponseHeaderMap, string>>;
124
+ /**
125
+ * Gets all input data (query parameters, route parameters, and body).
126
+ * @returns A promise resolving to an object containing all input data.
127
+ */
128
+ all<T = Record<string, unknown>>(): Promise<T>;
129
+ /**
130
+ * Gets a single input field from query or body.
131
+ * @param key - The key of the input field.
132
+ * @param defaultValue - Optional default value if the key is not found.
133
+ * @returns A promise resolving to the value of the input field or the default value.
134
+ */
135
+ input<T = unknown>(key: string, defaultValue?: T): Promise<T>;
132
136
  /**
133
137
  * Gets the underlying event object or a specific property of it.
134
138
  * @param key - Optional key to access a nested property of the event.
@@ -142,6 +146,10 @@ interface IRequest {
142
146
  * Interface for the Response contract, defining methods for handling HTTP responses.
143
147
  */
144
148
  interface IResponse {
149
+ /**
150
+ * The current app instance
151
+ */
152
+ app: IApplication;
145
153
  /**
146
154
  * Sets the HTTP status code for the response.
147
155
  * @param code - The HTTP status code.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@h3ravel/shared",
3
- "version": "0.11.0",
3
+ "version": "0.12.1",
4
4
  "description": "Shared Utilities.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -2,24 +2,16 @@ import { DotNestedKeys, DotNestedValue } from './ObjContract'
2
2
  import type { ResponseHeaderMap, TypedHeaders } from 'fetchdts'
3
3
 
4
4
  import type { H3Event } from 'h3'
5
+ import type { IApplication } from './IApplication';
5
6
 
6
7
  /**
7
8
  * Interface for the Request contract, defining methods for handling HTTP request data.
8
9
  */
9
10
  export interface IRequest {
10
11
  /**
11
- * Gets all input data (query parameters, route parameters, and body).
12
- * @returns A promise resolving to an object containing all input data.
12
+ * The current app instance
13
13
  */
14
- all<T = Record<string, unknown>> (): Promise<T>;
15
-
16
- /**
17
- * Gets a single input field from query or body.
18
- * @param key - The key of the input field.
19
- * @param defaultValue - Optional default value if the key is not found.
20
- * @returns A promise resolving to the value of the input field or the default value.
21
- */
22
- input<T = unknown> (key: string, defaultValue?: T): Promise<T>;
14
+ app: IApplication
23
15
 
24
16
  /**
25
17
  * Gets route parameters.
@@ -39,6 +31,20 @@ export interface IRequest {
39
31
  */
40
32
  headers: TypedHeaders<Record<keyof ResponseHeaderMap, string>>;
41
33
 
34
+ /**
35
+ * Gets all input data (query parameters, route parameters, and body).
36
+ * @returns A promise resolving to an object containing all input data.
37
+ */
38
+ all<T = Record<string, unknown>> (): Promise<T>;
39
+
40
+ /**
41
+ * Gets a single input field from query or body.
42
+ * @param key - The key of the input field.
43
+ * @param defaultValue - Optional default value if the key is not found.
44
+ * @returns A promise resolving to the value of the input field or the default value.
45
+ */
46
+ input<T = unknown> (key: string, defaultValue?: T): Promise<T>;
47
+
42
48
  /**
43
49
  * Gets the underlying event object or a specific property of it.
44
50
  * @param key - Optional key to access a nested property of the event.
@@ -1,11 +1,17 @@
1
1
  import { DotNestedKeys, DotNestedValue } from './ObjContract'
2
2
 
3
3
  import type { H3Event } from 'h3'
4
+ import type { IApplication } from './IApplication';
4
5
 
5
6
  /**
6
7
  * Interface for the Response contract, defining methods for handling HTTP responses.
7
8
  */
8
9
  export interface IResponse {
10
+ /**
11
+ * The current app instance
12
+ */
13
+ app: IApplication
14
+
9
15
  /**
10
16
  * Sets the HTTP status code for the response.
11
17
  * @param code - The HTTP status code.