@netlify/edge-bundler 4.3.2 → 4.4.0
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/dist/node/bridge.d.ts +2 -2
- package/dist/node/bundle.d.ts +6 -3
- package/dist/node/bundle.js +5 -1
- package/dist/node/declaration.d.ts +3 -3
- package/dist/node/feature_flags.d.ts +2 -2
- package/dist/node/formats/eszip.d.ts +1 -1
- package/dist/node/formats/eszip.js +2 -1
- package/dist/node/formats/javascript.d.ts +1 -1
- package/dist/node/formats/javascript.js +2 -1
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.js +1 -0
- package/dist/node/logger.d.ts +1 -1
- package/dist/node/manifest.test.js +7 -6
- package/dist/node/server/server.d.ts +1 -1
- package/dist/node/validation/manifest/error.d.ts +3 -0
- package/dist/node/validation/manifest/error.js +8 -0
- package/dist/node/validation/manifest/index.d.ts +3 -0
- package/dist/node/validation/manifest/index.js +34 -0
- package/dist/node/validation/manifest/index.test.d.ts +1 -0
- package/dist/node/validation/manifest/index.test.js +116 -0
- package/dist/node/validation/manifest/schema.d.ts +89 -0
- package/dist/node/validation/manifest/schema.js +58 -0
- package/package.json +7 -3
package/dist/node/bridge.d.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { ExecaChildProcess } from 'execa';
|
|
3
3
|
import { Logger } from './logger.js';
|
|
4
4
|
declare const DENO_VERSION_RANGE = "^1.22.0";
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
type OnBeforeDownloadHook = () => void | Promise<void>;
|
|
6
|
+
type OnAfterDownloadHook = (error?: Error) => void | Promise<void>;
|
|
7
7
|
interface DenoOptions {
|
|
8
8
|
cacheDirectory?: string;
|
|
9
9
|
debug?: boolean;
|
package/dist/node/bundle.d.ts
CHANGED
package/dist/node/bundle.js
CHANGED
|
@@ -4,12 +4,12 @@ interface BaseDeclaration {
|
|
|
4
4
|
function: string;
|
|
5
5
|
name?: string;
|
|
6
6
|
}
|
|
7
|
-
|
|
7
|
+
type DeclarationWithPath = BaseDeclaration & {
|
|
8
8
|
path: string;
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
type DeclarationWithPattern = BaseDeclaration & {
|
|
11
11
|
pattern: string;
|
|
12
12
|
};
|
|
13
|
-
|
|
13
|
+
type Declaration = DeclarationWithPath | DeclarationWithPattern;
|
|
14
14
|
export declare const getDeclarationsFromConfig: (tomlDeclarations: Declaration[], functionsConfig: Record<string, FunctionConfig>) => Declaration[];
|
|
15
15
|
export { Declaration, DeclarationWithPath, DeclarationWithPattern };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
declare const defaultFlags: Record<string, boolean>;
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
type FeatureFlag = keyof typeof defaultFlags;
|
|
3
|
+
type FeatureFlags = Record<FeatureFlag, boolean>;
|
|
4
4
|
declare const getFlags: (input?: Record<string, boolean>, flags?: Record<string, boolean>) => FeatureFlags;
|
|
5
5
|
export { defaultFlags, getFlags };
|
|
6
6
|
export type { FeatureFlag, FeatureFlags };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DenoBridge } from '../bridge.js';
|
|
2
|
-
import
|
|
2
|
+
import { Bundle } from '../bundle.js';
|
|
3
3
|
import { EdgeFunction } from '../edge_function.js';
|
|
4
4
|
import { FeatureFlags } from '../feature_flags.js';
|
|
5
5
|
import { ImportMap } from '../import_map.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { join } from 'path';
|
|
2
|
+
import { BundleFormat } from '../bundle.js';
|
|
2
3
|
import { wrapBundleError } from '../bundle_error.js';
|
|
3
4
|
import { wrapNpmImportError } from '../npm_import_error.js';
|
|
4
5
|
import { getPackagePath } from '../package_json.js';
|
|
@@ -27,7 +28,7 @@ const bundleESZIP = async ({ basePath, buildID, debug, deno, distDirectory, func
|
|
|
27
28
|
throw wrapBundleError(wrapNpmImportError(error), { format: 'eszip' });
|
|
28
29
|
}
|
|
29
30
|
const hash = await getFileHash(destPath);
|
|
30
|
-
return { extension, format:
|
|
31
|
+
return { extension, format: BundleFormat.ESZIP2, hash };
|
|
31
32
|
};
|
|
32
33
|
const getESZIPPaths = () => {
|
|
33
34
|
const denoPath = join(getPackagePath(), 'deno');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DenoBridge } from '../bridge.js';
|
|
2
|
-
import
|
|
2
|
+
import { Bundle } from '../bundle.js';
|
|
3
3
|
import { EdgeFunction } from '../edge_function.js';
|
|
4
4
|
import { ImportMap } from '../import_map.js';
|
|
5
5
|
import type { FormatFunction } from '../server/server.js';
|
|
@@ -3,6 +3,7 @@ import { join } from 'path';
|
|
|
3
3
|
import { env } from 'process';
|
|
4
4
|
import { pathToFileURL } from 'url';
|
|
5
5
|
import { deleteAsync } from 'del';
|
|
6
|
+
import { BundleFormat } from '../bundle.js';
|
|
6
7
|
import { wrapBundleError } from '../bundle_error.js';
|
|
7
8
|
import { wrapNpmImportError } from '../npm_import_error.js';
|
|
8
9
|
import { getFileHash } from '../utils/sha256.js';
|
|
@@ -23,7 +24,7 @@ const bundleJS = async ({ buildID, debug, deno, distDirectory, functions, import
|
|
|
23
24
|
}
|
|
24
25
|
await fs.unlink(stage2Path);
|
|
25
26
|
const hash = await getFileHash(jsBundlePath);
|
|
26
|
-
return { extension, format:
|
|
27
|
+
return { extension, format: BundleFormat.JS, hash };
|
|
27
28
|
};
|
|
28
29
|
const defaultFormatExportTypeError = (name) => `The Edge Function "${name}" has failed to load. Does it have a function as the default export?`;
|
|
29
30
|
const defaultFormatImpoortError = (name) => `There was an error with Edge Function "${name}".`;
|
package/dist/node/index.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export { DenoBridge } from './bridge.js';
|
|
|
3
3
|
export { findFunctions as find } from './finder.js';
|
|
4
4
|
export { generateManifest } from './manifest.js';
|
|
5
5
|
export { serve } from './server/server.js';
|
|
6
|
+
export { validateManifest, ManifestValidationError } from './validation/manifest/index.js';
|
package/dist/node/index.js
CHANGED
|
@@ -3,3 +3,4 @@ export { DenoBridge } from './bridge.js';
|
|
|
3
3
|
export { findFunctions as find } from './finder.js';
|
|
4
4
|
export { generateManifest } from './manifest.js';
|
|
5
5
|
export { serve } from './server/server.js';
|
|
6
|
+
export { validateManifest, ManifestValidationError } from './validation/manifest/index.js';
|
package/dist/node/logger.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { env } from 'process';
|
|
2
2
|
import { test, expect } from 'vitest';
|
|
3
|
+
import { BundleFormat } from './bundle.js';
|
|
3
4
|
import { generateManifest } from './manifest.js';
|
|
4
5
|
test('Generates a manifest with different bundles', () => {
|
|
5
6
|
const bundle1 = {
|
|
6
7
|
extension: '.ext1',
|
|
7
|
-
format:
|
|
8
|
+
format: BundleFormat.ESZIP2,
|
|
8
9
|
hash: '123456',
|
|
9
10
|
};
|
|
10
11
|
const bundle2 = {
|
|
11
12
|
extension: '.ext2',
|
|
12
|
-
format:
|
|
13
|
+
format: BundleFormat.ESZIP2,
|
|
13
14
|
hash: '654321',
|
|
14
15
|
};
|
|
15
16
|
const functions = [{ name: 'func-1', path: '/path/to/func-1.ts' }];
|
|
@@ -44,7 +45,7 @@ test('Generates a manifest with display names', () => {
|
|
|
44
45
|
test('Excludes functions for which there are function files but no matching config declarations', () => {
|
|
45
46
|
const bundle1 = {
|
|
46
47
|
extension: '.ext2',
|
|
47
|
-
format:
|
|
48
|
+
format: BundleFormat.ESZIP2,
|
|
48
49
|
hash: '123456',
|
|
49
50
|
};
|
|
50
51
|
const functions = [
|
|
@@ -59,7 +60,7 @@ test('Excludes functions for which there are function files but no matching conf
|
|
|
59
60
|
test('Excludes functions for which there are config declarations but no matching function files', () => {
|
|
60
61
|
const bundle1 = {
|
|
61
62
|
extension: '.ext2',
|
|
62
|
-
format:
|
|
63
|
+
format: BundleFormat.ESZIP2,
|
|
63
64
|
hash: '123456',
|
|
64
65
|
};
|
|
65
66
|
const functions = [{ name: 'func-2', path: '/path/to/func-2.ts' }];
|
|
@@ -83,12 +84,12 @@ test('Generates a manifest without bundles', () => {
|
|
|
83
84
|
test('Generates a manifest with pre and post-cache routes', () => {
|
|
84
85
|
const bundle1 = {
|
|
85
86
|
extension: '.ext1',
|
|
86
|
-
format:
|
|
87
|
+
format: BundleFormat.ESZIP2,
|
|
87
88
|
hash: '123456',
|
|
88
89
|
};
|
|
89
90
|
const bundle2 = {
|
|
90
91
|
extension: '.ext2',
|
|
91
|
-
format:
|
|
92
|
+
format: BundleFormat.ESZIP2,
|
|
92
93
|
hash: '654321',
|
|
93
94
|
};
|
|
94
95
|
const functions = [
|
|
@@ -8,7 +8,7 @@ import { FunctionConfig } from '../config.js';
|
|
|
8
8
|
import type { EdgeFunction } from '../edge_function.js';
|
|
9
9
|
import { ImportMapFile } from '../import_map.js';
|
|
10
10
|
import { LogFunction } from '../logger.js';
|
|
11
|
-
|
|
11
|
+
type FormatFunction = (name: string) => string;
|
|
12
12
|
interface StartServerOptions {
|
|
13
13
|
getFunctionsConfig?: boolean;
|
|
14
14
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export default class ManifestValidationError extends Error {
|
|
2
|
+
constructor(message) {
|
|
3
|
+
super(`Validation of Edge Functions manifest failed\n${message}`);
|
|
4
|
+
this.name = 'ManifestValidationError';
|
|
5
|
+
// https://github.com/microsoft/TypeScript-wiki/blob/0fecbda7263f130c57394d779b8ca13f0a2e9123/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
|
|
6
|
+
Object.setPrototypeOf(this, ManifestValidationError.prototype);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import Ajv from 'ajv';
|
|
2
|
+
import ajvErrors from 'ajv-errors';
|
|
3
|
+
import betterAjvErrors from 'better-ajv-errors';
|
|
4
|
+
import ManifestValidationError from './error.js';
|
|
5
|
+
import edgeManifestSchema from './schema.js';
|
|
6
|
+
let manifestValidator;
|
|
7
|
+
const initializeValidator = () => {
|
|
8
|
+
if (manifestValidator === undefined) {
|
|
9
|
+
const ajv = new Ajv({ allErrors: true });
|
|
10
|
+
ajvErrors(ajv);
|
|
11
|
+
// regex pattern for manifest route pattern
|
|
12
|
+
// checks if the pattern string starts with ^ and ends with $
|
|
13
|
+
const normalizedPatternRegex = /^\^.*\$$/;
|
|
14
|
+
ajv.addFormat('regexPattern', {
|
|
15
|
+
validate: (data) => normalizedPatternRegex.test(data),
|
|
16
|
+
});
|
|
17
|
+
manifestValidator = ajv.compile(edgeManifestSchema);
|
|
18
|
+
}
|
|
19
|
+
return manifestValidator;
|
|
20
|
+
};
|
|
21
|
+
// throws on validation error
|
|
22
|
+
export const validateManifest = (manifestData) => {
|
|
23
|
+
const validate = initializeValidator();
|
|
24
|
+
const valid = validate(manifestData);
|
|
25
|
+
if (!valid) {
|
|
26
|
+
let errorOutput;
|
|
27
|
+
if (validate.errors) {
|
|
28
|
+
errorOutput = betterAjvErrors(edgeManifestSchema, manifestData, validate.errors, { indent: 2 });
|
|
29
|
+
}
|
|
30
|
+
throw new ManifestValidationError(errorOutput);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
// eslint-disable-next-line unicorn/prefer-export-from
|
|
34
|
+
export { ManifestValidationError };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/* eslint-disable max-nested-callbacks */
|
|
2
|
+
import { test, expect, describe } from 'vitest';
|
|
3
|
+
import { validateManifest, ManifestValidationError } from './index.js';
|
|
4
|
+
// Factory so we have a new object per test
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
+
const getBaseManifest = () => ({
|
|
7
|
+
bundles: [
|
|
8
|
+
{
|
|
9
|
+
asset: 'f35baff44129a8f6be7db68590b2efd86ed4ba29000e2edbcaddc5d620d7d043.js',
|
|
10
|
+
format: 'js',
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
routes: [
|
|
14
|
+
{
|
|
15
|
+
name: 'name',
|
|
16
|
+
function: 'hello',
|
|
17
|
+
pattern: '^/hello/?$',
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
post_cache_routes: [
|
|
21
|
+
{
|
|
22
|
+
name: 'name',
|
|
23
|
+
function: 'hello',
|
|
24
|
+
pattern: '^/hello/?$',
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
layers: [
|
|
28
|
+
{
|
|
29
|
+
flag: 'flag',
|
|
30
|
+
name: 'name',
|
|
31
|
+
local: 'local',
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
bundler_version: '1.6.0',
|
|
35
|
+
});
|
|
36
|
+
test('should not throw on valid manifest', () => {
|
|
37
|
+
expect(() => validateManifest(getBaseManifest())).not.toThrowError();
|
|
38
|
+
});
|
|
39
|
+
test('should throw ManifestValidationError with correct message', () => {
|
|
40
|
+
expect(() => validateManifest('manifest')).toThrowError(ManifestValidationError);
|
|
41
|
+
expect(() => validateManifest('manifest')).toThrowError(/^Validation of Edge Functions manifest failed/);
|
|
42
|
+
});
|
|
43
|
+
test('should throw on additional property on root level', () => {
|
|
44
|
+
const manifest = getBaseManifest();
|
|
45
|
+
manifest.foo = 'bar';
|
|
46
|
+
expect(() => validateManifest(manifest)).toThrowErrorMatchingSnapshot();
|
|
47
|
+
});
|
|
48
|
+
test('should show multiple errors', () => {
|
|
49
|
+
const manifest = getBaseManifest();
|
|
50
|
+
manifest.foo = 'bar';
|
|
51
|
+
manifest.baz = 'bar';
|
|
52
|
+
expect(() => validateManifest(manifest)).toThrowErrorMatchingSnapshot();
|
|
53
|
+
});
|
|
54
|
+
describe('bundle', () => {
|
|
55
|
+
test('should throw on additional property in bundle', () => {
|
|
56
|
+
const manifest = getBaseManifest();
|
|
57
|
+
manifest.bundles[0].foo = 'bar';
|
|
58
|
+
expect(() => validateManifest(manifest)).toThrowErrorMatchingSnapshot();
|
|
59
|
+
});
|
|
60
|
+
test('should throw on missing asset', () => {
|
|
61
|
+
const manifest = getBaseManifest();
|
|
62
|
+
delete manifest.bundles[0].asset;
|
|
63
|
+
expect(() => validateManifest(manifest)).toThrowErrorMatchingSnapshot();
|
|
64
|
+
});
|
|
65
|
+
test('should throw on missing format', () => {
|
|
66
|
+
const manifest = getBaseManifest();
|
|
67
|
+
delete manifest.bundles[0].format;
|
|
68
|
+
expect(() => validateManifest(manifest)).toThrowErrorMatchingSnapshot();
|
|
69
|
+
});
|
|
70
|
+
test('should throw on invalid format', () => {
|
|
71
|
+
const manifest = getBaseManifest();
|
|
72
|
+
manifest.bundles[0].format = 'foo';
|
|
73
|
+
expect(() => validateManifest(manifest)).toThrowErrorMatchingSnapshot();
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
describe('route', () => {
|
|
77
|
+
test('should throw on additional property', () => {
|
|
78
|
+
const manifest = getBaseManifest();
|
|
79
|
+
manifest.routes[0].foo = 'bar';
|
|
80
|
+
expect(() => validateManifest(manifest)).toThrowErrorMatchingSnapshot();
|
|
81
|
+
});
|
|
82
|
+
test('should throw on invalid pattern', () => {
|
|
83
|
+
const manifest = getBaseManifest();
|
|
84
|
+
manifest.routes[0].pattern = '/^/hello/?$/';
|
|
85
|
+
expect(() => validateManifest(manifest)).toThrowErrorMatchingSnapshot();
|
|
86
|
+
});
|
|
87
|
+
test('should throw on missing function', () => {
|
|
88
|
+
const manifest = getBaseManifest();
|
|
89
|
+
delete manifest.routes[0].function;
|
|
90
|
+
expect(() => validateManifest(manifest)).toThrowErrorMatchingSnapshot();
|
|
91
|
+
});
|
|
92
|
+
test('should throw on missing pattern', () => {
|
|
93
|
+
const manifest = getBaseManifest();
|
|
94
|
+
delete manifest.routes[0].pattern;
|
|
95
|
+
expect(() => validateManifest(manifest)).toThrowErrorMatchingSnapshot();
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
// No tests for post_cache_routes as schema shared with routes
|
|
99
|
+
describe('layers', () => {
|
|
100
|
+
test('should throw on additional property', () => {
|
|
101
|
+
const manifest = getBaseManifest();
|
|
102
|
+
manifest.layers[0].foo = 'bar';
|
|
103
|
+
expect(() => validateManifest(manifest)).toThrowErrorMatchingSnapshot();
|
|
104
|
+
});
|
|
105
|
+
test('should throw on missing name', () => {
|
|
106
|
+
const manifest = getBaseManifest();
|
|
107
|
+
delete manifest.layers[0].name;
|
|
108
|
+
expect(() => validateManifest(manifest)).toThrowErrorMatchingSnapshot();
|
|
109
|
+
});
|
|
110
|
+
test('should throw on missing flag', () => {
|
|
111
|
+
const manifest = getBaseManifest();
|
|
112
|
+
delete manifest.layers[0].flag;
|
|
113
|
+
expect(() => validateManifest(manifest)).toThrowErrorMatchingSnapshot();
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
/* eslint-enable max-nested-callbacks */
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
declare const edgeManifestSchema: {
|
|
2
|
+
type: string;
|
|
3
|
+
required: string[];
|
|
4
|
+
properties: {
|
|
5
|
+
bundles: {
|
|
6
|
+
type: string;
|
|
7
|
+
items: {
|
|
8
|
+
type: string;
|
|
9
|
+
required: string[];
|
|
10
|
+
properties: {
|
|
11
|
+
asset: {
|
|
12
|
+
type: string;
|
|
13
|
+
};
|
|
14
|
+
format: {
|
|
15
|
+
type: string;
|
|
16
|
+
enum: string[];
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
additionalProperties: boolean;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
routes: {
|
|
23
|
+
type: string;
|
|
24
|
+
items: {
|
|
25
|
+
type: string;
|
|
26
|
+
required: string[];
|
|
27
|
+
properties: {
|
|
28
|
+
name: {
|
|
29
|
+
type: string;
|
|
30
|
+
};
|
|
31
|
+
function: {
|
|
32
|
+
type: string;
|
|
33
|
+
};
|
|
34
|
+
pattern: {
|
|
35
|
+
type: string;
|
|
36
|
+
format: string;
|
|
37
|
+
errorMessage: string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
additionalProperties: boolean;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
post_cache_routes: {
|
|
44
|
+
type: string;
|
|
45
|
+
items: {
|
|
46
|
+
type: string;
|
|
47
|
+
required: string[];
|
|
48
|
+
properties: {
|
|
49
|
+
name: {
|
|
50
|
+
type: string;
|
|
51
|
+
};
|
|
52
|
+
function: {
|
|
53
|
+
type: string;
|
|
54
|
+
};
|
|
55
|
+
pattern: {
|
|
56
|
+
type: string;
|
|
57
|
+
format: string;
|
|
58
|
+
errorMessage: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
additionalProperties: boolean;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
layers: {
|
|
65
|
+
type: string;
|
|
66
|
+
items: {
|
|
67
|
+
type: string;
|
|
68
|
+
required: string[];
|
|
69
|
+
properties: {
|
|
70
|
+
flag: {
|
|
71
|
+
type: string;
|
|
72
|
+
};
|
|
73
|
+
name: {
|
|
74
|
+
type: string;
|
|
75
|
+
};
|
|
76
|
+
local: {
|
|
77
|
+
type: string;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
additionalProperties: boolean;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
bundler_version: {
|
|
84
|
+
type: string;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
additionalProperties: boolean;
|
|
88
|
+
};
|
|
89
|
+
export default edgeManifestSchema;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const bundlesSchema = {
|
|
2
|
+
type: 'object',
|
|
3
|
+
required: ['asset', 'format'],
|
|
4
|
+
properties: {
|
|
5
|
+
asset: { type: 'string' },
|
|
6
|
+
format: { type: 'string', enum: ['eszip2', 'js'] },
|
|
7
|
+
},
|
|
8
|
+
additionalProperties: false,
|
|
9
|
+
};
|
|
10
|
+
const routesSchema = {
|
|
11
|
+
type: 'object',
|
|
12
|
+
required: ['function', 'pattern'],
|
|
13
|
+
properties: {
|
|
14
|
+
name: { type: 'string' },
|
|
15
|
+
function: { type: 'string' },
|
|
16
|
+
pattern: {
|
|
17
|
+
type: 'string',
|
|
18
|
+
format: 'regexPattern',
|
|
19
|
+
errorMessage: 'pattern needs to be a regex that starts with ^ and ends with $ without any additional slashes before and afterwards',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
additionalProperties: false,
|
|
23
|
+
};
|
|
24
|
+
const layersSchema = {
|
|
25
|
+
type: 'object',
|
|
26
|
+
required: ['flag', 'name'],
|
|
27
|
+
properties: {
|
|
28
|
+
flag: { type: 'string' },
|
|
29
|
+
name: { type: 'string' },
|
|
30
|
+
local: { type: 'string' },
|
|
31
|
+
},
|
|
32
|
+
additionalProperties: false,
|
|
33
|
+
};
|
|
34
|
+
const edgeManifestSchema = {
|
|
35
|
+
type: 'object',
|
|
36
|
+
required: ['bundles', 'routes', 'bundler_version'],
|
|
37
|
+
properties: {
|
|
38
|
+
bundles: {
|
|
39
|
+
type: 'array',
|
|
40
|
+
items: bundlesSchema,
|
|
41
|
+
},
|
|
42
|
+
routes: {
|
|
43
|
+
type: 'array',
|
|
44
|
+
items: routesSchema,
|
|
45
|
+
},
|
|
46
|
+
post_cache_routes: {
|
|
47
|
+
type: 'array',
|
|
48
|
+
items: routesSchema,
|
|
49
|
+
},
|
|
50
|
+
layers: {
|
|
51
|
+
type: 'array',
|
|
52
|
+
items: layersSchema,
|
|
53
|
+
},
|
|
54
|
+
bundler_version: { type: 'string' },
|
|
55
|
+
},
|
|
56
|
+
additionalProperties: false,
|
|
57
|
+
};
|
|
58
|
+
export default edgeManifestSchema;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/edge-bundler",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"description": "Intelligently prepare Netlify Edge Functions for deployment",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/node/index.js",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"format:fix:prettier": "cross-env-shell prettier --write $npm_package_config_prettier",
|
|
29
29
|
"test:dev": "run-s test:dev:*",
|
|
30
30
|
"test:ci": "run-s test:ci:*",
|
|
31
|
-
"test:dev:vitest": "vitest run",
|
|
31
|
+
"test:dev:vitest": "cross-env FORCE_COLOR=0 vitest run",
|
|
32
32
|
"test:dev:deno": "deno test --allow-all deno",
|
|
33
|
-
"test:ci:vitest": "vitest run",
|
|
33
|
+
"test:ci:vitest": "cross-env FORCE_COLOR=0 vitest run",
|
|
34
34
|
"test:ci:deno": "deno test --allow-all deno",
|
|
35
35
|
"test:integration": "node --experimental-modules test/integration/test.js"
|
|
36
36
|
},
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"@types/uuid": "^8.3.4",
|
|
60
60
|
"@vitest/coverage-c8": "^0.25.0",
|
|
61
61
|
"archiver": "^5.3.1",
|
|
62
|
+
"cross-env": "^7.0.3",
|
|
62
63
|
"husky": "^8.0.0",
|
|
63
64
|
"nock": "^13.2.4",
|
|
64
65
|
"tar": "^6.1.11",
|
|
@@ -71,6 +72,9 @@
|
|
|
71
72
|
},
|
|
72
73
|
"dependencies": {
|
|
73
74
|
"@import-maps/resolve": "^1.0.1",
|
|
75
|
+
"ajv": "^8.11.2",
|
|
76
|
+
"ajv-errors": "^3.0.0",
|
|
77
|
+
"better-ajv-errors": "^1.2.0",
|
|
74
78
|
"common-path-prefix": "^3.0.0",
|
|
75
79
|
"del": "^7.0.0",
|
|
76
80
|
"env-paths": "^3.0.0",
|