@h3ravel/shared 0.9.0 → 0.10.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @h3ravel/shared
2
2
 
3
+ ## 0.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - feat: hide RouterEnd from itslelf to prevent unintentional chaining.
8
+
3
9
  ## 0.9.0
4
10
 
5
11
  ### Minor Changes
package/dist/index.d.cts CHANGED
@@ -189,6 +189,7 @@ interface IResponse {
189
189
  getEvent<K extends DotNestedKeys<H3Event>>(key: K): DotNestedValue<H3Event, K>;
190
190
  }
191
191
 
192
+ type RouterEnd = 'get' | 'delete' | 'put' | 'post' | 'apiResource' | 'name' | 'group' | 'route';
192
193
  /**
193
194
  * Interface for the Router contract, defining methods for HTTP routing.
194
195
  */
@@ -200,7 +201,7 @@ interface IRouter {
200
201
  * @param name - Optional route name.
201
202
  * @param middleware - Optional middleware array.
202
203
  */
203
- get(path: string, definition: EventHandler | [(new (...args: any[]) => IController), methodName: string], name?: string, middleware?: IMiddleware[]): this;
204
+ get(path: string, definition: EventHandler | [(new (...args: any[]) => IController), methodName: string], name?: string, middleware?: IMiddleware[]): Omit<this, RouterEnd>;
204
205
  /**
205
206
  * Registers a POST route.
206
207
  * @param path - The route path.
@@ -208,7 +209,7 @@ interface IRouter {
208
209
  * @param name - Optional route name.
209
210
  * @param middleware - Optional middleware array.
210
211
  */
211
- post(path: string, definition: EventHandler | [(new (...args: any[]) => IController), methodName: string], name?: string, middleware?: IMiddleware[]): this;
212
+ post(path: string, definition: EventHandler | [(new (...args: any[]) => IController), methodName: string], name?: string, middleware?: IMiddleware[]): Omit<this, RouterEnd>;
212
213
  /**
213
214
  * Registers a PUT route.
214
215
  * @param path - The route path.
@@ -216,7 +217,7 @@ interface IRouter {
216
217
  * @param name - Optional route name.
217
218
  * @param middleware - Optional middleware array.
218
219
  */
219
- put(path: string, definition: EventHandler | [(new (...args: any[]) => IController), methodName: string], name?: string, middleware?: IMiddleware[]): this;
220
+ put(path: string, definition: EventHandler | [(new (...args: any[]) => IController), methodName: string], name?: string, middleware?: IMiddleware[]): Omit<this, RouterEnd>;
220
221
  /**
221
222
  * Registers a DELETE route.
222
223
  * @param path - The route path.
@@ -224,14 +225,14 @@ interface IRouter {
224
225
  * @param name - Optional route name.
225
226
  * @param middleware - Optional middleware array.
226
227
  */
227
- delete(path: string, definition: EventHandler | [(new (...args: any[]) => IController), methodName: string], name?: string, middleware?: IMiddleware[]): this;
228
+ delete(path: string, definition: EventHandler | [(new (...args: any[]) => IController), methodName: string], name?: string, middleware?: IMiddleware[]): Omit<this, RouterEnd>;
228
229
  /**
229
230
  * Registers an API resource with standard CRUD routes.
230
231
  * @param path - The base path for the resource.
231
232
  * @param controller - The controller class handling the resource.
232
233
  * @param middleware - Optional middleware array.
233
234
  */
234
- apiResource(path: string, controller: new (app: IApplication) => IController, middleware?: IMiddleware[]): this;
235
+ apiResource(path: string, controller: new (app: IApplication) => IController, middleware?: IMiddleware[]): Omit<this, RouterEnd>;
235
236
  /**
236
237
  * Generates a URL for a named route.
237
238
  * @param name - The name of the route.
@@ -289,4 +290,4 @@ interface IMiddleware {
289
290
  handle(context: HttpContext, next: () => Promise<any>): Promise<any>;
290
291
  }
291
292
 
292
- export type { DotFlatten, DotNestedKeys, DotNestedValue, EventHandler, HttpContext, IApplication, IController, IMiddleware, IPathName, IRequest, IResponse, IRouter, IServiceProvider };
293
+ export type { DotFlatten, DotNestedKeys, DotNestedValue, EventHandler, HttpContext, IApplication, IController, IMiddleware, IPathName, IRequest, IResponse, IRouter, IServiceProvider, RouterEnd };
package/dist/index.d.ts CHANGED
@@ -189,6 +189,7 @@ interface IResponse {
189
189
  getEvent<K extends DotNestedKeys<H3Event>>(key: K): DotNestedValue<H3Event, K>;
190
190
  }
191
191
 
192
+ type RouterEnd = 'get' | 'delete' | 'put' | 'post' | 'apiResource' | 'name' | 'group' | 'route';
192
193
  /**
193
194
  * Interface for the Router contract, defining methods for HTTP routing.
194
195
  */
@@ -200,7 +201,7 @@ interface IRouter {
200
201
  * @param name - Optional route name.
201
202
  * @param middleware - Optional middleware array.
202
203
  */
203
- get(path: string, definition: EventHandler | [(new (...args: any[]) => IController), methodName: string], name?: string, middleware?: IMiddleware[]): this;
204
+ get(path: string, definition: EventHandler | [(new (...args: any[]) => IController), methodName: string], name?: string, middleware?: IMiddleware[]): Omit<this, RouterEnd>;
204
205
  /**
205
206
  * Registers a POST route.
206
207
  * @param path - The route path.
@@ -208,7 +209,7 @@ interface IRouter {
208
209
  * @param name - Optional route name.
209
210
  * @param middleware - Optional middleware array.
210
211
  */
211
- post(path: string, definition: EventHandler | [(new (...args: any[]) => IController), methodName: string], name?: string, middleware?: IMiddleware[]): this;
212
+ post(path: string, definition: EventHandler | [(new (...args: any[]) => IController), methodName: string], name?: string, middleware?: IMiddleware[]): Omit<this, RouterEnd>;
212
213
  /**
213
214
  * Registers a PUT route.
214
215
  * @param path - The route path.
@@ -216,7 +217,7 @@ interface IRouter {
216
217
  * @param name - Optional route name.
217
218
  * @param middleware - Optional middleware array.
218
219
  */
219
- put(path: string, definition: EventHandler | [(new (...args: any[]) => IController), methodName: string], name?: string, middleware?: IMiddleware[]): this;
220
+ put(path: string, definition: EventHandler | [(new (...args: any[]) => IController), methodName: string], name?: string, middleware?: IMiddleware[]): Omit<this, RouterEnd>;
220
221
  /**
221
222
  * Registers a DELETE route.
222
223
  * @param path - The route path.
@@ -224,14 +225,14 @@ interface IRouter {
224
225
  * @param name - Optional route name.
225
226
  * @param middleware - Optional middleware array.
226
227
  */
227
- delete(path: string, definition: EventHandler | [(new (...args: any[]) => IController), methodName: string], name?: string, middleware?: IMiddleware[]): this;
228
+ delete(path: string, definition: EventHandler | [(new (...args: any[]) => IController), methodName: string], name?: string, middleware?: IMiddleware[]): Omit<this, RouterEnd>;
228
229
  /**
229
230
  * Registers an API resource with standard CRUD routes.
230
231
  * @param path - The base path for the resource.
231
232
  * @param controller - The controller class handling the resource.
232
233
  * @param middleware - Optional middleware array.
233
234
  */
234
- apiResource(path: string, controller: new (app: IApplication) => IController, middleware?: IMiddleware[]): this;
235
+ apiResource(path: string, controller: new (app: IApplication) => IController, middleware?: IMiddleware[]): Omit<this, RouterEnd>;
235
236
  /**
236
237
  * Generates a URL for a named route.
237
238
  * @param name - The name of the route.
@@ -289,4 +290,4 @@ interface IMiddleware {
289
290
  handle(context: HttpContext, next: () => Promise<any>): Promise<any>;
290
291
  }
291
292
 
292
- export type { DotFlatten, DotNestedKeys, DotNestedValue, EventHandler, HttpContext, IApplication, IController, IMiddleware, IPathName, IRequest, IResponse, IRouter, IServiceProvider };
293
+ export type { DotFlatten, DotNestedKeys, DotNestedValue, EventHandler, HttpContext, IApplication, IController, IMiddleware, IPathName, IRequest, IResponse, IRouter, IServiceProvider, RouterEnd };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@h3ravel/shared",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "Shared Utilities.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -4,6 +4,8 @@ import { IApplication } from './IApplication'
4
4
  import { IRequest } from './IRequest'
5
5
  import { IResponse } from './IResponse'
6
6
 
7
+ export type RouterEnd = 'get' | 'delete' | 'put' | 'post' | 'apiResource' | 'name' | 'group' | 'route';
8
+
7
9
  /**
8
10
  * Interface for the Router contract, defining methods for HTTP routing.
9
11
  */
@@ -20,7 +22,7 @@ export interface IRouter {
20
22
  definition: EventHandler | [(new (...args: any[]) => IController), methodName: string],
21
23
  name?: string,
22
24
  middleware?: IMiddleware[]
23
- ): this;
25
+ ): Omit<this, RouterEnd>;
24
26
 
25
27
  /**
26
28
  * Registers a POST route.
@@ -34,7 +36,7 @@ export interface IRouter {
34
36
  definition: EventHandler | [(new (...args: any[]) => IController), methodName: string],
35
37
  name?: string,
36
38
  middleware?: IMiddleware[]
37
- ): this;
39
+ ): Omit<this, RouterEnd>;
38
40
 
39
41
  /**
40
42
  * Registers a PUT route.
@@ -48,7 +50,7 @@ export interface IRouter {
48
50
  definition: EventHandler | [(new (...args: any[]) => IController), methodName: string],
49
51
  name?: string,
50
52
  middleware?: IMiddleware[]
51
- ): this;
53
+ ): Omit<this, RouterEnd>;
52
54
 
53
55
  /**
54
56
  * Registers a DELETE route.
@@ -62,7 +64,7 @@ export interface IRouter {
62
64
  definition: EventHandler | [(new (...args: any[]) => IController), methodName: string],
63
65
  name?: string,
64
66
  middleware?: IMiddleware[]
65
- ): this;
67
+ ): Omit<this, RouterEnd>;
66
68
 
67
69
  /**
68
70
  * Registers an API resource with standard CRUD routes.
@@ -74,7 +76,7 @@ export interface IRouter {
74
76
  path: string,
75
77
  controller: new (app: IApplication) => IController,
76
78
  middleware?: IMiddleware[]
77
- ): this;
79
+ ): Omit<this, RouterEnd>;
78
80
 
79
81
  /**
80
82
  * Generates a URL for a named route.