@adonisjs/core 6.18.0 → 6.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -0
- package/build/providers/vinejs_provider.d.ts +1 -19
- package/build/providers/vinejs_provider.js +2 -63
- package/build/src/helpers/types.d.ts +1 -0
- package/build/src/vine.d.ts +19 -0
- package/build/src/vine.js +71 -0
- package/package.json +36 -35
package/README.md
CHANGED
|
@@ -1,5 +1,66 @@
|
|
|
1
1
|
# @adonisjs/core
|
|
2
2
|
|
|
3
|
+
**Featured sponsors**
|
|
4
|
+
|
|
5
|
+
<table>
|
|
6
|
+
|
|
7
|
+
<tr>
|
|
8
|
+
<td>
|
|
9
|
+
|
|
10
|
+
<a href="https://route4me.com/?utm_source=adonisjs.com">
|
|
11
|
+
<img src="https://raw.githubusercontent.com/thetutlage/static/refs/heads/main/featured_sponsors/logos/route4me.jpg" />
|
|
12
|
+
</a>
|
|
13
|
+
|
|
14
|
+
</td>
|
|
15
|
+
|
|
16
|
+
<td>
|
|
17
|
+
|
|
18
|
+
<a href="https://ezycourse.com/?utm_source=adonisjs.com">
|
|
19
|
+
<img src="https://raw.githubusercontent.com/thetutlage/static/refs/heads/main/featured_sponsors/logos/ezycourse.jpg" />
|
|
20
|
+
</a>
|
|
21
|
+
|
|
22
|
+
</td>
|
|
23
|
+
|
|
24
|
+
</tr>
|
|
25
|
+
|
|
26
|
+
<tr>
|
|
27
|
+
|
|
28
|
+
<td>
|
|
29
|
+
|
|
30
|
+
<a href="https://meteor.software/g6h?utm_source=adonisjs.com">
|
|
31
|
+
<img src="https://raw.githubusercontent.com/thetutlage/static/refs/heads/main/featured_sponsors/logos/galaxy.jpg" />
|
|
32
|
+
</a>
|
|
33
|
+
|
|
34
|
+
</td>
|
|
35
|
+
|
|
36
|
+
<td>
|
|
37
|
+
|
|
38
|
+
<a href="https://www.lambdatest.com/?utm_source=adonisjs.com">
|
|
39
|
+
<img src="https://raw.githubusercontent.com/thetutlage/static/refs/heads/main/featured_sponsors/logos/lambdatest.jpg" />
|
|
40
|
+
</a>
|
|
41
|
+
|
|
42
|
+
</td>
|
|
43
|
+
|
|
44
|
+
</tr>
|
|
45
|
+
|
|
46
|
+
<tr>
|
|
47
|
+
|
|
48
|
+
<td>
|
|
49
|
+
|
|
50
|
+
<a href="https://relancer.com/?utm_source=adonisjs.com">
|
|
51
|
+
<img src="https://raw.githubusercontent.com/thetutlage/static/refs/heads/main/featured_sponsors/logos/relancer.jpg" />
|
|
52
|
+
</a>
|
|
53
|
+
|
|
54
|
+
</td>
|
|
55
|
+
|
|
56
|
+
<td>
|
|
57
|
+
|
|
58
|
+
</td>
|
|
59
|
+
|
|
60
|
+
</tr>
|
|
61
|
+
|
|
62
|
+
</table>
|
|
63
|
+
|
|
3
64
|

|
|
4
65
|
|
|
5
66
|
<hr>
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
import { symbols, BaseLiteralType } from '@vinejs/vine';
|
|
2
|
-
import type { Validation, FieldContext, FieldOptions } from '@vinejs/vine/types';
|
|
3
|
-
import type { MultipartFile, FileValidationOptions } from '@adonisjs/bodyparser/types';
|
|
4
1
|
import type { ApplicationService } from '../src/types.js';
|
|
5
2
|
import { RequestValidator } from '../modules/http/main.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Validation options accepted by the "file" rule
|
|
9
|
-
*/
|
|
10
|
-
export type FileRuleValidationOptions = Partial<FileValidationOptions> | ((field: FieldContext) => Partial<FileValidationOptions>);
|
|
3
|
+
import { FileRuleValidationOptions, VineMultipartFile } from '../src/vine.js';
|
|
11
4
|
/**
|
|
12
5
|
* Extend VineJS
|
|
13
6
|
*/
|
|
@@ -23,16 +16,6 @@ declare module '@adonisjs/core/http' {
|
|
|
23
16
|
interface Request extends RequestValidator {
|
|
24
17
|
}
|
|
25
18
|
}
|
|
26
|
-
/**
|
|
27
|
-
* Represents a multipart file uploaded via multipart/form-data HTTP
|
|
28
|
-
* request.
|
|
29
|
-
*/
|
|
30
|
-
declare class VineMultipartFile extends BaseLiteralType<MultipartFile, MultipartFile, MultipartFile> {
|
|
31
|
-
#private;
|
|
32
|
-
[MULTIPART_FILE]: string;
|
|
33
|
-
constructor(validationOptions?: FileRuleValidationOptions, options?: FieldOptions, validations?: Validation<any>[]);
|
|
34
|
-
clone(): this;
|
|
35
|
-
}
|
|
36
19
|
/**
|
|
37
20
|
* The Edge service provider configures Edge to work within
|
|
38
21
|
* an AdonisJS application environment
|
|
@@ -42,4 +25,3 @@ export default class VineJSServiceProvider {
|
|
|
42
25
|
constructor(app: ApplicationService);
|
|
43
26
|
boot(): void;
|
|
44
27
|
}
|
|
45
|
-
export {};
|
|
@@ -6,70 +6,9 @@
|
|
|
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
|
|
9
|
+
import { Vine } from '@vinejs/vine';
|
|
10
10
|
import { Request, RequestValidator } from '../modules/http/main.js';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Checks if the value is an instance of multipart file
|
|
14
|
-
* from bodyparser.
|
|
15
|
-
*/
|
|
16
|
-
function isBodyParserFile(file) {
|
|
17
|
-
return !!(file && typeof file === 'object' && 'isMultipartFile' in file);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* VineJS validation rule that validates the file to be an
|
|
21
|
-
* instance of BodyParser MultipartFile class.
|
|
22
|
-
*/
|
|
23
|
-
const isMultipartFile = vine.createRule((file, options, field) => {
|
|
24
|
-
/**
|
|
25
|
-
* Report error when value is not a field multipart
|
|
26
|
-
* file object
|
|
27
|
-
*/
|
|
28
|
-
if (!isBodyParserFile(file)) {
|
|
29
|
-
field.report('The {{ field }} must be a file', 'file', field);
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
const validationOptions = typeof options === 'function' ? options(field) : options;
|
|
33
|
-
/**
|
|
34
|
-
* Set size when it's defined in the options and missing
|
|
35
|
-
* on the file instance
|
|
36
|
-
*/
|
|
37
|
-
if (file.sizeLimit === undefined && validationOptions.size) {
|
|
38
|
-
file.sizeLimit = validationOptions.size;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Set extensions when it's defined in the options and missing
|
|
42
|
-
* on the file instance
|
|
43
|
-
*/
|
|
44
|
-
if (file.allowedExtensions === undefined && validationOptions.extnames) {
|
|
45
|
-
file.allowedExtensions = validationOptions.extnames;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Validate file
|
|
49
|
-
*/
|
|
50
|
-
file.validate();
|
|
51
|
-
/**
|
|
52
|
-
* Report errors
|
|
53
|
-
*/
|
|
54
|
-
file.errors.forEach((error) => {
|
|
55
|
-
field.report(error.message, `file.${error.type}`, field, validationOptions);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
/**
|
|
59
|
-
* Represents a multipart file uploaded via multipart/form-data HTTP
|
|
60
|
-
* request.
|
|
61
|
-
*/
|
|
62
|
-
class VineMultipartFile extends BaseLiteralType {
|
|
63
|
-
#validationOptions;
|
|
64
|
-
[MULTIPART_FILE] = 'multipartFile';
|
|
65
|
-
constructor(validationOptions, options, validations) {
|
|
66
|
-
super(options, validations || [isMultipartFile(validationOptions || {})]);
|
|
67
|
-
this.#validationOptions = validationOptions;
|
|
68
|
-
}
|
|
69
|
-
clone() {
|
|
70
|
-
return new VineMultipartFile(this.#validationOptions, this.cloneOptions(), this.cloneValidations());
|
|
71
|
-
}
|
|
72
|
-
}
|
|
11
|
+
import { VineMultipartFile } from '../src/vine.js';
|
|
73
12
|
/**
|
|
74
13
|
* The Edge service provider configures Edge to work within
|
|
75
14
|
* an AdonisJS application environment
|
|
@@ -90,6 +90,7 @@ declare const types: {
|
|
|
90
90
|
urlInstance: typeof import("@sindresorhus/is").isUrlInstance;
|
|
91
91
|
urlSearchParams: typeof import("@sindresorhus/is").isUrlSearchParams;
|
|
92
92
|
urlString: typeof import("@sindresorhus/is").isUrlString;
|
|
93
|
+
optional: typeof import("@sindresorhus/is").isOptional;
|
|
93
94
|
validDate: typeof import("@sindresorhus/is").isValidDate;
|
|
94
95
|
validLength: typeof import("@sindresorhus/is").isValidLength;
|
|
95
96
|
weakMap: typeof import("@sindresorhus/is").isWeakMap;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { symbols, BaseLiteralType } from '@vinejs/vine';
|
|
2
|
+
import type { Validation, FieldContext, FieldOptions } from '@vinejs/vine/types';
|
|
3
|
+
import type { MultipartFile, FileValidationOptions } from '@adonisjs/bodyparser/types';
|
|
4
|
+
declare const MULTIPART_FILE: typeof symbols.SUBTYPE;
|
|
5
|
+
/**
|
|
6
|
+
* Validation options accepted by the "file" rule
|
|
7
|
+
*/
|
|
8
|
+
export type FileRuleValidationOptions = Partial<FileValidationOptions> | ((field: FieldContext) => Partial<FileValidationOptions>);
|
|
9
|
+
/**
|
|
10
|
+
* Represents a multipart file uploaded via multipart/form-data HTTP
|
|
11
|
+
* request.
|
|
12
|
+
*/
|
|
13
|
+
export declare class VineMultipartFile extends BaseLiteralType<MultipartFile, MultipartFile, MultipartFile> {
|
|
14
|
+
#private;
|
|
15
|
+
[MULTIPART_FILE]: string;
|
|
16
|
+
constructor(validationOptions?: FileRuleValidationOptions, options?: FieldOptions, validations?: Validation<any>[]);
|
|
17
|
+
clone(): this;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
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, { symbols, BaseLiteralType } from '@vinejs/vine';
|
|
10
|
+
const MULTIPART_FILE = symbols.SUBTYPE ?? Symbol.for('subtype');
|
|
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
|
+
export class VineMultipartFile extends BaseLiteralType {
|
|
62
|
+
#validationOptions;
|
|
63
|
+
[MULTIPART_FILE] = 'multipartFile';
|
|
64
|
+
constructor(validationOptions, options, validations) {
|
|
65
|
+
super(options, validations || [isMultipartFile(validationOptions || {})]);
|
|
66
|
+
this.#validationOptions = validationOptions;
|
|
67
|
+
}
|
|
68
|
+
clone() {
|
|
69
|
+
return new VineMultipartFile(this.#validationOptions, this.cloneOptions(), this.cloneValidations());
|
|
70
|
+
}
|
|
71
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/core",
|
|
3
3
|
"description": "Core of AdonisJS",
|
|
4
|
-
"version": "6.
|
|
4
|
+
"version": "6.19.1",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=20.6.0"
|
|
7
7
|
},
|
|
@@ -59,7 +59,8 @@
|
|
|
59
59
|
"./package.json": "./package.json",
|
|
60
60
|
"./exceptions": "./build/src/exceptions.js",
|
|
61
61
|
"./test_utils": "./build/src/test_utils/main.js",
|
|
62
|
-
"./health": "./build/modules/health.js"
|
|
62
|
+
"./health": "./build/modules/health.js",
|
|
63
|
+
"./vine": "./build/src/vine.js"
|
|
63
64
|
},
|
|
64
65
|
"scripts": {
|
|
65
66
|
"pretest": "npm run lint",
|
|
@@ -82,62 +83,62 @@
|
|
|
82
83
|
},
|
|
83
84
|
"devDependencies": {
|
|
84
85
|
"@adonisjs/assembler": "^7.8.2",
|
|
85
|
-
"@adonisjs/eslint-config": "^2.
|
|
86
|
-
"@adonisjs/prettier-config": "^1.4.
|
|
87
|
-
"@adonisjs/tsconfig": "^1.4.
|
|
88
|
-
"@japa/assert": "^4.
|
|
86
|
+
"@adonisjs/eslint-config": "^2.1.2",
|
|
87
|
+
"@adonisjs/prettier-config": "^1.4.5",
|
|
88
|
+
"@adonisjs/tsconfig": "^1.4.1",
|
|
89
|
+
"@japa/assert": "^4.1.1",
|
|
89
90
|
"@japa/expect-type": "^2.0.3",
|
|
90
91
|
"@japa/file-system": "^2.3.2",
|
|
91
|
-
"@japa/runner": "^4.
|
|
92
|
-
"@japa/snapshot": "^2.0.
|
|
92
|
+
"@japa/runner": "^4.4.0",
|
|
93
|
+
"@japa/snapshot": "^2.0.9",
|
|
93
94
|
"@release-it/conventional-changelog": "^10.0.1",
|
|
94
|
-
"@swc/core": "1.
|
|
95
|
-
"@types/node": "^
|
|
95
|
+
"@swc/core": "1.14.0",
|
|
96
|
+
"@types/node": "^24.9.2",
|
|
96
97
|
"@types/pretty-hrtime": "^1.0.3",
|
|
97
98
|
"@types/sinon": "^17.0.4",
|
|
98
99
|
"@types/supertest": "^6.0.3",
|
|
99
100
|
"@types/test-console": "^2.0.3",
|
|
100
|
-
"@vinejs/vine": "^
|
|
101
|
+
"@vinejs/vine": "^4.1.0",
|
|
101
102
|
"argon2": "^0.43.0",
|
|
102
103
|
"bcrypt": "^6.0.0",
|
|
103
104
|
"c8": "^10.1.3",
|
|
104
105
|
"copyfiles": "^2.4.1",
|
|
105
|
-
"cross-env": "^
|
|
106
|
-
"del-cli": "^
|
|
107
|
-
"edge.js": "^6.
|
|
108
|
-
"eslint": "^9.
|
|
109
|
-
"execa": "^9.
|
|
106
|
+
"cross-env": "^10.1.0",
|
|
107
|
+
"del-cli": "^7.0.0",
|
|
108
|
+
"edge.js": "^6.3.0",
|
|
109
|
+
"eslint": "^9.38.0",
|
|
110
|
+
"execa": "^9.6.0",
|
|
110
111
|
"get-port": "^7.1.0",
|
|
111
|
-
"prettier": "^3.
|
|
112
|
-
"release-it": "^19.0.
|
|
113
|
-
"sinon": "^
|
|
114
|
-
"supertest": "^7.1.
|
|
112
|
+
"prettier": "^3.6.2",
|
|
113
|
+
"release-it": "^19.0.5",
|
|
114
|
+
"sinon": "^21.0.0",
|
|
115
|
+
"supertest": "^7.1.4",
|
|
115
116
|
"test-console": "^2.0.0",
|
|
116
117
|
"timekeeper": "^2.3.1",
|
|
117
|
-
"ts-node-maintained": "^10.9.
|
|
118
|
-
"typescript": "^5.
|
|
118
|
+
"ts-node-maintained": "^10.9.6",
|
|
119
|
+
"typescript": "^5.9.3"
|
|
119
120
|
},
|
|
120
121
|
"dependencies": {
|
|
121
|
-
"@adonisjs/ace": "^13.
|
|
122
|
-
"@adonisjs/application": "^8.4.
|
|
122
|
+
"@adonisjs/ace": "^13.4.0",
|
|
123
|
+
"@adonisjs/application": "^8.4.2",
|
|
123
124
|
"@adonisjs/bodyparser": "^10.1.0",
|
|
124
|
-
"@adonisjs/config": "^5.0.
|
|
125
|
+
"@adonisjs/config": "^5.0.3",
|
|
125
126
|
"@adonisjs/encryption": "^6.0.2",
|
|
126
127
|
"@adonisjs/env": "^6.2.0",
|
|
127
128
|
"@adonisjs/events": "^9.0.2",
|
|
128
|
-
"@adonisjs/fold": "^10.
|
|
129
|
+
"@adonisjs/fold": "^10.2.0",
|
|
129
130
|
"@adonisjs/hash": "^9.1.1",
|
|
130
131
|
"@adonisjs/health": "^2.0.0",
|
|
131
|
-
"@adonisjs/http-server": "^7.
|
|
132
|
+
"@adonisjs/http-server": "^7.7.0",
|
|
132
133
|
"@adonisjs/logger": "^6.0.6",
|
|
133
|
-
"@adonisjs/repl": "^4.1.
|
|
134
|
+
"@adonisjs/repl": "^4.1.2",
|
|
134
135
|
"@antfu/install-pkg": "^1.1.0",
|
|
135
136
|
"@paralleldrive/cuid2": "^2.2.2",
|
|
136
|
-
"@poppinss/colors": "^4.1.
|
|
137
|
-
"@poppinss/dumper": "^0.6.
|
|
138
|
-
"@poppinss/macroable": "^1.0
|
|
139
|
-
"@poppinss/utils": "^6.
|
|
140
|
-
"@sindresorhus/is": "^7.0
|
|
137
|
+
"@poppinss/colors": "^4.1.5",
|
|
138
|
+
"@poppinss/dumper": "^0.6.4",
|
|
139
|
+
"@poppinss/macroable": "^1.1.0",
|
|
140
|
+
"@poppinss/utils": "^6.10.1",
|
|
141
|
+
"@sindresorhus/is": "^7.1.0",
|
|
141
142
|
"@types/he": "^1.2.3",
|
|
142
143
|
"error-stack-parser-es": "^1.0.5",
|
|
143
144
|
"he": "^1.2.0",
|
|
@@ -149,8 +150,8 @@
|
|
|
149
150
|
},
|
|
150
151
|
"peerDependencies": {
|
|
151
152
|
"@adonisjs/assembler": "^7.8.0",
|
|
152
|
-
"@vinejs/vine": "^2.1.0 || ^3.0.0",
|
|
153
|
-
"argon2": "^0.31.2 || ^0.41.0 || ^0.43.0",
|
|
153
|
+
"@vinejs/vine": "^2.1.0 || ^3.0.0 || ^4.0.0",
|
|
154
|
+
"argon2": "^0.31.2 || ^0.41.0 || ^0.43.0 || ^0.44.0",
|
|
154
155
|
"bcrypt": "^5.1.1 || ^6.0.0",
|
|
155
156
|
"edge.js": "^6.2.0"
|
|
156
157
|
},
|