@adonisjs/core 7.0.0-next.2 → 7.0.0-next.21

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 (217) hide show
  1. package/build/ace-sWl9sgM1.js +16 -0
  2. package/build/app-B6oge7b3.js +5 -0
  3. package/build/app-DNvbxVWl.js +5 -0
  4. package/build/bodyparser_middleware-BmARtnYe.js +3 -0
  5. package/build/chunk-B88MteZI.js +26 -0
  6. package/build/commands/add.d.ts +4 -3
  7. package/build/commands/add.js +76 -110
  8. package/build/commands/build.js +51 -107
  9. package/build/commands/commands.json +1 -1
  10. package/build/commands/configure.js +82 -177
  11. package/build/commands/eject.js +17 -60
  12. package/build/commands/env/add.js +55 -134
  13. package/build/commands/generate_key.js +22 -66
  14. package/build/commands/inspect_rcfile.js +27 -55
  15. package/build/commands/list/routes.js +246 -116
  16. package/build/commands/make/command.js +15 -57
  17. package/build/commands/make/controller.js +43 -120
  18. package/build/commands/make/event.js +16 -62
  19. package/build/commands/make/exception.js +16 -62
  20. package/build/commands/make/listener.js +36 -93
  21. package/build/commands/make/middleware.js +41 -101
  22. package/build/commands/make/preload.js +47 -113
  23. package/build/commands/make/provider.js +47 -112
  24. package/build/commands/make/service.js +16 -55
  25. package/build/commands/make/test.js +47 -132
  26. package/build/commands/make/transformer.js +17 -64
  27. package/build/commands/make/validator.js +20 -80
  28. package/build/commands/make/view.js +15 -56
  29. package/build/commands/repl.js +17 -50
  30. package/build/commands/serve.js +80 -156
  31. package/build/commands/test.js +92 -208
  32. package/build/config-Dd2H6-_e.js +5 -0
  33. package/build/config_provider-DWVFHOQX.js +15 -0
  34. package/build/container-uxa8LpGI.js +5 -0
  35. package/build/core-BuPP8K6N.js +140 -0
  36. package/build/create_kernel-Cn8zVtvt.js +3 -0
  37. package/build/create_kernel-Cpqqa931.js +38 -0
  38. package/build/decorate-CJcHOoD-.js +7 -0
  39. package/build/define_config-CoWy5lbf.js +62 -0
  40. package/build/dumper-BTjb8j4y.js +147 -0
  41. package/build/edge-BVYR-Vjr.js +47 -0
  42. package/build/events-C4d0OPUI.js +5 -0
  43. package/build/exceptions-DNMesP42.js +2 -0
  44. package/build/factories/app.js +2 -9
  45. package/build/factories/bodyparser.js +2 -9
  46. package/build/factories/core/ace.js +16 -46
  47. package/build/factories/core/ignitor.js +13 -180
  48. package/build/factories/core/main.js +24 -11
  49. package/build/factories/core/test_utils.js +21 -43
  50. package/build/factories/encryption.d.ts +1 -1
  51. package/build/factories/encryption.js +2 -9
  52. package/build/factories/events.js +2 -9
  53. package/build/factories/hash.js +2 -9
  54. package/build/factories/http.js +2 -9
  55. package/build/factories/logger.js +2 -9
  56. package/build/factories/stubs.js +27 -91
  57. package/build/ignitor-BrmVPN5N.js +71 -0
  58. package/build/index.d.ts +1 -1
  59. package/build/index.js +12 -46
  60. package/build/logger-0KKSqgPG.js +13 -0
  61. package/build/main-BU8NWUEG.js +73 -0
  62. package/build/main-Bfnr5tAw.js +2 -0
  63. package/build/main-BlJhxJJ2.js +81 -0
  64. package/build/main-C4B2SPOT.js +5 -0
  65. package/build/main-CZZ21eXm.js +171 -0
  66. package/build/main-D-WhqOOn.js +51 -0
  67. package/build/main-DOY5Q8Av.js +5 -0
  68. package/build/main-kn40V-hF.js +2 -0
  69. package/build/main-nojlltNo.js +30 -0
  70. package/build/{stubs/make → make}/health/controller.stub +5 -2
  71. package/build/modules/ace/codemods.d.ts +109 -14
  72. package/build/modules/ace/codemods.js +222 -382
  73. package/build/modules/ace/main.d.ts +30 -0
  74. package/build/modules/ace/main.js +2 -11
  75. package/build/modules/app.d.ts +17 -0
  76. package/build/modules/app.js +4 -9
  77. package/build/modules/bodyparser/bodyparser_middleware.js +2 -14
  78. package/build/modules/bodyparser/main.js +4 -9
  79. package/build/modules/config.d.ts +17 -0
  80. package/build/modules/config.js +4 -9
  81. package/build/modules/container.js +4 -9
  82. package/build/modules/dumper/dumper.d.ts +5 -0
  83. package/build/modules/dumper/main.d.ts +21 -0
  84. package/build/modules/dumper/main.js +6 -11
  85. package/build/modules/dumper/plugins/edge.js +2 -62
  86. package/build/modules/encryption/define_config.d.ts +128 -0
  87. package/build/modules/encryption/drivers/aes_256_cbc.d.ts +20 -0
  88. package/build/modules/encryption/drivers/aes_256_cbc.js +2 -0
  89. package/build/modules/encryption/drivers/aes_256_gcm.d.ts +21 -0
  90. package/build/modules/encryption/drivers/aes_256_gcm.js +2 -0
  91. package/build/modules/encryption/drivers/chacha20_poly1305.d.ts +21 -0
  92. package/build/modules/encryption/drivers/chacha20_poly1305.js +2 -0
  93. package/build/modules/encryption/main.d.ts +85 -0
  94. package/build/modules/encryption/main.js +5 -0
  95. package/build/modules/env/editor.js +2 -9
  96. package/build/modules/env/main.d.ts +19 -0
  97. package/build/modules/env/main.js +2 -9
  98. package/build/modules/events.js +4 -9
  99. package/build/modules/hash/drivers/argon.js +2 -9
  100. package/build/modules/hash/drivers/bcrypt.d.ts +11 -0
  101. package/build/modules/hash/drivers/bcrypt.js +2 -9
  102. package/build/modules/hash/drivers/scrypt.js +2 -9
  103. package/build/modules/hash/main.d.ts +18 -0
  104. package/build/modules/hash/main.js +5 -10
  105. package/build/modules/hash/phc_formatter.js +2 -9
  106. package/build/modules/health.js +2 -9
  107. package/build/modules/http/main.js +4 -15
  108. package/build/modules/http/request_validator.d.ts +1 -3
  109. package/build/modules/http/url_builder_client.d.ts +1 -0
  110. package/build/modules/http/url_builder_client.js +2 -0
  111. package/build/modules/logger.d.ts +30 -0
  112. package/build/modules/logger.js +4 -9
  113. package/build/modules/repl.js +4 -9
  114. package/build/modules/transformers/main.js +4 -9
  115. package/build/providers/app_provider.d.ts +14 -25
  116. package/build/providers/app_provider.js +155 -363
  117. package/build/providers/edge_provider.js +97 -114
  118. package/build/providers/hash_provider.js +28 -91
  119. package/build/providers/repl_provider.js +66 -152
  120. package/build/providers/vinejs_provider.d.ts +1 -1
  121. package/build/providers/vinejs_provider.js +19 -66
  122. package/build/repl-GSxgovJQ.js +5 -0
  123. package/build/services/ace.js +2 -17
  124. package/build/services/app.js +2 -21
  125. package/build/services/config.js +2 -13
  126. package/build/services/dumper.js +5 -21
  127. package/build/services/emitter.js +2 -14
  128. package/build/services/encryption.js +2 -14
  129. package/build/services/hash.js +2 -14
  130. package/build/services/logger.js +2 -14
  131. package/build/services/repl.js +2 -14
  132. package/build/services/router.js +2 -14
  133. package/build/services/server.js +2 -14
  134. package/build/services/test_utils.js +2 -17
  135. package/build/services/url_builder.d.ts +3 -3
  136. package/build/services/url_builder.js +5 -17
  137. package/build/src/assembler_hooks/index_entities.d.ts +29 -1
  138. package/build/src/debug.d.ts +1 -1
  139. package/build/src/exceptions.js +2 -49
  140. package/build/src/helpers/assert.js +2 -55
  141. package/build/src/helpers/http.d.ts +20 -0
  142. package/build/src/helpers/http.js +2 -0
  143. package/build/src/helpers/is.js +3 -31
  144. package/build/src/helpers/main.d.ts +1 -5
  145. package/build/src/helpers/main.js +5 -56
  146. package/build/src/helpers/string.js +2 -60
  147. package/build/src/helpers/types.js +26 -135
  148. package/build/src/helpers/verification_token.js +2 -120
  149. package/build/src/test_utils/main.js +8 -77
  150. package/build/src/types.d.ts +53 -99
  151. package/build/src/types.js +0 -8
  152. package/build/src/utils.d.ts +1 -1
  153. package/build/src/vine.js +2 -97
  154. package/build/string-Cx6q_win.js +28 -0
  155. package/build/test_utils-hkQDmNpX.js +10 -0
  156. package/build/toolkit/main.js +19 -21
  157. package/build/types/ace.js +2 -9
  158. package/build/types/app.js +2 -9
  159. package/build/types/bodyparser.js +2 -9
  160. package/build/types/common.js +2 -9
  161. package/build/types/container.js +2 -9
  162. package/build/types/encryption.d.ts +39 -1
  163. package/build/types/encryption.js +1 -9
  164. package/build/types/events.js +2 -9
  165. package/build/types/hash.js +2 -9
  166. package/build/types/health.js +2 -9
  167. package/build/types/helpers.d.ts +20 -0
  168. package/build/types/helpers.js +0 -8
  169. package/build/types/http.js +2 -9
  170. package/build/types/logger.js +2 -9
  171. package/build/types/repl.js +2 -9
  172. package/build/types/transformers.js +2 -9
  173. package/build/utils-CtGytdtt.js +42 -0
  174. package/build/verification_token-DrdoU4RH.js +46 -0
  175. package/build/vine-DGint2rk.js +32 -0
  176. package/package.json +113 -60
  177. package/build/modules/ace/commands.js +0 -157
  178. package/build/modules/ace/create_kernel.js +0 -91
  179. package/build/modules/ace/kernel.js +0 -40
  180. package/build/modules/dumper/define_config.js +0 -36
  181. package/build/modules/dumper/dumper.js +0 -256
  182. package/build/modules/dumper/errors.js +0 -119
  183. package/build/modules/encryption.d.ts +0 -1
  184. package/build/modules/encryption.js +0 -9
  185. package/build/modules/hash/define_config.js +0 -125
  186. package/build/modules/http/request_validator.js +0 -100
  187. package/build/src/assembler_hooks/index_entities.js +0 -107
  188. package/build/src/cli_formatters/routes_list.js +0 -381
  189. package/build/src/config_provider.js +0 -71
  190. package/build/src/debug.js +0 -25
  191. package/build/src/ignitor/ace.js +0 -102
  192. package/build/src/ignitor/http.js +0 -146
  193. package/build/src/ignitor/main.js +0 -124
  194. package/build/src/ignitor/test.js +0 -66
  195. package/build/src/test_utils/http.js +0 -82
  196. package/build/src/utils.js +0 -104
  197. package/build/stubs/main.js +0 -9
  198. package/build/toolkit/commands/index_commands.js +0 -30
  199. /package/build/{stubs/make → make}/command/main.stub +0 -0
  200. /package/build/{stubs/make → make}/controller/actions.stub +0 -0
  201. /package/build/{stubs/make → make}/controller/api.stub +0 -0
  202. /package/build/{stubs/make → make}/controller/main.stub +0 -0
  203. /package/build/{stubs/make → make}/controller/resource.stub +0 -0
  204. /package/build/{stubs/make → make}/event/main.stub +0 -0
  205. /package/build/{stubs/make → make}/exception/main.stub +0 -0
  206. /package/build/{stubs/make → make}/health/main.stub +0 -0
  207. /package/build/{stubs/make → make}/listener/for_event.stub +0 -0
  208. /package/build/{stubs/make → make}/listener/main.stub +0 -0
  209. /package/build/{stubs/make → make}/middleware/main.stub +0 -0
  210. /package/build/{stubs/make → make}/preload/main.stub +0 -0
  211. /package/build/{stubs/make → make}/provider/main.stub +0 -0
  212. /package/build/{stubs/make → make}/service/main.stub +0 -0
  213. /package/build/{stubs/make → make}/test/main.stub +0 -0
  214. /package/build/{stubs/make → make}/transformer/main.stub +0 -0
  215. /package/build/{stubs/make → make}/validator/main.stub +0 -0
  216. /package/build/{stubs/make → make}/validator/resource.stub +0 -0
  217. /package/build/{stubs/make → make}/view/main.stub +0 -0
@@ -1,256 +0,0 @@
1
- /*
2
- * @adonisjs/core
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- import useColors from '@poppinss/colors';
10
- import { dump as consoleDump } from '@poppinss/dumper/console';
11
- import { createScript, createStyleSheet, dump } from '@poppinss/dumper/html';
12
- import { E_DUMP_DIE_EXCEPTION } from "./errors.js";
13
- const colors = useColors.ansi();
14
- const DUMP_TITLE_STYLES = `
15
- .adonisjs-dump-header {
16
- font-family: JetBrains Mono, monaspace argon, Menlo, Monaco, Consolas, monospace;
17
- background: #ff1639;
18
- border-radius: 4px;
19
- color: #fff;
20
- border-bottom-left-radius: 0;
21
- border-bottom-right-radius: 0;
22
- padding: 0.4rem 1.2rem;
23
- font-size: 1em;
24
- display: flex;
25
- justify-content: space-between;
26
- }
27
- .adonisjs-dump-header .adonisjs-dump-header-title {
28
- font-weight: bold;
29
- text-transform: uppercase;
30
- }
31
- .adonisjs-dump-header .adonisjs-dump-header-source {
32
- font-weight: bold;
33
- color: inherit;
34
- text-decoration: underline;
35
- }
36
- .dumper-dump pre {
37
- border-radius: 4px;
38
- border-top-left-radius: 0;
39
- border-top-right-radius: 0;
40
- }`;
41
- const IDE = process.env.ADONIS_IDE ?? process.env.EDITOR ?? '';
42
- /**
43
- * Dumper exposes the API to dump or die/dump values in your
44
- * AdonisJS application. An singleton instance of the Dumper
45
- * is shared as a service and may use it follows.
46
- *
47
- * ```ts
48
- * const dumper = container.make('dumper')
49
- *
50
- * dumper.configureHtmlOutput({
51
- * // parser + html formatter config
52
- * })
53
- *
54
- * dumper.configureAnsiOutput({
55
- * // parser + console formatter config
56
- * })
57
- *
58
- * const html = dumper.dumpToHtml(value)
59
- * const ansi = dumper.dumpToAnsi(value)
60
- *
61
- * // Returns style and script tags that must be
62
- * // injeted to the head of the HTML document
63
- *
64
- * const head = dumper.getHeadElements()
65
- * ```
66
- */
67
- export class Dumper {
68
- #app;
69
- /**
70
- * Configuration for the HTML formatter
71
- */
72
- #htmlConfig = {};
73
- /**
74
- * Configuration for the Console formatter
75
- */
76
- #consoleConfig = {
77
- collapse: ['DateTime', 'Date'],
78
- };
79
- /**
80
- * A collections of known editors to create URLs to open
81
- * them
82
- */
83
- #editors = {
84
- textmate: 'txmt://open?url=file://%f&line=%l',
85
- macvim: 'mvim://open?url=file://%f&line=%l',
86
- emacs: 'emacs://open?url=file://%f&line=%l',
87
- sublime: 'subl://open?url=file://%f&line=%l',
88
- phpstorm: 'phpstorm://open?file=%f&line=%l',
89
- atom: 'atom://core/open/file?filename=%f&line=%l',
90
- vscode: 'vscode://file/%f:%l',
91
- };
92
- constructor(app) {
93
- this.#app = app;
94
- }
95
- /**
96
- * Returns the link to open the file using dd inside one
97
- * of the known code editors
98
- */
99
- #getEditorLink(source) {
100
- const editorURL = this.#editors[IDE] || IDE;
101
- if (!editorURL || !source) {
102
- return;
103
- }
104
- return {
105
- href: editorURL.replace('%f', source.location).replace('%l', String(source.line)),
106
- text: `${this.#app.relativePath(source.location)}:${source.line}`,
107
- };
108
- }
109
- /**
110
- * Configure the HTML formatter output options
111
- *
112
- * @param config - Configuration options for HTML dump formatting
113
- *
114
- * @example
115
- * ```ts
116
- * dumper.configureHtmlOutput({
117
- * showHidden: true,
118
- * depth: 5,
119
- * colors: false
120
- * })
121
- * ```
122
- */
123
- configureHtmlOutput(config) {
124
- this.#htmlConfig = config;
125
- return this;
126
- }
127
- /**
128
- * Configure the ANSI formatter output options for console display
129
- *
130
- * @param config - Configuration options for ANSI console formatting
131
- *
132
- * @example
133
- * ```ts
134
- * dumper.configureAnsiOutput({
135
- * showHidden: true,
136
- * depth: 3,
137
- * collapse: ['Date', 'DateTime']
138
- * })
139
- * ```
140
- */
141
- configureAnsiOutput(config) {
142
- this.#consoleConfig = config;
143
- return this;
144
- }
145
- /**
146
- * Returns the style and script elements that need to be injected into
147
- * the HTML document head for proper dump visualization
148
- *
149
- * @param cspNonce - Optional Content Security Policy nonce for inline scripts
150
- *
151
- * @example
152
- * ```ts
153
- * const headElements = dumper.getHeadElements('abc123')
154
- * // Insert into your HTML head section
155
- * ```
156
- */
157
- getHeadElements(cspNonce) {
158
- return (`<style id="dumper-styles">` +
159
- createStyleSheet() +
160
- DUMP_TITLE_STYLES +
161
- '</style>' +
162
- `<script id="dumper-script"${cspNonce ? ` nonce="${cspNonce}"` : ''}>` +
163
- createScript() +
164
- '</script>');
165
- }
166
- /**
167
- * Dump a value to formatted HTML output
168
- *
169
- * @param value - The value to dump and inspect
170
- * @param options - Options for HTML output formatting
171
- * @param options.cspNonce - Optional Content Security Policy nonce
172
- * @param options.title - Optional title to display in the dump header
173
- * @param options.source - Optional source file information for editor links
174
- *
175
- * @example
176
- * ```ts
177
- * const htmlOutput = dumper.dumpToHtml(user, {
178
- * title: 'User Object',
179
- * source: { location: '/app/controllers/user.ts', line: 42 }
180
- * })
181
- * ```
182
- */
183
- dumpToHtml(value, options = {}) {
184
- const link = this.#getEditorLink(options.source) ?? null;
185
- const title = options.title || 'DUMP';
186
- return ('<div class="adonisjs-dump-header">' +
187
- `<span class="adonisjs-dump-header-title">${title}</span>` +
188
- (link ? `<a href="${link.href}" class="adonisjs-dump-header-source">${link.text}</a>` : '') +
189
- '</div>' +
190
- dump(value, { cspNonce: options.cspNonce, ...this.#htmlConfig }));
191
- }
192
- /**
193
- * Dump a value to formatted ANSI output for console display
194
- *
195
- * @param value - The value to dump and inspect
196
- * @param options - Options for ANSI output formatting
197
- * @param options.title - Optional title to display in the dump header
198
- * @param options.source - Optional source file information for editor links
199
- *
200
- * @example
201
- * ```ts
202
- * const ansiOutput = dumper.dumpToAnsi(user, {
203
- * title: 'User Debug',
204
- * source: { location: '/app/controllers/user.ts', line: 42 }
205
- * })
206
- * console.log(ansiOutput)
207
- * ```
208
- */
209
- dumpToAnsi(value, options = {}) {
210
- const columns = process.stdout.columns;
211
- /**
212
- * Link to the source file
213
- */
214
- const link = `${this.#getEditorLink(options.source)?.text ?? ''} `;
215
- /**
216
- * Dump title
217
- */
218
- const title = ` ${options.title || 'DUMP'}`;
219
- /**
220
- * Whitespace between the title and the link to align them
221
- * on each side of x axis
222
- */
223
- const whiteSpaceLength = columns ? columns - link.length - title.length - 4 : 2;
224
- const whiteSpace = new Array(whiteSpaceLength <= 0 ? 2 : whiteSpaceLength).join(' ');
225
- /**
226
- * Styled heading with background color and bold text
227
- */
228
- const heading = colors.bgRed().bold(`${title}${whiteSpace}${link}`);
229
- return `${heading}\n${consoleDump(value, this.#consoleConfig)}`;
230
- }
231
- /**
232
- * Dump values and die. This method dumps the provided value and then
233
- * terminates the application. The output format is automatically chosen
234
- * based on the execution context.
235
- *
236
- * - During an HTTP request, HTML output will be sent to the browser
237
- * - Otherwise the value will be logged to the console in ANSI format
238
- *
239
- * @param value - The value to dump before terminating
240
- * @param traceSourceIndex - Stack trace index for source location (default: 1)
241
- *
242
- * @example
243
- * ```ts
244
- * // This will dump the user object and terminate the application
245
- * dumper.dd(user)
246
- *
247
- * // This will never execute
248
- * console.log('This line will not run')
249
- * ```
250
- */
251
- dd(value, traceSourceIndex = 1) {
252
- const error = new E_DUMP_DIE_EXCEPTION(value, this);
253
- error.setTraceSourceIndex(traceSourceIndex);
254
- throw error;
255
- }
256
- }
@@ -1,119 +0,0 @@
1
- /*
2
- * @adonisjs/core
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- import { inspect } from 'node:util';
10
- import { parse } from 'error-stack-parser-es';
11
- import { Exception } from '@poppinss/utils/exception';
12
- /**
13
- * DumpDie exception raised by the "dd" (dump and die) function.
14
- * This special exception terminates execution while dumping the provided
15
- * value as HTML (during HTTP requests) or ANSI (in console/CLI).
16
- *
17
- * @example
18
- * ```ts
19
- * // This will dump the user object and terminate
20
- * dumper.dd(user)
21
- *
22
- * // In HTTP context: sends HTML dump to browser
23
- * // In CLI context: prints ANSI dump to console
24
- * ```
25
- */
26
- class DumpDieException extends Exception {
27
- static status = 500;
28
- static code = 'E_DUMP_DIE_EXCEPTION';
29
- #dumper;
30
- #traceSourceIndex = 1;
31
- value;
32
- constructor(value, dumper) {
33
- super('Dump and Die exception');
34
- this.#dumper = dumper;
35
- this.value = value;
36
- }
37
- /**
38
- * Returns the source file and line number location for the error
39
- */
40
- #getErrorSource() {
41
- if (this.fileName && this.lineNumber) {
42
- return {
43
- location: this.fileName,
44
- line: this.lineNumber,
45
- };
46
- }
47
- const source = parse(this)[this.#traceSourceIndex];
48
- if (!source.fileName || !source.lineNumber) {
49
- return;
50
- }
51
- return {
52
- location: source.fileName,
53
- line: source.lineNumber,
54
- };
55
- }
56
- /**
57
- * Set the stack trace index for determining the source location.
58
- * This is useful when building nested helpers on top of dump/die functionality.
59
- *
60
- * @param index - Stack trace index (0 = current function, 1 = caller, etc.)
61
- */
62
- setTraceSourceIndex(index) {
63
- this.#traceSourceIndex = index;
64
- return this;
65
- }
66
- /**
67
- * Preventing itself from getting reported by the
68
- * AdonisJS exception reporter
69
- */
70
- report() { }
71
- /**
72
- * HTTP exception handler that renders the dump as HTML output.
73
- * This method is called automatically by AdonisJS when a DumpDieException
74
- * is thrown during an HTTP request.
75
- *
76
- * @param error - The DumpDieException instance
77
- * @param ctx - HTTP context for the current request
78
- */
79
- async handle(error, ctx) {
80
- const source = this.#getErrorSource();
81
- /**
82
- * Comes from the shield package
83
- */
84
- const cspNonce = 'nonce' in ctx.response ? ctx.response.nonce : undefined;
85
- ctx.response
86
- .status(500)
87
- .send('<!DOCTYPE html>' +
88
- '<html>' +
89
- '<head>' +
90
- '<meta charset="utf-8">' +
91
- '<meta name="viewport" content="width=device-width">' +
92
- `${this.#dumper.getHeadElements(cspNonce)}` +
93
- '</head>' +
94
- '<body>' +
95
- `${this.#dumper.dumpToHtml(error.value, { cspNonce, source, title: 'DUMP DIE' })}` +
96
- '</body>' +
97
- '</html>');
98
- }
99
- /**
100
- * Ace command exception handler that renders the dump as ANSI output.
101
- * This method is called automatically by the Ace kernel when a DumpDieException
102
- * is thrown during command execution.
103
- *
104
- * @param error - The DumpDieException instance
105
- * @param kernel - Ace kernel instance
106
- */
107
- async render(error, kernel) {
108
- const source = this.#getErrorSource();
109
- kernel.ui.logger.log(this.#dumper.dumpToAnsi(error.value, { source, title: 'DUMP DIE' }));
110
- }
111
- /**
112
- * Custom output for the Node.js util inspect
113
- */
114
- [inspect.custom]() {
115
- const source = this.#getErrorSource();
116
- return this.#dumper.dumpToAnsi(this.value, { source, title: 'DUMP DIE' });
117
- }
118
- }
119
- export const E_DUMP_DIE_EXCEPTION = DumpDieException;
@@ -1 +0,0 @@
1
- export * from '@adonisjs/encryption';
@@ -1,9 +0,0 @@
1
- /*
2
- * @adonisjs/core
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- export * from '@adonisjs/encryption';
@@ -1,125 +0,0 @@
1
- /*
2
- * @adonisjs/core
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- import { InvalidArgumentsException } from '@poppinss/utils/exception';
10
- import debug from "../../src/debug.js";
11
- import { configProvider } from "../../src/config_provider.js";
12
- /**
13
- * Define config for the hash service. This function creates a configuration
14
- * provider that lazily imports and resolves hash drivers when needed.
15
- *
16
- * @param config - Configuration object containing default hasher and list of hashers
17
- * @param config.default - Optional default hasher name (must exist in the list)
18
- * @param config.list - Record of hasher configurations or config providers
19
- *
20
- * @example
21
- * ```ts
22
- * const hashConfig = defineConfig({
23
- * default: 'scrypt',
24
- * list: {
25
- * scrypt: drivers.scrypt({
26
- * cost: 16384,
27
- * blockSize: 8,
28
- * parallelization: 1,
29
- * saltSize: 16,
30
- * keyLength: 64,
31
- * }),
32
- * bcrypt: drivers.bcrypt({
33
- * rounds: 10,
34
- * })
35
- * }
36
- * })
37
- * ```
38
- */
39
- export function defineConfig(config) {
40
- /**
41
- * Hashers list should always be provided
42
- */
43
- if (!config.list) {
44
- throw new InvalidArgumentsException('Missing "list" property in hash config');
45
- }
46
- /**
47
- * The default hasher should be mentioned in the list
48
- */
49
- if (config.default && !config.list[config.default]) {
50
- throw new InvalidArgumentsException(`Missing "list.${String(config.default)}" in hash config. It is referenced by the "default" property`);
51
- }
52
- /**
53
- * Config provider to lazily import drivers as they are used inside
54
- * the user application
55
- */
56
- return configProvider.create(async (app) => {
57
- debug('resolving hash config');
58
- const hashersList = Object.keys(config.list);
59
- const hashers = {};
60
- for (let hasherName of hashersList) {
61
- const hasher = config.list[hasherName];
62
- if (typeof hasher === 'function') {
63
- hashers[hasherName] = hasher;
64
- }
65
- else {
66
- hashers[hasherName] = await hasher.resolver(app);
67
- }
68
- }
69
- return {
70
- default: config.default,
71
- list: hashers,
72
- };
73
- });
74
- }
75
- /**
76
- * Helpers to configure drivers inside the config file. These functions create
77
- * configuration providers that lazily import and instantiate hash drivers.
78
- *
79
- * - Import happens when you first use the hash module
80
- * - Construction of drivers happens when you first use a driver
81
- *
82
- * @example
83
- * ```ts
84
- * const hashConfig = defineConfig({
85
- * default: 'bcrypt',
86
- * list: {
87
- * bcrypt: drivers.bcrypt({ rounds: 12 }),
88
- * argon2: drivers.argon2({
89
- * variant: 'id',
90
- * memory: 65536,
91
- * time: 3,
92
- * parallelism: 4
93
- * }),
94
- * scrypt: drivers.scrypt({
95
- * cost: 16384,
96
- * blockSize: 8,
97
- * parallelization: 1
98
- * })
99
- * }
100
- * })
101
- * ```
102
- */
103
- export const drivers = {
104
- argon2: (config) => {
105
- return configProvider.create(async () => {
106
- const { Argon } = await import('./drivers/argon.js');
107
- debug('configuring argon driver');
108
- return () => new Argon(config);
109
- });
110
- },
111
- bcrypt: (config) => {
112
- return configProvider.create(async () => {
113
- const { Bcrypt } = await import('./drivers/bcrypt.js');
114
- debug('configuring bcrypt driver');
115
- return () => new Bcrypt(config);
116
- });
117
- },
118
- scrypt: (config) => {
119
- return configProvider.create(async () => {
120
- const { Scrypt } = await import('./drivers/scrypt.js');
121
- debug('configuring scrypt driver');
122
- return () => new Scrypt(config);
123
- });
124
- },
125
- };
@@ -1,100 +0,0 @@
1
- /*
2
- * @adonisjs/core
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- /**
10
- * Request validator for validating HTTP request data using VineJS validators.
11
- * This class provides a convenient way to validate request body, files, cookies,
12
- * headers, and URL parameters in AdonisJS applications.
13
- *
14
- * @example
15
- * ```ts
16
- * // Inside a controller method
17
- * const data = await request.validateUsing(createUserValidator, {
18
- * messagesProvider: customMessages
19
- * })
20
- * ```
21
- */
22
- export class RequestValidator {
23
- #ctx;
24
- #experimentalFlags;
25
- constructor(ctx, experimentalFlags) {
26
- this.#ctx = ctx;
27
- this.#experimentalFlags = experimentalFlags;
28
- }
29
- /**
30
- * The error reporter method returns the error reporter
31
- * to use for reporting errors.
32
- *
33
- * You can use this function to pick a different error reporter
34
- * for each HTTP request
35
- */
36
- static errorReporter;
37
- /**
38
- * The messages provider method returns the messages provider to use
39
- * finding custom error messages
40
- *
41
- * You can use this function to pick a different messages provider for
42
- * each HTTP request
43
- */
44
- static messagesProvider;
45
- /**
46
- * Validate the current HTTP request data using a VineJS validator.
47
- * This method automatically includes request body, files, URL parameters,
48
- * headers, and cookies in the validation data.
49
- *
50
- * @param validator - VineJS validator instance
51
- * @param options - Optional validation options including custom error reporters and messages
52
- *
53
- * @example
54
- * ```ts
55
- * const createUserValidator = vine.compile(
56
- * vine.object({
57
- * email: vine.string().email(),
58
- * name: vine.string().minLength(3)
59
- * })
60
- * )
61
- *
62
- * const data = await request.validateUsing(createUserValidator, {
63
- * errorReporter: () => vine.errors.SimpleErrorReporter,
64
- * messagesProvider: customMessages
65
- * })
66
- * ```
67
- */
68
- validateUsing(validator, ...[options]) {
69
- const validatorOptions = options || {};
70
- /**
71
- * Assign request specific error reporter
72
- */
73
- if (RequestValidator.errorReporter && !validatorOptions.errorReporter) {
74
- const errorReporter = RequestValidator.errorReporter(this.#ctx);
75
- validatorOptions.errorReporter = () => errorReporter;
76
- }
77
- /**
78
- * Assign request specific messages provider
79
- */
80
- if (RequestValidator.messagesProvider && !validatorOptions.messagesProvider) {
81
- validatorOptions.messagesProvider = RequestValidator.messagesProvider(this.#ctx);
82
- }
83
- const requestBody = this.#experimentalFlags?.enabled('mergeMultipartFieldsAndFiles')
84
- ? this.#ctx.request.all()
85
- : {
86
- ...this.#ctx.request.all(),
87
- ...this.#ctx.request.allFiles(),
88
- };
89
- /**
90
- * Data to validate
91
- */
92
- const data = validatorOptions.data || {
93
- ...requestBody,
94
- params: this.#ctx.request.params(),
95
- headers: this.#ctx.request.headers(),
96
- cookies: this.#ctx.request.cookiesList(),
97
- };
98
- return validator.validate(data, validatorOptions);
99
- }
100
- }