@adonisjs/http-server 8.0.0-next.1 → 8.0.0-next.11

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 (67) hide show
  1. package/build/chunk-2QM3D5BN.js +87 -0
  2. package/build/chunk-77CSRFCU.js +131 -0
  3. package/build/{chunk-HMYAZG76.js → chunk-Q3DRGJUE.js} +1180 -1691
  4. package/build/chunk-QDK57QGB.js +1176 -0
  5. package/build/factories/http_context.d.ts +2 -1
  6. package/build/factories/http_server.d.ts +7 -0
  7. package/build/factories/main.js +33 -5
  8. package/build/factories/qs_parser_factory.d.ts +3 -2
  9. package/build/factories/request.d.ts +1 -0
  10. package/build/factories/response.d.ts +1 -0
  11. package/build/factories/router.d.ts +1 -0
  12. package/build/factories/server_factory.d.ts +1 -0
  13. package/build/factories/url_builder_factory.d.ts +3 -2
  14. package/build/index.d.ts +4 -1
  15. package/build/index.js +97 -42
  16. package/build/src/client/helpers.d.ts +37 -0
  17. package/build/src/client/types.d.ts +203 -0
  18. package/build/src/client/url_builder.d.ts +15 -0
  19. package/build/src/client/url_builder.js +12 -0
  20. package/build/src/cookies/client.d.ts +61 -3
  21. package/build/src/cookies/drivers/encrypted.d.ts +13 -0
  22. package/build/src/cookies/drivers/plain.d.ts +9 -0
  23. package/build/src/cookies/drivers/signed.d.ts +13 -0
  24. package/build/src/cookies/parser.d.ts +18 -0
  25. package/build/src/cookies/serializer.d.ts +21 -2
  26. package/build/src/debug.d.ts +13 -0
  27. package/build/src/define_config.d.ts +20 -4
  28. package/build/src/define_middleware.d.ts +20 -4
  29. package/build/src/errors.d.ts +60 -5
  30. package/build/src/exception_handler.d.ts +93 -39
  31. package/build/src/helpers.d.ts +57 -0
  32. package/build/src/helpers.js +9 -1
  33. package/build/src/http_context/local_storage.d.ts +17 -0
  34. package/build/src/http_context/main.d.ts +68 -10
  35. package/build/src/qs.d.ts +30 -2
  36. package/build/src/redirect.d.ts +84 -12
  37. package/build/src/request.d.ts +118 -12
  38. package/build/src/response.d.ts +416 -203
  39. package/build/src/response_status.d.ts +14 -0
  40. package/build/src/router/brisk.d.ts +15 -4
  41. package/build/src/router/executor.d.ts +4 -0
  42. package/build/src/router/factories/use_return_value.d.ts +5 -0
  43. package/build/src/router/group.d.ts +18 -1
  44. package/build/src/router/legacy/url_builder.d.ts +14 -14
  45. package/build/src/router/main.d.ts +79 -22
  46. package/build/src/router/matchers.d.ts +3 -0
  47. package/build/src/router/resource.d.ts +34 -1
  48. package/build/src/router/route.d.ts +28 -3
  49. package/build/src/router/signed_url_builder.d.ts +4 -8
  50. package/build/src/router/store.d.ts +9 -0
  51. package/build/src/server/factories/middleware_handler.d.ts +10 -1
  52. package/build/src/server/factories/route_finder.d.ts +13 -3
  53. package/build/src/server/factories/write_response.d.ts +9 -2
  54. package/build/src/server/main.d.ts +77 -23
  55. package/build/src/tracing_channels.d.ts +4 -4
  56. package/build/src/types/middleware.d.ts +34 -9
  57. package/build/src/types/qs.d.ts +5 -0
  58. package/build/src/types/request.d.ts +1 -1
  59. package/build/src/types/response.d.ts +14 -6
  60. package/build/src/types/route.d.ts +42 -42
  61. package/build/src/types/server.d.ts +26 -11
  62. package/build/src/types/tracing_channels.d.ts +21 -3
  63. package/build/src/types/url_builder.d.ts +10 -135
  64. package/build/src/utils.d.ts +71 -6
  65. package/package.json +27 -23
  66. package/build/chunk-ASX56VAK.js +0 -76
  67. package/build/src/router/url_builder.d.ts +0 -14
@@ -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,131 @@
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
+ if (method) {
22
+ throw new Error(`Cannot lookup route "${routeIdentifier}" for method "${method}"`);
23
+ }
24
+ throw new Error(`Cannot lookup route "${routeIdentifier}"`);
25
+ }
26
+ return createURL(
27
+ route.name ?? route.pattern,
28
+ route.tokens,
29
+ searchParamsStringifier,
30
+ params,
31
+ options
32
+ );
33
+ }
34
+ const urlFor = function route(...[identifier, params, options]) {
35
+ return createUrlForRoute(identifier, params, options);
36
+ };
37
+ urlFor.get = function urlForMethodGet(...[identifier, params, options]) {
38
+ const method = "GET";
39
+ const url = createUrlForRoute(identifier, params, options, method);
40
+ return {
41
+ url,
42
+ method,
43
+ toString() {
44
+ return url;
45
+ },
46
+ form: {
47
+ action: url,
48
+ method
49
+ }
50
+ };
51
+ };
52
+ urlFor.post = function urlForMethodPost(...[identifier, params, options]) {
53
+ const method = "POST";
54
+ const url = createUrlForRoute(identifier, params, options, method);
55
+ return {
56
+ url,
57
+ method,
58
+ toString() {
59
+ return url;
60
+ },
61
+ form: {
62
+ action: url,
63
+ method
64
+ }
65
+ };
66
+ };
67
+ urlFor.put = function urlForMethodPut(...[identifier, params, options]) {
68
+ const method = "PUT";
69
+ const url = createUrlForRoute(identifier, params, options, method);
70
+ return {
71
+ url,
72
+ method,
73
+ toString() {
74
+ return url;
75
+ },
76
+ form: {
77
+ action: url,
78
+ method
79
+ }
80
+ };
81
+ };
82
+ urlFor.patch = function urlForMethodPatch(...[identifier, params, options]) {
83
+ const method = "PATCH";
84
+ const url = createUrlForRoute(identifier, params, options, method);
85
+ return {
86
+ url,
87
+ method,
88
+ toString() {
89
+ return url;
90
+ },
91
+ form: {
92
+ action: url,
93
+ method
94
+ }
95
+ };
96
+ };
97
+ urlFor.delete = function urlForMethodDelete(...[identifier, params, options]) {
98
+ const method = "DELETE";
99
+ const url = createUrlForRoute(identifier, params, options, method);
100
+ return {
101
+ url,
102
+ method,
103
+ toString() {
104
+ return url;
105
+ },
106
+ form: {
107
+ action: url,
108
+ method
109
+ }
110
+ };
111
+ };
112
+ urlFor.method = function urlForCustomMethod(method, ...[identifier, params, options]) {
113
+ const url = createUrlForRoute(identifier, params, options, method);
114
+ return {
115
+ url,
116
+ method,
117
+ toString() {
118
+ return url;
119
+ },
120
+ form: {
121
+ action: url,
122
+ method
123
+ }
124
+ };
125
+ };
126
+ return urlFor;
127
+ }
128
+
129
+ export {
130
+ createUrlBuilder
131
+ };