@adonisjs/core 6.19.0 → 7.0.0-next.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/build/commands/add.d.ts +4 -5
- package/build/commands/add.js +7 -60
- package/build/commands/build.d.ts +1 -3
- package/build/commands/build.js +4 -36
- package/build/commands/commands.json +1 -1
- package/build/commands/configure.d.ts +3 -3
- package/build/commands/configure.js +3 -3
- package/build/commands/eject.d.ts +1 -1
- package/build/commands/eject.js +3 -3
- package/build/commands/env/add.d.ts +2 -2
- package/build/commands/env/add.js +2 -2
- package/build/commands/generate_key.d.ts +1 -1
- package/build/commands/generate_key.js +1 -1
- package/build/commands/inspect_rcfile.d.ts +1 -1
- package/build/commands/inspect_rcfile.js +1 -1
- package/build/commands/list/routes.d.ts +2 -2
- package/build/commands/list/routes.js +2 -2
- package/build/commands/make/command.d.ts +1 -1
- package/build/commands/make/command.js +3 -3
- package/build/commands/make/controller.d.ts +2 -2
- package/build/commands/make/controller.js +2 -2
- package/build/commands/make/event.d.ts +2 -2
- package/build/commands/make/event.js +2 -2
- package/build/commands/make/exception.d.ts +2 -2
- package/build/commands/make/exception.js +2 -2
- package/build/commands/make/listener.d.ts +2 -2
- package/build/commands/make/listener.js +2 -2
- package/build/commands/make/middleware.d.ts +2 -2
- package/build/commands/make/middleware.js +4 -4
- package/build/commands/make/preload.d.ts +1 -1
- package/build/commands/make/preload.js +4 -4
- package/build/commands/make/provider.d.ts +1 -1
- package/build/commands/make/provider.js +4 -4
- package/build/commands/make/service.d.ts +2 -2
- package/build/commands/make/service.js +2 -2
- package/build/commands/make/test.d.ts +1 -1
- package/build/commands/make/test.js +2 -2
- package/build/commands/make/validator.d.ts +2 -2
- package/build/commands/make/validator.js +2 -2
- package/build/commands/make/view.d.ts +1 -1
- package/build/commands/make/view.js +2 -2
- package/build/commands/repl.d.ts +2 -2
- package/build/commands/repl.js +1 -1
- package/build/commands/serve.d.ts +2 -4
- package/build/commands/serve.js +11 -43
- package/build/commands/test.d.ts +2 -4
- package/build/commands/test.js +4 -32
- package/build/factories/core/ace.d.ts +31 -4
- package/build/factories/core/ace.js +20 -4
- package/build/factories/core/ignitor.d.ts +80 -9
- package/build/factories/core/ignitor.js +84 -13
- package/build/factories/core/main.d.ts +3 -3
- package/build/factories/core/main.js +3 -3
- package/build/factories/core/test_utils.d.ts +32 -4
- package/build/factories/core/test_utils.js +21 -4
- package/build/factories/stubs.d.ts +54 -5
- package/build/factories/stubs.js +55 -6
- package/build/index.d.ts +5 -4
- package/build/index.js +13 -9
- package/build/modules/ace/codemods.d.ts +71 -11
- package/build/modules/ace/codemods.js +90 -22
- package/build/modules/ace/commands.d.ts +49 -13
- package/build/modules/ace/commands.js +48 -10
- package/build/modules/ace/create_kernel.d.ts +19 -8
- package/build/modules/ace/create_kernel.js +19 -8
- package/build/modules/ace/kernel.d.ts +18 -4
- package/build/modules/ace/kernel.js +17 -3
- package/build/modules/ace/main.d.ts +3 -3
- package/build/modules/ace/main.js +3 -3
- package/build/modules/dumper/define_config.d.ts +25 -4
- package/build/modules/dumper/define_config.js +23 -2
- package/build/modules/dumper/dumper.d.ts +82 -12
- package/build/modules/dumper/dumper.js +82 -12
- package/build/modules/dumper/errors.d.ts +31 -10
- package/build/modules/dumper/errors.js +28 -7
- package/build/modules/dumper/main.d.ts +3 -3
- package/build/modules/dumper/main.js +3 -3
- package/build/modules/dumper/plugins/edge.d.ts +1 -1
- package/build/modules/hash/define_config.d.ts +53 -8
- package/build/modules/hash/define_config.js +51 -6
- package/build/modules/hash/main.d.ts +1 -1
- package/build/modules/hash/main.js +1 -1
- package/build/modules/http/main.d.ts +1 -1
- package/build/modules/http/main.js +1 -1
- package/build/modules/http/request_validator.d.ts +36 -9
- package/build/modules/http/request_validator.js +32 -5
- package/build/modules/transformers/main.d.ts +1 -0
- package/build/modules/transformers/main.js +9 -0
- package/build/providers/app_provider.d.ts +173 -1
- package/build/providers/app_provider.js +204 -8
- package/build/providers/edge_provider.d.ts +31 -2
- package/build/providers/edge_provider.js +31 -2
- package/build/providers/hash_provider.d.ts +38 -1
- package/build/providers/hash_provider.js +40 -3
- package/build/providers/repl_provider.d.ts +40 -1
- package/build/providers/repl_provider.js +52 -2
- package/build/providers/vinejs_provider.d.ts +32 -5
- package/build/providers/vinejs_provider.js +31 -4
- package/build/services/ace.d.ts +1 -1
- package/build/services/ace.js +1 -1
- package/build/services/app.d.ts +1 -1
- package/build/services/config.d.ts +1 -1
- package/build/services/config.js +1 -1
- package/build/services/dumper.js +1 -1
- package/build/services/emitter.d.ts +1 -1
- package/build/services/emitter.js +1 -1
- package/build/services/encryption.d.ts +1 -1
- package/build/services/encryption.js +1 -1
- package/build/services/hash.d.ts +1 -1
- package/build/services/hash.js +1 -1
- package/build/services/logger.d.ts +1 -1
- package/build/services/logger.js +1 -1
- package/build/services/repl.d.ts +1 -1
- package/build/services/repl.js +1 -1
- package/build/services/router.d.ts +1 -1
- package/build/services/router.js +1 -1
- package/build/services/server.d.ts +1 -1
- package/build/services/server.js +1 -1
- package/build/services/test_utils.d.ts +1 -1
- package/build/services/test_utils.js +1 -1
- package/build/services/url_builder.d.ts +4 -0
- package/build/services/url_builder.js +21 -0
- package/build/src/assembler_hooks/index_entities.d.ts +51 -0
- package/build/src/assembler_hooks/index_entities.js +96 -0
- package/build/src/cli_formatters/routes_list.d.ts +24 -12
- package/build/src/cli_formatters/routes_list.js +43 -46
- package/build/src/config_provider.d.ts +48 -3
- package/build/src/config_provider.js +47 -2
- package/build/src/debug.d.ts +15 -0
- package/build/src/debug.js +15 -0
- package/build/src/exceptions.d.ts +41 -1
- package/build/src/exceptions.js +41 -1
- package/build/src/helpers/assert.d.ts +47 -1
- package/build/src/helpers/assert.js +47 -1
- package/build/src/helpers/is.d.ts +21 -0
- package/build/src/helpers/is.js +21 -0
- package/build/src/helpers/main.d.ts +48 -5
- package/build/src/helpers/main.js +48 -5
- package/build/src/helpers/string.d.ts +89 -9
- package/build/src/helpers/string.js +15 -2
- package/build/src/helpers/types.d.ts +96 -2
- package/build/src/helpers/types.js +96 -2
- package/build/src/helpers/verification_token.d.ts +22 -1
- package/build/src/helpers/verification_token.js +24 -2
- package/build/src/ignitor/ace.d.ts +23 -3
- package/build/src/ignitor/ace.js +21 -1
- package/build/src/ignitor/http.d.ts +16 -3
- package/build/src/ignitor/http.js +16 -3
- package/build/src/ignitor/main.d.ts +29 -6
- package/build/src/ignitor/main.js +30 -7
- package/build/src/ignitor/test.d.ts +26 -3
- package/build/src/ignitor/test.js +24 -1
- package/build/src/test_utils/http.d.ts +19 -3
- package/build/src/test_utils/http.js +24 -3
- package/build/src/test_utils/main.d.ts +22 -4
- package/build/src/test_utils/main.js +21 -3
- package/build/src/types.d.ts +277 -26
- package/build/src/utils.d.ts +34 -0
- package/build/src/utils.js +49 -0
- package/build/src/vine.d.ts +24 -1
- package/build/src/vine.js +27 -1
- package/build/stubs/main.js +1 -2
- package/build/toolkit/main.js +1 -1
- package/build/types/helpers.d.ts +2 -1
- package/build/types/transformers.d.ts +1 -0
- package/build/types/transformers.js +9 -0
- package/package.json +51 -50
- package/build/src/helpers/parse_binding_reference.d.ts +0 -45
- package/build/src/helpers/parse_binding_reference.js +0 -83
- package/build/src/internal_helpers.d.ts +0 -15
- package/build/src/internal_helpers.js +0 -63
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HTMLDumpConfig } from '@poppinss/dumper/html/types';
|
|
2
2
|
import type { ConsoleDumpConfig } from '@poppinss/dumper/console/types';
|
|
3
|
-
import type { Application } from '../app.
|
|
3
|
+
import type { Application } from '../app.ts';
|
|
4
4
|
/**
|
|
5
5
|
* Dumper exposes the API to dump or die/dump values in your
|
|
6
6
|
* AdonisJS application. An singleton instance of the Dumper
|
|
@@ -30,20 +30,64 @@ export declare class Dumper {
|
|
|
30
30
|
#private;
|
|
31
31
|
constructor(app: Application<any>);
|
|
32
32
|
/**
|
|
33
|
-
* Configure the HTML formatter output
|
|
33
|
+
* Configure the HTML formatter output options
|
|
34
|
+
*
|
|
35
|
+
* @param config - Configuration options for HTML dump formatting
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* dumper.configureHtmlOutput({
|
|
40
|
+
* showHidden: true,
|
|
41
|
+
* depth: 5,
|
|
42
|
+
* colors: false
|
|
43
|
+
* })
|
|
44
|
+
* ```
|
|
34
45
|
*/
|
|
35
46
|
configureHtmlOutput(config: HTMLDumpConfig): this;
|
|
36
47
|
/**
|
|
37
|
-
* Configure the ANSI formatter output
|
|
48
|
+
* Configure the ANSI formatter output options for console display
|
|
49
|
+
*
|
|
50
|
+
* @param config - Configuration options for ANSI console formatting
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* dumper.configureAnsiOutput({
|
|
55
|
+
* showHidden: true,
|
|
56
|
+
* depth: 3,
|
|
57
|
+
* collapse: ['Date', 'DateTime']
|
|
58
|
+
* })
|
|
59
|
+
* ```
|
|
38
60
|
*/
|
|
39
61
|
configureAnsiOutput(config: ConsoleDumpConfig): this;
|
|
40
62
|
/**
|
|
41
|
-
* Returns the style and
|
|
42
|
-
* HTML document
|
|
63
|
+
* Returns the style and script elements that need to be injected into
|
|
64
|
+
* the HTML document head for proper dump visualization
|
|
65
|
+
*
|
|
66
|
+
* @param cspNonce - Optional Content Security Policy nonce for inline scripts
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* const headElements = dumper.getHeadElements('abc123')
|
|
71
|
+
* // Insert into your HTML head section
|
|
72
|
+
* ```
|
|
43
73
|
*/
|
|
44
74
|
getHeadElements(cspNonce?: string): string;
|
|
45
75
|
/**
|
|
46
|
-
* Dump value to HTML
|
|
76
|
+
* Dump a value to formatted HTML output
|
|
77
|
+
*
|
|
78
|
+
* @param value - The value to dump and inspect
|
|
79
|
+
* @param options - Options for HTML output formatting
|
|
80
|
+
* @param options.cspNonce - Optional Content Security Policy nonce
|
|
81
|
+
* @param options.title - Optional title to display in the dump header
|
|
82
|
+
* @param options.source - Optional source file information for editor links
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* const htmlOutput = dumper.dumpToHtml(user, {
|
|
87
|
+
* title: 'User Object',
|
|
88
|
+
* source: { location: '/app/controllers/user.ts', line: 42 }
|
|
89
|
+
* })
|
|
90
|
+
* ```
|
|
47
91
|
*/
|
|
48
92
|
dumpToHtml(value: unknown, options?: {
|
|
49
93
|
cspNonce?: string;
|
|
@@ -54,7 +98,21 @@ export declare class Dumper {
|
|
|
54
98
|
};
|
|
55
99
|
}): string;
|
|
56
100
|
/**
|
|
57
|
-
* Dump value to ANSI output
|
|
101
|
+
* Dump a value to formatted ANSI output for console display
|
|
102
|
+
*
|
|
103
|
+
* @param value - The value to dump and inspect
|
|
104
|
+
* @param options - Options for ANSI output formatting
|
|
105
|
+
* @param options.title - Optional title to display in the dump header
|
|
106
|
+
* @param options.source - Optional source file information for editor links
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* const ansiOutput = dumper.dumpToAnsi(user, {
|
|
111
|
+
* title: 'User Debug',
|
|
112
|
+
* source: { location: '/app/controllers/user.ts', line: 42 }
|
|
113
|
+
* })
|
|
114
|
+
* console.log(ansiOutput)
|
|
115
|
+
* ```
|
|
58
116
|
*/
|
|
59
117
|
dumpToAnsi(value: unknown, options?: {
|
|
60
118
|
title?: string;
|
|
@@ -64,12 +122,24 @@ export declare class Dumper {
|
|
|
64
122
|
};
|
|
65
123
|
}): string;
|
|
66
124
|
/**
|
|
67
|
-
* Dump values and die.
|
|
68
|
-
*
|
|
125
|
+
* Dump values and die. This method dumps the provided value and then
|
|
126
|
+
* terminates the application. The output format is automatically chosen
|
|
127
|
+
* based on the execution context.
|
|
128
|
+
*
|
|
129
|
+
* - During an HTTP request, HTML output will be sent to the browser
|
|
130
|
+
* - Otherwise the value will be logged to the console in ANSI format
|
|
131
|
+
*
|
|
132
|
+
* @param value - The value to dump before terminating
|
|
133
|
+
* @param traceSourceIndex - Stack trace index for source location (default: 1)
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```ts
|
|
137
|
+
* // This will dump the user object and terminate the application
|
|
138
|
+
* dumper.dd(user)
|
|
69
139
|
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
140
|
+
* // This will never execute
|
|
141
|
+
* console.log('This line will not run')
|
|
142
|
+
* ```
|
|
73
143
|
*/
|
|
74
144
|
dd(value: unknown, traceSourceIndex?: number): void;
|
|
75
145
|
}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import useColors from '@poppinss/colors';
|
|
10
10
|
import { dump as consoleDump } from '@poppinss/dumper/console';
|
|
11
11
|
import { createScript, createStyleSheet, dump } from '@poppinss/dumper/html';
|
|
12
|
-
import { E_DUMP_DIE_EXCEPTION } from
|
|
12
|
+
import { E_DUMP_DIE_EXCEPTION } from "./errors.js";
|
|
13
13
|
const colors = useColors.ansi();
|
|
14
14
|
const DUMP_TITLE_STYLES = `
|
|
15
15
|
.adonisjs-dump-header {
|
|
@@ -107,22 +107,52 @@ export class Dumper {
|
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
109
|
/**
|
|
110
|
-
* Configure the HTML formatter output
|
|
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
|
+
* ```
|
|
111
122
|
*/
|
|
112
123
|
configureHtmlOutput(config) {
|
|
113
124
|
this.#htmlConfig = config;
|
|
114
125
|
return this;
|
|
115
126
|
}
|
|
116
127
|
/**
|
|
117
|
-
* Configure the ANSI formatter output
|
|
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
|
+
* ```
|
|
118
140
|
*/
|
|
119
141
|
configureAnsiOutput(config) {
|
|
120
142
|
this.#consoleConfig = config;
|
|
121
143
|
return this;
|
|
122
144
|
}
|
|
123
145
|
/**
|
|
124
|
-
* Returns the style and
|
|
125
|
-
* HTML document
|
|
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
|
+
* ```
|
|
126
156
|
*/
|
|
127
157
|
getHeadElements(cspNonce) {
|
|
128
158
|
return (`<style id="dumper-styles">` +
|
|
@@ -134,7 +164,21 @@ export class Dumper {
|
|
|
134
164
|
'</script>');
|
|
135
165
|
}
|
|
136
166
|
/**
|
|
137
|
-
* Dump value to HTML
|
|
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
|
+
* ```
|
|
138
182
|
*/
|
|
139
183
|
dumpToHtml(value, options = {}) {
|
|
140
184
|
const link = this.#getEditorLink(options.source) ?? null;
|
|
@@ -146,7 +190,21 @@ export class Dumper {
|
|
|
146
190
|
dump(value, { cspNonce: options.cspNonce, ...this.#htmlConfig }));
|
|
147
191
|
}
|
|
148
192
|
/**
|
|
149
|
-
* Dump value to ANSI output
|
|
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
|
+
* ```
|
|
150
208
|
*/
|
|
151
209
|
dumpToAnsi(value, options = {}) {
|
|
152
210
|
const columns = process.stdout.columns;
|
|
@@ -171,12 +229,24 @@ export class Dumper {
|
|
|
171
229
|
return `${heading}\n${consoleDump(value, this.#consoleConfig)}`;
|
|
172
230
|
}
|
|
173
231
|
/**
|
|
174
|
-
* Dump values and die.
|
|
175
|
-
*
|
|
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)
|
|
176
246
|
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
247
|
+
* // This will never execute
|
|
248
|
+
* console.log('This line will not run')
|
|
249
|
+
* ```
|
|
180
250
|
*/
|
|
181
251
|
dd(value, traceSourceIndex = 1) {
|
|
182
252
|
const error = new E_DUMP_DIE_EXCEPTION(value, this);
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
import { inspect } from 'node:util';
|
|
2
|
-
import type { Kernel } from '@adonisjs/core/ace';
|
|
3
2
|
import { Exception } from '@poppinss/utils/exception';
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
3
|
+
import type { Dumper } from './dumper.ts';
|
|
4
|
+
import type { Kernel } from '../ace/kernel.ts';
|
|
5
|
+
import type { HttpContext } from '../http/main.ts';
|
|
6
6
|
/**
|
|
7
|
-
* DumpDie exception
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* DumpDie exception raised by the "dd" (dump and die) function.
|
|
8
|
+
* This special exception terminates execution while dumping the provided
|
|
9
|
+
* value as HTML (during HTTP requests) or ANSI (in console/CLI).
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* // This will dump the user object and terminate
|
|
14
|
+
* dumper.dd(user)
|
|
15
|
+
*
|
|
16
|
+
* // In HTTP context: sends HTML dump to browser
|
|
17
|
+
* // In CLI context: prints ANSI dump to console
|
|
18
|
+
* ```
|
|
10
19
|
*/
|
|
11
20
|
declare class DumpDieException extends Exception {
|
|
12
21
|
#private;
|
|
@@ -17,8 +26,10 @@ declare class DumpDieException extends Exception {
|
|
|
17
26
|
value: unknown;
|
|
18
27
|
constructor(value: unknown, dumper: Dumper);
|
|
19
28
|
/**
|
|
20
|
-
* Set the index for the
|
|
21
|
-
*
|
|
29
|
+
* Set the stack trace index for determining the source location.
|
|
30
|
+
* This is useful when building nested helpers on top of dump/die functionality.
|
|
31
|
+
*
|
|
32
|
+
* @param index - Stack trace index (0 = current function, 1 = caller, etc.)
|
|
22
33
|
*/
|
|
23
34
|
setTraceSourceIndex(index: number): this;
|
|
24
35
|
/**
|
|
@@ -27,11 +38,21 @@ declare class DumpDieException extends Exception {
|
|
|
27
38
|
*/
|
|
28
39
|
report(): void;
|
|
29
40
|
/**
|
|
30
|
-
*
|
|
41
|
+
* HTTP exception handler that renders the dump as HTML output.
|
|
42
|
+
* This method is called automatically by AdonisJS when a DumpDieException
|
|
43
|
+
* is thrown during an HTTP request.
|
|
44
|
+
*
|
|
45
|
+
* @param error - The DumpDieException instance
|
|
46
|
+
* @param ctx - HTTP context for the current request
|
|
31
47
|
*/
|
|
32
48
|
handle(error: DumpDieException, ctx: HttpContext): Promise<void>;
|
|
33
49
|
/**
|
|
34
|
-
*
|
|
50
|
+
* Ace command exception handler that renders the dump as ANSI output.
|
|
51
|
+
* This method is called automatically by the Ace kernel when a DumpDieException
|
|
52
|
+
* is thrown during command execution.
|
|
53
|
+
*
|
|
54
|
+
* @param error - The DumpDieException instance
|
|
55
|
+
* @param kernel - Ace kernel instance
|
|
35
56
|
*/
|
|
36
57
|
render(error: DumpDieException, kernel: Kernel): Promise<void>;
|
|
37
58
|
/**
|
|
@@ -10,9 +10,18 @@ import { inspect } from 'node:util';
|
|
|
10
10
|
import { parse } from 'error-stack-parser-es';
|
|
11
11
|
import { Exception } from '@poppinss/utils/exception';
|
|
12
12
|
/**
|
|
13
|
-
* DumpDie exception
|
|
14
|
-
*
|
|
15
|
-
*
|
|
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
|
+
* ```
|
|
16
25
|
*/
|
|
17
26
|
class DumpDieException extends Exception {
|
|
18
27
|
static status = 500;
|
|
@@ -45,8 +54,10 @@ class DumpDieException extends Exception {
|
|
|
45
54
|
};
|
|
46
55
|
}
|
|
47
56
|
/**
|
|
48
|
-
* Set the index for the
|
|
49
|
-
*
|
|
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.)
|
|
50
61
|
*/
|
|
51
62
|
setTraceSourceIndex(index) {
|
|
52
63
|
this.#traceSourceIndex = index;
|
|
@@ -58,7 +69,12 @@ class DumpDieException extends Exception {
|
|
|
58
69
|
*/
|
|
59
70
|
report() { }
|
|
60
71
|
/**
|
|
61
|
-
*
|
|
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
|
|
62
78
|
*/
|
|
63
79
|
async handle(error, ctx) {
|
|
64
80
|
const source = this.#getErrorSource();
|
|
@@ -81,7 +97,12 @@ class DumpDieException extends Exception {
|
|
|
81
97
|
'</html>');
|
|
82
98
|
}
|
|
83
99
|
/**
|
|
84
|
-
*
|
|
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
|
|
85
106
|
*/
|
|
86
107
|
async render(error, kernel) {
|
|
87
108
|
const source = this.#getErrorSource();
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * as errors from './errors.
|
|
2
|
-
export { Dumper } from './dumper.
|
|
3
|
-
export { defineConfig } from './define_config.
|
|
1
|
+
export * as errors from './errors.ts';
|
|
2
|
+
export { Dumper } from './dumper.ts';
|
|
3
|
+
export { defineConfig } from './define_config.ts';
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
export * as errors from
|
|
10
|
-
export { Dumper } from
|
|
11
|
-
export { defineConfig } from
|
|
9
|
+
export * as errors from "./errors.js";
|
|
10
|
+
export { Dumper } from "./dumper.js";
|
|
11
|
+
export { defineConfig } from "./define_config.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { Argon } from './drivers/argon.
|
|
2
|
-
import type { Scrypt } from './drivers/scrypt.
|
|
3
|
-
import type { Bcrypt } from './drivers/bcrypt.
|
|
4
|
-
import type { ConfigProvider } from '../../src/types.
|
|
5
|
-
import type { ArgonConfig, BcryptConfig, ScryptConfig, ManagerDriverFactory } from '../../types/hash.
|
|
1
|
+
import type { Argon } from './drivers/argon.ts';
|
|
2
|
+
import type { Scrypt } from './drivers/scrypt.ts';
|
|
3
|
+
import type { Bcrypt } from './drivers/bcrypt.ts';
|
|
4
|
+
import type { ConfigProvider } from '../../src/types.ts';
|
|
5
|
+
import type { ArgonConfig, BcryptConfig, ScryptConfig, ManagerDriverFactory } from '../../types/hash.ts';
|
|
6
6
|
/**
|
|
7
7
|
* Resolved config from the config provider will be
|
|
8
8
|
* the config accepted by the hash manager
|
|
@@ -14,18 +14,63 @@ type ResolvedConfig<KnownHashers extends Record<string, ManagerDriverFactory | C
|
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
17
|
-
* Define config for the hash service.
|
|
17
|
+
* Define config for the hash service. This function creates a configuration
|
|
18
|
+
* provider that lazily imports and resolves hash drivers when needed.
|
|
19
|
+
*
|
|
20
|
+
* @param config - Configuration object containing default hasher and list of hashers
|
|
21
|
+
* @param config.default - Optional default hasher name (must exist in the list)
|
|
22
|
+
* @param config.list - Record of hasher configurations or config providers
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const hashConfig = defineConfig({
|
|
27
|
+
* default: 'scrypt',
|
|
28
|
+
* list: {
|
|
29
|
+
* scrypt: drivers.scrypt({
|
|
30
|
+
* cost: 16384,
|
|
31
|
+
* blockSize: 8,
|
|
32
|
+
* parallelization: 1,
|
|
33
|
+
* saltSize: 16,
|
|
34
|
+
* keyLength: 64,
|
|
35
|
+
* }),
|
|
36
|
+
* bcrypt: drivers.bcrypt({
|
|
37
|
+
* rounds: 10,
|
|
38
|
+
* })
|
|
39
|
+
* }
|
|
40
|
+
* })
|
|
41
|
+
* ```
|
|
18
42
|
*/
|
|
19
43
|
export declare function defineConfig<KnownHashers extends Record<string, ManagerDriverFactory | ConfigProvider<ManagerDriverFactory>>>(config: {
|
|
20
44
|
default?: keyof KnownHashers;
|
|
21
45
|
list: KnownHashers;
|
|
22
46
|
}): ConfigProvider<ResolvedConfig<KnownHashers>>;
|
|
23
47
|
/**
|
|
24
|
-
* Helpers to configure drivers inside the config file.
|
|
25
|
-
*
|
|
48
|
+
* Helpers to configure drivers inside the config file. These functions create
|
|
49
|
+
* configuration providers that lazily import and instantiate hash drivers.
|
|
26
50
|
*
|
|
27
51
|
* - Import happens when you first use the hash module
|
|
28
52
|
* - Construction of drivers happens when you first use a driver
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* const hashConfig = defineConfig({
|
|
57
|
+
* default: 'bcrypt',
|
|
58
|
+
* list: {
|
|
59
|
+
* bcrypt: drivers.bcrypt({ rounds: 12 }),
|
|
60
|
+
* argon2: drivers.argon2({
|
|
61
|
+
* variant: 'id',
|
|
62
|
+
* memory: 65536,
|
|
63
|
+
* time: 3,
|
|
64
|
+
* parallelism: 4
|
|
65
|
+
* }),
|
|
66
|
+
* scrypt: drivers.scrypt({
|
|
67
|
+
* cost: 16384,
|
|
68
|
+
* blockSize: 8,
|
|
69
|
+
* parallelization: 1
|
|
70
|
+
* })
|
|
71
|
+
* }
|
|
72
|
+
* })
|
|
73
|
+
* ```
|
|
29
74
|
*/
|
|
30
75
|
export declare const drivers: {
|
|
31
76
|
argon2: (config: ArgonConfig) => ConfigProvider<() => Argon>;
|
|
@@ -6,11 +6,35 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
import { InvalidArgumentsException } from '@poppinss/utils';
|
|
10
|
-
import debug from
|
|
11
|
-
import { configProvider } from
|
|
9
|
+
import { InvalidArgumentsException } from '@poppinss/utils/exception';
|
|
10
|
+
import debug from "../../src/debug.js";
|
|
11
|
+
import { configProvider } from "../../src/config_provider.js";
|
|
12
12
|
/**
|
|
13
|
-
* Define config for the hash service.
|
|
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
|
+
* ```
|
|
14
38
|
*/
|
|
15
39
|
export function defineConfig(config) {
|
|
16
40
|
/**
|
|
@@ -49,11 +73,32 @@ export function defineConfig(config) {
|
|
|
49
73
|
});
|
|
50
74
|
}
|
|
51
75
|
/**
|
|
52
|
-
* Helpers to configure drivers inside the config file.
|
|
53
|
-
*
|
|
76
|
+
* Helpers to configure drivers inside the config file. These functions create
|
|
77
|
+
* configuration providers that lazily import and instantiate hash drivers.
|
|
54
78
|
*
|
|
55
79
|
* - Import happens when you first use the hash module
|
|
56
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
|
+
* ```
|
|
57
102
|
*/
|
|
58
103
|
export const drivers = {
|
|
59
104
|
argon2: (config) => {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from '@adonisjs/hash';
|
|
2
|
-
export { defineConfig, drivers } from './define_config.
|
|
2
|
+
export { defineConfig, drivers } from './define_config.ts';
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import type { VineValidator } from '@vinejs/vine';
|
|
2
2
|
import type { Infer, SchemaTypes, ErrorReporterContract, MessagesProviderContact } from '@vinejs/vine/types';
|
|
3
|
-
import type { HttpContext } from './main.
|
|
4
|
-
import type { FeatureFlags } from '../app.
|
|
5
|
-
import type { ExperimentalFlagsList } from '../../types/app.
|
|
6
|
-
import type { RequestValidationOptions } from '../../types/http.
|
|
3
|
+
import type { HttpContext } from './main.ts';
|
|
4
|
+
import type { FeatureFlags } from '../app.ts';
|
|
5
|
+
import type { ExperimentalFlagsList } from '../../types/app.ts';
|
|
6
|
+
import type { RequestValidationOptions } from '../../types/http.ts';
|
|
7
7
|
/**
|
|
8
|
-
* Request validator
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* Request validator for validating HTTP request data using VineJS validators.
|
|
9
|
+
* This class provides a convenient way to validate request body, files, cookies,
|
|
10
|
+
* headers, and URL parameters in AdonisJS applications.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* // Inside a controller method
|
|
15
|
+
* const data = await request.validateUsing(createUserValidator, {
|
|
16
|
+
* messagesProvider: customMessages
|
|
17
|
+
* })
|
|
18
|
+
* ```
|
|
11
19
|
*/
|
|
12
20
|
export declare class RequestValidator {
|
|
13
21
|
#private;
|
|
@@ -29,8 +37,27 @@ export declare class RequestValidator {
|
|
|
29
37
|
*/
|
|
30
38
|
static messagesProvider?: (_: HttpContext) => MessagesProviderContact;
|
|
31
39
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
40
|
+
* Validate the current HTTP request data using a VineJS validator.
|
|
41
|
+
* This method automatically includes request body, files, URL parameters,
|
|
42
|
+
* headers, and cookies in the validation data.
|
|
43
|
+
*
|
|
44
|
+
* @param validator - VineJS validator instance
|
|
45
|
+
* @param options - Optional validation options including custom error reporters and messages
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* const createUserValidator = vine.compile(
|
|
50
|
+
* vine.object({
|
|
51
|
+
* email: vine.string().email(),
|
|
52
|
+
* name: vine.string().minLength(3)
|
|
53
|
+
* })
|
|
54
|
+
* )
|
|
55
|
+
*
|
|
56
|
+
* const data = await request.validateUsing(createUserValidator, {
|
|
57
|
+
* errorReporter: () => vine.errors.SimpleErrorReporter,
|
|
58
|
+
* messagesProvider: customMessages
|
|
59
|
+
* })
|
|
60
|
+
* ```
|
|
34
61
|
*/
|
|
35
62
|
validateUsing<Schema extends SchemaTypes, MetaData extends undefined | Record<string, any>>(validator: VineValidator<Schema, MetaData>, ...[options]: [undefined] extends MetaData ? [options?: RequestValidationOptions<MetaData> | undefined] : [options: RequestValidationOptions<MetaData>]): Promise<Infer<Schema>>;
|
|
36
63
|
}
|