@adonisjs/core 6.1.5-0 → 6.1.5-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 (175) hide show
  1. package/build/commands/build.d.ts +10 -0
  2. package/build/commands/build.js +65 -22
  3. package/build/commands/commands.json +1 -1
  4. package/build/commands/configure.d.ts +36 -0
  5. package/build/commands/configure.js +84 -6
  6. package/build/commands/eject.d.ts +4 -0
  7. package/build/commands/eject.js +14 -7
  8. package/build/commands/generate_key.d.ts +4 -0
  9. package/build/commands/generate_key.js +14 -7
  10. package/build/commands/inspect_rcfile.d.ts +9 -0
  11. package/build/commands/inspect_rcfile.js +20 -0
  12. package/build/commands/list/routes.d.ts +36 -0
  13. package/build/commands/list/routes.js +94 -0
  14. package/build/commands/make/_base.d.ts +31 -1
  15. package/build/commands/make/_base.js +18 -10
  16. package/build/commands/make/command.d.ts +6 -0
  17. package/build/commands/make/command.js +15 -5
  18. package/build/commands/make/controller.d.ts +9 -0
  19. package/build/commands/make/controller.js +30 -11
  20. package/build/commands/make/event.d.ts +6 -0
  21. package/build/commands/make/event.js +15 -5
  22. package/build/commands/make/exception.d.ts +14 -0
  23. package/build/commands/make/exception.js +35 -0
  24. package/build/commands/make/listener.d.ts +7 -0
  25. package/build/commands/make/listener.js +20 -7
  26. package/build/commands/make/middleware.d.ts +7 -0
  27. package/build/commands/make/middleware.js +16 -5
  28. package/build/commands/make/preload.d.ts +22 -0
  29. package/build/commands/make/preload.js +95 -0
  30. package/build/commands/make/provider.d.ts +6 -0
  31. package/build/commands/make/provider.js +22 -6
  32. package/build/commands/make/service.d.ts +14 -0
  33. package/build/commands/make/service.js +35 -0
  34. package/build/commands/make/test.d.ts +19 -0
  35. package/build/commands/make/test.js +103 -0
  36. package/build/commands/repl.d.ts +14 -0
  37. package/build/commands/repl.js +30 -0
  38. package/build/commands/serve.d.ts +12 -0
  39. package/build/commands/serve.js +78 -27
  40. package/build/commands/test.d.ts +32 -0
  41. package/build/commands/test.js +203 -0
  42. package/build/factories/app.js +8 -0
  43. package/build/factories/bodyparser.js +8 -0
  44. package/build/factories/core/ace.d.ts +4 -1
  45. package/build/factories/core/ace.js +11 -0
  46. package/build/factories/core/ignitor.d.ts +20 -1
  47. package/build/factories/core/ignitor.js +35 -1
  48. package/build/factories/core/main.js +8 -0
  49. package/build/factories/core/test_utils.d.ts +4 -1
  50. package/build/factories/core/test_utils.js +11 -0
  51. package/build/factories/encryption.js +8 -0
  52. package/build/factories/events.js +8 -0
  53. package/build/factories/hash.js +8 -0
  54. package/build/factories/http.js +8 -0
  55. package/build/factories/logger.js +8 -0
  56. package/build/factories/stubs.d.ts +10 -0
  57. package/build/factories/stubs.js +21 -0
  58. package/build/index.d.ts +5 -1
  59. package/build/index.js +13 -0
  60. package/build/modules/ace/commands.d.ts +123 -0
  61. package/build/modules/ace/commands.js +79 -0
  62. package/build/modules/ace/create_kernel.d.ts +9 -0
  63. package/build/modules/ace/create_kernel.js +31 -0
  64. package/build/modules/ace/kernel.d.ts +4 -0
  65. package/build/modules/ace/kernel.js +12 -0
  66. package/build/modules/ace/main.d.ts +1 -1
  67. package/build/modules/ace/main.js +9 -1
  68. package/build/modules/ace/shell.d.ts +9 -1
  69. package/build/modules/ace/shell.js +21 -0
  70. package/build/modules/app.js +8 -0
  71. package/build/modules/bodyparser/bodyparser_middleware.d.ts +4 -0
  72. package/build/modules/bodyparser/bodyparser_middleware.js +12 -0
  73. package/build/modules/bodyparser/main.js +8 -0
  74. package/build/modules/config.js +8 -0
  75. package/build/modules/container.js +8 -0
  76. package/build/modules/encryption.js +8 -0
  77. package/build/modules/env.js +8 -0
  78. package/build/modules/events.js +8 -0
  79. package/build/modules/hash/define_config.d.ts +3 -0
  80. package/build/modules/hash/define_config.js +20 -0
  81. package/build/modules/hash/drivers_collection.d.ts +16 -4
  82. package/build/modules/hash/drivers_collection.js +31 -8
  83. package/build/modules/hash/main.d.ts +1 -0
  84. package/build/modules/hash/main.js +9 -0
  85. package/build/modules/http/main.d.ts +2 -0
  86. package/build/modules/http/main.js +10 -0
  87. package/build/modules/http/request_validator.d.ts +44 -0
  88. package/build/modules/http/request_validator.js +74 -0
  89. package/build/modules/logger.js +8 -0
  90. package/build/modules/repl.d.ts +1 -0
  91. package/build/modules/repl.js +9 -0
  92. package/build/providers/app_provider.d.ts +31 -2
  93. package/build/providers/app_provider.js +44 -15
  94. package/build/providers/hash_provider.d.ts +16 -0
  95. package/build/providers/hash_provider.js +31 -6
  96. package/build/providers/http_provider.d.ts +17 -0
  97. package/build/providers/http_provider.js +26 -1
  98. package/build/providers/repl_provider.d.ts +13 -0
  99. package/build/providers/repl_provider.js +37 -0
  100. package/build/services/ace.js +15 -0
  101. package/build/services/app.d.ts +8 -0
  102. package/build/services/app.js +16 -0
  103. package/build/services/config.js +11 -0
  104. package/build/services/emitter.js +13 -2
  105. package/build/services/encryption.js +13 -2
  106. package/build/services/hash.js +13 -2
  107. package/build/services/logger.js +13 -2
  108. package/build/services/repl.d.ts +3 -0
  109. package/build/services/repl.js +18 -0
  110. package/build/services/router.js +13 -2
  111. package/build/services/server.js +13 -2
  112. package/build/services/test_utils.js +15 -0
  113. package/build/src/bindings/repl.d.ts +6 -0
  114. package/build/src/bindings/repl.js +78 -0
  115. package/build/src/cli_formatters/routes_list.d.ts +63 -0
  116. package/build/src/cli_formatters/routes_list.js +376 -0
  117. package/build/src/debug.d.ts +1 -1
  118. package/build/src/debug.js +8 -0
  119. package/build/src/exceptions.d.ts +1 -0
  120. package/build/src/exceptions.js +9 -0
  121. package/build/src/helpers/is.js +8 -0
  122. package/build/src/helpers/main.d.ts +3 -1
  123. package/build/src/helpers/main.js +11 -1
  124. package/build/src/helpers/parse_binding_reference.d.ts +45 -0
  125. package/build/src/helpers/parse_binding_reference.js +83 -0
  126. package/build/src/helpers/string.d.ts +26 -0
  127. package/build/src/helpers/string.js +15 -0
  128. package/build/src/helpers/types.d.ts +7 -2
  129. package/build/src/helpers/types.js +13 -0
  130. package/build/src/ignitor/ace.d.ts +12 -0
  131. package/build/src/ignitor/ace.js +50 -1
  132. package/build/src/ignitor/http.d.ts +9 -2
  133. package/build/src/ignitor/http.js +67 -0
  134. package/build/src/ignitor/main.d.ts +29 -1
  135. package/build/src/ignitor/main.js +56 -0
  136. package/build/src/ignitor/test.d.ts +10 -0
  137. package/build/src/ignitor/test.js +25 -0
  138. package/build/src/internal_helpers.d.ts +12 -5
  139. package/build/src/internal_helpers.js +35 -7
  140. package/build/src/test_utils/http.d.ts +10 -2
  141. package/build/src/test_utils/http.js +19 -0
  142. package/build/src/test_utils/main.d.ts +21 -3
  143. package/build/src/test_utils/main.js +27 -1
  144. package/build/src/types.d.ts +61 -3
  145. package/build/src/types.js +8 -0
  146. package/build/src/vinejs/extensions/main.d.ts +1 -0
  147. package/build/src/vinejs/extensions/main.js +9 -0
  148. package/build/src/vinejs/extensions/validates_files.d.ts +22 -0
  149. package/build/src/vinejs/extensions/validates_files.js +76 -0
  150. package/build/stubs/index.js +8 -0
  151. package/build/stubs/make/exception/main.stub +10 -0
  152. package/build/stubs/make/preload_file/main.stub +4 -0
  153. package/build/stubs/make/service/main.stub +4 -0
  154. package/build/stubs/make/test/main.stub +11 -0
  155. package/build/toolkit/commands/index_commands.d.ts +4 -0
  156. package/build/toolkit/commands/index_commands.js +13 -5
  157. package/build/toolkit/main.js +11 -0
  158. package/build/types/ace.js +8 -0
  159. package/build/types/app.js +8 -0
  160. package/build/types/bodyparser.js +8 -0
  161. package/build/types/container.js +8 -0
  162. package/build/types/encryption.js +8 -0
  163. package/build/types/events.js +8 -0
  164. package/build/types/hash.js +8 -0
  165. package/build/types/http.js +8 -0
  166. package/build/types/logger.js +8 -0
  167. package/build/types/repl.d.ts +1 -0
  168. package/build/types/repl.js +9 -0
  169. package/package.json +76 -123
  170. package/build/legacy/validator.d.ts +0 -1
  171. package/build/legacy/validator.js +0 -1
  172. package/build/modules/http.d.ts +0 -1
  173. package/build/modules/http.js +0 -1
  174. package/build/src/helpers/string_builder.d.ts +0 -23
  175. package/build/src/helpers/string_builder.js +0 -86
@@ -1,13 +1,38 @@
1
+ /*
2
+ * @adonisjs/core
3
+ *
4
+ * (c) AdonisJS
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+ /**
10
+ * The Test runner process is used to start the tests runner process
11
+ */
1
12
  export class TestRunnerProcess {
13
+ /**
14
+ * Ignitor reference
15
+ */
2
16
  #ignitor;
17
+ /**
18
+ * The callback that configures the tests runner. This callback
19
+ * runs at the time of starting the app.
20
+ */
3
21
  #configureCallback = () => { };
4
22
  constructor(ignitor) {
5
23
  this.#ignitor = ignitor;
6
24
  }
25
+ /**
26
+ * Register a callback that runs after booting the AdonisJS app
27
+ * and just before the provider's ready hook
28
+ */
7
29
  configure(callback) {
8
30
  this.#configureCallback = callback;
9
31
  return this;
10
32
  }
33
+ /**
34
+ * Runs a callback after starting the app
35
+ */
11
36
  async run(callback) {
12
37
  const app = this.#ignitor.createApp('test');
13
38
  await app.init();
@@ -1,8 +1,15 @@
1
1
  import { ApplicationService } from './types.js';
2
+ import { RcFile } from '@adonisjs/application/types';
3
+ /**
4
+ * Imports assembler optionally
5
+ */
2
6
  export declare function importAssembler(app: ApplicationService): Promise<typeof import('@adonisjs/assembler') | undefined>;
7
+ /**
8
+ * Imports typescript optionally
9
+ */
3
10
  export declare function importTypeScript(app: ApplicationService): Promise<typeof import('typescript') | undefined>;
4
- export declare function detectAssetsBundler(app: ApplicationService): Promise<{
5
- name: string;
6
- devServerCommand: string;
7
- buildCommand: string;
8
- } | undefined>;
11
+ /**
12
+ * Detects the assets bundler in use. The rcFile.assetsBundler is
13
+ * used when exists.
14
+ */
15
+ export declare function detectAssetsBundler(app: ApplicationService): Promise<RcFile['assetsBundler']>;
@@ -1,32 +1,60 @@
1
- import fs from 'fs-extra';
1
+ /*
2
+ * @adonisjs/core
3
+ *
4
+ * (c) AdonisJS
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+ import { existsSync } from 'node:fs';
10
+ /**
11
+ * Imports assembler optionally
12
+ */
2
13
  export async function importAssembler(app) {
3
14
  try {
4
15
  return await app.import('@adonisjs/assembler');
5
16
  }
6
17
  catch { }
7
18
  }
19
+ /**
20
+ * Imports typescript optionally
21
+ */
8
22
  export async function importTypeScript(app) {
9
23
  try {
10
24
  return await app.importDefault('typescript');
11
25
  }
12
26
  catch { }
13
27
  }
28
+ /**
29
+ * Generates an array of filenames with different JavaScript
30
+ * extensions for the given filename
31
+ */
32
+ function generateJsFilenames(filename) {
33
+ const extensions = ['.js', '.ts', '.cjs', '.mjs', '.cts', '.mts'];
34
+ return extensions.map((extension) => filename + extension);
35
+ }
36
+ /**
37
+ * Detects the assets bundler in use. The rcFile.assetsBundler is
38
+ * used when exists.
39
+ */
14
40
  export async function detectAssetsBundler(app) {
15
41
  if (app.rcFile.assetsBundler) {
16
42
  return app.rcFile.assetsBundler;
17
43
  }
18
- if (await fs.exists(app.makePath('vite.config.js'))) {
44
+ const possibleViteConfigFiles = generateJsFilenames('vite.config');
45
+ if (possibleViteConfigFiles.some((config) => existsSync(app.makePath(config)))) {
19
46
  return {
20
47
  name: 'vite',
21
- devServerCommand: 'vite',
22
- buildCommand: 'vite build',
48
+ devServer: { command: 'vite' },
49
+ build: { command: 'vite', args: ['build'] },
23
50
  };
24
51
  }
25
- if (await fs.exists(app.makePath('webpack.config.js'))) {
52
+ const possibleEncoreConfigFiles = generateJsFilenames('webpack.config');
53
+ if (possibleEncoreConfigFiles.some((config) => existsSync(app.makePath(config)))) {
26
54
  return {
27
55
  name: 'encore',
28
- devServerCommand: 'encore dev-server',
29
- buildCommand: 'encore',
56
+ devServer: { command: 'encore', args: ['dev-server'] },
57
+ build: { command: 'encore', args: ['production'] },
30
58
  };
31
59
  }
32
60
  }
@@ -1,10 +1,18 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
1
+ /// <reference types="@types/node" resolution-mode="require"/>
2
+ /// <reference types="@types/node" resolution-mode="require"/>
3
3
  import type { TestUtils } from './main.js';
4
4
  import type { Server as NodeHttpsServer } from 'node:https';
5
5
  import { IncomingMessage, ServerResponse, Server as NodeHttpServer } from 'node:http';
6
+ /**
7
+ * Http server utils are used to start the AdonisJS HTTP server
8
+ * during testing
9
+ */
6
10
  export declare class HttpServerUtils {
7
11
  #private;
8
12
  constructor(utils: TestUtils);
13
+ /**
14
+ * Testing hook to start the HTTP server to listen for new request.
15
+ * The return value is a function to close the HTTP server.
16
+ */
9
17
  start(serverCallback?: (handler: (req: IncomingMessage, res: ServerResponse) => any) => NodeHttpsServer | NodeHttpServer): Promise<() => Promise<void>>;
10
18
  }
@@ -1,10 +1,25 @@
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
+ */
1
9
  import debug from '../debug.js';
2
10
  import { createServer } from 'node:http';
11
+ /**
12
+ * Http server utils are used to start the AdonisJS HTTP server
13
+ * during testing
14
+ */
3
15
  export class HttpServerUtils {
4
16
  #utils;
5
17
  constructor(utils) {
6
18
  this.#utils = utils;
7
19
  }
20
+ /**
21
+ * Starts the http server a given host and port
22
+ */
8
23
  #listen(nodeHttpServer) {
9
24
  return new Promise((resolve, reject) => {
10
25
  const host = process.env.HOST || '0.0.0.0';
@@ -19,6 +34,10 @@ export class HttpServerUtils {
19
34
  });
20
35
  });
21
36
  }
37
+ /**
38
+ * Testing hook to start the HTTP server to listen for new request.
39
+ * The return value is a function to close the HTTP server.
40
+ */
22
41
  async start(serverCallback) {
23
42
  const createHTTPServer = serverCallback || createServer;
24
43
  const server = await this.#utils.app.container.make('server');
@@ -1,19 +1,37 @@
1
- /// <reference types="node" resolution-mode="require"/>
1
+ /// <reference types="@types/node" resolution-mode="require"/>
2
2
  import Macroable from '@poppinss/macroable';
3
3
  import { IncomingMessage, ServerResponse } from 'node:http';
4
4
  import { HttpServerUtils } from './http.js';
5
+ import { CookieClient } from '../../modules/http/main.js';
5
6
  import type { ApplicationService } from '../types.js';
6
- import { CookieClient } from '../../modules/http.js';
7
+ /**
8
+ * Test utils has a collection of helper methods to make testing
9
+ * experience great for AdonisJS applications
10
+ */
7
11
  export declare class TestUtils extends Macroable {
8
12
  #private;
9
13
  app: ApplicationService;
14
+ /**
15
+ * Check if utils have been booted
16
+ */
10
17
  get isBooted(): boolean;
11
18
  cookies: CookieClient;
12
19
  constructor(app: ApplicationService);
20
+ /**
21
+ * Boot test utils. It requires the app to be booted
22
+ * and container to have all the bindings
23
+ */
13
24
  boot(): Promise<void>;
25
+ /**
26
+ * Returns an instance of the HTTP server testing
27
+ * utils
28
+ */
14
29
  httpServer(): HttpServerUtils;
30
+ /**
31
+ * Create an instance of HTTP context for testing
32
+ */
15
33
  createHttpContext(options?: {
16
34
  req?: IncomingMessage;
17
35
  res?: ServerResponse;
18
- }): Promise<import("../../modules/http.js").HttpContext>;
36
+ }): Promise<import("../../modules/http/main.js").HttpContext>;
19
37
  }
@@ -1,11 +1,26 @@
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
+ */
1
9
  import { Socket } from 'node:net';
2
10
  import Macroable from '@poppinss/macroable';
3
11
  import { IncomingMessage, ServerResponse } from 'node:http';
4
12
  import { HttpServerUtils } from './http.js';
5
- import { CookieClient } from '../../modules/http.js';
13
+ import { CookieClient } from '../../modules/http/main.js';
14
+ /**
15
+ * Test utils has a collection of helper methods to make testing
16
+ * experience great for AdonisJS applications
17
+ */
6
18
  export class TestUtils extends Macroable {
7
19
  app;
8
20
  #booted = false;
21
+ /**
22
+ * Check if utils have been booted
23
+ */
9
24
  get isBooted() {
10
25
  return this.#booted;
11
26
  }
@@ -13,15 +28,26 @@ export class TestUtils extends Macroable {
13
28
  super();
14
29
  this.app = app;
15
30
  }
31
+ /**
32
+ * Boot test utils. It requires the app to be booted
33
+ * and container to have all the bindings
34
+ */
16
35
  async boot() {
17
36
  if (!this.isBooted) {
18
37
  this.#booted = true;
19
38
  this.cookies = new CookieClient(await this.app.container.make('encryption'));
20
39
  }
21
40
  }
41
+ /**
42
+ * Returns an instance of the HTTP server testing
43
+ * utils
44
+ */
22
45
  httpServer() {
23
46
  return new HttpServerUtils(this);
24
47
  }
48
+ /**
49
+ * Create an instance of HTTP context for testing
50
+ */
25
51
  async createHttpContext(options = {}) {
26
52
  const req = options.req || new IncomingMessage(new Socket());
27
53
  const res = options.res || new ServerResponse(req);
@@ -1,53 +1,111 @@
1
+ import type { Repl } from '../modules/repl.js';
1
2
  import type { Importer } from '../types/app.js';
2
3
  import type { Emitter } from '../modules/events.js';
3
4
  import type { Kernel } from '../modules/ace/main.js';
4
5
  import type { Application } from '../modules/app.js';
5
6
  import type { TestUtils } from './test_utils/main.js';
6
- import type { Router, Server } from '../modules/http.js';
7
7
  import type { LoggerManager } from '../modules/logger.js';
8
8
  import type { Encryption } from '../modules/encryption.js';
9
+ import type { Router, Server } from '../modules/http/main.js';
9
10
  import type { HttpRequestFinishedPayload } from '../types/http.js';
11
+ import type { ContainerResolveEventData } from '../types/container.js';
10
12
  import type { LoggerConfig, LoggerManagerConfig } from '../types/logger.js';
11
- import type hashDriversCollection from '../modules/hash/drivers_collection.js';
12
13
  import type { Argon, Bcrypt, HashManager, Scrypt } from '../modules/hash/main.js';
13
14
  import type { ArgonConfig, BcryptConfig, ScryptConfig, ManagerDriverFactory } from '../types/hash.js';
15
+ /**
16
+ * Options accepted by ignitor
17
+ */
14
18
  export type IgnitorOptions = {
15
19
  importer: Importer;
16
20
  };
21
+ /**
22
+ * A list of known events. The interface must be extended in
23
+ * user land code or packages to register events and their
24
+ * types.
25
+ */
17
26
  export interface EventsList {
27
+ 'container:resolved': ContainerResolveEventData<ContainerBindings>;
18
28
  'http:request_handled': HttpRequestFinishedPayload;
19
29
  'http:server_ready': {
20
30
  port: number;
21
31
  host: string;
22
32
  };
23
33
  }
34
+ /**
35
+ * The loggers list inferred from the user application
36
+ * config
37
+ */
24
38
  export interface LoggersList {
25
39
  }
26
40
  export type InferLoggers<T extends LoggerManagerConfig<any>> = T['loggers'];
41
+ /**
42
+ * A list of globally available hash drivers
43
+ */
27
44
  export interface HashDriversList {
28
45
  bcrypt: (config: BcryptConfig) => Bcrypt;
29
46
  argon2: (config: ArgonConfig) => Argon;
30
47
  scrypt: (config: ScryptConfig) => Scrypt;
31
48
  }
49
+ /**
50
+ * A list of known hashers inferred from the user config
51
+ */
32
52
  export interface HashersList {
33
53
  }
34
54
  export type InferHashers<T extends {
35
55
  list: Record<string, ManagerDriverFactory>;
36
56
  }> = T['list'];
57
+ /**
58
+ * ----------------------------------------------------------------
59
+ * Container services
60
+ * -----------------------------------------------------------------
61
+ *
62
+ * Types for the container singleton services. Defining them
63
+ * upfront so that we do not have to define them in
64
+ * multiple places.
65
+ */
66
+ /**
67
+ * Application service is a singleton resolved from
68
+ * the container
69
+ */
37
70
  export interface ApplicationService extends Application<ContainerBindings extends Record<any, any> ? ContainerBindings : never> {
38
71
  }
72
+ /**
73
+ * Logger service is a singleton logger instance registered
74
+ * to the container.
75
+ */
39
76
  export interface LoggerService extends LoggerManager<LoggersList extends Record<string, LoggerConfig> ? LoggersList : never> {
40
77
  }
78
+ /**
79
+ * Emitter service is a singleton emitter instance registered
80
+ * to the container.
81
+ */
41
82
  export interface EmitterService extends Emitter<EventsList> {
42
83
  }
84
+ /**
85
+ * Encryption service is a singleton Encryption class instance
86
+ * registered to the container.
87
+ */
43
88
  export interface EncryptionService extends Encryption {
44
89
  }
90
+ /**
91
+ * Http server service added to the container as a singleton
92
+ */
45
93
  export interface HttpServerService extends Server {
46
94
  }
95
+ /**
96
+ * Http server service added to the container as a singleton
97
+ */
47
98
  export interface HttpRouterService extends Router {
48
99
  }
100
+ /**
101
+ * Hash service is a singleton instance of the HashManager
102
+ * registered in the container
103
+ */
49
104
  export interface HashService extends HashManager<HashersList extends Record<string, ManagerDriverFactory> ? HashersList : never> {
50
105
  }
106
+ /**
107
+ * A list of known container bindings.
108
+ */
51
109
  export interface ContainerBindings {
52
110
  ace: Kernel;
53
111
  app: ApplicationService;
@@ -56,8 +114,8 @@ export interface ContainerBindings {
56
114
  emitter: EmitterService;
57
115
  encryption: EncryptionService;
58
116
  hash: HashService;
59
- hashDrivers: typeof hashDriversCollection;
60
117
  server: HttpServerService;
61
118
  router: HttpRouterService;
62
119
  testUtils: TestUtils;
120
+ repl: Repl;
63
121
  }
@@ -1 +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
+ */
1
9
  export {};
@@ -0,0 +1 @@
1
+ import './validates_files.js';
@@ -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
+ import './validates_files.js';
@@ -0,0 +1,22 @@
1
+ import { BaseLiteralType } from '@vinejs/vine';
2
+ import type { FieldContext, FieldOptions, Validation } from '@vinejs/vine/types';
3
+ import type { MultipartFile, FileValidationOptions } from '@adonisjs/bodyparser/types';
4
+ type ValidationOptions = Partial<FileValidationOptions> | ((field: FieldContext) => Partial<FileValidationOptions>);
5
+ /**
6
+ * Represents a multipart file uploaded via multipart/form-data HTTP
7
+ * request.
8
+ */
9
+ declare class VineMultipartFile extends BaseLiteralType<MultipartFile, MultipartFile> {
10
+ #private;
11
+ constructor(validationOptions?: ValidationOptions, options?: FieldOptions, validations?: Validation<any>[]);
12
+ clone(): this;
13
+ }
14
+ /**
15
+ * Notifying TypeScript
16
+ */
17
+ declare module '@vinejs/vine' {
18
+ interface Vine {
19
+ file(options?: ValidationOptions): VineMultipartFile;
20
+ }
21
+ }
22
+ export {};
@@ -0,0 +1,76 @@
1
+ /*
2
+ * @adonisjs/core
3
+ *
4
+ * (c) AdonisJS
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+ import vine, { BaseLiteralType, Vine } from '@vinejs/vine';
10
+ /**
11
+ * Checks if the value is an instance of multipart file
12
+ * from bodyparser.
13
+ */
14
+ function isBodyParserFile(file) {
15
+ return !!(file && typeof file === 'object' && 'isMultipartFile' in file);
16
+ }
17
+ /**
18
+ * VineJS validation rule that validates the file to be an
19
+ * instance of BodyParser MultipartFile class.
20
+ */
21
+ const isMultipartFile = vine.createRule((file, options, field) => {
22
+ /**
23
+ * Report error when value is not a field multipart
24
+ * file object
25
+ */
26
+ if (!isBodyParserFile(file)) {
27
+ field.report('The {{ field }} must be a file', 'file', field);
28
+ return;
29
+ }
30
+ const validationOptions = typeof options === 'function' ? options(field) : options;
31
+ /**
32
+ * Set size when it's defined in the options and missing
33
+ * on the file instance
34
+ */
35
+ if (file.sizeLimit === undefined && validationOptions.size) {
36
+ file.sizeLimit = validationOptions.size;
37
+ }
38
+ /**
39
+ * Set extensions when it's defined in the options and missing
40
+ * on the file instance
41
+ */
42
+ if (file.allowedExtensions === undefined && validationOptions.extnames) {
43
+ file.allowedExtensions = validationOptions.extnames;
44
+ }
45
+ /**
46
+ * Validate file
47
+ */
48
+ file.validate();
49
+ /**
50
+ * Report errors
51
+ */
52
+ file.errors.forEach((error) => {
53
+ field.report(error.message, `file.${error.type}`, field, validationOptions);
54
+ });
55
+ });
56
+ /**
57
+ * Represents a multipart file uploaded via multipart/form-data HTTP
58
+ * request.
59
+ */
60
+ class VineMultipartFile extends BaseLiteralType {
61
+ #validationOptions;
62
+ constructor(validationOptions, options, validations) {
63
+ super(options, validations || [isMultipartFile(validationOptions || {})]);
64
+ this.#validationOptions = validationOptions;
65
+ }
66
+ clone() {
67
+ return new VineMultipartFile(this.#validationOptions, this.cloneOptions(), this.cloneValidations());
68
+ }
69
+ }
70
+ /**
71
+ * The file method is used to validate a field to be a valid
72
+ * multipart file.
73
+ */
74
+ Vine.macro('file', function (options) {
75
+ return new VineMultipartFile(options);
76
+ });
@@ -1,2 +1,10 @@
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
+ */
1
9
  import { getDirname } from '@poppinss/utils';
2
10
  export const stubsRoot = getDirname(import.meta.url);
@@ -0,0 +1,10 @@
1
+ {{#var exceptionName = generators.exceptionName(entity.name)}}
2
+ {{#var exceptionFileName = generators.exceptionFileName(entity.name)}}
3
+ ---
4
+ to: {{ app.exceptionsPath(entity.path, exceptionFileName) }}
5
+ ---
6
+ import { Exception } from '@adonisjs/core/exceptions'
7
+
8
+ export default class {{ exceptionName }} extends Exception {
9
+ static status = 500
10
+ }
@@ -0,0 +1,4 @@
1
+ {{#var preloadFileName = string(entity.name).snakeCase().removeExtension().ext('.ts').toString()}}
2
+ ---
3
+ to: {{ app.startPath(entity.path, preloadFileName) }}
4
+ ---
@@ -0,0 +1,4 @@
1
+ {{#var serviceFileName = generators.serviceFileName(entity.name)}}
2
+ ---
3
+ to: {{ app.servicesPath(entity.path, serviceFileName) }}
4
+ ---
@@ -0,0 +1,11 @@
1
+ {{#var testGroupName = generators.testGroupName(entity)}}
2
+ {{#var testFileName = generators.testFileName(entity.name)}}
3
+ ---
4
+ to: {{ app.makePath(suite.directory, entity.path, testFileName) }}
5
+ ---
6
+ import { test } from '@japa/runner'
7
+
8
+ test.group('{{ testGroupName }}', () => {
9
+ test('example test', async ({ assert }) => {
10
+ })
11
+ })
@@ -1,4 +1,8 @@
1
1
  import { BaseCommand } from '@adonisjs/ace';
2
+ /**
3
+ * Generates index of commands with a loader. Must be called against
4
+ * the TypeScript compiled output.
5
+ */
2
6
  export default class IndexCommand extends BaseCommand {
3
7
  static commandName: string;
4
8
  static description: string;
@@ -1,14 +1,23 @@
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
+ */
1
9
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
10
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
11
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
12
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
13
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
14
  };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
15
  import { join } from 'node:path';
11
16
  import { args, BaseCommand, IndexGenerator } from '@adonisjs/ace';
17
+ /**
18
+ * Generates index of commands with a loader. Must be called against
19
+ * the TypeScript compiled output.
20
+ */
12
21
  export default class IndexCommand extends BaseCommand {
13
22
  static commandName = 'index';
14
23
  static description = 'Create an index of commands along with a lazy loader';
@@ -17,6 +26,5 @@ export default class IndexCommand extends BaseCommand {
17
26
  }
18
27
  }
19
28
  __decorate([
20
- args.string({ description: 'Relative path from cwd to the commands directory' }),
21
- __metadata("design:type", String)
29
+ args.string({ description: 'Relative path from cwd to the commands directory' })
22
30
  ], IndexCommand.prototype, "commandsDir", void 0);
@@ -1,4 +1,12 @@
1
1
  #!/usr/bin/env node
2
+ /*
3
+ * @adonisjs/core
4
+ *
5
+ * (c) AdonisJS
6
+ *
7
+ * For the full copyright and license information, please view the LICENSE
8
+ * file that was distributed with this source code.
9
+ */
2
10
  import IndexCommand from './commands/index_commands.js';
3
11
  import { Kernel, ListLoader, HelpCommand } from '@adonisjs/ace';
4
12
  const kernel = Kernel.create();
@@ -7,6 +15,9 @@ kernel.defineFlag('help', {
7
15
  type: 'boolean',
8
16
  description: HelpCommand.description,
9
17
  });
18
+ /**
19
+ * Flag listener to display the help
20
+ */
10
21
  kernel.on('help', async (command, $kernel, parsed) => {
11
22
  parsed.args.unshift(command.commandName);
12
23
  const help = new HelpCommand($kernel, parsed, kernel.ui, kernel.prompt);
@@ -1 +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
+ */
1
9
  export * from '@adonisjs/ace/types';
@@ -1 +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
+ */
1
9
  export * from '@adonisjs/application/types';