@payloadcms/figma 1.0.0-beta.4 → 1.0.0-beta.5
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/adapters/asset-collection.d.ts +15 -0
- package/dist/adapters/asset-collection.js +51 -45
- package/dist/adapters/build-lambda-zip.d.ts +8 -9
- package/dist/adapters/build-lambda-zip.js +36 -44
- package/dist/adapters/index.d.ts +4 -0
- package/dist/adapters/index.js +4 -0
- package/dist/adapters/lambdaLimits.d.ts +6 -0
- package/dist/adapters/lambdaLimits.js +5 -0
- package/dist/adapters/nextjs-assets.d.ts +7 -0
- package/dist/adapters/nextjs-assets.js +44 -0
- package/dist/adapters/nextjs.d.ts +8 -0
- package/dist/adapters/nextjs.js +19 -37
- package/dist/adapters/nitro.js +18 -43
- package/dist/adapters/omit-optional-sharp.d.ts +22 -0
- package/dist/adapters/omit-optional-sharp.js +158 -0
- package/dist/adapters/secret-files.js +8 -1
- package/dist/adapters/types.d.ts +8 -0
- package/dist/adapters/v2/core/build.d.ts +69 -0
- package/dist/adapters/v2/core/build.js +183 -0
- package/dist/adapters/v2/core/content-type.d.ts +3 -0
- package/dist/adapters/v2/core/content-type.js +41 -0
- package/dist/adapters/v2/core/getRelativePathError.d.ts +5 -0
- package/dist/adapters/v2/core/getRelativePathError.js +21 -0
- package/dist/adapters/v2/core/index.d.ts +15 -0
- package/dist/adapters/v2/core/index.js +13 -0
- package/dist/adapters/v2/core/limits.d.ts +28 -0
- package/dist/adapters/v2/core/limits.js +26 -0
- package/dist/adapters/v2/core/manifest-version.d.ts +10 -0
- package/dist/adapters/v2/core/manifest-version.js +14 -0
- package/dist/adapters/v2/core/server-zip.d.ts +58 -0
- package/dist/adapters/v2/core/server-zip.js +123 -0
- package/dist/adapters/v2/core/services.d.ts +46 -0
- package/dist/adapters/v2/core/services.js +202 -0
- package/dist/adapters/v2/core/static-path.d.ts +13 -0
- package/dist/adapters/v2/core/static-path.js +32 -0
- package/dist/adapters/v2/core/static-site.d.ts +26 -0
- package/dist/adapters/v2/core/static-site.js +95 -0
- package/dist/adapters/v2/core/types.d.ts +128 -0
- package/dist/adapters/v2/core/types.js +7 -0
- package/dist/adapters/v2/core/upload.d.ts +67 -0
- package/dist/adapters/v2/core/upload.js +198 -0
- package/dist/adapters/v2/core/validateDeployment/createIssue.d.ts +3 -0
- package/dist/adapters/v2/core/validateDeployment/createIssue.js +7 -0
- package/dist/adapters/v2/core/validateDeployment/escapePointer.d.ts +2 -0
- package/dist/adapters/v2/core/validateDeployment/escapePointer.js +3 -0
- package/dist/adapters/v2/core/validateDeployment/singletonHeaders.d.ts +2 -0
- package/dist/adapters/v2/core/validateDeployment/singletonHeaders.js +10 -0
- package/dist/adapters/v2/core/validateDeployment/types.d.ts +16 -0
- package/dist/adapters/v2/core/validateDeployment/types.js +8 -0
- package/dist/adapters/v2/core/validateDeployment/validateArtifacts.d.ts +3 -0
- package/dist/adapters/v2/core/validateDeployment/validateArtifacts.js +30 -0
- package/dist/adapters/v2/core/validateDeployment/validateCachePolicy.d.ts +8 -0
- package/dist/adapters/v2/core/validateDeployment/validateCachePolicy.js +26 -0
- package/dist/adapters/v2/core/validateDeployment/validateCounts/validateCount.d.ts +7 -0
- package/dist/adapters/v2/core/validateDeployment/validateCounts/validateCount.js +11 -0
- package/dist/adapters/v2/core/validateDeployment/validateCounts.d.ts +3 -0
- package/dist/adapters/v2/core/validateDeployment/validateCounts.js +41 -0
- package/dist/adapters/v2/core/validateDeployment/validateFallback.d.ts +3 -0
- package/dist/adapters/v2/core/validateDeployment/validateFallback.js +21 -0
- package/dist/adapters/v2/core/validateDeployment/validateHeaderName.d.ts +6 -0
- package/dist/adapters/v2/core/validateDeployment/validateHeaderName.js +13 -0
- package/dist/adapters/v2/core/validateDeployment/validateHeaderRules/validateHeaderOp/isReservedRuleHeader.d.ts +2 -0
- package/dist/adapters/v2/core/validateDeployment/validateHeaderRules/validateHeaderOp/isReservedRuleHeader.js +13 -0
- package/dist/adapters/v2/core/validateDeployment/validateHeaderRules/validateHeaderOp.d.ts +11 -0
- package/dist/adapters/v2/core/validateDeployment/validateHeaderRules/validateHeaderOp.js +38 -0
- package/dist/adapters/v2/core/validateDeployment/validateHeaderRules.d.ts +3 -0
- package/dist/adapters/v2/core/validateDeployment/validateHeaderRules.js +17 -0
- package/dist/adapters/v2/core/validateDeployment/validateHeaderValue.d.ts +6 -0
- package/dist/adapters/v2/core/validateDeployment/validateHeaderValue.js +24 -0
- package/dist/adapters/v2/core/validateDeployment/validateId.d.ts +7 -0
- package/dist/adapters/v2/core/validateDeployment/validateId.js +12 -0
- package/dist/adapters/v2/core/validateDeployment/validateMatch.d.ts +15 -0
- package/dist/adapters/v2/core/validateDeployment/validateMatch.js +74 -0
- package/dist/adapters/v2/core/validateDeployment/validatePublicPath.d.ts +7 -0
- package/dist/adapters/v2/core/validateDeployment/validatePublicPath.js +21 -0
- package/dist/adapters/v2/core/validateDeployment/validateResponses/validateHeaderList/findRepeatedSingletons.d.ts +3 -0
- package/dist/adapters/v2/core/validateDeployment/validateResponses/validateHeaderList/findRepeatedSingletons.js +16 -0
- package/dist/adapters/v2/core/validateDeployment/validateResponses/validateHeaderList.d.ts +11 -0
- package/dist/adapters/v2/core/validateDeployment/validateResponses/validateHeaderList.js +48 -0
- package/dist/adapters/v2/core/validateDeployment/validateResponses/validateResponseBody.d.ts +10 -0
- package/dist/adapters/v2/core/validateDeployment/validateResponses/validateResponseBody.js +16 -0
- package/dist/adapters/v2/core/validateDeployment/validateResponses/validateResponseStatus.d.ts +8 -0
- package/dist/adapters/v2/core/validateDeployment/validateResponses/validateResponseStatus.js +25 -0
- package/dist/adapters/v2/core/validateDeployment/validateResponses.d.ts +7 -0
- package/dist/adapters/v2/core/validateDeployment/validateResponses.js +59 -0
- package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateCaptures.d.ts +10 -0
- package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateCaptures.js +12 -0
- package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateRedirectAction.d.ts +14 -0
- package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateRedirectAction.js +59 -0
- package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateRewriteAction.d.ts +11 -0
- package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateRewriteAction.js +20 -0
- package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateServerAction.d.ts +11 -0
- package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateServerAction.js +26 -0
- package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateStaticAction.d.ts +13 -0
- package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateStaticAction.js +25 -0
- package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction.d.ts +12 -0
- package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction.js +35 -0
- package/dist/adapters/v2/core/validateDeployment/validateRoutes.d.ts +6 -0
- package/dist/adapters/v2/core/validateDeployment/validateRoutes.js +55 -0
- package/dist/adapters/v2/core/validateDeployment/validateServers/listReferencedServerIds.d.ts +3 -0
- package/dist/adapters/v2/core/validateDeployment/validateServers/listReferencedServerIds.js +12 -0
- package/dist/adapters/v2/core/validateDeployment/validateServers.d.ts +7 -0
- package/dist/adapters/v2/core/validateDeployment/validateServers.js +59 -0
- package/dist/adapters/v2/core/validateDeployment/validateStaticMap.d.ts +3 -0
- package/dist/adapters/v2/core/validateDeployment/validateStaticMap.js +22 -0
- package/dist/adapters/v2/core/validateDeployment.d.ts +7 -0
- package/dist/adapters/v2/core/validateDeployment.js +42 -0
- package/dist/adapters/v2/core/write.d.ts +21 -0
- package/dist/adapters/v2/core/write.js +30 -0
- package/dist/adapters/v2/nextjs/coverage.d.ts +45 -0
- package/dist/adapters/v2/nextjs/coverage.js +113 -0
- package/dist/adapters/v2/nextjs/read-build-output.d.ts +116 -0
- package/dist/adapters/v2/nextjs/read-build-output.js +368 -0
- package/dist/adapters/v2/nextjs/translate.d.ts +20 -0
- package/dist/adapters/v2/nextjs/translate.js +400 -0
- package/dist/adapters/vite.d.ts +7 -0
- package/dist/adapters/vite.js +47 -0
- package/dist/adapters/writeZip.d.ts +20 -0
- package/dist/adapters/writeZip.js +28 -0
- package/dist/api/control-plane.d.ts +28 -6
- package/dist/api/control-plane.js +67 -64
- package/dist/auth/cli-build-context.d.ts +3 -0
- package/dist/auth/cli-build-context.js +2 -0
- package/dist/auth/oauth-flow.d.ts +3 -3
- package/dist/auth/oauth-flow.js +13 -3
- package/dist/cli.js +15 -0
- package/dist/commands/build-manifest.d.ts +49 -0
- package/dist/commands/build-manifest.js +111 -0
- package/dist/commands/deploy.js +195 -26
- package/dist/db-content-api/generated/content-api-types.d.ts +18 -14
- package/dist/db-content-api/index.js +4 -1
- package/dist/db-content-api/utilities/where.js +2 -6
- package/dist/endpoints/client-config.d.ts +3 -0
- package/dist/endpoints/client-config.js +87 -0
- package/dist/image-transforms/constants.d.ts +8 -0
- package/dist/image-transforms/constants.js +26 -0
- package/dist/image-transforms/createImageTransformer.d.ts +6 -0
- package/dist/image-transforms/createImageTransformer.js +100 -0
- package/dist/image-transforms/deliverImageResponse.d.ts +11 -0
- package/dist/image-transforms/deliverImageResponse.js +43 -0
- package/dist/image-transforms/imageRevision.d.ts +14 -0
- package/dist/image-transforms/imageRevision.js +115 -0
- package/dist/image-transforms/normalizeMediaType.d.ts +2 -0
- package/dist/image-transforms/normalizeMediaType.js +3 -0
- package/dist/image-transforms/parseImageOverrides.d.ts +4 -0
- package/dist/image-transforms/parseImageOverrides.js +20 -0
- package/dist/image-transforms/preserveImageRedirectHeaders.d.ts +2 -0
- package/dist/image-transforms/preserveImageRedirectHeaders.js +30 -0
- package/dist/image-transforms/preventConflictingImageTransformers.d.ts +9 -0
- package/dist/image-transforms/preventConflictingImageTransformers.js +67 -0
- package/dist/image-transforms/serveImageRequest.d.ts +6 -0
- package/dist/image-transforms/serveImageRequest.js +97 -0
- package/dist/image-transforms/storedImage.d.ts +49 -0
- package/dist/image-transforms/storedImage.js +84 -0
- package/dist/image-transforms/types.d.ts +9 -0
- package/dist/image-transforms/types.js +1 -0
- package/dist/image-transforms/variantMetadata.d.ts +13 -0
- package/dist/image-transforms/variantMetadata.js +164 -0
- package/dist/imageSizeOptions.d.ts +8 -8
- package/dist/imageSizeOptions.js +0 -2
- package/dist/index.d.ts +1 -0
- package/dist/plugin/build-config.d.ts +3 -4
- package/dist/plugin/build-config.js +32 -16
- package/dist/storage-content-api/buildClientUploadFetchBackHeaders.d.ts +2 -1
- package/dist/storage-content-api/buildClientUploadFetchBackHeaders.js +2 -1
- package/dist/storage-content-api/buildMediaResponseHeaders.d.ts +2 -1
- package/dist/storage-content-api/buildMediaResponseHeaders.js +11 -5
- package/dist/storage-content-api/isRunningInLambda.d.ts +2 -0
- package/dist/storage-content-api/isRunningInLambda.js +3 -0
- package/dist/storage-content-api/staticHandler.js +13 -51
- package/dist/storage-content-api/streamMediaResponse.d.ts +17 -0
- package/dist/storage-content-api/streamMediaResponse.js +96 -0
- package/dist/utils/lambda-config.js +1 -1
- package/dist/utils/messages.js +8 -0
- package/dist/utils/next-image-loader-config.js +43 -6
- package/dist/utils/next-image-loader-file.js +8 -0
- package/package.json +7 -1
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { readJson } from './deploy-output/readJson.js';
|
|
4
|
+
/**
|
|
5
|
+
* Matches Sharp and its native packages (`@img/sharp-<platform>` and
|
|
6
|
+
* `@img/sharp-libvips-<platform>`) in both hoisted layouts
|
|
7
|
+
* (`node_modules/sharp/...`) and pnpm's isolated layout
|
|
8
|
+
* (`node_modules/.pnpm/sharp@<version>/node_modules/sharp/...`), including the
|
|
9
|
+
* package symlinks pnpm creates. Sharp's small pure-JS dependencies, such as
|
|
10
|
+
* `@img/colour`, may be shared with other packages and are left in place.
|
|
11
|
+
*/ const SHARP_PACKAGE_PATH = /(?:^|\/)node_modules\/(?:sharp|@img\/sharp-[^/]+)(?:\/|$)/;
|
|
12
|
+
/**
|
|
13
|
+
* Returns the Lambda bundle files without Sharp when the app holds Sharp only
|
|
14
|
+
* because Next.js optionally depends on it.
|
|
15
|
+
*
|
|
16
|
+
* Next's output tracing copies Sharp and its native binaries (about 40 MB) into
|
|
17
|
+
* standalone output for two optional uses:
|
|
18
|
+
* - Next's built-in image optimizer, which is off when the app uses a custom
|
|
19
|
+
* image loader or `images.unoptimized`.
|
|
20
|
+
* - `next/og`, which tries to import Sharp and otherwise renders with its
|
|
21
|
+
* bundled WebAssembly renderer. Payload's API routes import `next/og`, so
|
|
22
|
+
* their route traces list Sharp even when the app never uses it.
|
|
23
|
+
*
|
|
24
|
+
* Because those traces list Sharp either way, they cannot show whether an app
|
|
25
|
+
* needs it. Code that imports Sharp must declare it, though, so Sharp stays
|
|
26
|
+
* whenever the app or a package it depends on, other than Next, declares it,
|
|
27
|
+
* such as `@payloadcms/transformer-sharp`. The standalone output cannot answer
|
|
28
|
+
* that: Next bundles most dependencies into server chunks and leaves their
|
|
29
|
+
* package.json files out, so this reads the app's installed dependencies.
|
|
30
|
+
*/ export async function omitOptionalSharp(projectPath, outputPath, files, logger) {
|
|
31
|
+
const sharpFiles = files.filter((file)=>SHARP_PACKAGE_PATH.test(file.relativePath));
|
|
32
|
+
if (sharpFiles.length === 0 || !await isImageOptimizerDisabled(outputPath) || await mayDependenciesUseSharp(projectPath)) {
|
|
33
|
+
return files;
|
|
34
|
+
}
|
|
35
|
+
const megabytes = sharpFiles.reduce((total, file)=>total + file.size, 0) / 1024 / 1024;
|
|
36
|
+
logger?.info(`Omitting Sharp (${megabytes.toFixed(1)} MB) from lambda.zip: only Next.js depends on it, ` + "and Next's image optimizer is disabled. If your code imports Sharp, add sharp to your " + 'package.json dependencies.');
|
|
37
|
+
return files.filter((file)=>!SHARP_PACKAGE_PATH.test(file.relativePath));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Mirrors the condition under which Next's server stops serving `/_next/image`:
|
|
41
|
+
* a non-default loader, or `images.unoptimized`. Next records its resolved
|
|
42
|
+
* image config in `required-server-files.json`.
|
|
43
|
+
*/ async function isImageOptimizerDisabled(outputPath) {
|
|
44
|
+
const manifest = await readJson(path.join(outputPath, 'required-server-files.json'));
|
|
45
|
+
const config = manifest?.config;
|
|
46
|
+
const images = isRecord(config) ? config.images : undefined;
|
|
47
|
+
if (!isRecord(images)) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
return images.unoptimized === true || typeof images.loader === 'string' && images.loader !== 'default';
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* True when the app or an installed package it depends on, other than Next,
|
|
54
|
+
* declares Sharp, or when part of that dependency graph cannot be read.
|
|
55
|
+
*/ async function mayDependenciesUseSharp(projectPath) {
|
|
56
|
+
try {
|
|
57
|
+
return await isSharpInDependencyGraph(await fs.realpath(projectPath));
|
|
58
|
+
} catch {
|
|
59
|
+
// An unreadable manifest or package directory hides part of the graph.
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async function isSharpInDependencyGraph(appDir) {
|
|
64
|
+
// Read one manifest at a time: a large graph must not exhaust file handles.
|
|
65
|
+
const pending = [
|
|
66
|
+
{
|
|
67
|
+
dir: appDir,
|
|
68
|
+
isApp: true,
|
|
69
|
+
manifest: await readManifest(appDir)
|
|
70
|
+
}
|
|
71
|
+
];
|
|
72
|
+
const visited = new Set([
|
|
73
|
+
appDir
|
|
74
|
+
]);
|
|
75
|
+
for(let current = pending.pop(); current; current = pending.pop()){
|
|
76
|
+
const dependencies = listDependencies(current);
|
|
77
|
+
if (dependencies.has('sharp')) {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
for (const [name, isRequired] of dependencies){
|
|
81
|
+
// Next's optional Sharp dependency is the one being omitted.
|
|
82
|
+
if (name === 'next') {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
const dir = await findInstalledPackage(name, current.dir);
|
|
86
|
+
if (dir === null) {
|
|
87
|
+
// A missing required dependency means the graph here is incomplete,
|
|
88
|
+
// for example when packaging a build copied away from node_modules.
|
|
89
|
+
if (isRequired) {
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (!visited.has(dir)) {
|
|
95
|
+
visited.add(dir);
|
|
96
|
+
pending.push({
|
|
97
|
+
dir,
|
|
98
|
+
isApp: false,
|
|
99
|
+
manifest: await readManifest(dir)
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Maps each declared dependency name to whether it must be installed. Only the
|
|
108
|
+
* app's devDependencies are installed, and they are included because Next
|
|
109
|
+
* bundles whatever server code imports, even from a devDependency.
|
|
110
|
+
*/ function listDependencies({ isApp, manifest }) {
|
|
111
|
+
const dependencies = new Map();
|
|
112
|
+
for (const name of dependencyNames(manifest.dependencies)){
|
|
113
|
+
dependencies.set(name, true);
|
|
114
|
+
}
|
|
115
|
+
const optionalFields = [
|
|
116
|
+
'optionalDependencies',
|
|
117
|
+
'peerDependencies',
|
|
118
|
+
isApp && 'devDependencies'
|
|
119
|
+
];
|
|
120
|
+
for (const field of optionalFields){
|
|
121
|
+
for (const name of field ? dependencyNames(manifest[field]) : []){
|
|
122
|
+
dependencies.set(name, false);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return dependencies;
|
|
126
|
+
}
|
|
127
|
+
function dependencyNames(field) {
|
|
128
|
+
return isRecord(field) ? Object.keys(field) : [];
|
|
129
|
+
}
|
|
130
|
+
/** Finds the real directory Node would load `name` from, for code in `fromDir`. */ async function findInstalledPackage(name, fromDir) {
|
|
131
|
+
for(let dir = fromDir;; dir = path.dirname(dir)){
|
|
132
|
+
// Like Node, skip `node_modules/node_modules` lookups.
|
|
133
|
+
if (path.basename(dir) !== 'node_modules') {
|
|
134
|
+
try {
|
|
135
|
+
return await fs.realpath(path.join(dir, 'node_modules', name));
|
|
136
|
+
} catch (error) {
|
|
137
|
+
const code = error.code;
|
|
138
|
+
if (code !== 'ENOENT' && code !== 'ENOTDIR') {
|
|
139
|
+
throw error;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (path.dirname(dir) === dir) {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
async function readManifest(packageDir) {
|
|
149
|
+
const manifestPath = path.join(packageDir, 'package.json');
|
|
150
|
+
const manifest = JSON.parse(await fs.readFile(manifestPath, 'utf8'));
|
|
151
|
+
if (!isRecord(manifest)) {
|
|
152
|
+
throw new Error(`${manifestPath} is not a JSON object`);
|
|
153
|
+
}
|
|
154
|
+
return manifest;
|
|
155
|
+
}
|
|
156
|
+
function isRecord(value) {
|
|
157
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
158
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FIGMA_BUILD_DIR } from './v2/core/write.js';
|
|
1
2
|
/**
|
|
2
3
|
* Local secrets and private history that must never leave the developer's
|
|
3
4
|
* machine: environment files, git history, and credential files.
|
|
@@ -23,7 +24,7 @@
|
|
|
23
24
|
* Every collected asset becomes a publicly reachable route, so `node_modules`
|
|
24
25
|
* is excluded here too.
|
|
25
26
|
*/ export function isPublishableAsset(key) {
|
|
26
|
-
return key.split('/').every((segment)=>segment !== DEPENDENCY_DIR && !isSecretName(segment));
|
|
27
|
+
return key.split('/').every((segment)=>segment !== DEPENDENCY_DIR && !isSecretName(segment) && !isBuildOutput(segment));
|
|
27
28
|
}
|
|
28
29
|
/**
|
|
29
30
|
* True when a forward-slash bundle path belongs in a Lambda zip.
|
|
@@ -40,11 +41,17 @@
|
|
|
40
41
|
* runtime would break the bundle.
|
|
41
42
|
*/ export function isBundlableFile(relativePath) {
|
|
42
43
|
const segments = relativePath.split('/');
|
|
44
|
+
if (segments.some(isBuildOutput)) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
43
47
|
if (segments.includes(DEPENDENCY_DIR)) {
|
|
44
48
|
return true;
|
|
45
49
|
}
|
|
46
50
|
return segments.every((segment)=>segment === BUNDLABLE_ENV_FILE || !isSecretName(segment));
|
|
47
51
|
}
|
|
52
|
+
function isBuildOutput(segment) {
|
|
53
|
+
return segment === FIGMA_BUILD_DIR;
|
|
54
|
+
}
|
|
48
55
|
function isSecretName(segment) {
|
|
49
56
|
return SECRET_NAMES.has(segment) || segment.startsWith('.env');
|
|
50
57
|
}
|
package/dist/adapters/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DeploymentInput } from './v2/core/build.js';
|
|
1
2
|
export interface PageCollection {
|
|
2
3
|
/** S3 key → relative filesystem path from project root */
|
|
3
4
|
pathMap: Record<string, string>;
|
|
@@ -34,6 +35,13 @@ export interface PrepareLambdaBundleOptions {
|
|
|
34
35
|
export interface DeployAdapter {
|
|
35
36
|
collectAssets(projectPath: string, output?: string): Promise<AssetCollection>;
|
|
36
37
|
collectPages(projectPath: string, output?: string): Promise<PageCollection>;
|
|
38
|
+
/**
|
|
39
|
+
* Describes the build as manifest v2 input. Absent until the adapter supports manifest v2.
|
|
40
|
+
* `artifactDir` receives generated files such as the server ZIP.
|
|
41
|
+
*/
|
|
42
|
+
createManifestV2Input?(projectPath: string, output?: string, options?: {
|
|
43
|
+
artifactDir: string;
|
|
44
|
+
}): Promise<DeploymentInput>;
|
|
37
45
|
/** SPA fallback path (e.g., "/index.html"). Undefined for SSR/SSG apps. */
|
|
38
46
|
fallback?: string;
|
|
39
47
|
name: AdapterName;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { DeploymentManifestV2, ManifestCachePolicy, ManifestFallback, ManifestGenerator, ManifestHeader, ManifestHeaderRule, ManifestId, ManifestRoute, ManifestServices, ManifestSource } from './types.js';
|
|
2
|
+
import type { ManifestIssue } from './validateDeployment/types.js';
|
|
3
|
+
/** A static response a framework adapter reports. */
|
|
4
|
+
export interface ResponseInput {
|
|
5
|
+
cache?: ManifestCachePolicy;
|
|
6
|
+
/** Defaults to the body file's extension. Ignored for a bodyless response. */
|
|
7
|
+
contentType?: string;
|
|
8
|
+
/** Absolute path of the body file inside `rootDir`, or null for a response without a body. */
|
|
9
|
+
file: null | string;
|
|
10
|
+
/** Headers other than Content-Type, in order. */
|
|
11
|
+
headers?: ManifestHeader[];
|
|
12
|
+
/** Defaults to 200. */
|
|
13
|
+
status?: number;
|
|
14
|
+
}
|
|
15
|
+
/** A server whose ZIP `packageServer` already built. */
|
|
16
|
+
export interface ServerInput {
|
|
17
|
+
/** ZIP-relative path of the file the platform starts. */
|
|
18
|
+
entrypoint: string;
|
|
19
|
+
/** Absolute path of the server ZIP. */
|
|
20
|
+
zipPath: string;
|
|
21
|
+
}
|
|
22
|
+
/** What a framework adapter built. Response bodies and servers name local files, not artifacts. */
|
|
23
|
+
export interface DeploymentInput {
|
|
24
|
+
fallback: ManifestFallback;
|
|
25
|
+
generator?: ManifestGenerator;
|
|
26
|
+
headers?: ManifestHeaderRule[];
|
|
27
|
+
responses: Record<ManifestId, ResponseInput>;
|
|
28
|
+
/** Every response body must resolve inside this directory. */
|
|
29
|
+
rootDir: string;
|
|
30
|
+
routes?: ManifestRoute[];
|
|
31
|
+
servers?: Record<ManifestId, ServerInput>;
|
|
32
|
+
services?: ManifestServices;
|
|
33
|
+
source?: ManifestSource;
|
|
34
|
+
static?: Record<string, ManifestId>;
|
|
35
|
+
}
|
|
36
|
+
/** A local file behind a manifest artifact. Never part of the manifest itself. */
|
|
37
|
+
export interface LocalArtifact {
|
|
38
|
+
path: string;
|
|
39
|
+
sha256: string;
|
|
40
|
+
size: number;
|
|
41
|
+
}
|
|
42
|
+
export interface BuiltDeployment {
|
|
43
|
+
/** The uploader's map from artifact ID to local file. */
|
|
44
|
+
artifacts: Record<ManifestId, LocalArtifact>;
|
|
45
|
+
manifest: DeploymentManifestV2;
|
|
46
|
+
/** Problems that don't stop the deploy, for the CLI to show. */
|
|
47
|
+
warnings: string[];
|
|
48
|
+
}
|
|
49
|
+
export declare class ManifestV2Error extends Error {
|
|
50
|
+
readonly issues: ManifestIssue[];
|
|
51
|
+
constructor(issues: ManifestIssue[]);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Hashes every artifact and assembles a manifest v2 submission, then validates it. Identical bytes
|
|
55
|
+
* share one artifact, so they upload once. Throws {@link ManifestV2Error} when the manifest breaks
|
|
56
|
+
* the base contract, and a plain error when a file is missing, unsafe or too large. Returns a
|
|
57
|
+
* warning when the manifest is over the size warning threshold.
|
|
58
|
+
*/
|
|
59
|
+
export declare function buildDeploymentManifestV2(input: DeploymentInput): Promise<BuiltDeployment>;
|
|
60
|
+
/**
|
|
61
|
+
* Turns a public path into a readable response ID that follows the manifest ID rules, adding a
|
|
62
|
+
* numeric suffix when `taken` already holds it. Adds the result to `taken`.
|
|
63
|
+
*/
|
|
64
|
+
export declare function responseIdForPath(publicPath: string, taken: Set<string>): ManifestId;
|
|
65
|
+
/** Streams a file and returns its lowercase hex SHA-256 and byte size. */
|
|
66
|
+
export declare function hashFile(filePath: string): Promise<{
|
|
67
|
+
sha256: string;
|
|
68
|
+
size: number;
|
|
69
|
+
}>;
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { createHash } from 'crypto';
|
|
2
|
+
import { createReadStream } from 'fs';
|
|
3
|
+
import fs from 'fs/promises';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { isPublishableAsset } from '../../secret-files.js';
|
|
6
|
+
import { contentTypeForPath } from './content-type.js';
|
|
7
|
+
import { MANIFEST_V2_LIMITS, MAX_RESPONSE_ARTIFACT_BYTES } from './limits.js';
|
|
8
|
+
import { validateDeployment } from './validateDeployment.js';
|
|
9
|
+
export class ManifestV2Error extends Error {
|
|
10
|
+
issues;
|
|
11
|
+
constructor(issues){
|
|
12
|
+
super(formatIssues(issues)), this.issues = issues;
|
|
13
|
+
this.name = 'ManifestV2Error';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Hashes every artifact and assembles a manifest v2 submission, then validates it. Identical bytes
|
|
18
|
+
* share one artifact, so they upload once. Throws {@link ManifestV2Error} when the manifest breaks
|
|
19
|
+
* the base contract, and a plain error when a file is missing, unsafe or too large. Returns a
|
|
20
|
+
* warning when the manifest is over the size warning threshold.
|
|
21
|
+
*/ export async function buildDeploymentManifestV2(input) {
|
|
22
|
+
const rootReal = await fs.realpath(input.rootDir);
|
|
23
|
+
const artifacts = {};
|
|
24
|
+
const addArtifact = async (filePath)=>{
|
|
25
|
+
const { sha256, size } = await hashFile(filePath);
|
|
26
|
+
// The digest is the ID: identical bytes upload once, and the ID is stable across builds.
|
|
27
|
+
artifacts[sha256] ??= {
|
|
28
|
+
path: filePath,
|
|
29
|
+
sha256,
|
|
30
|
+
size
|
|
31
|
+
};
|
|
32
|
+
return sha256;
|
|
33
|
+
};
|
|
34
|
+
const responses = {};
|
|
35
|
+
for (const [id, response] of Object.entries(input.responses)){
|
|
36
|
+
let body = null;
|
|
37
|
+
if (response.file !== null) {
|
|
38
|
+
const relativePath = await assertPublicFile(rootReal, response.file);
|
|
39
|
+
body = {
|
|
40
|
+
artifact: await addArtifact(response.file)
|
|
41
|
+
};
|
|
42
|
+
if (artifacts[body.artifact].size > MAX_RESPONSE_ARTIFACT_BYTES) {
|
|
43
|
+
throw new Error(`${relativePath} is ${artifacts[body.artifact].size} bytes; the limit is ${MAX_RESPONSE_ARTIFACT_BYTES}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
responses[id] = {
|
|
47
|
+
body,
|
|
48
|
+
...response.cache ? {
|
|
49
|
+
cache: response.cache
|
|
50
|
+
} : {},
|
|
51
|
+
...toMetadata(response)
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
const servers = {};
|
|
55
|
+
for (const [id, server] of Object.entries(input.servers ?? {})){
|
|
56
|
+
servers[id] = {
|
|
57
|
+
artifact: await addArtifact(server.zipPath),
|
|
58
|
+
entrypoint: server.entrypoint,
|
|
59
|
+
runtime: 'nodejs',
|
|
60
|
+
runtimeVersion: '24'
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const manifest = {
|
|
64
|
+
version: 2,
|
|
65
|
+
...input.source ? {
|
|
66
|
+
source: input.source
|
|
67
|
+
} : {},
|
|
68
|
+
...input.generator ? {
|
|
69
|
+
generator: input.generator
|
|
70
|
+
} : {},
|
|
71
|
+
...Object.keys(servers).length > 0 ? {
|
|
72
|
+
servers
|
|
73
|
+
} : {},
|
|
74
|
+
...input.services ? {
|
|
75
|
+
services: input.services
|
|
76
|
+
} : {},
|
|
77
|
+
artifacts: Object.fromEntries(Object.entries(artifacts).map(([id, { sha256, size }])=>[
|
|
78
|
+
id,
|
|
79
|
+
{
|
|
80
|
+
sha256,
|
|
81
|
+
size
|
|
82
|
+
}
|
|
83
|
+
])),
|
|
84
|
+
responses,
|
|
85
|
+
routes: input.routes ?? [],
|
|
86
|
+
static: input.static ?? {},
|
|
87
|
+
...input.headers?.length ? {
|
|
88
|
+
headers: input.headers
|
|
89
|
+
} : {},
|
|
90
|
+
fallback: input.fallback
|
|
91
|
+
};
|
|
92
|
+
const issues = validateDeployment(manifest);
|
|
93
|
+
if (issues.length > 0) {
|
|
94
|
+
throw new ManifestV2Error(issues);
|
|
95
|
+
}
|
|
96
|
+
const manifestBytes = Buffer.byteLength(JSON.stringify(manifest));
|
|
97
|
+
const warnings = manifestBytes > MANIFEST_V2_LIMITS.warnManifestBytes ? [
|
|
98
|
+
`The manifest is ${manifestBytes} bytes, over the ${MANIFEST_V2_LIMITS.warnManifestBytes}-byte warning threshold. The limit is ${MANIFEST_V2_LIMITS.maxManifestBytes}.`
|
|
99
|
+
] : [];
|
|
100
|
+
return {
|
|
101
|
+
artifacts,
|
|
102
|
+
manifest,
|
|
103
|
+
warnings
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Turns a public path into a readable response ID that follows the manifest ID rules, adding a
|
|
108
|
+
* numeric suffix when `taken` already holds it. Adds the result to `taken`.
|
|
109
|
+
*/ export function responseIdForPath(publicPath, taken) {
|
|
110
|
+
const slug = publicPath.replace(/^\/+/, '').replace(/[^\w.-]+/g, '-').replace(/^[^A-Z0-9]+/i, '').slice(0, 110) || 'index';
|
|
111
|
+
let id = slug;
|
|
112
|
+
for(let suffix = 2; taken.has(id); suffix++){
|
|
113
|
+
id = `${slug}-${suffix}`;
|
|
114
|
+
}
|
|
115
|
+
taken.add(id);
|
|
116
|
+
return id;
|
|
117
|
+
}
|
|
118
|
+
/** Streams a file and returns its lowercase hex SHA-256 and byte size. */ export async function hashFile(filePath) {
|
|
119
|
+
const hash = createHash('sha256');
|
|
120
|
+
let size = 0;
|
|
121
|
+
for await (const chunk of createReadStream(filePath)){
|
|
122
|
+
hash.update(chunk);
|
|
123
|
+
size += chunk.byteLength;
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
sha256: hash.digest('hex'),
|
|
127
|
+
size
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function toMetadata(response) {
|
|
131
|
+
const headers = [];
|
|
132
|
+
if (response.file !== null) {
|
|
133
|
+
const contentType = response.contentType ?? contentTypeForPath(response.file);
|
|
134
|
+
headers.push({
|
|
135
|
+
name: 'Content-Type',
|
|
136
|
+
value: contentType
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
headers.push(...response.headers ?? []);
|
|
140
|
+
if (headers.length === 0 && (response.status ?? 200) === 200) {
|
|
141
|
+
return {};
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
metadata: {
|
|
145
|
+
headers,
|
|
146
|
+
status: response.status ?? 200
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Checks that a response body is a regular file whose real path stays inside the root and holds
|
|
152
|
+
* no secret path segment. Returns its forward-slash path relative to the root.
|
|
153
|
+
*/ async function assertPublicFile(rootReal, filePath) {
|
|
154
|
+
let fileReal;
|
|
155
|
+
try {
|
|
156
|
+
fileReal = await fs.realpath(filePath);
|
|
157
|
+
} catch {
|
|
158
|
+
throw new Error(`Response file not found: ${filePath}`);
|
|
159
|
+
}
|
|
160
|
+
const relative = path.relative(rootReal, fileReal);
|
|
161
|
+
if (relative === '' || relative.startsWith(`..${path.sep}`) || relative === '..' || path.isAbsolute(relative)) {
|
|
162
|
+
throw new Error(`Response file ${filePath} resolves outside ${rootReal}`);
|
|
163
|
+
}
|
|
164
|
+
const relativePath = relative.split(path.sep).join('/');
|
|
165
|
+
if (!isPublishableAsset(relativePath)) {
|
|
166
|
+
throw new Error(`Response file ${relativePath} is private and cannot be published`);
|
|
167
|
+
}
|
|
168
|
+
if (!(await fs.stat(fileReal)).isFile()) {
|
|
169
|
+
throw new Error(`Response file ${relativePath} is not a regular file`);
|
|
170
|
+
}
|
|
171
|
+
return relativePath;
|
|
172
|
+
}
|
|
173
|
+
function formatIssues(issues) {
|
|
174
|
+
const shown = issues.slice(0, 10).map((issue)=>` ${issue.code} at ${issue.pointer || '/'}: ${issue.message}`);
|
|
175
|
+
const more = issues.length > shown.length ? [
|
|
176
|
+
` ...and ${issues.length - shown.length} more`
|
|
177
|
+
] : [];
|
|
178
|
+
return [
|
|
179
|
+
'Manifest v2 is invalid:',
|
|
180
|
+
...shown,
|
|
181
|
+
...more
|
|
182
|
+
].join('\n');
|
|
183
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
/**
|
|
3
|
+
* Content types for known build output. Manifest v2 has no implicit content type for a response
|
|
4
|
+
* body other than application/octet-stream, so the core always sets one explicitly.
|
|
5
|
+
*/ const CONTENT_TYPES = {
|
|
6
|
+
'.avif': 'image/avif',
|
|
7
|
+
'.css': 'text/css; charset=utf-8',
|
|
8
|
+
'.csv': 'text/csv; charset=utf-8',
|
|
9
|
+
'.eot': 'application/vnd.ms-fontobject',
|
|
10
|
+
'.gif': 'image/gif',
|
|
11
|
+
'.htm': 'text/html; charset=utf-8',
|
|
12
|
+
'.html': 'text/html; charset=utf-8',
|
|
13
|
+
'.ico': 'image/x-icon',
|
|
14
|
+
'.jpeg': 'image/jpeg',
|
|
15
|
+
'.jpg': 'image/jpeg',
|
|
16
|
+
'.js': 'text/javascript; charset=utf-8',
|
|
17
|
+
'.json': 'application/json',
|
|
18
|
+
'.map': 'application/json',
|
|
19
|
+
'.md': 'text/markdown; charset=utf-8',
|
|
20
|
+
'.mjs': 'text/javascript; charset=utf-8',
|
|
21
|
+
'.mp3': 'audio/mpeg',
|
|
22
|
+
'.mp4': 'video/mp4',
|
|
23
|
+
'.otf': 'font/otf',
|
|
24
|
+
'.pdf': 'application/pdf',
|
|
25
|
+
'.png': 'image/png',
|
|
26
|
+
'.rsc': 'text/x-component',
|
|
27
|
+
'.svg': 'image/svg+xml',
|
|
28
|
+
'.ttf': 'font/ttf',
|
|
29
|
+
'.txt': 'text/plain; charset=utf-8',
|
|
30
|
+
'.wasm': 'application/wasm',
|
|
31
|
+
'.webm': 'video/webm',
|
|
32
|
+
'.webmanifest': 'application/manifest+json',
|
|
33
|
+
'.webp': 'image/webp',
|
|
34
|
+
'.woff': 'font/woff',
|
|
35
|
+
'.woff2': 'font/woff2',
|
|
36
|
+
'.xml': 'application/xml'
|
|
37
|
+
};
|
|
38
|
+
export const DEFAULT_CONTENT_TYPE = 'application/octet-stream';
|
|
39
|
+
/** Returns the content type for a file name from its extension. */ export function contentTypeForPath(filePath) {
|
|
40
|
+
return CONTENT_TYPES[path.extname(filePath).toLowerCase()] ?? DEFAULT_CONTENT_TYPE;
|
|
41
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Explains why a ZIP-relative path is unsafe, or returns undefined when it is a plain relative
|
|
3
|
+
* path. Used for server entrypoints and server ZIP entries.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getRelativePathError(relativePath: string): "is empty" | "must be relative" | "cannot contain a backslash" | "cannot be a URL" | "cannot contain empty, \".\" or \"..\" segments" | undefined;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Explains why a ZIP-relative path is unsafe, or returns undefined when it is a plain relative
|
|
3
|
+
* path. Used for server entrypoints and server ZIP entries.
|
|
4
|
+
*/ export function getRelativePathError(relativePath) {
|
|
5
|
+
if (relativePath.length === 0) {
|
|
6
|
+
return 'is empty';
|
|
7
|
+
}
|
|
8
|
+
if (relativePath.startsWith('/')) {
|
|
9
|
+
return 'must be relative';
|
|
10
|
+
}
|
|
11
|
+
if (relativePath.includes('\\')) {
|
|
12
|
+
return 'cannot contain a backslash';
|
|
13
|
+
}
|
|
14
|
+
if (/^[A-Z][A-Z0-9+.-]*:/i.test(relativePath)) {
|
|
15
|
+
return 'cannot be a URL';
|
|
16
|
+
}
|
|
17
|
+
if (relativePath.split('/').some((segment)=>segment === '' || segment === '.' || segment === '..')) {
|
|
18
|
+
return 'cannot contain empty, "." or ".." segments';
|
|
19
|
+
}
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { buildDeploymentManifestV2, type BuiltDeployment, type DeploymentInput, hashFile, type LocalArtifact, ManifestV2Error, responseIdForPath, type ResponseInput, type ServerInput, } from './build.js';
|
|
2
|
+
export { contentTypeForPath, DEFAULT_CONTENT_TYPE } from './content-type.js';
|
|
3
|
+
export { getRelativePathError } from './getRelativePathError.js';
|
|
4
|
+
export { MANIFEST_V2_LIMITS, MAX_RESPONSE_ARTIFACT_BYTES } from './limits.js';
|
|
5
|
+
export { MANIFEST_VERSION_ENV, type ManifestVersion, parseManifestVersion, readManifestVersionEnv, } from './manifest-version.js';
|
|
6
|
+
export { LAUNCHER_FILE_NAME, LAUNCHER_SCRIPT, type PackagedServer, packageServer, type PackageServerOptions, SERVER_ZIP_FILE_NAME, ServerPackageError, } from './server-zip.js';
|
|
7
|
+
export { type DeclaredServices, DEPLOY_CONFIG_PATH, detectPayloadServices, readDeclaredServices, type ResolvedServices, resolveProjectServices, resolveServices, SERVICE_NAMES, type ServiceDeclaration, ServiceDeclarationError, type ServiceName, type ServiceRequests, type ServiceSource, } from './services.js';
|
|
8
|
+
export { staticPathsForFile } from './static-path.js';
|
|
9
|
+
export { createStaticSiteInput, type StaticSiteOptions } from './static-site.js';
|
|
10
|
+
export type * from './types.js';
|
|
11
|
+
export { ARTIFACT_CHANGED_ERROR, type ArtifactUpload, type ArtifactUploadResults, ASSET_ATTEMPT_TIMEOUT_MS, type AttemptFailureHandler, LARGE_UPLOAD_ATTEMPT_TIMEOUT_MS, type PresignedPost, runUploadPool, UPLOAD_CONCURRENCY, uploadPresignedPostFile, uploadVerifiedArtifacts, } from './upload.js';
|
|
12
|
+
export { validateDeployment } from './validateDeployment.js';
|
|
13
|
+
export { ManifestIssueCode } from './validateDeployment/types.js';
|
|
14
|
+
export type { ManifestIssue } from './validateDeployment/types.js';
|
|
15
|
+
export { ARTIFACTS_FILE_NAME, FIGMA_BUILD_DIR, MANIFEST_FILE_NAME, writeBuiltDeployment, } from './write.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { buildDeploymentManifestV2, hashFile, ManifestV2Error, responseIdForPath } from './build.js';
|
|
2
|
+
export { contentTypeForPath, DEFAULT_CONTENT_TYPE } from './content-type.js';
|
|
3
|
+
export { getRelativePathError } from './getRelativePathError.js';
|
|
4
|
+
export { MANIFEST_V2_LIMITS, MAX_RESPONSE_ARTIFACT_BYTES } from './limits.js';
|
|
5
|
+
export { MANIFEST_VERSION_ENV, parseManifestVersion, readManifestVersionEnv } from './manifest-version.js';
|
|
6
|
+
export { LAUNCHER_FILE_NAME, LAUNCHER_SCRIPT, packageServer, SERVER_ZIP_FILE_NAME, ServerPackageError } from './server-zip.js';
|
|
7
|
+
export { DEPLOY_CONFIG_PATH, detectPayloadServices, readDeclaredServices, resolveProjectServices, resolveServices, SERVICE_NAMES, ServiceDeclarationError } from './services.js';
|
|
8
|
+
export { staticPathsForFile } from './static-path.js';
|
|
9
|
+
export { createStaticSiteInput } from './static-site.js';
|
|
10
|
+
export { ARTIFACT_CHANGED_ERROR, ASSET_ATTEMPT_TIMEOUT_MS, LARGE_UPLOAD_ATTEMPT_TIMEOUT_MS, runUploadPool, UPLOAD_CONCURRENCY, uploadPresignedPostFile, uploadVerifiedArtifacts } from './upload.js';
|
|
11
|
+
export { validateDeployment } from './validateDeployment.js';
|
|
12
|
+
export { ManifestIssueCode } from './validateDeployment/types.js';
|
|
13
|
+
export { ARTIFACTS_FILE_NAME, FIGMA_BUILD_DIR, MANIFEST_FILE_NAME, writeBuiltDeployment } from './write.js';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Initial manifest v2 policy limits from Appendix D of the design. Figma Cloud advertises the
|
|
3
|
+
* effective values and enforces them again; the client checks them so a deploy fails before it
|
|
4
|
+
* uploads anything.
|
|
5
|
+
*/
|
|
6
|
+
export declare const MANIFEST_V2_LIMITS: {
|
|
7
|
+
readonly maxArtifacts: 50000;
|
|
8
|
+
readonly maxConditionsPerList: 16;
|
|
9
|
+
readonly maxHeaderBlockBytes: 32768;
|
|
10
|
+
readonly maxHeaderBlockFields: 128;
|
|
11
|
+
readonly maxHeaderNameBytes: 128;
|
|
12
|
+
readonly maxHeaderRules: 256;
|
|
13
|
+
readonly maxHeaderValueBytes: 8192;
|
|
14
|
+
readonly maxManifestBytes: number;
|
|
15
|
+
readonly maxPathLength: 2048;
|
|
16
|
+
readonly maxPathParams: 16;
|
|
17
|
+
readonly maxPatternRoutes: 1024;
|
|
18
|
+
readonly maxResponses: 50000;
|
|
19
|
+
readonly maxRoutes: 10000;
|
|
20
|
+
readonly maxServers: 1;
|
|
21
|
+
readonly maxStaticEntries: 50000;
|
|
22
|
+
readonly warnManifestBytes: number;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Largest public artifact the client uploads. Matches the deployment upload limit in Sinatra
|
|
26
|
+
* (MakeNegotiateUpload::DEFAULT_MAX_OBJECT_BYTES, 100 MiB).
|
|
27
|
+
*/
|
|
28
|
+
export declare const MAX_RESPONSE_ARTIFACT_BYTES: number;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Initial manifest v2 policy limits from Appendix D of the design. Figma Cloud advertises the
|
|
3
|
+
* effective values and enforces them again; the client checks them so a deploy fails before it
|
|
4
|
+
* uploads anything.
|
|
5
|
+
*/ export const MANIFEST_V2_LIMITS = {
|
|
6
|
+
maxArtifacts: 50_000,
|
|
7
|
+
maxConditionsPerList: 16,
|
|
8
|
+
maxHeaderBlockBytes: 32_768,
|
|
9
|
+
maxHeaderBlockFields: 128,
|
|
10
|
+
maxHeaderNameBytes: 128,
|
|
11
|
+
maxHeaderRules: 256,
|
|
12
|
+
maxHeaderValueBytes: 8192,
|
|
13
|
+
maxManifestBytes: 10 * 1024 * 1024,
|
|
14
|
+
maxPathLength: 2048,
|
|
15
|
+
maxPathParams: 16,
|
|
16
|
+
maxPatternRoutes: 1024,
|
|
17
|
+
maxResponses: 50_000,
|
|
18
|
+
maxRoutes: 10_000,
|
|
19
|
+
maxServers: 1,
|
|
20
|
+
maxStaticEntries: 50_000,
|
|
21
|
+
warnManifestBytes: 2 * 1024 * 1024
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Largest public artifact the client uploads. Matches the deployment upload limit in Sinatra
|
|
25
|
+
* (MakeNegotiateUpload::DEFAULT_MAX_OBJECT_BYTES, 100 MiB).
|
|
26
|
+
*/ export const MAX_RESPONSE_ARTIFACT_BYTES = 100 * 1024 * 1024;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Selects the deployment manifest version both CLIs submit, during the manifest v2 rollout. `1` or
|
|
3
|
+
* unset submits v1; `2` submits manifest v2. The Make workload sets it from a feature flag.
|
|
4
|
+
*/
|
|
5
|
+
export declare const MANIFEST_VERSION_ENV = "FIGMA_CLOUD_MANIFEST_VERSION";
|
|
6
|
+
export type ManifestVersion = 1 | 2;
|
|
7
|
+
/** Parses `1` or `2`; any other value throws, naming `source` (a flag or env var). */
|
|
8
|
+
export declare function parseManifestVersion(value: string, source: string): ManifestVersion;
|
|
9
|
+
/** The version {@link MANIFEST_VERSION_ENV} selects; v1 when it is unset or empty. */
|
|
10
|
+
export declare function readManifestVersionEnv(env?: NodeJS.ProcessEnv): ManifestVersion;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Selects the deployment manifest version both CLIs submit, during the manifest v2 rollout. `1` or
|
|
3
|
+
* unset submits v1; `2` submits manifest v2. The Make workload sets it from a feature flag.
|
|
4
|
+
*/ export const MANIFEST_VERSION_ENV = 'FIGMA_CLOUD_MANIFEST_VERSION';
|
|
5
|
+
/** Parses `1` or `2`; any other value throws, naming `source` (a flag or env var). */ export function parseManifestVersion(value, source) {
|
|
6
|
+
if (value === '1' || value === '2') {
|
|
7
|
+
return Number(value);
|
|
8
|
+
}
|
|
9
|
+
throw new Error(`${source} must be 1 or 2, got ${JSON.stringify(value)}`);
|
|
10
|
+
}
|
|
11
|
+
/** The version {@link MANIFEST_VERSION_ENV} selects; v1 when it is unset or empty. */ export function readManifestVersionEnv(env = process.env) {
|
|
12
|
+
const value = env[MANIFEST_VERSION_ENV];
|
|
13
|
+
return value === undefined || value === '' ? 1 : parseManifestVersion(value, MANIFEST_VERSION_ENV);
|
|
14
|
+
}
|