@payloadcms/figma 1.0.0-beta.3 → 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/oauth/hooks/refresh.js +9 -4
- package/dist/oauth/strategy/index.js +34 -14
- package/dist/oauth/utilities/createTokenCookie.d.ts +11 -0
- package/dist/oauth/utilities/createTokenCookie.js +21 -0
- package/dist/oauth/utilities/refreshTokens.d.ts +7 -5
- package/dist/oauth/utilities/refreshTokens.js +7 -23
- package/dist/plugin/build-config.d.ts +3 -4
- package/dist/plugin/build-config.js +39 -18
- package/dist/plugin/mcp-oauth.d.ts +18 -7
- package/dist/plugin/mcp-oauth.js +123 -10
- package/dist/skills/deploy-to-figma/SKILL.md +8 -8
- package/dist/skills/deploy-to-figma/references/cli-reference.md +1 -1
- 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 +12 -4
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createIssue } from '../../createIssue.js';
|
|
2
|
+
import { ManifestIssueCode } from '../../types.js';
|
|
3
|
+
import { validateCachePolicy } from '../../validateCachePolicy.js';
|
|
4
|
+
/** A server action names a declared server, with a cache policy that isn't immutable. */ export function validateServerAction({ action, manifest, pointer }) {
|
|
5
|
+
const cachePointer = `${pointer}/cache`;
|
|
6
|
+
return [
|
|
7
|
+
...Object.hasOwn(manifest.servers ?? {}, action.server) ? [] : [
|
|
8
|
+
createIssue({
|
|
9
|
+
code: ManifestIssueCode.REFERENCE_INVALID,
|
|
10
|
+
message: `unknown server ${action.server}`,
|
|
11
|
+
pointer: `${pointer}/server`
|
|
12
|
+
})
|
|
13
|
+
],
|
|
14
|
+
...action.cache?.mode === 'immutable' ? [
|
|
15
|
+
createIssue({
|
|
16
|
+
code: ManifestIssueCode.SCHEMA_INVALID,
|
|
17
|
+
message: 'server responses cannot be immutable',
|
|
18
|
+
pointer: cachePointer
|
|
19
|
+
})
|
|
20
|
+
] : [],
|
|
21
|
+
...action.cache ? validateCachePolicy({
|
|
22
|
+
cache: action.cache,
|
|
23
|
+
pointer: cachePointer
|
|
24
|
+
}) : []
|
|
25
|
+
];
|
|
26
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DeploymentManifestV2, ManifestRoute, ManifestRouteAction } from '../../../types.js';
|
|
2
|
+
interface ValidateStaticActionArgs {
|
|
3
|
+
action: Extract<ManifestRouteAction, {
|
|
4
|
+
type: 'static';
|
|
5
|
+
}>;
|
|
6
|
+
manifest: DeploymentManifestV2;
|
|
7
|
+
/** Pointer to the route. */
|
|
8
|
+
pointer: string;
|
|
9
|
+
route: ManifestRoute;
|
|
10
|
+
}
|
|
11
|
+
/** A static action names a declared response, and its route limits methods to GET and HEAD. */
|
|
12
|
+
export declare function validateStaticAction({ action, manifest, pointer, route, }: ValidateStaticActionArgs): import("../../types.js").ManifestIssue[];
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createIssue } from '../../createIssue.js';
|
|
2
|
+
import { ManifestIssueCode } from '../../types.js';
|
|
3
|
+
const STATIC_METHODS = new Set([
|
|
4
|
+
'GET',
|
|
5
|
+
'HEAD'
|
|
6
|
+
]);
|
|
7
|
+
/** A static action names a declared response, and its route limits methods to GET and HEAD. */ export function validateStaticAction({ action, manifest, pointer, route }) {
|
|
8
|
+
const { methods } = route.match;
|
|
9
|
+
return [
|
|
10
|
+
...Object.hasOwn(manifest.responses, action.response) ? [] : [
|
|
11
|
+
createIssue({
|
|
12
|
+
code: ManifestIssueCode.REFERENCE_INVALID,
|
|
13
|
+
message: `unknown response ${action.response}`,
|
|
14
|
+
pointer: `${pointer}/action/response`
|
|
15
|
+
})
|
|
16
|
+
],
|
|
17
|
+
...methods && methods.every((method)=>STATIC_METHODS.has(method)) ? [] : [
|
|
18
|
+
createIssue({
|
|
19
|
+
code: ManifestIssueCode.HTTP_INVALID,
|
|
20
|
+
message: 'a static route must limit methods to GET and HEAD',
|
|
21
|
+
pointer: `${pointer}/match/methods`
|
|
22
|
+
})
|
|
23
|
+
]
|
|
24
|
+
];
|
|
25
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DeploymentManifestV2, ManifestRoute } from '../../types.js';
|
|
2
|
+
interface ValidateRouteActionArgs {
|
|
3
|
+
manifest: DeploymentManifestV2;
|
|
4
|
+
/** Parameter names the route's path pattern captures. */
|
|
5
|
+
params: string[];
|
|
6
|
+
/** Pointer to the route. */
|
|
7
|
+
pointer: string;
|
|
8
|
+
route: ManifestRoute;
|
|
9
|
+
}
|
|
10
|
+
/** Validates a route's action against the rules for its type. */
|
|
11
|
+
export declare function validateRouteAction({ manifest, params, pointer, route }: ValidateRouteActionArgs): import("../types.js").ManifestIssue[];
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { validateRedirectAction } from './validateRouteAction/validateRedirectAction.js';
|
|
2
|
+
import { validateRewriteAction } from './validateRouteAction/validateRewriteAction.js';
|
|
3
|
+
import { validateServerAction } from './validateRouteAction/validateServerAction.js';
|
|
4
|
+
import { validateStaticAction } from './validateRouteAction/validateStaticAction.js';
|
|
5
|
+
/** Validates a route's action against the rules for its type. */ export function validateRouteAction({ manifest, params, pointer, route }) {
|
|
6
|
+
const { action } = route;
|
|
7
|
+
const actionPointer = `${pointer}/action`;
|
|
8
|
+
switch(action.type){
|
|
9
|
+
case 'redirect':
|
|
10
|
+
return validateRedirectAction({
|
|
11
|
+
action,
|
|
12
|
+
params,
|
|
13
|
+
pointer: actionPointer
|
|
14
|
+
});
|
|
15
|
+
case 'rewrite':
|
|
16
|
+
return validateRewriteAction({
|
|
17
|
+
action,
|
|
18
|
+
params,
|
|
19
|
+
pointer: actionPointer
|
|
20
|
+
});
|
|
21
|
+
case 'server':
|
|
22
|
+
return validateServerAction({
|
|
23
|
+
action,
|
|
24
|
+
manifest,
|
|
25
|
+
pointer: actionPointer
|
|
26
|
+
});
|
|
27
|
+
case 'static':
|
|
28
|
+
return validateStaticAction({
|
|
29
|
+
action,
|
|
30
|
+
manifest,
|
|
31
|
+
pointer,
|
|
32
|
+
route
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DeploymentManifestV2 } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Every route has a unique valid ID, a valid match and a valid action, and the number of routes
|
|
4
|
+
* with path patterns stays within its limit.
|
|
5
|
+
*/
|
|
6
|
+
export declare function validateRoutes(manifest: DeploymentManifestV2): import("./types.js").ManifestIssue[];
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { MANIFEST_V2_LIMITS } from '../limits.js';
|
|
2
|
+
import { createIssue } from './createIssue.js';
|
|
3
|
+
import { ManifestIssueCode } from './types.js';
|
|
4
|
+
import { validateId } from './validateId.js';
|
|
5
|
+
import { validateMatch } from './validateMatch.js';
|
|
6
|
+
import { validateRouteAction } from './validateRoutes/validateRouteAction.js';
|
|
7
|
+
/**
|
|
8
|
+
* Every route has a unique valid ID, a valid match and a valid action, and the number of routes
|
|
9
|
+
* with path patterns stays within its limit.
|
|
10
|
+
*/ export function validateRoutes(manifest) {
|
|
11
|
+
const seenIds = new Set();
|
|
12
|
+
const routeResults = manifest.routes.map((route, index)=>{
|
|
13
|
+
const pointer = `/routes/${index}`;
|
|
14
|
+
const match = validateMatch({
|
|
15
|
+
match: route.match,
|
|
16
|
+
pointer: `${pointer}/match`
|
|
17
|
+
});
|
|
18
|
+
const isDuplicate = seenIds.has(route.id);
|
|
19
|
+
seenIds.add(route.id);
|
|
20
|
+
return {
|
|
21
|
+
isPattern: match.params.length > 0,
|
|
22
|
+
issues: [
|
|
23
|
+
...validateId({
|
|
24
|
+
id: route.id,
|
|
25
|
+
pointer: `${pointer}/id`
|
|
26
|
+
}),
|
|
27
|
+
...isDuplicate ? [
|
|
28
|
+
createIssue({
|
|
29
|
+
code: ManifestIssueCode.REFERENCE_INVALID,
|
|
30
|
+
message: `duplicate route ID ${route.id}`,
|
|
31
|
+
pointer: `${pointer}/id`
|
|
32
|
+
})
|
|
33
|
+
] : [],
|
|
34
|
+
...match.issues,
|
|
35
|
+
...validateRouteAction({
|
|
36
|
+
manifest,
|
|
37
|
+
params: match.params,
|
|
38
|
+
pointer,
|
|
39
|
+
route
|
|
40
|
+
})
|
|
41
|
+
]
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
const patternRouteCount = routeResults.filter((result)=>result.isPattern).length;
|
|
45
|
+
return [
|
|
46
|
+
...routeResults.flatMap((result)=>result.issues),
|
|
47
|
+
...patternRouteCount > MANIFEST_V2_LIMITS.maxPatternRoutes ? [
|
|
48
|
+
createIssue({
|
|
49
|
+
code: ManifestIssueCode.LIMIT_EXCEEDED,
|
|
50
|
+
message: `${patternRouteCount} routes use path patterns; the limit is ${MANIFEST_V2_LIMITS.maxPatternRoutes}`,
|
|
51
|
+
pointer: '/routes'
|
|
52
|
+
})
|
|
53
|
+
] : []
|
|
54
|
+
];
|
|
55
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** The server IDs that server routes and a server fallback invoke. */ export function listReferencedServerIds(manifest) {
|
|
2
|
+
const routeServerIds = manifest.routes.flatMap((route)=>route.action.type === 'server' ? [
|
|
3
|
+
route.action.server
|
|
4
|
+
] : []);
|
|
5
|
+
const fallbackServerIds = manifest.fallback.type === 'server' ? [
|
|
6
|
+
manifest.fallback.server
|
|
7
|
+
] : [];
|
|
8
|
+
return new Set([
|
|
9
|
+
...fallbackServerIds,
|
|
10
|
+
...routeServerIds
|
|
11
|
+
]);
|
|
12
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DeploymentManifestV2 } from '../types.js';
|
|
2
|
+
import type { ManifestIssue } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Every server runs Node.js 24 on ARM64, starts a safe ZIP-relative entrypoint, has its own
|
|
5
|
+
* declared ZIP artifact, and is invoked by at least one route or the fallback.
|
|
6
|
+
*/
|
|
7
|
+
export declare function validateServers(manifest: DeploymentManifestV2): ManifestIssue[];
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { getRelativePathError } from '../getRelativePathError.js';
|
|
2
|
+
import { createIssue } from './createIssue.js';
|
|
3
|
+
import { escapePointer } from './escapePointer.js';
|
|
4
|
+
import { ManifestIssueCode } from './types.js';
|
|
5
|
+
import { validateId } from './validateId.js';
|
|
6
|
+
import { listReferencedServerIds } from './validateServers/listReferencedServerIds.js';
|
|
7
|
+
/**
|
|
8
|
+
* Every server runs Node.js 24 on ARM64, starts a safe ZIP-relative entrypoint, has its own
|
|
9
|
+
* declared ZIP artifact, and is invoked by at least one route or the fallback.
|
|
10
|
+
*/ export function validateServers(manifest) {
|
|
11
|
+
const servers = Object.entries(manifest.servers ?? {});
|
|
12
|
+
const referencedServerIds = listReferencedServerIds(manifest);
|
|
13
|
+
const seenArtifacts = new Set();
|
|
14
|
+
return servers.flatMap(([id, server])=>{
|
|
15
|
+
const pointer = `/servers/${escapePointer(id)}`;
|
|
16
|
+
const entrypointError = getRelativePathError(server.entrypoint);
|
|
17
|
+
const sharesArtifact = seenArtifacts.has(server.artifact);
|
|
18
|
+
seenArtifacts.add(server.artifact);
|
|
19
|
+
const candidates = [
|
|
20
|
+
(server.runtime !== 'nodejs' || server.runtimeVersion !== '24') && createIssue({
|
|
21
|
+
code: ManifestIssueCode.SCHEMA_INVALID,
|
|
22
|
+
message: 'the only supported runtime is nodejs 24',
|
|
23
|
+
pointer
|
|
24
|
+
}),
|
|
25
|
+
server.architecture !== undefined && server.architecture !== 'arm64' && createIssue({
|
|
26
|
+
code: ManifestIssueCode.SCHEMA_INVALID,
|
|
27
|
+
message: 'the only supported architecture is arm64',
|
|
28
|
+
pointer: `${pointer}/architecture`
|
|
29
|
+
}),
|
|
30
|
+
entrypointError !== undefined && createIssue({
|
|
31
|
+
code: ManifestIssueCode.SCHEMA_INVALID,
|
|
32
|
+
message: `entrypoint ${entrypointError}`,
|
|
33
|
+
pointer: `${pointer}/entrypoint`
|
|
34
|
+
}),
|
|
35
|
+
!Object.hasOwn(manifest.artifacts, server.artifact) && createIssue({
|
|
36
|
+
code: ManifestIssueCode.REFERENCE_INVALID,
|
|
37
|
+
message: `unknown artifact ${server.artifact}`,
|
|
38
|
+
pointer: `${pointer}/artifact`
|
|
39
|
+
}),
|
|
40
|
+
sharesArtifact && createIssue({
|
|
41
|
+
code: ManifestIssueCode.REFERENCE_INVALID,
|
|
42
|
+
message: 'two servers cannot share an artifact',
|
|
43
|
+
pointer: `${pointer}/artifact`
|
|
44
|
+
}),
|
|
45
|
+
!referencedServerIds.has(id) && createIssue({
|
|
46
|
+
code: ManifestIssueCode.REFERENCE_INVALID,
|
|
47
|
+
message: `no route or fallback uses server ${id}`,
|
|
48
|
+
pointer
|
|
49
|
+
})
|
|
50
|
+
];
|
|
51
|
+
return [
|
|
52
|
+
...validateId({
|
|
53
|
+
id,
|
|
54
|
+
pointer
|
|
55
|
+
}),
|
|
56
|
+
...candidates.filter((candidate)=>candidate !== false)
|
|
57
|
+
];
|
|
58
|
+
});
|
|
59
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createIssue } from './createIssue.js';
|
|
2
|
+
import { escapePointer } from './escapePointer.js';
|
|
3
|
+
import { ManifestIssueCode } from './types.js';
|
|
4
|
+
import { validatePublicPath } from './validatePublicPath.js';
|
|
5
|
+
/** Every static map key is a public path, and every value names a declared response. */ export function validateStaticMap(manifest) {
|
|
6
|
+
return Object.entries(manifest.static).flatMap(([publicPath, responseId])=>{
|
|
7
|
+
const pointer = `/static/${escapePointer(publicPath)}`;
|
|
8
|
+
return [
|
|
9
|
+
...validatePublicPath({
|
|
10
|
+
pointer,
|
|
11
|
+
publicPath
|
|
12
|
+
}),
|
|
13
|
+
...Object.hasOwn(manifest.responses, responseId) ? [] : [
|
|
14
|
+
createIssue({
|
|
15
|
+
code: ManifestIssueCode.REFERENCE_INVALID,
|
|
16
|
+
message: `unknown response ${responseId}`,
|
|
17
|
+
pointer
|
|
18
|
+
})
|
|
19
|
+
]
|
|
20
|
+
];
|
|
21
|
+
});
|
|
22
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DeploymentManifestV2 } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Checks a manifest against the client-checkable rules of the v2 base contract: IDs, references,
|
|
4
|
+
* limits, paths, header and HTTP semantics, and cache policies. The control plane validates the
|
|
5
|
+
* same manifest again; this exists so a bad build fails before any upload.
|
|
6
|
+
*/
|
|
7
|
+
export declare function validateDeployment(manifest: DeploymentManifestV2): import("./validateDeployment/types.js").ManifestIssue[];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { MANIFEST_V2_LIMITS } from './limits.js';
|
|
2
|
+
import { createIssue } from './validateDeployment/createIssue.js';
|
|
3
|
+
import { ManifestIssueCode } from './validateDeployment/types.js';
|
|
4
|
+
import { validateArtifacts } from './validateDeployment/validateArtifacts.js';
|
|
5
|
+
import { validateCounts } from './validateDeployment/validateCounts.js';
|
|
6
|
+
import { validateFallback } from './validateDeployment/validateFallback.js';
|
|
7
|
+
import { validateHeaderRules } from './validateDeployment/validateHeaderRules.js';
|
|
8
|
+
import { validateResponses } from './validateDeployment/validateResponses.js';
|
|
9
|
+
import { validateRoutes } from './validateDeployment/validateRoutes.js';
|
|
10
|
+
import { validateServers } from './validateDeployment/validateServers.js';
|
|
11
|
+
import { validateStaticMap } from './validateDeployment/validateStaticMap.js';
|
|
12
|
+
/**
|
|
13
|
+
* Checks a manifest against the client-checkable rules of the v2 base contract: IDs, references,
|
|
14
|
+
* limits, paths, header and HTTP semantics, and cache policies. The control plane validates the
|
|
15
|
+
* same manifest again; this exists so a bad build fails before any upload.
|
|
16
|
+
*/ export function validateDeployment(manifest) {
|
|
17
|
+
const manifestBytes = Buffer.byteLength(JSON.stringify(manifest));
|
|
18
|
+
return [
|
|
19
|
+
...manifest.version === 2 ? [] : [
|
|
20
|
+
createIssue({
|
|
21
|
+
code: ManifestIssueCode.SCHEMA_INVALID,
|
|
22
|
+
message: 'version must be 2',
|
|
23
|
+
pointer: '/version'
|
|
24
|
+
})
|
|
25
|
+
],
|
|
26
|
+
...validateCounts(manifest),
|
|
27
|
+
...validateArtifacts(manifest),
|
|
28
|
+
...validateResponses(manifest),
|
|
29
|
+
...validateStaticMap(manifest),
|
|
30
|
+
...validateRoutes(manifest),
|
|
31
|
+
...validateHeaderRules(manifest),
|
|
32
|
+
...validateFallback(manifest),
|
|
33
|
+
...validateServers(manifest),
|
|
34
|
+
...manifestBytes > MANIFEST_V2_LIMITS.maxManifestBytes ? [
|
|
35
|
+
createIssue({
|
|
36
|
+
code: ManifestIssueCode.TOO_LARGE,
|
|
37
|
+
message: `manifest is ${manifestBytes} bytes; the limit is ${MANIFEST_V2_LIMITS.maxManifestBytes}`,
|
|
38
|
+
pointer: ''
|
|
39
|
+
})
|
|
40
|
+
] : []
|
|
41
|
+
];
|
|
42
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { BuiltDeployment } from './build.js';
|
|
2
|
+
export declare const MANIFEST_FILE_NAME = "manifest.json";
|
|
3
|
+
export declare const ARTIFACTS_FILE_NAME = "artifacts.json";
|
|
4
|
+
/**
|
|
5
|
+
* Where `build-manifest` writes its output, relative to the project. The location is fixed, like
|
|
6
|
+
* `.vercel/output` and `.netlify/v1`, so deploys and adapters always find it. The CLI owns this
|
|
7
|
+
* folder: it holds only generated files, is emptied before each build and is added to
|
|
8
|
+
* `.gitignore`. `.figma/` stays for committed config.
|
|
9
|
+
*
|
|
10
|
+
* `isPublishableAsset` and `isBundlableFile` never publish or bundle it: it holds `artifacts.json`
|
|
11
|
+
* with absolute local paths and server ZIPs, which can carry `.env.production`.
|
|
12
|
+
*/
|
|
13
|
+
export declare const FIGMA_BUILD_DIR = ".figma-build";
|
|
14
|
+
/**
|
|
15
|
+
* Writes a built deployment to `outDir`: the manifest a client submits, and the uploader's map
|
|
16
|
+
* from artifact ID to local file beside it. Only `manifest.json` is ever sent to Figma Cloud.
|
|
17
|
+
*/
|
|
18
|
+
export declare function writeBuiltDeployment(deployment: BuiltDeployment, outDir: string): Promise<{
|
|
19
|
+
artifactsPath: string;
|
|
20
|
+
manifestPath: string;
|
|
21
|
+
}>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
export const MANIFEST_FILE_NAME = 'manifest.json';
|
|
4
|
+
export const ARTIFACTS_FILE_NAME = 'artifacts.json';
|
|
5
|
+
/**
|
|
6
|
+
* Where `build-manifest` writes its output, relative to the project. The location is fixed, like
|
|
7
|
+
* `.vercel/output` and `.netlify/v1`, so deploys and adapters always find it. The CLI owns this
|
|
8
|
+
* folder: it holds only generated files, is emptied before each build and is added to
|
|
9
|
+
* `.gitignore`. `.figma/` stays for committed config.
|
|
10
|
+
*
|
|
11
|
+
* `isPublishableAsset` and `isBundlableFile` never publish or bundle it: it holds `artifacts.json`
|
|
12
|
+
* with absolute local paths and server ZIPs, which can carry `.env.production`.
|
|
13
|
+
*/ export const FIGMA_BUILD_DIR = '.figma-build';
|
|
14
|
+
/**
|
|
15
|
+
* Writes a built deployment to `outDir`: the manifest a client submits, and the uploader's map
|
|
16
|
+
* from artifact ID to local file beside it. Only `manifest.json` is ever sent to Figma Cloud.
|
|
17
|
+
*/ export async function writeBuiltDeployment(deployment, outDir) {
|
|
18
|
+
await fs.mkdir(outDir, {
|
|
19
|
+
recursive: true
|
|
20
|
+
});
|
|
21
|
+
const manifestPath = path.join(outDir, MANIFEST_FILE_NAME);
|
|
22
|
+
const artifactsPath = path.join(outDir, ARTIFACTS_FILE_NAME);
|
|
23
|
+
// Compact, with no trailing newline: the file is exactly the bytes the size limit measured.
|
|
24
|
+
await fs.writeFile(manifestPath, JSON.stringify(deployment.manifest));
|
|
25
|
+
await fs.writeFile(artifactsPath, `${JSON.stringify(deployment.artifacts, null, 2)}\n`);
|
|
26
|
+
return {
|
|
27
|
+
artifactsPath,
|
|
28
|
+
manifestPath
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { ManifestHeader } from '../core/types.js';
|
|
2
|
+
import type { NextBuildModel, NextIsrRoute } from './read-build-output.js';
|
|
3
|
+
/** Whether the manifest may answer a request for a path without running the Next.js server. */
|
|
4
|
+
export interface StaticPathDecision {
|
|
5
|
+
/** next.config headers Next.js would add to the file, in order. */
|
|
6
|
+
headers: ManifestHeader[];
|
|
7
|
+
/**
|
|
8
|
+
* For hashed build output only: the server reasons it is served statically without, because the
|
|
9
|
+
* server deployment doesn't contain those files. Absent when none apply.
|
|
10
|
+
*/
|
|
11
|
+
ignoredReasons?: string[];
|
|
12
|
+
/** Why the path must reach the server; empty when it may be served statically. */
|
|
13
|
+
reasons: string[];
|
|
14
|
+
serveStatically: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface NextCoverage {
|
|
17
|
+
/**
|
|
18
|
+
* Whether a time-based ISR route may carry a shared-cache ttl: an exact path that neither
|
|
19
|
+
* middleware nor a request-dependent next.config rule covers. Their responses can differ per
|
|
20
|
+
* request, so a shared cache would hand one visitor's response to the next. A pattern covers
|
|
21
|
+
* paths no build-time check can enumerate, so it never qualifies.
|
|
22
|
+
*/
|
|
23
|
+
allowsIsrCache(route: NextIsrRoute): boolean;
|
|
24
|
+
/** Decides whether a concrete public path (without basePath) can skip the server. */
|
|
25
|
+
decideStaticPath(publicPath: string, options?: {
|
|
26
|
+
hashed?: boolean;
|
|
27
|
+
}): StaticPathDecision;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The URL Next.js serves a public path (without basePath) at. With a basePath, the root is the
|
|
31
|
+
* basePath itself (`/docs`), not `/docs/`.
|
|
32
|
+
*/
|
|
33
|
+
export declare function publicUrl(basePath: string, publicPath: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* Proves, at build time, which concrete paths middleware and next.config routing leave alone.
|
|
36
|
+
* Next.js compiles every matcher and rule to a regex in the build output, so testing a path
|
|
37
|
+
* against those regexes is exact for unconditional rules. Rules with `has`/`missing` conditions
|
|
38
|
+
* depend on the request, so a path they match always goes to the server. No regex ever reaches
|
|
39
|
+
* the manifest.
|
|
40
|
+
*
|
|
41
|
+
* Hashed build output (`_next/static/`) is the exception: it is always static. The standalone
|
|
42
|
+
* server doesn't serve it and the server ZIP leaves it out, so sending it to the server would
|
|
43
|
+
* return 404. Unconditional headers still apply; the skipped reasons are reported.
|
|
44
|
+
*/
|
|
45
|
+
export declare function createNextCoverage(model: NextBuildModel): NextCoverage;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The URL Next.js serves a public path (without basePath) at. With a basePath, the root is the
|
|
3
|
+
* basePath itself (`/docs`), not `/docs/`.
|
|
4
|
+
*/ export function publicUrl(basePath, publicPath) {
|
|
5
|
+
return publicPath === '/' && basePath ? basePath : basePath + publicPath;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Proves, at build time, which concrete paths middleware and next.config routing leave alone.
|
|
9
|
+
* Next.js compiles every matcher and rule to a regex in the build output, so testing a path
|
|
10
|
+
* against those regexes is exact for unconditional rules. Rules with `has`/`missing` conditions
|
|
11
|
+
* depend on the request, so a path they match always goes to the server. No regex ever reaches
|
|
12
|
+
* the manifest.
|
|
13
|
+
*
|
|
14
|
+
* Hashed build output (`_next/static/`) is the exception: it is always static. The standalone
|
|
15
|
+
* server doesn't serve it and the server ZIP leaves it out, so sending it to the server would
|
|
16
|
+
* return 404. Unconditional headers still apply; the skipped reasons are reported.
|
|
17
|
+
*/ export function createNextCoverage(model) {
|
|
18
|
+
const flags = model.caseSensitive ? '' : 'i';
|
|
19
|
+
const middleware = (model.middlewareMatchers ?? []).map((matcher)=>compile(matcher.regexp, flags));
|
|
20
|
+
const preFilesystem = model.preFilesystemRules.map((rule)=>({
|
|
21
|
+
matches: compile(rule.regex, flags),
|
|
22
|
+
source: rule.source
|
|
23
|
+
}));
|
|
24
|
+
const headerRules = model.configHeaders.map((rule)=>{
|
|
25
|
+
// Next.js fills in `:name` in header names and values per request, so only those headers
|
|
26
|
+
// depend on the request; the rule's other headers are fixed.
|
|
27
|
+
const usesParameter = pathParameterTest(rule.source);
|
|
28
|
+
const headers = rule.headers ?? [];
|
|
29
|
+
return {
|
|
30
|
+
conditional: rule.conditional,
|
|
31
|
+
fixedHeaders: headers.filter((header)=>!usesParameter(header)),
|
|
32
|
+
matches: compile(rule.regex, flags),
|
|
33
|
+
parameterized: headers.some(usesParameter),
|
|
34
|
+
source: rule.source
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
const coverage = {
|
|
38
|
+
allowsIsrCache (route) {
|
|
39
|
+
return !route.path.includes(':') && coverage.decideStaticPath(route.path).serveStatically;
|
|
40
|
+
},
|
|
41
|
+
decideStaticPath (publicPath, options = {}) {
|
|
42
|
+
const url = publicUrl(model.basePath, publicPath);
|
|
43
|
+
const reasons = [];
|
|
44
|
+
const headers = [];
|
|
45
|
+
if (middleware.some((matches)=>matches(url))) {
|
|
46
|
+
reasons.push('middleware');
|
|
47
|
+
}
|
|
48
|
+
for (const rule of preFilesystem){
|
|
49
|
+
if (rule.matches(url)) {
|
|
50
|
+
reasons.push(`next.config rule ${rule.source}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
for (const rule of headerRules){
|
|
54
|
+
if (!rule.matches(url)) {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if (rule.conditional) {
|
|
58
|
+
reasons.push(`conditional next.config headers ${rule.source}`);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (rule.parameterized) {
|
|
62
|
+
reasons.push(`next.config headers ${rule.source} with path parameters`);
|
|
63
|
+
}
|
|
64
|
+
mergeHeaders(headers, rule.fixedHeaders);
|
|
65
|
+
}
|
|
66
|
+
if (options.hashed) {
|
|
67
|
+
return {
|
|
68
|
+
headers,
|
|
69
|
+
...reasons.length > 0 ? {
|
|
70
|
+
ignoredReasons: reasons
|
|
71
|
+
} : {},
|
|
72
|
+
reasons: [],
|
|
73
|
+
serveStatically: true
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
headers,
|
|
78
|
+
reasons,
|
|
79
|
+
serveStatically: reasons.length === 0
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
return coverage;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Adds a rule's headers the way Next.js does: a later rule's value replaces an earlier one with the
|
|
87
|
+
* same name, compared case-insensitively, except `Set-Cookie`, which can repeat.
|
|
88
|
+
*/ function mergeHeaders(headers, added) {
|
|
89
|
+
for (const header of added){
|
|
90
|
+
const name = header.name.toLowerCase();
|
|
91
|
+
if (name !== 'set-cookie') {
|
|
92
|
+
const index = headers.findIndex((existing)=>existing.name.toLowerCase() === name);
|
|
93
|
+
if (index !== -1) {
|
|
94
|
+
headers.splice(index, 1);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
headers.push(header);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/** Tests whether a header's name or value references a `:name` parameter `source` captures. */ function pathParameterTest(source) {
|
|
101
|
+
const references = [
|
|
102
|
+
...source.matchAll(/:([A-Z_]\w*)/gi)
|
|
103
|
+
].map(([, name])=>new RegExp(`:${name}(?!\\w)`));
|
|
104
|
+
return (header)=>references.some((reference)=>reference.test(header.name) || reference.test(header.value));
|
|
105
|
+
}
|
|
106
|
+
/** Compiles a Next.js regex; one JavaScript can't parse is treated as matching every path. */ function compile(source, flags) {
|
|
107
|
+
try {
|
|
108
|
+
const regex = new RegExp(source, flags);
|
|
109
|
+
return (url)=>regex.test(url);
|
|
110
|
+
} catch {
|
|
111
|
+
return ()=>true;
|
|
112
|
+
}
|
|
113
|
+
}
|