@vercel/build-utils 13.15.0 → 13.17.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/CHANGELOG.md +16 -0
- package/dist/collect-build-result/file-to-build-output-file.d.ts +26 -0
- package/dist/collect-build-result/file-to-build-output-file.js +54 -0
- package/dist/collect-build-result/get-content-type.d.ts +1 -0
- package/dist/collect-build-result/get-content-type.js +45 -0
- package/dist/collect-build-result/prerender-to-build-output-file.d.ts +23 -0
- package/dist/collect-build-result/prerender-to-build-output-file.js +85 -0
- package/dist/collect-build-result/validate-prerender.d.ts +8 -0
- package/dist/collect-build-result/validate-prerender.js +32 -0
- package/dist/collect-build-result/validate-regular-file.d.ts +9 -0
- package/dist/collect-build-result/validate-regular-file.js +42 -0
- package/dist/deserialize/deserialize-edge-function.d.ts +5 -0
- package/dist/deserialize/deserialize-edge-function.js +47 -0
- package/dist/deserialize/deserialize-lambda.d.ts +22 -0
- package/dist/deserialize/deserialize-lambda.js +56 -0
- package/dist/deserialize/serialized-types.d.ts +28 -0
- package/dist/deserialize/serialized-types.js +16 -0
- package/dist/framework-helpers.d.ts +1 -1
- package/dist/framework-helpers.js +2 -1
- package/dist/index.d.ts +9 -0
- package/dist/index.js +8572 -17
- package/dist/service-path-utils.d.ts +13 -0
- package/dist/service-path-utils.js +48 -0
- package/dist/types.d.ts +16 -1
- package/package.json +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @vercel/build-utils
|
|
2
2
|
|
|
3
|
+
## 13.17.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Support dynamically specifying crons from a python service ([#15930](https://github.com/vercel/vercel/pull/15930))
|
|
8
|
+
|
|
9
|
+
## 13.16.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- Add shared deserialization and build-result collection utilities. ([#15961](https://github.com/vercel/vercel/pull/15961))
|
|
14
|
+
|
|
15
|
+
- Add root to experimentalServices to set a service's working directory. ([#15929](https://github.com/vercel/vercel/pull/15929))
|
|
16
|
+
|
|
17
|
+
- Add a new flag to vercel deploy to let users deploy to hive ([#15892](https://github.com/vercel/vercel/pull/15892))
|
|
18
|
+
|
|
3
19
|
## 13.15.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { FileDigest } from '../fs/stream-to-digest-async';
|
|
2
|
+
import type FileFsRef from '../file-fs-ref';
|
|
3
|
+
import type FileRef from '../file-ref';
|
|
4
|
+
import type FileBlob from '../file-blob';
|
|
5
|
+
export interface BuildOutputFile {
|
|
6
|
+
contentType?: string;
|
|
7
|
+
digest: string;
|
|
8
|
+
lambda: null;
|
|
9
|
+
mode: number;
|
|
10
|
+
path: string;
|
|
11
|
+
paths?: string[];
|
|
12
|
+
size?: number;
|
|
13
|
+
type?: 'file';
|
|
14
|
+
prerenderPath?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function fileToBuildOutputFile(params: {
|
|
17
|
+
buildResult: FileBlob | FileFsRef | FileRef;
|
|
18
|
+
extendedBody?: {
|
|
19
|
+
prefix: string;
|
|
20
|
+
suffix: string;
|
|
21
|
+
};
|
|
22
|
+
outputPath: string;
|
|
23
|
+
}): Promise<{
|
|
24
|
+
output: BuildOutputFile;
|
|
25
|
+
digest: FileDigest;
|
|
26
|
+
}>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
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 file_to_build_output_file_exports = {};
|
|
20
|
+
__export(file_to_build_output_file_exports, {
|
|
21
|
+
fileToBuildOutputFile: () => fileToBuildOutputFile
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(file_to_build_output_file_exports);
|
|
24
|
+
var import_stream_to_digest_async = require("../fs/stream-to-digest-async");
|
|
25
|
+
var import_stream_with_extended_payload = require("./stream-with-extended-payload");
|
|
26
|
+
var import_validate_regular_file = require("./validate-regular-file");
|
|
27
|
+
var import_get_content_type = require("./get-content-type");
|
|
28
|
+
async function fileToBuildOutputFile(params) {
|
|
29
|
+
await (0, import_validate_regular_file.validateRegularFile)(params.buildResult);
|
|
30
|
+
const digest = await (0, import_stream_to_digest_async.streamToDigestAsync)(
|
|
31
|
+
(0, import_stream_with_extended_payload.streamWithExtendedPayload)(
|
|
32
|
+
params.buildResult.toStreamAsync ? await params.buildResult.toStreamAsync() : params.buildResult.toStream(),
|
|
33
|
+
params.extendedBody
|
|
34
|
+
)
|
|
35
|
+
);
|
|
36
|
+
const contentType = params.buildResult.contentType ? params.buildResult.contentType : "fsPath" in params.buildResult ? (0, import_get_content_type.getContentType)(params.buildResult.fsPath) : void 0;
|
|
37
|
+
return {
|
|
38
|
+
digest,
|
|
39
|
+
output: {
|
|
40
|
+
type: "file",
|
|
41
|
+
path: params.outputPath,
|
|
42
|
+
prerenderPath: params.buildResult.prerenderPath,
|
|
43
|
+
digest: digest.sha256,
|
|
44
|
+
mode: params.buildResult.mode,
|
|
45
|
+
contentType,
|
|
46
|
+
size: digest.size,
|
|
47
|
+
lambda: null
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
+
0 && (module.exports = {
|
|
53
|
+
fileToBuildOutputFile
|
|
54
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getContentType(path: string): string;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
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 });
|
|
11
|
+
};
|
|
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 get_content_type_exports = {};
|
|
30
|
+
__export(get_content_type_exports, {
|
|
31
|
+
getContentType: () => getContentType
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(get_content_type_exports);
|
|
34
|
+
var import_path = require("path");
|
|
35
|
+
var import_mime_types = __toESM(require("mime-types"));
|
|
36
|
+
function getContentType(path) {
|
|
37
|
+
if (path.endsWith(".html")) {
|
|
38
|
+
return "text/html; charset=utf-8";
|
|
39
|
+
}
|
|
40
|
+
return import_mime_types.default.contentType((0, import_path.extname)(path)) || "application/octet-stream";
|
|
41
|
+
}
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
44
|
+
getContentType
|
|
45
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { FileDigest } from '../fs/stream-to-digest-async';
|
|
2
|
+
import type { Prerender } from '../prerender';
|
|
3
|
+
import type { File } from '../types';
|
|
4
|
+
import { type BuildOutputFile } from './file-to-build-output-file';
|
|
5
|
+
interface PrerenderToBuildOutputFileResult {
|
|
6
|
+
digest: FileDigest;
|
|
7
|
+
extended: ExtendedPayload;
|
|
8
|
+
file: File;
|
|
9
|
+
output: BuildOutputFile;
|
|
10
|
+
}
|
|
11
|
+
export declare function prerenderToBuildOutputFile(params: {
|
|
12
|
+
buildResult: Prerender;
|
|
13
|
+
outputPath: string;
|
|
14
|
+
}): Promise<PrerenderToBuildOutputFileResult | null>;
|
|
15
|
+
export interface ExtendedPayload {
|
|
16
|
+
extendedBody: {
|
|
17
|
+
prefix: string;
|
|
18
|
+
suffix: string;
|
|
19
|
+
} | undefined;
|
|
20
|
+
fallback?: File | null;
|
|
21
|
+
initialHeaders: Record<string, string> | undefined;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
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 });
|
|
11
|
+
};
|
|
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 prerender_to_build_output_file_exports = {};
|
|
30
|
+
__export(prerender_to_build_output_file_exports, {
|
|
31
|
+
prerenderToBuildOutputFile: () => prerenderToBuildOutputFile
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(prerender_to_build_output_file_exports);
|
|
34
|
+
var import_file_blob = __toESM(require("../file-blob"));
|
|
35
|
+
var import_crypto = require("crypto");
|
|
36
|
+
var import_file_to_build_output_file = require("./file-to-build-output-file");
|
|
37
|
+
async function prerenderToBuildOutputFile(params) {
|
|
38
|
+
const extended = getExtendedPayload(params.buildResult);
|
|
39
|
+
if (!extended.fallback) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
const filePath = params.outputPath + ".fallback";
|
|
43
|
+
const { output, digest } = await (0, import_file_to_build_output_file.fileToBuildOutputFile)({
|
|
44
|
+
outputPath: filePath,
|
|
45
|
+
buildResult: extended.fallback,
|
|
46
|
+
extendedBody: extended.extendedBody
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
file: extended.fallback,
|
|
50
|
+
output,
|
|
51
|
+
digest,
|
|
52
|
+
extended
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
const CRLF = "\r\n";
|
|
56
|
+
const MULTIPART_HEADER = "multipart/x-nextjs-extended-payload";
|
|
57
|
+
function getExtendedPayload({
|
|
58
|
+
initialHeaders,
|
|
59
|
+
fallback
|
|
60
|
+
}) {
|
|
61
|
+
if (!initialHeaders || !Object.entries(initialHeaders).length) {
|
|
62
|
+
return { initialHeaders: void 0, fallback, extendedBody: void 0 };
|
|
63
|
+
}
|
|
64
|
+
const boundary = (0, import_crypto.randomBytes)(8).toString("hex");
|
|
65
|
+
return {
|
|
66
|
+
initialHeaders: {
|
|
67
|
+
...fallback ? {} : { "x-vercel-empty-fallback": "true" },
|
|
68
|
+
"content-type": `${MULTIPART_HEADER}; boundary=${boundary}`
|
|
69
|
+
},
|
|
70
|
+
fallback: fallback ?? new import_file_blob.default({ data: "" }),
|
|
71
|
+
extendedBody: {
|
|
72
|
+
suffix: `${CRLF}${CRLF}--${boundary}--${CRLF}`,
|
|
73
|
+
prefix: [
|
|
74
|
+
`--${boundary}`,
|
|
75
|
+
...Object.entries(initialHeaders).map(
|
|
76
|
+
([key, value]) => `${key}: ${value}`
|
|
77
|
+
)
|
|
78
|
+
].join(CRLF) + CRLF + CRLF
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
83
|
+
0 && (module.exports = {
|
|
84
|
+
prerenderToBuildOutputFile
|
|
85
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
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 validate_prerender_exports = {};
|
|
20
|
+
__export(validate_prerender_exports, {
|
|
21
|
+
validatePrerender: () => validatePrerender
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(validate_prerender_exports);
|
|
24
|
+
function validatePrerender(prerender) {
|
|
25
|
+
if (typeof prerender.lambda === "undefined") {
|
|
26
|
+
throw new Error(`Prerender "buildResult" is missing "lambda" property`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
validatePrerender
|
|
32
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type FileFsRef from '../file-fs-ref';
|
|
3
|
+
import { type Stats } from 'fs-extra';
|
|
4
|
+
interface FileLike {
|
|
5
|
+
fsPath?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function validateRegularFile(file: FileFsRef): Promise<Stats>;
|
|
8
|
+
export declare function validateRegularFile<T extends object>(file: FileLike | T): Promise<Stats | null>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
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 validate_regular_file_exports = {};
|
|
20
|
+
__export(validate_regular_file_exports, {
|
|
21
|
+
validateRegularFile: () => validateRegularFile
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(validate_regular_file_exports);
|
|
24
|
+
var import_errors = require("../errors");
|
|
25
|
+
var import_fs_extra = require("fs-extra");
|
|
26
|
+
async function validateRegularFile(file) {
|
|
27
|
+
if ("fsPath" in file && typeof file.fsPath === "string") {
|
|
28
|
+
const stat = await (0, import_fs_extra.lstat)(file.fsPath);
|
|
29
|
+
if (!stat.isFile() && !stat.isDirectory() && !stat.isSymbolicLink()) {
|
|
30
|
+
throw new import_errors.NowBuildError({
|
|
31
|
+
message: `Output file path is actually not a (regular) file: \`${file.fsPath}\``,
|
|
32
|
+
code: "OUTPUT_FILE_IS_NOT_REGULAR_FILE"
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return stat;
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
validateRegularFile
|
|
42
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Files } from '../types';
|
|
2
|
+
import { EdgeFunction } from '../edge-function';
|
|
3
|
+
import type FileFsRef from '../file-fs-ref';
|
|
4
|
+
import type { SerializedEdgeFunction } from './serialized-types';
|
|
5
|
+
export declare function deserializeEdgeFunction(files: Files, config: SerializedEdgeFunction, repoRootPath: string, fileFsRefsCache: Map<string, FileFsRef>): Promise<EdgeFunction>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
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 deserialize_edge_function_exports = {};
|
|
20
|
+
__export(deserialize_edge_function_exports, {
|
|
21
|
+
deserializeEdgeFunction: () => deserializeEdgeFunction
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(deserialize_edge_function_exports);
|
|
24
|
+
var import_edge_function = require("../edge-function");
|
|
25
|
+
var import_hydrate_files_map = require("./hydrate-files-map");
|
|
26
|
+
async function deserializeEdgeFunction(files, config, repoRootPath, fileFsRefsCache) {
|
|
27
|
+
if (config.filePathMap) {
|
|
28
|
+
await (0, import_hydrate_files_map.hydrateFilesMap)(
|
|
29
|
+
files,
|
|
30
|
+
config.filePathMap,
|
|
31
|
+
repoRootPath,
|
|
32
|
+
fileFsRefsCache
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
const edgeFunction = new import_edge_function.EdgeFunction({
|
|
36
|
+
// "v8-worker" is currently the only supported target, so specify
|
|
37
|
+
// it implicitly here so that `.vc-config.json` does not need to.
|
|
38
|
+
deploymentTarget: "v8-worker",
|
|
39
|
+
...config,
|
|
40
|
+
files
|
|
41
|
+
});
|
|
42
|
+
return edgeFunction;
|
|
43
|
+
}
|
|
44
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
45
|
+
0 && (module.exports = {
|
|
46
|
+
deserializeEdgeFunction
|
|
47
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Files } from '../types';
|
|
2
|
+
import { Lambda } from '../lambda';
|
|
3
|
+
import { NodejsLambda } from '../nodejs-lambda';
|
|
4
|
+
import type FileFsRef from '../file-fs-ref';
|
|
5
|
+
import type { SerializedLambda, SerializedNodejsLambda } from './serialized-types';
|
|
6
|
+
export interface DeserializeLambdaOptions {
|
|
7
|
+
useOnlyStreamingLambda?: boolean;
|
|
8
|
+
forceNodejsStreaming?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Custom Lambda class constructor. Defaults to the base Lambda class.
|
|
11
|
+
* Pass an extended class (e.g. with BYOC `external` property) to
|
|
12
|
+
* preserve extra properties through deserialization.
|
|
13
|
+
*/
|
|
14
|
+
LambdaClass?: typeof Lambda;
|
|
15
|
+
/**
|
|
16
|
+
* Custom NodejsLambda class constructor. Defaults to the base NodejsLambda class.
|
|
17
|
+
* Pass an extended class (e.g. with BYOC `external` property) to
|
|
18
|
+
* preserve extra properties through deserialization.
|
|
19
|
+
*/
|
|
20
|
+
NodejsLambdaClass?: typeof NodejsLambda;
|
|
21
|
+
}
|
|
22
|
+
export declare function deserializeLambda(files: Files, config: SerializedLambda | SerializedNodejsLambda, repoRootPath: string, fileFsRefsCache: Map<string, FileFsRef>, options?: DeserializeLambdaOptions): Promise<Lambda>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
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 deserialize_lambda_exports = {};
|
|
20
|
+
__export(deserialize_lambda_exports, {
|
|
21
|
+
deserializeLambda: () => deserializeLambda
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(deserialize_lambda_exports);
|
|
24
|
+
var import_lambda = require("../lambda");
|
|
25
|
+
var import_nodejs_lambda = require("../nodejs-lambda");
|
|
26
|
+
var import_hydrate_files_map = require("./hydrate-files-map");
|
|
27
|
+
async function deserializeLambda(files, config, repoRootPath, fileFsRefsCache, options) {
|
|
28
|
+
const LambdaCtor = options?.LambdaClass ?? import_lambda.Lambda;
|
|
29
|
+
const NodejsLambdaCtor = options?.NodejsLambdaClass ?? import_nodejs_lambda.NodejsLambda;
|
|
30
|
+
if (config.filePathMap) {
|
|
31
|
+
await (0, import_hydrate_files_map.hydrateFilesMap)(
|
|
32
|
+
files,
|
|
33
|
+
config.filePathMap,
|
|
34
|
+
repoRootPath,
|
|
35
|
+
fileFsRefsCache
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
const supportsResponseStreaming = config.supportsResponseStreaming ?? config.experimentalResponseStreaming;
|
|
39
|
+
if ("launcherType" in config && config.launcherType === "Nodejs") {
|
|
40
|
+
const overrideResponseStreaming = (options?.useOnlyStreamingLambda || options?.forceNodejsStreaming) && (config.awsLambdaHandler === void 0 || config.awsLambdaHandler === "");
|
|
41
|
+
return new NodejsLambdaCtor({
|
|
42
|
+
...config,
|
|
43
|
+
supportsResponseStreaming: overrideResponseStreaming || supportsResponseStreaming,
|
|
44
|
+
files
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return new LambdaCtor({
|
|
48
|
+
...config,
|
|
49
|
+
supportsResponseStreaming,
|
|
50
|
+
files
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
54
|
+
0 && (module.exports = {
|
|
55
|
+
deserializeLambda
|
|
56
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Lambda } from '../lambda';
|
|
2
|
+
import type { NodejsLambda } from '../nodejs-lambda';
|
|
3
|
+
import type { EdgeFunction } from '../edge-function';
|
|
4
|
+
import type FileFsRef from '../file-fs-ref';
|
|
5
|
+
import type { Prerender } from '../prerender';
|
|
6
|
+
/**
|
|
7
|
+
* Maps a type to a new type that does not contain any functions on it.
|
|
8
|
+
* Useful for typing serialized `class` types, which will not contain
|
|
9
|
+
* functions when serialized to JSON.
|
|
10
|
+
*/
|
|
11
|
+
export type Properties<T> = {
|
|
12
|
+
[P in keyof T as T[P] extends (...args: any[]) => any ? never : P]: T[P];
|
|
13
|
+
};
|
|
14
|
+
type FilesMapProp = {
|
|
15
|
+
filePathMap?: Record<string, string>;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Type for the `.vc-config.json` file of a serialized
|
|
19
|
+
* `ServerlessFunction` instance.
|
|
20
|
+
*/
|
|
21
|
+
export type SerializedLambda = Properties<Omit<Lambda, 'files' | 'zipBuffer'>> & FilesMapProp;
|
|
22
|
+
export type SerializedNodejsLambda = Properties<Omit<NodejsLambda, 'files' | 'zipBuffer'>> & FilesMapProp;
|
|
23
|
+
export type SerializedFileFsRef = Properties<FileFsRef>;
|
|
24
|
+
export type SerializedPrerender = Properties<Omit<Prerender, 'lambda' | 'fallback'>> & {
|
|
25
|
+
fallback: SerializedFileFsRef | null;
|
|
26
|
+
};
|
|
27
|
+
export type SerializedEdgeFunction = Properties<Omit<EdgeFunction, 'name' | 'files' | 'deploymentTarget'>> & FilesMapProp;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var serialized_types_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(serialized_types_exports);
|
|
@@ -3,7 +3,7 @@ import { Builder } from '.';
|
|
|
3
3
|
* List of backend frameworks supported by the experimental backends feature
|
|
4
4
|
*/
|
|
5
5
|
export declare const BACKEND_FRAMEWORKS: readonly ["express", "hono", "h3", "koa", "nestjs", "fastify", "elysia"];
|
|
6
|
-
export declare const PYTHON_FRAMEWORKS: readonly ["fastapi", "flask", "django", "python"];
|
|
6
|
+
export declare const PYTHON_FRAMEWORKS: readonly ["fastapi", "flask", "django", "python", "fasthtml"];
|
|
7
7
|
export declare const RUNTIME_FRAMEWORKS: readonly ["python"];
|
|
8
8
|
/**
|
|
9
9
|
* List of framework-specific backend builders that get replaced by UNIFIED_BACKEND_BUILDER
|
package/dist/index.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ export { generateNodeBuilderFunctions } from './generate-node-builder-functions'
|
|
|
37
37
|
export { BACKEND_FRAMEWORKS, BACKEND_BUILDERS, UNIFIED_BACKEND_BUILDER, BackendFramework, isBackendFramework, isNodeBackendFramework, isBackendBuilder, isExperimentalBackendsEnabled, isExperimentalBackendsWithoutIntrospectionEnabled, shouldUseExperimentalBackends, PYTHON_FRAMEWORKS, PythonFramework, isPythonFramework, } from './framework-helpers';
|
|
38
38
|
export * from './python';
|
|
39
39
|
export * from './node-entrypoint';
|
|
40
|
+
export * from './service-path-utils';
|
|
40
41
|
export { getEncryptedEnv, type EncryptedEnvFile, } from './process-serverless/get-encrypted-env-file';
|
|
41
42
|
export { getLambdaEnvironment } from './process-serverless/get-lambda-environment';
|
|
42
43
|
export { getLambdaPreloadScripts, type BytecodeCachingOptions, } from './process-serverless/get-lambda-preload-scripts';
|
|
@@ -54,3 +55,11 @@ export { validateFrameworkVersion } from './deserialize/validate-framework-versi
|
|
|
54
55
|
export { hydrateFilesMap } from './deserialize/hydrate-files-map';
|
|
55
56
|
export { createFunctionsIterator } from './deserialize/create-functions-iterator';
|
|
56
57
|
export { maybeReadJSON } from './deserialize/maybe-read-json';
|
|
58
|
+
export { deserializeLambda, type DeserializeLambdaOptions, } from './deserialize/deserialize-lambda';
|
|
59
|
+
export { deserializeEdgeFunction } from './deserialize/deserialize-edge-function';
|
|
60
|
+
export type { Properties, SerializedLambda, SerializedNodejsLambda, SerializedEdgeFunction, SerializedFileFsRef, SerializedPrerender, } from './deserialize/serialized-types';
|
|
61
|
+
export { validateRegularFile } from './collect-build-result/validate-regular-file';
|
|
62
|
+
export { validatePrerender } from './collect-build-result/validate-prerender';
|
|
63
|
+
export { getContentType } from './collect-build-result/get-content-type';
|
|
64
|
+
export { fileToBuildOutputFile, type BuildOutputFile, } from './collect-build-result/file-to-build-output-file';
|
|
65
|
+
export { prerenderToBuildOutputFile, type ExtendedPayload, } from './collect-build-result/prerender-to-build-output-file';
|