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

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 (67) 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 +23 -0
  48. package/build/commands/test.d.ts +66 -3
  49. package/build/commands/test.js +35 -5
  50. package/build/modules/ace/codemods.js +10 -2
  51. package/build/modules/ace/commands.d.ts +0 -1
  52. package/build/modules/ace/commands.js +0 -3
  53. package/build/providers/app_provider.d.ts +2 -2
  54. package/build/providers/app_provider.js +3 -3
  55. package/build/providers/edge_provider.js +10 -0
  56. package/build/src/assembler_hooks/index_entities.d.ts +3 -17
  57. package/build/src/assembler_hooks/index_entities.js +26 -15
  58. package/build/src/helpers/string.js +6 -0
  59. package/build/src/helpers/types.d.ts +1 -0
  60. package/build/src/types.d.ts +6 -0
  61. package/build/src/utils.d.ts +26 -0
  62. package/build/src/utils.js +55 -0
  63. package/build/stubs/make/transformer/main.stub +18 -0
  64. package/build/types/common.d.ts +1 -0
  65. package/build/types/common.js +9 -0
  66. package/build/types/http.d.ts +1 -0
  67. package/package.json +14 -12
@@ -1,14 +1,37 @@
1
1
  import { BaseCommand } from '../../modules/ace/main.ts';
2
2
  /**
3
- * Make a new EdgeJS template file
3
+ * Command to create a new Edge.js template file.
4
+ * Edge templates are used for rendering HTML views in your web application,
5
+ * supporting layouts, partials, components, and template inheritance.
6
+ *
7
+ * @example
8
+ * ```
9
+ * ace make:view home
10
+ * ace make:view users/profile
11
+ * ace make:view components/navbar
12
+ * ace make:view layouts/app
13
+ * ```
4
14
  */
5
15
  export default class MakeView extends BaseCommand {
16
+ /**
17
+ * The command name
18
+ */
6
19
  static commandName: string;
20
+ /**
21
+ * The command description
22
+ */
7
23
  static description: string;
24
+ /**
25
+ * Name of the template file to create
26
+ */
8
27
  name: string;
9
28
  /**
10
- * The stub to use for generating the template
29
+ * The stub template file to use for generating the Edge template
11
30
  */
12
31
  protected stubPath: string;
32
+ /**
33
+ * Execute the command to create a new Edge.js template file.
34
+ * Generates the template file in the views directory.
35
+ */
13
36
  run(): Promise<void>;
14
37
  }
@@ -15,15 +15,35 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
15
15
  import { stubsRoot } from "../../stubs/main.js";
16
16
  import { args, BaseCommand } from "../../modules/ace/main.js";
17
17
  /**
18
- * Make a new EdgeJS template file
18
+ * Command to create a new Edge.js template file.
19
+ * Edge templates are used for rendering HTML views in your web application,
20
+ * supporting layouts, partials, components, and template inheritance.
21
+ *
22
+ * @example
23
+ * ```
24
+ * ace make:view home
25
+ * ace make:view users/profile
26
+ * ace make:view components/navbar
27
+ * ace make:view layouts/app
28
+ * ```
19
29
  */
20
30
  export default class MakeView extends BaseCommand {
31
+ /**
32
+ * The command name
33
+ */
21
34
  static commandName = 'make:view';
35
+ /**
36
+ * The command description
37
+ */
22
38
  static description = 'Create a new Edge.js template file';
23
39
  /**
24
- * The stub to use for generating the template
40
+ * The stub template file to use for generating the Edge template
25
41
  */
26
42
  stubPath = 'make/view/main.stub';
43
+ /**
44
+ * Execute the command to create a new Edge.js template file.
45
+ * Generates the template file in the views directory.
46
+ */
27
47
  async run() {
28
48
  const codemods = await this.createCodemods();
29
49
  await codemods.makeUsingStub(stubsRoot, this.stubPath, {
@@ -1,14 +1,34 @@
1
1
  import { BaseCommand } from '../modules/ace/main.ts';
2
2
  import { type CommandOptions } from '../types/ace.ts';
3
3
  /**
4
- * The ReplCommand class is used to start the Repl server
4
+ * Command to start an interactive REPL (Read-Eval-Print Loop) session for AdonisJS.
5
+ * The REPL provides a command-line interface where you can execute JavaScript code
6
+ * in the context of your AdonisJS application, allowing you to interact with models,
7
+ * services, and other application components in real-time.
8
+ *
9
+ * @example
10
+ * ```
11
+ * ace repl
12
+ * ```
5
13
  */
6
14
  export default class ReplCommand extends BaseCommand {
15
+ /**
16
+ * The command name
17
+ */
7
18
  static commandName: string;
19
+ /**
20
+ * The command description
21
+ */
8
22
  static description: string;
23
+ /**
24
+ * Command options configuration.
25
+ * Requires the application to be started and keeps the process alive.
26
+ */
9
27
  static options: CommandOptions;
10
28
  /**
11
- * Starts the REPL server process
29
+ * Execute the command to start the REPL server.
30
+ * Creates a REPL instance from the container and sets up an exit handler
31
+ * that properly terminates the application when the REPL session ends.
12
32
  */
13
33
  run(): Promise<void>;
14
34
  }
@@ -8,17 +8,37 @@
8
8
  */
9
9
  import { BaseCommand } from "../modules/ace/main.js";
10
10
  /**
11
- * The ReplCommand class is used to start the Repl server
11
+ * Command to start an interactive REPL (Read-Eval-Print Loop) session for AdonisJS.
12
+ * The REPL provides a command-line interface where you can execute JavaScript code
13
+ * in the context of your AdonisJS application, allowing you to interact with models,
14
+ * services, and other application components in real-time.
15
+ *
16
+ * @example
17
+ * ```
18
+ * ace repl
19
+ * ```
12
20
  */
13
21
  export default class ReplCommand extends BaseCommand {
22
+ /**
23
+ * The command name
24
+ */
14
25
  static commandName = 'repl';
26
+ /**
27
+ * The command description
28
+ */
15
29
  static description = 'Start a new REPL session';
30
+ /**
31
+ * Command options configuration.
32
+ * Requires the application to be started and keeps the process alive.
33
+ */
16
34
  static options = {
17
35
  startApp: true,
18
36
  staysAlive: true,
19
37
  };
20
38
  /**
21
- * Starts the REPL server process
39
+ * Execute the command to start the REPL server.
40
+ * Creates a REPL instance from the container and sets up an exit handler
41
+ * that properly terminates the application when the REPL session ends.
22
42
  */
23
43
  async run() {
24
44
  const repl = await this.app.container.make('repl');
@@ -5,17 +5,53 @@ import { BaseCommand } from '../modules/ace/main.ts';
5
5
  * Serve command is used to run the AdonisJS HTTP server during development. The
6
6
  * command under the hood runs the "bin/server.ts" file and watches for file
7
7
  * system changes
8
+ *
9
+ * @example
10
+ * ```
11
+ * ace serve
12
+ * ace serve --watch
13
+ * ace serve --hmr
14
+ * ace serve --poll
15
+ * ace serve --no-clear
16
+ * ```
8
17
  */
9
18
  export default class Serve extends BaseCommand {
10
19
  #private;
20
+ /**
21
+ * The command name
22
+ */
11
23
  static commandName: string;
24
+ /**
25
+ * The command description
26
+ */
12
27
  static description: string;
28
+ /**
29
+ * Help text for the command
30
+ */
13
31
  static help: string[];
32
+ /**
33
+ * Command options configuration
34
+ */
14
35
  static options: CommandOptions;
36
+ /**
37
+ * The development server instance
38
+ */
15
39
  devServer: DevServer;
40
+ /**
41
+ * Start the server with HMR support
42
+ */
16
43
  hmr?: boolean;
44
+ /**
45
+ * Watch filesystem and restart the HTTP server on file change
46
+ */
17
47
  watch?: boolean;
48
+ /**
49
+ * Use polling to detect filesystem changes
50
+ */
18
51
  poll?: boolean;
52
+ /**
53
+ * Clear the terminal for new logs after file change
54
+ */
19
55
  clear?: boolean;
20
56
  /**
21
57
  * Runs the HTTP server
@@ -18,10 +18,28 @@ import { importAssembler, importTypeScript } from "../src/utils.js";
18
18
  * Serve command is used to run the AdonisJS HTTP server during development. The
19
19
  * command under the hood runs the "bin/server.ts" file and watches for file
20
20
  * system changes
21
+ *
22
+ * @example
23
+ * ```
24
+ * ace serve
25
+ * ace serve --watch
26
+ * ace serve --hmr
27
+ * ace serve --poll
28
+ * ace serve --no-clear
29
+ * ```
21
30
  */
22
31
  export default class Serve extends BaseCommand {
32
+ /**
33
+ * The command name
34
+ */
23
35
  static commandName = 'serve';
36
+ /**
37
+ * The command description
38
+ */
24
39
  static description = 'Start the development HTTP server along with the file watcher to perform restarts on file change';
40
+ /**
41
+ * Help text for the command
42
+ */
25
43
  static help = [
26
44
  'Start the development server with file watcher using the following command.',
27
45
  '```',
@@ -39,11 +57,16 @@ export default class Serve extends BaseCommand {
39
57
  '{{ binaryName }} serve --assets-args="--debug --base=/public"',
40
58
  '```',
41
59
  ];
60
+ /**
61
+ * Command options configuration
62
+ */
42
63
  static options = {
43
64
  staysAlive: true,
44
65
  };
45
66
  /**
46
67
  * Log a development dependency is missing
68
+ *
69
+ * @param dependency - The name of the missing dependency
47
70
  */
48
71
  #logMissingDevelopmentDependency(dependency) {
49
72
  this.logger.error([
@@ -2,29 +2,92 @@ import type { TestRunner } from '@adonisjs/assembler';
2
2
  import type { CommandOptions } from '../types/ace.ts';
3
3
  import { BaseCommand } from '../modules/ace/main.ts';
4
4
  /**
5
- * Test command is used to run tests with optional file watcher. Under the
6
- * hood, we run "bin/test.js" file.
5
+ * Command to run application tests using the Japa test runner.
6
+ * Supports filtering tests by suites, files, tags, groups, and individual tests.
7
+ * Can run in watch mode to automatically re-run tests when files change.
8
+ *
9
+ * @example
10
+ * ```
11
+ * ace test
12
+ * ace test unit integration
13
+ * ace test --watch
14
+ * ace test --files=user.spec.ts
15
+ * ace test --tags=slow --groups="User tests"
16
+ * ace test --reporters=spec,dot
17
+ * ace test --timeout=5000 --retries=2
18
+ * ```
7
19
  */
8
20
  export default class Test extends BaseCommand {
9
21
  #private;
22
+ /**
23
+ * The command name
24
+ */
10
25
  static commandName: string;
26
+ /**
27
+ * The command description
28
+ */
11
29
  static description: string;
30
+ /**
31
+ * Command options configuration.
32
+ * Allows unknown flags to be passed to Japa and keeps the process alive.
33
+ */
12
34
  static options: CommandOptions;
35
+ /**
36
+ * The test runner instance from the assembler package
37
+ */
13
38
  testsRunner: TestRunner;
39
+ /**
40
+ * Test suite names to run. When provided, only tests from the specified suites will be executed
41
+ */
14
42
  suites?: string[];
43
+ /**
44
+ * Filter tests by filename patterns
45
+ */
15
46
  files?: string[];
47
+ /**
48
+ * Filter tests by tags
49
+ */
16
50
  tags?: string[];
51
+ /**
52
+ * Filter tests by parent group title
53
+ */
17
54
  groups?: string[];
55
+ /**
56
+ * Filter tests by test title
57
+ */
18
58
  tests?: string[];
59
+ /**
60
+ * Specify one or more test reporters to use for output formatting
61
+ */
19
62
  reporters?: string[];
63
+ /**
64
+ * Enable watch mode to automatically re-run tests when files change
65
+ */
20
66
  watch?: boolean;
67
+ /**
68
+ * Use polling instead of native filesystem events to detect file changes
69
+ */
21
70
  poll?: boolean;
71
+ /**
72
+ * Default timeout in milliseconds for all tests
73
+ */
22
74
  timeout?: number;
75
+ /**
76
+ * Default number of retries for failed tests
77
+ */
23
78
  retries?: number;
79
+ /**
80
+ * Execute only tests that failed during the last run
81
+ */
24
82
  failed?: boolean;
83
+ /**
84
+ * Clear the terminal for new logs after file change in watch mode
85
+ */
25
86
  clear?: boolean;
26
87
  /**
27
- * Runs tests
88
+ * Execute the test command. Sets up the test runner with all configured options
89
+ * and filters, then runs tests either once or in watch mode. Handles missing
90
+ * dependencies and properly configures the test environment.
28
91
  */
29
92
  run(): Promise<void>;
30
93
  }
@@ -15,18 +15,43 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
15
15
  import { BaseCommand, flags, args } from "../modules/ace/main.js";
16
16
  import { importAssembler, importTypeScript } from "../src/utils.js";
17
17
  /**
18
- * Test command is used to run tests with optional file watcher. Under the
19
- * hood, we run "bin/test.js" file.
18
+ * Command to run application tests using the Japa test runner.
19
+ * Supports filtering tests by suites, files, tags, groups, and individual tests.
20
+ * Can run in watch mode to automatically re-run tests when files change.
21
+ *
22
+ * @example
23
+ * ```
24
+ * ace test
25
+ * ace test unit integration
26
+ * ace test --watch
27
+ * ace test --files=user.spec.ts
28
+ * ace test --tags=slow --groups="User tests"
29
+ * ace test --reporters=spec,dot
30
+ * ace test --timeout=5000 --retries=2
31
+ * ```
20
32
  */
21
33
  export default class Test extends BaseCommand {
34
+ /**
35
+ * The command name
36
+ */
22
37
  static commandName = 'test';
38
+ /**
39
+ * The command description
40
+ */
23
41
  static description = 'Run tests along with the file watcher to re-run tests on file change';
42
+ /**
43
+ * Command options configuration.
44
+ * Allows unknown flags to be passed to Japa and keeps the process alive.
45
+ */
24
46
  static options = {
25
47
  allowUnknownFlags: true,
26
48
  staysAlive: true,
27
49
  };
28
50
  /**
29
- * Log a development dependency is missing
51
+ * Log an error message when a required development dependency is missing.
52
+ * Provides helpful instructions for resolving the issue.
53
+ *
54
+ * @param dependency - The name of the missing dependency package
30
55
  */
31
56
  #logMissingDevelopmentDependency(dependency) {
32
57
  this.logger.error([
@@ -38,7 +63,10 @@ export default class Test extends BaseCommand {
38
63
  ].join('\n'));
39
64
  }
40
65
  /**
41
- * Collection of unknown flags to pass to Japa
66
+ * Collect unknown flags and format them to pass to the Japa test runner.
67
+ * Handles boolean flags, arrays, and single values appropriately.
68
+ *
69
+ * @returns Array of formatted command-line arguments for Japa
42
70
  */
43
71
  #getPassthroughFlags() {
44
72
  return this.parsed.unknownFlags
@@ -61,7 +89,9 @@ export default class Test extends BaseCommand {
61
89
  .flat(2);
62
90
  }
63
91
  /**
64
- * Runs tests
92
+ * Execute the test command. Sets up the test runner with all configured options
93
+ * and filters, then runs tests either once or in watch mode. Handles missing
94
+ * dependencies and properly configures the test environment.
65
95
  */
66
96
  async run() {
67
97
  process.env.NODE_ENV = 'test';
@@ -308,8 +308,16 @@ export class Codemods extends EventEmitter {
308
308
  const transformer = await this.#getCodeTransformer();
309
309
  const appPath = this.#app.makePath();
310
310
  const colors = this.#cliLogger.getColors();
311
- const devDependencies = packages.filter((pkg) => pkg.isDevDependency).map(({ name }) => name);
312
- const dependencies = packages.filter((pkg) => !pkg.isDevDependency).map(({ name }) => name);
311
+ const devDependencies = packages
312
+ .filter((pkg) => pkg.isDevDependency)
313
+ .map(({ name }) => {
314
+ return name.startsWith('@adonisjs/') ? `${name}@next` : name;
315
+ });
316
+ const dependencies = packages
317
+ .filter((pkg) => !pkg.isDevDependency)
318
+ .map(({ name }) => {
319
+ return name.startsWith('@adonisjs/') ? `${name}@next` : name;
320
+ });
313
321
  if (!transformer) {
314
322
  this.#cliLogger.warning('Cannot install packages. Install "@adonisjs/assembler" or manually install following packages');
315
323
  this.#cliLogger.log(`devDependencies: ${devDependencies.join(',')}`);
@@ -99,7 +99,6 @@ export declare class ListCommand extends AceListCommand implements BaseCommand {
99
99
  * This method provides access to AST-based code transformations.
100
100
  */
101
101
  createCodemods(): Promise<import("./codemods.js").Codemods>;
102
- execCommand(): Promise<any>;
103
102
  /**
104
103
  * Terminate the app. A command should prefer calling this method
105
104
  * over the "app.terminate", because this method only triggers
@@ -143,9 +143,6 @@ export class ListCommand extends AceListCommand {
143
143
  const { Codemods } = await import('./codemods.js');
144
144
  return new Codemods(this.app, this.logger);
145
145
  }
146
- async execCommand() {
147
- return this.exec();
148
- }
149
146
  /**
150
147
  * Terminate the app. A command should prefer calling this method
151
148
  * over the "app.terminate", because this method only triggers
@@ -1,12 +1,12 @@
1
1
  import { Router } from '../modules/http/main.ts';
2
- import { type TransformFn } from '../types/transformers.ts';
2
+ import { type SerializeFn } from '../types/transformers.ts';
3
3
  import type { ApplicationService } from '../src/types.ts';
4
4
  /**
5
5
  * Extend HTTP request class with the transform method
6
6
  */
7
7
  declare module '@adonisjs/core/http' {
8
8
  interface HttpContext {
9
- transform: TransformFn;
9
+ serialize: SerializeFn;
10
10
  }
11
11
  }
12
12
  /**
@@ -16,7 +16,7 @@ import { HttpContext } from "../modules/http/main.js";
16
16
  import { Encryption } from "../modules/encryption.js";
17
17
  import { Router, Server } from "../modules/http/main.js";
18
18
  import { BaseEvent, Emitter } from "../modules/events.js";
19
- import { transform } from "../modules/transformers/main.js";
19
+ import { serialize } from "../modules/transformers/main.js";
20
20
  import BodyParserMiddleware from "../modules/bodyparser/bodyparser_middleware.js";
21
21
  /**
22
22
  * The Application Service provider registers all the baseline
@@ -337,8 +337,8 @@ export default class AppServiceProvider {
337
337
  */
338
338
  async boot() {
339
339
  BaseEvent.useEmitter(await this.app.container.make('emitter'));
340
- HttpContext.macro('transform', function (data, transformer, variant) {
341
- return transform(data, transformer, variant, this.containerResolver);
340
+ HttpContext.instanceProperty('serialize', function (...args) {
341
+ return serialize(...args);
342
342
  });
343
343
  }
344
344
  /**
@@ -71,6 +71,7 @@ export default class EdgeServiceProvider {
71
71
  edge.configure({ cache: app.inProduction });
72
72
  /**
73
73
  * Define Edge global helpers
74
+ * @deprecated
74
75
  */
75
76
  edge.global('route', function (...args) {
76
77
  return router.makeUrl(...args);
@@ -80,6 +81,15 @@ export default class EdgeServiceProvider {
80
81
  });
81
82
  edge.global('app', app);
82
83
  edge.global('config', edgeConfigResolver);
84
+ /**
85
+ * Route helpers
86
+ */
87
+ edge.global('urlFor', function (...args) {
88
+ return router.urlBuilder.urlFor(...args);
89
+ });
90
+ edge.global('signedUrlFor', function (...args) {
91
+ return router.urlBuilder.signedUrlFor(...args);
92
+ });
83
93
  /**
84
94
  * Creating a isolated instance of edge renderer
85
95
  */
@@ -1,26 +1,10 @@
1
1
  import { type IndexEntitiesConfig } from '../types.ts';
2
- import { type CommonHooks } from '@adonisjs/assembler/types';
3
2
  /**
4
3
  * Configures the IndexGenerator to create barrel files for "controllers", "events",
5
4
  * and "listeners". This function is used as an assembler hook to automatically generate
6
5
  * index files that export all modules from specified directories.
7
6
  *
8
7
  * @param {IndexEntitiesConfig} entities - Configuration object for entities indexing
9
- * @param {object} [entities.events] - Configuration for events indexing
10
- * @param {boolean} [entities.events.enabled=true] - Whether to enable events indexing
11
- * @param {string} [entities.events.source='app/events'] - Source directory for events
12
- * @param {string} [entities.events.importAlias='#events'] - Import alias for events
13
- * @param {string} [entities.events.glob] - Glob pattern for matching event files
14
- * @param {object} [entities.listeners] - Configuration for listeners indexing
15
- * @param {boolean} [entities.listeners.enabled=true] - Whether to enable listeners indexing
16
- * @param {string} [entities.listeners.source='app/listeners'] - Source directory for listeners
17
- * @param {string} [entities.listeners.importAlias='#listeners'] - Import alias for listeners
18
- * @param {string} [entities.listeners.glob] - Glob pattern for matching listener files
19
- * @param {object} [entities.controllers] - Configuration for controllers indexing
20
- * @param {boolean} [entities.controllers.enabled=true] - Whether to enable controllers indexing
21
- * @param {string} [entities.controllers.source='app/controllers'] - Source directory for controllers
22
- * @param {string} [entities.controllers.importAlias='#controllers'] - Import alias for controllers
23
- * @param {string} [entities.controllers.glob] - Glob pattern for matching controller files
24
8
  *
25
9
  * @example
26
10
  * // Basic usage with default configuration
@@ -48,4 +32,6 @@ import { type CommonHooks } from '@adonisjs/assembler/types';
48
32
  * }
49
33
  * })
50
34
  */
51
- export declare function indexEntities(entities?: IndexEntitiesConfig): CommonHooks['init'][number];
35
+ export declare function indexEntities(entities?: IndexEntitiesConfig): {
36
+ run(_: import("@adonisjs/assembler").DevServer | import("@adonisjs/assembler").TestRunner | import("@adonisjs/assembler").Bundler, indexGenerator: import("@adonisjs/assembler/index_generator").IndexGenerator): void;
37
+ };
@@ -6,27 +6,14 @@
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 stringHelpers from "../helpers/string.js";
10
+ import { outputTransformerDataObjects } from "../utils.js";
9
11
  /**
10
12
  * Configures the IndexGenerator to create barrel files for "controllers", "events",
11
13
  * and "listeners". This function is used as an assembler hook to automatically generate
12
14
  * index files that export all modules from specified directories.
13
15
  *
14
16
  * @param {IndexEntitiesConfig} entities - Configuration object for entities indexing
15
- * @param {object} [entities.events] - Configuration for events indexing
16
- * @param {boolean} [entities.events.enabled=true] - Whether to enable events indexing
17
- * @param {string} [entities.events.source='app/events'] - Source directory for events
18
- * @param {string} [entities.events.importAlias='#events'] - Import alias for events
19
- * @param {string} [entities.events.glob] - Glob pattern for matching event files
20
- * @param {object} [entities.listeners] - Configuration for listeners indexing
21
- * @param {boolean} [entities.listeners.enabled=true] - Whether to enable listeners indexing
22
- * @param {string} [entities.listeners.source='app/listeners'] - Source directory for listeners
23
- * @param {string} [entities.listeners.importAlias='#listeners'] - Import alias for listeners
24
- * @param {string} [entities.listeners.glob] - Glob pattern for matching listener files
25
- * @param {object} [entities.controllers] - Configuration for controllers indexing
26
- * @param {boolean} [entities.controllers.enabled=true] - Whether to enable controllers indexing
27
- * @param {string} [entities.controllers.source='app/controllers'] - Source directory for controllers
28
- * @param {string} [entities.controllers.importAlias='#controllers'] - Import alias for controllers
29
- * @param {string} [entities.controllers.glob] - Glob pattern for matching controller files
30
17
  *
31
18
  * @example
32
19
  * // Basic usage with default configuration
@@ -58,11 +45,13 @@ export function indexEntities(entities = {}) {
58
45
  const events = Object.assign({ enabled: true, source: 'app/events', importAlias: '#events' }, entities.events);
59
46
  const listeners = Object.assign({ enabled: true, source: 'app/listeners', importAlias: '#listeners' }, entities.listeners);
60
47
  const controllers = Object.assign({ enabled: true, source: 'app/controllers', importAlias: '#controllers' }, entities.controllers);
48
+ const transformers = Object.assign({ enabled: false, source: 'app/transformers', importAlias: '#transformers' }, entities.transformers);
61
49
  return {
62
50
  run(_, indexGenerator) {
63
51
  if (events.enabled) {
64
52
  indexGenerator.add('events', {
65
53
  source: events.source,
54
+ disableLazyImports: true,
66
55
  glob: events.glob,
67
56
  as: 'barrelFile',
68
57
  exportName: 'events',
@@ -91,6 +80,28 @@ export function indexEntities(entities = {}) {
91
80
  output: '.adonisjs/server/controllers.ts',
92
81
  });
93
82
  }
83
+ if (transformers.enabled) {
84
+ indexGenerator.add('transformers', {
85
+ source: transformers.source,
86
+ glob: transformers.glob,
87
+ as(vfs, buffer, __, helpers) {
88
+ const transformersList = vfs.asTree({
89
+ transformKey(key) {
90
+ const segments = key.split('/');
91
+ const baseName = segments.pop();
92
+ return [
93
+ ...segments.map((segment) => stringHelpers.pascalCase(segment)),
94
+ stringHelpers.create(baseName).removeSuffix('transformer').pascalCase(),
95
+ ].join('/');
96
+ },
97
+ transformValue: helpers.toImportPath,
98
+ });
99
+ outputTransformerDataObjects(transformersList, buffer);
100
+ },
101
+ importAlias: transformers.importAlias,
102
+ output: '.adonisjs/client/data.d.ts',
103
+ });
104
+ }
94
105
  },
95
106
  };
96
107
  }
@@ -34,6 +34,12 @@ const stringHelpers = {
34
34
  create(value) {
35
35
  return new StringBuilder(value);
36
36
  },
37
+ /**
38
+ * Formats Node.js hrtime output into a human-readable string.
39
+ *
40
+ * @param time - Tuple of [seconds, nanoseconds] from process.hrtime()
41
+ * @param options - Formatting options for output style and precision
42
+ */
37
43
  prettyHrTime(time, options) {
38
44
  return prettyHrTime(time, options);
39
45
  },
@@ -104,6 +104,7 @@ declare const types: {
104
104
  urlInstance: typeof import("@sindresorhus/is").isUrlInstance;
105
105
  urlSearchParams: typeof import("@sindresorhus/is").isUrlSearchParams;
106
106
  urlString: typeof import("@sindresorhus/is").isUrlString;
107
+ optional: typeof import("@sindresorhus/is").isOptional;
107
108
  validDate: typeof import("@sindresorhus/is").isValidDate;
108
109
  validLength: typeof import("@sindresorhus/is").isValidLength;
109
110
  weakMap: typeof import("@sindresorhus/is").isWeakMap;
@@ -372,4 +372,10 @@ export type IndexEntitiesConfig = {
372
372
  /** Glob patterns for matching event files */
373
373
  glob?: string[];
374
374
  };
375
+ transformers?: {
376
+ enabled?: boolean;
377
+ source?: string;
378
+ importAlias?: string;
379
+ glob?: string[];
380
+ };
375
381
  };