@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,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript shape of the Figma Cloud deployment manifest v2 submission (base contract).
|
|
3
|
+
*
|
|
4
|
+
* The JSON Schema in payload/deployment-manifest/schemas/deployment-manifest-v2.schema.json is
|
|
5
|
+
* the source of truth. `build.spec.ts` validates manifests built from these types against it, so
|
|
6
|
+
* a drift between the two fails the tests.
|
|
7
|
+
*/
|
|
8
|
+
export type ManifestId = string;
|
|
9
|
+
export interface DeploymentManifestV2 {
|
|
10
|
+
artifacts: Record<ManifestId, ManifestArtifact>;
|
|
11
|
+
fallback: ManifestFallback;
|
|
12
|
+
generator?: ManifestGenerator;
|
|
13
|
+
headers?: ManifestHeaderRule[];
|
|
14
|
+
requires?: string[];
|
|
15
|
+
responses: Record<ManifestId, ManifestResponse>;
|
|
16
|
+
routes: ManifestRoute[];
|
|
17
|
+
servers?: Record<ManifestId, ManifestServer>;
|
|
18
|
+
services?: ManifestServices;
|
|
19
|
+
source?: ManifestSource;
|
|
20
|
+
static: Record<string, ManifestId>;
|
|
21
|
+
version: 2;
|
|
22
|
+
}
|
|
23
|
+
export interface ManifestSource {
|
|
24
|
+
framework?: string;
|
|
25
|
+
frameworkVersion?: string;
|
|
26
|
+
languages: string[];
|
|
27
|
+
}
|
|
28
|
+
export interface ManifestGenerator {
|
|
29
|
+
name: string;
|
|
30
|
+
version: string;
|
|
31
|
+
}
|
|
32
|
+
export interface ManifestServer {
|
|
33
|
+
architecture?: 'arm64';
|
|
34
|
+
artifact: ManifestId;
|
|
35
|
+
entrypoint: string;
|
|
36
|
+
runtime: 'nodejs';
|
|
37
|
+
runtimeVersion: '24';
|
|
38
|
+
}
|
|
39
|
+
export interface ManifestServices {
|
|
40
|
+
contentSystem?: boolean;
|
|
41
|
+
figmaOauth?: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface ManifestArtifact {
|
|
44
|
+
/** 64 lowercase hex characters over the uploaded bytes. */
|
|
45
|
+
sha256: string;
|
|
46
|
+
size: number;
|
|
47
|
+
}
|
|
48
|
+
export interface ManifestHeader {
|
|
49
|
+
name: string;
|
|
50
|
+
value: string;
|
|
51
|
+
}
|
|
52
|
+
export interface ManifestResponseMetadata {
|
|
53
|
+
headers: ManifestHeader[];
|
|
54
|
+
status: number;
|
|
55
|
+
}
|
|
56
|
+
export interface ManifestResponse {
|
|
57
|
+
body: {
|
|
58
|
+
artifact: ManifestId;
|
|
59
|
+
} | null;
|
|
60
|
+
cache?: ManifestCachePolicy;
|
|
61
|
+
metadata?: ManifestResponseMetadata;
|
|
62
|
+
}
|
|
63
|
+
export type ManifestCachePolicy = {
|
|
64
|
+
browserMaxAgeSeconds: number;
|
|
65
|
+
mode: 'immutable' | 'ttl';
|
|
66
|
+
sharedMaxAgeSeconds: number;
|
|
67
|
+
staleWhileRevalidateSeconds?: number;
|
|
68
|
+
varyHeaders?: string[];
|
|
69
|
+
} | {
|
|
70
|
+
mode: 'bypass';
|
|
71
|
+
} | {
|
|
72
|
+
mode: 'revalidate';
|
|
73
|
+
};
|
|
74
|
+
export interface ManifestCondition {
|
|
75
|
+
key: string;
|
|
76
|
+
type: 'cookie' | 'header' | 'query';
|
|
77
|
+
value?: string;
|
|
78
|
+
}
|
|
79
|
+
export interface ManifestMatch {
|
|
80
|
+
has?: ManifestCondition[];
|
|
81
|
+
methods?: string[];
|
|
82
|
+
missing?: ManifestCondition[];
|
|
83
|
+
path?: string;
|
|
84
|
+
queryKeys?: string[];
|
|
85
|
+
}
|
|
86
|
+
export type ManifestRouteAction = {
|
|
87
|
+
cache?: ManifestCachePolicy;
|
|
88
|
+
server: ManifestId;
|
|
89
|
+
type: 'server';
|
|
90
|
+
} | {
|
|
91
|
+
location: string;
|
|
92
|
+
query?: 'drop' | 'preserve';
|
|
93
|
+
status: 301 | 302 | 303 | 307 | 308;
|
|
94
|
+
type: 'redirect';
|
|
95
|
+
} | {
|
|
96
|
+
path: string;
|
|
97
|
+
type: 'rewrite';
|
|
98
|
+
} | {
|
|
99
|
+
response: ManifestId;
|
|
100
|
+
type: 'static';
|
|
101
|
+
};
|
|
102
|
+
export interface ManifestRoute {
|
|
103
|
+
action: ManifestRouteAction;
|
|
104
|
+
id: ManifestId;
|
|
105
|
+
match: ManifestMatch;
|
|
106
|
+
}
|
|
107
|
+
export type ManifestHeaderOp = {
|
|
108
|
+
name: string;
|
|
109
|
+
op: 'append' | 'set';
|
|
110
|
+
value: string;
|
|
111
|
+
} | {
|
|
112
|
+
name: string;
|
|
113
|
+
op: 'remove';
|
|
114
|
+
};
|
|
115
|
+
export interface ManifestHeaderRule {
|
|
116
|
+
match: ManifestMatch;
|
|
117
|
+
ops: ManifestHeaderOp[];
|
|
118
|
+
}
|
|
119
|
+
export type ManifestFallback = {
|
|
120
|
+
response: ManifestId;
|
|
121
|
+
type: 'spa';
|
|
122
|
+
} | {
|
|
123
|
+
response?: ManifestId;
|
|
124
|
+
type: 'notFound';
|
|
125
|
+
} | {
|
|
126
|
+
server: ManifestId;
|
|
127
|
+
type: 'server';
|
|
128
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript shape of the Figma Cloud deployment manifest v2 submission (base contract).
|
|
3
|
+
*
|
|
4
|
+
* The JSON Schema in payload/deployment-manifest/schemas/deployment-manifest-v2.schema.json is
|
|
5
|
+
* the source of truth. `build.spec.ts` validates manifests built from these types against it, so
|
|
6
|
+
* a drift between the two fails the tests.
|
|
7
|
+
*/ export { };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { LocalArtifact } from './build.js';
|
|
2
|
+
/** A presigned S3 POST: the form fields its policy signs, sent before the file. */
|
|
3
|
+
export interface PresignedPost {
|
|
4
|
+
fields: Record<string, string>;
|
|
5
|
+
url: string;
|
|
6
|
+
}
|
|
7
|
+
/** The presigned POST the control plane returned for one manifest artifact. */
|
|
8
|
+
export interface ArtifactUpload extends PresignedPost {
|
|
9
|
+
artifact: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ArtifactUploadResults {
|
|
12
|
+
failed: number;
|
|
13
|
+
/** The artifact whose failure stopped the upload, if one did. */
|
|
14
|
+
failedArtifact?: string;
|
|
15
|
+
totalBytesUploaded: number;
|
|
16
|
+
uploaded: number;
|
|
17
|
+
}
|
|
18
|
+
export type AttemptFailureHandler = (statusCode: number | undefined, retryCount: number, error: string | undefined) => void;
|
|
19
|
+
export declare const ASSET_ATTEMPT_TIMEOUT_MS = 30000;
|
|
20
|
+
export declare const LARGE_UPLOAD_ATTEMPT_TIMEOUT_MS: number;
|
|
21
|
+
export declare const UPLOAD_CONCURRENCY = 10;
|
|
22
|
+
/**
|
|
23
|
+
* Reported as an attempt's error when a file's bytes no longer match the digest and size its
|
|
24
|
+
* manifest declared.
|
|
25
|
+
*/
|
|
26
|
+
export declare const ARTIFACT_CHANGED_ERROR = "artifact_changed";
|
|
27
|
+
/**
|
|
28
|
+
* Uploads manifest v2 artifacts to the presigned POSTs the control plane returned for them. Each
|
|
29
|
+
* file is checked against the SHA-256 and size its manifest declared, on the exact bytes sent, so a
|
|
30
|
+
* file that changed after the manifest was built fails instead of uploading different bytes. The
|
|
31
|
+
* first artifact to fail for good aborts `cancel` and stops the rest.
|
|
32
|
+
*/
|
|
33
|
+
export declare function uploadVerifiedArtifacts(params: {
|
|
34
|
+
artifacts: Record<string, LocalArtifact>;
|
|
35
|
+
/** Aborted by the first artifact to fail for good, and by the caller to cancel. */
|
|
36
|
+
cancel: AbortController;
|
|
37
|
+
/** Epoch ms after which no attempt starts. Unlimited by default. */
|
|
38
|
+
deadline?: number;
|
|
39
|
+
onAttemptFailure?: (artifact: string, statusCode?: number, retryCount?: number, error?: string) => void;
|
|
40
|
+
onProgress?: (uploaded: number, total: number) => void;
|
|
41
|
+
uploads: ArtifactUpload[];
|
|
42
|
+
}): Promise<ArtifactUploadResults>;
|
|
43
|
+
/**
|
|
44
|
+
* Uploads one file to a presigned S3 POST, retrying transient failures with jittered backoff.
|
|
45
|
+
* Returns the uploaded byte count, or undefined once the file has failed for good, ran out of
|
|
46
|
+
* budget, or `signal` cancelled it. Cancelled attempts aren't reported to `onAttemptFailure`. A
|
|
47
|
+
* failed attempt's `error` is `upload_budget_exhausted` when the budget, not the failure, rules out
|
|
48
|
+
* another attempt, and otherwise names what ended an attempt that got no response.
|
|
49
|
+
*/
|
|
50
|
+
export declare function uploadPresignedPostFile(filePath: string, post: PresignedPost, contentType: string, options: {
|
|
51
|
+
attemptTimeoutMs: number;
|
|
52
|
+
/** Epoch ms after which no attempt starts. Unlimited by default. */
|
|
53
|
+
deadline?: number;
|
|
54
|
+
/** The digest and size the bytes must still have. */
|
|
55
|
+
expected?: {
|
|
56
|
+
sha256: string;
|
|
57
|
+
size: number;
|
|
58
|
+
};
|
|
59
|
+
onAttemptFailure?: AttemptFailureHandler;
|
|
60
|
+
signal?: AbortSignal;
|
|
61
|
+
}): Promise<number | undefined>;
|
|
62
|
+
/**
|
|
63
|
+
* Runs `uploadOne` over `items` with {@link UPLOAD_CONCURRENCY} workers. Each worker takes the
|
|
64
|
+
* next item as soon as its current one finishes, so a slow file holds up only its own slot instead
|
|
65
|
+
* of a whole batch. Stops taking items once `signal` aborts.
|
|
66
|
+
*/
|
|
67
|
+
export declare function runUploadPool<T>(items: T[], signal: AbortSignal, uploadOne: (item: T) => Promise<void>): Promise<void>;
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import crypto from 'crypto';
|
|
2
|
+
import fs from 'fs/promises';
|
|
3
|
+
// Cloudflare holds a 524 for 100s, so cap each attempt well below that. A server ZIP can be up to
|
|
4
|
+
// 250 MB and needs longer to send.
|
|
5
|
+
export const ASSET_ATTEMPT_TIMEOUT_MS = 30_000;
|
|
6
|
+
export const LARGE_UPLOAD_ATTEMPT_TIMEOUT_MS = 2 * 60_000;
|
|
7
|
+
// Uploads are bound by request latency, not bandwidth, so a deploy's file count decides how long
|
|
8
|
+
// it takes. Each upload in flight holds its file and its request body in memory, so even ten
|
|
9
|
+
// 100 MB assets fit in a Make sandbox.
|
|
10
|
+
export const UPLOAD_CONCURRENCY = 10;
|
|
11
|
+
/**
|
|
12
|
+
* Reported as an attempt's error when a file's bytes no longer match the digest and size its
|
|
13
|
+
* manifest declared.
|
|
14
|
+
*/ export const ARTIFACT_CHANGED_ERROR = 'artifact_changed';
|
|
15
|
+
// Manifest v2 artifacts this large get the longer attempt timeout.
|
|
16
|
+
const LARGE_ARTIFACT_BYTES = 25 * 1024 * 1024;
|
|
17
|
+
const MAX_ATTEMPTS = 8;
|
|
18
|
+
const RETRY_BASE_DELAY_MS = 1_000;
|
|
19
|
+
const RETRY_MAX_DELAY_MS = 20_000;
|
|
20
|
+
/**
|
|
21
|
+
* Uploads manifest v2 artifacts to the presigned POSTs the control plane returned for them. Each
|
|
22
|
+
* file is checked against the SHA-256 and size its manifest declared, on the exact bytes sent, so a
|
|
23
|
+
* file that changed after the manifest was built fails instead of uploading different bytes. The
|
|
24
|
+
* first artifact to fail for good aborts `cancel` and stops the rest.
|
|
25
|
+
*/ export async function uploadVerifiedArtifacts(params) {
|
|
26
|
+
const { artifacts, cancel, deadline, onAttemptFailure, onProgress, uploads } = params;
|
|
27
|
+
const stats = {
|
|
28
|
+
failed: 0,
|
|
29
|
+
totalBytesUploaded: 0,
|
|
30
|
+
uploaded: 0
|
|
31
|
+
};
|
|
32
|
+
const uploadOne = async (upload)=>{
|
|
33
|
+
const artifact = artifacts[upload.artifact];
|
|
34
|
+
const report = (statusCode, retryCount, error)=>onAttemptFailure?.(upload.artifact, statusCode, retryCount, error);
|
|
35
|
+
let bytes;
|
|
36
|
+
if (artifact) {
|
|
37
|
+
try {
|
|
38
|
+
bytes = await uploadPresignedPostFile(artifact.path, upload, // Serving headers come from the manifest, not the stored object.
|
|
39
|
+
'application/octet-stream', {
|
|
40
|
+
attemptTimeoutMs: artifact.size >= LARGE_ARTIFACT_BYTES ? LARGE_UPLOAD_ATTEMPT_TIMEOUT_MS : ASSET_ATTEMPT_TIMEOUT_MS,
|
|
41
|
+
deadline,
|
|
42
|
+
expected: artifact,
|
|
43
|
+
onAttemptFailure: report,
|
|
44
|
+
signal: cancel.signal
|
|
45
|
+
});
|
|
46
|
+
} catch {
|
|
47
|
+
report();
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
report();
|
|
51
|
+
}
|
|
52
|
+
if (bytes === undefined) {
|
|
53
|
+
if (!cancel.signal.aborted) {
|
|
54
|
+
stats.failed++;
|
|
55
|
+
stats.failedArtifact = upload.artifact;
|
|
56
|
+
cancel.abort();
|
|
57
|
+
}
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
stats.uploaded++;
|
|
61
|
+
stats.totalBytesUploaded += bytes;
|
|
62
|
+
onProgress?.(stats.uploaded, uploads.length);
|
|
63
|
+
};
|
|
64
|
+
await runUploadPool(uploads, cancel.signal, uploadOne);
|
|
65
|
+
return stats;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Uploads one file to a presigned S3 POST, retrying transient failures with jittered backoff.
|
|
69
|
+
* Returns the uploaded byte count, or undefined once the file has failed for good, ran out of
|
|
70
|
+
* budget, or `signal` cancelled it. Cancelled attempts aren't reported to `onAttemptFailure`. A
|
|
71
|
+
* failed attempt's `error` is `upload_budget_exhausted` when the budget, not the failure, rules out
|
|
72
|
+
* another attempt, and otherwise names what ended an attempt that got no response.
|
|
73
|
+
*/ export async function uploadPresignedPostFile(filePath, post, contentType, options) {
|
|
74
|
+
const { attemptTimeoutMs, deadline = Number.POSITIVE_INFINITY, expected, onAttemptFailure, signal } = options;
|
|
75
|
+
// One copy per file, reused by every attempt.
|
|
76
|
+
const data = await fs.readFile(filePath);
|
|
77
|
+
if (expected && (data.byteLength !== expected.size || crypto.createHash('sha256').update(data).digest('hex') !== expected.sha256)) {
|
|
78
|
+
onAttemptFailure?.(undefined, 0, ARTIFACT_CHANGED_ERROR);
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
const file = new Blob([
|
|
82
|
+
data
|
|
83
|
+
], {
|
|
84
|
+
type: contentType
|
|
85
|
+
});
|
|
86
|
+
for(let attempt = 0; attempt < MAX_ATTEMPTS; attempt++){
|
|
87
|
+
if (signal?.aborted) {
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
const attemptController = new AbortController();
|
|
91
|
+
const abortAttempt = ()=>attemptController.abort();
|
|
92
|
+
const timer = setTimeout(abortAttempt, Math.min(attemptTimeoutMs, deadline - Date.now()));
|
|
93
|
+
signal?.addEventListener('abort', abortAttempt);
|
|
94
|
+
let statusCode;
|
|
95
|
+
let error;
|
|
96
|
+
let retryable = true;
|
|
97
|
+
try {
|
|
98
|
+
// S3 presigned POST: policy fields go first, file part LAST. Fields appearing after `file`
|
|
99
|
+
// are ignored by S3, and the policy's signature covers the field set, so order matters.
|
|
100
|
+
// Don't set the request's Content-Type header: fetch generates the multipart/form-data
|
|
101
|
+
// boundary from the FormData body.
|
|
102
|
+
const form = new FormData();
|
|
103
|
+
for (const [name, value] of Object.entries(post.fields)){
|
|
104
|
+
form.append(name, value);
|
|
105
|
+
}
|
|
106
|
+
form.append('Content-Type', contentType);
|
|
107
|
+
form.append('file', file, 'file');
|
|
108
|
+
const response = await fetch(post.url, {
|
|
109
|
+
body: form,
|
|
110
|
+
method: 'POST',
|
|
111
|
+
signal: attemptController.signal
|
|
112
|
+
});
|
|
113
|
+
if (response.ok) {
|
|
114
|
+
return file.size;
|
|
115
|
+
}
|
|
116
|
+
statusCode = response.status;
|
|
117
|
+
retryable = await isRetryableResponse(response);
|
|
118
|
+
} catch (e) {
|
|
119
|
+
// Network error or attempt timeout: retryable.
|
|
120
|
+
error = attemptController.signal.aborted ? 'attempt_timeout' : networkErrorCode(e);
|
|
121
|
+
} finally{
|
|
122
|
+
clearTimeout(timer);
|
|
123
|
+
signal?.removeEventListener('abort', abortAttempt);
|
|
124
|
+
}
|
|
125
|
+
if (signal?.aborted) {
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
// Full jitter, so uploads that failed together don't retry together.
|
|
129
|
+
const delayMs = Math.random() * Math.min(RETRY_MAX_DELAY_MS, RETRY_BASE_DELAY_MS * 2 ** attempt);
|
|
130
|
+
const outOfBudget = Date.now() + delayMs >= deadline;
|
|
131
|
+
if (retryable && outOfBudget) {
|
|
132
|
+
error = 'upload_budget_exhausted';
|
|
133
|
+
}
|
|
134
|
+
onAttemptFailure?.(statusCode, attempt, error);
|
|
135
|
+
if (!retryable || attempt === MAX_ATTEMPTS - 1 || outOfBudget) {
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
await sleepUnlessAborted(delayMs, signal);
|
|
139
|
+
}
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Runs `uploadOne` over `items` with {@link UPLOAD_CONCURRENCY} workers. Each worker takes the
|
|
144
|
+
* next item as soon as its current one finishes, so a slow file holds up only its own slot instead
|
|
145
|
+
* of a whole batch. Stops taking items once `signal` aborts.
|
|
146
|
+
*/ export async function runUploadPool(items, signal, uploadOne) {
|
|
147
|
+
let next = 0;
|
|
148
|
+
const worker = async ()=>{
|
|
149
|
+
while(!signal.aborted){
|
|
150
|
+
const item = items[next++];
|
|
151
|
+
if (!item) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
await uploadOne(item);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
await Promise.all(Array.from({
|
|
158
|
+
length: UPLOAD_CONCURRENCY
|
|
159
|
+
}, worker));
|
|
160
|
+
}
|
|
161
|
+
// The socket's error code (such as ECONNRESET) is on the error fetch rejects with under Bun, which
|
|
162
|
+
// runs the compiled Make CLI, and on its cause under Node.
|
|
163
|
+
function networkErrorCode(e) {
|
|
164
|
+
if (!(e instanceof Error)) {
|
|
165
|
+
return 'unknown';
|
|
166
|
+
}
|
|
167
|
+
const cause = 'cause' in e ? e.cause : undefined;
|
|
168
|
+
for (const error of [
|
|
169
|
+
e,
|
|
170
|
+
cause
|
|
171
|
+
]){
|
|
172
|
+
if (error instanceof Error && 'code' in error && typeof error.code === 'string') {
|
|
173
|
+
return error.code;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return e.name;
|
|
177
|
+
}
|
|
178
|
+
// 5xx (including Cloudflare's 52x), 408, and 429 are transient. Other 4xx mean S3 rejected the
|
|
179
|
+
// presigned policy (expired, checksum mismatch, too large) and will again, except RequestTimeout,
|
|
180
|
+
// a 400 S3 sends when the body stalls mid-upload.
|
|
181
|
+
async function isRetryableResponse(response) {
|
|
182
|
+
const { status } = response;
|
|
183
|
+
if (status >= 500 || status === 408 || status === 429) {
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
return status === 400 && (await response.text()).includes('<Code>RequestTimeout</Code>');
|
|
187
|
+
}
|
|
188
|
+
function sleepUnlessAborted(ms, signal) {
|
|
189
|
+
return new Promise((resolve)=>{
|
|
190
|
+
const done = ()=>{
|
|
191
|
+
clearTimeout(timer);
|
|
192
|
+
signal?.removeEventListener('abort', done);
|
|
193
|
+
resolve();
|
|
194
|
+
};
|
|
195
|
+
const timer = setTimeout(done, ms);
|
|
196
|
+
signal?.addEventListener('abort', done);
|
|
197
|
+
});
|
|
198
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Stable codes shared with the control plane's manifest validation errors. */
|
|
2
|
+
export declare const ManifestIssueCode: {
|
|
3
|
+
readonly HEADER_RESERVED: "MANIFEST_HEADER_RESERVED";
|
|
4
|
+
readonly HTTP_INVALID: "MANIFEST_HTTP_INVALID";
|
|
5
|
+
readonly LIMIT_EXCEEDED: "MANIFEST_LIMIT_EXCEEDED";
|
|
6
|
+
readonly REFERENCE_INVALID: "MANIFEST_REFERENCE_INVALID";
|
|
7
|
+
readonly SCHEMA_INVALID: "MANIFEST_SCHEMA_INVALID";
|
|
8
|
+
readonly TOO_LARGE: "MANIFEST_TOO_LARGE";
|
|
9
|
+
};
|
|
10
|
+
export type ManifestIssueCode = (typeof ManifestIssueCode)[keyof typeof ManifestIssueCode];
|
|
11
|
+
export interface ManifestIssue {
|
|
12
|
+
code: ManifestIssueCode;
|
|
13
|
+
message: string;
|
|
14
|
+
/** JSON Pointer into the manifest. */
|
|
15
|
+
pointer: string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Stable codes shared with the control plane's manifest validation errors. */ export const ManifestIssueCode = {
|
|
2
|
+
HEADER_RESERVED: 'MANIFEST_HEADER_RESERVED',
|
|
3
|
+
HTTP_INVALID: 'MANIFEST_HTTP_INVALID',
|
|
4
|
+
LIMIT_EXCEEDED: 'MANIFEST_LIMIT_EXCEEDED',
|
|
5
|
+
REFERENCE_INVALID: 'MANIFEST_REFERENCE_INVALID',
|
|
6
|
+
SCHEMA_INVALID: 'MANIFEST_SCHEMA_INVALID',
|
|
7
|
+
TOO_LARGE: 'MANIFEST_TOO_LARGE'
|
|
8
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { createIssue } from './createIssue.js';
|
|
2
|
+
import { escapePointer } from './escapePointer.js';
|
|
3
|
+
import { ManifestIssueCode } from './types.js';
|
|
4
|
+
import { validateId } from './validateId.js';
|
|
5
|
+
const SHA256_PATTERN = /^[0-9a-f]{64}$/;
|
|
6
|
+
/** Every artifact has a valid ID, a lowercase hex SHA-256 and a non-negative integer size. */ export function validateArtifacts(manifest) {
|
|
7
|
+
return Object.entries(manifest.artifacts).flatMap(([id, artifact])=>{
|
|
8
|
+
const pointer = `/artifacts/${escapePointer(id)}`;
|
|
9
|
+
return [
|
|
10
|
+
...validateId({
|
|
11
|
+
id,
|
|
12
|
+
pointer
|
|
13
|
+
}),
|
|
14
|
+
...SHA256_PATTERN.test(artifact.sha256) ? [] : [
|
|
15
|
+
createIssue({
|
|
16
|
+
code: ManifestIssueCode.SCHEMA_INVALID,
|
|
17
|
+
message: 'sha256 must be 64 lowercase hex characters',
|
|
18
|
+
pointer: `${pointer}/sha256`
|
|
19
|
+
})
|
|
20
|
+
],
|
|
21
|
+
...Number.isSafeInteger(artifact.size) && artifact.size >= 0 ? [] : [
|
|
22
|
+
createIssue({
|
|
23
|
+
code: ManifestIssueCode.SCHEMA_INVALID,
|
|
24
|
+
message: 'size must be a non-negative integer',
|
|
25
|
+
pointer: `${pointer}/size`
|
|
26
|
+
})
|
|
27
|
+
]
|
|
28
|
+
];
|
|
29
|
+
});
|
|
30
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ManifestCachePolicy } from '../types.js';
|
|
2
|
+
interface ValidateCachePolicyArgs {
|
|
3
|
+
cache: ManifestCachePolicy;
|
|
4
|
+
pointer: string;
|
|
5
|
+
}
|
|
6
|
+
/** Bounded policies need ages from 0 to one year; immutable also needs a positive browser age. */
|
|
7
|
+
export declare function validateCachePolicy({ cache, pointer }: ValidateCachePolicyArgs): import("./types.js").ManifestIssue[];
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createIssue } from './createIssue.js';
|
|
2
|
+
import { ManifestIssueCode } from './types.js';
|
|
3
|
+
const MAX_AGE_SECONDS = 31_536_000;
|
|
4
|
+
/** Bounded policies need ages from 0 to one year; immutable also needs a positive browser age. */ export function validateCachePolicy({ cache, pointer }) {
|
|
5
|
+
if (cache.mode !== 'ttl' && cache.mode !== 'immutable') {
|
|
6
|
+
return [];
|
|
7
|
+
}
|
|
8
|
+
const ages = {
|
|
9
|
+
browserMaxAgeSeconds: cache.browserMaxAgeSeconds,
|
|
10
|
+
sharedMaxAgeSeconds: cache.sharedMaxAgeSeconds,
|
|
11
|
+
staleWhileRevalidateSeconds: cache.staleWhileRevalidateSeconds ?? 0
|
|
12
|
+
};
|
|
13
|
+
const ageIssues = Object.entries(ages).filter(([, value])=>!Number.isInteger(value) || value < 0 || value > MAX_AGE_SECONDS).map(([field])=>createIssue({
|
|
14
|
+
code: ManifestIssueCode.SCHEMA_INVALID,
|
|
15
|
+
message: `${field} must be an integer from 0 to ${MAX_AGE_SECONDS}`,
|
|
16
|
+
pointer: `${pointer}/${field}`
|
|
17
|
+
}));
|
|
18
|
+
return cache.mode === 'immutable' && cache.browserMaxAgeSeconds < 1 ? [
|
|
19
|
+
...ageIssues,
|
|
20
|
+
createIssue({
|
|
21
|
+
code: ManifestIssueCode.SCHEMA_INVALID,
|
|
22
|
+
message: 'immutable responses need a positive browserMaxAgeSeconds',
|
|
23
|
+
pointer: `${pointer}/browserMaxAgeSeconds`
|
|
24
|
+
})
|
|
25
|
+
] : ageIssues;
|
|
26
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createIssue } from '../createIssue.js';
|
|
2
|
+
import { ManifestIssueCode } from '../types.js';
|
|
3
|
+
export function validateCount({ count, limit, pointer }) {
|
|
4
|
+
return count > limit ? [
|
|
5
|
+
createIssue({
|
|
6
|
+
code: ManifestIssueCode.LIMIT_EXCEEDED,
|
|
7
|
+
message: `${count} entries; the limit is ${limit}`,
|
|
8
|
+
pointer
|
|
9
|
+
})
|
|
10
|
+
] : [];
|
|
11
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { MANIFEST_V2_LIMITS } from '../limits.js';
|
|
2
|
+
import { validateCount } from './validateCounts/validateCount.js';
|
|
3
|
+
/** Artifacts, responses, static entries, routes, header rules and servers stay within limits. */ export function validateCounts(manifest) {
|
|
4
|
+
const counts = [
|
|
5
|
+
[
|
|
6
|
+
'/artifacts',
|
|
7
|
+
Object.keys(manifest.artifacts).length,
|
|
8
|
+
MANIFEST_V2_LIMITS.maxArtifacts
|
|
9
|
+
],
|
|
10
|
+
[
|
|
11
|
+
'/responses',
|
|
12
|
+
Object.keys(manifest.responses).length,
|
|
13
|
+
MANIFEST_V2_LIMITS.maxResponses
|
|
14
|
+
],
|
|
15
|
+
[
|
|
16
|
+
'/static',
|
|
17
|
+
Object.keys(manifest.static).length,
|
|
18
|
+
MANIFEST_V2_LIMITS.maxStaticEntries
|
|
19
|
+
],
|
|
20
|
+
[
|
|
21
|
+
'/routes',
|
|
22
|
+
manifest.routes.length,
|
|
23
|
+
MANIFEST_V2_LIMITS.maxRoutes
|
|
24
|
+
],
|
|
25
|
+
[
|
|
26
|
+
'/headers',
|
|
27
|
+
manifest.headers?.length ?? 0,
|
|
28
|
+
MANIFEST_V2_LIMITS.maxHeaderRules
|
|
29
|
+
],
|
|
30
|
+
[
|
|
31
|
+
'/servers',
|
|
32
|
+
Object.keys(manifest.servers ?? {}).length,
|
|
33
|
+
MANIFEST_V2_LIMITS.maxServers
|
|
34
|
+
]
|
|
35
|
+
];
|
|
36
|
+
return counts.flatMap(([pointer, count, limit])=>validateCount({
|
|
37
|
+
count,
|
|
38
|
+
limit,
|
|
39
|
+
pointer
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createIssue } from './createIssue.js';
|
|
2
|
+
import { ManifestIssueCode } from './types.js';
|
|
3
|
+
/** The fallback names a declared server or response. */ export function validateFallback(manifest) {
|
|
4
|
+
const { fallback } = manifest;
|
|
5
|
+
if (fallback.type === 'server') {
|
|
6
|
+
return Object.hasOwn(manifest.servers ?? {}, fallback.server) ? [] : [
|
|
7
|
+
createIssue({
|
|
8
|
+
code: ManifestIssueCode.REFERENCE_INVALID,
|
|
9
|
+
message: `unknown server ${fallback.server}`,
|
|
10
|
+
pointer: '/fallback/server'
|
|
11
|
+
})
|
|
12
|
+
];
|
|
13
|
+
}
|
|
14
|
+
return fallback.response === undefined || Object.hasOwn(manifest.responses, fallback.response) ? [] : [
|
|
15
|
+
createIssue({
|
|
16
|
+
code: ManifestIssueCode.REFERENCE_INVALID,
|
|
17
|
+
message: `unknown response ${fallback.response}`,
|
|
18
|
+
pointer: '/fallback/response'
|
|
19
|
+
})
|
|
20
|
+
];
|
|
21
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createIssue } from './createIssue.js';
|
|
2
|
+
import { ManifestIssueCode } from './types.js';
|
|
3
|
+
// An HTTP field name (RFC 9110 token) of at most 128 bytes.
|
|
4
|
+
const HEADER_NAME_PATTERN = /^[!#$%&'*+.^\w`|~-]{1,128}$/;
|
|
5
|
+
export function validateHeaderName({ name, pointer }) {
|
|
6
|
+
return HEADER_NAME_PATTERN.test(name) ? [] : [
|
|
7
|
+
createIssue({
|
|
8
|
+
code: ManifestIssueCode.SCHEMA_INVALID,
|
|
9
|
+
message: `invalid header name ${JSON.stringify(name)}`,
|
|
10
|
+
pointer
|
|
11
|
+
})
|
|
12
|
+
];
|
|
13
|
+
}
|