@adonisjs/http-server 8.0.0-next.0 → 8.0.0-next.2

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.
Files changed (54) hide show
  1. package/build/{chunk-VYBTM3NC.js → chunk-Z5EN426L.js} +141 -192
  2. package/build/factories/http_context.d.ts +3 -3
  3. package/build/factories/main.d.ts +6 -6
  4. package/build/factories/main.js +1 -1
  5. package/build/factories/qs_parser_factory.d.ts +2 -2
  6. package/build/factories/request.d.ts +2 -2
  7. package/build/factories/response.d.ts +3 -3
  8. package/build/factories/router.d.ts +1 -1
  9. package/build/factories/server_factory.d.ts +2 -2
  10. package/build/factories/url_builder_factory.d.ts +3 -3
  11. package/build/index.d.ts +16 -16
  12. package/build/index.js +1 -1
  13. package/build/src/cookies/serializer.d.ts +1 -1
  14. package/build/src/define_config.d.ts +1 -1
  15. package/build/src/define_middleware.d.ts +1 -1
  16. package/build/src/errors.d.ts +7 -5
  17. package/build/src/exception_handler.d.ts +2 -2
  18. package/build/src/helpers.d.ts +3 -4
  19. package/build/src/http_context/local_storage.d.ts +1 -1
  20. package/build/src/http_context/main.d.ts +3 -3
  21. package/build/src/qs.d.ts +1 -1
  22. package/build/src/redirect.d.ts +4 -5
  23. package/build/src/request.d.ts +3 -3
  24. package/build/src/response.d.ts +5 -5
  25. package/build/src/router/brisk.d.ts +4 -4
  26. package/build/src/router/executor.d.ts +3 -3
  27. package/build/src/router/factories/use_return_value.d.ts +1 -1
  28. package/build/src/router/group.d.ts +5 -5
  29. package/build/src/router/legacy/url_builder.d.ts +1 -1
  30. package/build/src/router/main.d.ts +61 -17
  31. package/build/src/router/resource.d.ts +3 -4
  32. package/build/src/router/route.d.ts +2 -3
  33. package/build/src/router/signed_url_builder.d.ts +4 -3
  34. package/build/src/router/store.d.ts +1 -2
  35. package/build/src/{client → router}/url_builder.d.ts +4 -3
  36. package/build/src/server/factories/middleware_handler.d.ts +2 -2
  37. package/build/src/server/factories/route_finder.d.ts +3 -3
  38. package/build/src/server/factories/write_response.d.ts +1 -1
  39. package/build/src/server/main.d.ts +6 -6
  40. package/build/src/tracing_channels.d.ts +1 -1
  41. package/build/src/types/main.d.ts +1 -1
  42. package/build/src/types/middleware.d.ts +1 -1
  43. package/build/src/types/route.d.ts +19 -17
  44. package/build/src/types/server.d.ts +4 -4
  45. package/build/src/types/tracing_channels.d.ts +3 -3
  46. package/build/src/{client/types.d.ts → types/url_builder.d.ts} +16 -50
  47. package/build/src/utils.d.ts +5 -5
  48. package/package.json +9 -14
  49. package/build/client.cjs +0 -232
  50. package/build/client.d.cts +0 -258
  51. package/build/client.d.ts +0 -258
  52. package/build/client.js +0 -229
  53. package/build/src/client/main.d.ts +0 -3
  54. package/build/src/client/router.d.ts +0 -68
@@ -3,14 +3,14 @@
3
3
  */
4
4
  import { type Prettify } from '@poppinss/utils/types';
5
5
  /**
6
- * Options accepted by "url" and "route" helper methods
6
+ * Options accepted by "urlFor" helper
7
7
  */
8
8
  export type URLOptions = {
9
9
  qs?: Record<string, any>;
10
10
  prefixUrl?: string;
11
11
  };
12
12
  /**
13
- * Options accepted by "signedUrl" and "signedRoute" helper methods
13
+ * Options accepted by "signedUrlFor" helper
14
14
  */
15
15
  export type SignedURLOptions = URLOptions & {
16
16
  expiresIn?: string | number;
@@ -19,7 +19,7 @@ export type SignedURLOptions = URLOptions & {
19
19
  /**
20
20
  * Returns params for a route identifier
21
21
  */
22
- export type RouteBuilderArguments<Routes, Method extends keyof Routes, Identifier extends keyof Routes[Method], Options extends any = URLOptions> = Routes extends LookupList ? Prettify<undefined extends Routes[Method][Identifier]['params'] ? [identifier: Identifier, params?: undefined, options?: Options] : [undefined] extends [Routes[Method][Identifier]['params']] ? [
22
+ export type RouteBuilderArguments<Routes, Method extends keyof Routes, Identifier extends keyof Routes[Method], Options extends any = URLOptions> = Routes extends LookupList ? Prettify<Routes[Method][Identifier]['params'] extends undefined ? [identifier: Identifier, params?: undefined, options?: Options] : [undefined] extends [Routes[Method][Identifier]['params']] ? [
23
23
  identifier: Identifier,
24
24
  params?: Routes[Method][Identifier]['params'] | Routes[Method][Identifier]['paramsTuple'],
25
25
  options?: Options
@@ -28,53 +28,6 @@ export type RouteBuilderArguments<Routes, Method extends keyof Routes, Identifie
28
28
  params: Routes[Method][Identifier]['params'] | Routes[Method][Identifier]['paramsTuple'],
29
29
  options?: Options
30
30
  ]> : never;
31
- /**
32
- * Shape of a route param matcher
33
- */
34
- export type RouteMatcher = {
35
- match?: RegExp;
36
- cast?: (value: string) => any;
37
- };
38
- /**
39
- * Route token stored by matchit library
40
- */
41
- export type MatchItRouteToken = RouteMatcher & {
42
- old: string;
43
- type: 0 | 1 | 2 | 3;
44
- val: string;
45
- end: string;
46
- };
47
- /**
48
- * Representation of route shared with the client
49
- */
50
- export type ClientRouteJSON = {
51
- /**
52
- * A unique name for the route
53
- */
54
- name?: string;
55
- /**
56
- * Route URI pattern
57
- */
58
- pattern: string;
59
- /**
60
- * HTTP methods, the route responds to.
61
- */
62
- methods: string[];
63
- /**
64
- * Route domain
65
- */
66
- domain: string;
67
- /**
68
- * Reference to the route handler
69
- */
70
- handler: {
71
- reference?: any;
72
- } | Function;
73
- /**
74
- * Tokens to be used to construct the route URL
75
- */
76
- tokens: MatchItRouteToken[];
77
- };
78
31
  /**
79
32
  * LookupList type is used by the URLBuilder to provide
80
33
  * type-safety when creating URLs.
@@ -179,3 +132,16 @@ export type UrlFor<Routes extends LookupList, Options extends any = URLOptions>
179
132
  url: string;
180
133
  };
181
134
  };
135
+ /**
136
+ * To be generated by the router and used by the URL builder
137
+ * and the LookupStore
138
+ */
139
+ export interface RoutesList {
140
+ }
141
+ /**
142
+ * Helper to get routes for a given method from the RoutesList. The
143
+ * RoutesList is extended in the userland code.
144
+ */
145
+ export type GetRoutesForMethod<Method> = {
146
+ [K in keyof RoutesList]: Method extends K ? RoutesList[Method] : never;
147
+ };
@@ -1,8 +1,8 @@
1
- import { type Route } from './router/route.js';
2
- import { RouteGroup } from './router/group.js';
3
- import { BriskRoute } from './router/brisk.js';
4
- import type { RouteJSON } from './types/route.js';
5
- import { RouteResource } from './router/resource.js';
1
+ import { type Route } from './router/route.ts';
2
+ import { RouteGroup } from './router/group.ts';
3
+ import { BriskRoute } from './router/brisk.ts';
4
+ import type { RouteJSON } from './types/route.ts';
5
+ import { RouteResource } from './router/resource.ts';
6
6
  /**
7
7
  * Makes input string consistent by having only the starting
8
8
  * slash
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adonisjs/http-server",
3
- "version": "8.0.0-next.0",
3
+ "version": "8.0.0-next.2",
4
4
  "description": "AdonisJS HTTP server with support packed with Routing and Cookies",
5
5
  "main": "build/index.js",
6
6
  "type": "module",
@@ -13,10 +13,6 @@
13
13
  ".": "./build/index.js",
14
14
  "./helpers": "./build/src/helpers.js",
15
15
  "./types": "./build/src/types/main.js",
16
- "./client": {
17
- "import": "./build/client.js",
18
- "require": "./build/client.cjs"
19
- },
20
16
  "./factories": "./build/factories/main.js"
21
17
  },
22
18
  "engines": {
@@ -28,8 +24,7 @@
28
24
  "typecheck": "tsc --noEmit",
29
25
  "precompile": "npm run lint",
30
26
  "compile": "tsup-node && tsc --emitDeclarationOnly --declaration",
31
- "compile:client": "tsup-node --config=bin/build_client.ts",
32
- "build": "npm run compile && npm run compile:client",
27
+ "build": "npm run compile",
33
28
  "prebenchmark": "npm run build",
34
29
  "benchmark": "node benchmarks/index.js",
35
30
  "release": "release-it",
@@ -58,9 +53,9 @@
58
53
  "@japa/assert": "^4.1.1",
59
54
  "@japa/expect-type": "^2.0.3",
60
55
  "@japa/file-system": "^2.3.2",
61
- "@japa/runner": "^4.3.0",
56
+ "@japa/runner": "^4.4.0",
62
57
  "@japa/snapshot": "^2.0.9",
63
- "@poppinss/ts-exec": "^1.4.0",
58
+ "@poppinss/ts-exec": "^1.4.1",
64
59
  "@release-it/conventional-changelog": "^10.0.1",
65
60
  "@types/accepts": "^1.3.7",
66
61
  "@types/content-disposition": "^0.5.9",
@@ -70,7 +65,7 @@
70
65
  "@types/fresh": "^0.5.3",
71
66
  "@types/fs-extra": "^11.0.4",
72
67
  "@types/mime-types": "^3.0.1",
73
- "@types/node": "^24.1.0",
68
+ "@types/node": "^24.3.0",
74
69
  "@types/on-finished": "^2.3.5",
75
70
  "@types/pem": "^1.14.4",
76
71
  "@types/proxy-addr": "^2.0.3",
@@ -82,9 +77,9 @@
82
77
  "autocannon": "^8.0.0",
83
78
  "c8": "^10.1.3",
84
79
  "cross-env": "^10.0.0",
85
- "eslint": "^9.32.0",
86
- "fastify": "^5.4.0",
87
- "fs-extra": "^11.3.0",
80
+ "eslint": "^9.34.0",
81
+ "fastify": "^5.5.0",
82
+ "fs-extra": "^11.3.1",
88
83
  "get-port": "^7.1.0",
89
84
  "http-status-codes": "^2.3.0",
90
85
  "pem": "^1.14.8",
@@ -93,7 +88,7 @@
93
88
  "release-it": "^19.0.4",
94
89
  "supertest": "^7.1.4",
95
90
  "tsup": "^8.5.0",
96
- "typescript": "^5.8.3",
91
+ "typescript": "^5.9.2",
97
92
  "youch": "^4.1.0-beta.11"
98
93
  },
99
94
  "dependencies": {
package/build/client.cjs DELETED
@@ -1,232 +0,0 @@
1
- 'use strict';
2
-
3
- // src/client/router.ts
4
- var RouterClient = class {
5
- /**
6
- * List of route references kept for lookup.
7
- */
8
- routes;
9
- /**
10
- * The lookup strategies to follow when generating URL builder
11
- * types and client
12
- */
13
- lookupStrategies = ["name", "pattern"];
14
- constructor(routes) {
15
- this.routes = routes ?? {};
16
- }
17
- /**
18
- * Register route JSON payload
19
- */
20
- register(route) {
21
- this.routes[route.domain] = this.routes[route.domain] || [];
22
- this.routes[route.domain].push(route);
23
- }
24
- /**
25
- * Define the lookup strategies to follow when generating URL builder
26
- * types and client.
27
- */
28
- updateLookupStrategies(strategies) {
29
- this.lookupStrategies = strategies;
30
- return this;
31
- }
32
- /**
33
- * Finds a route by its identifier. The identifier can be the
34
- * route name, controller.method name or the route pattern
35
- * itself.
36
- *
37
- * When "followLookupStrategy" is enabled, the lookup will be performed
38
- * on the basis of the lookup strategy enabled via the "lookupStrategies"
39
- * method. The default lookupStrategy is "name" and "pattern".
40
- */
41
- find(routeIdentifier, domain, method, followLookupStrategy) {
42
- if (!domain) {
43
- let route = null;
44
- for (const routeDomain of Object.keys(this.routes)) {
45
- route = this.find(routeIdentifier, routeDomain, method, followLookupStrategy);
46
- if (route) {
47
- break;
48
- }
49
- }
50
- return route;
51
- }
52
- const routes = this.routes[domain];
53
- if (!routes) {
54
- return null;
55
- }
56
- const lookupByName = !followLookupStrategy || this.lookupStrategies.includes("name");
57
- const lookupByPattern = !followLookupStrategy || this.lookupStrategies.includes("pattern");
58
- const lookupByController = !followLookupStrategy || this.lookupStrategies.includes("controller");
59
- return routes.find((route) => {
60
- if (method && !route.methods.includes(method)) {
61
- return false;
62
- }
63
- if (route.name === routeIdentifier && lookupByName || route.pattern === routeIdentifier && lookupByPattern) {
64
- return true;
65
- }
66
- if (typeof route.handler === "function" || !lookupByController) {
67
- return false;
68
- }
69
- return route.handler.reference === routeIdentifier;
70
- }) || null;
71
- }
72
- /**
73
- * Finds a route by its identifier. The identifier can be the
74
- * route name, controller.method name or the route pattern
75
- * itself.
76
- *
77
- * An error is raised when unable to find the route.
78
- *
79
- * When "followLookupStrategy" is enabled, the lookup will be performed
80
- * on the basis of the lookup strategy enabled via the "lookupStrategies"
81
- * method. The default lookupStrategy is "name" and "pattern".
82
- */
83
- findOrFail(routeIdentifier, domain, method, followLookupStrategy) {
84
- const route = this.find(routeIdentifier, domain, method, followLookupStrategy);
85
- if (!route) {
86
- throw new Error(`Cannot lookup route "${routeIdentifier}"`);
87
- }
88
- return route;
89
- }
90
- /**
91
- * Check if a route exists. The identifier can be the
92
- * route name, controller.method name or the route pattern
93
- * itself.
94
- *
95
- * When "followLookupStrategy" is enabled, the lookup will be performed
96
- * on the basis of the lookup strategy enabled via the "lookupStrategies"
97
- * method. The default lookupStrategy is "name" and "pattern".
98
- */
99
- has(routeIdentifier, domain, method, followLookupStrategy) {
100
- return !!this.find(routeIdentifier, domain, method, followLookupStrategy);
101
- }
102
- /**
103
- * Returns a list of routes grouped by their domain names
104
- */
105
- toJSON() {
106
- return this.routes;
107
- }
108
- };
109
-
110
- // src/client/url_builder.ts
111
- function createURL(identifier, tokens, searchParamsStringifier, params, options) {
112
- const uriSegments = [];
113
- const paramsArray = Array.isArray(params) ? params : null;
114
- const paramsObject = !Array.isArray(params) ? params ?? {} : {};
115
- let paramsIndex = 0;
116
- for (const token of tokens) {
117
- if (token.type === 0) {
118
- uriSegments.push(token.val === "/" ? "" : `${token.val}${token.end}`);
119
- continue;
120
- }
121
- if (token.type === 2) {
122
- const values = paramsArray ? paramsArray.slice(paramsIndex) : paramsObject["*"];
123
- if (!Array.isArray(values) || !values.length) {
124
- throw new Error(
125
- `Cannot make URL for "${identifier}". Invalid value provided for the wildcard param`
126
- );
127
- }
128
- uriSegments.push(`${values.join("/")}${token.end}`);
129
- break;
130
- }
131
- const paramName = token.val;
132
- const value = paramsArray ? paramsArray[paramsIndex] : paramsObject[paramName];
133
- const isDefined = value !== void 0 && value !== null;
134
- if (token.type === 1 && !isDefined) {
135
- throw new Error(
136
- `Cannot make URL for "${identifier}". Missing value for the "${paramName}" param`
137
- );
138
- }
139
- if (isDefined) {
140
- uriSegments.push(`${value}${token.end}`);
141
- }
142
- paramsIndex++;
143
- }
144
- let URI = `/${uriSegments.join("/")}`;
145
- if (options?.prefixUrl) {
146
- URI = `${options?.prefixUrl.replace(/\/$/, "")}${URI}`;
147
- }
148
- if (options?.qs) {
149
- const queryString = searchParamsStringifier(options?.qs);
150
- URI = queryString ? `${URI}?${queryString}` : URI;
151
- }
152
- return URI;
153
- }
154
- function createUrlBuilder(router, searchParamsStringifier) {
155
- let domainsList;
156
- function createUrlForRoute(identifier, params, options, method) {
157
- if (!domainsList) {
158
- domainsList = Object.keys(router.toJSON()).filter((domain2) => domain2 !== "root");
159
- }
160
- const domain = domainsList.find((name) => identifier.startsWith(`${name}@`));
161
- const routeIdentifier = domain ? identifier.replace(new RegExp(`^${domain}@`), "") : identifier;
162
- const route = router.findOrFail(routeIdentifier, domain, method, true);
163
- return createURL(
164
- route.name ?? route.pattern,
165
- route.tokens,
166
- searchParamsStringifier,
167
- params,
168
- options
169
- );
170
- }
171
- const urlFor = function route(...[identifier, params, options]) {
172
- return createUrlForRoute(identifier, params, options);
173
- };
174
- urlFor.get = function urlForMethodGet(...[identifier, params, options]) {
175
- return {
176
- url: createUrlForRoute(identifier, params, options, "GET"),
177
- method: "get",
178
- toString() {
179
- return this.url;
180
- }
181
- };
182
- };
183
- urlFor.post = function urlForMethodPost(...[identifier, params, options]) {
184
- return {
185
- url: createUrlForRoute(identifier, params, options, "POST"),
186
- method: "post",
187
- toString() {
188
- return this.url;
189
- }
190
- };
191
- };
192
- urlFor.put = function urlForMethodPut(...[identifier, params, options]) {
193
- return {
194
- url: createUrlForRoute(identifier, params, options, "PUT"),
195
- method: "put",
196
- toString() {
197
- return this.url;
198
- }
199
- };
200
- };
201
- urlFor.patch = function urlForMethodPatch(...[identifier, params, options]) {
202
- return {
203
- url: createUrlForRoute(identifier, params, options, "PATCH"),
204
- method: "patch",
205
- toString() {
206
- return this.url;
207
- }
208
- };
209
- };
210
- urlFor.delete = function urlForMethodDelete(...[identifier, params, options]) {
211
- return {
212
- url: createUrlForRoute(identifier, params, options, "DELETE"),
213
- method: "delete",
214
- toString() {
215
- return this.url;
216
- }
217
- };
218
- };
219
- urlFor.method = function urlForCustomMethod(method, ...[identifier, params, options]) {
220
- return {
221
- url: createUrlForRoute(identifier, params, options, method),
222
- method,
223
- toString() {
224
- return this.url;
225
- }
226
- };
227
- };
228
- return urlFor;
229
- }
230
-
231
- exports.RouterClient = RouterClient;
232
- exports.createUrlBuilder = createUrlBuilder;
@@ -1,258 +0,0 @@
1
- import { Prettify } from '@poppinss/utils/types';
2
-
3
- /**
4
- * Types shared with the client. These should never import other types
5
- */
6
-
7
- /**
8
- * Options accepted by "url" and "route" helper methods
9
- */
10
- type URLOptions = {
11
- qs?: Record<string, any>;
12
- prefixUrl?: string;
13
- };
14
- /**
15
- * Options accepted by "signedUrl" and "signedRoute" helper methods
16
- */
17
- type SignedURLOptions = URLOptions & {
18
- expiresIn?: string | number;
19
- purpose?: string;
20
- };
21
- /**
22
- * Returns params for a route identifier
23
- */
24
- type RouteBuilderArguments<Routes, Method extends keyof Routes, Identifier extends keyof Routes[Method], Options extends any = URLOptions> = Routes extends LookupList ? Prettify<undefined extends Routes[Method][Identifier]['params'] ? [identifier: Identifier, params?: undefined, options?: Options] : [undefined] extends [Routes[Method][Identifier]['params']] ? [
25
- identifier: Identifier,
26
- params?: Routes[Method][Identifier]['params'] | Routes[Method][Identifier]['paramsTuple'],
27
- options?: Options
28
- ] : [
29
- identifier: Identifier,
30
- params: Routes[Method][Identifier]['params'] | Routes[Method][Identifier]['paramsTuple'],
31
- options?: Options
32
- ]> : never;
33
- /**
34
- * Shape of a route param matcher
35
- */
36
- type RouteMatcher = {
37
- match?: RegExp;
38
- cast?: (value: string) => any;
39
- };
40
- /**
41
- * Route token stored by matchit library
42
- */
43
- type MatchItRouteToken = RouteMatcher & {
44
- old: string;
45
- type: 0 | 1 | 2 | 3;
46
- val: string;
47
- end: string;
48
- };
49
- /**
50
- * Representation of route shared with the client
51
- */
52
- type ClientRouteJSON = {
53
- /**
54
- * A unique name for the route
55
- */
56
- name?: string;
57
- /**
58
- * Route URI pattern
59
- */
60
- pattern: string;
61
- /**
62
- * HTTP methods, the route responds to.
63
- */
64
- methods: string[];
65
- /**
66
- * Route domain
67
- */
68
- domain: string;
69
- /**
70
- * Reference to the route handler
71
- */
72
- handler: {
73
- reference?: any;
74
- } | Function;
75
- /**
76
- * Tokens to be used to construct the route URL
77
- */
78
- tokens: MatchItRouteToken[];
79
- };
80
- /**
81
- * LookupList type is used by the URLBuilder to provide
82
- * type-safety when creating URLs.
83
- *
84
- * There is no runtime property that matches this type. Its
85
- * purely for type-inference.
86
- */
87
- type LookupList = {
88
- [method: string]: {
89
- [identifier: string]: {
90
- paramsTuple?: [...any[]];
91
- params?: {
92
- [name: string]: any;
93
- };
94
- };
95
- };
96
- };
97
- /**
98
- * The urlFor helper is used to make URLs for pre-existing known routes. You can
99
- * make a URL using the route name, route pattern, or the route controller
100
- * reference (depends upon enabled lookupStrategies)
101
- *
102
- * ```ts
103
- * urlFor('users.show', [1]) // /users/1
104
- *
105
- * // Lookup inside a specific domain
106
- * urlFor('blog.adonisjs.com@posts.show', [1]) // /posts/1
107
- * ```
108
- */
109
- type UrlFor<Routes extends LookupList, Options extends any = URLOptions> = (<Identifier extends keyof Routes['ALL'] & string>(...[identifier, params, options]: RouteBuilderArguments<Routes, 'ALL', Identifier, Options>) => string) & {
110
- /**
111
- * Make URL for a GET route. An error will be raised if the route doesn't
112
- * exist.
113
- *
114
- * ```ts
115
- * urlFor.get('users.show', [1]) // { method: 'get', url: '/users/1' }
116
- * urlFor.get('users.store', [1]) // Error: Route not found GET@users/store
117
- * ```
118
- */
119
- get<RouteIdentifier extends keyof Routes['GET'] & string>(...[identifier, params, options]: RouteBuilderArguments<Routes, 'GET', RouteIdentifier, Options>): {
120
- method: 'get';
121
- url: string;
122
- };
123
- /**
124
- * Make URL for a POST route. An error will be raised if the route doesn't
125
- * exist.
126
- *
127
- * ```ts
128
- * urlFor.post('users.store') // { method: 'post', url: '/users' }
129
- * urlFor.post('users.show', [1]) // Error: Route not found POST@users.show
130
- * ```
131
- */
132
- post<RouteIdentifier extends keyof Routes['POST'] & string>(...[identifier, params, options]: RouteBuilderArguments<Routes, 'POST', RouteIdentifier, Options>): {
133
- method: 'post';
134
- url: string;
135
- };
136
- /**
137
- * Make URL for a PUT route. An error will be raised if the route doesn't
138
- * exist.
139
- *
140
- * ```ts
141
- * urlFor.put('users.update', [1]) // { method: 'put', url: '/users/1' }
142
- * urlFor.put('users.show', [1]) // Error: Route not found PUT@users.show
143
- * ```
144
- */
145
- put<RouteIdentifier extends keyof Routes['PUT'] & string>(...[identifier, params, options]: RouteBuilderArguments<Routes, 'PUT', RouteIdentifier, Options>): {
146
- method: 'put';
147
- url: string;
148
- };
149
- /**
150
- * Make URL for a PATCH route. An error will be raised if the route doesn't
151
- * exist.
152
- *
153
- * ```ts
154
- * urlFor.put('users.update', [1]) // { method: 'patch', url: '/users/1' }
155
- * urlFor.put('users.show', [1]) // Error: Route not found PATCH@users.show
156
- * ```
157
- */
158
- patch<RouteIdentifier extends keyof Routes['PATCH'] & string>(...[identifier, params, options]: RouteBuilderArguments<Routes, 'PATCH', RouteIdentifier, Options>): {
159
- method: 'patch';
160
- url: string;
161
- };
162
- /**
163
- * Make URL for a DELETE route. An error will be raised if the route doesn't
164
- * exist.
165
- *
166
- * ```ts
167
- * urlFor.delete('users.destroy', [1]) // { method: 'delete', url: '/users/1' }
168
- * urlFor.delete('users.show', [1]) // Error: Route not found DELETE@users.show
169
- * ```
170
- */
171
- delete<RouteIdentifier extends keyof Routes['DELETE'] & string>(...[identifier, params, options]: RouteBuilderArguments<Routes, 'DELETE', RouteIdentifier, Options>): {
172
- method: 'delete';
173
- url: string;
174
- };
175
- /**
176
- * Make URL for a custom route method. An error will be raised if the route doesn't
177
- * exist for the same method.
178
- */
179
- method<Method extends keyof Routes & string, RouteIdentifier extends keyof Routes[Method] & string>(method: Method, ...[identifier, params, options]: RouteBuilderArguments<Routes, Method, RouteIdentifier, Options>): {
180
- method: Method;
181
- url: string;
182
- };
183
- };
184
-
185
- /**
186
- * The router client contains the shared logic for finding routes
187
- * used by the server and the client.
188
- */
189
- declare class RouterClient<T extends ClientRouteJSON> {
190
- /**
191
- * List of route references kept for lookup.
192
- */
193
- protected routes: {
194
- [domain: string]: T[];
195
- };
196
- /**
197
- * The lookup strategies to follow when generating URL builder
198
- * types and client
199
- */
200
- lookupStrategies: ('name' | 'pattern' | 'controller')[];
201
- constructor(routes?: {
202
- [domain: string]: T[];
203
- });
204
- /**
205
- * Register route JSON payload
206
- */
207
- protected register(route: T): void;
208
- /**
209
- * Define the lookup strategies to follow when generating URL builder
210
- * types and client.
211
- */
212
- updateLookupStrategies(strategies: ('name' | 'pattern' | 'controller')[]): this;
213
- /**
214
- * Finds a route by its identifier. The identifier can be the
215
- * route name, controller.method name or the route pattern
216
- * itself.
217
- *
218
- * When "followLookupStrategy" is enabled, the lookup will be performed
219
- * on the basis of the lookup strategy enabled via the "lookupStrategies"
220
- * method. The default lookupStrategy is "name" and "pattern".
221
- */
222
- find(routeIdentifier: string, domain?: string, method?: string, followLookupStrategy?: boolean): T | null;
223
- /**
224
- * Finds a route by its identifier. The identifier can be the
225
- * route name, controller.method name or the route pattern
226
- * itself.
227
- *
228
- * An error is raised when unable to find the route.
229
- *
230
- * When "followLookupStrategy" is enabled, the lookup will be performed
231
- * on the basis of the lookup strategy enabled via the "lookupStrategies"
232
- * method. The default lookupStrategy is "name" and "pattern".
233
- */
234
- findOrFail(routeIdentifier: string, domain?: string, method?: string, followLookupStrategy?: boolean): T;
235
- /**
236
- * Check if a route exists. The identifier can be the
237
- * route name, controller.method name or the route pattern
238
- * itself.
239
- *
240
- * When "followLookupStrategy" is enabled, the lookup will be performed
241
- * on the basis of the lookup strategy enabled via the "lookupStrategies"
242
- * method. The default lookupStrategy is "name" and "pattern".
243
- */
244
- has(routeIdentifier: string, domain?: string, method?: string, followLookupStrategy?: boolean): boolean;
245
- /**
246
- * Returns a list of routes grouped by their domain names
247
- */
248
- toJSON(): {
249
- [domain: string]: T[];
250
- };
251
- }
252
-
253
- /**
254
- * Creates the URLBuilder helper
255
- */
256
- declare function createUrlBuilder<Routes extends LookupList>(router: RouterClient<ClientRouteJSON>, searchParamsStringifier: (qs: Record<string, any>) => string): UrlFor<Routes>;
257
-
258
- export { type ClientRouteJSON, type LookupList, type MatchItRouteToken, type RouteBuilderArguments, type RouteMatcher, RouterClient, type SignedURLOptions, type URLOptions, type UrlFor, createUrlBuilder };