@adonisjs/core 6.18.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 -23
- package/build/providers/vinejs_provider.js +32 -66
- 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 +42 -0
- package/build/src/vine.js +97 -0
- 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 +57 -55
- 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
|
@@ -9,14 +9,25 @@
|
|
|
9
9
|
import { Socket } from 'node:net';
|
|
10
10
|
import Macroable from '@poppinss/macroable';
|
|
11
11
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
12
|
-
import { HttpServerUtils } from
|
|
13
|
-
import { CookieClient } from
|
|
12
|
+
import { HttpServerUtils } from "./http.js";
|
|
13
|
+
import { CookieClient } from "../../modules/http/main.js";
|
|
14
14
|
/**
|
|
15
15
|
* Test utils has a collection of helper methods to make testing
|
|
16
|
-
* experience great for AdonisJS applications
|
|
16
|
+
* experience great for AdonisJS applications. It provides utilities
|
|
17
|
+
* for HTTP testing, context creation, and cookie handling.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* const testUtils = new TestUtils(app)
|
|
21
|
+
* await testUtils.boot()
|
|
22
|
+
*
|
|
23
|
+
* const ctx = await testUtils.createHttpContext()
|
|
24
|
+
* const httpUtils = testUtils.httpServer()
|
|
17
25
|
*/
|
|
18
26
|
export class TestUtils extends Macroable {
|
|
19
27
|
app;
|
|
28
|
+
/**
|
|
29
|
+
* Flag to track if test utils have been booted
|
|
30
|
+
*/
|
|
20
31
|
#booted = false;
|
|
21
32
|
/**
|
|
22
33
|
* Check if utils have been booted
|
|
@@ -24,6 +35,11 @@ export class TestUtils extends Macroable {
|
|
|
24
35
|
get isBooted() {
|
|
25
36
|
return this.#booted;
|
|
26
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Creates a new TestUtils instance
|
|
40
|
+
*
|
|
41
|
+
* @param app - The application service instance
|
|
42
|
+
*/
|
|
27
43
|
constructor(app) {
|
|
28
44
|
super();
|
|
29
45
|
this.app = app;
|
|
@@ -47,6 +63,8 @@ export class TestUtils extends Macroable {
|
|
|
47
63
|
}
|
|
48
64
|
/**
|
|
49
65
|
* Create an instance of HTTP context for testing
|
|
66
|
+
*
|
|
67
|
+
* @param options - Options for creating HTTP context with custom req/res objects
|
|
50
68
|
*/
|
|
51
69
|
async createHttpContext(options = {}) {
|
|
52
70
|
const req = options.req || new IncomingMessage(new Socket());
|
package/build/src/types.d.ts
CHANGED
|
@@ -1,40 +1,72 @@
|
|
|
1
|
-
import type { Repl } from '../modules/repl.
|
|
2
|
-
import type { Importer } from '../types/app.
|
|
3
|
-
import type { Emitter } from '../modules/events.
|
|
4
|
-
import type { Kernel } from '../modules/ace/main.
|
|
5
|
-
import type { Application } from '../modules/app.
|
|
6
|
-
import type { TestUtils } from './test_utils/main.
|
|
7
|
-
import type { HttpServerEvents } from '../types/http.
|
|
8
|
-
import type { Dumper } from '../modules/dumper/dumper.
|
|
9
|
-
import type { LoggerManager } from '../modules/logger.
|
|
10
|
-
import type { HashManager } from '../modules/hash/main.
|
|
11
|
-
import type { Encryption } from '../modules/encryption.
|
|
12
|
-
import type { ManagerDriverFactory } from '../types/hash.
|
|
13
|
-
import type { Router, Server } from '../modules/http/main.
|
|
14
|
-
import type { ContainerResolveEventData } from '../types/container.
|
|
15
|
-
import type { LoggerConfig, LoggerManagerConfig } from '../types/logger.
|
|
1
|
+
import type { Repl } from '../modules/repl.ts';
|
|
2
|
+
import type { Importer } from '../types/app.ts';
|
|
3
|
+
import type { Emitter } from '../modules/events.ts';
|
|
4
|
+
import type { Kernel } from '../modules/ace/main.ts';
|
|
5
|
+
import type { Application } from '../modules/app.ts';
|
|
6
|
+
import type { TestUtils } from './test_utils/main.ts';
|
|
7
|
+
import type { HttpServerEvents, LookupList, RoutesList, SignedURLOptions, UrlFor, URLOptions } from '../types/http.ts';
|
|
8
|
+
import type { Dumper } from '../modules/dumper/dumper.ts';
|
|
9
|
+
import type { LoggerManager } from '../modules/logger.ts';
|
|
10
|
+
import type { HashManager } from '../modules/hash/main.ts';
|
|
11
|
+
import type { Encryption } from '../modules/encryption.ts';
|
|
12
|
+
import type { ManagerDriverFactory } from '../types/hash.ts';
|
|
13
|
+
import type { Router, Server } from '../modules/http/main.ts';
|
|
14
|
+
import type { ContainerResolveEventData } from '../types/container.ts';
|
|
15
|
+
import type { LoggerConfig, LoggerManagerConfig } from '../types/logger.ts';
|
|
16
16
|
/**
|
|
17
17
|
* A config provider waits for the application to get booted
|
|
18
18
|
* and then resolves the config. It receives an instance
|
|
19
19
|
* of the application service.
|
|
20
|
+
*
|
|
21
|
+
* @template T - The type of configuration object that the provider resolves
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* const databaseProvider: ConfigProvider<DatabaseConfig> = {
|
|
25
|
+
* type: 'provider',
|
|
26
|
+
* resolver: async (app) => {
|
|
27
|
+
* return {
|
|
28
|
+
* connection: app.env.get('DB_CONNECTION', 'sqlite'),
|
|
29
|
+
* host: app.env.get('DB_HOST', 'localhost')
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
20
33
|
*/
|
|
21
34
|
export type ConfigProvider<T> = {
|
|
35
|
+
/** Identifies this as a config provider */
|
|
22
36
|
type: 'provider';
|
|
37
|
+
/** Function that resolves the configuration using the application service */
|
|
23
38
|
resolver: (app: ApplicationService) => Promise<T>;
|
|
24
39
|
};
|
|
25
40
|
/**
|
|
26
|
-
* Options accepted by ignitor
|
|
41
|
+
* Options accepted by ignitor for configuring the application bootstrap process.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* const options: IgnitorOptions = {
|
|
45
|
+
* importer: (filePath) => import(filePath)
|
|
46
|
+
* }
|
|
27
47
|
*/
|
|
28
48
|
export type IgnitorOptions = {
|
|
49
|
+
/** Optional custom importer function for loading modules */
|
|
29
50
|
importer?: Importer;
|
|
30
51
|
};
|
|
31
52
|
/**
|
|
32
53
|
* A list of known events. The interface must be extended in
|
|
33
54
|
* user land code or packages to register events and their
|
|
34
55
|
* types.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* // Extending EventsList in user code
|
|
59
|
+
* declare module '@adonisjs/core' {
|
|
60
|
+
* interface EventsList {
|
|
61
|
+
* 'user:created': { user: User }
|
|
62
|
+
* 'order:placed': { orderId: string, amount: number }
|
|
63
|
+
* }
|
|
64
|
+
* }
|
|
35
65
|
*/
|
|
36
66
|
export interface EventsList extends HttpServerEvents {
|
|
67
|
+
/** Event fired when a container binding is resolved */
|
|
37
68
|
'container_binding:resolved': ContainerResolveEventData<ContainerBindings>;
|
|
69
|
+
/** Event fired when the HTTP server is ready and listening */
|
|
38
70
|
'http:server_ready': {
|
|
39
71
|
port: number;
|
|
40
72
|
host: string;
|
|
@@ -43,16 +75,47 @@ export interface EventsList extends HttpServerEvents {
|
|
|
43
75
|
}
|
|
44
76
|
/**
|
|
45
77
|
* The loggers list inferred from the user application
|
|
46
|
-
* config
|
|
78
|
+
* config. This interface should be extended in user code
|
|
79
|
+
* to register custom loggers.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* // Extending LoggersList in user code
|
|
83
|
+
* declare module '@adonisjs/core' {
|
|
84
|
+
* interface LoggersList {
|
|
85
|
+
* default: LoggerConfig
|
|
86
|
+
* file: LoggerConfig
|
|
87
|
+
* }
|
|
88
|
+
* }
|
|
47
89
|
*/
|
|
48
90
|
export interface LoggersList {
|
|
49
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Utility type to infer logger configurations from a LoggerManagerConfig.
|
|
94
|
+
*
|
|
95
|
+
* @template T - The logger manager configuration type
|
|
96
|
+
*/
|
|
50
97
|
export type InferLoggers<T extends LoggerManagerConfig<any>> = T['loggers'];
|
|
51
98
|
/**
|
|
52
|
-
* A list of known hashers inferred from the user config
|
|
99
|
+
* A list of known hashers inferred from the user config.
|
|
100
|
+
* This interface should be extended in user code to register
|
|
101
|
+
* custom hashers.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* // Extending HashersList in user code
|
|
105
|
+
* declare module '@adonisjs/core' {
|
|
106
|
+
* interface HashersList {
|
|
107
|
+
* scrypt: ManagerDriverFactory
|
|
108
|
+
* argon: ManagerDriverFactory
|
|
109
|
+
* }
|
|
110
|
+
* }
|
|
53
111
|
*/
|
|
54
112
|
export interface HashersList {
|
|
55
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* Utility type to infer hasher configurations from a config provider.
|
|
116
|
+
*
|
|
117
|
+
* @template T - The config provider type that resolves to an object with a 'list' property
|
|
118
|
+
*/
|
|
56
119
|
export type InferHashers<T extends ConfigProvider<{
|
|
57
120
|
list: Record<string, ManagerDriverFactory>;
|
|
58
121
|
}>> = Awaited<ReturnType<T['resolver']>>['list'];
|
|
@@ -67,58 +130,246 @@ export type InferHashers<T extends ConfigProvider<{
|
|
|
67
130
|
*/
|
|
68
131
|
/**
|
|
69
132
|
* Application service is a singleton resolved from
|
|
70
|
-
* the container
|
|
133
|
+
* the container. It provides access to the core application
|
|
134
|
+
* instance with all registered bindings.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* // Accessing application service in a controller
|
|
138
|
+
* export default class HomeController {
|
|
139
|
+
* async index({ app }: { app: ApplicationService }) {
|
|
140
|
+
* const version = app.version
|
|
141
|
+
* const env = app.env.get('NODE_ENV')
|
|
142
|
+
* }
|
|
143
|
+
* }
|
|
71
144
|
*/
|
|
72
145
|
export interface ApplicationService extends Application<ContainerBindings extends Record<any, any> ? ContainerBindings : never> {
|
|
73
146
|
}
|
|
74
147
|
/**
|
|
75
148
|
* Logger service is a singleton logger instance registered
|
|
76
|
-
* to the container.
|
|
149
|
+
* to the container. It provides access to configured loggers.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* // Using logger service in a controller
|
|
153
|
+
* export default class UserController {
|
|
154
|
+
* async store({ logger }: { logger: LoggerService }) {
|
|
155
|
+
* logger.info('Creating new user')
|
|
156
|
+
* logger.use('file').error('Failed to create user')
|
|
157
|
+
* }
|
|
158
|
+
* }
|
|
77
159
|
*/
|
|
78
160
|
export interface LoggerService extends LoggerManager<LoggersList extends Record<string, LoggerConfig> ? LoggersList : never> {
|
|
79
161
|
}
|
|
80
162
|
/**
|
|
81
163
|
* Emitter service is a singleton emitter instance registered
|
|
82
|
-
* to the container.
|
|
164
|
+
* to the container. It provides type-safe event emission and listening.
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* // Using emitter service to emit events
|
|
168
|
+
* export default class UserController {
|
|
169
|
+
* async store({ emitter }: { emitter: EmitterService }) {
|
|
170
|
+
* const user = await User.create(data)
|
|
171
|
+
* emitter.emit('user:created', { user })
|
|
172
|
+
* }
|
|
173
|
+
* }
|
|
83
174
|
*/
|
|
84
175
|
export interface EmitterService extends Emitter<EventsList> {
|
|
85
176
|
}
|
|
86
177
|
/**
|
|
87
178
|
* Encryption service is a singleton Encryption class instance
|
|
88
|
-
* registered to the container.
|
|
179
|
+
* registered to the container. It provides encryption and decryption
|
|
180
|
+
* functionality using the application's secret key.
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* // Using encryption service
|
|
184
|
+
* export default class PaymentController {
|
|
185
|
+
* async process({ encryption }: { encryption: EncryptionService }) {
|
|
186
|
+
* const encrypted = encryption.encrypt('sensitive-data')
|
|
187
|
+
* const decrypted = encryption.decrypt(encrypted)
|
|
188
|
+
* }
|
|
189
|
+
* }
|
|
89
190
|
*/
|
|
90
191
|
export interface EncryptionService extends Encryption {
|
|
91
192
|
}
|
|
92
193
|
/**
|
|
93
|
-
* Http server service added to the container as a singleton
|
|
194
|
+
* Http server service added to the container as a singleton.
|
|
195
|
+
* It provides access to the HTTP server instance for handling
|
|
196
|
+
* requests and responses.
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* // Accessing server service in middleware
|
|
200
|
+
* export default class CustomMiddleware {
|
|
201
|
+
* async handle({ server }: { server: HttpServerService }, next: NextFn) {
|
|
202
|
+
* console.log('Server listening on:', server.getPort())
|
|
203
|
+
* return next()
|
|
204
|
+
* }
|
|
205
|
+
* }
|
|
94
206
|
*/
|
|
95
207
|
export interface HttpServerService extends Server {
|
|
96
208
|
}
|
|
97
209
|
/**
|
|
98
|
-
* Http
|
|
210
|
+
* Http router service added to the container as a singleton.
|
|
211
|
+
* It provides access to the application's router for defining
|
|
212
|
+
* and managing routes.
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* // Using router service to define routes programmatically
|
|
216
|
+
* export default class RouteProvider {
|
|
217
|
+
* boot({ router }: { router: HttpRouterService }) {
|
|
218
|
+
* router.get('/api/health', () => ({ status: 'ok' }))
|
|
219
|
+
* }
|
|
220
|
+
* }
|
|
99
221
|
*/
|
|
100
222
|
export interface HttpRouterService extends Router {
|
|
101
223
|
}
|
|
224
|
+
/**
|
|
225
|
+
* Url builder service offers a type-safe API for creating URLs
|
|
226
|
+
* for pre-registered routes. It ensures type safety when building
|
|
227
|
+
* URLs with parameters.
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* // Using URL builder service
|
|
231
|
+
* export default class PostController {
|
|
232
|
+
* async show({ urlBuilder }: { urlBuilder: UrlBuilderService }) {
|
|
233
|
+
* const postUrl = urlBuilder.make('posts.show', { id: 1 })
|
|
234
|
+
* const userUrl = urlBuilder.make('users.profile', { username: 'john' })
|
|
235
|
+
* }
|
|
236
|
+
* }
|
|
237
|
+
*/
|
|
238
|
+
export interface UrlBuilderService extends UrlFor<RoutesList extends LookupList ? RoutesList : never, URLOptions> {
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Url builder service offers a type-safe API for creating signed URLs
|
|
242
|
+
* for pre-registered routes. Signed URLs include a signature that prevents
|
|
243
|
+
* tampering and can have expiration times.
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* // Using signed URL builder service
|
|
247
|
+
* export default class FileController {
|
|
248
|
+
* async getDownloadUrl({ signedUrlBuilder }: { signedUrlBuilder: SignedUrlBuilderService }) {
|
|
249
|
+
* const signedUrl = signedUrlBuilder.make('files.download',
|
|
250
|
+
* { id: 1 },
|
|
251
|
+
* { expiresIn: '1h' }
|
|
252
|
+
* )
|
|
253
|
+
* }
|
|
254
|
+
* }
|
|
255
|
+
*/
|
|
256
|
+
export interface SignedUrlBuilderService extends UrlFor<RoutesList extends LookupList ? RoutesList : never, SignedURLOptions> {
|
|
257
|
+
}
|
|
102
258
|
/**
|
|
103
259
|
* Hash service is a singleton instance of the HashManager
|
|
104
|
-
* registered in the container
|
|
260
|
+
* registered in the container. It provides password hashing
|
|
261
|
+
* and verification functionality.
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* // Using hash service for password management
|
|
265
|
+
* export default class AuthController {
|
|
266
|
+
* async register({ hash }: { hash: HashService }) {
|
|
267
|
+
* const hashedPassword = await hash.make('user-password')
|
|
268
|
+
* const isValid = await hash.verify(hashedPassword, 'user-password')
|
|
269
|
+
* }
|
|
270
|
+
* }
|
|
105
271
|
*/
|
|
106
272
|
export interface HashService extends HashManager<HashersList extends Record<string, ManagerDriverFactory> ? HashersList : never> {
|
|
107
273
|
}
|
|
108
274
|
/**
|
|
109
|
-
* A list of known container bindings.
|
|
275
|
+
* A list of known container bindings. This interface defines
|
|
276
|
+
* all the services that are registered in the IoC container
|
|
277
|
+
* and available for dependency injection.
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
* // Accessing container bindings in a service
|
|
281
|
+
* export default class UserService {
|
|
282
|
+
* constructor(
|
|
283
|
+
* private logger: LoggerService,
|
|
284
|
+
* private hash: HashService,
|
|
285
|
+
* private emitter: EmitterService
|
|
286
|
+
* ) {}
|
|
287
|
+
* }
|
|
110
288
|
*/
|
|
111
289
|
export interface ContainerBindings {
|
|
290
|
+
/** Ace command-line kernel */
|
|
112
291
|
ace: Kernel;
|
|
292
|
+
/** Database query dumper */
|
|
113
293
|
dumper: Dumper;
|
|
294
|
+
/** Main application instance */
|
|
114
295
|
app: ApplicationService;
|
|
296
|
+
/** Logger manager instance */
|
|
115
297
|
logger: LoggerService;
|
|
298
|
+
/** Application configuration */
|
|
116
299
|
config: ApplicationService['config'];
|
|
300
|
+
/** Event emitter instance */
|
|
117
301
|
emitter: EmitterService;
|
|
302
|
+
/** Encryption service */
|
|
118
303
|
encryption: EncryptionService;
|
|
304
|
+
/** Hash manager for password hashing */
|
|
119
305
|
hash: HashService;
|
|
306
|
+
/** HTTP server instance */
|
|
120
307
|
server: HttpServerService;
|
|
308
|
+
/** HTTP router instance */
|
|
121
309
|
router: HttpRouterService;
|
|
310
|
+
/** Test utilities */
|
|
122
311
|
testUtils: TestUtils;
|
|
312
|
+
/** REPL instance */
|
|
123
313
|
repl: Repl;
|
|
124
314
|
}
|
|
315
|
+
/**
|
|
316
|
+
* Configuration options for the IndexEntities assembler hook.
|
|
317
|
+
* This type defines the settings for automatically generating
|
|
318
|
+
* barrel files for controllers, listeners, and events.
|
|
319
|
+
*
|
|
320
|
+
* @example
|
|
321
|
+
* // Basic configuration
|
|
322
|
+
* const config: IndexEntitiesConfig = {
|
|
323
|
+
* controllers: { enabled: true },
|
|
324
|
+
* events: { source: 'app/custom-events' }
|
|
325
|
+
* }
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* // Detailed configuration with custom paths
|
|
329
|
+
* const config: IndexEntitiesConfig = {
|
|
330
|
+
* controllers: {
|
|
331
|
+
* enabled: true,
|
|
332
|
+
* source: 'app/http/controllers',
|
|
333
|
+
* importAlias: '#controllers',
|
|
334
|
+
* glob: ['**\/*_controller.ts']
|
|
335
|
+
* },
|
|
336
|
+
* listeners: {
|
|
337
|
+
* enabled: false
|
|
338
|
+
* }
|
|
339
|
+
* }
|
|
340
|
+
*/
|
|
341
|
+
export type IndexEntitiesConfig = {
|
|
342
|
+
/** Configuration for controllers indexing */
|
|
343
|
+
controllers?: {
|
|
344
|
+
/** Whether to enable controllers indexing */
|
|
345
|
+
enabled?: boolean;
|
|
346
|
+
/** Source directory for controllers */
|
|
347
|
+
source?: string;
|
|
348
|
+
/** Import alias for controllers */
|
|
349
|
+
importAlias?: string;
|
|
350
|
+
/** Glob patterns for matching controller files */
|
|
351
|
+
glob?: string[];
|
|
352
|
+
};
|
|
353
|
+
/** Configuration for listeners indexing */
|
|
354
|
+
listeners?: {
|
|
355
|
+
/** Whether to enable listeners indexing */
|
|
356
|
+
enabled?: boolean;
|
|
357
|
+
/** Source directory for listeners */
|
|
358
|
+
source?: string;
|
|
359
|
+
/** Import alias for listeners */
|
|
360
|
+
importAlias?: string;
|
|
361
|
+
/** Glob patterns for matching listener files */
|
|
362
|
+
glob?: string[];
|
|
363
|
+
};
|
|
364
|
+
/** Configuration for events indexing */
|
|
365
|
+
events?: {
|
|
366
|
+
/** Whether to enable events indexing */
|
|
367
|
+
enabled?: boolean;
|
|
368
|
+
/** Source directory for events */
|
|
369
|
+
source?: string;
|
|
370
|
+
/** Import alias for events */
|
|
371
|
+
importAlias?: string;
|
|
372
|
+
/** Glob patterns for matching event files */
|
|
373
|
+
glob?: string[];
|
|
374
|
+
};
|
|
375
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type typescript from 'typescript';
|
|
2
|
+
import type * as Assembler from '@adonisjs/assembler';
|
|
3
|
+
import { type ApplicationService } from './types.ts';
|
|
4
|
+
/**
|
|
5
|
+
* Imports the AdonisJS assembler package optionally. This function attempts
|
|
6
|
+
* to import the assembler and returns undefined if it's not available,
|
|
7
|
+
* making it safe to use in environments where the assembler might not be installed.
|
|
8
|
+
*
|
|
9
|
+
* @param app - The application service instance used for importing the assembler
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const assembler = await importAssembler(app)
|
|
13
|
+
* if (assembler) {
|
|
14
|
+
* // Use assembler functionality
|
|
15
|
+
* const generator = new assembler.IndexGenerator()
|
|
16
|
+
* }
|
|
17
|
+
*/
|
|
18
|
+
export declare function importAssembler(app: ApplicationService): Promise<typeof Assembler | undefined>;
|
|
19
|
+
/**
|
|
20
|
+
* Imports the TypeScript compiler package optionally. This function attempts
|
|
21
|
+
* to import TypeScript and returns undefined if it's not available,
|
|
22
|
+
* making it safe to use in environments where TypeScript might not be installed.
|
|
23
|
+
*
|
|
24
|
+
* @param app - The application service instance used for importing TypeScript
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* const ts = await importTypeScript(app)
|
|
28
|
+
* if (ts) {
|
|
29
|
+
* // Use TypeScript compiler API
|
|
30
|
+
* const program = ts.createProgram(['file.ts'], {})
|
|
31
|
+
* const sourceFile = program.getSourceFile('file.ts')
|
|
32
|
+
* }
|
|
33
|
+
*/
|
|
34
|
+
export declare function importTypeScript(app: ApplicationService): Promise<typeof typescript | undefined>;
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
* Imports the AdonisJS assembler package optionally. This function attempts
|
|
11
|
+
* to import the assembler and returns undefined if it's not available,
|
|
12
|
+
* making it safe to use in environments where the assembler might not be installed.
|
|
13
|
+
*
|
|
14
|
+
* @param app - The application service instance used for importing the assembler
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* const assembler = await importAssembler(app)
|
|
18
|
+
* if (assembler) {
|
|
19
|
+
* // Use assembler functionality
|
|
20
|
+
* const generator = new assembler.IndexGenerator()
|
|
21
|
+
* }
|
|
22
|
+
*/
|
|
23
|
+
export async function importAssembler(app) {
|
|
24
|
+
try {
|
|
25
|
+
return await app.import('@adonisjs/assembler');
|
|
26
|
+
}
|
|
27
|
+
catch { }
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Imports the TypeScript compiler package optionally. This function attempts
|
|
31
|
+
* to import TypeScript and returns undefined if it's not available,
|
|
32
|
+
* making it safe to use in environments where TypeScript might not be installed.
|
|
33
|
+
*
|
|
34
|
+
* @param app - The application service instance used for importing TypeScript
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* const ts = await importTypeScript(app)
|
|
38
|
+
* if (ts) {
|
|
39
|
+
* // Use TypeScript compiler API
|
|
40
|
+
* const program = ts.createProgram(['file.ts'], {})
|
|
41
|
+
* const sourceFile = program.getSourceFile('file.ts')
|
|
42
|
+
* }
|
|
43
|
+
*/
|
|
44
|
+
export async function importTypeScript(app) {
|
|
45
|
+
try {
|
|
46
|
+
return await app.importDefault('typescript');
|
|
47
|
+
}
|
|
48
|
+
catch { }
|
|
49
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { symbols, BaseLiteralType } from '@vinejs/vine';
|
|
2
|
+
import type { Validation, FieldContext, FieldOptions } from '@vinejs/vine/types';
|
|
3
|
+
import type { MultipartFile, FileValidationOptions } from '@adonisjs/bodyparser/types';
|
|
4
|
+
declare const MULTIPART_FILE: typeof symbols.SUBTYPE;
|
|
5
|
+
/**
|
|
6
|
+
* Validation options accepted by the "file" rule
|
|
7
|
+
*/
|
|
8
|
+
export type FileRuleValidationOptions = Partial<FileValidationOptions> | ((field: FieldContext) => Partial<FileValidationOptions>);
|
|
9
|
+
/**
|
|
10
|
+
* Represents a multipart file uploaded via multipart/form-data HTTP
|
|
11
|
+
* request. This class extends VineJS's BaseLiteralType to provide
|
|
12
|
+
* specialized validation for uploaded files.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const fileSchema = vine.object({
|
|
16
|
+
* avatar: vine.file({
|
|
17
|
+
* size: '2mb',
|
|
18
|
+
* extnames: ['jpg', 'png']
|
|
19
|
+
* })
|
|
20
|
+
* })
|
|
21
|
+
*/
|
|
22
|
+
export declare class VineMultipartFile extends BaseLiteralType<MultipartFile, MultipartFile, MultipartFile> {
|
|
23
|
+
#private;
|
|
24
|
+
/**
|
|
25
|
+
* Symbol identifier for multipart file subtype
|
|
26
|
+
*/
|
|
27
|
+
[MULTIPART_FILE]: string;
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new VineMultipartFile instance
|
|
30
|
+
*
|
|
31
|
+
* @param validationOptions - File validation options like size limits and allowed extensions
|
|
32
|
+
* @param options - Field options from VineJS
|
|
33
|
+
* @param validations - Array of validation functions to apply
|
|
34
|
+
*/
|
|
35
|
+
constructor(validationOptions?: FileRuleValidationOptions, options?: FieldOptions, validations?: Validation<any>[]);
|
|
36
|
+
/**
|
|
37
|
+
* Creates a clone of the current VineMultipartFile instance
|
|
38
|
+
* with the same validation options and configurations
|
|
39
|
+
*/
|
|
40
|
+
clone(): this;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
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 vine, { symbols, BaseLiteralType } from '@vinejs/vine';
|
|
10
|
+
const MULTIPART_FILE = symbols.SUBTYPE ?? Symbol.for('subtype');
|
|
11
|
+
/**
|
|
12
|
+
* Checks if the value is an instance of multipart file
|
|
13
|
+
* from bodyparser.
|
|
14
|
+
*/
|
|
15
|
+
function isBodyParserFile(file) {
|
|
16
|
+
return !!(file && typeof file === 'object' && 'isMultipartFile' in file);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* VineJS validation rule that validates the file to be an
|
|
20
|
+
* instance of BodyParser MultipartFile class.
|
|
21
|
+
*/
|
|
22
|
+
const isMultipartFile = vine.createRule((file, options, field) => {
|
|
23
|
+
/**
|
|
24
|
+
* Report error when value is not a field multipart
|
|
25
|
+
* file object
|
|
26
|
+
*/
|
|
27
|
+
if (!isBodyParserFile(file)) {
|
|
28
|
+
field.report('The {{ field }} must be a file', 'file', field);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const validationOptions = typeof options === 'function' ? options(field) : options;
|
|
32
|
+
/**
|
|
33
|
+
* Set size when it's defined in the options and missing
|
|
34
|
+
* on the file instance
|
|
35
|
+
*/
|
|
36
|
+
if (file.sizeLimit === undefined && validationOptions.size) {
|
|
37
|
+
file.sizeLimit = validationOptions.size;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Set extensions when it's defined in the options and missing
|
|
41
|
+
* on the file instance
|
|
42
|
+
*/
|
|
43
|
+
if (file.allowedExtensions === undefined && validationOptions.extnames) {
|
|
44
|
+
file.allowedExtensions = validationOptions.extnames;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Validate file
|
|
48
|
+
*/
|
|
49
|
+
file.validate();
|
|
50
|
+
/**
|
|
51
|
+
* Report errors
|
|
52
|
+
*/
|
|
53
|
+
file.errors.forEach((error) => {
|
|
54
|
+
field.report(error.message, `file.${error.type}`, field, validationOptions);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
/**
|
|
58
|
+
* Represents a multipart file uploaded via multipart/form-data HTTP
|
|
59
|
+
* request. This class extends VineJS's BaseLiteralType to provide
|
|
60
|
+
* specialized validation for uploaded files.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* const fileSchema = vine.object({
|
|
64
|
+
* avatar: vine.file({
|
|
65
|
+
* size: '2mb',
|
|
66
|
+
* extnames: ['jpg', 'png']
|
|
67
|
+
* })
|
|
68
|
+
* })
|
|
69
|
+
*/
|
|
70
|
+
export class VineMultipartFile extends BaseLiteralType {
|
|
71
|
+
/**
|
|
72
|
+
* Private validation options for file validation
|
|
73
|
+
*/
|
|
74
|
+
#validationOptions;
|
|
75
|
+
/**
|
|
76
|
+
* Symbol identifier for multipart file subtype
|
|
77
|
+
*/
|
|
78
|
+
[MULTIPART_FILE] = 'multipartFile';
|
|
79
|
+
/**
|
|
80
|
+
* Creates a new VineMultipartFile instance
|
|
81
|
+
*
|
|
82
|
+
* @param validationOptions - File validation options like size limits and allowed extensions
|
|
83
|
+
* @param options - Field options from VineJS
|
|
84
|
+
* @param validations - Array of validation functions to apply
|
|
85
|
+
*/
|
|
86
|
+
constructor(validationOptions, options, validations) {
|
|
87
|
+
super(options, validations || [isMultipartFile(validationOptions || {})]);
|
|
88
|
+
this.#validationOptions = validationOptions;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Creates a clone of the current VineMultipartFile instance
|
|
92
|
+
* with the same validation options and configurations
|
|
93
|
+
*/
|
|
94
|
+
clone() {
|
|
95
|
+
return new VineMultipartFile(this.#validationOptions, this.cloneOptions(), this.cloneValidations());
|
|
96
|
+
}
|
|
97
|
+
}
|
package/build/stubs/main.js
CHANGED
|
@@ -6,5 +6,4 @@
|
|
|
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
|
-
export const stubsRoot = getDirname(import.meta.url);
|
|
9
|
+
export const stubsRoot = import.meta.dirname;
|
package/build/toolkit/main.js
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* For the full copyright and license information, please view the LICENSE
|
|
8
8
|
* file that was distributed with this source code.
|
|
9
9
|
*/
|
|
10
|
-
import IndexCommand from './commands/index_commands.js';
|
|
11
10
|
import { Kernel, ListLoader, HelpCommand } from '@adonisjs/ace';
|
|
11
|
+
import IndexCommand from "./commands/index_commands.js";
|
|
12
12
|
const kernel = Kernel.create();
|
|
13
13
|
kernel.addLoader(new ListLoader([IndexCommand]));
|
|
14
14
|
kernel.defineFlag('help', {
|
package/build/types/helpers.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export type { Opaque,
|
|
1
|
+
export type { Opaque, NormalizeConstructor } from '@poppinss/utils/types';
|
|
2
|
+
export type { ImportAllFilesOptions, ReadAllFilesOptions } from '@poppinss/utils/fs';
|