@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.
Files changed (187) hide show
  1. package/dist/adapters/asset-collection.d.ts +15 -0
  2. package/dist/adapters/asset-collection.js +51 -45
  3. package/dist/adapters/build-lambda-zip.d.ts +8 -9
  4. package/dist/adapters/build-lambda-zip.js +36 -44
  5. package/dist/adapters/index.d.ts +4 -0
  6. package/dist/adapters/index.js +4 -0
  7. package/dist/adapters/lambdaLimits.d.ts +6 -0
  8. package/dist/adapters/lambdaLimits.js +5 -0
  9. package/dist/adapters/nextjs-assets.d.ts +7 -0
  10. package/dist/adapters/nextjs-assets.js +44 -0
  11. package/dist/adapters/nextjs.d.ts +8 -0
  12. package/dist/adapters/nextjs.js +19 -37
  13. package/dist/adapters/nitro.js +18 -43
  14. package/dist/adapters/omit-optional-sharp.d.ts +22 -0
  15. package/dist/adapters/omit-optional-sharp.js +158 -0
  16. package/dist/adapters/secret-files.js +8 -1
  17. package/dist/adapters/types.d.ts +8 -0
  18. package/dist/adapters/v2/core/build.d.ts +69 -0
  19. package/dist/adapters/v2/core/build.js +183 -0
  20. package/dist/adapters/v2/core/content-type.d.ts +3 -0
  21. package/dist/adapters/v2/core/content-type.js +41 -0
  22. package/dist/adapters/v2/core/getRelativePathError.d.ts +5 -0
  23. package/dist/adapters/v2/core/getRelativePathError.js +21 -0
  24. package/dist/adapters/v2/core/index.d.ts +15 -0
  25. package/dist/adapters/v2/core/index.js +13 -0
  26. package/dist/adapters/v2/core/limits.d.ts +28 -0
  27. package/dist/adapters/v2/core/limits.js +26 -0
  28. package/dist/adapters/v2/core/manifest-version.d.ts +10 -0
  29. package/dist/adapters/v2/core/manifest-version.js +14 -0
  30. package/dist/adapters/v2/core/server-zip.d.ts +58 -0
  31. package/dist/adapters/v2/core/server-zip.js +123 -0
  32. package/dist/adapters/v2/core/services.d.ts +46 -0
  33. package/dist/adapters/v2/core/services.js +202 -0
  34. package/dist/adapters/v2/core/static-path.d.ts +13 -0
  35. package/dist/adapters/v2/core/static-path.js +32 -0
  36. package/dist/adapters/v2/core/static-site.d.ts +26 -0
  37. package/dist/adapters/v2/core/static-site.js +95 -0
  38. package/dist/adapters/v2/core/types.d.ts +128 -0
  39. package/dist/adapters/v2/core/types.js +7 -0
  40. package/dist/adapters/v2/core/upload.d.ts +67 -0
  41. package/dist/adapters/v2/core/upload.js +198 -0
  42. package/dist/adapters/v2/core/validateDeployment/createIssue.d.ts +3 -0
  43. package/dist/adapters/v2/core/validateDeployment/createIssue.js +7 -0
  44. package/dist/adapters/v2/core/validateDeployment/escapePointer.d.ts +2 -0
  45. package/dist/adapters/v2/core/validateDeployment/escapePointer.js +3 -0
  46. package/dist/adapters/v2/core/validateDeployment/singletonHeaders.d.ts +2 -0
  47. package/dist/adapters/v2/core/validateDeployment/singletonHeaders.js +10 -0
  48. package/dist/adapters/v2/core/validateDeployment/types.d.ts +16 -0
  49. package/dist/adapters/v2/core/validateDeployment/types.js +8 -0
  50. package/dist/adapters/v2/core/validateDeployment/validateArtifacts.d.ts +3 -0
  51. package/dist/adapters/v2/core/validateDeployment/validateArtifacts.js +30 -0
  52. package/dist/adapters/v2/core/validateDeployment/validateCachePolicy.d.ts +8 -0
  53. package/dist/adapters/v2/core/validateDeployment/validateCachePolicy.js +26 -0
  54. package/dist/adapters/v2/core/validateDeployment/validateCounts/validateCount.d.ts +7 -0
  55. package/dist/adapters/v2/core/validateDeployment/validateCounts/validateCount.js +11 -0
  56. package/dist/adapters/v2/core/validateDeployment/validateCounts.d.ts +3 -0
  57. package/dist/adapters/v2/core/validateDeployment/validateCounts.js +41 -0
  58. package/dist/adapters/v2/core/validateDeployment/validateFallback.d.ts +3 -0
  59. package/dist/adapters/v2/core/validateDeployment/validateFallback.js +21 -0
  60. package/dist/adapters/v2/core/validateDeployment/validateHeaderName.d.ts +6 -0
  61. package/dist/adapters/v2/core/validateDeployment/validateHeaderName.js +13 -0
  62. package/dist/adapters/v2/core/validateDeployment/validateHeaderRules/validateHeaderOp/isReservedRuleHeader.d.ts +2 -0
  63. package/dist/adapters/v2/core/validateDeployment/validateHeaderRules/validateHeaderOp/isReservedRuleHeader.js +13 -0
  64. package/dist/adapters/v2/core/validateDeployment/validateHeaderRules/validateHeaderOp.d.ts +11 -0
  65. package/dist/adapters/v2/core/validateDeployment/validateHeaderRules/validateHeaderOp.js +38 -0
  66. package/dist/adapters/v2/core/validateDeployment/validateHeaderRules.d.ts +3 -0
  67. package/dist/adapters/v2/core/validateDeployment/validateHeaderRules.js +17 -0
  68. package/dist/adapters/v2/core/validateDeployment/validateHeaderValue.d.ts +6 -0
  69. package/dist/adapters/v2/core/validateDeployment/validateHeaderValue.js +24 -0
  70. package/dist/adapters/v2/core/validateDeployment/validateId.d.ts +7 -0
  71. package/dist/adapters/v2/core/validateDeployment/validateId.js +12 -0
  72. package/dist/adapters/v2/core/validateDeployment/validateMatch.d.ts +15 -0
  73. package/dist/adapters/v2/core/validateDeployment/validateMatch.js +74 -0
  74. package/dist/adapters/v2/core/validateDeployment/validatePublicPath.d.ts +7 -0
  75. package/dist/adapters/v2/core/validateDeployment/validatePublicPath.js +21 -0
  76. package/dist/adapters/v2/core/validateDeployment/validateResponses/validateHeaderList/findRepeatedSingletons.d.ts +3 -0
  77. package/dist/adapters/v2/core/validateDeployment/validateResponses/validateHeaderList/findRepeatedSingletons.js +16 -0
  78. package/dist/adapters/v2/core/validateDeployment/validateResponses/validateHeaderList.d.ts +11 -0
  79. package/dist/adapters/v2/core/validateDeployment/validateResponses/validateHeaderList.js +48 -0
  80. package/dist/adapters/v2/core/validateDeployment/validateResponses/validateResponseBody.d.ts +10 -0
  81. package/dist/adapters/v2/core/validateDeployment/validateResponses/validateResponseBody.js +16 -0
  82. package/dist/adapters/v2/core/validateDeployment/validateResponses/validateResponseStatus.d.ts +8 -0
  83. package/dist/adapters/v2/core/validateDeployment/validateResponses/validateResponseStatus.js +25 -0
  84. package/dist/adapters/v2/core/validateDeployment/validateResponses.d.ts +7 -0
  85. package/dist/adapters/v2/core/validateDeployment/validateResponses.js +59 -0
  86. package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateCaptures.d.ts +10 -0
  87. package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateCaptures.js +12 -0
  88. package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateRedirectAction.d.ts +14 -0
  89. package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateRedirectAction.js +59 -0
  90. package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateRewriteAction.d.ts +11 -0
  91. package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateRewriteAction.js +20 -0
  92. package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateServerAction.d.ts +11 -0
  93. package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateServerAction.js +26 -0
  94. package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateStaticAction.d.ts +13 -0
  95. package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateStaticAction.js +25 -0
  96. package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction.d.ts +12 -0
  97. package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction.js +35 -0
  98. package/dist/adapters/v2/core/validateDeployment/validateRoutes.d.ts +6 -0
  99. package/dist/adapters/v2/core/validateDeployment/validateRoutes.js +55 -0
  100. package/dist/adapters/v2/core/validateDeployment/validateServers/listReferencedServerIds.d.ts +3 -0
  101. package/dist/adapters/v2/core/validateDeployment/validateServers/listReferencedServerIds.js +12 -0
  102. package/dist/adapters/v2/core/validateDeployment/validateServers.d.ts +7 -0
  103. package/dist/adapters/v2/core/validateDeployment/validateServers.js +59 -0
  104. package/dist/adapters/v2/core/validateDeployment/validateStaticMap.d.ts +3 -0
  105. package/dist/adapters/v2/core/validateDeployment/validateStaticMap.js +22 -0
  106. package/dist/adapters/v2/core/validateDeployment.d.ts +7 -0
  107. package/dist/adapters/v2/core/validateDeployment.js +42 -0
  108. package/dist/adapters/v2/core/write.d.ts +21 -0
  109. package/dist/adapters/v2/core/write.js +30 -0
  110. package/dist/adapters/v2/nextjs/coverage.d.ts +45 -0
  111. package/dist/adapters/v2/nextjs/coverage.js +113 -0
  112. package/dist/adapters/v2/nextjs/read-build-output.d.ts +116 -0
  113. package/dist/adapters/v2/nextjs/read-build-output.js +368 -0
  114. package/dist/adapters/v2/nextjs/translate.d.ts +20 -0
  115. package/dist/adapters/v2/nextjs/translate.js +400 -0
  116. package/dist/adapters/vite.d.ts +7 -0
  117. package/dist/adapters/vite.js +47 -0
  118. package/dist/adapters/writeZip.d.ts +20 -0
  119. package/dist/adapters/writeZip.js +28 -0
  120. package/dist/api/control-plane.d.ts +28 -6
  121. package/dist/api/control-plane.js +67 -64
  122. package/dist/auth/cli-build-context.d.ts +3 -0
  123. package/dist/auth/cli-build-context.js +2 -0
  124. package/dist/auth/oauth-flow.d.ts +3 -3
  125. package/dist/auth/oauth-flow.js +13 -3
  126. package/dist/cli.js +15 -0
  127. package/dist/commands/build-manifest.d.ts +49 -0
  128. package/dist/commands/build-manifest.js +111 -0
  129. package/dist/commands/deploy.js +195 -26
  130. package/dist/db-content-api/generated/content-api-types.d.ts +18 -14
  131. package/dist/db-content-api/index.js +4 -1
  132. package/dist/db-content-api/utilities/where.js +2 -6
  133. package/dist/endpoints/client-config.d.ts +3 -0
  134. package/dist/endpoints/client-config.js +87 -0
  135. package/dist/image-transforms/constants.d.ts +8 -0
  136. package/dist/image-transforms/constants.js +26 -0
  137. package/dist/image-transforms/createImageTransformer.d.ts +6 -0
  138. package/dist/image-transforms/createImageTransformer.js +100 -0
  139. package/dist/image-transforms/deliverImageResponse.d.ts +11 -0
  140. package/dist/image-transforms/deliverImageResponse.js +43 -0
  141. package/dist/image-transforms/imageRevision.d.ts +14 -0
  142. package/dist/image-transforms/imageRevision.js +115 -0
  143. package/dist/image-transforms/normalizeMediaType.d.ts +2 -0
  144. package/dist/image-transforms/normalizeMediaType.js +3 -0
  145. package/dist/image-transforms/parseImageOverrides.d.ts +4 -0
  146. package/dist/image-transforms/parseImageOverrides.js +20 -0
  147. package/dist/image-transforms/preserveImageRedirectHeaders.d.ts +2 -0
  148. package/dist/image-transforms/preserveImageRedirectHeaders.js +30 -0
  149. package/dist/image-transforms/preventConflictingImageTransformers.d.ts +9 -0
  150. package/dist/image-transforms/preventConflictingImageTransformers.js +67 -0
  151. package/dist/image-transforms/serveImageRequest.d.ts +6 -0
  152. package/dist/image-transforms/serveImageRequest.js +97 -0
  153. package/dist/image-transforms/storedImage.d.ts +49 -0
  154. package/dist/image-transforms/storedImage.js +84 -0
  155. package/dist/image-transforms/types.d.ts +9 -0
  156. package/dist/image-transforms/types.js +1 -0
  157. package/dist/image-transforms/variantMetadata.d.ts +13 -0
  158. package/dist/image-transforms/variantMetadata.js +164 -0
  159. package/dist/imageSizeOptions.d.ts +8 -8
  160. package/dist/imageSizeOptions.js +0 -2
  161. package/dist/index.d.ts +1 -0
  162. package/dist/oauth/hooks/refresh.js +9 -4
  163. package/dist/oauth/strategy/index.js +34 -14
  164. package/dist/oauth/utilities/createTokenCookie.d.ts +11 -0
  165. package/dist/oauth/utilities/createTokenCookie.js +21 -0
  166. package/dist/oauth/utilities/refreshTokens.d.ts +7 -5
  167. package/dist/oauth/utilities/refreshTokens.js +7 -23
  168. package/dist/plugin/build-config.d.ts +3 -4
  169. package/dist/plugin/build-config.js +39 -18
  170. package/dist/plugin/mcp-oauth.d.ts +18 -7
  171. package/dist/plugin/mcp-oauth.js +123 -10
  172. package/dist/skills/deploy-to-figma/SKILL.md +8 -8
  173. package/dist/skills/deploy-to-figma/references/cli-reference.md +1 -1
  174. package/dist/storage-content-api/buildClientUploadFetchBackHeaders.d.ts +2 -1
  175. package/dist/storage-content-api/buildClientUploadFetchBackHeaders.js +2 -1
  176. package/dist/storage-content-api/buildMediaResponseHeaders.d.ts +2 -1
  177. package/dist/storage-content-api/buildMediaResponseHeaders.js +11 -5
  178. package/dist/storage-content-api/isRunningInLambda.d.ts +2 -0
  179. package/dist/storage-content-api/isRunningInLambda.js +3 -0
  180. package/dist/storage-content-api/staticHandler.js +13 -51
  181. package/dist/storage-content-api/streamMediaResponse.d.ts +17 -0
  182. package/dist/storage-content-api/streamMediaResponse.js +96 -0
  183. package/dist/utils/lambda-config.js +1 -1
  184. package/dist/utils/messages.js +8 -0
  185. package/dist/utils/next-image-loader-config.js +43 -6
  186. package/dist/utils/next-image-loader-file.js +8 -0
  187. package/package.json +12 -4
@@ -0,0 +1,400 @@
1
+ import path from 'path';
2
+ import { createNextjsServerFiles } from '../../build-lambda-zip.js';
3
+ import { assertDeployableServerActionsKey } from '../../deploy-output/assertDeployableServerActionsKey.js';
4
+ import { omitOptionalSharp } from '../../omit-optional-sharp.js';
5
+ import { responseIdForPath } from '../core/build.js';
6
+ import { contentTypeForPath } from '../core/content-type.js';
7
+ import { packageServer } from '../core/server-zip.js';
8
+ import { staticPathsForFile } from '../core/static-path.js';
9
+ import { createNextCoverage, publicUrl } from './coverage.js';
10
+ export const NEXTJS_SERVER_ID = 'web';
11
+ const HTML_CONTENT_TYPE = 'text/html; charset=utf-8';
12
+ const RSC_CONTENT_TYPE = 'text/x-component';
13
+ const MAX_AGE_SECONDS = 31_536_000;
14
+ /** `_next/static/` paths carry the build ID or a content hash, so they never change content. */ const IMMUTABLE_CACHE = {
15
+ browserMaxAgeSeconds: MAX_AGE_SECONDS,
16
+ mode: 'immutable',
17
+ sharedMaxAgeSeconds: MAX_AGE_SECONDS
18
+ };
19
+ const STATIC_METHODS = [
20
+ 'GET',
21
+ 'HEAD'
22
+ ];
23
+ const RSC_QUERY = '_rsc';
24
+ /** Headers `.meta` carries for Next.js's own cache that its server never sends. */ const INTERNAL_META_HEADERS = new Set([
25
+ 'x-next-cache-tags'
26
+ ]);
27
+ /** Next.js routes that exist only for the server's own error handling. */ const INTERNAL_PAGES = new Set([
28
+ '/_global-error',
29
+ '/_not-found'
30
+ ]);
31
+ /**
32
+ * Translates a Next.js build into manifest v2 input. Framework behavior stays in the Next.js
33
+ * server: the manifest answers only requests it can prove match a prerendered artifact, and sends
34
+ * everything else, including every path middleware or request-dependent next.config rules cover,
35
+ * to the server.
36
+ */ export async function toManifestV2Input(model, options) {
37
+ const coverage = createNextCoverage(model);
38
+ const responses = {};
39
+ const responseIds = new Set();
40
+ const routeIds = new Set();
41
+ const routes = [];
42
+ const staticMap = {};
43
+ const serverPublicFiles = [];
44
+ const vary = varyHeader(model);
45
+ const serverCanRewrite = model.hasRewrites || model.middlewareMatchers !== undefined;
46
+ // Page and ISR paths come from prerender-manifest.json; undefined when no request can match one.
47
+ const toUrl = (routeKey)=>{
48
+ const requestPath = toRequestPath(routeKey);
49
+ return requestPath === undefined ? undefined : publicUrl(model.basePath, requestPath);
50
+ };
51
+ // Static files are raw names on disk. Gatekeeper matches paths as received, percent-encoded, so
52
+ // each file gets a key for every encoded form a client sends.
53
+ const toFileUrls = (publicPath)=>staticPathsForFile(publicPath.slice(1)).map((url)=>model.basePath + url);
54
+ const addResponse = (key, response)=>{
55
+ const id = responseIdForPath(key, responseIds);
56
+ responses[id] = response;
57
+ return id;
58
+ };
59
+ const addRoute = (key, route)=>{
60
+ routes.push({
61
+ id: responseIdForPath(key, routeIds),
62
+ ...route
63
+ });
64
+ };
65
+ if (!model.computeRscParam) {
66
+ options.logger?.warning("This Next.js build doesn't export computeCacheBustingSearchParam, so RSC requests go to the server.");
67
+ }
68
+ for (const page of model.pages){
69
+ if (INTERNAL_PAGES.has(page.path)) {
70
+ continue;
71
+ }
72
+ const decision = coverage.decideStaticPath(page.path);
73
+ const url = toUrl(page.path);
74
+ // An uncovered page needs no routes: the server fallback answers every request for it. A
75
+ // next.config Content-Type would also replace the RSC payload's type, so Next.js serves it.
76
+ if (!decision.serveStatically || contentTypeOverride(decision.headers) !== undefined || url === undefined) {
77
+ continue;
78
+ }
79
+ await addPageRoutes({
80
+ addResponse,
81
+ addRoute,
82
+ extraHeaders: [
83
+ ...decision.headers,
84
+ {
85
+ name: 'Vary',
86
+ value: vary
87
+ }
88
+ ],
89
+ model,
90
+ page,
91
+ url
92
+ });
93
+ }
94
+ // Only exact prerendered ISR paths get a shared cache. A pattern such as `/blog/:slug` would also
95
+ // match sibling routes Next.js ranks higher (`app/blog/feed/route.ts`, `pages/api/...`) and
96
+ // static files, and cache their per-visitor responses. Other paths reach the server uncached.
97
+ for (const route of model.isrRoutes){
98
+ const url = toUrl(route.path);
99
+ if (route.path.includes(':') || !coverage.allowsIsrCache(route) || url === undefined) {
100
+ continue;
101
+ }
102
+ addRoute(`isr${route.path}`, {
103
+ action: {
104
+ type: 'server',
105
+ cache: isrCache(model, route),
106
+ server: NEXTJS_SERVER_ID
107
+ },
108
+ // Server Actions are POSTs to the page path, and must never share a cache.
109
+ match: {
110
+ methods: STATIC_METHODS,
111
+ path: url
112
+ }
113
+ });
114
+ }
115
+ // Hashed build output counted per server reason it is served statically without.
116
+ const ignoredReasons = new Map();
117
+ for (const file of model.staticFiles){
118
+ const decision = coverage.decideStaticPath(file.path, {
119
+ hashed: file.hashed
120
+ });
121
+ for (const reason of decision.ignoredReasons ?? []){
122
+ ignoredReasons.set(reason, (ignoredReasons.get(reason) ?? 0) + 1);
123
+ }
124
+ // Next.js's standalone server serves public/ only when it is copied beside server.js. It needs
125
+ // them for paths it handles, and for any next.config or middleware rewrite it applies, which can
126
+ // target a public file at a path still served statically.
127
+ if (file.kind === 'public' && (!decision.serveStatically || serverCanRewrite)) {
128
+ serverPublicFiles.push({
129
+ sourcePath: file.file,
130
+ zipPath: path.posix.join(serverDir(model), 'public', file.path.slice(1))
131
+ });
132
+ }
133
+ if (!decision.serveStatically) {
134
+ continue;
135
+ }
136
+ const override = contentTypeOverride(decision.headers);
137
+ const headers = decision.headers.filter((header)=>!isContentType(header));
138
+ const id = addResponse(file.path, {
139
+ // Metadata icon bytes live in `.body` files, so type them by their public path.
140
+ contentType: override ?? contentTypeForPath(file.path),
141
+ file: file.file,
142
+ ...headers.length > 0 ? {
143
+ headers
144
+ } : {},
145
+ ...file.hashed ? {
146
+ cache: IMMUTABLE_CACHE
147
+ } : {}
148
+ });
149
+ for (const url of toFileUrls(file.path)){
150
+ staticMap[url] = id;
151
+ }
152
+ }
153
+ for (const [reason, count] of ignoredReasons){
154
+ options.logger?.warning(`${reason} matches ${count} _next/static files. They are served statically without it, because the server deployment doesn't contain them.`);
155
+ }
156
+ await assertDeployableServerActionsKey(model.server.outputPath);
157
+ const server = await packageServer({
158
+ entrypoint: relativeEntrypoint(model),
159
+ extraFiles: serverPublicFiles,
160
+ // Like v1's lambda.zip: Sharp (about 40 MB) goes when only Next.js pulled it in.
161
+ filterFiles: (files)=>omitOptionalSharp(options.projectPath, model.server.outputPath, files, options.logger),
162
+ maxUnzippedBytes: options.skipSizeCheck ? null : undefined,
163
+ outDir: options.artifactDir,
164
+ overrides: await createNextjsServerFiles(model.server.standalonePath, model.server.serverEntryPath, options.logger),
165
+ rootDir: model.server.standalonePath
166
+ });
167
+ return {
168
+ fallback: {
169
+ type: 'server',
170
+ server: NEXTJS_SERVER_ID
171
+ },
172
+ responses,
173
+ rootDir: commonRoot(Object.values(responses).flatMap((response)=>response.file ? [
174
+ response.file
175
+ ] : []), model.server.outputPath),
176
+ routes,
177
+ servers: {
178
+ [NEXTJS_SERVER_ID]: {
179
+ entrypoint: server.entrypoint,
180
+ zipPath: server.zipPath
181
+ }
182
+ },
183
+ source: {
184
+ framework: 'nextjs',
185
+ ...model.nextVersion ? {
186
+ frameworkVersion: model.nextVersion
187
+ } : {},
188
+ languages: [
189
+ 'javascript'
190
+ ]
191
+ },
192
+ static: staticMap
193
+ };
194
+ }
195
+ /**
196
+ * The request path that matches a prerender-manifest.json route key, or undefined when no request
197
+ * path can match it statically. Next.js builds the key from the decoded parameter values and
198
+ * escapes only `/`, `#` and `?` in them (`escapePathDelimiters`), so `café` stays raw while the
199
+ * slug `a?b` becomes `a%3Fb`. The URL `pathname` setter encodes the raw characters the way a
200
+ * browser does (`caf%C3%A9`, `a%20b`) and keeps those escapes.
201
+ *
202
+ * Any other `%` is ambiguous: `a%20b` is either the slug `a b` or the literal text, which Next.js
203
+ * leaves as is. A `%2F` or `\` in a value can't reach the server as part of one segment either, and
204
+ * the setter would collapse a `.` or `..` segment into another page's path (`/blog/..` into `/`).
205
+ * Those pages go to the server.
206
+ */ function toRequestPath(routeKey) {
207
+ if (/[\\\t\n\r]/.test(routeKey) || routeKey.replace(/%(?:23|3F)/g, '').includes('%') || routeKey.split('/').some((segment)=>segment === '.' || segment === '..')) {
208
+ return undefined;
209
+ }
210
+ const url = new URL('http://static.invalid');
211
+ url.pathname = routeKey;
212
+ return url.pathname;
213
+ }
214
+ /** The Content-Type a next.config `headers` rule sets, which replaces the file's own type. */ function contentTypeOverride(headers) {
215
+ return headers.filter(isContentType).at(-1)?.value;
216
+ }
217
+ function isContentType(header) {
218
+ return header.name.toLowerCase() === 'content-type';
219
+ }
220
+ /**
221
+ * Emits, in order: one static route per segment-prefetch payload, one for the full RSC payload,
222
+ * one for HTML, and a server route for every other request to the page, so those requests never
223
+ * fall through to the static map. RSC routes require the exact `_rsc` value the build's Next.js
224
+ * computes; without that function every RSC request goes to the server.
225
+ */ async function addPageRoutes(options) {
226
+ const { addResponse, addRoute, extraHeaders, model, page, url } = options;
227
+ const h = model.rscHeaders;
228
+ const compute = model.computeRscParam;
229
+ const headers = [
230
+ ...page.metaHeaders.filter((entry)=>!INTERNAL_META_HEADERS.has(entry.name.toLowerCase())),
231
+ ...extraHeaders
232
+ ];
233
+ const header = (key, value)=>({
234
+ type: 'header',
235
+ key,
236
+ ...value !== undefined ? {
237
+ value
238
+ } : {}
239
+ });
240
+ const rscResponse = (file, extra = [])=>({
241
+ contentType: RSC_CONTENT_TYPE,
242
+ file,
243
+ headers: [
244
+ ...headers,
245
+ ...extra
246
+ ],
247
+ status: page.status
248
+ });
249
+ if (compute) {
250
+ for (const segment of page.segments){
251
+ addRoute(`${page.path}.segment${segment.segmentPath}`, {
252
+ action: {
253
+ type: 'static',
254
+ response: addResponse(`${page.path}.segments${segment.segmentPath}`, rscResponse(segment.file, [
255
+ {
256
+ name: 'x-nextjs-postponed',
257
+ value: '2'
258
+ }
259
+ ]))
260
+ },
261
+ match: {
262
+ has: [
263
+ header(h.rsc, '1'),
264
+ header(h.prefetch, '1'),
265
+ header(h.segmentPrefetch, segment.segmentPath),
266
+ {
267
+ type: 'query',
268
+ key: RSC_QUERY,
269
+ value: await compute({
270
+ prefetch: '1',
271
+ segmentPrefetch: segment.segmentPath
272
+ })
273
+ }
274
+ ],
275
+ methods: STATIC_METHODS,
276
+ missing: [
277
+ header(h.stateTree),
278
+ header(h.nextUrl)
279
+ ],
280
+ path: url,
281
+ queryKeys: [
282
+ RSC_QUERY
283
+ ]
284
+ }
285
+ });
286
+ }
287
+ if (page.rsc) {
288
+ addRoute(`${page.path}.rsc`, {
289
+ action: {
290
+ type: 'static',
291
+ response: addResponse(`${page.path}.rsc`, rscResponse(page.rsc))
292
+ },
293
+ match: {
294
+ has: [
295
+ header(h.rsc, '1'),
296
+ {
297
+ type: 'query',
298
+ key: RSC_QUERY,
299
+ value: await compute({})
300
+ }
301
+ ],
302
+ methods: STATIC_METHODS,
303
+ missing: [
304
+ header(h.stateTree),
305
+ header(h.prefetch),
306
+ header(h.segmentPrefetch),
307
+ header(h.nextUrl)
308
+ ],
309
+ path: url,
310
+ queryKeys: [
311
+ RSC_QUERY
312
+ ]
313
+ }
314
+ });
315
+ }
316
+ }
317
+ addRoute(`${page.path}.html`, {
318
+ action: {
319
+ type: 'static',
320
+ response: addResponse(`${page.path}.html`, {
321
+ contentType: HTML_CONTENT_TYPE,
322
+ file: page.html,
323
+ headers,
324
+ status: page.status
325
+ })
326
+ },
327
+ match: {
328
+ methods: STATIC_METHODS,
329
+ missing: [
330
+ header(h.rsc),
331
+ header(h.stateTree),
332
+ header(h.prefetch),
333
+ header(h.segmentPrefetch),
334
+ header(h.nextUrl)
335
+ ],
336
+ path: url,
337
+ queryKeys: []
338
+ }
339
+ });
340
+ addRoute(`${page.path}.other`, {
341
+ action: {
342
+ type: 'server',
343
+ server: NEXTJS_SERVER_ID
344
+ },
345
+ match: {
346
+ path: url
347
+ }
348
+ });
349
+ }
350
+ /**
351
+ * Time-based ISR keeps Next.js's own freshness: the server's `s-maxage` and
352
+ * `stale-while-revalidate` stay authoritative, and this policy is their upper bound.
353
+ */ function isrCache(model, route) {
354
+ const shared = Math.min(route.revalidateSeconds, MAX_AGE_SECONDS);
355
+ const stale = route.expireSeconds !== undefined ? Math.max(0, Math.min(route.expireSeconds - shared, MAX_AGE_SECONDS)) : 0;
356
+ const h = model.rscHeaders;
357
+ return {
358
+ browserMaxAgeSeconds: 0,
359
+ mode: 'ttl',
360
+ sharedMaxAgeSeconds: shared,
361
+ staleWhileRevalidateSeconds: stale,
362
+ varyHeaders: [
363
+ h.rsc,
364
+ h.stateTree,
365
+ h.prefetch,
366
+ h.segmentPrefetch,
367
+ h.nextUrl
368
+ ]
369
+ };
370
+ }
371
+ function varyHeader(model) {
372
+ const h = model.rscHeaders;
373
+ return [
374
+ h.rsc,
375
+ h.stateTree,
376
+ h.prefetch,
377
+ h.segmentPrefetch,
378
+ h.nextUrl
379
+ ].join(', ');
380
+ }
381
+ function relativeEntrypoint(model) {
382
+ return path.relative(model.server.standalonePath, model.server.serverEntryPath).split(path.sep).join('/');
383
+ }
384
+ /** The server file's directory in the ZIP, where Next.js looks for `public/`. */ function serverDir(model) {
385
+ const dir = path.posix.dirname(relativeEntrypoint(model));
386
+ return dir === '.' ? '' : dir;
387
+ }
388
+ /** The deepest directory containing every path. */ function commonRoot(paths, fallback) {
389
+ const dirs = paths.map((file)=>path.dirname(path.resolve(file)));
390
+ if (dirs.length === 0) {
391
+ return fallback;
392
+ }
393
+ let root = dirs[0];
394
+ for (const dir of dirs.slice(1)){
395
+ while(root !== path.dirname(root) && path.relative(root, dir).startsWith('..')){
396
+ root = path.dirname(root);
397
+ }
398
+ }
399
+ return root;
400
+ }
@@ -1,9 +1,16 @@
1
1
  import type { AssetCollection, DeployAdapter, LambdaBundle, PageCollection } from './types.js';
2
+ import type { DeploymentInput } from './v2/core/build.js';
2
3
  export declare class ViteAdapter implements DeployAdapter {
3
4
  fallback: string;
4
5
  name: "vite";
5
6
  collectAssets(projectPath: string, output?: string): Promise<AssetCollection>;
6
7
  collectPages(): Promise<PageCollection>;
8
+ /**
9
+ * An SPA: every file in the output directory, and index.html for unknown paths. Every file
10
+ * revalidates, like Vercel's Vite preset. Detection picks this adapter for any output with an
11
+ * index.html, so only a Vite project reports `vite`; any other build reports `static`.
12
+ */
13
+ createManifestV2Input(projectPath: string, output?: string): Promise<DeploymentInput>;
7
14
  prepareLambdaBundle(): Promise<LambdaBundle | null>;
8
15
  }
9
16
  export declare const viteAdapter: ViteAdapter;
@@ -1,7 +1,9 @@
1
+ import fs from 'fs/promises';
1
2
  import path from 'path';
2
3
  import { resolveOutputPath } from './deploy-output/resolveOutputPath.js';
3
4
  import { collectFilesRecursive } from './fs-utils.js';
4
5
  import { isPublishableAsset } from './secret-files.js';
6
+ import { createStaticSiteInput } from './v2/core/static-site.js';
5
7
  export class ViteAdapter {
6
8
  fallback = '/index.html';
7
9
  name = 'vite';
@@ -26,8 +28,53 @@ export class ViteAdapter {
26
28
  uploadKeys: []
27
29
  });
28
30
  }
31
+ /**
32
+ * An SPA: every file in the output directory, and index.html for unknown paths. Every file
33
+ * revalidates, like Vercel's Vite preset. Detection picks this adapter for any output with an
34
+ * index.html, so only a Vite project reports `vite`; any other build reports `static`.
35
+ */ async createManifestV2Input(projectPath, output) {
36
+ const framework = await isViteProject(projectPath) ? 'vite' : 'static';
37
+ return createStaticSiteInput({
38
+ fallback: 'spa',
39
+ outputDir: resolveOutputPath(projectPath, 'vite', output),
40
+ source: {
41
+ framework,
42
+ languages: [
43
+ 'javascript'
44
+ ]
45
+ }
46
+ });
47
+ }
29
48
  prepareLambdaBundle() {
30
49
  return Promise.resolve(null);
31
50
  }
32
51
  }
33
52
  export const viteAdapter = new ViteAdapter();
53
+ const VITE_CONFIG_FILES = [
54
+ 'js',
55
+ 'mjs',
56
+ 'cjs',
57
+ 'ts',
58
+ 'mts',
59
+ 'cts'
60
+ ].map((ext)=>`vite.config.${ext}`);
61
+ /** A Vite config, or a `vite` dependency in package.json. */ async function isViteProject(projectPath) {
62
+ const configs = await Promise.all(VITE_CONFIG_FILES.map((file)=>exists(path.join(projectPath, file))));
63
+ if (configs.some(Boolean)) {
64
+ return true;
65
+ }
66
+ try {
67
+ const packageJson = JSON.parse(await fs.readFile(path.join(projectPath, 'package.json'), 'utf8'));
68
+ return Boolean(packageJson.dependencies?.vite ?? packageJson.devDependencies?.vite);
69
+ } catch {
70
+ return false;
71
+ }
72
+ }
73
+ async function exists(filePath) {
74
+ try {
75
+ await fs.stat(filePath);
76
+ return true;
77
+ } catch {
78
+ return false;
79
+ }
80
+ }
@@ -0,0 +1,20 @@
1
+ /** A file copied into the ZIP. It keeps its mode on disk. */
2
+ interface ZipFileEntry {
3
+ name: string;
4
+ sourcePath: string;
5
+ }
6
+ /** Generated contents written into the ZIP with an explicit mode. */
7
+ interface ZipContentsEntry {
8
+ contents: Buffer;
9
+ mode: number;
10
+ name: string;
11
+ }
12
+ export type ZipEntry = ZipContentsEntry | ZipFileEntry;
13
+ interface WriteZipArgs {
14
+ /** Written in order. A name must not repeat; callers remove replaced files first. */
15
+ entries: ZipEntry[];
16
+ zipPath: string;
17
+ }
18
+ /** Writes a deflate-compressed ZIP (level 9). Shared by v1 Lambda bundles and v2 server ZIPs. */
19
+ export declare function writeZip({ entries, zipPath }: WriteZipArgs): Promise<void>;
20
+ export {};
@@ -0,0 +1,28 @@
1
+ import archiver from 'archiver';
2
+ import { createWriteStream } from 'fs';
3
+ /** Writes a deflate-compressed ZIP (level 9). Shared by v1 Lambda bundles and v2 server ZIPs. */ export function writeZip({ entries, zipPath }) {
4
+ return new Promise((resolve, reject)=>{
5
+ const output = createWriteStream(zipPath);
6
+ const archive = archiver('zip', {
7
+ zlib: {
8
+ level: 9
9
+ }
10
+ });
11
+ output.on('close', ()=>resolve());
12
+ archive.on('error', (error)=>reject(error));
13
+ archive.pipe(output);
14
+ for (const entry of entries){
15
+ if ('sourcePath' in entry) {
16
+ archive.file(entry.sourcePath, {
17
+ name: entry.name
18
+ });
19
+ } else {
20
+ archive.append(entry.contents, {
21
+ name: entry.name,
22
+ mode: entry.mode
23
+ });
24
+ }
25
+ }
26
+ void archive.finalize();
27
+ });
28
+ }
@@ -3,6 +3,7 @@
3
3
  *
4
4
  * TODO: Replace with real API calls when Control Plane is available
5
5
  */
6
+ import type { DeploymentManifestV2, PresignedPost } from '../adapters/v2/core/index.js';
6
7
  import type { AuthCredential } from '../auth/credentials.js';
7
8
  import type { Tenant } from '../types/config.js';
8
9
  /**
@@ -17,13 +18,14 @@ export interface CreateTenantOptions {
17
18
  parentType?: 'org' | 'team' | 'workspace';
18
19
  }
19
20
  /**
20
- * Options for creating a new deployment
21
+ * Options for creating a manifest v1 deployment
21
22
  */
22
23
  export interface CreateDeploymentOptions {
23
24
  /** Framework adapter name (e.g., "vite", "nextjs"). Forwarded to Gatekeeper. */
24
25
  adapter?: string;
25
26
  /** SPA fallback path (e.g., "/index.html"). Vite-only. */
26
27
  fallback?: string;
28
+ manifestVersion: 1;
27
29
  /** Pages keyed by route, each with its associated asset keys */
28
30
  pages: Record<string, {
29
31
  assets: string[];
@@ -47,6 +49,8 @@ export interface CreateDeploymentResponse {
47
49
  export interface CreateDeploymentApiResponse {
48
50
  error: boolean;
49
51
  meta: {
52
+ /** Manifest v2 only: the presigned POST for each artifact */
53
+ artifact_uploads?: Record<string, PresignedPost>;
50
54
  deployment_id: string;
51
55
  lambda_zip_upload_url: string;
52
56
  page_upload_urls: Record<string, string>;
@@ -54,6 +58,19 @@ export interface CreateDeploymentApiResponse {
54
58
  };
55
59
  status: number;
56
60
  }
61
+ /** Options for creating a manifest v2 deployment */
62
+ export interface CreateManifestV2DeploymentOptions {
63
+ /** The manifest v2 submission; the control plane validates it */
64
+ manifest: DeploymentManifestV2;
65
+ manifestVersion: 2;
66
+ }
67
+ /** Response from creating a manifest v2 deployment */
68
+ export interface CreateManifestV2DeploymentResponse {
69
+ /** The presigned POST for each declared artifact, by artifact ID */
70
+ artifactUploads: Record<string, PresignedPost>;
71
+ /** Unique deployment ID */
72
+ deploymentId: string;
73
+ }
57
74
  /**
58
75
  * Options for performing a deployment
59
76
  */
@@ -109,14 +126,19 @@ export declare function createTenant(credential: AuthCredential, options: Create
109
126
  */
110
127
  export declare function getTenantDetails(credential: AuthCredential, tenantId: string): Promise<Tenant>;
111
128
  /**
112
- * Create a new deployment and get signed upload URLs
113
- * Maps to: POST /v1/tenant/{tenant_id}/deploy/create
129
+ * Create a new deployment and get its upload targets
130
+ * Maps to: POST /v1/cms/tenant/{tenant_id}/deploy/create
114
131
  *
115
- * @param accessToken - OAuth access token
132
+ * `manifestVersion` picks the submission. v1 sends pages and static assets and returns signed PUT
133
+ * URLs. v2 sends the manifest, which the control plane validates, and returns a presigned POST per
134
+ * artifact, pinned to its declared SHA-256 and size. deploy/perform activates either.
135
+ *
136
+ * @param credential - Auth credential
116
137
  * @param tenantId - Tenant ID
117
- * @param options - Deployment creation options
118
- * @returns Deployment ID and upload URLs
138
+ * @param options - The submission for the chosen manifest version
139
+ * @returns Deployment ID and upload targets
119
140
  */
141
+ export declare function createDeployment(credential: AuthCredential, tenantId: string, options: CreateManifestV2DeploymentOptions): Promise<CreateManifestV2DeploymentResponse>;
120
142
  export declare function createDeployment(credential: AuthCredential, tenantId: string, options: CreateDeploymentOptions): Promise<CreateDeploymentResponse>;
121
143
  /**
122
144
  * Perform deployment for a created deployment ID