@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
|
@@ -4,7 +4,16 @@ import { Secret } from '@poppinss/utils';
|
|
|
4
4
|
* shareable tokens while storing the token hash within the database.
|
|
5
5
|
*
|
|
6
6
|
* This class is used by the Auth and the Persona packages to manage
|
|
7
|
-
* tokens
|
|
7
|
+
* tokens for authentication and authorization purposes.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* class UserToken extends VerificationToken {
|
|
11
|
+
* constructor(user: User, secret: Secret<string>) {
|
|
12
|
+
* super()
|
|
13
|
+
* this.tokenableId = user.id
|
|
14
|
+
* this.computeValue(secret)
|
|
15
|
+
* }
|
|
16
|
+
* }
|
|
8
17
|
*/
|
|
9
18
|
export declare abstract class VerificationToken {
|
|
10
19
|
/**
|
|
@@ -13,6 +22,8 @@ export declare abstract class VerificationToken {
|
|
|
13
22
|
*
|
|
14
23
|
* Returns null when unable to decode the token because of
|
|
15
24
|
* invalid format or encoding.
|
|
25
|
+
*
|
|
26
|
+
* @param value - The token string to decode
|
|
16
27
|
*/
|
|
17
28
|
static decode(value: string): null | {
|
|
18
29
|
identifier: string;
|
|
@@ -21,6 +32,10 @@ export declare abstract class VerificationToken {
|
|
|
21
32
|
/**
|
|
22
33
|
* Creates a transient token that can be shared with the persistence
|
|
23
34
|
* layer.
|
|
35
|
+
*
|
|
36
|
+
* @param userId - The user ID for whom the token is being created
|
|
37
|
+
* @param size - The size of the random token seed
|
|
38
|
+
* @param expiresIn - Token expiration time (string like '2h' or number in seconds)
|
|
24
39
|
*/
|
|
25
40
|
static createTransientToken(userId: string | number | BigInt, size: number, expiresIn: string | number): {
|
|
26
41
|
secret: Secret<string>;
|
|
@@ -30,6 +45,8 @@ export declare abstract class VerificationToken {
|
|
|
30
45
|
};
|
|
31
46
|
/**
|
|
32
47
|
* Creates a secret opaque token and its hash.
|
|
48
|
+
*
|
|
49
|
+
* @param size - The length of the random token to generate
|
|
33
50
|
*/
|
|
34
51
|
static seed(size: number): {
|
|
35
52
|
secret: Secret<string>;
|
|
@@ -64,6 +81,8 @@ export declare abstract class VerificationToken {
|
|
|
64
81
|
/**
|
|
65
82
|
* Compute the value property using the given secret. You can
|
|
66
83
|
* get secret via the static "createTransientToken" method.
|
|
84
|
+
*
|
|
85
|
+
* @param secret - The secret value to compute the public token value from
|
|
67
86
|
*/
|
|
68
87
|
protected computeValue(secret: Secret<string>): void;
|
|
69
88
|
/**
|
|
@@ -74,6 +93,8 @@ export declare abstract class VerificationToken {
|
|
|
74
93
|
isExpired(): boolean;
|
|
75
94
|
/**
|
|
76
95
|
* Verifies the value of a token against the pre-defined hash
|
|
96
|
+
*
|
|
97
|
+
* @param secret - The secret to verify against the stored hash
|
|
77
98
|
*/
|
|
78
99
|
verify(secret: Secret<string>): boolean;
|
|
79
100
|
}
|
|
@@ -8,13 +8,23 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { createHash } from 'node:crypto';
|
|
10
10
|
import string from '@poppinss/utils/string';
|
|
11
|
-
import {
|
|
11
|
+
import { safeEqual, Secret } from '@poppinss/utils';
|
|
12
|
+
import base64 from '@poppinss/utils/base64';
|
|
12
13
|
/**
|
|
13
14
|
* Verification token class can be used to create tokens publicly
|
|
14
15
|
* shareable tokens while storing the token hash within the database.
|
|
15
16
|
*
|
|
16
17
|
* This class is used by the Auth and the Persona packages to manage
|
|
17
|
-
* tokens
|
|
18
|
+
* tokens for authentication and authorization purposes.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* class UserToken extends VerificationToken {
|
|
22
|
+
* constructor(user: User, secret: Secret<string>) {
|
|
23
|
+
* super()
|
|
24
|
+
* this.tokenableId = user.id
|
|
25
|
+
* this.computeValue(secret)
|
|
26
|
+
* }
|
|
27
|
+
* }
|
|
18
28
|
*/
|
|
19
29
|
export class VerificationToken {
|
|
20
30
|
/**
|
|
@@ -23,6 +33,8 @@ export class VerificationToken {
|
|
|
23
33
|
*
|
|
24
34
|
* Returns null when unable to decode the token because of
|
|
25
35
|
* invalid format or encoding.
|
|
36
|
+
*
|
|
37
|
+
* @param value - The token string to decode
|
|
26
38
|
*/
|
|
27
39
|
static decode(value) {
|
|
28
40
|
/**
|
|
@@ -54,6 +66,10 @@ export class VerificationToken {
|
|
|
54
66
|
/**
|
|
55
67
|
* Creates a transient token that can be shared with the persistence
|
|
56
68
|
* layer.
|
|
69
|
+
*
|
|
70
|
+
* @param userId - The user ID for whom the token is being created
|
|
71
|
+
* @param size - The size of the random token seed
|
|
72
|
+
* @param expiresIn - Token expiration time (string like '2h' or number in seconds)
|
|
57
73
|
*/
|
|
58
74
|
static createTransientToken(userId, size, expiresIn) {
|
|
59
75
|
const expiresAt = new Date();
|
|
@@ -66,6 +82,8 @@ export class VerificationToken {
|
|
|
66
82
|
}
|
|
67
83
|
/**
|
|
68
84
|
* Creates a secret opaque token and its hash.
|
|
85
|
+
*
|
|
86
|
+
* @param size - The length of the random token to generate
|
|
69
87
|
*/
|
|
70
88
|
static seed(size) {
|
|
71
89
|
const seed = string.random(size);
|
|
@@ -76,6 +94,8 @@ export class VerificationToken {
|
|
|
76
94
|
/**
|
|
77
95
|
* Compute the value property using the given secret. You can
|
|
78
96
|
* get secret via the static "createTransientToken" method.
|
|
97
|
+
*
|
|
98
|
+
* @param secret - The secret value to compute the public token value from
|
|
79
99
|
*/
|
|
80
100
|
computeValue(secret) {
|
|
81
101
|
this.value = new Secret(`${base64.urlEncode(String(this.identifier))}.${base64.urlEncode(secret.release())}`);
|
|
@@ -90,6 +110,8 @@ export class VerificationToken {
|
|
|
90
110
|
}
|
|
91
111
|
/**
|
|
92
112
|
* Verifies the value of a token against the pre-defined hash
|
|
113
|
+
*
|
|
114
|
+
* @param secret - The secret to verify against the stored hash
|
|
93
115
|
*/
|
|
94
116
|
verify(secret) {
|
|
95
117
|
const newHash = createHash('sha256').update(secret.release()).digest('hex');
|
|
@@ -1,20 +1,40 @@
|
|
|
1
|
-
import { Ignitor } from './main.
|
|
2
|
-
import type { ApplicationService } from '../types.
|
|
1
|
+
import { type Ignitor } from './main.ts';
|
|
2
|
+
import type { ApplicationService } from '../types.ts';
|
|
3
3
|
/**
|
|
4
4
|
* The Ace process is used to start the application in the
|
|
5
|
-
* console environment.
|
|
5
|
+
* console environment. It manages the Ace kernel lifecycle
|
|
6
|
+
* and command execution.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const ignitor = new Ignitor()
|
|
10
|
+
* const aceProcess = new AceProcess(ignitor)
|
|
11
|
+
*
|
|
12
|
+
* await aceProcess
|
|
13
|
+
* .configure((app) => {
|
|
14
|
+
* // Configure ace kernel
|
|
15
|
+
* })
|
|
16
|
+
* .handle(['make:controller', 'UserController'])
|
|
6
17
|
*/
|
|
7
18
|
export declare class AceProcess {
|
|
8
19
|
#private;
|
|
20
|
+
/**
|
|
21
|
+
* Creates a new Ace process instance
|
|
22
|
+
*
|
|
23
|
+
* @param ignitor - The ignitor instance used to create and manage the app
|
|
24
|
+
*/
|
|
9
25
|
constructor(ignitor: Ignitor);
|
|
10
26
|
/**
|
|
11
27
|
* Register a callback that can be used to configure the ace
|
|
12
28
|
* kernel before the handle method is called
|
|
29
|
+
*
|
|
30
|
+
* @param callback - Configuration callback function
|
|
13
31
|
*/
|
|
14
32
|
configure(callback: (app: ApplicationService) => Promise<void> | void): this;
|
|
15
33
|
/**
|
|
16
34
|
* Handles the command line arguments and executes
|
|
17
35
|
* the matching ace commands
|
|
36
|
+
*
|
|
37
|
+
* @param argv - Command line arguments array
|
|
18
38
|
*/
|
|
19
39
|
handle(argv: string[]): Promise<void>;
|
|
20
40
|
}
|
package/build/src/ignitor/ace.js
CHANGED
|
@@ -8,7 +8,18 @@
|
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
10
10
|
* The Ace process is used to start the application in the
|
|
11
|
-
* console environment.
|
|
11
|
+
* console environment. It manages the Ace kernel lifecycle
|
|
12
|
+
* and command execution.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const ignitor = new Ignitor()
|
|
16
|
+
* const aceProcess = new AceProcess(ignitor)
|
|
17
|
+
*
|
|
18
|
+
* await aceProcess
|
|
19
|
+
* .configure((app) => {
|
|
20
|
+
* // Configure ace kernel
|
|
21
|
+
* })
|
|
22
|
+
* .handle(['make:controller', 'UserController'])
|
|
12
23
|
*/
|
|
13
24
|
export class AceProcess {
|
|
14
25
|
/**
|
|
@@ -20,12 +31,19 @@ export class AceProcess {
|
|
|
20
31
|
* handle method is called
|
|
21
32
|
*/
|
|
22
33
|
#configureCallback = () => { };
|
|
34
|
+
/**
|
|
35
|
+
* Creates a new Ace process instance
|
|
36
|
+
*
|
|
37
|
+
* @param ignitor - The ignitor instance used to create and manage the app
|
|
38
|
+
*/
|
|
23
39
|
constructor(ignitor) {
|
|
24
40
|
this.#ignitor = ignitor;
|
|
25
41
|
}
|
|
26
42
|
/**
|
|
27
43
|
* Register a callback that can be used to configure the ace
|
|
28
44
|
* kernel before the handle method is called
|
|
45
|
+
*
|
|
46
|
+
* @param callback - Configuration callback function
|
|
29
47
|
*/
|
|
30
48
|
configure(callback) {
|
|
31
49
|
this.#configureCallback = callback;
|
|
@@ -34,6 +52,8 @@ export class AceProcess {
|
|
|
34
52
|
/**
|
|
35
53
|
* Handles the command line arguments and executes
|
|
36
54
|
* the matching ace commands
|
|
55
|
+
*
|
|
56
|
+
* @param argv - Command line arguments array
|
|
37
57
|
*/
|
|
38
58
|
async handle(argv) {
|
|
39
59
|
const app = this.#ignitor.createApp('console');
|
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
import type { Server as NodeHttpsServer } from 'node:https';
|
|
2
|
-
import { IncomingMessage, ServerResponse, Server as NodeHttpServer } from 'node:http';
|
|
3
|
-
import { Ignitor } from './main.
|
|
2
|
+
import { type IncomingMessage, type ServerResponse, type Server as NodeHttpServer } from 'node:http';
|
|
3
|
+
import { type Ignitor } from './main.ts';
|
|
4
4
|
/**
|
|
5
5
|
* The HTTP server process is used to start the application in the
|
|
6
|
-
* web environment.
|
|
6
|
+
* web environment. It creates and manages the Node.js HTTP server
|
|
7
|
+
* instance, handling lifecycle events and monitoring.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const ignitor = new Ignitor()
|
|
11
|
+
* const httpProcess = new HttpServerProcess(ignitor)
|
|
12
|
+
* await httpProcess.start()
|
|
7
13
|
*/
|
|
8
14
|
export declare class HttpServerProcess {
|
|
9
15
|
#private;
|
|
16
|
+
/**
|
|
17
|
+
* Creates a new HTTP server process instance
|
|
18
|
+
*
|
|
19
|
+
* @param ignitor - The ignitor instance used to create and manage the app
|
|
20
|
+
*/
|
|
10
21
|
constructor(ignitor: Ignitor);
|
|
11
22
|
/**
|
|
12
23
|
* Start the HTTP server by wiring up the application
|
|
24
|
+
*
|
|
25
|
+
* @param serverCallback - Optional callback to create custom HTTP server instance
|
|
13
26
|
*/
|
|
14
27
|
start(serverCallback?: (handler: (req: IncomingMessage, res: ServerResponse) => any) => NodeHttpsServer | NodeHttpServer): Promise<void>;
|
|
15
28
|
}
|
|
@@ -6,17 +6,28 @@
|
|
|
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 { createServer } from 'node:http';
|
|
10
|
-
import debug from
|
|
9
|
+
import { createServer, } from 'node:http';
|
|
10
|
+
import debug from "../debug.js";
|
|
11
11
|
/**
|
|
12
12
|
* The HTTP server process is used to start the application in the
|
|
13
|
-
* web environment.
|
|
13
|
+
* web environment. It creates and manages the Node.js HTTP server
|
|
14
|
+
* instance, handling lifecycle events and monitoring.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* const ignitor = new Ignitor()
|
|
18
|
+
* const httpProcess = new HttpServerProcess(ignitor)
|
|
19
|
+
* await httpProcess.start()
|
|
14
20
|
*/
|
|
15
21
|
export class HttpServerProcess {
|
|
16
22
|
/**
|
|
17
23
|
* Ignitor reference
|
|
18
24
|
*/
|
|
19
25
|
#ignitor;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a new HTTP server process instance
|
|
28
|
+
*
|
|
29
|
+
* @param ignitor - The ignitor instance used to create and manage the app
|
|
30
|
+
*/
|
|
20
31
|
constructor(ignitor) {
|
|
21
32
|
this.#ignitor = ignitor;
|
|
22
33
|
}
|
|
@@ -89,6 +100,8 @@ export class HttpServerProcess {
|
|
|
89
100
|
}
|
|
90
101
|
/**
|
|
91
102
|
* Start the HTTP server by wiring up the application
|
|
103
|
+
*
|
|
104
|
+
* @param serverCallback - Optional callback to create custom HTTP server instance
|
|
92
105
|
*/
|
|
93
106
|
async start(serverCallback) {
|
|
94
107
|
const startTime = process.hrtime();
|
|
@@ -1,14 +1,33 @@
|
|
|
1
|
-
import { AceProcess } from './ace.
|
|
2
|
-
import { TestRunnerProcess } from './test.
|
|
3
|
-
import { HttpServerProcess } from './http.
|
|
4
|
-
import type { AppEnvironments } from '../../types/app.
|
|
5
|
-
import type { ApplicationService, IgnitorOptions } from '../types.
|
|
1
|
+
import { AceProcess } from './ace.ts';
|
|
2
|
+
import { TestRunnerProcess } from './test.ts';
|
|
3
|
+
import { HttpServerProcess } from './http.ts';
|
|
4
|
+
import type { AppEnvironments } from '../../types/app.ts';
|
|
5
|
+
import type { ApplicationService, IgnitorOptions } from '../types.ts';
|
|
6
6
|
/**
|
|
7
7
|
* Ignitor is used to instantiate an AdonisJS application in different
|
|
8
|
-
* known environments.
|
|
8
|
+
* known environments. It serves as the main entry point for creating
|
|
9
|
+
* and managing application processes.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const ignitor = new Ignitor(new URL(import.meta.url))
|
|
13
|
+
*
|
|
14
|
+
* // For HTTP server
|
|
15
|
+
* await ignitor.httpServer().start()
|
|
16
|
+
*
|
|
17
|
+
* // For CLI commands
|
|
18
|
+
* await ignitor.ace().handle(process.argv.slice(2))
|
|
19
|
+
*
|
|
20
|
+
* // For tests
|
|
21
|
+
* await ignitor.testRunner().run(() => {})
|
|
9
22
|
*/
|
|
10
23
|
export declare class Ignitor {
|
|
11
24
|
#private;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a new Ignitor instance
|
|
27
|
+
*
|
|
28
|
+
* @param appRoot - The root URL of the application
|
|
29
|
+
* @param options - Configuration options for the ignitor
|
|
30
|
+
*/
|
|
12
31
|
constructor(appRoot: URL, options?: IgnitorOptions);
|
|
13
32
|
/**
|
|
14
33
|
* Get access to the application instance created
|
|
@@ -18,10 +37,14 @@ export declare class Ignitor {
|
|
|
18
37
|
getApp(): ApplicationService | undefined;
|
|
19
38
|
/**
|
|
20
39
|
* Create an instance of AdonisJS application
|
|
40
|
+
*
|
|
41
|
+
* @param environment - The environment in which to create the app (web, console, test, repl)
|
|
21
42
|
*/
|
|
22
43
|
createApp(environment: AppEnvironments): ApplicationService;
|
|
23
44
|
/**
|
|
24
45
|
* Tap to access the application class instance.
|
|
46
|
+
*
|
|
47
|
+
* @param callback - Callback function to execute when app is created
|
|
25
48
|
*/
|
|
26
49
|
tap(callback: (app: ApplicationService) => void): this;
|
|
27
50
|
/**
|
|
@@ -6,15 +6,28 @@
|
|
|
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 debug from
|
|
10
|
-
import { AceProcess } from
|
|
11
|
-
import { TestRunnerProcess } from
|
|
12
|
-
import { HttpServerProcess } from
|
|
13
|
-
import { setApp } from
|
|
14
|
-
import { Application } from
|
|
9
|
+
import debug from "../debug.js";
|
|
10
|
+
import { AceProcess } from "./ace.js";
|
|
11
|
+
import { TestRunnerProcess } from "./test.js";
|
|
12
|
+
import { HttpServerProcess } from "./http.js";
|
|
13
|
+
import { setApp } from "../../services/app.js";
|
|
14
|
+
import { Application } from "../../modules/app.js";
|
|
15
15
|
/**
|
|
16
16
|
* Ignitor is used to instantiate an AdonisJS application in different
|
|
17
|
-
* known environments.
|
|
17
|
+
* known environments. It serves as the main entry point for creating
|
|
18
|
+
* and managing application processes.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* const ignitor = new Ignitor(new URL(import.meta.url))
|
|
22
|
+
*
|
|
23
|
+
* // For HTTP server
|
|
24
|
+
* await ignitor.httpServer().start()
|
|
25
|
+
*
|
|
26
|
+
* // For CLI commands
|
|
27
|
+
* await ignitor.ace().handle(process.argv.slice(2))
|
|
28
|
+
*
|
|
29
|
+
* // For tests
|
|
30
|
+
* await ignitor.testRunner().run(() => {})
|
|
18
31
|
*/
|
|
19
32
|
export class Ignitor {
|
|
20
33
|
/**
|
|
@@ -38,6 +51,12 @@ export class Ignitor {
|
|
|
38
51
|
* Reference to the created application
|
|
39
52
|
*/
|
|
40
53
|
#tapCallbacks = new Set();
|
|
54
|
+
/**
|
|
55
|
+
* Creates a new Ignitor instance
|
|
56
|
+
*
|
|
57
|
+
* @param appRoot - The root URL of the application
|
|
58
|
+
* @param options - Configuration options for the ignitor
|
|
59
|
+
*/
|
|
41
60
|
constructor(appRoot, options = {}) {
|
|
42
61
|
this.#appRoot = appRoot;
|
|
43
62
|
this.#options = options;
|
|
@@ -58,6 +77,8 @@ export class Ignitor {
|
|
|
58
77
|
}
|
|
59
78
|
/**
|
|
60
79
|
* Create an instance of AdonisJS application
|
|
80
|
+
*
|
|
81
|
+
* @param environment - The environment in which to create the app (web, console, test, repl)
|
|
61
82
|
*/
|
|
62
83
|
createApp(environment) {
|
|
63
84
|
debug('creating application instance');
|
|
@@ -68,6 +89,8 @@ export class Ignitor {
|
|
|
68
89
|
}
|
|
69
90
|
/**
|
|
70
91
|
* Tap to access the application class instance.
|
|
92
|
+
*
|
|
93
|
+
* @param callback - Callback function to execute when app is created
|
|
71
94
|
*/
|
|
72
95
|
tap(callback) {
|
|
73
96
|
this.#tapCallbacks.add(callback);
|
|
@@ -1,18 +1,41 @@
|
|
|
1
|
-
import { Ignitor } from './main.
|
|
2
|
-
import type { ApplicationService } from '../types.
|
|
1
|
+
import { type Ignitor } from './main.ts';
|
|
2
|
+
import type { ApplicationService } from '../types.ts';
|
|
3
3
|
/**
|
|
4
|
-
* The Test runner process is used to start the tests runner process
|
|
4
|
+
* The Test runner process is used to start the tests runner process.
|
|
5
|
+
* It provides lifecycle hooks for configuring the test environment
|
|
6
|
+
* and running tests within the AdonisJS application context.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const ignitor = new Ignitor()
|
|
10
|
+
* const testProcess = new TestRunnerProcess(ignitor)
|
|
11
|
+
*
|
|
12
|
+
* await testProcess
|
|
13
|
+
* .configure((app) => {
|
|
14
|
+
* // Configure test environment
|
|
15
|
+
* })
|
|
16
|
+
* .run(async (app) => {
|
|
17
|
+
* // Run your tests
|
|
18
|
+
* })
|
|
5
19
|
*/
|
|
6
20
|
export declare class TestRunnerProcess {
|
|
7
21
|
#private;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a new test runner process instance
|
|
24
|
+
*
|
|
25
|
+
* @param ignitor - The ignitor instance used to create and manage the app
|
|
26
|
+
*/
|
|
8
27
|
constructor(ignitor: Ignitor);
|
|
9
28
|
/**
|
|
10
29
|
* Register a callback that runs after booting the AdonisJS app
|
|
11
30
|
* and just before the provider's ready hook
|
|
31
|
+
*
|
|
32
|
+
* @param callback - Configuration callback function
|
|
12
33
|
*/
|
|
13
34
|
configure(callback: (app: ApplicationService) => Promise<void> | void): this;
|
|
14
35
|
/**
|
|
15
36
|
* Runs a callback after starting the app
|
|
37
|
+
*
|
|
38
|
+
* @param callback - Test execution callback function
|
|
16
39
|
*/
|
|
17
40
|
run(callback: (app: ApplicationService) => Promise<void> | void): Promise<void>;
|
|
18
41
|
}
|
|
@@ -7,7 +7,21 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
10
|
-
* The Test runner process is used to start the tests runner process
|
|
10
|
+
* The Test runner process is used to start the tests runner process.
|
|
11
|
+
* It provides lifecycle hooks for configuring the test environment
|
|
12
|
+
* and running tests within the AdonisJS application context.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const ignitor = new Ignitor()
|
|
16
|
+
* const testProcess = new TestRunnerProcess(ignitor)
|
|
17
|
+
*
|
|
18
|
+
* await testProcess
|
|
19
|
+
* .configure((app) => {
|
|
20
|
+
* // Configure test environment
|
|
21
|
+
* })
|
|
22
|
+
* .run(async (app) => {
|
|
23
|
+
* // Run your tests
|
|
24
|
+
* })
|
|
11
25
|
*/
|
|
12
26
|
export class TestRunnerProcess {
|
|
13
27
|
/**
|
|
@@ -19,12 +33,19 @@ export class TestRunnerProcess {
|
|
|
19
33
|
* runs at the time of starting the app.
|
|
20
34
|
*/
|
|
21
35
|
#configureCallback = () => { };
|
|
36
|
+
/**
|
|
37
|
+
* Creates a new test runner process instance
|
|
38
|
+
*
|
|
39
|
+
* @param ignitor - The ignitor instance used to create and manage the app
|
|
40
|
+
*/
|
|
22
41
|
constructor(ignitor) {
|
|
23
42
|
this.#ignitor = ignitor;
|
|
24
43
|
}
|
|
25
44
|
/**
|
|
26
45
|
* Register a callback that runs after booting the AdonisJS app
|
|
27
46
|
* and just before the provider's ready hook
|
|
47
|
+
*
|
|
48
|
+
* @param callback - Configuration callback function
|
|
28
49
|
*/
|
|
29
50
|
configure(callback) {
|
|
30
51
|
this.#configureCallback = callback;
|
|
@@ -32,6 +53,8 @@ export class TestRunnerProcess {
|
|
|
32
53
|
}
|
|
33
54
|
/**
|
|
34
55
|
* Runs a callback after starting the app
|
|
56
|
+
*
|
|
57
|
+
* @param callback - Test execution callback function
|
|
35
58
|
*/
|
|
36
59
|
async run(callback) {
|
|
37
60
|
const app = this.#ignitor.createApp('test');
|
|
@@ -1,16 +1,32 @@
|
|
|
1
|
-
import type { TestUtils } from './main.
|
|
1
|
+
import type { TestUtils } from './main.ts';
|
|
2
2
|
import type { Server as NodeHttpsServer } from 'node:https';
|
|
3
|
-
import { IncomingMessage, ServerResponse, Server as NodeHttpServer } from 'node:http';
|
|
3
|
+
import { type IncomingMessage, type ServerResponse, type Server as NodeHttpServer } from 'node:http';
|
|
4
4
|
/**
|
|
5
5
|
* Http server utils are used to start the AdonisJS HTTP server
|
|
6
|
-
* during testing
|
|
6
|
+
* during testing. It provides methods to start and stop the server
|
|
7
|
+
* for integration testing.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const testUtils = new TestUtils(app)
|
|
11
|
+
* const httpUtils = testUtils.httpServer()
|
|
12
|
+
*
|
|
13
|
+
* const closeServer = await httpUtils.start()
|
|
14
|
+
* // Make HTTP requests to test endpoints
|
|
15
|
+
* await closeServer() // Clean up
|
|
7
16
|
*/
|
|
8
17
|
export declare class HttpServerUtils {
|
|
9
18
|
#private;
|
|
19
|
+
/**
|
|
20
|
+
* Creates a new HttpServerUtils instance
|
|
21
|
+
*
|
|
22
|
+
* @param utils - The test utils instance
|
|
23
|
+
*/
|
|
10
24
|
constructor(utils: TestUtils);
|
|
11
25
|
/**
|
|
12
26
|
* Testing hook to start the HTTP server to listen for new request.
|
|
13
27
|
* The return value is a function to close the HTTP server.
|
|
28
|
+
*
|
|
29
|
+
* @param serverCallback - Optional callback to create custom HTTP server instance
|
|
14
30
|
*/
|
|
15
31
|
start(serverCallback?: (handler: (req: IncomingMessage, res: ServerResponse) => any) => NodeHttpsServer | NodeHttpServer): Promise<() => Promise<void>>;
|
|
16
32
|
}
|
|
@@ -6,19 +6,38 @@
|
|
|
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 debug from
|
|
10
|
-
import { createServer } from 'node:http';
|
|
9
|
+
import debug from "../debug.js";
|
|
10
|
+
import { createServer, } from 'node:http';
|
|
11
11
|
/**
|
|
12
12
|
* Http server utils are used to start the AdonisJS HTTP server
|
|
13
|
-
* during testing
|
|
13
|
+
* during testing. It provides methods to start and stop the server
|
|
14
|
+
* for integration testing.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* const testUtils = new TestUtils(app)
|
|
18
|
+
* const httpUtils = testUtils.httpServer()
|
|
19
|
+
*
|
|
20
|
+
* const closeServer = await httpUtils.start()
|
|
21
|
+
* // Make HTTP requests to test endpoints
|
|
22
|
+
* await closeServer() // Clean up
|
|
14
23
|
*/
|
|
15
24
|
export class HttpServerUtils {
|
|
25
|
+
/**
|
|
26
|
+
* Reference to the test utils instance
|
|
27
|
+
*/
|
|
16
28
|
#utils;
|
|
29
|
+
/**
|
|
30
|
+
* Creates a new HttpServerUtils instance
|
|
31
|
+
*
|
|
32
|
+
* @param utils - The test utils instance
|
|
33
|
+
*/
|
|
17
34
|
constructor(utils) {
|
|
18
35
|
this.#utils = utils;
|
|
19
36
|
}
|
|
20
37
|
/**
|
|
21
38
|
* Starts the http server a given host and port
|
|
39
|
+
*
|
|
40
|
+
* @param nodeHttpServer - The Node.js HTTP server instance
|
|
22
41
|
*/
|
|
23
42
|
#listen(nodeHttpServer) {
|
|
24
43
|
return new Promise((resolve, reject) => {
|
|
@@ -37,6 +56,8 @@ export class HttpServerUtils {
|
|
|
37
56
|
/**
|
|
38
57
|
* Testing hook to start the HTTP server to listen for new request.
|
|
39
58
|
* The return value is a function to close the HTTP server.
|
|
59
|
+
*
|
|
60
|
+
* @param serverCallback - Optional callback to create custom HTTP server instance
|
|
40
61
|
*/
|
|
41
62
|
async start(serverCallback) {
|
|
42
63
|
const createHTTPServer = serverCallback || createServer;
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import Macroable from '@poppinss/macroable';
|
|
2
2
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
3
|
-
import { HttpServerUtils } from './http.
|
|
4
|
-
import type { ApplicationService } from '../types.
|
|
5
|
-
import { CookieClient, type HttpContext } from '../../modules/http/main.
|
|
3
|
+
import { HttpServerUtils } from './http.ts';
|
|
4
|
+
import type { ApplicationService } from '../types.ts';
|
|
5
|
+
import { CookieClient, type HttpContext } from '../../modules/http/main.ts';
|
|
6
6
|
/**
|
|
7
7
|
* Test utils has a collection of helper methods to make testing
|
|
8
|
-
* experience great for AdonisJS applications
|
|
8
|
+
* experience great for AdonisJS applications. It provides utilities
|
|
9
|
+
* for HTTP testing, context creation, and cookie handling.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const testUtils = new TestUtils(app)
|
|
13
|
+
* await testUtils.boot()
|
|
14
|
+
*
|
|
15
|
+
* const ctx = await testUtils.createHttpContext()
|
|
16
|
+
* const httpUtils = testUtils.httpServer()
|
|
9
17
|
*/
|
|
10
18
|
export declare class TestUtils extends Macroable {
|
|
11
19
|
#private;
|
|
@@ -14,7 +22,15 @@ export declare class TestUtils extends Macroable {
|
|
|
14
22
|
* Check if utils have been booted
|
|
15
23
|
*/
|
|
16
24
|
get isBooted(): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Cookie client instance for handling cookies in tests
|
|
27
|
+
*/
|
|
17
28
|
cookies: CookieClient;
|
|
29
|
+
/**
|
|
30
|
+
* Creates a new TestUtils instance
|
|
31
|
+
*
|
|
32
|
+
* @param app - The application service instance
|
|
33
|
+
*/
|
|
18
34
|
constructor(app: ApplicationService);
|
|
19
35
|
/**
|
|
20
36
|
* Boot test utils. It requires the app to be booted
|
|
@@ -28,6 +44,8 @@ export declare class TestUtils extends Macroable {
|
|
|
28
44
|
httpServer(): HttpServerUtils;
|
|
29
45
|
/**
|
|
30
46
|
* Create an instance of HTTP context for testing
|
|
47
|
+
*
|
|
48
|
+
* @param options - Options for creating HTTP context with custom req/res objects
|
|
31
49
|
*/
|
|
32
50
|
createHttpContext(options?: {
|
|
33
51
|
req?: IncomingMessage;
|