@adonisjs/core 6.1.5-2 → 6.1.5-21

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 (189) 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 +30 -3
  5. package/build/commands/configure.js +103 -25
  6. package/build/commands/eject.d.ts +4 -0
  7. package/build/commands/eject.js +16 -8
  8. package/build/commands/generate_key.d.ts +4 -0
  9. package/build/commands/generate_key.js +15 -8
  10. package/build/commands/inspect_rcfile.d.ts +9 -0
  11. package/build/commands/inspect_rcfile.js +36 -0
  12. package/build/commands/list/routes.d.ts +23 -0
  13. package/build/commands/list/routes.js +29 -13
  14. package/build/commands/main.d.ts +4 -0
  15. package/build/commands/make/command.d.ts +7 -1
  16. package/build/commands/make/command.js +20 -7
  17. package/build/commands/make/controller.d.ts +10 -1
  18. package/build/commands/make/controller.js +35 -14
  19. package/build/commands/make/event.d.ts +7 -1
  20. package/build/commands/make/event.js +20 -8
  21. package/build/commands/make/exception.d.ts +14 -0
  22. package/build/commands/make/exception.js +37 -0
  23. package/build/commands/make/listener.d.ts +8 -1
  24. package/build/commands/make/listener.js +28 -12
  25. package/build/commands/make/middleware.d.ts +8 -1
  26. package/build/commands/make/middleware.js +21 -8
  27. package/build/commands/make/preload.d.ts +22 -0
  28. package/build/commands/make/preload.js +99 -0
  29. package/build/commands/make/provider.d.ts +7 -1
  30. package/build/commands/make/provider.js +28 -8
  31. package/build/commands/make/service.d.ts +14 -0
  32. package/build/commands/make/service.js +37 -0
  33. package/build/commands/make/test.d.ts +10 -1
  34. package/build/commands/make/test.js +46 -10
  35. package/build/commands/make/validator.d.ts +14 -0
  36. package/build/commands/make/validator.js +37 -0
  37. package/build/commands/make/view.d.ts +14 -0
  38. package/build/commands/make/view.js +37 -0
  39. package/build/commands/repl.d.ts +14 -0
  40. package/build/commands/repl.js +30 -0
  41. package/build/commands/serve.d.ts +12 -0
  42. package/build/commands/serve.js +78 -27
  43. package/build/commands/test.d.ts +32 -0
  44. package/build/commands/test.js +203 -0
  45. package/build/factories/app.js +8 -0
  46. package/build/factories/bodyparser.js +8 -0
  47. package/build/factories/core/ace.d.ts +4 -1
  48. package/build/factories/core/ace.js +11 -0
  49. package/build/factories/core/ignitor.d.ts +20 -1
  50. package/build/factories/core/ignitor.js +35 -1
  51. package/build/factories/core/main.js +8 -0
  52. package/build/factories/core/test_utils.d.ts +4 -1
  53. package/build/factories/core/test_utils.js +11 -0
  54. package/build/factories/encryption.js +8 -0
  55. package/build/factories/events.js +8 -0
  56. package/build/factories/hash.js +8 -0
  57. package/build/factories/http.js +8 -0
  58. package/build/factories/logger.js +8 -0
  59. package/build/factories/stubs.d.ts +10 -0
  60. package/build/factories/stubs.js +23 -1
  61. package/build/index.d.ts +6 -2
  62. package/build/index.js +14 -1
  63. package/build/modules/ace/codemods.d.ts +54 -0
  64. package/build/modules/ace/codemods.js +133 -0
  65. package/build/modules/ace/commands.d.ts +48 -0
  66. package/build/modules/ace/commands.js +54 -0
  67. package/build/modules/ace/create_kernel.d.ts +9 -0
  68. package/build/modules/ace/create_kernel.js +32 -1
  69. package/build/modules/ace/kernel.d.ts +4 -0
  70. package/build/modules/ace/kernel.js +12 -0
  71. package/build/modules/ace/main.js +8 -0
  72. package/build/modules/ace/shell.d.ts +9 -1
  73. package/build/modules/ace/shell.js +21 -0
  74. package/build/modules/app.js +8 -0
  75. package/build/modules/bodyparser/bodyparser_middleware.d.ts +4 -0
  76. package/build/modules/bodyparser/bodyparser_middleware.js +12 -0
  77. package/build/modules/bodyparser/main.js +8 -0
  78. package/build/modules/config.js +8 -0
  79. package/build/modules/container.js +8 -0
  80. package/build/modules/encryption.js +8 -0
  81. package/build/modules/env.js +8 -0
  82. package/build/modules/events.js +8 -0
  83. package/build/modules/hash/define_config.d.ts +4 -0
  84. package/build/modules/hash/define_config.js +23 -0
  85. package/build/modules/hash/drivers/argon.d.ts +1 -0
  86. package/build/modules/hash/drivers/argon.js +9 -0
  87. package/build/modules/hash/drivers/bcrypt.d.ts +1 -0
  88. package/build/modules/hash/drivers/bcrypt.js +9 -0
  89. package/build/modules/hash/drivers/scrypt.d.ts +1 -0
  90. package/build/modules/hash/drivers/scrypt.js +9 -0
  91. package/build/modules/hash/drivers_collection.d.ts +16 -4
  92. package/build/modules/hash/drivers_collection.js +31 -8
  93. package/build/modules/hash/main.d.ts +1 -0
  94. package/build/modules/hash/main.js +9 -0
  95. package/build/modules/http/main.d.ts +2 -0
  96. package/build/modules/http/main.js +10 -0
  97. package/build/modules/http/request_validator.d.ts +34 -0
  98. package/build/modules/http/request_validator.js +66 -0
  99. package/build/modules/logger.js +8 -0
  100. package/build/modules/repl.d.ts +1 -0
  101. package/build/modules/repl.js +9 -0
  102. package/build/providers/app_provider.d.ts +31 -2
  103. package/build/providers/app_provider.js +44 -15
  104. package/build/providers/edge_provider.d.ts +31 -0
  105. package/build/providers/edge_provider.js +69 -0
  106. package/build/providers/hash_provider.d.ts +22 -2
  107. package/build/providers/hash_provider.js +49 -7
  108. package/build/providers/http_provider.d.ts +17 -0
  109. package/build/providers/http_provider.js +26 -1
  110. package/build/providers/repl_provider.d.ts +13 -0
  111. package/build/providers/repl_provider.js +98 -0
  112. package/build/providers/vinejs_provider.d.ts +33 -0
  113. package/build/providers/vinejs_provider.js +84 -0
  114. package/build/services/ace.js +15 -0
  115. package/build/services/app.d.ts +8 -0
  116. package/build/services/app.js +16 -0
  117. package/build/services/config.js +11 -0
  118. package/build/services/emitter.js +13 -2
  119. package/build/services/encryption.js +13 -2
  120. package/build/services/hash.js +13 -2
  121. package/build/services/logger.js +13 -2
  122. package/build/services/repl.d.ts +3 -0
  123. package/build/services/repl.js +18 -0
  124. package/build/services/router.js +13 -2
  125. package/build/services/server.js +13 -2
  126. package/build/services/test_utils.js +15 -0
  127. package/build/src/cli_formatters/routes_list.d.ts +24 -1
  128. package/build/src/cli_formatters/routes_list.js +118 -0
  129. package/build/src/debug.d.ts +1 -1
  130. package/build/src/debug.js +8 -0
  131. package/build/src/exceptions.d.ts +1 -0
  132. package/build/src/exceptions.js +9 -0
  133. package/build/src/helpers/is.js +8 -0
  134. package/build/src/helpers/main.d.ts +1 -1
  135. package/build/src/helpers/main.js +9 -1
  136. package/build/src/helpers/parse_binding_reference.d.ts +40 -0
  137. package/build/src/helpers/parse_binding_reference.js +60 -0
  138. package/build/src/helpers/string.d.ts +26 -0
  139. package/build/src/helpers/string.js +15 -0
  140. package/build/src/helpers/types.d.ts +114 -16
  141. package/build/src/helpers/types.js +13 -0
  142. package/build/src/ignitor/ace.d.ts +12 -0
  143. package/build/src/ignitor/ace.js +50 -1
  144. package/build/src/ignitor/http.d.ts +9 -2
  145. package/build/src/ignitor/http.js +67 -0
  146. package/build/src/ignitor/main.d.ts +29 -1
  147. package/build/src/ignitor/main.js +56 -0
  148. package/build/src/ignitor/test.d.ts +10 -0
  149. package/build/src/ignitor/test.js +25 -0
  150. package/build/src/internal_helpers.d.ts +12 -5
  151. package/build/src/internal_helpers.js +35 -7
  152. package/build/src/test_utils/http.d.ts +10 -2
  153. package/build/src/test_utils/http.js +19 -0
  154. package/build/src/test_utils/main.d.ts +21 -3
  155. package/build/src/test_utils/main.js +27 -1
  156. package/build/src/types.d.ts +65 -4
  157. package/build/src/types.js +8 -0
  158. package/build/stubs/main.js +10 -0
  159. package/build/stubs/make/exception/main.stub +10 -0
  160. package/build/stubs/make/preload_file/main.stub +4 -0
  161. package/build/stubs/make/service/main.stub +4 -0
  162. package/build/stubs/make/validator/main.stub +5 -0
  163. package/build/stubs/make/view/main.stub +4 -0
  164. package/build/toolkit/commands/index_commands.d.ts +4 -0
  165. package/build/toolkit/commands/index_commands.js +13 -5
  166. package/build/toolkit/main.js +11 -0
  167. package/build/types/ace.js +8 -0
  168. package/build/types/app.js +8 -0
  169. package/build/types/bodyparser.js +8 -0
  170. package/build/types/container.js +8 -0
  171. package/build/types/encryption.js +8 -0
  172. package/build/types/events.js +8 -0
  173. package/build/types/hash.js +8 -0
  174. package/build/types/http.d.ts +7 -0
  175. package/build/types/http.js +8 -0
  176. package/build/types/logger.js +8 -0
  177. package/build/types/repl.d.ts +1 -0
  178. package/build/types/repl.js +9 -0
  179. package/package.json +83 -121
  180. package/build/commands/make/_base.d.ts +0 -6
  181. package/build/commands/make/_base.js +0 -19
  182. package/build/legacy/validator.d.ts +0 -1
  183. package/build/legacy/validator.js +0 -1
  184. package/build/modules/http.d.ts +0 -1
  185. package/build/modules/http.js +0 -1
  186. package/build/src/helpers/string_builder.d.ts +0 -23
  187. package/build/src/helpers/string_builder.js +0 -86
  188. package/build/stubs/index.js +0 -2
  189. /package/build/stubs/{index.d.ts → main.d.ts} +0 -0
@@ -1,9 +1,29 @@
1
- import type { ApplicationService } from '../src/types.js';
1
+ import type { ApplicationService, HashDriversList } from '../src/types.js';
2
+ /**
3
+ * Registers the passwords hasher with the container
4
+ */
2
5
  export default class HashServiceProvider {
3
6
  protected app: ApplicationService;
4
7
  constructor(app: ApplicationService);
5
- protected registerHashDrivers(): void;
8
+ /**
9
+ * Lazily registers a hash driver with the driversList collection
10
+ */
11
+ protected registerHashDrivers(driversInUse: Set<keyof HashDriversList>): Promise<void>;
12
+ /**
13
+ * Registering the hash class to resolve an instance with the
14
+ * default hasher.
15
+ */
6
16
  protected registerHash(): void;
17
+ /**
18
+ * Registers the hash manager with the container
19
+ */
7
20
  protected registerHashManager(): void;
21
+ /**
22
+ * Registers bindings
23
+ */
8
24
  register(): void;
25
+ /**
26
+ * Register drivers based upon hash config
27
+ */
28
+ boot(): void;
9
29
  }
@@ -1,29 +1,71 @@
1
- import { Hash, HashManager } from '../modules/hash/main.js';
2
- import hashDriversCollection from '../modules/hash/drivers_collection.js';
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 { Hash, driversList } from '../modules/hash/main.js';
10
+ /**
11
+ * Registers the passwords hasher with the container
12
+ */
3
13
  export default class HashServiceProvider {
4
14
  app;
5
15
  constructor(app) {
6
16
  this.app = app;
7
17
  }
8
- registerHashDrivers() {
9
- this.app.container.singleton('hashDrivers', () => hashDriversCollection);
18
+ /**
19
+ * Lazily registers a hash driver with the driversList collection
20
+ */
21
+ async registerHashDrivers(driversInUse) {
22
+ if (driversInUse.has('bcrypt')) {
23
+ const { Bcrypt } = await import('../modules/hash/drivers/bcrypt.js');
24
+ driversList.extend('bcrypt', (config) => new Bcrypt(config));
25
+ }
26
+ if (driversInUse.has('scrypt')) {
27
+ const { Scrypt } = await import('../modules/hash/drivers/scrypt.js');
28
+ driversList.extend('scrypt', (config) => new Scrypt(config));
29
+ }
30
+ if (driversInUse.has('argon2')) {
31
+ const { Argon } = await import('../modules/hash/drivers/argon.js');
32
+ driversList.extend('argon2', (config) => new Argon(config));
33
+ }
10
34
  }
35
+ /**
36
+ * Registering the hash class to resolve an instance with the
37
+ * default hasher.
38
+ */
11
39
  registerHash() {
12
40
  this.app.container.singleton(Hash, async (resolver) => {
13
41
  const hashManager = await resolver.make('hash');
14
42
  return hashManager.use();
15
43
  });
16
44
  }
45
+ /**
46
+ * Registers the hash manager with the container
47
+ */
17
48
  registerHashManager() {
18
- this.app.container.singleton(HashManager, async () => {
49
+ this.app.container.singleton('hash', async () => {
19
50
  const config = this.app.config.get('hash');
51
+ const { HashManager } = await import('../modules/hash/main.js');
20
52
  return new HashManager(config);
21
53
  });
22
- this.app.container.alias('hash', HashManager);
23
54
  }
55
+ /**
56
+ * Registers bindings
57
+ */
24
58
  register() {
25
59
  this.registerHashManager();
26
- this.registerHashDrivers();
27
60
  this.registerHash();
28
61
  }
62
+ /**
63
+ * Register drivers based upon hash config
64
+ */
65
+ boot() {
66
+ this.app.container.resolving('hash', async () => {
67
+ const config = this.app.config.get('hash');
68
+ await this.registerHashDrivers(config.driversInUse);
69
+ });
70
+ }
29
71
  }
@@ -1,9 +1,26 @@
1
1
  import type { ApplicationService } from '../src/types.js';
2
+ /**
3
+ * Http Service provider binds the router and the HTTP server to
4
+ * the container.
5
+ */
2
6
  export default class HttpServiceProvider {
3
7
  protected app: ApplicationService;
4
8
  constructor(app: ApplicationService);
9
+ /**
10
+ * Registers the HTTP server with the container as a singleton
11
+ */
5
12
  protected registerServer(): void;
13
+ /**
14
+ * Registers router with the container as a singleton
15
+ */
6
16
  protected registerRouter(): void;
17
+ /**
18
+ * Self construct bodyparser middleware class, since it needs
19
+ * config that cannot be resolved by the container
20
+ */
7
21
  protected registerBodyParserMiddleware(): void;
22
+ /**
23
+ * Registers bindings
24
+ */
8
25
  register(): void;
9
26
  }
@@ -1,10 +1,25 @@
1
- import { Router, Server } from '../modules/http.js';
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 { Router, Server } from '../modules/http/main.js';
2
10
  import BodyParserMiddleware from '../modules/bodyparser/bodyparser_middleware.js';
11
+ /**
12
+ * Http Service provider binds the router and the HTTP server to
13
+ * the container.
14
+ */
3
15
  export default class HttpServiceProvider {
4
16
  app;
5
17
  constructor(app) {
6
18
  this.app = app;
7
19
  }
20
+ /**
21
+ * Registers the HTTP server with the container as a singleton
22
+ */
8
23
  registerServer() {
9
24
  this.app.container.singleton(Server, async (resolver) => {
10
25
  const encryption = await resolver.make('encryption');
@@ -15,6 +30,9 @@ export default class HttpServiceProvider {
15
30
  });
16
31
  this.app.container.alias('server', Server);
17
32
  }
33
+ /**
34
+ * Registers router with the container as a singleton
35
+ */
18
36
  registerRouter() {
19
37
  this.app.container.singleton(Router, async (resolver) => {
20
38
  const server = await resolver.make('server');
@@ -22,12 +40,19 @@ export default class HttpServiceProvider {
22
40
  });
23
41
  this.app.container.alias('router', Router);
24
42
  }
43
+ /**
44
+ * Self construct bodyparser middleware class, since it needs
45
+ * config that cannot be resolved by the container
46
+ */
25
47
  registerBodyParserMiddleware() {
26
48
  this.app.container.bind(BodyParserMiddleware, () => {
27
49
  const config = this.app.config.get('bodyparser');
28
50
  return new BodyParserMiddleware(config);
29
51
  });
30
52
  }
53
+ /**
54
+ * Registers bindings
55
+ */
31
56
  register() {
32
57
  this.registerServer();
33
58
  this.registerRouter();
@@ -0,0 +1,13 @@
1
+ import type { ApplicationService } from '../src/types.js';
2
+ export default class ReplServiceProvider {
3
+ protected app: ApplicationService;
4
+ constructor(app: ApplicationService);
5
+ /**
6
+ * Registers the REPL binding
7
+ */
8
+ register(): void;
9
+ /**
10
+ * Registering REPL bindings during provider boot
11
+ */
12
+ boot(): Promise<void>;
13
+ }
@@ -0,0 +1,98 @@
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 { join } from 'node:path';
10
+ import { homedir } from 'node:os';
11
+ /**
12
+ * Resolves a container binding and sets it on the REPL
13
+ * context
14
+ */
15
+ async function resolveBindingForRepl(app, repl, binding) {
16
+ repl.server.context[binding] = await app.container.make(binding);
17
+ repl.notify(`Loaded "${binding}" service. You can access it using the "${repl.colors.underline(binding)}" variable`);
18
+ }
19
+ export default class ReplServiceProvider {
20
+ app;
21
+ constructor(app) {
22
+ this.app = app;
23
+ }
24
+ /**
25
+ * Registers the REPL binding
26
+ */
27
+ register() {
28
+ this.app.container.singleton('repl', async () => {
29
+ const { Repl } = await import('../modules/repl.js');
30
+ return new Repl({
31
+ historyFilePath: join(homedir(), '.adonisjs_v6_repl_history'),
32
+ });
33
+ });
34
+ }
35
+ /**
36
+ * Registering REPL bindings during provider boot
37
+ */
38
+ async boot() {
39
+ const repl = await this.app.container.make('repl');
40
+ repl.addMethod('importDefault', (_, modulePath) => {
41
+ return this.app.importDefault(modulePath);
42
+ }, {
43
+ description: 'Returns the default export for a module',
44
+ });
45
+ repl.addMethod('make', (_, service, runtimeValues) => {
46
+ return this.app.container.make(service, runtimeValues);
47
+ }, {
48
+ description: 'Make class instance using "container.make" method',
49
+ });
50
+ repl.addMethod('loadApp', () => {
51
+ return resolveBindingForRepl(this.app, repl, 'app');
52
+ }, {
53
+ description: 'Load "app" service in the REPL context',
54
+ });
55
+ repl.addMethod('loadEncryption', () => {
56
+ return resolveBindingForRepl(this.app, repl, 'encryption');
57
+ }, {
58
+ description: 'Load "encryption" service in the REPL context',
59
+ });
60
+ repl.addMethod('loadHash', () => {
61
+ return resolveBindingForRepl(this.app, repl, 'hash');
62
+ }, {
63
+ description: 'Load "hash" service in the REPL context',
64
+ });
65
+ repl.addMethod('loadRouter', () => {
66
+ return resolveBindingForRepl(this.app, repl, 'router');
67
+ }, {
68
+ description: 'Load "router" service in the REPL context',
69
+ });
70
+ repl.addMethod('loadConfig', () => {
71
+ return resolveBindingForRepl(this.app, repl, 'config');
72
+ }, {
73
+ description: 'Load "config" service in the REPL context',
74
+ });
75
+ repl.addMethod('loadTestUtils', () => {
76
+ return resolveBindingForRepl(this.app, repl, 'testUtils');
77
+ }, {
78
+ description: 'Load "testUtils" service in the REPL context',
79
+ });
80
+ repl.addMethod('loadHelpers', async () => {
81
+ const { default: isModule } = await import('../src/helpers/is.js');
82
+ const { default: stringModule } = await import('../src/helpers/string.js');
83
+ const { base64, cuid, fsReadAll, slash, parseImports } = await import('../src/helpers/main.js');
84
+ repl.server.context.helpers = {
85
+ string: stringModule,
86
+ is: isModule,
87
+ base64,
88
+ cuid,
89
+ fsReadAll,
90
+ slash,
91
+ parseImports,
92
+ };
93
+ repl.notify(`Loaded "helpers" module. You can access it using the "${repl.colors.underline('helpers')}" variable`);
94
+ }, {
95
+ description: 'Load "helpers" module in the REPL context',
96
+ });
97
+ }
98
+ }
@@ -0,0 +1,33 @@
1
+ import { BaseLiteralType } from '@vinejs/vine';
2
+ import type { Validation, FieldContext, FieldOptions } from '@vinejs/vine/types';
3
+ import type { MultipartFile, FileValidationOptions } from '@adonisjs/bodyparser/types';
4
+ import { RequestValidator } from '../modules/http/main.js';
5
+ /**
6
+ * Validation options accepted by the "file" rule
7
+ */
8
+ export type FileRuleValidationOptions = Partial<FileValidationOptions> | ((field: FieldContext) => Partial<FileValidationOptions>);
9
+ /**
10
+ * Extend VineJS
11
+ */
12
+ declare module '@vinejs/vine' {
13
+ interface Vine {
14
+ file(options?: FileRuleValidationOptions): VineMultipartFile;
15
+ }
16
+ }
17
+ /**
18
+ * Extend HTTP request class
19
+ */
20
+ declare module '@adonisjs/core/http' {
21
+ interface Request extends RequestValidator {
22
+ }
23
+ }
24
+ /**
25
+ * Represents a multipart file uploaded via multipart/form-data HTTP
26
+ * request.
27
+ */
28
+ declare class VineMultipartFile extends BaseLiteralType<MultipartFile, MultipartFile> {
29
+ #private;
30
+ constructor(validationOptions?: FileRuleValidationOptions, options?: FieldOptions, validations?: Validation<any>[]);
31
+ clone(): this;
32
+ }
33
+ export {};
@@ -0,0 +1,84 @@
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
+ import { Request, RequestValidator } from '../modules/http/main.js';
11
+ /**
12
+ * Checks if the value is an instance of multipart file
13
+ * from bodyparser.
14
+ */
15
+ function isBodyParserFile(file) {
16
+ return !!(file && typeof file === 'object' && 'isMultipartFile' in file);
17
+ }
18
+ /**
19
+ * VineJS validation rule that validates the file to be an
20
+ * instance of BodyParser MultipartFile class.
21
+ */
22
+ const isMultipartFile = vine.createRule((file, options, field) => {
23
+ /**
24
+ * Report error when value is not a field multipart
25
+ * file object
26
+ */
27
+ if (!isBodyParserFile(file)) {
28
+ field.report('The {{ field }} must be a file', 'file', field);
29
+ return;
30
+ }
31
+ const validationOptions = typeof options === 'function' ? options(field) : options;
32
+ /**
33
+ * Set size when it's defined in the options and missing
34
+ * on the file instance
35
+ */
36
+ if (file.sizeLimit === undefined && validationOptions.size) {
37
+ file.sizeLimit = validationOptions.size;
38
+ }
39
+ /**
40
+ * Set extensions when it's defined in the options and missing
41
+ * on the file instance
42
+ */
43
+ if (file.allowedExtensions === undefined && validationOptions.extnames) {
44
+ file.allowedExtensions = validationOptions.extnames;
45
+ }
46
+ /**
47
+ * Validate file
48
+ */
49
+ file.validate();
50
+ /**
51
+ * Report errors
52
+ */
53
+ file.errors.forEach((error) => {
54
+ field.report(error.message, `file.${error.type}`, field, validationOptions);
55
+ });
56
+ });
57
+ /**
58
+ * Represents a multipart file uploaded via multipart/form-data HTTP
59
+ * request.
60
+ */
61
+ class VineMultipartFile extends BaseLiteralType {
62
+ #validationOptions;
63
+ constructor(validationOptions, options, validations) {
64
+ super(options, validations || [isMultipartFile(validationOptions || {})]);
65
+ this.#validationOptions = validationOptions;
66
+ }
67
+ clone() {
68
+ return new VineMultipartFile(this.#validationOptions, this.cloneOptions(), this.cloneValidations());
69
+ }
70
+ }
71
+ /**
72
+ * The file method is used to validate a field to be a valid
73
+ * multipart file.
74
+ */
75
+ Vine.macro('file', function (options) {
76
+ return new VineMultipartFile(options);
77
+ });
78
+ /**
79
+ * The validate method can be used to validate the request
80
+ * data for the current request using VineJS validators
81
+ */
82
+ Request.macro('validateUsing', function (...args) {
83
+ return new RequestValidator(this.ctx).validateUsing(...args);
84
+ });
@@ -1,5 +1,20 @@
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 app from './app.js';
2
10
  let ace;
11
+ /**
12
+ * Returns a singleton instance of the ace kernel
13
+ * from the container.
14
+ *
15
+ * ace service is an instance of the "Kernel" class stored inside
16
+ * the "modules/ace/kernel.ts" file
17
+ */
3
18
  await app.booted(async () => {
4
19
  ace = await app.container.make('ace');
5
20
  });
@@ -1,4 +1,12 @@
1
1
  import type { ApplicationService } from '../src/types.js';
2
2
  declare let app: ApplicationService;
3
+ /**
4
+ * Set the application instance the app service should
5
+ * be using. Other services relies on the same app
6
+ * instance as well.
7
+ *
8
+ * app service is an instance of the "Application" exported from
9
+ * the "modules/app.ts" file.
10
+ */
3
11
  export declare function setApp(appService: ApplicationService): void;
4
12
  export { app as default };
@@ -1,4 +1,20 @@
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
  let app;
10
+ /**
11
+ * Set the application instance the app service should
12
+ * be using. Other services relies on the same app
13
+ * instance as well.
14
+ *
15
+ * app service is an instance of the "Application" exported from
16
+ * the "modules/app.ts" file.
17
+ */
2
18
  export function setApp(appService) {
3
19
  app = appService;
4
20
  }
@@ -1,5 +1,16 @@
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 app from './app.js';
2
10
  let config;
11
+ /**
12
+ * The config service uses the config instance from the app service
13
+ */
3
14
  await app.booted(() => {
4
15
  config = app.config;
5
16
  });
@@ -1,7 +1,18 @@
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 app from './app.js';
2
- import { Emitter } from '../modules/events.js';
3
10
  let emitter;
11
+ /**
12
+ * Returns a singleton instance of the emitter class
13
+ * from the container
14
+ */
4
15
  await app.booted(async () => {
5
- emitter = await app.container.make(Emitter);
16
+ emitter = await app.container.make('emitter');
6
17
  });
7
18
  export { emitter as default };
@@ -1,7 +1,18 @@
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 app from './app.js';
2
- import { Encryption } from '../modules/encryption.js';
3
10
  let encryption;
11
+ /**
12
+ * Returns a singleton instance of the encryption class
13
+ * from the container
14
+ */
4
15
  await app.booted(async () => {
5
- encryption = await app.container.make(Encryption);
16
+ encryption = await app.container.make('encryption');
6
17
  });
7
18
  export { encryption as default };
@@ -1,7 +1,18 @@
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 app from './app.js';
2
- import { HashManager } from '../modules/hash/main.js';
3
10
  let hash;
11
+ /**
12
+ * Returns a singleton instance of the Hash manager from the
13
+ * container
14
+ */
4
15
  await app.booted(async () => {
5
- hash = await app.container.make(HashManager);
16
+ hash = await app.container.make('hash');
6
17
  });
7
18
  export { hash as default };
@@ -1,7 +1,18 @@
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 app from './app.js';
2
- import { LoggerManager } from '@adonisjs/logger';
3
10
  let logger;
11
+ /**
12
+ * Returns a singleton instance of the logger class
13
+ * from the container
14
+ */
4
15
  await app.booted(async () => {
5
- logger = (await app.container.make(LoggerManager));
16
+ logger = await app.container.make('logger');
6
17
  });
7
18
  export { logger as default };
@@ -0,0 +1,3 @@
1
+ import type { Repl } from '../modules/repl.js';
2
+ declare let repl: Repl;
3
+ export { repl as default };
@@ -0,0 +1,18 @@
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 app from './app.js';
10
+ let repl;
11
+ /**
12
+ * Returns a singleton instance of the Repl class from
13
+ * the container
14
+ */
15
+ await app.booted(async () => {
16
+ repl = await app.container.make('repl');
17
+ });
18
+ export { repl as default };
@@ -1,7 +1,18 @@
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 app from './app.js';
2
- import { Router } from '../modules/http.js';
3
10
  let router;
11
+ /**
12
+ * Returns a singleton instance of the router class from
13
+ * the container
14
+ */
4
15
  await app.booted(async () => {
5
- router = await app.container.make(Router);
16
+ router = await app.container.make('router');
6
17
  });
7
18
  export { router as default };
@@ -1,7 +1,18 @@
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 app from './app.js';
2
- import { Server } from '../modules/http.js';
3
10
  let server;
11
+ /**
12
+ * Returns a singleton instance of the HTTP server
13
+ * from the container
14
+ */
4
15
  await app.booted(async () => {
5
- server = await app.container.make(Server);
16
+ server = await app.container.make('server');
6
17
  });
7
18
  export { server as default };
@@ -1,5 +1,20 @@
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 app from './app.js';
2
10
  let testUtils;
11
+ /**
12
+ * Returns a singleton instance of the TestUtils class
13
+ * from the container.
14
+ *
15
+ * testUtils service is an instance of the "TestUtils" exported from
16
+ * the "src/test_utils/main.ts" file.
17
+ */
3
18
  await app.booted(async () => {
4
19
  testUtils = await app.container.make('testUtils');
5
20
  });