@adonisjs/core 7.0.0-next.0 → 7.0.0-next.10

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.
Files changed (96) hide show
  1. package/build/commands/add.d.ts +32 -0
  2. package/build/commands/add.js +17 -0
  3. package/build/commands/build.d.ts +22 -0
  4. package/build/commands/build.js +18 -0
  5. package/build/commands/commands.json +1 -1
  6. package/build/commands/configure.d.ts +32 -9
  7. package/build/commands/configure.js +36 -9
  8. package/build/commands/eject.d.ts +27 -2
  9. package/build/commands/eject.js +21 -2
  10. package/build/commands/env/add.d.ts +39 -2
  11. package/build/commands/env/add.js +30 -3
  12. package/build/commands/generate_key.d.ts +19 -0
  13. package/build/commands/generate_key.js +13 -0
  14. package/build/commands/inspect_rcfile.d.ts +19 -1
  15. package/build/commands/inspect_rcfile.js +19 -1
  16. package/build/commands/list/routes.d.ts +31 -9
  17. package/build/commands/list/routes.js +26 -3
  18. package/build/commands/make/command.d.ts +25 -2
  19. package/build/commands/make/command.js +22 -2
  20. package/build/commands/make/controller.d.ts +33 -0
  21. package/build/commands/make/controller.js +18 -0
  22. package/build/commands/make/event.d.ts +28 -2
  23. package/build/commands/make/event.js +25 -2
  24. package/build/commands/make/exception.d.ts +28 -2
  25. package/build/commands/make/exception.js +25 -2
  26. package/build/commands/make/listener.d.ts +36 -3
  27. package/build/commands/make/listener.js +30 -3
  28. package/build/commands/make/middleware.d.ts +23 -0
  29. package/build/commands/make/middleware.js +17 -0
  30. package/build/commands/make/preload.d.ts +30 -3
  31. package/build/commands/make/preload.js +24 -4
  32. package/build/commands/make/provider.d.ts +31 -2
  33. package/build/commands/make/provider.js +25 -3
  34. package/build/commands/make/service.d.ts +19 -0
  35. package/build/commands/make/service.js +16 -0
  36. package/build/commands/make/test.d.ts +26 -3
  37. package/build/commands/make/test.js +34 -6
  38. package/build/commands/make/transformer.d.ts +43 -0
  39. package/build/commands/make/transformer.js +65 -0
  40. package/build/commands/make/validator.d.ts +34 -3
  41. package/build/commands/make/validator.js +28 -3
  42. package/build/commands/make/view.d.ts +25 -2
  43. package/build/commands/make/view.js +22 -2
  44. package/build/commands/repl.d.ts +22 -2
  45. package/build/commands/repl.js +22 -2
  46. package/build/commands/serve.d.ts +36 -0
  47. package/build/commands/serve.js +26 -9
  48. package/build/commands/test.d.ts +66 -3
  49. package/build/commands/test.js +37 -13
  50. package/build/modules/ace/codemods.d.ts +109 -14
  51. package/build/modules/ace/codemods.js +119 -16
  52. package/build/modules/ace/commands.d.ts +0 -1
  53. package/build/modules/ace/commands.js +0 -3
  54. package/build/modules/ace/main.d.ts +30 -0
  55. package/build/modules/ace/main.js +30 -0
  56. package/build/modules/app.d.ts +17 -0
  57. package/build/modules/app.js +17 -0
  58. package/build/modules/config.d.ts +17 -0
  59. package/build/modules/config.js +17 -0
  60. package/build/modules/dumper/dumper.d.ts +5 -0
  61. package/build/modules/dumper/dumper.js +11 -1
  62. package/build/modules/dumper/main.d.ts +21 -0
  63. package/build/modules/dumper/main.js +21 -0
  64. package/build/modules/encryption.d.ts +17 -0
  65. package/build/modules/encryption.js +17 -0
  66. package/build/modules/env/main.d.ts +19 -0
  67. package/build/modules/env/main.js +19 -0
  68. package/build/modules/hash/drivers/bcrypt.d.ts +11 -0
  69. package/build/modules/hash/drivers/bcrypt.js +11 -0
  70. package/build/modules/hash/main.d.ts +18 -0
  71. package/build/modules/hash/main.js +18 -0
  72. package/build/modules/http/url_builder_client.d.ts +1 -0
  73. package/build/modules/http/url_builder_client.js +9 -0
  74. package/build/providers/app_provider.d.ts +11 -23
  75. package/build/providers/app_provider.js +41 -45
  76. package/build/providers/edge_provider.js +62 -1
  77. package/build/src/assembler_hooks/index_entities.d.ts +3 -17
  78. package/build/src/assembler_hooks/index_entities.js +31 -15
  79. package/build/src/cli_formatters/routes_list.js +23 -7
  80. package/build/src/helpers/http.d.ts +20 -0
  81. package/build/src/helpers/http.js +28 -0
  82. package/build/src/helpers/main.d.ts +1 -5
  83. package/build/src/helpers/main.js +1 -5
  84. package/build/src/helpers/string.js +24 -0
  85. package/build/src/helpers/types.d.ts +1 -0
  86. package/build/src/ignitor/http.js +18 -5
  87. package/build/src/types.d.ts +7 -0
  88. package/build/src/utils.d.ts +26 -0
  89. package/build/src/utils.js +65 -0
  90. package/build/src/vine.js +14 -6
  91. package/build/stubs/make/transformer/main.stub +18 -0
  92. package/build/types/common.d.ts +1 -0
  93. package/build/types/common.js +9 -0
  94. package/build/types/helpers.d.ts +20 -0
  95. package/build/types/http.d.ts +1 -0
  96. package/package.json +26 -23
@@ -372,4 +372,11 @@ export type IndexEntitiesConfig = {
372
372
  /** Glob patterns for matching event files */
373
373
  glob?: string[];
374
374
  };
375
+ transformers?: {
376
+ enabled?: boolean;
377
+ withSharedProps?: boolean;
378
+ source?: string;
379
+ importAlias?: string;
380
+ glob?: string[];
381
+ };
375
382
  };
@@ -1,5 +1,6 @@
1
1
  import type typescript from 'typescript';
2
2
  import type * as Assembler from '@adonisjs/assembler';
3
+ import { type RecursiveFileTree } from '@adonisjs/assembler/types';
3
4
  import { type ApplicationService } from './types.ts';
4
5
  /**
5
6
  * Imports the AdonisJS assembler package optionally. This function attempts
@@ -32,3 +33,28 @@ export declare function importAssembler(app: ApplicationService): Promise<typeof
32
33
  * }
33
34
  */
34
35
  export declare function importTypeScript(app: ApplicationService): Promise<typeof typescript | undefined>;
36
+ /**
37
+ * Outputs transformer data objects by generating TypeScript type definitions
38
+ * for all transformers in the provided file tree. This function creates
39
+ * InferData types for each transformer and organizes them in namespaces.
40
+ *
41
+ * @param transformersList - A recursive file tree containing transformer file paths
42
+ * @param buffer - The file buffer to write the generated types to
43
+ *
44
+ * @example
45
+ * const transformersList = {
46
+ * User: '#app/transformers/user_transformer',
47
+ * Auth: {
48
+ * Login: '#app/transformers/auth/login_transformer'
49
+ * }
50
+ * }
51
+ * await outputTransformerDataObjects(transformersList, buffer)
52
+ * // Generates:
53
+ * // export namespace Data {
54
+ * // export type User = InferData<UserTransformer>
55
+ * // export namespace Auth {
56
+ * // export type Login = InferData<AuthLoginTransformer>
57
+ * // }
58
+ * // }
59
+ */
60
+ export declare function outputTransformerDataObjects(transformersList: RecursiveFileTree, buffer: Assembler.FileBuffer, withSharedProps: boolean): Promise<void>;
@@ -47,3 +47,68 @@ export async function importTypeScript(app) {
47
47
  }
48
48
  catch { }
49
49
  }
50
+ /**
51
+ * Outputs transformer data objects by generating TypeScript type definitions
52
+ * for all transformers in the provided file tree. This function creates
53
+ * InferData types for each transformer and organizes them in namespaces.
54
+ *
55
+ * @param transformersList - A recursive file tree containing transformer file paths
56
+ * @param buffer - The file buffer to write the generated types to
57
+ *
58
+ * @example
59
+ * const transformersList = {
60
+ * User: '#app/transformers/user_transformer',
61
+ * Auth: {
62
+ * Login: '#app/transformers/auth/login_transformer'
63
+ * }
64
+ * }
65
+ * await outputTransformerDataObjects(transformersList, buffer)
66
+ * // Generates:
67
+ * // export namespace Data {
68
+ * // export type User = InferData<UserTransformer>
69
+ * // export namespace Auth {
70
+ * // export type Login = InferData<AuthLoginTransformer>
71
+ * // }
72
+ * // }
73
+ */
74
+ export async function outputTransformerDataObjects(transformersList, buffer, withSharedProps) {
75
+ const importsBuffer = buffer.create();
76
+ importsBuffer.write(`import type { InferData, InferVariants } from '@adonisjs/core/types/transformers'`);
77
+ if (withSharedProps) {
78
+ importsBuffer.write(`import type { InferSharedProps } from '@adonisjs/inertia/types'`);
79
+ }
80
+ buffer.writeLine(importsBuffer);
81
+ buffer.write('export namespace Data {').indent();
82
+ /**
83
+ * Recursively generates namespace tree structure for transformers.
84
+ * Creates nested namespaces for directory structures and type exports
85
+ * for individual transformer files.
86
+ *
87
+ * @param input - The current level of the file tree to process
88
+ * @param parents - Array of parent namespace names for import naming
89
+ */
90
+ function generateNamespaceTree(input, parents) {
91
+ Object.keys(input).forEach((key) => {
92
+ const value = input[key];
93
+ if (typeof value === 'string') {
94
+ const importName = `${parents.join()}${key}Transformer`;
95
+ importsBuffer.write(`import type ${importName} from '${value}'`);
96
+ buffer.write(`export type ${key} = InferData<${importName}>`);
97
+ buffer.write(`export namespace ${key} {`).indent();
98
+ buffer.write(`export type Variants = InferVariants<${importName}>`);
99
+ buffer.dedent().write('}');
100
+ }
101
+ else {
102
+ buffer.write(`export namespace ${key} {`).indent();
103
+ generateNamespaceTree(value, [...parents, key]);
104
+ buffer.dedent().write(`}`);
105
+ }
106
+ });
107
+ }
108
+ generateNamespaceTree(transformersList, []);
109
+ if (withSharedProps) {
110
+ importsBuffer.write(`import type InertiaMiddleware from '#middleware/inertia_middleware'`);
111
+ buffer.write('export type SharedProps = InferSharedProps<InertiaMiddleware>');
112
+ }
113
+ buffer.dedent().write('}');
114
+ }
package/build/src/vine.js CHANGED
@@ -9,15 +9,21 @@
9
9
  import vine, { symbols, BaseLiteralType } from '@vinejs/vine';
10
10
  const MULTIPART_FILE = symbols.SUBTYPE ?? Symbol.for('subtype');
11
11
  /**
12
- * Checks if the value is an instance of multipart file
13
- * from bodyparser.
12
+ * Checks if the value is an instance of multipart file from bodyparser.
13
+ * Used internally for type guarding in file validation.
14
+ *
15
+ * @param file - The value to check for MultipartFile instance
14
16
  */
15
17
  function isBodyParserFile(file) {
16
18
  return !!(file && typeof file === 'object' && 'isMultipartFile' in file);
17
19
  }
18
20
  /**
19
- * VineJS validation rule that validates the file to be an
20
- * instance of BodyParser MultipartFile class.
21
+ * VineJS validation rule that validates the file to be an instance of BodyParser
22
+ * MultipartFile class and applies size/extension validation if configured.
23
+ *
24
+ * @param file - The file value to validate
25
+ * @param options - Validation options for file size and extensions
26
+ * @param field - The field context from VineJS validation
21
27
  */
22
28
  const isMultipartFile = vine.createRule((file, options, field) => {
23
29
  /**
@@ -26,7 +32,7 @@ const isMultipartFile = vine.createRule((file, options, field) => {
26
32
  */
27
33
  if (!isBodyParserFile(file)) {
28
34
  field.report('The {{ field }} must be a file', 'file', field);
29
- return;
35
+ return false;
30
36
  }
31
37
  const validationOptions = typeof options === 'function' ? options(field) : options;
32
38
  /**
@@ -53,6 +59,7 @@ const isMultipartFile = vine.createRule((file, options, field) => {
53
59
  file.errors.forEach((error) => {
54
60
  field.report(error.message, `file.${error.type}`, field, validationOptions);
55
61
  });
62
+ return file.isValid;
56
63
  });
57
64
  /**
58
65
  * Represents a multipart file uploaded via multipart/form-data HTTP
@@ -84,8 +91,9 @@ export class VineMultipartFile extends BaseLiteralType {
84
91
  * @param validations - Array of validation functions to apply
85
92
  */
86
93
  constructor(validationOptions, options, validations) {
87
- super(options, validations || [isMultipartFile(validationOptions || {})]);
94
+ super(options, validations || []);
88
95
  this.#validationOptions = validationOptions;
96
+ this.dataTypeValidator = isMultipartFile(validationOptions || {});
89
97
  }
90
98
  /**
91
99
  * Creates a clone of the current VineMultipartFile instance
@@ -0,0 +1,18 @@
1
+ {{#var transformerName = generators.transformerName(entity.name)}}
2
+ {{#var transformerFileName = generators.transformerFileName(entity.name)}}
3
+ {{#var modelName = generators.modelName(model.name)}}
4
+ {{#var modelFileName = generators.modelFileName(model.name)}}
5
+ {{#var modelImportPath = generators.importPath('#models', model.path, modelFileName.replace(/\.ts$/, ''))}}
6
+ {{{
7
+ exports({
8
+ to: app.transformersPath(entity.path, transformerFileName)
9
+ })
10
+ }}}
11
+ import { BaseTransformer } from '@adonisjs/core/transformers'
12
+ import {{ modelName }} from '{{ modelImportPath }}'
13
+
14
+ export default class {{ transformerName }} extends BaseTransformer<{{modelName}}> {
15
+ toObject() {
16
+ return this.pick(this.resource, ['id'])
17
+ }
18
+ }
@@ -0,0 +1 @@
1
+ export * from '@poppinss/utils/types';
@@ -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 * from '@poppinss/utils/types';
@@ -1,2 +1,22 @@
1
+ /**
2
+ * Helper types and utilities for AdonisJS applications.
3
+ * Re-exports commonly used type utilities and file system operation types.
4
+ *
5
+ * @example
6
+ * // Use Opaque type for branded primitives
7
+ * import type { Opaque } from '@adonisjs/core/types/helpers'
8
+ *
9
+ * type UserId = Opaque<'UserId', number>
10
+ * const userId: UserId = 123 as UserId
11
+ *
12
+ * @example
13
+ * // Use file system option types
14
+ * import type { ImportAllFilesOptions } from '@adonisjs/core/types/helpers'
15
+ *
16
+ * const options: ImportAllFilesOptions = {
17
+ * ignoreMissingExports: true,
18
+ * transformKeys: (key) => key.toLowerCase()
19
+ * }
20
+ */
1
21
  export type { Opaque, NormalizeConstructor } from '@poppinss/utils/types';
2
22
  export type { ImportAllFilesOptions, ReadAllFilesOptions } from '@poppinss/utils/fs';
@@ -1,5 +1,6 @@
1
1
  export * from '@adonisjs/http-server/types';
2
2
  import type { ValidationOptions } from '@vinejs/vine/types';
3
+ export type { InferRouteParams } from '@poppinss/utils/types';
3
4
  /**
4
5
  * Validation options accepted by the "request.validateUsing" method
5
6
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@adonisjs/core",
3
3
  "description": "Core of AdonisJS",
4
- "version": "7.0.0-next.0",
4
+ "version": "7.0.0-next.10",
5
5
  "engines": {
6
6
  "node": ">=24.0.0"
7
7
  },
@@ -54,6 +54,7 @@
54
54
  "./env/editor": "./build/modules/env/editor.js",
55
55
  "./events": "./build/modules/events.js",
56
56
  "./http": "./build/modules/http/main.js",
57
+ "./http/url_builder_client": "./build/modules/http/url_builder_client.js",
57
58
  "./logger": "./build/modules/logger.js",
58
59
  "./repl": "./build/modules/repl.js",
59
60
  "./transformers": "./build/modules/transformers/main.js",
@@ -72,6 +73,7 @@
72
73
  "compile": "npm run clean && tsc",
73
74
  "postcompile": "npm run copy:templates && npm run index:commands",
74
75
  "build": "npm run compile",
76
+ "docs": "typedoc",
75
77
  "release": "npx release-it",
76
78
  "version": "npm run build",
77
79
  "prepublishOnly": "npm run build",
@@ -83,10 +85,10 @@
83
85
  "index:commands": "node --import=@poppinss/ts-exec toolkit/main.js index build/commands"
84
86
  },
85
87
  "devDependencies": {
86
- "@adonisjs/assembler": "^8.0.0-next.7",
87
- "@adonisjs/eslint-config": "^3.0.0-next.1",
88
+ "@adonisjs/assembler": "^8.0.0-next.16",
89
+ "@adonisjs/eslint-config": "^3.0.0-next.4",
88
90
  "@adonisjs/prettier-config": "^1.4.5",
89
- "@adonisjs/tsconfig": "^2.0.0-next.0",
91
+ "@adonisjs/tsconfig": "^2.0.0-next.2",
90
92
  "@japa/assert": "^4.1.1",
91
93
  "@japa/expect-type": "^2.0.3",
92
94
  "@japa/file-system": "^2.3.2",
@@ -94,51 +96,52 @@
94
96
  "@japa/snapshot": "^2.0.9",
95
97
  "@poppinss/ts-exec": "^1.4.1",
96
98
  "@release-it/conventional-changelog": "^10.0.1",
97
- "@types/node": "^24.3.1",
99
+ "@types/node": "^24.10.0",
98
100
  "@types/pretty-hrtime": "^1.0.3",
99
101
  "@types/sinon": "^17.0.4",
100
102
  "@types/supertest": "^6.0.3",
101
103
  "@types/test-console": "^2.0.3",
102
- "@vinejs/vine": "^3.0.1",
104
+ "@vinejs/vine": "^4.1.0",
103
105
  "argon2": "^0.44.0",
104
106
  "bcrypt": "^6.0.0",
105
107
  "c8": "^10.1.3",
106
108
  "copyfiles": "^2.4.1",
107
- "cross-env": "^10.0.0",
108
- "del-cli": "^6.0.0",
109
+ "cross-env": "^10.1.0",
110
+ "del-cli": "^7.0.0",
109
111
  "edge.js": "^6.3.0",
110
- "eslint": "^9.34.0",
112
+ "eslint": "^9.39.1",
111
113
  "execa": "^9.6.0",
112
114
  "get-port": "^7.1.0",
113
115
  "prettier": "^3.6.2",
114
- "release-it": "^19.0.4",
116
+ "release-it": "^19.0.5",
115
117
  "sinon": "^21.0.0",
116
118
  "supertest": "^7.1.4",
117
119
  "test-console": "^2.0.0",
118
120
  "timekeeper": "^2.3.1",
119
- "typescript": "^5.9.2",
121
+ "typedoc": "^0.28.14",
122
+ "typescript": "^5.9.3",
120
123
  "youch": "^4.1.0-beta.11"
121
124
  },
122
125
  "dependencies": {
123
- "@adonisjs/ace": "^14.0.1-next.1",
124
- "@adonisjs/application": "^9.0.0-next.5",
125
- "@adonisjs/bodyparser": "^11.0.0-next.1",
126
+ "@adonisjs/ace": "^14.0.1-next.2",
127
+ "@adonisjs/application": "^9.0.0-next.10",
128
+ "@adonisjs/bodyparser": "^11.0.0-next.2",
126
129
  "@adonisjs/config": "^6.0.0-next.1",
127
130
  "@adonisjs/encryption": "^7.0.0-next.1",
128
131
  "@adonisjs/env": "^7.0.0-next.1",
129
132
  "@adonisjs/events": "^10.1.0-next.2",
130
- "@adonisjs/fold": "^11.0.0-next.2",
133
+ "@adonisjs/fold": "^11.0.0-next.3",
131
134
  "@adonisjs/hash": "^10.0.0-next.1",
132
135
  "@adonisjs/health": "^3.0.0-next.0",
133
- "@adonisjs/http-server": "^8.0.0-next.6",
134
- "@adonisjs/http-transformers": "^1.1.0",
135
- "@adonisjs/logger": "^7.1.0-next.0",
136
+ "@adonisjs/http-server": "^8.0.0-next.12",
137
+ "@adonisjs/http-transformers": "^1.5.0",
138
+ "@adonisjs/logger": "^7.1.0-next.2",
136
139
  "@adonisjs/repl": "^5.0.0-next.0",
137
140
  "@poppinss/colors": "^4.1.5",
138
- "@poppinss/dumper": "^0.6.4",
139
- "@poppinss/macroable": "^1.0.5",
141
+ "@poppinss/dumper": "^0.6.5",
142
+ "@poppinss/macroable": "^1.1.0",
140
143
  "@poppinss/utils": "^7.0.0-next.3",
141
- "@sindresorhus/is": "^7.0.2",
144
+ "@sindresorhus/is": "^7.1.1",
142
145
  "@types/he": "^1.2.3",
143
146
  "error-stack-parser-es": "^1.0.5",
144
147
  "he": "^1.2.0",
@@ -146,8 +149,8 @@
146
149
  "string-width": "^8.1.0"
147
150
  },
148
151
  "peerDependencies": {
149
- "@adonisjs/assembler": "^8.0.0-next.6",
150
- "@vinejs/vine": "^3.0.0",
152
+ "@adonisjs/assembler": "^8.0.0-next.10",
153
+ "@vinejs/vine": "^4.0.0-next.0",
151
154
  "argon2": "^0.43.0",
152
155
  "bcrypt": "^6.0.0",
153
156
  "edge.js": "^6.2.0",