@adonisjs/core 6.1.5-9 → 6.2.1
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/README.md +3 -5
- package/build/commands/build.d.ts +3 -5
- package/build/commands/build.js +5 -9
- package/build/commands/commands.json +1 -1
- package/build/commands/configure.d.ts +21 -28
- package/build/commands/configure.js +60 -118
- package/build/commands/eject.js +2 -1
- package/build/commands/generate_key.js +2 -2
- package/build/commands/inspect_rcfile.js +19 -2
- package/build/commands/main.d.ts +4 -0
- package/build/commands/make/command.d.ts +1 -1
- package/build/commands/make/command.js +5 -2
- package/build/commands/make/controller.d.ts +2 -1
- package/build/commands/make/controller.js +33 -10
- package/build/commands/make/event.d.ts +1 -1
- package/build/commands/make/event.js +5 -3
- package/build/commands/make/exception.d.ts +1 -1
- package/build/commands/make/exception.js +6 -4
- package/build/commands/make/listener.d.ts +1 -1
- package/build/commands/make/listener.js +9 -6
- package/build/commands/make/middleware.d.ts +2 -1
- package/build/commands/make/middleware.js +50 -4
- package/build/commands/make/preload.d.ts +4 -3
- package/build/commands/make/preload.js +34 -35
- package/build/commands/make/provider.d.ts +7 -1
- package/build/commands/make/provider.js +57 -7
- package/build/commands/make/service.d.ts +1 -1
- package/build/commands/make/service.js +5 -3
- package/build/commands/make/test.d.ts +1 -1
- package/build/commands/make/test.js +7 -5
- package/build/commands/make/validator.d.ts +19 -0
- package/build/commands/make/validator.js +53 -0
- package/build/commands/make/view.d.ts +14 -0
- package/build/commands/make/view.js +37 -0
- package/build/commands/serve.js +7 -4
- package/build/commands/test.js +2 -2
- package/build/factories/core/ace.d.ts +2 -2
- package/build/factories/core/ignitor.d.ts +2 -2
- package/build/factories/core/ignitor.js +8 -9
- package/build/factories/core/main.d.ts +0 -1
- package/build/factories/core/main.js +0 -1
- package/build/factories/core/test_utils.d.ts +2 -2
- package/build/factories/stubs.d.ts +2 -2
- package/build/factories/stubs.js +3 -2
- package/build/index.d.ts +11 -140
- package/build/index.js +5 -1
- package/build/modules/ace/codemods.d.ts +93 -0
- package/build/modules/ace/codemods.js +259 -0
- package/build/modules/ace/commands.d.ts +6 -81
- package/build/modules/ace/commands.js +12 -33
- package/build/modules/ace/create_kernel.d.ts +1 -1
- package/build/modules/ace/create_kernel.js +19 -3
- package/build/modules/env/editor.d.ts +1 -0
- package/build/modules/env/editor.js +9 -0
- package/build/modules/hash/define_config.d.ts +29 -12
- package/build/modules/hash/define_config.js +52 -11
- package/build/modules/hash/drivers/argon.d.ts +1 -0
- package/build/modules/hash/drivers/argon.js +9 -0
- package/build/modules/hash/drivers/bcrypt.d.ts +1 -0
- package/build/modules/hash/drivers/bcrypt.js +9 -0
- package/build/modules/hash/drivers/scrypt.d.ts +1 -0
- package/build/modules/hash/drivers/scrypt.js +9 -0
- package/build/modules/hash/main.d.ts +1 -2
- package/build/modules/hash/main.js +1 -2
- package/build/modules/hash/phc_formatter.d.ts +1 -0
- package/build/modules/hash/phc_formatter.js +9 -0
- package/build/modules/http/main.d.ts +5 -0
- package/build/modules/http/main.js +5 -0
- package/build/modules/http/request_validator.d.ts +4 -14
- package/build/modules/http/request_validator.js +2 -10
- package/build/providers/app_provider.d.ts +14 -0
- package/build/providers/app_provider.js +47 -3
- package/build/providers/edge_provider.d.ts +31 -0
- package/build/providers/edge_provider.js +70 -0
- package/build/providers/hash_provider.d.ts +0 -4
- package/build/providers/hash_provider.js +11 -11
- package/build/providers/repl_provider.js +74 -7
- package/build/providers/vinejs_provider.d.ts +43 -0
- package/build/{src/vinejs/extensions/validates_files.js → providers/vinejs_provider.js} +26 -5
- package/build/src/config_provider.d.ts +9 -0
- package/build/src/config_provider.js +26 -0
- package/build/src/debug.d.ts +1 -1
- package/build/src/helpers/assert.d.ts +1 -0
- package/build/src/helpers/assert.js +9 -0
- package/build/src/helpers/main.d.ts +2 -2
- package/build/src/helpers/main.js +2 -2
- package/build/src/helpers/types.d.ts +109 -16
- package/build/src/helpers/types.js +3 -3
- package/build/src/ignitor/ace.js +3 -1
- package/build/src/ignitor/http.d.ts +2 -2
- package/build/src/ignitor/http.js +5 -1
- package/build/src/ignitor/main.d.ts +2 -2
- package/build/src/ignitor/main.js +1 -1
- package/build/src/test_utils/http.d.ts +2 -2
- package/build/src/test_utils/main.d.ts +3 -3
- package/build/src/types.d.ts +18 -17
- package/build/stubs/make/command/main.stub +6 -4
- package/build/stubs/make/controller/actions.stub +14 -0
- package/build/stubs/make/controller/api.stub +6 -4
- package/build/stubs/make/controller/main.stub +6 -4
- package/build/stubs/make/controller/resource.stub +6 -4
- package/build/stubs/make/event/main.stub +5 -3
- package/build/stubs/make/exception/main.stub +5 -3
- package/build/stubs/make/listener/for_event.stub +6 -4
- package/build/stubs/make/listener/main.stub +5 -3
- package/build/stubs/make/middleware/main.stub +7 -5
- package/build/stubs/make/{preload_file → preload}/main.stub +5 -3
- package/build/stubs/make/provider/main.stub +6 -4
- package/build/stubs/make/service/main.stub +5 -3
- package/build/stubs/make/test/main.stub +5 -3
- package/build/stubs/make/validator/main.stub +7 -0
- package/build/stubs/make/validator/resource.stub +26 -0
- package/build/stubs/make/view/main.stub +6 -0
- package/build/types/bodyparser.js +1 -1
- package/build/types/helpers.d.ts +1 -0
- package/build/{src/vinejs/extensions/main.js → types/helpers.js} +1 -1
- package/build/types/http.d.ts +7 -0
- package/package.json +69 -60
- package/build/commands/make/_base.d.ts +0 -36
- package/build/commands/make/_base.js +0 -27
- package/build/modules/ace/shell.d.ts +0 -12
- package/build/modules/ace/shell.js +0 -49
- package/build/modules/hash/drivers_collection.d.ts +0 -21
- package/build/modules/hash/drivers_collection.js +0 -45
- package/build/providers/http_provider.d.ts +0 -26
- package/build/providers/http_provider.js +0 -61
- package/build/src/bindings/repl.d.ts +0 -6
- package/build/src/bindings/repl.js +0 -78
- package/build/src/vinejs/extensions/main.d.ts +0 -1
- package/build/src/vinejs/extensions/validates_files.d.ts +0 -22
- /package/build/modules/{env.d.ts → env/main.d.ts} +0 -0
- /package/build/modules/{env.js → env/main.js} +0 -0
- /package/build/stubs/{index.d.ts → main.d.ts} +0 -0
- /package/build/stubs/{index.js → main.js} +0 -0
|
@@ -7,5 +7,4 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
export * from '@adonisjs/hash';
|
|
10
|
-
export { defineConfig } from './define_config.js';
|
|
11
|
-
export { default as driversList } from './drivers_collection.js';
|
|
10
|
+
export { defineConfig, drivers } from './define_config.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@adonisjs/hash/phc_formatter';
|
|
@@ -6,5 +6,10 @@
|
|
|
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
|
+
/**
|
|
10
|
+
* Bodyparser import is needed to merge types of Request
|
|
11
|
+
* class augmented by the bodyparser package
|
|
12
|
+
*/
|
|
13
|
+
import '@adonisjs/bodyparser';
|
|
9
14
|
export * from '@adonisjs/http-server';
|
|
10
15
|
export { RequestValidator } from './request_validator.js';
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { Infer, SchemaTypes,
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
* Request validation options with custom data as well
|
|
6
|
-
*/
|
|
7
|
-
type RequestValidationOptions<MetaData extends undefined | Record<string, any>> = ValidationOptions<MetaData> & {
|
|
8
|
-
data?: any;
|
|
9
|
-
};
|
|
1
|
+
import type { VineValidator } from '@vinejs/vine';
|
|
2
|
+
import type { Infer, SchemaTypes, ErrorReporterContract, MessagesProviderContact } from '@vinejs/vine/types';
|
|
3
|
+
import type { HttpContext } from './main.js';
|
|
4
|
+
import type { RequestValidationOptions } from '../../types/http.js';
|
|
10
5
|
/**
|
|
11
6
|
* Request validator is used validate HTTP request data using
|
|
12
7
|
* VineJS validators. You may validate the request body,
|
|
@@ -37,8 +32,3 @@ export declare class RequestValidator {
|
|
|
37
32
|
*/
|
|
38
33
|
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>>;
|
|
39
34
|
}
|
|
40
|
-
declare module '@adonisjs/http-server' {
|
|
41
|
-
interface Request extends RequestValidator {
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
export {};
|
|
@@ -6,7 +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
|
-
import { Request } from '@adonisjs/http-server';
|
|
10
9
|
/**
|
|
11
10
|
* Request validator is used validate HTTP request data using
|
|
12
11
|
* VineJS validators. You may validate the request body,
|
|
@@ -42,14 +41,14 @@ export class RequestValidator {
|
|
|
42
41
|
/**
|
|
43
42
|
* Assign request specific error reporter
|
|
44
43
|
*/
|
|
45
|
-
if (RequestValidator.errorReporter) {
|
|
44
|
+
if (RequestValidator.errorReporter && !validatorOptions.errorReporter) {
|
|
46
45
|
const errorReporter = RequestValidator.errorReporter(this.#ctx);
|
|
47
46
|
validatorOptions.errorReporter = () => errorReporter;
|
|
48
47
|
}
|
|
49
48
|
/**
|
|
50
49
|
* Assign request specific messages provider
|
|
51
50
|
*/
|
|
52
|
-
if (RequestValidator.messagesProvider) {
|
|
51
|
+
if (RequestValidator.messagesProvider && !validatorOptions.messagesProvider) {
|
|
53
52
|
validatorOptions.messagesProvider = RequestValidator.messagesProvider(this.#ctx);
|
|
54
53
|
}
|
|
55
54
|
/**
|
|
@@ -65,10 +64,3 @@ export class RequestValidator {
|
|
|
65
64
|
return validator.validate(data, validatorOptions);
|
|
66
65
|
}
|
|
67
66
|
}
|
|
68
|
-
/**
|
|
69
|
-
* The validate method can be used to validate the request
|
|
70
|
-
* data for the current request using VineJS validators
|
|
71
|
-
*/
|
|
72
|
-
Request.macro('validateUsing', function (...args) {
|
|
73
|
-
return new RequestValidator(this.ctx).validateUsing(...args);
|
|
74
|
-
});
|
|
@@ -38,8 +38,22 @@ export default class AppServiceProvider {
|
|
|
38
38
|
* Register the encryption service to the container
|
|
39
39
|
*/
|
|
40
40
|
protected registerEncryption(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Registers the HTTP server with the container as a singleton
|
|
43
|
+
*/
|
|
44
|
+
protected registerServer(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Registers router with the container as a singleton
|
|
47
|
+
*/
|
|
48
|
+
protected registerRouter(): void;
|
|
49
|
+
/**
|
|
50
|
+
* Self construct bodyparser middleware class, since it needs
|
|
51
|
+
* config that cannot be resolved by the container
|
|
52
|
+
*/
|
|
53
|
+
protected registerBodyParserMiddleware(): void;
|
|
41
54
|
/**
|
|
42
55
|
* Registers bindings
|
|
43
56
|
*/
|
|
44
57
|
register(): void;
|
|
58
|
+
boot(): Promise<void>;
|
|
45
59
|
}
|
|
@@ -8,7 +8,11 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { Config } from '../modules/config.js';
|
|
10
10
|
import { Logger } from '../modules/logger.js';
|
|
11
|
+
import { Application } from '../modules/app.js';
|
|
12
|
+
import { BaseEvent, Emitter } from '../modules/events.js';
|
|
11
13
|
import { Encryption } from '../modules/encryption.js';
|
|
14
|
+
import { Router, Server } from '../modules/http/main.js';
|
|
15
|
+
import BodyParserMiddleware from '../modules/bodyparser/bodyparser_middleware.js';
|
|
12
16
|
/**
|
|
13
17
|
* The Application Service provider registers all the baseline
|
|
14
18
|
* features required to run the framework.
|
|
@@ -40,7 +44,8 @@ export default class AppServiceProvider {
|
|
|
40
44
|
* Registers the application to the container
|
|
41
45
|
*/
|
|
42
46
|
registerApp() {
|
|
43
|
-
this.app.container.singleton(
|
|
47
|
+
this.app.container.singleton(Application, () => this.app);
|
|
48
|
+
this.app.container.alias('app', Application);
|
|
44
49
|
}
|
|
45
50
|
/**
|
|
46
51
|
* Registers the logger class to resolve the default logger
|
|
@@ -72,10 +77,10 @@ export default class AppServiceProvider {
|
|
|
72
77
|
* Registers emitter service to the container
|
|
73
78
|
*/
|
|
74
79
|
registerEmitter() {
|
|
75
|
-
this.app.container.singleton(
|
|
76
|
-
const { Emitter } = await import('../modules/events.js');
|
|
80
|
+
this.app.container.singleton(Emitter, async () => {
|
|
77
81
|
return new Emitter(this.app);
|
|
78
82
|
});
|
|
83
|
+
this.app.container.alias('emitter', Emitter);
|
|
79
84
|
}
|
|
80
85
|
/**
|
|
81
86
|
* Register the encryption service to the container
|
|
@@ -87,6 +92,39 @@ export default class AppServiceProvider {
|
|
|
87
92
|
});
|
|
88
93
|
this.app.container.alias('encryption', Encryption);
|
|
89
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Registers the HTTP server with the container as a singleton
|
|
97
|
+
*/
|
|
98
|
+
registerServer() {
|
|
99
|
+
this.app.container.singleton(Server, async (resolver) => {
|
|
100
|
+
const encryption = await resolver.make('encryption');
|
|
101
|
+
const emitter = await resolver.make('emitter');
|
|
102
|
+
const logger = await resolver.make('logger');
|
|
103
|
+
const config = this.app.config.get('app.http');
|
|
104
|
+
return new Server(this.app, encryption, emitter, logger, config);
|
|
105
|
+
});
|
|
106
|
+
this.app.container.alias('server', Server);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Registers router with the container as a singleton
|
|
110
|
+
*/
|
|
111
|
+
registerRouter() {
|
|
112
|
+
this.app.container.singleton(Router, async (resolver) => {
|
|
113
|
+
const server = await resolver.make('server');
|
|
114
|
+
return server.getRouter();
|
|
115
|
+
});
|
|
116
|
+
this.app.container.alias('router', Router);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Self construct bodyparser middleware class, since it needs
|
|
120
|
+
* config that cannot be resolved by the container
|
|
121
|
+
*/
|
|
122
|
+
registerBodyParserMiddleware() {
|
|
123
|
+
this.app.container.bind(BodyParserMiddleware, () => {
|
|
124
|
+
const config = this.app.config.get('bodyparser');
|
|
125
|
+
return new BodyParserMiddleware(config);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
90
128
|
/**
|
|
91
129
|
* Registers bindings
|
|
92
130
|
*/
|
|
@@ -99,5 +137,11 @@ export default class AppServiceProvider {
|
|
|
99
137
|
this.registerEmitter();
|
|
100
138
|
this.registerEncryption();
|
|
101
139
|
this.registerTestUtils();
|
|
140
|
+
this.registerServer();
|
|
141
|
+
this.registerRouter();
|
|
142
|
+
this.registerBodyParserMiddleware();
|
|
143
|
+
}
|
|
144
|
+
async boot() {
|
|
145
|
+
BaseEvent.useEmitter(await this.app.container.make('emitter'));
|
|
102
146
|
}
|
|
103
147
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Edge } from 'edge.js';
|
|
2
|
+
import type { ApplicationService } from '../src/types.js';
|
|
3
|
+
import { type Route } from '../modules/http/main.js';
|
|
4
|
+
declare module '@adonisjs/core/http' {
|
|
5
|
+
interface HttpContext {
|
|
6
|
+
/**
|
|
7
|
+
* Reference to the edge renderer to render templates
|
|
8
|
+
* during an HTTP request
|
|
9
|
+
*/
|
|
10
|
+
view: ReturnType<Edge['createRenderer']>;
|
|
11
|
+
}
|
|
12
|
+
interface BriskRoute {
|
|
13
|
+
/**
|
|
14
|
+
* Render an edge template without defining an
|
|
15
|
+
* explicit route handler
|
|
16
|
+
*/
|
|
17
|
+
render(template: string, data?: Record<string, any>): Route;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The Edge service provider configures Edge to work within
|
|
22
|
+
* an AdonisJS application environment
|
|
23
|
+
*/
|
|
24
|
+
export default class EdgeServiceProvider {
|
|
25
|
+
protected app: ApplicationService;
|
|
26
|
+
constructor(app: ApplicationService);
|
|
27
|
+
/**
|
|
28
|
+
* Bridge AdonisJS and Edge
|
|
29
|
+
*/
|
|
30
|
+
boot(): Promise<void>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
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 edge from 'edge.js';
|
|
10
|
+
import { BriskRoute, HttpContext } from '../modules/http/main.js';
|
|
11
|
+
/**
|
|
12
|
+
* The Edge service provider configures Edge to work within
|
|
13
|
+
* an AdonisJS application environment
|
|
14
|
+
*/
|
|
15
|
+
export default class EdgeServiceProvider {
|
|
16
|
+
app;
|
|
17
|
+
constructor(app) {
|
|
18
|
+
this.app = app;
|
|
19
|
+
this.app.usingEdgeJS = true;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Bridge AdonisJS and Edge
|
|
23
|
+
*/
|
|
24
|
+
async boot() {
|
|
25
|
+
const app = this.app;
|
|
26
|
+
const router = await this.app.container.make('router');
|
|
27
|
+
function edgeConfigResolver(key, defaultValue) {
|
|
28
|
+
return app.config.get(key, defaultValue);
|
|
29
|
+
}
|
|
30
|
+
edgeConfigResolver.has = function (key) {
|
|
31
|
+
return app.config.has(key);
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Mount the default disk
|
|
35
|
+
*/
|
|
36
|
+
edge.mount(app.viewsPath());
|
|
37
|
+
/**
|
|
38
|
+
* Cache templates in production
|
|
39
|
+
*/
|
|
40
|
+
edge.configure({ cache: app.inProduction });
|
|
41
|
+
/**
|
|
42
|
+
* Define Edge global helpers
|
|
43
|
+
*/
|
|
44
|
+
edge.global('route', function (...args) {
|
|
45
|
+
return router.makeUrl(...args);
|
|
46
|
+
});
|
|
47
|
+
edge.global('signedRoute', function (...args) {
|
|
48
|
+
return router.makeSignedUrl(...args);
|
|
49
|
+
});
|
|
50
|
+
edge.global('app', app);
|
|
51
|
+
edge.global('config', edgeConfigResolver);
|
|
52
|
+
/**
|
|
53
|
+
* Creating a isolated instance of edge renderer
|
|
54
|
+
*/
|
|
55
|
+
HttpContext.getter('view', function () {
|
|
56
|
+
return edge.createRenderer().share({
|
|
57
|
+
request: this.request,
|
|
58
|
+
});
|
|
59
|
+
}, true);
|
|
60
|
+
/**
|
|
61
|
+
* Adding brisk route to render templates without an
|
|
62
|
+
* explicit handler
|
|
63
|
+
*/
|
|
64
|
+
BriskRoute.macro('render', function (template, data) {
|
|
65
|
+
return this.setHandler(({ view }) => {
|
|
66
|
+
return view.render(template, data);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -5,10 +5,6 @@ import type { ApplicationService } from '../src/types.js';
|
|
|
5
5
|
export default class HashServiceProvider {
|
|
6
6
|
protected app: ApplicationService;
|
|
7
7
|
constructor(app: ApplicationService);
|
|
8
|
-
/**
|
|
9
|
-
* Registering bundled drivers with the driversList collection
|
|
10
|
-
*/
|
|
11
|
-
protected registerHashDrivers(): void;
|
|
12
8
|
/**
|
|
13
9
|
* Registering the hash class to resolve an instance with the
|
|
14
10
|
* default hasher.
|
|
@@ -6,7 +6,9 @@
|
|
|
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 {
|
|
9
|
+
import { RuntimeException } from '@poppinss/utils';
|
|
10
|
+
import { Hash } from '../modules/hash/main.js';
|
|
11
|
+
import { configProvider } from '../src/config_provider.js';
|
|
10
12
|
/**
|
|
11
13
|
* Registers the passwords hasher with the container
|
|
12
14
|
*/
|
|
@@ -15,14 +17,6 @@ export default class HashServiceProvider {
|
|
|
15
17
|
constructor(app) {
|
|
16
18
|
this.app = app;
|
|
17
19
|
}
|
|
18
|
-
/**
|
|
19
|
-
* Registering bundled drivers with the driversList collection
|
|
20
|
-
*/
|
|
21
|
-
registerHashDrivers() {
|
|
22
|
-
driversList.extend('bcrypt', (config) => new Bcrypt(config));
|
|
23
|
-
driversList.extend('scrypt', (config) => new Scrypt(config));
|
|
24
|
-
driversList.extend('argon2', (config) => new Argon(config));
|
|
25
|
-
}
|
|
26
20
|
/**
|
|
27
21
|
* Registering the hash class to resolve an instance with the
|
|
28
22
|
* default hasher.
|
|
@@ -38,8 +32,15 @@ export default class HashServiceProvider {
|
|
|
38
32
|
*/
|
|
39
33
|
registerHashManager() {
|
|
40
34
|
this.app.container.singleton('hash', async () => {
|
|
35
|
+
const hashConfigProvider = this.app.config.get('hash');
|
|
36
|
+
/**
|
|
37
|
+
* Resolve config from the provider
|
|
38
|
+
*/
|
|
39
|
+
const config = await configProvider.resolve(this.app, hashConfigProvider);
|
|
40
|
+
if (!config) {
|
|
41
|
+
throw new RuntimeException('Invalid "config/hash.ts" file. Make sure you are using the "defineConfig" method');
|
|
42
|
+
}
|
|
41
43
|
const { HashManager } = await import('../modules/hash/main.js');
|
|
42
|
-
const config = this.app.config.get('hash');
|
|
43
44
|
return new HashManager(config);
|
|
44
45
|
});
|
|
45
46
|
}
|
|
@@ -47,7 +48,6 @@ export default class HashServiceProvider {
|
|
|
47
48
|
* Registers bindings
|
|
48
49
|
*/
|
|
49
50
|
register() {
|
|
50
|
-
this.registerHashDrivers();
|
|
51
51
|
this.registerHashManager();
|
|
52
52
|
this.registerHash();
|
|
53
53
|
}
|
|
@@ -8,6 +8,16 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { join } from 'node:path';
|
|
10
10
|
import { homedir } from 'node:os';
|
|
11
|
+
import { fsImportAll } from '@poppinss/utils';
|
|
12
|
+
import { Repl } from '../modules/repl.js';
|
|
13
|
+
/**
|
|
14
|
+
* Resolves a container binding and sets it on the REPL
|
|
15
|
+
* context
|
|
16
|
+
*/
|
|
17
|
+
async function resolveBindingForRepl(app, repl, binding) {
|
|
18
|
+
repl.server.context[binding] = await app.container.make(binding);
|
|
19
|
+
repl.notify(`Loaded "${binding}" service. You can access it using the "${repl.colors.underline(binding)}" variable`);
|
|
20
|
+
}
|
|
11
21
|
export default class ReplServiceProvider {
|
|
12
22
|
app;
|
|
13
23
|
constructor(app) {
|
|
@@ -17,21 +27,78 @@ export default class ReplServiceProvider {
|
|
|
17
27
|
* Registers the REPL binding
|
|
18
28
|
*/
|
|
19
29
|
register() {
|
|
20
|
-
this.app.container.singleton(
|
|
21
|
-
const { Repl } = await import('../modules/repl.js');
|
|
30
|
+
this.app.container.singleton(Repl, async () => {
|
|
22
31
|
return new Repl({
|
|
23
32
|
historyFilePath: join(homedir(), '.adonisjs_v6_repl_history'),
|
|
24
33
|
});
|
|
25
34
|
});
|
|
35
|
+
this.app.container.alias('repl', Repl);
|
|
26
36
|
}
|
|
27
37
|
/**
|
|
28
38
|
* Registering REPL bindings during provider boot
|
|
29
39
|
*/
|
|
30
40
|
async boot() {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
41
|
+
this.app.container.resolving('repl', (repl) => {
|
|
42
|
+
repl.addMethod('importDefault', (_, modulePath) => {
|
|
43
|
+
return this.app.importDefault(modulePath);
|
|
44
|
+
}, {
|
|
45
|
+
description: 'Returns the default export for a module',
|
|
46
|
+
});
|
|
47
|
+
repl.addMethod('importAll', (_, dirPath) => {
|
|
48
|
+
return fsImportAll(this.app.makeURL(dirPath), {
|
|
49
|
+
ignoreMissingRoot: false,
|
|
50
|
+
});
|
|
51
|
+
}, {
|
|
52
|
+
description: 'Import all files from a directory and assign them to a variable',
|
|
53
|
+
});
|
|
54
|
+
repl.addMethod('make', (_, service, runtimeValues) => {
|
|
55
|
+
return this.app.container.make(service, runtimeValues);
|
|
56
|
+
}, {
|
|
57
|
+
description: 'Make class instance using "container.make" method',
|
|
58
|
+
});
|
|
59
|
+
repl.addMethod('loadApp', () => {
|
|
60
|
+
return resolveBindingForRepl(this.app, repl, 'app');
|
|
61
|
+
}, {
|
|
62
|
+
description: 'Load "app" service in the REPL context',
|
|
63
|
+
});
|
|
64
|
+
repl.addMethod('loadEncryption', () => {
|
|
65
|
+
return resolveBindingForRepl(this.app, repl, 'encryption');
|
|
66
|
+
}, {
|
|
67
|
+
description: 'Load "encryption" service in the REPL context',
|
|
68
|
+
});
|
|
69
|
+
repl.addMethod('loadHash', () => {
|
|
70
|
+
return resolveBindingForRepl(this.app, repl, 'hash');
|
|
71
|
+
}, {
|
|
72
|
+
description: 'Load "hash" service in the REPL context',
|
|
73
|
+
});
|
|
74
|
+
repl.addMethod('loadRouter', () => {
|
|
75
|
+
return resolveBindingForRepl(this.app, repl, 'router');
|
|
76
|
+
}, {
|
|
77
|
+
description: 'Load "router" service in the REPL context',
|
|
78
|
+
});
|
|
79
|
+
repl.addMethod('loadConfig', () => {
|
|
80
|
+
return resolveBindingForRepl(this.app, repl, 'config');
|
|
81
|
+
}, {
|
|
82
|
+
description: 'Load "config" service in the REPL context',
|
|
83
|
+
});
|
|
84
|
+
repl.addMethod('loadTestUtils', () => {
|
|
85
|
+
return resolveBindingForRepl(this.app, repl, 'testUtils');
|
|
86
|
+
}, {
|
|
87
|
+
description: 'Load "testUtils" service in the REPL context',
|
|
88
|
+
});
|
|
89
|
+
repl.addMethod('loadHelpers', async () => {
|
|
90
|
+
const { default: isModule } = await import('../src/helpers/is.js');
|
|
91
|
+
const { default: stringModule } = await import('../src/helpers/string.js');
|
|
92
|
+
const helpers = await import('../src/helpers/main.js');
|
|
93
|
+
repl.server.context.helpers = {
|
|
94
|
+
string: stringModule,
|
|
95
|
+
is: isModule,
|
|
96
|
+
...helpers,
|
|
97
|
+
};
|
|
98
|
+
repl.notify(`Loaded "helpers" module. You can access it using the "${repl.colors.underline('helpers')}" variable`);
|
|
99
|
+
}, {
|
|
100
|
+
description: 'Load "helpers" module in the REPL context',
|
|
101
|
+
});
|
|
102
|
+
});
|
|
36
103
|
}
|
|
37
104
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { BaseLiteralType } from '@vinejs/vine';
|
|
2
|
+
import type { Validation, FieldContext, FieldOptions } from '@vinejs/vine/types';
|
|
3
|
+
import type { MultipartFile, FileValidationOptions } from '@adonisjs/bodyparser/types';
|
|
4
|
+
import type { ApplicationService } from '../src/types.js';
|
|
5
|
+
import { RequestValidator } from '../modules/http/main.js';
|
|
6
|
+
/**
|
|
7
|
+
* Validation options accepted by the "file" rule
|
|
8
|
+
*/
|
|
9
|
+
export type FileRuleValidationOptions = Partial<FileValidationOptions> | ((field: FieldContext) => Partial<FileValidationOptions>);
|
|
10
|
+
/**
|
|
11
|
+
* Extend VineJS
|
|
12
|
+
*/
|
|
13
|
+
declare module '@vinejs/vine' {
|
|
14
|
+
interface Vine {
|
|
15
|
+
file(options?: FileRuleValidationOptions): VineMultipartFile;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Extend HTTP request class
|
|
20
|
+
*/
|
|
21
|
+
declare module '@adonisjs/core/http' {
|
|
22
|
+
interface Request extends RequestValidator {
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Represents a multipart file uploaded via multipart/form-data HTTP
|
|
27
|
+
* request.
|
|
28
|
+
*/
|
|
29
|
+
declare class VineMultipartFile extends BaseLiteralType<MultipartFile, MultipartFile> {
|
|
30
|
+
#private;
|
|
31
|
+
constructor(validationOptions?: FileRuleValidationOptions, options?: FieldOptions, validations?: Validation<any>[]);
|
|
32
|
+
clone(): this;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The Edge service provider configures Edge to work within
|
|
36
|
+
* an AdonisJS application environment
|
|
37
|
+
*/
|
|
38
|
+
export default class VineJSServiceProvider {
|
|
39
|
+
protected app: ApplicationService;
|
|
40
|
+
constructor(app: ApplicationService);
|
|
41
|
+
boot(): void;
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
import vine, { BaseLiteralType, Vine } from '@vinejs/vine';
|
|
10
|
+
import { Request, RequestValidator } from '../modules/http/main.js';
|
|
10
11
|
/**
|
|
11
12
|
* Checks if the value is an instance of multipart file
|
|
12
13
|
* from bodyparser.
|
|
@@ -68,9 +69,29 @@ class VineMultipartFile extends BaseLiteralType {
|
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
71
|
/**
|
|
71
|
-
* The
|
|
72
|
-
*
|
|
72
|
+
* The Edge service provider configures Edge to work within
|
|
73
|
+
* an AdonisJS application environment
|
|
73
74
|
*/
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
export default class VineJSServiceProvider {
|
|
76
|
+
app;
|
|
77
|
+
constructor(app) {
|
|
78
|
+
this.app = app;
|
|
79
|
+
this.app.usingVineJS = true;
|
|
80
|
+
}
|
|
81
|
+
boot() {
|
|
82
|
+
/**
|
|
83
|
+
* The file method is used to validate a field to be a valid
|
|
84
|
+
* multipart file.
|
|
85
|
+
*/
|
|
86
|
+
Vine.macro('file', function (options) {
|
|
87
|
+
return new VineMultipartFile(options);
|
|
88
|
+
});
|
|
89
|
+
/**
|
|
90
|
+
* The validate method can be used to validate the request
|
|
91
|
+
* data for the current request using VineJS validators
|
|
92
|
+
*/
|
|
93
|
+
Request.macro('validateUsing', function (...args) {
|
|
94
|
+
return new RequestValidator(this.ctx).validateUsing(...args);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ApplicationService, ConfigProvider } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Helper to create config provider and resolve config from
|
|
4
|
+
* them
|
|
5
|
+
*/
|
|
6
|
+
export declare const configProvider: {
|
|
7
|
+
create<T>(resolver: (app: ApplicationService) => Promise<T>): ConfigProvider<T>;
|
|
8
|
+
resolve<T_1>(app: ApplicationService, provider: unknown): Promise<T_1 | null>;
|
|
9
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
* Helper to create config provider and resolve config from
|
|
11
|
+
* them
|
|
12
|
+
*/
|
|
13
|
+
export const configProvider = {
|
|
14
|
+
create(resolver) {
|
|
15
|
+
return {
|
|
16
|
+
type: 'provider',
|
|
17
|
+
resolver,
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
async resolve(app, provider) {
|
|
21
|
+
if (provider && typeof provider === 'object' && 'type' in provider) {
|
|
22
|
+
return provider.resolver(app);
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
},
|
|
26
|
+
};
|
package/build/src/debug.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { assertExists, assertNotNull, assertIsDefined, assertUnreachable, } from '@poppinss/utils/assert';
|
|
@@ -0,0 +1,9 @@
|
|
|
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 { assertExists, assertNotNull, assertIsDefined, assertUnreachable, } from '@poppinss/utils/assert';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { default as parseImports } from 'parse-imports';
|
|
2
|
-
export { createId as cuid } from '@paralleldrive/cuid2';
|
|
3
|
-
export {
|
|
2
|
+
export { createId as cuid, isCuid } from '@paralleldrive/cuid2';
|
|
3
|
+
export { slash, base64, compose, Secret, joinToURL, fsReadAll, safeEqual, getDirname, getFilename, fsImportAll, MessageBuilder, } from '@poppinss/utils';
|
|
4
4
|
export { parseBindingReference } from './parse_binding_reference.js';
|
|
@@ -7,6 +7,6 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
export { default as parseImports } from 'parse-imports';
|
|
10
|
-
export { createId as cuid } from '@paralleldrive/cuid2';
|
|
11
|
-
export {
|
|
10
|
+
export { createId as cuid, isCuid } from '@paralleldrive/cuid2';
|
|
11
|
+
export { slash, base64, compose, Secret, joinToURL, fsReadAll, safeEqual, getDirname, getFilename, fsImportAll, MessageBuilder, } from '@poppinss/utils';
|
|
12
12
|
export { parseBindingReference } from './parse_binding_reference.js';
|