@vercel/build-utils 13.14.2 → 13.16.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 +20 -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/create-functions-iterator.d.ts +8 -0
- package/dist/deserialize/create-functions-iterator.js +52 -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/hydrate-files-map.d.ts +3 -0
- package/dist/deserialize/hydrate-files-map.js +55 -0
- package/dist/deserialize/maybe-read-json.d.ts +5 -0
- package/dist/deserialize/maybe-read-json.js +37 -0
- package/dist/deserialize/serialized-types.d.ts +28 -0
- package/dist/deserialize/serialized-types.js +16 -0
- package/dist/deserialize/validate-framework-version.d.ts +5 -0
- package/dist/deserialize/validate-framework-version.js +53 -0
- package/dist/framework-helpers.d.ts +1 -1
- package/dist/framework-helpers.js +2 -1
- package/dist/index.d.ts +12 -0
- package/dist/index.js +8727 -105
- package/dist/lambda.js +5 -6
- package/dist/types.d.ts +7 -1
- package/package.json +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @vercel/build-utils
|
|
2
2
|
|
|
3
|
+
## 13.16.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Add shared deserialization and build-result collection utilities. ([#15961](https://github.com/vercel/vercel/pull/15961))
|
|
8
|
+
|
|
9
|
+
- Add root to experimentalServices to set a service's working directory. ([#15929](https://github.com/vercel/vercel/pull/15929))
|
|
10
|
+
|
|
11
|
+
- Add a new flag to vercel deploy to let users deploy to hive ([#15892](https://github.com/vercel/vercel/pull/15892))
|
|
12
|
+
|
|
13
|
+
## 13.15.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- [services] allow multiple v2beta triggers for a single Lambda when config is coming from services ([#15890](https://github.com/vercel/vercel/pull/15890))
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Add deserialization utilities ([#15927](https://github.com/vercel/vercel/pull/15927))
|
|
22
|
+
|
|
3
23
|
## 13.14.2
|
|
4
24
|
|
|
5
25
|
### Patch 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,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates an async iterator that scans a directory for sub-directories
|
|
3
|
+
* that end with the suffix `.func`.
|
|
4
|
+
*
|
|
5
|
+
* @param dir Absolute path to scan for `.func` directories
|
|
6
|
+
* @param root The root directory from where the scanning started
|
|
7
|
+
*/
|
|
8
|
+
export declare function createFunctionsIterator(dir: string, root?: string): AsyncIterable<string>;
|
|
@@ -0,0 +1,52 @@
|
|
|
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 create_functions_iterator_exports = {};
|
|
20
|
+
__export(create_functions_iterator_exports, {
|
|
21
|
+
createFunctionsIterator: () => createFunctionsIterator
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(create_functions_iterator_exports);
|
|
24
|
+
var import_path = require("path");
|
|
25
|
+
var import_fs_extra = require("fs-extra");
|
|
26
|
+
const SUFFIX = ".func";
|
|
27
|
+
async function* createFunctionsIterator(dir, root = dir) {
|
|
28
|
+
let paths;
|
|
29
|
+
try {
|
|
30
|
+
paths = await (0, import_fs_extra.readdir)(dir);
|
|
31
|
+
} catch (err) {
|
|
32
|
+
if (err.code !== "ENOENT" && err.code !== "ENOTDIR") {
|
|
33
|
+
throw err;
|
|
34
|
+
}
|
|
35
|
+
paths = [];
|
|
36
|
+
}
|
|
37
|
+
for (const path of paths) {
|
|
38
|
+
const abs = (0, import_path.join)(dir, path);
|
|
39
|
+
const s = await (0, import_fs_extra.stat)(abs);
|
|
40
|
+
if (s.isDirectory()) {
|
|
41
|
+
if (path.endsWith(SUFFIX)) {
|
|
42
|
+
yield (0, import_path.relative)(root, abs.substring(0, abs.length - SUFFIX.length));
|
|
43
|
+
} else {
|
|
44
|
+
yield* createFunctionsIterator(abs, root);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
+
0 && (module.exports = {
|
|
51
|
+
createFunctionsIterator
|
|
52
|
+
});
|
|
@@ -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,55 @@
|
|
|
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 hydrate_files_map_exports = {};
|
|
30
|
+
__export(hydrate_files_map_exports, {
|
|
31
|
+
hydrateFilesMap: () => hydrateFilesMap
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(hydrate_files_map_exports);
|
|
34
|
+
var import_file_fs_ref = __toESM(require("../file-fs-ref"));
|
|
35
|
+
var import_path = require("path");
|
|
36
|
+
async function hydrateFilesMap(files, filesMap, repoRootPath, fileFsRefsCache) {
|
|
37
|
+
for (const [funcPath, projectPath] of Object.entries(filesMap)) {
|
|
38
|
+
files[funcPath] = await fileFsRefCached(
|
|
39
|
+
(0, import_path.join)(repoRootPath, projectPath),
|
|
40
|
+
fileFsRefsCache
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async function fileFsRefCached(fsPath, cache) {
|
|
45
|
+
let file = cache.get(fsPath);
|
|
46
|
+
if (!file) {
|
|
47
|
+
file = await import_file_fs_ref.default.fromFsPath({ fsPath });
|
|
48
|
+
cache.set(fsPath, file);
|
|
49
|
+
}
|
|
50
|
+
return file;
|
|
51
|
+
}
|
|
52
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
+
0 && (module.exports = {
|
|
54
|
+
hydrateFilesMap
|
|
55
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
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 maybe_read_json_exports = {};
|
|
20
|
+
__export(maybe_read_json_exports, {
|
|
21
|
+
maybeReadJSON: () => maybeReadJSON
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(maybe_read_json_exports);
|
|
24
|
+
var import_fs_extra = require("fs-extra");
|
|
25
|
+
async function maybeReadJSON(path) {
|
|
26
|
+
try {
|
|
27
|
+
return await (0, import_fs_extra.readJSON)(path);
|
|
28
|
+
} catch (err) {
|
|
29
|
+
if (err.code !== "ENOENT")
|
|
30
|
+
throw err;
|
|
31
|
+
}
|
|
32
|
+
return void 0;
|
|
33
|
+
}
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
maybeReadJSON
|
|
37
|
+
});
|