@adonisjs/assembler 8.0.0-next.2 → 8.0.0-next.20
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 +88 -84
- package/build/chunk-4452KFDQ.js +465 -0
- package/build/chunk-JFBQ4OEM.js +434 -0
- package/build/chunk-NAASGAFO.js +478 -0
- package/build/chunk-TIKQQRMX.js +116 -0
- package/build/index.d.ts +3 -0
- package/build/index.js +800 -447
- package/build/src/bundler.d.ts +44 -3
- package/build/src/code_scanners/routes_scanner/main.d.ts +119 -0
- package/build/src/code_scanners/routes_scanner/main.js +8 -0
- package/build/src/code_scanners/routes_scanner/validator_extractor.d.ts +26 -0
- package/build/src/code_transformer/main.d.ts +44 -43
- package/build/src/code_transformer/main.js +123 -101
- package/build/src/code_transformer/rc_file_transformer.d.ts +56 -4
- package/build/src/debug.d.ts +12 -0
- package/build/src/dev_server.d.ts +92 -17
- package/build/src/file_buffer.d.ts +87 -0
- package/build/src/file_system.d.ts +46 -8
- package/build/src/helpers.d.ts +115 -0
- package/build/src/helpers.js +16 -0
- package/build/src/index_generator/main.d.ts +68 -0
- package/build/src/index_generator/main.js +7 -0
- package/build/src/index_generator/source.d.ts +60 -0
- package/build/src/paths_resolver.d.ts +41 -0
- package/build/src/shortcuts_manager.d.ts +43 -28
- package/build/src/test_runner.d.ts +57 -12
- package/build/src/types/code_scanners.d.ts +226 -0
- package/build/src/types/code_transformer.d.ts +61 -19
- package/build/src/types/common.d.ts +270 -51
- package/build/src/types/hooks.d.ts +235 -22
- package/build/src/types/main.d.ts +15 -1
- package/build/src/utils.d.ts +99 -15
- package/build/src/virtual_file_system.d.ts +112 -0
- package/package.json +33 -20
- package/build/chunk-RR4HCA4M.js +0 -7
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a controller that has been scanned and analyzed by the routes scanner.
|
|
3
|
+
* Contains metadata about the controller class and the specific method being called.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* const controller: ScannedController = {
|
|
7
|
+
* name: 'UsersController',
|
|
8
|
+
* path: '/project/app/controllers/users_controller.ts',
|
|
9
|
+
* method: 'index',
|
|
10
|
+
* import: {
|
|
11
|
+
* type: 'default',
|
|
12
|
+
* specifier: '#controllers/users_controller',
|
|
13
|
+
* value: 'UsersController'
|
|
14
|
+
* }
|
|
15
|
+
* }
|
|
16
|
+
*/
|
|
17
|
+
export type ScannedController = {
|
|
18
|
+
/** The name of the controller class */
|
|
19
|
+
name: string;
|
|
20
|
+
/** Absolute file path to the controller */
|
|
21
|
+
path: string;
|
|
22
|
+
/** The method name being called on the controller */
|
|
23
|
+
method: string;
|
|
24
|
+
/** Import information for the controller */
|
|
25
|
+
import: {
|
|
26
|
+
/** Import type (always 'default' for controllers) */
|
|
27
|
+
type: 'default';
|
|
28
|
+
/** Import specifier used to import the controller */
|
|
29
|
+
specifier: string;
|
|
30
|
+
/** The imported value name */
|
|
31
|
+
value: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Represents a validator that has been extracted from controller methods.
|
|
36
|
+
* Contains information about how the validator is imported and used.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* const validator: ScannedValidator = {
|
|
40
|
+
* name: 'createUserValidator',
|
|
41
|
+
* import: {
|
|
42
|
+
* type: 'named',
|
|
43
|
+
* specifier: '#validators/user_validators',
|
|
44
|
+
* value: 'createUserValidator'
|
|
45
|
+
* }
|
|
46
|
+
* }
|
|
47
|
+
*/
|
|
48
|
+
export type ScannedValidator = {
|
|
49
|
+
/** The name/identifier of the validator */
|
|
50
|
+
name: string;
|
|
51
|
+
/** Import information for the validator */
|
|
52
|
+
import: {
|
|
53
|
+
/** The type of import (namespace, default, or named) */
|
|
54
|
+
type: 'namespace' | 'default' | 'named';
|
|
55
|
+
/** The module specifier being imported from */
|
|
56
|
+
specifier: string;
|
|
57
|
+
/** The imported value name */
|
|
58
|
+
value: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Output of a scanned route containing all extracted metadata including
|
|
63
|
+
* controller information, validators, request/response types, and route patterns.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* const scannedRoute: ScannedRoute = {
|
|
67
|
+
* name: 'users.store',
|
|
68
|
+
* methods: ['POST'],
|
|
69
|
+
* domain: 'root',
|
|
70
|
+
* pattern: '/users',
|
|
71
|
+
* tokens: [{ val: '/users', old: '/users', type: 0, end: '' }],
|
|
72
|
+
* request: {
|
|
73
|
+
* type: 'Infer<typeof createUserValidator>',
|
|
74
|
+
* imports: ['import { Infer } from "@vinejs/vine/types"']
|
|
75
|
+
* },
|
|
76
|
+
* response: {
|
|
77
|
+
* type: 'ReturnType<UsersController["store"]>',
|
|
78
|
+
* imports: []
|
|
79
|
+
* },
|
|
80
|
+
* validators: [{
|
|
81
|
+
* name: 'createUserValidator',
|
|
82
|
+
* import: { type: 'named', specifier: '#validators/user', value: 'createUserValidator' }
|
|
83
|
+
* }],
|
|
84
|
+
* controller: {
|
|
85
|
+
* name: 'UsersController',
|
|
86
|
+
* method: 'store',
|
|
87
|
+
* path: '/app/controllers/users_controller.ts',
|
|
88
|
+
* import: { type: 'default', specifier: '#controllers/users_controller', value: 'UsersController' }
|
|
89
|
+
* }
|
|
90
|
+
* }
|
|
91
|
+
*/
|
|
92
|
+
export type ScannedRoute = {
|
|
93
|
+
/**
|
|
94
|
+
* A unique name for the route provided by AdonisJS http-server.
|
|
95
|
+
* May be duplicate across different domains.
|
|
96
|
+
*/
|
|
97
|
+
name: string;
|
|
98
|
+
/**
|
|
99
|
+
* HTTP methods for which the route is defined (GET, POST, PUT, etc.)
|
|
100
|
+
*/
|
|
101
|
+
methods: string[];
|
|
102
|
+
/**
|
|
103
|
+
* The domain on which the route is registered (typically 'root')
|
|
104
|
+
*/
|
|
105
|
+
domain: string;
|
|
106
|
+
/**
|
|
107
|
+
* The route pattern with parameter placeholders (e.g., '/users/:id')
|
|
108
|
+
*/
|
|
109
|
+
pattern: string;
|
|
110
|
+
/**
|
|
111
|
+
* Route tokens that can be used for constructing URIs without parsing the pattern.
|
|
112
|
+
* Contains information about static and dynamic segments.
|
|
113
|
+
*/
|
|
114
|
+
tokens: {
|
|
115
|
+
val: string;
|
|
116
|
+
old: string;
|
|
117
|
+
type: 0 | 1 | 2 | 3;
|
|
118
|
+
end: string;
|
|
119
|
+
}[];
|
|
120
|
+
/**
|
|
121
|
+
* Inferred request data type accepted by the route.
|
|
122
|
+
* Generated when the route uses a controller with validators.
|
|
123
|
+
*/
|
|
124
|
+
request?: {
|
|
125
|
+
/** TypeScript type definition for the request data */
|
|
126
|
+
type: string;
|
|
127
|
+
/** Import statements needed for the type definition */
|
|
128
|
+
imports: string[];
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Inferred response type returned by the route.
|
|
132
|
+
* Generated when the route uses a controller method.
|
|
133
|
+
*/
|
|
134
|
+
response?: {
|
|
135
|
+
/** TypeScript type definition for the response data */
|
|
136
|
+
type: string;
|
|
137
|
+
/** Import statements needed for the type definition */
|
|
138
|
+
imports: string[];
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* Extracted validator information from the controller method.
|
|
142
|
+
* Only present when using controller-based routes with validation.
|
|
143
|
+
*/
|
|
144
|
+
validators?: ScannedValidator[];
|
|
145
|
+
/**
|
|
146
|
+
* Extracted controller information including class and method details.
|
|
147
|
+
* Only present when using controller-based routes.
|
|
148
|
+
*/
|
|
149
|
+
controller?: ScannedController;
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* The route data structure accepted by the routes scanner when initiating
|
|
153
|
+
* the scanning process. This represents the raw route definition before analysis.
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* const routeItem: RoutesListItem = {
|
|
157
|
+
* name: 'users.store',
|
|
158
|
+
* pattern: '/users',
|
|
159
|
+
* domain: 'root',
|
|
160
|
+
* methods: ['POST'],
|
|
161
|
+
* controllerReference: {
|
|
162
|
+
* importExpression: "() => import('#controllers/users_controller')",
|
|
163
|
+
* method: 'store'
|
|
164
|
+
* },
|
|
165
|
+
* tokens: [{ val: '/users', old: '/users', type: 0, end: '' }]
|
|
166
|
+
* }
|
|
167
|
+
*/
|
|
168
|
+
export type RoutesListItem = {
|
|
169
|
+
/** Optional unique name for the route */
|
|
170
|
+
name?: string;
|
|
171
|
+
/** Route pattern with parameter placeholders */
|
|
172
|
+
pattern: string;
|
|
173
|
+
/** Domain on which the route is registered */
|
|
174
|
+
domain: string;
|
|
175
|
+
/** HTTP methods accepted by this route */
|
|
176
|
+
methods: string[];
|
|
177
|
+
handler?: {
|
|
178
|
+
method: string;
|
|
179
|
+
importExpression: string | null;
|
|
180
|
+
};
|
|
181
|
+
/** Parsed route tokens for URI construction */
|
|
182
|
+
tokens: {
|
|
183
|
+
val: string;
|
|
184
|
+
old: string;
|
|
185
|
+
type: 0 | 1 | 2 | 3;
|
|
186
|
+
end: string;
|
|
187
|
+
}[];
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* Configuration rules accepted by the routes scanner to customize
|
|
191
|
+
* the scanning behavior and override type inference.
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* const rules: RoutesScannerRules = {
|
|
195
|
+
* skip: ['admin.dashboard', 'health.check'],
|
|
196
|
+
* response: {
|
|
197
|
+
* 'users.index': {
|
|
198
|
+
* type: 'PaginatedResponse<User[]>',
|
|
199
|
+
* imports: ['import { User } from "#models/user"']
|
|
200
|
+
* }
|
|
201
|
+
* },
|
|
202
|
+
* request: {
|
|
203
|
+
* 'users.store': {
|
|
204
|
+
* type: 'CreateUserRequest',
|
|
205
|
+
* imports: ['import { CreateUserRequest } from "#types/requests"']
|
|
206
|
+
* }
|
|
207
|
+
* }
|
|
208
|
+
* }
|
|
209
|
+
*/
|
|
210
|
+
export type RoutesScannerRules = {
|
|
211
|
+
/**
|
|
212
|
+
* An array of route names or controller+method paths to skip from processing.
|
|
213
|
+
* Useful for excluding routes that don't need type generation.
|
|
214
|
+
*/
|
|
215
|
+
skip: string[];
|
|
216
|
+
/**
|
|
217
|
+
* Define custom response types for specific routes by their name
|
|
218
|
+
* or controller+method path. Overrides automatic type inference.
|
|
219
|
+
*/
|
|
220
|
+
response: Record<string, ScannedRoute['response']>;
|
|
221
|
+
/**
|
|
222
|
+
* Define custom request data types for specific routes by their name
|
|
223
|
+
* or controller+method path. Overrides automatic type inference.
|
|
224
|
+
*/
|
|
225
|
+
request: Record<string, ScannedRoute['response']>;
|
|
226
|
+
};
|
|
@@ -1,61 +1,103 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Entry to add a middleware to a given middleware stack
|
|
3
|
-
*
|
|
2
|
+
* Entry to add a middleware to a given middleware stack via the CodeTransformer.
|
|
3
|
+
* Represents middleware configuration for server, router, or named middleware stacks.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* const corsMiddleware: MiddlewareNode = {
|
|
7
|
+
* path: '@adonisjs/cors/cors_middleware',
|
|
8
|
+
* position: 'before'
|
|
9
|
+
* }
|
|
10
|
+
*
|
|
11
|
+
* const namedMiddleware: MiddlewareNode = {
|
|
12
|
+
* name: 'auth',
|
|
13
|
+
* path: '#middleware/auth_middleware',
|
|
14
|
+
* position: 'after'
|
|
15
|
+
* }
|
|
4
16
|
*/
|
|
5
17
|
export type MiddlewareNode = {
|
|
6
18
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
19
|
+
* Required for named middleware. The key name under which the middleware
|
|
20
|
+
* will be registered in the named middleware collection.
|
|
9
21
|
*/
|
|
10
22
|
name?: string;
|
|
11
23
|
/**
|
|
12
|
-
* The path to the middleware file
|
|
24
|
+
* The import path to the middleware file. Can be a package import,
|
|
25
|
+
* subpath import, or relative path.
|
|
13
26
|
*
|
|
14
27
|
* @example
|
|
15
|
-
*
|
|
16
|
-
*
|
|
28
|
+
* '@adonisjs/static/static_middleware'
|
|
29
|
+
* '#middlewares/silent_auth'
|
|
30
|
+
* './middleware/custom_middleware.js'
|
|
17
31
|
*/
|
|
18
32
|
path: string;
|
|
19
33
|
/**
|
|
20
|
-
* The position to add the middleware
|
|
21
|
-
*
|
|
22
|
-
* therefore will be run before all others
|
|
34
|
+
* The position to add the middleware in the stack.
|
|
35
|
+
* 'before' adds at the beginning (runs first), 'after' adds at the end (runs last).
|
|
23
36
|
*
|
|
24
37
|
* @default 'after'
|
|
25
38
|
*/
|
|
26
39
|
position?: 'before' | 'after';
|
|
27
40
|
};
|
|
28
41
|
/**
|
|
29
|
-
* Policy node to be added to the list of policies.
|
|
42
|
+
* Policy node to be added to the list of Bouncer authorization policies.
|
|
43
|
+
* Used for registering policies in the application's policy registry.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* const userPolicy: BouncerPolicyNode = {
|
|
47
|
+
* name: 'UserPolicy',
|
|
48
|
+
* path: '#policies/user_policy'
|
|
49
|
+
* }
|
|
30
50
|
*/
|
|
31
51
|
export type BouncerPolicyNode = {
|
|
32
52
|
/**
|
|
33
|
-
*
|
|
53
|
+
* The name of the policy class (should match the exported class name)
|
|
34
54
|
*/
|
|
35
55
|
name: string;
|
|
36
56
|
/**
|
|
37
|
-
*
|
|
57
|
+
* The import path to the policy file
|
|
38
58
|
*/
|
|
39
59
|
path: string;
|
|
40
60
|
};
|
|
41
61
|
/**
|
|
42
|
-
* Defines the structure of an environment variable validation
|
|
43
|
-
*
|
|
62
|
+
* Defines the structure of an environment variable validation definition.
|
|
63
|
+
* Used to add new environment variable validations to the start/env.ts file.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* const envValidation: EnvValidationNode = {
|
|
67
|
+
* leadingComment: 'Database configuration',
|
|
68
|
+
* variables: {
|
|
69
|
+
* DB_HOST: 'Env.schema.string()',
|
|
70
|
+
* DB_PORT: 'Env.schema.number.optional({ port: 5432 })',
|
|
71
|
+
* DB_PASSWORD: 'Env.schema.string.optional()'
|
|
72
|
+
* }
|
|
73
|
+
* }
|
|
44
74
|
*/
|
|
45
75
|
export type EnvValidationNode = {
|
|
46
76
|
/**
|
|
47
|
-
*
|
|
77
|
+
* Optional leading comment to write above the variable definitions.
|
|
78
|
+
* Helps group related environment variables together.
|
|
48
79
|
*/
|
|
49
80
|
leadingComment?: string;
|
|
50
81
|
/**
|
|
51
|
-
* A key-value pair of
|
|
82
|
+
* A key-value pair of environment variables and their validation schemas.
|
|
83
|
+
* The key is the environment variable name, the value is the validation code.
|
|
52
84
|
*
|
|
53
85
|
* @example
|
|
54
|
-
*
|
|
86
|
+
* {
|
|
87
|
+
* MY_VAR: 'Env.schema.string.optional()',
|
|
88
|
+
* API_KEY: 'Env.schema.string()'
|
|
89
|
+
* }
|
|
55
90
|
*/
|
|
56
91
|
variables: Record<string, string>;
|
|
57
92
|
};
|
|
58
93
|
/**
|
|
59
|
-
* The supported package managers for installing packages
|
|
94
|
+
* The supported package managers for installing packages and managing lockfiles.
|
|
95
|
+
* Each package manager has specific lockfiles and install commands.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* const packageManager: SupportedPackageManager = 'pnpm'
|
|
99
|
+
*
|
|
100
|
+
* // Used in bundler configuration
|
|
101
|
+
* const bundler = new Bundler(cwd, ts, { packageManager: 'yarn@berry' })
|
|
60
102
|
*/
|
|
61
103
|
export type SupportedPackageManager = 'npm' | 'yarn' | 'yarn@berry' | 'pnpm' | 'bun';
|