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

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 (74) hide show
  1. package/build/chunk-2QM3D5BN.js +87 -0
  2. package/build/chunk-5PWHBE2E.js +128 -0
  3. package/build/chunk-QDK57QGB.js +1176 -0
  4. package/build/{chunk-VYBTM3NC.js → chunk-YBLFT4O6.js} +1161 -1719
  5. package/build/factories/http_context.d.ts +5 -4
  6. package/build/factories/http_server.d.ts +7 -0
  7. package/build/factories/main.d.ts +6 -6
  8. package/build/factories/main.js +33 -5
  9. package/build/factories/qs_parser_factory.d.ts +5 -4
  10. package/build/factories/request.d.ts +3 -2
  11. package/build/factories/response.d.ts +4 -3
  12. package/build/factories/router.d.ts +2 -1
  13. package/build/factories/server_factory.d.ts +3 -2
  14. package/build/factories/url_builder_factory.d.ts +3 -2
  15. package/build/index.d.ts +19 -16
  16. package/build/index.js +97 -42
  17. package/build/src/client/helpers.d.ts +37 -0
  18. package/build/src/client/types.d.ts +88 -66
  19. package/build/src/client/url_builder.d.ts +12 -10
  20. package/build/src/client/url_builder.js +12 -0
  21. package/build/src/cookies/client.d.ts +61 -3
  22. package/build/src/cookies/drivers/encrypted.d.ts +13 -0
  23. package/build/src/cookies/drivers/plain.d.ts +9 -0
  24. package/build/src/cookies/drivers/signed.d.ts +13 -0
  25. package/build/src/cookies/parser.d.ts +18 -0
  26. package/build/src/cookies/serializer.d.ts +22 -3
  27. package/build/src/debug.d.ts +13 -0
  28. package/build/src/define_config.d.ts +21 -5
  29. package/build/src/define_middleware.d.ts +20 -4
  30. package/build/src/errors.d.ts +67 -10
  31. package/build/src/exception_handler.d.ts +95 -41
  32. package/build/src/helpers.d.ts +60 -4
  33. package/build/src/helpers.js +9 -1
  34. package/build/src/http_context/local_storage.d.ts +18 -1
  35. package/build/src/http_context/main.d.ts +71 -13
  36. package/build/src/qs.d.ts +31 -3
  37. package/build/src/redirect.d.ts +87 -16
  38. package/build/src/request.d.ts +121 -15
  39. package/build/src/response.d.ts +421 -208
  40. package/build/src/response_status.d.ts +14 -0
  41. package/build/src/router/brisk.d.ts +18 -7
  42. package/build/src/router/executor.d.ts +7 -3
  43. package/build/src/router/factories/use_return_value.d.ts +6 -1
  44. package/build/src/router/group.d.ts +23 -6
  45. package/build/src/router/legacy/url_builder.d.ts +15 -15
  46. package/build/src/router/main.d.ts +133 -20
  47. package/build/src/router/matchers.d.ts +3 -0
  48. package/build/src/router/resource.d.ts +37 -5
  49. package/build/src/router/route.d.ts +30 -6
  50. package/build/src/router/signed_url_builder.d.ts +7 -10
  51. package/build/src/router/store.d.ts +10 -2
  52. package/build/src/server/factories/middleware_handler.d.ts +12 -3
  53. package/build/src/server/factories/route_finder.d.ts +16 -6
  54. package/build/src/server/factories/write_response.d.ts +10 -3
  55. package/build/src/server/main.d.ts +83 -29
  56. package/build/src/tracing_channels.d.ts +4 -4
  57. package/build/src/types/main.d.ts +1 -1
  58. package/build/src/types/middleware.d.ts +35 -10
  59. package/build/src/types/qs.d.ts +5 -0
  60. package/build/src/types/request.d.ts +1 -1
  61. package/build/src/types/response.d.ts +14 -6
  62. package/build/src/types/route.d.ts +53 -51
  63. package/build/src/types/server.d.ts +30 -15
  64. package/build/src/types/tracing_channels.d.ts +24 -6
  65. package/build/src/types/url_builder.d.ts +22 -0
  66. package/build/src/utils.d.ts +76 -11
  67. package/package.json +29 -30
  68. package/build/chunk-ASX56VAK.js +0 -76
  69. package/build/client.cjs +0 -232
  70. package/build/client.d.cts +0 -258
  71. package/build/client.d.ts +0 -258
  72. package/build/client.js +0 -229
  73. package/build/src/client/main.d.ts +0 -3
  74. package/build/src/client/router.d.ts +0 -68
@@ -0,0 +1,87 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ // src/client/helpers.ts
8
+ function findRoute(domainsRoutes, routeIdentifier, domain, method, disableLegacyLookup) {
9
+ if (!domain) {
10
+ let route = null;
11
+ for (const routeDomain of Object.keys(domainsRoutes)) {
12
+ route = findRoute(domainsRoutes, routeIdentifier, routeDomain, method, disableLegacyLookup);
13
+ if (route) {
14
+ break;
15
+ }
16
+ }
17
+ return route;
18
+ }
19
+ const routes = domainsRoutes[domain];
20
+ if (!routes) {
21
+ return null;
22
+ }
23
+ const lookupByName = true;
24
+ const lookupByPattern = !disableLegacyLookup;
25
+ const lookupByController = !disableLegacyLookup;
26
+ return routes.find((route) => {
27
+ if (method && !route.methods.includes(method)) {
28
+ return false;
29
+ }
30
+ if (lookupByName && route.name === routeIdentifier || lookupByPattern && route.pattern === routeIdentifier) {
31
+ return true;
32
+ }
33
+ if (lookupByController && route.handler && typeof route.handler === "object") {
34
+ return "reference" in route.handler && route.handler.reference === routeIdentifier;
35
+ }
36
+ return false;
37
+ }) || null;
38
+ }
39
+ function createURL(pattern, tokens, searchParamsStringifier, params, options) {
40
+ const uriSegments = [];
41
+ const paramsArray = Array.isArray(params) ? params : null;
42
+ const paramsObject = !Array.isArray(params) ? params ?? {} : {};
43
+ let paramsIndex = 0;
44
+ for (const token of tokens) {
45
+ if (token.type === 0) {
46
+ uriSegments.push(token.val === "/" ? "" : `${token.val}${token.end}`);
47
+ continue;
48
+ }
49
+ if (token.type === 2) {
50
+ const values = paramsArray ? paramsArray.slice(paramsIndex) : paramsObject["*"];
51
+ if (!Array.isArray(values) || !values.length) {
52
+ throw new Error(
53
+ `Cannot make URL for "${pattern}". Invalid value provided for the wildcard param`
54
+ );
55
+ }
56
+ uriSegments.push(`${values.join("/")}${token.end}`);
57
+ break;
58
+ }
59
+ const paramName = token.val;
60
+ const value = paramsArray ? paramsArray[paramsIndex] : paramsObject[paramName];
61
+ const isDefined = value !== void 0 && value !== null;
62
+ if (token.type === 1 && !isDefined) {
63
+ throw new Error(
64
+ `Cannot make URL for "${pattern}". Missing value for the "${paramName}" param`
65
+ );
66
+ }
67
+ if (isDefined) {
68
+ uriSegments.push(`${value}${token.end}`);
69
+ }
70
+ paramsIndex++;
71
+ }
72
+ let URI = `/${uriSegments.join("/")}`;
73
+ if (options?.prefixUrl) {
74
+ URI = `${options?.prefixUrl.replace(/\/$/, "")}${URI}`;
75
+ }
76
+ if (options?.qs) {
77
+ const queryString = searchParamsStringifier(options?.qs);
78
+ URI = queryString ? `${URI}?${queryString}` : URI;
79
+ }
80
+ return URI;
81
+ }
82
+
83
+ export {
84
+ __export,
85
+ findRoute,
86
+ createURL
87
+ };
@@ -0,0 +1,128 @@
1
+ import {
2
+ createURL,
3
+ findRoute
4
+ } from "./chunk-2QM3D5BN.js";
5
+
6
+ // src/client/url_builder.ts
7
+ function createUrlBuilder(routesLoader, searchParamsStringifier) {
8
+ let domainsList;
9
+ let domainsRoutes;
10
+ function createUrlForRoute(identifier, params, options, method) {
11
+ if (!domainsRoutes) {
12
+ domainsRoutes = typeof routesLoader === "function" ? routesLoader() : routesLoader;
13
+ }
14
+ if (!domainsList) {
15
+ domainsList = Object.keys(domainsRoutes).filter((domain2) => domain2 !== "root");
16
+ }
17
+ const domain = domainsList.find((name) => identifier.startsWith(`${name}@`));
18
+ const routeIdentifier = domain ? identifier.replace(new RegExp(`^${domain}@`), "") : identifier;
19
+ const route = findRoute(domainsRoutes, routeIdentifier, domain, method, true);
20
+ if (!route) {
21
+ throw new Error(`Cannot lookup route "${routeIdentifier}"`);
22
+ }
23
+ return createURL(
24
+ route.name ?? route.pattern,
25
+ route.tokens,
26
+ searchParamsStringifier,
27
+ params,
28
+ options
29
+ );
30
+ }
31
+ const urlFor = function route(...[identifier, params, options]) {
32
+ return createUrlForRoute(identifier, params, options);
33
+ };
34
+ urlFor.get = function urlForMethodGet(...[identifier, params, options]) {
35
+ const method = "GET";
36
+ const url = createUrlForRoute(identifier, params, options, method);
37
+ return {
38
+ url,
39
+ method,
40
+ toString() {
41
+ return url;
42
+ },
43
+ form: {
44
+ action: url,
45
+ method
46
+ }
47
+ };
48
+ };
49
+ urlFor.post = function urlForMethodPost(...[identifier, params, options]) {
50
+ const method = "POST";
51
+ const url = createUrlForRoute(identifier, params, options, method);
52
+ return {
53
+ url,
54
+ method,
55
+ toString() {
56
+ return url;
57
+ },
58
+ form: {
59
+ action: url,
60
+ method
61
+ }
62
+ };
63
+ };
64
+ urlFor.put = function urlForMethodPut(...[identifier, params, options]) {
65
+ const method = "PUT";
66
+ const url = createUrlForRoute(identifier, params, options, method);
67
+ return {
68
+ url,
69
+ method,
70
+ toString() {
71
+ return url;
72
+ },
73
+ form: {
74
+ action: url,
75
+ method
76
+ }
77
+ };
78
+ };
79
+ urlFor.patch = function urlForMethodPatch(...[identifier, params, options]) {
80
+ const method = "PATCH";
81
+ const url = createUrlForRoute(identifier, params, options, method);
82
+ return {
83
+ url,
84
+ method,
85
+ toString() {
86
+ return url;
87
+ },
88
+ form: {
89
+ action: url,
90
+ method
91
+ }
92
+ };
93
+ };
94
+ urlFor.delete = function urlForMethodDelete(...[identifier, params, options]) {
95
+ const method = "DELETE";
96
+ const url = createUrlForRoute(identifier, params, options, method);
97
+ return {
98
+ url,
99
+ method,
100
+ toString() {
101
+ return url;
102
+ },
103
+ form: {
104
+ action: url,
105
+ method
106
+ }
107
+ };
108
+ };
109
+ urlFor.method = function urlForCustomMethod(method, ...[identifier, params, options]) {
110
+ const url = createUrlForRoute(identifier, params, options, method);
111
+ return {
112
+ url,
113
+ method,
114
+ toString() {
115
+ return url;
116
+ },
117
+ form: {
118
+ action: url,
119
+ method
120
+ }
121
+ };
122
+ };
123
+ return urlFor;
124
+ }
125
+
126
+ export {
127
+ createUrlBuilder
128
+ };