-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
1,364 additions
and
827 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
interface Bundle { | ||
export enum BundleFormat { | ||
ESZIP2 = 'eszip2', | ||
JS = 'js', | ||
} | ||
|
||
export interface Bundle { | ||
extension: string | ||
format: string | ||
format: BundleFormat | ||
hash: string | ||
} | ||
|
||
export type { Bundle } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
176 changes: 176 additions & 0 deletions
176
node/validation/manifest/__snapshots__/index.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
// Vitest Snapshot v1 | ||
|
||
exports[`bundle > should throw on additional property in bundle 1`] = ` | ||
"Validation of Edge Functions manifest failed | ||
[31m[1mADDTIONAL PROPERTY[22m[39m[31m must NOT have additional properties[39m | ||
4 | \\"asset\\": \\"f35baff44129a8f6be7db68590b2efd86ed4ba29000e2edbcaddc5d620d7d043.js\\", | ||
5 | \\"format\\": \\"js\\", | ||
> 6 | \\"foo\\": \\"bar\\" | ||
| ^^^^^ 😲 [95mfoo[39m is not expected to be here! | ||
7 | } | ||
8 | ], | ||
9 | \\"routes\\": [" | ||
`; | ||
|
||
exports[`bundle > should throw on invalid format 1`] = ` | ||
"Validation of Edge Functions manifest failed | ||
[31m[1mENUM[22m[39m[31m must be equal to one of the allowed values[39m | ||
[31m(eszip2, js)[39m | ||
3 | { | ||
4 | \\"asset\\": \\"f35baff44129a8f6be7db68590b2efd86ed4ba29000e2edbcaddc5d620d7d043.js\\", | ||
> 5 | \\"format\\": \\"foo\\" | ||
| ^^^^^ 👈🏽 Unexpected value, should be equal to one of the allowed values | ||
6 | } | ||
7 | ], | ||
8 | \\"routes\\": [" | ||
`; | ||
|
||
exports[`bundle > should throw on missing asset 1`] = ` | ||
"Validation of Edge Functions manifest failed | ||
[31m[1mREQUIRED[22m[39m[31m must have required property 'asset'[39m | ||
1 | { | ||
2 | \\"bundles\\": [ | ||
> 3 | { | ||
| ^ ☹️ [95masset[39m is missing here! | ||
4 | \\"format\\": \\"js\\" | ||
5 | } | ||
6 | ]," | ||
`; | ||
exports[`bundle > should throw on missing format 1`] = ` | ||
"Validation of Edge Functions manifest failed | ||
[31m[1mREQUIRED[22m[39m[31m must have required property 'format'[39m | ||
1 | { | ||
2 | \\"bundles\\": [ | ||
> 3 | { | ||
| ^ ☹️ [95mformat[39m is missing here! | ||
4 | \\"asset\\": \\"f35baff44129a8f6be7db68590b2efd86ed4ba29000e2edbcaddc5d620d7d043.js\\" | ||
5 | } | ||
6 | ]," | ||
`; | ||
exports[`layers > should throw on additional property 1`] = ` | ||
"Validation of Edge Functions manifest failed | ||
[31m[1mADDTIONAL PROPERTY[22m[39m[31m must NOT have additional properties[39m | ||
25 | \\"name\\": \\"name\\", | ||
26 | \\"local\\": \\"local\\", | ||
> 27 | \\"foo\\": \\"bar\\" | ||
| ^^^^^ 😲 [95mfoo[39m is not expected to be here! | ||
28 | } | ||
29 | ], | ||
30 | \\"bundler_version\\": \\"1.6.0\\"" | ||
`; | ||
exports[`layers > should throw on missing flag 1`] = ` | ||
"Validation of Edge Functions manifest failed | ||
[31m[1mREQUIRED[22m[39m[31m must have required property 'flag'[39m | ||
21 | ], | ||
22 | \\"layers\\": [ | ||
> 23 | { | ||
| ^ ☹️ [95mflag[39m is missing here! | ||
24 | \\"name\\": \\"name\\", | ||
25 | \\"local\\": \\"local\\" | ||
26 | }" | ||
`; | ||
exports[`layers > should throw on missing name 1`] = ` | ||
"Validation of Edge Functions manifest failed | ||
[31m[1mREQUIRED[22m[39m[31m must have required property 'name'[39m | ||
21 | ], | ||
22 | \\"layers\\": [ | ||
> 23 | { | ||
| ^ ☹️ [95mname[39m is missing here! | ||
24 | \\"flag\\": \\"flag\\", | ||
25 | \\"local\\": \\"local\\" | ||
26 | }" | ||
`; | ||
exports[`route > should throw on additional property 1`] = ` | ||
"Validation of Edge Functions manifest failed | ||
[31m[1mADDTIONAL PROPERTY[22m[39m[31m must NOT have additional properties[39m | ||
11 | \\"function\\": \\"hello\\", | ||
12 | \\"pattern\\": \\"^/hello/?$\\", | ||
> 13 | \\"foo\\": \\"bar\\" | ||
| ^^^^^ 😲 [95mfoo[39m is not expected to be here! | ||
14 | } | ||
15 | ], | ||
16 | \\"post_cache_routes\\": [" | ||
`; | ||
exports[`route > should throw on invalid pattern 1`] = ` | ||
"Validation of Edge Functions manifest failed | ||
[31m[1mFORMAT[22m[39m[31m pattern needs to be a regex that starts with ^ and ends with $ without any additional slashes before and afterwards[39m | ||
10 | \\"name\\": \\"name\\", | ||
11 | \\"function\\": \\"hello\\", | ||
> 12 | \\"pattern\\": \\"/^/hello/?$/\\" | ||
| ^^^^^^^^^^^^^^ 👈🏽 [95mformat[39m pattern needs to be a regex that starts with ^ and ends with $ without any additional slashes before and afterwards | ||
13 | } | ||
14 | ], | ||
15 | \\"post_cache_routes\\": [" | ||
`; | ||
exports[`route > should throw on missing function 1`] = ` | ||
"Validation of Edge Functions manifest failed | ||
[31m[1mREQUIRED[22m[39m[31m must have required property 'function'[39m | ||
7 | ], | ||
8 | \\"routes\\": [ | ||
> 9 | { | ||
| ^ ☹️ [95mfunction[39m is missing here! | ||
10 | \\"name\\": \\"name\\", | ||
11 | \\"pattern\\": \\"^/hello/?$\\" | ||
12 | }" | ||
`; | ||
exports[`route > should throw on missing pattern 1`] = ` | ||
"Validation of Edge Functions manifest failed | ||
[31m[1mREQUIRED[22m[39m[31m must have required property 'pattern'[39m | ||
7 | ], | ||
8 | \\"routes\\": [ | ||
> 9 | { | ||
| ^ ☹️ [95mpattern[39m is missing here! | ||
10 | \\"name\\": \\"name\\", | ||
11 | \\"function\\": \\"hello\\" | ||
12 | }" | ||
`; | ||
exports[`should show multiple errors 1`] = ` | ||
"Validation of Edge Functions manifest failed | ||
[31m[1mADDTIONAL PROPERTY[22m[39m[31m must NOT have additional properties[39m | ||
28 | ], | ||
29 | \\"bundler_version\\": \\"1.6.0\\", | ||
> 30 | \\"foo\\": \\"bar\\", | ||
| ^^^^^ 😲 [95mfoo[39m is not expected to be here! | ||
31 | \\"baz\\": \\"bar\\" | ||
32 | } | ||
[31m[1mADDTIONAL PROPERTY[22m[39m[31m must NOT have additional properties[39m | ||
29 | \\"bundler_version\\": \\"1.6.0\\", | ||
30 | \\"foo\\": \\"bar\\", | ||
> 31 | \\"baz\\": \\"bar\\" | ||
| ^^^^^ 😲 [95mbaz[39m is not expected to be here! | ||
32 | }" | ||
`; | ||
exports[`should throw on additional property on root level 1`] = ` | ||
"Validation of Edge Functions manifest failed | ||
[31m[1mADDTIONAL PROPERTY[22m[39m[31m must NOT have additional properties[39m | ||
28 | ], | ||
29 | \\"bundler_version\\": \\"1.6.0\\", | ||
> 30 | \\"foo\\": \\"bar\\" | ||
| ^^^^^ 😲 [95mfoo[39m is not expected to be here! | ||
31 | }" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export default class ManifestValidationError extends Error { | ||
constructor(message: string | undefined) { | ||
super(`Validation of Edge Functions manifest failed\n${message}`) | ||
|
||
this.name = 'ManifestValidationError' | ||
|
||
// https://github.com/microsoft/TypeScript-wiki/blob/0fecbda7263f130c57394d779b8ca13f0a2e9123/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work | ||
Object.setPrototypeOf(this, ManifestValidationError.prototype) | ||
} | ||
} |
Oops, something went wrong.