@adonisjs/core 7.0.0 → 7.1.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/ace-DBm6EcQ-.js +37 -0
- package/build/app-BCcG_oDd.js +7 -0
- package/build/app-CAuSGb2P.js +15 -0
- package/build/bodyparser_middleware-H5FArWkI.js +9 -0
- package/build/{chunk-iKc69rpz.js → chunk-Do49iUES.js} +3 -0
- package/build/commands/add.d.ts +1 -0
- package/build/commands/add.js +64 -10
- package/build/commands/build.js +41 -3
- package/build/commands/commands.json +1 -1
- package/build/commands/configure.js +70 -4
- package/build/commands/eject.js +30 -4
- package/build/commands/env/add.js +62 -4
- package/build/commands/generate_key.js +23 -3
- package/build/commands/inspect_rcfile.js +26 -2
- package/build/commands/list/routes.d.ts +5 -0
- package/build/commands/list/routes.js +242 -3
- package/build/commands/make/command.js +33 -4
- package/build/commands/make/controller.js +46 -4
- package/build/commands/make/event.js +36 -4
- package/build/commands/make/exception.js +36 -4
- package/build/commands/make/listener.js +44 -4
- package/build/commands/make/middleware.js +53 -5
- package/build/commands/make/preload.js +55 -5
- package/build/commands/make/provider.js +54 -5
- package/build/commands/make/service.js +29 -4
- package/build/commands/make/test.js +63 -4
- package/build/commands/make/transformer.js +37 -4
- package/build/commands/make/validator.js +44 -4
- package/build/commands/make/view.js +33 -4
- package/build/commands/repl.js +31 -2
- package/build/commands/serve.js +54 -4
- package/build/commands/test.js +69 -4
- package/build/config-Coti2q6R.js +7 -0
- package/build/config_provider-Do9af1ze.js +35 -0
- package/build/container-CGfEwWof.js +7 -0
- package/build/{core-IpCOCkUL.js → core-XjMm_ipu.js} +51 -2
- package/build/create_kernel-BV3swyCg.js +4 -0
- package/build/{create_kernel-B7ILNhuP.js → create_kernel-D38-0Zbt.js} +41 -1
- package/build/debug-DWofTfIX.js +20 -0
- package/build/{decorate-DmrZA614.js → decorate-B9Uz0anB.js} +2 -0
- package/build/{define_config-0oHaj43l.js → define_config--5euEdi8.js} +54 -3
- package/build/dumper-3R77st8F.js +353 -0
- package/build/edge-BG5ZYp6Z.js +57 -0
- package/build/{errors-CrCO-k44.js → errors-BScZTzBu.js} +9 -1
- package/build/events-DlKX1ZdL.js +7 -0
- package/build/exceptions-B2MzIlHY.js +2 -0
- package/build/factories/app.js +1 -0
- package/build/factories/bodyparser.js +1 -0
- package/build/factories/core/ace.js +16 -22
- package/build/factories/core/ignitor.js +13 -73
- package/build/factories/core/main.js +25 -17
- package/build/factories/core/test_utils.js +22 -19
- package/build/factories/encryption.js +1 -0
- package/build/factories/events.js +1 -0
- package/build/factories/hash.js +1 -0
- package/build/factories/http.js +1 -0
- package/build/factories/logger.js +1 -0
- package/build/factories/stubs.js +75 -7
- package/build/ignitor-Kym3gR-I.js +169 -0
- package/build/index.js +11 -8
- package/build/logger-DIdZPHCe.js +43 -0
- package/build/main-B50zECAi.js +121 -0
- package/build/main-CRnMnrH7.js +184 -0
- package/build/{main-kn40V-hF.js → main-CfTiGsiS.js} +2 -0
- package/build/main-Ck0GqLx4.js +117 -0
- package/build/main-CoZI4Ezs.js +2 -0
- package/build/main-D1MSq4Uu.js +435 -0
- package/build/{main--nXd7T-C.js → main-bRYXIHgD.js} +75 -3
- package/build/main-zxNP7iRl.js +7 -0
- package/build/modules/ace/codemods.d.ts +1 -1
- package/build/modules/ace/codemods.js +303 -8
- package/build/modules/ace/commands.d.ts +5 -0
- package/build/modules/ace/main.js +2 -1
- package/build/modules/app.js +3 -5
- package/build/modules/bodyparser/bodyparser_middleware.js +2 -2
- package/build/modules/bodyparser/main.js +3 -5
- package/build/modules/config.js +3 -5
- package/build/modules/container.js +3 -5
- package/build/modules/dumper/main.js +29 -2
- package/build/modules/dumper/plugins/edge.js +2 -46
- package/build/modules/encryption/drivers/aes_256_cbc.js +1 -0
- package/build/modules/encryption/drivers/aes_256_gcm.js +1 -0
- package/build/modules/encryption/drivers/aes_siv.js +1 -0
- package/build/modules/encryption/drivers/chacha20_poly1305.js +1 -0
- package/build/modules/encryption/drivers/legacy.js +46 -1
- package/build/modules/encryption/main.js +7 -5
- package/build/modules/env/editor.js +1 -0
- package/build/modules/env/main.js +1 -0
- package/build/modules/events.js +3 -5
- package/build/modules/hash/drivers/argon.js +1 -0
- package/build/modules/hash/drivers/bcrypt.js +1 -0
- package/build/modules/hash/drivers/scrypt.js +1 -0
- package/build/modules/hash/main.js +4 -4
- package/build/modules/hash/phc_formatter.js +1 -0
- package/build/modules/health.js +1 -0
- package/build/modules/http/helpers.js +1 -0
- package/build/modules/http/main.js +2 -2
- package/build/modules/http/url_builder_client.js +1 -0
- package/build/modules/logger.js +3 -13
- package/build/modules/repl.js +3 -5
- package/build/modules/transformers/main.js +1 -0
- package/build/providers/app_provider.js +214 -15
- package/build/providers/edge_provider.js +90 -3
- package/build/providers/hash_provider.js +59 -4
- package/build/providers/repl_provider.js +64 -2
- package/build/providers/vinejs_provider.js +44 -3
- package/build/repl-C02Re0Yd.js +7 -0
- package/build/services/ace.js +11 -1
- package/build/services/app.js +2 -4
- package/build/services/config.js +7 -1
- package/build/services/dumper.js +13 -1
- package/build/services/emitter.js +8 -1
- package/build/services/encryption.js +8 -1
- package/build/services/hash.js +8 -1
- package/build/services/logger.js +8 -1
- package/build/services/repl.js +8 -1
- package/build/services/router.js +8 -1
- package/build/services/server.js +8 -1
- package/build/services/test_utils.js +11 -1
- package/build/services/url_builder.js +8 -1
- package/build/src/cli_formatters/routes_list.d.ts +7 -0
- package/build/src/exceptions.js +2 -1
- package/build/src/helpers/assert.js +1 -0
- package/build/src/helpers/http.js +1 -0
- package/build/src/helpers/is.js +24 -0
- package/build/src/helpers/main.js +2 -1
- package/build/src/helpers/string.js +2 -27
- package/build/src/helpers/types.js +18 -0
- package/build/src/helpers/verification_token.js +2 -45
- package/build/src/test_utils/main.js +9 -7
- package/build/src/types.js +1 -0
- package/build/src/vine.js +2 -32
- package/build/string-8_8He-HH.js +46 -0
- package/build/test_utils-DbJS_uEu.js +32 -0
- package/build/toolkit/main.js +13 -1
- package/build/types/ace.js +1 -0
- package/build/types/app.js +1 -0
- package/build/types/bodyparser.js +1 -0
- package/build/types/common.js +1 -0
- package/build/types/container.js +1 -0
- package/build/types/encryption.js +1 -0
- package/build/types/events.js +1 -0
- package/build/types/hash.js +1 -0
- package/build/types/health.js +1 -0
- package/build/types/helpers.js +1 -0
- package/build/types/http.js +1 -0
- package/build/types/logger.js +1 -0
- package/build/types/repl.js +1 -0
- package/build/types/transformers.js +1 -0
- package/build/utils-CKwka7OL.js +105 -0
- package/build/verification_token-WCrZtUgZ.js +108 -0
- package/build/vine-DkIupA3Z.js +97 -0
- package/package.json +12 -12
- package/build/config_provider-FIAUgvae.js +0 -13
- package/build/create_kernel-BD0Iqi8e.js +0 -3
- package/build/debug-CGQmxzGt.js +0 -3
- package/build/dumper-BBgqFX5a.js +0 -147
- package/build/main-Cxz0TyIw.js +0 -173
- package/build/main-DN2qEEg5.js +0 -41
- package/build/main-DkNgvceD.js +0 -52
- package/build/main-MBAMnmJb.js +0 -81
- package/build/utils-rRkbAPnP.js +0 -42
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { BaseCommand, FsLoader, HelpCommand as HelpCommand$1, IndexGenerator as IndexGenerator$1, Kernel, ListCommand, ListLoader as ListLoader$1, Parser, args as args$1, cliHelpers, errors as errors$1, flags, tracingChannels } from "@adonisjs/ace";
|
|
2
|
+
//#region modules/ace/commands.ts
|
|
3
|
+
/**
|
|
4
|
+
* The base command class for creating custom Ace commands in AdonisJS applications.
|
|
5
|
+
* This class extends the base Ace command with AdonisJS-specific functionality like
|
|
6
|
+
* dependency injection and application lifecycle management.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* export default class MakeUser extends BaseCommand {
|
|
11
|
+
* static commandName = 'make:user'
|
|
12
|
+
* static description = 'Create a new user'
|
|
13
|
+
*
|
|
14
|
+
* async run() {
|
|
15
|
+
* this.logger.info('Creating user...')
|
|
16
|
+
* // Command implementation
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
var BaseCommand$1 = class extends BaseCommand {
|
|
22
|
+
static options = {};
|
|
23
|
+
get staysAlive() {
|
|
24
|
+
return this.constructor.options.staysAlive;
|
|
25
|
+
}
|
|
26
|
+
get startApp() {
|
|
27
|
+
return this.constructor.options.startApp;
|
|
28
|
+
}
|
|
29
|
+
constructor(app, kernel, parsed, ui, prompt) {
|
|
30
|
+
super(kernel, parsed, ui, prompt);
|
|
31
|
+
this.app = app;
|
|
32
|
+
this.kernel = kernel;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Creates the codemods module to modify source files programmatically.
|
|
36
|
+
* This method provides access to AST-based code transformations.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* const codemods = await this.createCodemods()
|
|
41
|
+
* await codemods.makeUsingStub(stubsRoot, 'controller.stub', {
|
|
42
|
+
* filename: 'UserController',
|
|
43
|
+
* entity: { name: 'User' }
|
|
44
|
+
* })
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
async createCodemods() {
|
|
48
|
+
const { Codemods } = await import("./modules/ace/codemods.js");
|
|
49
|
+
const codemods = new Codemods(this.app, this.logger);
|
|
50
|
+
codemods.on("error", () => {
|
|
51
|
+
this.exitCode = 1;
|
|
52
|
+
});
|
|
53
|
+
return codemods;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Executes the lifecycle hooks and the run method from the command
|
|
57
|
+
*/
|
|
58
|
+
async exec() {
|
|
59
|
+
this.hydrate();
|
|
60
|
+
try {
|
|
61
|
+
/**
|
|
62
|
+
* Executing the template methods
|
|
63
|
+
*/
|
|
64
|
+
this.prepare && await this.app.container.call(this, "prepare");
|
|
65
|
+
this.interact && await this.app.container.call(this, "interact");
|
|
66
|
+
const result = await this.app.container.call(this, "run");
|
|
67
|
+
/**
|
|
68
|
+
* Set exit code
|
|
69
|
+
*/
|
|
70
|
+
this.result = this.result === void 0 ? result : this.result;
|
|
71
|
+
this.exitCode = this.exitCode ?? 0;
|
|
72
|
+
} catch (error) {
|
|
73
|
+
this.error = error;
|
|
74
|
+
this.exitCode = this.exitCode ?? 1;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Run the completed method (if exists) and check if has handled
|
|
78
|
+
* the error
|
|
79
|
+
*/
|
|
80
|
+
let errorHandled = this.completed ? await this.app.container.call(this, "completed") : false;
|
|
81
|
+
if (this.error && !errorHandled) await this.kernel.errorHandler.render(this.error, this.kernel);
|
|
82
|
+
return this.result;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Terminate the application gracefully. This method should be preferred over
|
|
86
|
+
* calling `app.terminate()` directly as it only triggers termination when
|
|
87
|
+
* the current command is the main command responsible for the process.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* export default class SomeCommand extends BaseCommand {
|
|
92
|
+
* async run() {
|
|
93
|
+
* // Do some work
|
|
94
|
+
* await this.terminate()
|
|
95
|
+
* }
|
|
96
|
+
* }
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
async terminate() {
|
|
100
|
+
if (this.kernel.getMainCommand() === this) await this.app.terminate();
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* The List command is used to display a list of available commands.
|
|
105
|
+
* This command extends the base Ace ListCommand with AdonisJS-specific functionality.
|
|
106
|
+
*/
|
|
107
|
+
var ListCommand$1 = class extends ListCommand {
|
|
108
|
+
static options = {};
|
|
109
|
+
get staysAlive() {
|
|
110
|
+
return this.constructor.options.staysAlive;
|
|
111
|
+
}
|
|
112
|
+
get startApp() {
|
|
113
|
+
return this.constructor.options.startApp;
|
|
114
|
+
}
|
|
115
|
+
constructor(app, kernel, parsed, ui, prompt) {
|
|
116
|
+
super(kernel, parsed, ui, prompt);
|
|
117
|
+
this.app = app;
|
|
118
|
+
this.kernel = kernel;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Auto-select JSON output when running inside an AI agent
|
|
122
|
+
* and no explicit format flag is provided.
|
|
123
|
+
*/
|
|
124
|
+
async run() {
|
|
125
|
+
if (!this.json && this.app.runningInAIAgent) this.json = true;
|
|
126
|
+
return super.run();
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Creates the codemods module to modify source files programmatically.
|
|
130
|
+
* This method provides access to AST-based code transformations.
|
|
131
|
+
*/
|
|
132
|
+
async createCodemods() {
|
|
133
|
+
const { Codemods } = await import("./modules/ace/codemods.js");
|
|
134
|
+
return new Codemods(this.app, this.logger);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Terminate the app. A command should prefer calling this method
|
|
138
|
+
* over the "app.terminate", because this method only triggers
|
|
139
|
+
* app termination when the current command is in the charge
|
|
140
|
+
* of the process.
|
|
141
|
+
*/
|
|
142
|
+
async terminate() {
|
|
143
|
+
if (this.kernel.getMainCommand() === this) await this.app.terminate();
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region modules/ace/kernel.ts
|
|
148
|
+
/**
|
|
149
|
+
* The Ace command kernel for AdonisJS applications. This kernel extends the base
|
|
150
|
+
* Ace kernel with AdonisJS-specific functionality like dependency injection and
|
|
151
|
+
* application lifecycle management.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```ts
|
|
155
|
+
* const app = new Application(new URL('../', import.meta.url))
|
|
156
|
+
* const kernel = new Kernel(app)
|
|
157
|
+
*
|
|
158
|
+
* await kernel.handle(['make:controller', 'UserController'])
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
var Kernel$1 = class extends Kernel {
|
|
162
|
+
/**
|
|
163
|
+
* Create a new Ace kernel instance
|
|
164
|
+
*
|
|
165
|
+
* @param app - The AdonisJS application instance
|
|
166
|
+
*/
|
|
167
|
+
constructor(app) {
|
|
168
|
+
super(ListCommand$1, {
|
|
169
|
+
create: async (command, parsedOutput, $kernel) => {
|
|
170
|
+
return app.container.make(command, [
|
|
171
|
+
app,
|
|
172
|
+
$kernel,
|
|
173
|
+
parsedOutput,
|
|
174
|
+
$kernel.ui,
|
|
175
|
+
$kernel.prompt
|
|
176
|
+
]);
|
|
177
|
+
},
|
|
178
|
+
run: (command) => command.exec()
|
|
179
|
+
});
|
|
180
|
+
this.app = app;
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
//#endregion
|
|
184
|
+
export { Parser as a, errors$1 as c, Kernel$1 as d, BaseCommand$1 as f, ListLoader$1 as i, flags as l, HelpCommand$1 as n, args$1 as o, ListCommand$1 as p, IndexGenerator$1 as r, cliHelpers as s, FsLoader as t, tracingChannels as u };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { n as __reExport, t as __exportAll } from "./chunk-Do49iUES.js";
|
|
2
|
+
import "@adonisjs/bodyparser";
|
|
3
|
+
//#region modules/http/request_validator.ts
|
|
4
|
+
/**
|
|
5
|
+
* Request validator for validating HTTP request data using VineJS validators.
|
|
6
|
+
* This class provides a convenient way to validate request body, files, cookies,
|
|
7
|
+
* headers, and URL parameters in AdonisJS applications.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* // Inside a controller method
|
|
12
|
+
* const data = await request.validateUsing(createUserValidator, {
|
|
13
|
+
* messagesProvider: customMessages
|
|
14
|
+
* })
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
var RequestValidator = class RequestValidator {
|
|
18
|
+
#ctx;
|
|
19
|
+
constructor(ctx) {
|
|
20
|
+
this.#ctx = ctx;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The error reporter method returns the error reporter
|
|
24
|
+
* to use for reporting errors.
|
|
25
|
+
*
|
|
26
|
+
* You can use this function to pick a different error reporter
|
|
27
|
+
* for each HTTP request
|
|
28
|
+
*/
|
|
29
|
+
static errorReporter;
|
|
30
|
+
/**
|
|
31
|
+
* The messages provider method returns the messages provider to use
|
|
32
|
+
* finding custom error messages
|
|
33
|
+
*
|
|
34
|
+
* You can use this function to pick a different messages provider for
|
|
35
|
+
* each HTTP request
|
|
36
|
+
*/
|
|
37
|
+
static messagesProvider;
|
|
38
|
+
#requestData() {
|
|
39
|
+
return {
|
|
40
|
+
...this.#ctx.request.all(),
|
|
41
|
+
params: this.#ctx.request.params(),
|
|
42
|
+
headers: this.#ctx.request.headers(),
|
|
43
|
+
cookies: this.#ctx.request.cookiesList()
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
#processValidatorOptions(options) {
|
|
47
|
+
const validatorOptions = options || {};
|
|
48
|
+
/**
|
|
49
|
+
* Assign request specific error reporter
|
|
50
|
+
*/
|
|
51
|
+
if (RequestValidator.errorReporter && !validatorOptions.errorReporter) {
|
|
52
|
+
const errorReporter = RequestValidator.errorReporter(this.#ctx);
|
|
53
|
+
validatorOptions.errorReporter = () => errorReporter;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Assign request specific messages provider
|
|
57
|
+
*/
|
|
58
|
+
if (RequestValidator.messagesProvider && !validatorOptions.messagesProvider) validatorOptions.messagesProvider = RequestValidator.messagesProvider(this.#ctx);
|
|
59
|
+
return validatorOptions;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Validate the current HTTP request data using a VineJS validator.
|
|
63
|
+
* This method automatically includes request body, files, URL parameters,
|
|
64
|
+
* headers, and cookies in the validation data.
|
|
65
|
+
*
|
|
66
|
+
* @param validator - VineJS validator instance
|
|
67
|
+
* @param options - Optional validation options including custom error reporters and messages
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* const createUserValidator = vine.compile(
|
|
72
|
+
* vine.object({
|
|
73
|
+
* email: vine.string().email(),
|
|
74
|
+
* name: vine.string().minLength(3)
|
|
75
|
+
* })
|
|
76
|
+
* )
|
|
77
|
+
*
|
|
78
|
+
* const data = await request.validateUsing(createUserValidator, {
|
|
79
|
+
* errorReporter: () => vine.errors.SimpleErrorReporter,
|
|
80
|
+
* messagesProvider: customMessages
|
|
81
|
+
* })
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
validateUsing(validator, ...[options]) {
|
|
85
|
+
/**
|
|
86
|
+
* Process the validation options
|
|
87
|
+
*/
|
|
88
|
+
const validatorOptions = this.#processValidatorOptions(options);
|
|
89
|
+
/**
|
|
90
|
+
* Data to validate
|
|
91
|
+
*/
|
|
92
|
+
const data = validatorOptions.data || this.#requestData();
|
|
93
|
+
return validator.validate(data, validatorOptions);
|
|
94
|
+
}
|
|
95
|
+
async tryValidateUsing(validator, ...[options]) {
|
|
96
|
+
/**
|
|
97
|
+
* Process the validation options
|
|
98
|
+
*/
|
|
99
|
+
const validatorOptions = this.#processValidatorOptions(options);
|
|
100
|
+
/**
|
|
101
|
+
* Data to validate
|
|
102
|
+
*/
|
|
103
|
+
const data = validatorOptions.data || this.#requestData();
|
|
104
|
+
return validator.tryValidate(data, validatorOptions);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region modules/http/main.ts
|
|
109
|
+
/**
|
|
110
|
+
* Bodyparser import is needed to merge types of Request
|
|
111
|
+
* class augmented by the bodyparser package
|
|
112
|
+
*/
|
|
113
|
+
var main_exports = /* @__PURE__ */ __exportAll({ RequestValidator: () => RequestValidator });
|
|
114
|
+
import * as import__adonisjs_http_server from "@adonisjs/http-server";
|
|
115
|
+
__reExport(main_exports, import__adonisjs_http_server);
|
|
116
|
+
//#endregion
|
|
117
|
+
export { RequestValidator as n, main_exports as t };
|