@vercel/build-utils 7.1.0 → 7.1.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/CHANGELOG.md +8 -0
- package/build.mjs +3 -0
- package/dist/clone-env.js +39 -30
- package/dist/debug.js +28 -9
- package/dist/edge-function.js +36 -16
- package/dist/errors.js +83 -74
- package/dist/file-blob.js +63 -32
- package/dist/file-fs-ref.js +99 -65
- package/dist/file-ref.js +97 -77
- package/dist/fs/download.js +121 -91
- package/dist/fs/get-writable-directory.js +29 -9
- package/dist/fs/glob.js +104 -77
- package/dist/fs/node-version.js +115 -82
- package/dist/fs/normalize-path.js +28 -8
- package/dist/fs/read-config-file.js +66 -40
- package/dist/fs/rename.js +27 -14
- package/dist/fs/run-user-scripts.js +457 -419
- package/dist/fs/stream-to-buffer.js +51 -24
- package/dist/get-ignore-filter.js +80 -49
- package/dist/get-platform-env.js +41 -22
- package/dist/get-prefixed-env-vars.js +48 -32
- package/dist/hard-link-dir.js +90 -70
- package/dist/index.js +22266 -29403
- package/dist/lambda.js +208 -144
- package/dist/nodejs-lambda.js +40 -12
- package/dist/prerender.js +109 -64
- package/dist/schemas.js +83 -57
- package/dist/should-serve.js +43 -16
- package/dist/types.d.ts +4 -0
- package/dist/types.js +15 -1
- package/dist/validate-npmrc.js +38 -24
- package/package.json +3 -3
- package/build.js +0 -30
package/dist/lambda.js
CHANGED
@@ -1,160 +1,224 @@
|
|
1
1
|
"use strict";
|
2
|
-
var
|
3
|
-
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __export = (target, all) => {
|
9
|
+
for (var name in all)
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
4
11
|
};
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
+
for (let key of __getOwnPropNames(from))
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
+
}
|
18
|
+
return to;
|
19
|
+
};
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
+
var lambda_exports = {};
|
30
|
+
__export(lambda_exports, {
|
31
|
+
Lambda: () => Lambda,
|
32
|
+
createLambda: () => createLambda,
|
33
|
+
createZip: () => createZip,
|
34
|
+
getLambdaOptionsFromFunction: () => getLambdaOptionsFromFunction
|
35
|
+
});
|
36
|
+
module.exports = __toCommonJS(lambda_exports);
|
37
|
+
var import_assert = __toESM(require("assert"));
|
38
|
+
var import_async_sema = __toESM(require("async-sema"));
|
39
|
+
var import_yazl = require("yazl");
|
40
|
+
var import_minimatch = __toESM(require("minimatch"));
|
41
|
+
var import_fs_extra = require("fs-extra");
|
42
|
+
var import_download = require("./fs/download");
|
43
|
+
var import_stream_to_buffer = __toESM(require("./fs/stream-to-buffer"));
|
14
44
|
class Lambda {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
this.handler = handler;
|
60
|
-
this.runtime = runtime;
|
61
|
-
this.architecture = architecture;
|
62
|
-
this.memory = memory;
|
63
|
-
this.maxDuration = maxDuration;
|
64
|
-
this.environment = environment;
|
65
|
-
this.allowQuery = allowQuery;
|
66
|
-
this.regions = regions;
|
67
|
-
this.zipBuffer = 'zipBuffer' in opts ? opts.zipBuffer : undefined;
|
68
|
-
this.supportsMultiPayloads = supportsMultiPayloads;
|
69
|
-
this.supportsWrapper = supportsWrapper;
|
70
|
-
this.supportsResponseStreaming =
|
71
|
-
supportsResponseStreaming ?? experimentalResponseStreaming;
|
72
|
-
this.framework = framework;
|
45
|
+
constructor(opts) {
|
46
|
+
const {
|
47
|
+
handler,
|
48
|
+
runtime,
|
49
|
+
maxDuration,
|
50
|
+
architecture,
|
51
|
+
memory,
|
52
|
+
environment = {},
|
53
|
+
allowQuery,
|
54
|
+
regions,
|
55
|
+
supportsMultiPayloads,
|
56
|
+
supportsWrapper,
|
57
|
+
supportsResponseStreaming,
|
58
|
+
experimentalResponseStreaming,
|
59
|
+
operationType,
|
60
|
+
framework
|
61
|
+
} = opts;
|
62
|
+
if ("files" in opts) {
|
63
|
+
(0, import_assert.default)(typeof opts.files === "object", '"files" must be an object');
|
64
|
+
}
|
65
|
+
if ("zipBuffer" in opts) {
|
66
|
+
(0, import_assert.default)(Buffer.isBuffer(opts.zipBuffer), '"zipBuffer" must be a Buffer');
|
67
|
+
}
|
68
|
+
(0, import_assert.default)(typeof handler === "string", '"handler" is not a string');
|
69
|
+
(0, import_assert.default)(typeof runtime === "string", '"runtime" is not a string');
|
70
|
+
(0, import_assert.default)(typeof environment === "object", '"environment" is not an object');
|
71
|
+
if (architecture !== void 0) {
|
72
|
+
(0, import_assert.default)(
|
73
|
+
architecture === "x86_64" || architecture === "arm64",
|
74
|
+
'"architecture" must be either "x86_64" or "arm64"'
|
75
|
+
);
|
76
|
+
}
|
77
|
+
if (memory !== void 0) {
|
78
|
+
(0, import_assert.default)(typeof memory === "number", '"memory" is not a number');
|
79
|
+
}
|
80
|
+
if (maxDuration !== void 0) {
|
81
|
+
(0, import_assert.default)(typeof maxDuration === "number", '"maxDuration" is not a number');
|
82
|
+
}
|
83
|
+
if (allowQuery !== void 0) {
|
84
|
+
(0, import_assert.default)(Array.isArray(allowQuery), '"allowQuery" is not an Array');
|
85
|
+
(0, import_assert.default)(
|
86
|
+
allowQuery.every((q) => typeof q === "string"),
|
87
|
+
'"allowQuery" is not a string Array'
|
88
|
+
);
|
73
89
|
}
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
}
|
80
|
-
await sema.acquire();
|
81
|
-
try {
|
82
|
-
zipBuffer = await createZip(this.files);
|
83
|
-
}
|
84
|
-
finally {
|
85
|
-
sema.release();
|
86
|
-
}
|
87
|
-
}
|
88
|
-
return zipBuffer;
|
90
|
+
if (supportsMultiPayloads !== void 0) {
|
91
|
+
(0, import_assert.default)(
|
92
|
+
typeof supportsMultiPayloads === "boolean",
|
93
|
+
'"supportsMultiPayloads" is not a boolean'
|
94
|
+
);
|
89
95
|
}
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
96
|
+
if (supportsWrapper !== void 0) {
|
97
|
+
(0, import_assert.default)(
|
98
|
+
typeof supportsWrapper === "boolean",
|
99
|
+
'"supportsWrapper" is not a boolean'
|
100
|
+
);
|
95
101
|
}
|
96
|
-
|
97
|
-
|
102
|
+
if (regions !== void 0) {
|
103
|
+
(0, import_assert.default)(Array.isArray(regions), '"regions" is not an Array');
|
104
|
+
(0, import_assert.default)(
|
105
|
+
regions.every((r) => typeof r === "string"),
|
106
|
+
'"regions" is not a string Array'
|
107
|
+
);
|
98
108
|
}
|
109
|
+
if (framework !== void 0) {
|
110
|
+
(0, import_assert.default)(typeof framework === "object", '"framework" is not an object');
|
111
|
+
(0, import_assert.default)(
|
112
|
+
typeof framework.slug === "string",
|
113
|
+
'"framework.slug" is not a string'
|
114
|
+
);
|
115
|
+
if (framework.version !== void 0) {
|
116
|
+
(0, import_assert.default)(
|
117
|
+
typeof framework.version === "string",
|
118
|
+
'"framework.version" is not a string'
|
119
|
+
);
|
120
|
+
}
|
121
|
+
}
|
122
|
+
this.type = "Lambda";
|
123
|
+
this.operationType = operationType;
|
124
|
+
this.files = "files" in opts ? opts.files : void 0;
|
125
|
+
this.handler = handler;
|
126
|
+
this.runtime = runtime;
|
127
|
+
this.architecture = architecture;
|
128
|
+
this.memory = memory;
|
129
|
+
this.maxDuration = maxDuration;
|
130
|
+
this.environment = environment;
|
131
|
+
this.allowQuery = allowQuery;
|
132
|
+
this.regions = regions;
|
133
|
+
this.zipBuffer = "zipBuffer" in opts ? opts.zipBuffer : void 0;
|
134
|
+
this.supportsMultiPayloads = supportsMultiPayloads;
|
135
|
+
this.supportsWrapper = supportsWrapper;
|
136
|
+
this.supportsResponseStreaming = supportsResponseStreaming ?? experimentalResponseStreaming;
|
137
|
+
this.framework = framework;
|
138
|
+
}
|
139
|
+
async createZip() {
|
140
|
+
let { zipBuffer } = this;
|
141
|
+
if (!zipBuffer) {
|
142
|
+
if (!this.files) {
|
143
|
+
throw new Error("`files` is not defined");
|
144
|
+
}
|
145
|
+
await sema.acquire();
|
146
|
+
try {
|
147
|
+
zipBuffer = await createZip(this.files);
|
148
|
+
} finally {
|
149
|
+
sema.release();
|
150
|
+
}
|
151
|
+
}
|
152
|
+
return zipBuffer;
|
153
|
+
}
|
154
|
+
/**
|
155
|
+
* @deprecated Use the `supportsResponseStreaming` property instead.
|
156
|
+
*/
|
157
|
+
get experimentalResponseStreaming() {
|
158
|
+
return this.supportsResponseStreaming;
|
159
|
+
}
|
160
|
+
set experimentalResponseStreaming(v) {
|
161
|
+
this.supportsResponseStreaming = v;
|
162
|
+
}
|
99
163
|
}
|
100
|
-
|
101
|
-
const
|
102
|
-
const mtime = new Date(1540000000000);
|
103
|
-
/**
|
104
|
-
* @deprecated Use `new Lambda()` instead.
|
105
|
-
*/
|
164
|
+
const sema = new import_async_sema.default(10);
|
165
|
+
const mtime = /* @__PURE__ */ new Date(154e10);
|
106
166
|
async function createLambda(opts) {
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
return lambda;
|
167
|
+
const lambda = new Lambda(opts);
|
168
|
+
lambda.zipBuffer = await lambda.createZip();
|
169
|
+
return lambda;
|
111
170
|
}
|
112
|
-
exports.createLambda = createLambda;
|
113
171
|
async function createZip(files) {
|
114
|
-
|
115
|
-
|
172
|
+
const names = Object.keys(files).sort();
|
173
|
+
const symlinkTargets = /* @__PURE__ */ new Map();
|
174
|
+
for (const name of names) {
|
175
|
+
const file = files[name];
|
176
|
+
if (file.mode && (0, import_download.isSymbolicLink)(file.mode) && file.type === "FileFsRef") {
|
177
|
+
const symlinkTarget = await (0, import_fs_extra.readlink)(file.fsPath);
|
178
|
+
symlinkTargets.set(name, symlinkTarget);
|
179
|
+
}
|
180
|
+
}
|
181
|
+
const zipFile = new import_yazl.ZipFile();
|
182
|
+
const zipBuffer = await new Promise((resolve, reject) => {
|
116
183
|
for (const name of names) {
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
184
|
+
const file = files[name];
|
185
|
+
const opts = { mode: file.mode, mtime };
|
186
|
+
const symlinkTarget = symlinkTargets.get(name);
|
187
|
+
if (typeof symlinkTarget === "string") {
|
188
|
+
zipFile.addBuffer(Buffer.from(symlinkTarget, "utf8"), name, opts);
|
189
|
+
} else if (file.mode && (0, import_download.isDirectory)(file.mode)) {
|
190
|
+
zipFile.addEmptyDirectory(name, opts);
|
191
|
+
} else {
|
192
|
+
const stream = file.toStream();
|
193
|
+
stream.on("error", reject);
|
194
|
+
zipFile.addReadStream(stream, name, opts);
|
195
|
+
}
|
122
196
|
}
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
const opts = { mode: file.mode, mtime };
|
128
|
-
const symlinkTarget = symlinkTargets.get(name);
|
129
|
-
if (typeof symlinkTarget === 'string') {
|
130
|
-
zipFile.addBuffer(Buffer.from(symlinkTarget, 'utf8'), name, opts);
|
131
|
-
}
|
132
|
-
else if (file.mode && (0, download_1.isDirectory)(file.mode)) {
|
133
|
-
zipFile.addEmptyDirectory(name, opts);
|
134
|
-
}
|
135
|
-
else {
|
136
|
-
const stream = file.toStream();
|
137
|
-
stream.on('error', reject);
|
138
|
-
zipFile.addReadStream(stream, name, opts);
|
139
|
-
}
|
140
|
-
}
|
141
|
-
zipFile.end();
|
142
|
-
(0, stream_to_buffer_1.default)(zipFile.outputStream).then(resolve).catch(reject);
|
143
|
-
});
|
144
|
-
return zipBuffer;
|
197
|
+
zipFile.end();
|
198
|
+
(0, import_stream_to_buffer.default)(zipFile.outputStream).then(resolve).catch(reject);
|
199
|
+
});
|
200
|
+
return zipBuffer;
|
145
201
|
}
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
}
|
202
|
+
async function getLambdaOptionsFromFunction({
|
203
|
+
sourceFile,
|
204
|
+
config
|
205
|
+
}) {
|
206
|
+
if (config?.functions) {
|
207
|
+
for (const [pattern, fn] of Object.entries(config.functions)) {
|
208
|
+
if (sourceFile === pattern || (0, import_minimatch.default)(sourceFile, pattern)) {
|
209
|
+
return {
|
210
|
+
memory: fn.memory,
|
211
|
+
maxDuration: fn.maxDuration
|
212
|
+
};
|
213
|
+
}
|
157
214
|
}
|
158
|
-
|
215
|
+
}
|
216
|
+
return {};
|
159
217
|
}
|
160
|
-
|
218
|
+
// Annotate the CommonJS export names for ESM import in node:
|
219
|
+
0 && (module.exports = {
|
220
|
+
Lambda,
|
221
|
+
createLambda,
|
222
|
+
createZip,
|
223
|
+
getLambdaOptionsFromFunction
|
224
|
+
});
|
package/dist/nodejs-lambda.js
CHANGED
@@ -1,14 +1,42 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.defineProperty
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var nodejs_lambda_exports = {};
|
20
|
+
__export(nodejs_lambda_exports, {
|
21
|
+
NodejsLambda: () => NodejsLambda
|
22
|
+
});
|
23
|
+
module.exports = __toCommonJS(nodejs_lambda_exports);
|
24
|
+
var import_lambda = require("./lambda");
|
25
|
+
class NodejsLambda extends import_lambda.Lambda {
|
26
|
+
constructor({
|
27
|
+
shouldAddHelpers,
|
28
|
+
shouldAddSourcemapSupport,
|
29
|
+
awsLambdaHandler,
|
30
|
+
...opts
|
31
|
+
}) {
|
32
|
+
super(opts);
|
33
|
+
this.launcherType = "Nodejs";
|
34
|
+
this.shouldAddHelpers = shouldAddHelpers;
|
35
|
+
this.shouldAddSourcemapSupport = shouldAddSourcemapSupport;
|
36
|
+
this.awsLambdaHandler = awsLambdaHandler;
|
37
|
+
}
|
13
38
|
}
|
14
|
-
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
40
|
+
0 && (module.exports = {
|
41
|
+
NodejsLambda
|
42
|
+
});
|
package/dist/prerender.js
CHANGED
@@ -1,68 +1,113 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.defineProperty
|
3
|
-
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var prerender_exports = {};
|
20
|
+
__export(prerender_exports, {
|
21
|
+
Prerender: () => Prerender
|
22
|
+
});
|
23
|
+
module.exports = __toCommonJS(prerender_exports);
|
4
24
|
class Prerender {
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
typeof passQuery !== 'undefined') {
|
24
|
-
throw new Error(`The \`passQuery\` argument for \`Prerender\` must be a boolean.`);
|
25
|
-
}
|
26
|
-
if (bypassToken == null) {
|
27
|
-
this.bypassToken = null;
|
28
|
-
}
|
29
|
-
else if (typeof bypassToken === 'string') {
|
30
|
-
if (bypassToken.length < 32) {
|
31
|
-
// Enforce 128 bits of entropy for safety reasons (UUIDv4 size)
|
32
|
-
throw new Error('The `bypassToken` argument for `Prerender` must be 32 characters or more.');
|
33
|
-
}
|
34
|
-
this.bypassToken = bypassToken;
|
35
|
-
}
|
36
|
-
else {
|
37
|
-
throw new Error('The `bypassToken` argument for `Prerender` must be a `string`.');
|
38
|
-
}
|
39
|
-
if (typeof fallback === 'undefined') {
|
40
|
-
throw new Error('The `fallback` argument for `Prerender` needs to be a `FileBlob`, `FileFsRef`, `FileRef`, or null.');
|
41
|
-
}
|
42
|
-
this.fallback = fallback;
|
43
|
-
if (initialHeaders !== undefined) {
|
44
|
-
if (!initialHeaders ||
|
45
|
-
typeof initialHeaders !== 'object' ||
|
46
|
-
Object.entries(initialHeaders).some(([key, value]) => typeof key !== 'string' || typeof value !== 'string')) {
|
47
|
-
throw new Error(`The \`initialHeaders\` argument for \`Prerender\` must be an object with string key/values`);
|
48
|
-
}
|
49
|
-
this.initialHeaders = initialHeaders;
|
50
|
-
}
|
51
|
-
if (initialStatus !== undefined) {
|
52
|
-
if (initialStatus <= 0 || !Number.isInteger(initialStatus)) {
|
53
|
-
throw new Error(`The \`initialStatus\` argument for \`Prerender\` must be a natural number.`);
|
54
|
-
}
|
55
|
-
this.initialStatus = initialStatus;
|
56
|
-
}
|
57
|
-
if (allowQuery !== undefined) {
|
58
|
-
if (!Array.isArray(allowQuery)) {
|
59
|
-
throw new Error('The `allowQuery` argument for `Prerender` must be Array.');
|
60
|
-
}
|
61
|
-
if (!allowQuery.every(q => typeof q === 'string')) {
|
62
|
-
throw new Error('The `allowQuery` argument for `Prerender` must be Array of strings.');
|
63
|
-
}
|
64
|
-
this.allowQuery = allowQuery;
|
65
|
-
}
|
25
|
+
constructor({
|
26
|
+
expiration,
|
27
|
+
lambda,
|
28
|
+
fallback,
|
29
|
+
group,
|
30
|
+
bypassToken,
|
31
|
+
allowQuery,
|
32
|
+
initialHeaders,
|
33
|
+
initialStatus,
|
34
|
+
passQuery,
|
35
|
+
sourcePath
|
36
|
+
}) {
|
37
|
+
this.type = "Prerender";
|
38
|
+
this.expiration = expiration;
|
39
|
+
this.sourcePath = sourcePath;
|
40
|
+
this.lambda = lambda;
|
41
|
+
if (this.lambda) {
|
42
|
+
this.lambda.operationType = this.lambda.operationType || "ISR";
|
66
43
|
}
|
44
|
+
if (typeof group !== "undefined" && (group <= 0 || !Number.isInteger(group))) {
|
45
|
+
throw new Error(
|
46
|
+
"The `group` argument for `Prerender` needs to be a natural number."
|
47
|
+
);
|
48
|
+
}
|
49
|
+
this.group = group;
|
50
|
+
if (passQuery === true) {
|
51
|
+
this.passQuery = true;
|
52
|
+
} else if (typeof passQuery !== "boolean" && typeof passQuery !== "undefined") {
|
53
|
+
throw new Error(
|
54
|
+
`The \`passQuery\` argument for \`Prerender\` must be a boolean.`
|
55
|
+
);
|
56
|
+
}
|
57
|
+
if (bypassToken == null) {
|
58
|
+
this.bypassToken = null;
|
59
|
+
} else if (typeof bypassToken === "string") {
|
60
|
+
if (bypassToken.length < 32) {
|
61
|
+
throw new Error(
|
62
|
+
"The `bypassToken` argument for `Prerender` must be 32 characters or more."
|
63
|
+
);
|
64
|
+
}
|
65
|
+
this.bypassToken = bypassToken;
|
66
|
+
} else {
|
67
|
+
throw new Error(
|
68
|
+
"The `bypassToken` argument for `Prerender` must be a `string`."
|
69
|
+
);
|
70
|
+
}
|
71
|
+
if (typeof fallback === "undefined") {
|
72
|
+
throw new Error(
|
73
|
+
"The `fallback` argument for `Prerender` needs to be a `FileBlob`, `FileFsRef`, `FileRef`, or null."
|
74
|
+
);
|
75
|
+
}
|
76
|
+
this.fallback = fallback;
|
77
|
+
if (initialHeaders !== void 0) {
|
78
|
+
if (!initialHeaders || typeof initialHeaders !== "object" || Object.entries(initialHeaders).some(
|
79
|
+
([key, value]) => typeof key !== "string" || typeof value !== "string"
|
80
|
+
)) {
|
81
|
+
throw new Error(
|
82
|
+
`The \`initialHeaders\` argument for \`Prerender\` must be an object with string key/values`
|
83
|
+
);
|
84
|
+
}
|
85
|
+
this.initialHeaders = initialHeaders;
|
86
|
+
}
|
87
|
+
if (initialStatus !== void 0) {
|
88
|
+
if (initialStatus <= 0 || !Number.isInteger(initialStatus)) {
|
89
|
+
throw new Error(
|
90
|
+
`The \`initialStatus\` argument for \`Prerender\` must be a natural number.`
|
91
|
+
);
|
92
|
+
}
|
93
|
+
this.initialStatus = initialStatus;
|
94
|
+
}
|
95
|
+
if (allowQuery !== void 0) {
|
96
|
+
if (!Array.isArray(allowQuery)) {
|
97
|
+
throw new Error(
|
98
|
+
"The `allowQuery` argument for `Prerender` must be Array."
|
99
|
+
);
|
100
|
+
}
|
101
|
+
if (!allowQuery.every((q) => typeof q === "string")) {
|
102
|
+
throw new Error(
|
103
|
+
"The `allowQuery` argument for `Prerender` must be Array of strings."
|
104
|
+
);
|
105
|
+
}
|
106
|
+
this.allowQuery = allowQuery;
|
107
|
+
}
|
108
|
+
}
|
67
109
|
}
|
68
|
-
|
110
|
+
// Annotate the CommonJS export names for ESM import in node:
|
111
|
+
0 && (module.exports = {
|
112
|
+
Prerender
|
113
|
+
});
|