@payloadcms/figma 0.1.0-internal.e071575 → 1.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (350) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/{utils → adapters}/asset-collection.d.ts +17 -3
  3. package/dist/adapters/asset-collection.js +242 -0
  4. package/dist/{utils → adapters}/build-lambda-zip.d.ts +8 -7
  5. package/dist/adapters/build-lambda-zip.js +111 -0
  6. package/dist/adapters/configureNextjsCache.d.ts +8 -0
  7. package/dist/adapters/configureNextjsCache.js +55 -0
  8. package/dist/adapters/deploy-output/inspectNextjsOutput/getNextRelativeAppDir.d.ts +1 -0
  9. package/dist/adapters/deploy-output/inspectNextjsOutput/getNextRelativeAppDir.js +15 -0
  10. package/dist/adapters/deploy-output/inspectNextjsOutput.d.ts +12 -0
  11. package/dist/adapters/deploy-output/inspectNextjsOutput.js +28 -0
  12. package/dist/adapters/deploy-output/inspectNitroOutput.d.ts +9 -0
  13. package/dist/adapters/deploy-output/inspectNitroOutput.js +13 -0
  14. package/dist/adapters/deploy-output/isFile.d.ts +1 -0
  15. package/dist/adapters/deploy-output/isFile.js +4 -0
  16. package/dist/adapters/deploy-output/readJson.d.ts +1 -0
  17. package/dist/adapters/deploy-output/readJson.js +9 -0
  18. package/dist/adapters/deploy-output/resolveNitroOutputLayout.d.ts +8 -0
  19. package/dist/adapters/deploy-output/resolveNitroOutputLayout.js +16 -0
  20. package/dist/adapters/deploy-output/resolveOutputPath.d.ts +2 -0
  21. package/dist/adapters/deploy-output/resolveOutputPath.js +9 -0
  22. package/dist/adapters/deploy-output/resolveWithin.d.ts +1 -0
  23. package/dist/adapters/deploy-output/resolveWithin.js +12 -0
  24. package/dist/adapters/fs-utils.d.ts +39 -0
  25. package/dist/adapters/fs-utils.js +135 -0
  26. package/dist/adapters/index.d.ts +4 -0
  27. package/dist/adapters/index.js +3 -0
  28. package/dist/adapters/lambda-runtime/nextjs-cache.d.ts +40 -0
  29. package/dist/adapters/lambda-runtime/nextjs-cache.js +174 -0
  30. package/dist/adapters/nextjs.d.ts +12 -0
  31. package/dist/adapters/nextjs.js +67 -0
  32. package/dist/adapters/nitro.d.ts +8 -0
  33. package/dist/adapters/nitro.js +193 -0
  34. package/dist/adapters/secret-files.d.ts +25 -0
  35. package/dist/adapters/secret-files.js +50 -0
  36. package/dist/adapters/types.d.ts +42 -0
  37. package/dist/adapters/types.js +1 -0
  38. package/dist/{utils/adapters → adapters}/vite.d.ts +2 -2
  39. package/dist/adapters/vite.js +33 -0
  40. package/dist/api/check-project-subdomain-availability.d.ts +12 -0
  41. package/dist/api/check-project-subdomain-availability.js +32 -0
  42. package/dist/api/control-plane-error.d.ts +6 -0
  43. package/dist/api/control-plane-error.js +8 -0
  44. package/dist/api/control-plane-fetch.d.ts +7 -0
  45. package/dist/api/control-plane-fetch.js +37 -0
  46. package/dist/api/control-plane.d.ts +12 -9
  47. package/dist/api/control-plane.js +28 -48
  48. package/dist/api/create-project.d.ts +18 -0
  49. package/dist/api/create-project.js +37 -0
  50. package/dist/api/list-project-workspaces.d.ts +8 -0
  51. package/dist/api/list-project-workspaces.js +28 -0
  52. package/dist/api/project-resource-type.d.ts +1 -0
  53. package/dist/api/project-resource-type.js +1 -0
  54. package/dist/auth/headless-oauth-flow.d.ts +23 -0
  55. package/dist/auth/headless-oauth-flow.js +73 -0
  56. package/dist/auth/oauth-flow.d.ts +2 -0
  57. package/dist/auth/oauth-flow.js +30 -8
  58. package/dist/auth/refresh.js +12 -12
  59. package/dist/auth/requested-scopes.d.ts +1 -0
  60. package/dist/auth/requested-scopes.js +3 -0
  61. package/dist/auth/token-store.d.ts +20 -1
  62. package/dist/auth/token-store.js +47 -0
  63. package/dist/auth/types.d.ts +17 -3
  64. package/dist/cli.d.ts +39 -0
  65. package/dist/cli.js +71 -36
  66. package/dist/commands/bootstrap.js +5 -1
  67. package/dist/commands/build-lambda-zip.js +1 -1
  68. package/dist/commands/deploy.d.ts +12 -0
  69. package/dist/commands/deploy.js +63 -25
  70. package/dist/commands/detect-project-resource-type.d.ts +3 -0
  71. package/dist/commands/detect-project-resource-type.js +28 -0
  72. package/dist/commands/init.d.ts +2 -2
  73. package/dist/commands/init.js +235 -80
  74. package/dist/commands/login.d.ts +11 -1
  75. package/dist/commands/login.js +66 -4
  76. package/dist/commands/prompt-to-create-project/format-project-subdomain.d.ts +1 -0
  77. package/dist/commands/prompt-to-create-project/format-project-subdomain.js +3 -0
  78. package/dist/commands/prompt-to-create-project/format-unavailable-subdomain-reason.d.ts +1 -0
  79. package/dist/commands/prompt-to-create-project/format-unavailable-subdomain-reason.js +7 -0
  80. package/dist/commands/prompt-to-create-project/get-default-project-name.d.ts +1 -0
  81. package/dist/commands/prompt-to-create-project/get-default-project-name.js +13 -0
  82. package/dist/commands/prompt-to-create-project/prompt-for-available-subdomain.d.ts +7 -0
  83. package/dist/commands/prompt-to-create-project/prompt-for-available-subdomain.js +32 -0
  84. package/dist/commands/prompt-to-create-project/resolve-project-region.d.ts +8 -0
  85. package/dist/commands/prompt-to-create-project/resolve-project-region.js +27 -0
  86. package/dist/commands/prompt-to-create-project/resolve-project-subdomain.d.ts +9 -0
  87. package/dist/commands/prompt-to-create-project/resolve-project-subdomain.js +54 -0
  88. package/dist/commands/prompt-to-create-project/resolve-text-input.d.ts +9 -0
  89. package/dist/commands/prompt-to-create-project/resolve-text-input.js +23 -0
  90. package/dist/commands/prompt-to-create-project/resolve-workspace-plan-key.d.ts +12 -0
  91. package/dist/commands/prompt-to-create-project/resolve-workspace-plan-key.js +36 -0
  92. package/dist/commands/prompt-to-create-project/validate-subdomain.d.ts +1 -0
  93. package/dist/commands/prompt-to-create-project/validate-subdomain.js +9 -0
  94. package/dist/commands/prompt-to-create-project.d.ts +24 -0
  95. package/dist/commands/prompt-to-create-project.js +69 -0
  96. package/dist/commands/setup-agent.d.ts +12 -0
  97. package/dist/commands/setup-agent.js +123 -0
  98. package/dist/commands/upgrade.js +65 -1
  99. package/dist/commands/upload-schema.js +3 -4
  100. package/dist/commands/write-project-configuration.d.ts +12 -0
  101. package/dist/commands/write-project-configuration.js +16 -0
  102. package/dist/config/oauth.js +6 -1
  103. package/dist/constants.d.ts +0 -2
  104. package/dist/constants.js +0 -3
  105. package/dist/db-content-api/generated/content-api-types.d.ts +6 -2
  106. package/dist/db-content-api/index.d.ts +1 -1
  107. package/dist/db-content-api/index.js +121 -72
  108. package/dist/db-content-api/utilities/data/index.js +8 -2
  109. package/dist/db-content-api/utilities/data/injectGlobalType.d.ts +6 -0
  110. package/dist/db-content-api/utilities/data/injectGlobalType.js +11 -0
  111. package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +3 -11
  112. package/dist/db-content-api/utilities/data/removeVirtualFields.js +12 -50
  113. package/dist/db-content-api/utilities/isRecord.d.ts +9 -0
  114. package/dist/db-content-api/utilities/isRecord.js +19 -0
  115. package/dist/db-content-api/utilities/joins.js +5 -1
  116. package/dist/db-content-api/utilities/meta/resolvesToRelationshipValue.d.ts +10 -0
  117. package/dist/db-content-api/utilities/meta/resolvesToRelationshipValue.js +95 -0
  118. package/dist/db-content-api/utilities/meta/stringifyIdsInWhere.d.ts +9 -0
  119. package/dist/db-content-api/utilities/meta/stringifyIdsInWhere.js +112 -0
  120. package/dist/db-content-api/utilities/schema/buildDocumentSchema.js +9 -4
  121. package/dist/db-content-api/utilities/schema/getDocumentSchema.d.ts +3 -0
  122. package/dist/db-content-api/utilities/schema/getDocumentSchema.js +24 -0
  123. package/dist/db-content-api/utilities/where.d.ts +2 -6
  124. package/dist/db-content-api/utilities/where.js +20 -9
  125. package/dist/exports/client.d.ts +2 -0
  126. package/dist/exports/client.js +2 -0
  127. package/dist/exports/views.d.ts +1 -0
  128. package/dist/exports/views.js +1 -0
  129. package/dist/imageSizeOptions.d.ts +23 -0
  130. package/dist/imageSizeOptions.js +26 -0
  131. package/dist/index.d.ts +2 -0
  132. package/dist/index.js +2 -0
  133. package/dist/lib/write-agent-config.d.ts +12 -0
  134. package/dist/lib/write-agent-config.js +52 -0
  135. package/dist/next/image-loader.d.ts +6 -0
  136. package/dist/next/image-loader.js +14 -0
  137. package/dist/oauth/components/LoginButton/index.js +66 -19
  138. package/dist/oauth/components/LoginButton/index.scss +121 -15
  139. package/dist/oauth/defaults.js +4 -1
  140. package/dist/oauth/endpoints/getLoginEndpoint.js +5 -2
  141. package/dist/oauth/index.js +8 -7
  142. package/dist/oauth/utilities/getAdminCollectionSlug.d.ts +1 -1
  143. package/dist/oauth/utilities/getAuthorizeURL.d.ts +1 -0
  144. package/dist/oauth/utilities/getAuthorizeURL.js +5 -1
  145. package/dist/plugin/build-config.d.ts +13 -3
  146. package/dist/plugin/build-config.js +250 -49
  147. package/dist/plugin/cache-revalidation-hooks.d.ts +6 -0
  148. package/dist/plugin/cache-revalidation-hooks.js +69 -0
  149. package/dist/plugin/cloud-limits/CloudLimitModal/index.d.ts +9 -0
  150. package/dist/plugin/cloud-limits/CloudLimitModal/index.js +66 -0
  151. package/dist/plugin/cloud-limits/CloudLimitModal/index.scss +56 -0
  152. package/dist/plugin/cloud-limits/CloudLimitProvider/index.d.ts +4 -0
  153. package/dist/plugin/cloud-limits/CloudLimitProvider/index.js +110 -0
  154. package/dist/plugin/cloud-limits/LimitReachedView/index.css +14 -0
  155. package/dist/plugin/cloud-limits/LimitReachedView/index.d.ts +4 -0
  156. package/dist/plugin/cloud-limits/LimitReachedView/index.js +52 -0
  157. package/dist/plugin/cloud-limits/SlugRegistryContext/index.d.ts +7 -0
  158. package/dist/plugin/cloud-limits/SlugRegistryContext/index.js +3 -0
  159. package/dist/plugin/cloud-limits/SlugTracker/index.d.ts +1 -0
  160. package/dist/plugin/cloud-limits/SlugTracker/index.js +27 -0
  161. package/dist/plugin/cloud-limits/icons/ExternalLinkIcon.d.ts +3 -0
  162. package/dist/plugin/cloud-limits/icons/ExternalLinkIcon.js +30 -0
  163. package/dist/plugin/cloud-limits/routes.d.ts +2 -0
  164. package/dist/plugin/cloud-limits/routes.js +4 -0
  165. package/dist/plugin/cloud-limits/server/redirectInitialAutosaveCreate.d.ts +9 -0
  166. package/dist/plugin/cloud-limits/server/redirectInitialAutosaveCreate.js +28 -0
  167. package/dist/plugin/cloud-limits/shared.d.ts +10 -0
  168. package/dist/plugin/cloud-limits/shared.js +52 -0
  169. package/dist/plugin/cloud-limits/utilities/cloudLimitInterceptor.d.ts +2 -0
  170. package/dist/plugin/cloud-limits/utilities/cloudLimitInterceptor.js +134 -0
  171. package/dist/plugin/cloud-limits/utilities/toasts.d.ts +4 -0
  172. package/dist/plugin/cloud-limits/utilities/toasts.js +19 -0
  173. package/dist/plugin/make-permission-access/make-permission-access.d.ts +8 -0
  174. package/dist/plugin/make-permission-access/make-permission-access.js +24 -0
  175. package/dist/plugin/sandbox-upload-fetch.d.ts +22 -20
  176. package/dist/plugin/sandbox-upload-fetch.js +15 -21
  177. package/dist/skills/deploy-to-figma/SKILL.md +234 -0
  178. package/dist/skills/deploy-to-figma/references/cli-reference.md +146 -0
  179. package/dist/storage-content-api/api-types.d.ts +5 -2
  180. package/dist/storage-content-api/buildBaseMediaResponseHeaders.d.ts +1 -0
  181. package/dist/storage-content-api/buildBaseMediaResponseHeaders.js +8 -0
  182. package/dist/storage-content-api/buildClientUploadFetchBackHeaders.d.ts +12 -0
  183. package/dist/storage-content-api/buildClientUploadFetchBackHeaders.js +26 -0
  184. package/dist/storage-content-api/buildMediaRequestHeaders.d.ts +1 -0
  185. package/dist/storage-content-api/buildMediaRequestHeaders.js +14 -0
  186. package/dist/storage-content-api/buildMediaResponseHeaders.d.ts +4 -0
  187. package/dist/storage-content-api/buildMediaResponseHeaders.js +52 -0
  188. package/dist/storage-content-api/client-uploads/generate.d.ts +7 -3
  189. package/dist/storage-content-api/client-uploads/generate.js +22 -21
  190. package/dist/storage-content-api/copyFile.d.ts +16 -0
  191. package/dist/storage-content-api/copyFile.js +90 -0
  192. package/dist/storage-content-api/deleteFile.d.ts +8 -0
  193. package/dist/storage-content-api/deleteFile.js +18 -0
  194. package/dist/storage-content-api/getDownloadResponseHeaderPolicy.d.ts +11 -0
  195. package/dist/storage-content-api/getDownloadResponseHeaderPolicy.js +33 -0
  196. package/dist/storage-content-api/getMediaType.d.ts +1 -0
  197. package/dist/storage-content-api/getMediaType.js +3 -0
  198. package/dist/storage-content-api/handleUpload.d.ts +1 -2
  199. package/dist/storage-content-api/handleUpload.js +13 -157
  200. package/dist/storage-content-api/hasSupportedContentEncoding.d.ts +1 -0
  201. package/dist/storage-content-api/hasSupportedContentEncoding.js +6 -0
  202. package/dist/storage-content-api/index.js +17 -8
  203. package/dist/storage-content-api/mediaErrorResponse.d.ts +1 -0
  204. package/dist/storage-content-api/mediaErrorResponse.js +12 -0
  205. package/dist/storage-content-api/resolveDownloadResponseHeaders.d.ts +5 -0
  206. package/dist/storage-content-api/resolveDownloadResponseHeaders.js +13 -0
  207. package/dist/storage-content-api/shouldAttachMedia.d.ts +1 -0
  208. package/dist/storage-content-api/shouldAttachMedia.js +34 -0
  209. package/dist/storage-content-api/staticHandler.d.ts +2 -1
  210. package/dist/storage-content-api/staticHandler.js +87 -32
  211. package/dist/storage-content-api/types.d.ts +4 -1
  212. package/dist/storage-content-api/uploadFileData.d.ts +10 -0
  213. package/dist/storage-content-api/uploadFileData.js +145 -0
  214. package/dist/translations/ar.d.ts +12 -0
  215. package/dist/translations/ar.js +12 -0
  216. package/dist/translations/az.d.ts +12 -0
  217. package/dist/translations/az.js +12 -0
  218. package/dist/translations/bg.d.ts +12 -0
  219. package/dist/translations/bg.js +12 -0
  220. package/dist/translations/bnBd.d.ts +12 -0
  221. package/dist/translations/bnBd.js +12 -0
  222. package/dist/translations/bnIn.d.ts +12 -0
  223. package/dist/translations/bnIn.js +12 -0
  224. package/dist/translations/ca.d.ts +12 -0
  225. package/dist/translations/ca.js +12 -0
  226. package/dist/translations/cs.d.ts +12 -0
  227. package/dist/translations/cs.js +12 -0
  228. package/dist/translations/da.d.ts +12 -0
  229. package/dist/translations/da.js +12 -0
  230. package/dist/translations/de.d.ts +12 -0
  231. package/dist/translations/de.js +12 -0
  232. package/dist/translations/en.d.ts +12 -0
  233. package/dist/translations/en.js +12 -0
  234. package/dist/translations/es.d.ts +12 -0
  235. package/dist/translations/es.js +12 -0
  236. package/dist/translations/et.d.ts +12 -0
  237. package/dist/translations/et.js +12 -0
  238. package/dist/translations/fa.d.ts +12 -0
  239. package/dist/translations/fa.js +12 -0
  240. package/dist/translations/fr.d.ts +12 -0
  241. package/dist/translations/fr.js +12 -0
  242. package/dist/translations/he.d.ts +12 -0
  243. package/dist/translations/he.js +12 -0
  244. package/dist/translations/hr.d.ts +12 -0
  245. package/dist/translations/hr.js +12 -0
  246. package/dist/translations/hu.d.ts +12 -0
  247. package/dist/translations/hu.js +12 -0
  248. package/dist/translations/hy.d.ts +12 -0
  249. package/dist/translations/hy.js +12 -0
  250. package/dist/translations/id.d.ts +12 -0
  251. package/dist/translations/id.js +12 -0
  252. package/dist/translations/index.d.ts +533 -0
  253. package/dist/translations/index.js +90 -0
  254. package/dist/translations/is.d.ts +12 -0
  255. package/dist/translations/is.js +12 -0
  256. package/dist/translations/it.d.ts +12 -0
  257. package/dist/translations/it.js +12 -0
  258. package/dist/translations/ja.d.ts +12 -0
  259. package/dist/translations/ja.js +12 -0
  260. package/dist/translations/ko.d.ts +12 -0
  261. package/dist/translations/ko.js +12 -0
  262. package/dist/translations/lt.d.ts +12 -0
  263. package/dist/translations/lt.js +12 -0
  264. package/dist/translations/lv.d.ts +12 -0
  265. package/dist/translations/lv.js +12 -0
  266. package/dist/translations/my.d.ts +12 -0
  267. package/dist/translations/my.js +12 -0
  268. package/dist/translations/nb.d.ts +12 -0
  269. package/dist/translations/nb.js +12 -0
  270. package/dist/translations/nl.d.ts +12 -0
  271. package/dist/translations/nl.js +12 -0
  272. package/dist/translations/pl.d.ts +12 -0
  273. package/dist/translations/pl.js +12 -0
  274. package/dist/translations/pt.d.ts +12 -0
  275. package/dist/translations/pt.js +12 -0
  276. package/dist/translations/ro.d.ts +12 -0
  277. package/dist/translations/ro.js +12 -0
  278. package/dist/translations/rs.d.ts +12 -0
  279. package/dist/translations/rs.js +12 -0
  280. package/dist/translations/rsLatin.d.ts +12 -0
  281. package/dist/translations/rsLatin.js +12 -0
  282. package/dist/translations/ru.d.ts +12 -0
  283. package/dist/translations/ru.js +12 -0
  284. package/dist/translations/sk.d.ts +12 -0
  285. package/dist/translations/sk.js +12 -0
  286. package/dist/translations/sl.d.ts +12 -0
  287. package/dist/translations/sl.js +12 -0
  288. package/dist/translations/sv.d.ts +12 -0
  289. package/dist/translations/sv.js +12 -0
  290. package/dist/translations/ta.d.ts +12 -0
  291. package/dist/translations/ta.js +12 -0
  292. package/dist/translations/th.d.ts +12 -0
  293. package/dist/translations/th.js +12 -0
  294. package/dist/translations/tr.d.ts +12 -0
  295. package/dist/translations/tr.js +12 -0
  296. package/dist/translations/uk.d.ts +12 -0
  297. package/dist/translations/uk.js +12 -0
  298. package/dist/translations/vi.d.ts +12 -0
  299. package/dist/translations/vi.js +12 -0
  300. package/dist/translations/zh.d.ts +12 -0
  301. package/dist/translations/zh.js +12 -0
  302. package/dist/translations/zhTw.d.ts +12 -0
  303. package/dist/translations/zhTw.js +12 -0
  304. package/dist/types.d.ts +11 -0
  305. package/dist/utils/assert-never.d.ts +1 -0
  306. package/dist/utils/assert-never.js +3 -0
  307. package/dist/utils/build-detection.d.ts +6 -1
  308. package/dist/utils/build-detection.js +68 -89
  309. package/dist/utils/cache-bootstrap.js +1 -0
  310. package/dist/utils/deploy-adapter.d.ts +3 -35
  311. package/dist/utils/deploy-adapter.js +25 -14
  312. package/dist/utils/env-management.d.ts +15 -0
  313. package/dist/utils/env-management.js +47 -0
  314. package/dist/utils/lambda-config.js +18 -23
  315. package/dist/utils/load-payload-config.js +1 -6
  316. package/dist/utils/messages.js +24 -3
  317. package/dist/utils/next-image-loader-config.d.ts +2 -0
  318. package/dist/utils/next-image-loader-config.js +63 -0
  319. package/dist/utils/next-image-loader-file.d.ts +2 -0
  320. package/dist/utils/next-image-loader-file.js +11 -0
  321. package/dist/utils/payload-config-ast.d.ts +5 -0
  322. package/dist/utils/payload-config-ast.js +73 -4
  323. package/dist/utils/payload-config-modifier.js +3 -0
  324. package/dist/utils/payload-generate.d.ts +10 -0
  325. package/dist/utils/payload-generate.js +59 -0
  326. package/dist/utils/payload-secret.d.ts +28 -0
  327. package/dist/utils/payload-secret.js +34 -0
  328. package/dist/utils/pnpm-builds.d.ts +14 -0
  329. package/dist/utils/pnpm-builds.js +125 -0
  330. package/dist/utils/s3-upload.js +4 -1
  331. package/package.json +32 -7
  332. package/dist/lib/download-skill.d.ts +0 -12
  333. package/dist/lib/download-skill.js +0 -77
  334. package/dist/storage-content-api/handleDelete.d.ts +0 -7
  335. package/dist/storage-content-api/handleDelete.js +0 -15
  336. package/dist/storage-content-api/utilities/getSafeFilename.d.ts +0 -11
  337. package/dist/storage-content-api/utilities/getSafeFilename.js +0 -59
  338. package/dist/storage-content-api/utilities/index.d.ts +0 -2
  339. package/dist/storage-content-api/utilities/index.js +0 -2
  340. package/dist/storage-content-api/utilities/parseUploadReference.d.ts +0 -17
  341. package/dist/storage-content-api/utilities/parseUploadReference.js +0 -27
  342. package/dist/utils/adapters/nextjs.d.ts +0 -8
  343. package/dist/utils/adapters/nextjs.js +0 -61
  344. package/dist/utils/adapters/nitro.d.ts +0 -8
  345. package/dist/utils/adapters/nitro.js +0 -172
  346. package/dist/utils/adapters/vite.js +0 -31
  347. package/dist/utils/asset-collection.js +0 -144
  348. package/dist/utils/build-lambda-zip.js +0 -90
  349. package/dist/utils/fs-utils.d.ts +0 -12
  350. package/dist/utils/fs-utils.js +0 -55
package/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2025 Figma
1
+ Copyright (c) 2026 Figma
2
2
 
3
3
  This source code is protected under international copyright law. All rights
4
4
  reserved and protected by the copyright holders.
@@ -1,3 +1,4 @@
1
+ import type { AdapterLogger } from './types.js';
1
2
  /**
2
3
  * Get file size in bytes
3
4
  *
@@ -14,7 +15,7 @@ export declare function getFileSize(filePath: string): Promise<number>;
14
15
  * @param projectPath - Path to project root
15
16
  * @returns Array of static asset paths (using _next prefix)
16
17
  */
17
- export declare function collectStaticAssets(projectPath: string): Promise<string[]>;
18
+ export declare function collectStaticAssets(projectPath: string, output?: string, logger?: AdapterLogger): Promise<string[]>;
18
19
  /**
19
20
  * Result from collecting SSG assets
20
21
  */
@@ -23,14 +24,18 @@ export type SSGAssets = {
23
24
  keys: string[];
24
25
  /** Map of S3 key → relative filesystem path from project root */
25
26
  pathMap: Record<string, string>;
27
+ /** Map of page route → S3 keys generated for that page */
28
+ routeAssetMap: Record<string, string[]>;
26
29
  };
30
+ type StaticMetadataAssets = Omit<SSGAssets, 'routeAssetMap'>;
27
31
  /**
28
32
  * Collect SSG asset paths by parsing .next/prerender-manifest.json
29
33
  *
30
- * For each route in the manifest's `routes` object, collects three files:
34
+ * For each static page route without revalidation in the manifest's `routes` object, collects:
31
35
  * - {route}.html (full HTML)
32
36
  * - {route}.rsc (React Server Components payload)
33
37
  * - {route}.meta (response headers JSON)
38
+ * - Nested `.segment.rsc` files under {route}.segments (segment-prefetch payloads)
34
39
  *
35
40
  * S3 keys use the route path without leading slash.
36
41
  * Filesystem paths point to .next/server/app/{route}.{ext}
@@ -38,7 +43,15 @@ export type SSGAssets = {
38
43
  * @param projectPath - Path to project root
39
44
  * @returns SSG asset keys and a pathMap for filesystem resolution
40
45
  */
41
- export declare function collectSSGAssets(projectPath: string): Promise<SSGAssets>;
46
+ export declare function collectSSGAssets(projectPath: string, output?: string, logger?: AdapterLogger): Promise<SSGAssets>;
47
+ /**
48
+ * Collect file-based Next.js metadata icons that were prerendered as static route handlers.
49
+ *
50
+ * Maps public asset keys such as `shop/icon1.png` to their raw
51
+ * `.next/server/app/shop/icon1.png.body` output.
52
+ * Documentation: https://nextjs.org/docs/app/api-reference/file-conventions/metadata/app-icons
53
+ */
54
+ export declare function collectStaticMetadataAssets(projectPath: string, output?: string): Promise<StaticMetadataAssets>;
42
55
  /**
43
56
  * Create Lambda deployment zip
44
57
  *
@@ -48,3 +61,4 @@ export declare function collectSSGAssets(projectPath: string): Promise<SSGAssets
48
61
  * @throws Error if build missing or zip creation fails
49
62
  */
50
63
  export declare function createLambdaZip(projectPath: string): Promise<void>;
64
+ export {};
@@ -0,0 +1,242 @@
1
+ import fs from 'fs/promises';
2
+ import path from 'path';
3
+ import { buildLambdaZip } from './build-lambda-zip.js';
4
+ import { resolveOutputPath } from './deploy-output/resolveOutputPath.js';
5
+ // Maximum file size for static assets (S3 limitation)
6
+ const MAX_ASSET_SIZE = 50 * 1024 * 1024 // 50MB
7
+ ;
8
+ /**
9
+ * Get file size in bytes
10
+ *
11
+ * @param filePath - Absolute path to file
12
+ * @returns File size in bytes
13
+ */ export async function getFileSize(filePath) {
14
+ const stats = await fs.stat(filePath);
15
+ return stats.size;
16
+ }
17
+ /**
18
+ * Recursively collect files from a directory
19
+ *
20
+ * Excludes files larger than 50MB (S3 limitation).
21
+ * Warns user when files are excluded due to size.
22
+ *
23
+ * @param dir - Directory to scan
24
+ * @param baseDir - Base directory for relative paths
25
+ * @returns Array of relative file paths
26
+ */ async function collectFiles(dir, baseDir, logger) {
27
+ const files = [];
28
+ try {
29
+ const entries = await fs.readdir(dir, {
30
+ withFileTypes: true
31
+ });
32
+ for (const entry of entries){
33
+ const fullPath = path.join(dir, entry.name);
34
+ if (entry.isDirectory()) {
35
+ // Recursively collect from subdirectories
36
+ const subFiles = await collectFiles(fullPath, baseDir, logger);
37
+ files.push(...subFiles);
38
+ } else if (entry.isFile()) {
39
+ // Check file size before adding
40
+ const stats = await fs.stat(fullPath);
41
+ if (stats.size <= MAX_ASSET_SIZE) {
42
+ // Add relative path from base directory
43
+ const relativePath = path.relative(baseDir, fullPath);
44
+ files.push(relativePath);
45
+ } else {
46
+ // Warn user about skipped files
47
+ const sizeMB = (stats.size / (1024 * 1024)).toFixed(2);
48
+ const relativePath = path.relative(baseDir, fullPath);
49
+ logger?.warning(`Skipping large asset: ${relativePath} (${sizeMB}MB exceeds 50MB limit)`);
50
+ }
51
+ }
52
+ }
53
+ } catch {
54
+ // Directory doesn't exist or not accessible
55
+ return [];
56
+ }
57
+ return files;
58
+ }
59
+ /**
60
+ * Collect all static asset paths from .next/static
61
+ *
62
+ * Returns paths relative to project root, formatted for S3:
63
+ * - `.next/static/chunks/main.js` → `_next/static/chunks/main.js`
64
+ *
65
+ * @param projectPath - Path to project root
66
+ * @returns Array of static asset paths (using _next prefix)
67
+ */ export async function collectStaticAssets(projectPath, output, logger) {
68
+ const outputPath = resolveOutputPath(projectPath, 'nextjs', output);
69
+ const staticDir = path.join(outputPath, 'static');
70
+ const files = await collectFiles(staticDir, projectPath, logger);
71
+ return files.map((file)=>{
72
+ const relativeToStatic = path.relative(staticDir, path.resolve(projectPath, file));
73
+ return `_next/static/${relativeToStatic.split(path.sep).join('/')}`;
74
+ });
75
+ }
76
+ /**
77
+ * Collect SSG asset paths by parsing .next/prerender-manifest.json
78
+ *
79
+ * For each static page route without revalidation in the manifest's `routes` object, collects:
80
+ * - {route}.html (full HTML)
81
+ * - {route}.rsc (React Server Components payload)
82
+ * - {route}.meta (response headers JSON)
83
+ * - Nested `.segment.rsc` files under {route}.segments (segment-prefetch payloads)
84
+ *
85
+ * S3 keys use the route path without leading slash.
86
+ * Filesystem paths point to .next/server/app/{route}.{ext}
87
+ *
88
+ * @param projectPath - Path to project root
89
+ * @returns SSG asset keys and a pathMap for filesystem resolution
90
+ */ export async function collectSSGAssets(projectPath, output, logger) {
91
+ const outputPath = resolveOutputPath(projectPath, 'nextjs', output);
92
+ const manifestPath = path.join(outputPath, 'prerender-manifest.json');
93
+ let manifest;
94
+ try {
95
+ const raw = await fs.readFile(manifestPath, 'utf-8');
96
+ manifest = JSON.parse(raw);
97
+ } catch {
98
+ return {
99
+ keys: [],
100
+ pathMap: {},
101
+ routeAssetMap: {}
102
+ };
103
+ }
104
+ if (!manifest.routes || typeof manifest.routes !== 'object') {
105
+ return {
106
+ keys: [],
107
+ pathMap: {},
108
+ routeAssetMap: {}
109
+ };
110
+ }
111
+ const keys = [];
112
+ const pathMap = {};
113
+ const routeAssetMap = {};
114
+ const appDir = path.join(outputPath, 'server', 'app');
115
+ for (const [routeKey, route] of Object.entries(manifest.routes)){
116
+ // Current manifests classify app pages explicitly. Older App Router manifests
117
+ // can be identified by their RSC data route. Other entries may be route handlers.
118
+ const isPageRoute = route.routeType === 'page' || route.routeType === undefined && typeof route.dataRoute === 'string' && route.dataRoute.endsWith('.rsc');
119
+ if (!isPageRoute) {
120
+ continue;
121
+ }
122
+ // ISR prerenders are seeds for the Next.js runtime, not permanent S3 pages.
123
+ // Keep legacy manifests without this field; only false explicitly disables revalidation.
124
+ if (route.initialRevalidateSeconds !== undefined && route.initialRevalidateSeconds !== false) {
125
+ continue;
126
+ }
127
+ // SSR and PPR can also disable revalidation. Only static computation can be
128
+ // served from S3; an initial response is safe for a static CSR shell.
129
+ const hasStaticRendering = route.compute === 'static' && (route.response === 'complete' || route.response === 'initial');
130
+ // Older SSG entries omit these fields. Ambiguous PPR entries must use Lambda.
131
+ const hasLegacyStaticRendering = route.compute === undefined && route.response === undefined && (route.renderingMode === undefined || route.renderingMode === 'STATIC');
132
+ if (!hasStaticRendering && !hasLegacyStaticRendering) {
133
+ continue;
134
+ }
135
+ // Strip leading slash for S3 key; handle root "/" → "index"
136
+ const stripped = routeKey === '/' ? 'index' : routeKey.replace(/^\//, '');
137
+ const routeAssets = [];
138
+ // For partially static routes, dataRoute can name a runtime endpoint even
139
+ // when the build has no full RSC file. Next.js sets prefetchDataRoute only
140
+ // when it emits that static payload.
141
+ const hasFullRSC = route.renderingMode !== 'PARTIALLY_STATIC' || typeof route.prefetchDataRoute === 'string';
142
+ const extensions = hasFullRSC ? [
143
+ '.html',
144
+ '.rsc',
145
+ '.meta'
146
+ ] : [
147
+ '.html',
148
+ '.meta'
149
+ ];
150
+ for (const ext of extensions){
151
+ const s3Key = `${stripped}${ext}`;
152
+ keys.push(s3Key);
153
+ routeAssets.push(s3Key);
154
+ pathMap[s3Key] = path.relative(projectPath, path.join(appDir, s3Key));
155
+ }
156
+ // Next.js stores segment-prefetch payloads beside each prerendered page in a
157
+ // `<page>.segments` tree. Scan the generated tree instead of reconstructing
158
+ // its opaque, potentially nested segment names from route information.
159
+ const segmentFiles = await collectFiles(path.join(appDir, `${stripped}.segments`), appDir, logger);
160
+ for (const segmentFile of segmentFiles.filter((file)=>file.endsWith('.segment.rsc'))){
161
+ const s3Key = segmentFile.split(path.sep).join('/');
162
+ keys.push(s3Key);
163
+ routeAssets.push(s3Key);
164
+ pathMap[s3Key] = path.relative(projectPath, path.join(appDir, segmentFile));
165
+ }
166
+ // Preserve the manifest route association for the original HTML/RSC/meta
167
+ // files and the new segment files; segment keys cannot be mapped back to a
168
+ // page reliably from their filename in NextjsAdapter.
169
+ routeAssetMap[routeKey] = routeAssets;
170
+ }
171
+ return {
172
+ keys,
173
+ pathMap,
174
+ routeAssetMap
175
+ };
176
+ }
177
+ /**
178
+ * Collect file-based Next.js metadata icons that were prerendered as static route handlers.
179
+ *
180
+ * Maps public asset keys such as `shop/icon1.png` to their raw
181
+ * `.next/server/app/shop/icon1.png.body` output.
182
+ * Documentation: https://nextjs.org/docs/app/api-reference/file-conventions/metadata/app-icons
183
+ */ export async function collectStaticMetadataAssets(projectPath, output) {
184
+ const outputPath = resolveOutputPath(projectPath, 'nextjs', output);
185
+ const manifestPath = path.join(outputPath, 'prerender-manifest.json');
186
+ let manifest;
187
+ try {
188
+ const raw = await fs.readFile(manifestPath, 'utf-8');
189
+ manifest = JSON.parse(raw);
190
+ } catch {
191
+ return {
192
+ keys: [],
193
+ pathMap: {}
194
+ };
195
+ }
196
+ if (!manifest.routes || typeof manifest.routes !== 'object') {
197
+ return {
198
+ keys: [],
199
+ pathMap: {}
200
+ };
201
+ }
202
+ const keys = [];
203
+ const pathMap = {};
204
+ for (const [routeKey, route] of Object.entries(manifest.routes)){
205
+ if (route.routeType !== 'route' || route.compute !== 'static' || route.response !== 'complete' || !isFileBasedMetadataIconRoute(routeKey)) {
206
+ continue;
207
+ }
208
+ const assetKey = routeKey.replace(/^\/+/, '');
209
+ const bodyPath = path.join(outputPath, 'server', 'app', `${assetKey}.body`);
210
+ try {
211
+ const bodyStat = await fs.stat(bodyPath);
212
+ if (!bodyStat.isFile()) {
213
+ continue;
214
+ }
215
+ } catch {
216
+ continue;
217
+ }
218
+ keys.push(assetKey);
219
+ pathMap[assetKey] = path.relative(projectPath, bodyPath);
220
+ }
221
+ return {
222
+ keys,
223
+ pathMap
224
+ };
225
+ }
226
+ /**
227
+ * Create Lambda deployment zip
228
+ *
229
+ * Uses cross-platform Node.js implementation instead of shell script.
230
+ *
231
+ * @param projectPath - Path to project root
232
+ * @throws Error if build missing or zip creation fails
233
+ */ export async function createLambdaZip(projectPath) {
234
+ await buildLambdaZip(projectPath);
235
+ }
236
+ function isFileBasedMetadataIconRoute(routeKey) {
237
+ const basename = path.posix.basename(routeKey);
238
+ if (routeKey === '/favicon.ico') {
239
+ return true;
240
+ }
241
+ return /^icon\d*(?:-[0-9a-z]{6})?\.(?:ico|jpe?g|png|svg)$/.test(basename) || /^apple-icon\d*(?:-[0-9a-z]{6})?\.(?:jpe?g|png)$/.test(basename);
242
+ }
@@ -1,4 +1,4 @@
1
- import type { LambdaBundle } from './deploy-adapter.js';
1
+ import type { AdapterLogger, LambdaBundle, PrepareLambdaBundleOptions } from './types.js';
2
2
  /**
3
3
  * AWS Lambda's hard limit on unzipped deployment code size (250 MB). The unzipped
4
4
  * total must be strictly less than this value, so a bundle exactly equal to it is
@@ -11,15 +11,16 @@ export declare const LAMBDA_MAX_UNZIPPED_BYTES: number;
11
11
  * Build Lambda deployment zip using pure Node.js
12
12
  *
13
13
  * Cross-platform replacement for build_for_lambda.sh:
14
- * 1. Copies .next/static to .next/standalone/.next/static
15
- * 2. Copies run.sh to .next/standalone/run.sh
16
- * 3. Creates lambda.zip from .next/standalone/
14
+ * 1. Adds a generated run.sh directly to the archive
15
+ * 2. Creates lambda.zip from the standalone output
17
16
  *
18
- * Note: public/ is NOT included in the zip — those files are uploaded
19
- * as static assets and served via CDN, not from the Lambda function.
17
+ * The output's static/ and the project's public/ directories are not copied into the zip. Those
18
+ * files are uploaded separately and served by Gatekeeper, not the Lambda function.
20
19
  *
21
20
  * @param projectPath - Path to project root
22
21
  * @returns The built bundle: its unzipped byte size and the absolute zip path.
23
22
  * @throws Error if standalone directory missing or zip creation fails
24
23
  */
25
- export declare function buildLambdaZip(projectPath: string): Promise<LambdaBundle>;
24
+ export declare function buildLambdaZip(projectPath: string, output?: string, options?: {
25
+ logger?: AdapterLogger;
26
+ } & PrepareLambdaBundleOptions): Promise<LambdaBundle>;
@@ -0,0 +1,111 @@
1
+ import archiver from 'archiver';
2
+ import { createWriteStream } from 'fs';
3
+ import fs from 'fs/promises';
4
+ import path from 'path';
5
+ import { configureNextjsCache } from './configureNextjsCache.js';
6
+ import { inspectNextjsOutput } from './deploy-output/inspectNextjsOutput.js';
7
+ import { resolveOutputPath } from './deploy-output/resolveOutputPath.js';
8
+ import { walkBundleFiles } from './fs-utils.js';
9
+ import { isBundlableFile } from './secret-files.js';
10
+ /**
11
+ * AWS Lambda's hard limit on unzipped deployment code size (250 MB). The unzipped
12
+ * total must be strictly less than this value, so a bundle exactly equal to it is
13
+ * rejected. The server enforces this too and now returns a clear message, so a
14
+ * client-side check against this value is an early-exit convenience, not the
15
+ * source of truth.
16
+ */ export const LAMBDA_MAX_UNZIPPED_BYTES = 250 * 1024 * 1024;
17
+ /**
18
+ * Build Lambda deployment zip using pure Node.js
19
+ *
20
+ * Cross-platform replacement for build_for_lambda.sh:
21
+ * 1. Adds a generated run.sh directly to the archive
22
+ * 2. Creates lambda.zip from the standalone output
23
+ *
24
+ * The output's static/ and the project's public/ directories are not copied into the zip. Those
25
+ * files are uploaded separately and served by Gatekeeper, not the Lambda function.
26
+ *
27
+ * @param projectPath - Path to project root
28
+ * @returns The built bundle: its unzipped byte size and the absolute zip path.
29
+ * @throws Error if standalone directory missing or zip creation fails
30
+ */ export async function buildLambdaZip(projectPath, output, options = {}) {
31
+ const outputPath = resolveOutputPath(projectPath, 'nextjs', output);
32
+ const layout = await inspectNextjsOutput(outputPath);
33
+ if (!layout) {
34
+ throw new Error(`Standalone build not found at ${outputPath}`);
35
+ }
36
+ const files = (await walkBundleFiles(layout.standalonePath)).filter((file)=>isBundlableFile(file.relativePath));
37
+ // Override archive entries in memory without changing Next's standalone output.
38
+ const bundleFileOverrides = await createBundleFileOverrides(layout.standalonePath, layout.serverEntryPath, options.logger);
39
+ const artifactDir = options.artifactDir ?? projectPath;
40
+ await fs.mkdir(artifactDir, {
41
+ recursive: true
42
+ });
43
+ const zipPath = path.join(artifactDir, 'lambda.zip');
44
+ let unzippedBytes = files.reduce((total, file)=>total + file.size, 0);
45
+ for (const [name, contents] of bundleFileOverrides){
46
+ const existingBytes = files.find((file)=>file.relativePath === name)?.size ?? 0;
47
+ unzippedBytes += contents.byteLength - existingBytes;
48
+ }
49
+ await createZip(files, zipPath, bundleFileOverrides);
50
+ return {
51
+ unzippedBytes,
52
+ zipPath
53
+ };
54
+ }
55
+ /**
56
+ * Returns files that replace or extend the standalone output in the Lambda zip:
57
+ * the generated launcher, the cache-configured server entry, and its optional
58
+ * cache handler. All paths are relative to the zip root.
59
+ */ async function createBundleFileOverrides(standalonePath, serverEntryPath, logger) {
60
+ const serverEntry = path.relative(standalonePath, serverEntryPath).split(path.sep).join('/');
61
+ const cacheConfiguration = await configureNextjsCache(serverEntryPath, logger);
62
+ const bundleFileOverrides = new Map([
63
+ [
64
+ 'run.sh',
65
+ Buffer.from(createRunScript(serverEntry))
66
+ ],
67
+ [
68
+ serverEntry,
69
+ Buffer.from(cacheConfiguration.server)
70
+ ]
71
+ ]);
72
+ if (cacheConfiguration.handler) {
73
+ bundleFileOverrides.set(path.posix.join(path.posix.dirname(serverEntry), cacheConfiguration.handler.name), cacheConfiguration.handler.data);
74
+ }
75
+ return bundleFileOverrides;
76
+ }
77
+ function createRunScript(serverEntry) {
78
+ const escapedEntry = serverEntry.replaceAll("'", "'\\''");
79
+ return `#!/bin/bash -x
80
+ [ ! -d '/tmp/cache' ] && mkdir -p /tmp/cache
81
+ NODE_ENV=production exec node '${escapedEntry}'
82
+ `;
83
+ }
84
+ function createZip(files, zipPath, bundleFileOverrides) {
85
+ return new Promise((resolve, reject)=>{
86
+ const output = createWriteStream(zipPath);
87
+ const archive = archiver('zip', {
88
+ zlib: {
89
+ level: 9
90
+ }
91
+ });
92
+ output.on('close', ()=>resolve());
93
+ archive.on('error', (err)=>reject(err));
94
+ archive.pipe(output);
95
+ for (const file of files){
96
+ if (bundleFileOverrides.has(file.relativePath)) {
97
+ continue;
98
+ }
99
+ archive.file(file.sourcePath, {
100
+ name: file.relativePath
101
+ });
102
+ }
103
+ for (const [name, contents] of bundleFileOverrides){
104
+ archive.append(contents, {
105
+ name,
106
+ mode: name === 'run.sh' ? 0o755 : 0o644
107
+ });
108
+ }
109
+ void archive.finalize();
110
+ });
111
+ }
@@ -0,0 +1,8 @@
1
+ import type { AdapterLogger } from './types.js';
2
+ export declare function configureNextjsCache(serverEntryPath: string, logger?: AdapterLogger): Promise<{
3
+ handler?: {
4
+ data: Buffer;
5
+ name: string;
6
+ };
7
+ server: string;
8
+ }>;
@@ -0,0 +1,55 @@
1
+ import fs from 'fs/promises';
2
+ import path from 'path';
3
+ import { Node, Project } from 'ts-morph';
4
+ import { createNextjsCacheHandlerSource } from './lambda-runtime/nextjs-cache.js';
5
+ const CACHE_HANDLER_FILE = '__figma_nextjs_cache.mjs';
6
+ export async function configureNextjsCache(serverEntryPath, logger) {
7
+ const original = await fs.readFile(serverEntryPath, 'utf8');
8
+ const project = new Project({
9
+ useInMemoryFileSystem: true
10
+ });
11
+ const source = project.createSourceFile('server.js', original);
12
+ const initializer = source.getVariableDeclaration('nextConfig')?.getInitializer();
13
+ if (!initializer || !Node.isObjectLiteralExpression(initializer)) {
14
+ throw new Error('Unsupported Next.js standalone server: expected a nextConfig object');
15
+ }
16
+ // Only accept Next's generated JSON, not arbitrary application code.
17
+ let config;
18
+ try {
19
+ config = JSON.parse(initializer.getText());
20
+ } catch {
21
+ throw new Error('Unsupported Next.js standalone server: expected generated JSON config');
22
+ }
23
+ const experimental = config.experimental;
24
+ // cacheHandler is the stable name; older Next.js builds use the experimental path.
25
+ if (config.cacheHandler || experimental?.incrementalCacheHandlerPath) {
26
+ logger?.info('Using the application cacheHandler; Figma fresh-only caching is not enabled.');
27
+ return {
28
+ server: original
29
+ };
30
+ }
31
+ const reservedPath = path.join(path.dirname(serverEntryPath), CACHE_HANDLER_FILE);
32
+ const exists = await fs.lstat(reservedPath).then(()=>true, (error)=>{
33
+ if (error.code === 'ENOENT') {
34
+ return false;
35
+ }
36
+ throw error;
37
+ });
38
+ if (exists) {
39
+ throw new Error(`Standalone output contains reserved file ${CACHE_HANDLER_FILE}`);
40
+ }
41
+ initializer.getProperty('"cacheHandler"')?.remove();
42
+ initializer.addPropertyAssignments([
43
+ {
44
+ name: 'cacheHandler',
45
+ initializer: `require.resolve('./${CACHE_HANDLER_FILE}')`
46
+ }
47
+ ]);
48
+ return {
49
+ handler: {
50
+ name: CACHE_HANDLER_FILE,
51
+ data: Buffer.from(createNextjsCacheHandlerSource())
52
+ },
53
+ server: source.getFullText()
54
+ };
55
+ }
@@ -0,0 +1 @@
1
+ export declare function getNextRelativeAppDir(manifest: null | Record<string, unknown>): null | string;
@@ -0,0 +1,15 @@
1
+ import path from 'path';
2
+ export function getNextRelativeAppDir(manifest) {
3
+ if (typeof manifest?.relativeAppDir === 'string') {
4
+ return manifest.relativeAppDir;
5
+ }
6
+ if (typeof manifest?.appDir !== 'string') {
7
+ return null;
8
+ }
9
+ const config = manifest.config;
10
+ if (config === null || typeof config !== 'object' || Array.isArray(config)) {
11
+ return null;
12
+ }
13
+ const tracingRoot = config.outputFileTracingRoot;
14
+ return typeof tracingRoot === 'string' ? path.relative(tracingRoot, manifest.appDir) : null;
15
+ }
@@ -0,0 +1,12 @@
1
+ interface NextjsOutputLayout {
2
+ buildId: string;
3
+ outputPath: string;
4
+ serverEntryPath: string;
5
+ standalonePath: string;
6
+ }
7
+ /**
8
+ * Inspects a resolved Next.js output directory, typically `<project>/.next`.
9
+ * Returns its build ID and standalone paths, or null when required files are missing.
10
+ */
11
+ export declare function inspectNextjsOutput(outputPath: string): Promise<NextjsOutputLayout | null>;
12
+ export {};
@@ -0,0 +1,28 @@
1
+ import fs from 'fs/promises';
2
+ import path from 'path';
3
+ import { getNextRelativeAppDir } from './inspectNextjsOutput/getNextRelativeAppDir.js';
4
+ import { isFile } from './isFile.js';
5
+ import { readJson } from './readJson.js';
6
+ import { resolveWithin } from './resolveWithin.js';
7
+ /**
8
+ * Inspects a resolved Next.js output directory, typically `<project>/.next`.
9
+ * Returns its build ID and standalone paths, or null when required files are missing.
10
+ */ export async function inspectNextjsOutput(outputPath) {
11
+ const buildId = await fs.readFile(path.join(outputPath, 'BUILD_ID'), 'utf8').then((value)=>value.trim()).catch(()=>null);
12
+ if (!buildId) {
13
+ return null;
14
+ }
15
+ const standalonePath = path.join(outputPath, 'standalone');
16
+ const manifest = await readJson(path.join(outputPath, 'required-server-files.json'));
17
+ const relativeAppDir = getNextRelativeAppDir(manifest);
18
+ const serverEntryPath = relativeAppDir === null ? path.join(standalonePath, 'server.js') : resolveWithin(standalonePath, path.join(relativeAppDir, 'server.js'), 'relativeAppDir');
19
+ if (!await isFile(serverEntryPath)) {
20
+ return null;
21
+ }
22
+ return {
23
+ buildId,
24
+ outputPath,
25
+ serverEntryPath,
26
+ standalonePath
27
+ };
28
+ }
@@ -0,0 +1,9 @@
1
+ import { resolveNitroOutputLayout } from './resolveNitroOutputLayout.js';
2
+ type NitroOutputLayout = Awaited<ReturnType<typeof resolveNitroOutputLayout>>;
3
+ /**
4
+ * Inspects a resolved Nitro output directory, typically `<project>/.output`.
5
+ * Returns its server and public paths, or null when the server entry is missing. The build ID is
6
+ * Nitro's manifest date when available; legacy outputs without a manifest omit it.
7
+ */
8
+ export declare function inspectNitroOutput(outputPath: string): Promise<NitroOutputLayout | null>;
9
+ export {};
@@ -0,0 +1,13 @@
1
+ import { isFile } from './isFile.js';
2
+ import { resolveNitroOutputLayout } from './resolveNitroOutputLayout.js';
3
+ /**
4
+ * Inspects a resolved Nitro output directory, typically `<project>/.output`.
5
+ * Returns its server and public paths, or null when the server entry is missing. The build ID is
6
+ * Nitro's manifest date when available; legacy outputs without a manifest omit it.
7
+ */ export async function inspectNitroOutput(outputPath) {
8
+ const layout = await resolveNitroOutputLayout(outputPath);
9
+ if (!await isFile(layout.serverEntryPath)) {
10
+ return null;
11
+ }
12
+ return layout;
13
+ }
@@ -0,0 +1 @@
1
+ export declare function isFile(filePath: string): Promise<boolean>;
@@ -0,0 +1,4 @@
1
+ import fs from 'fs/promises';
2
+ export async function isFile(filePath) {
3
+ return fs.stat(filePath).then((stat)=>stat.isFile()).catch(()=>false);
4
+ }
@@ -0,0 +1 @@
1
+ export declare function readJson(filePath: string): Promise<null | Record<string, unknown>>;
@@ -0,0 +1,9 @@
1
+ import fs from 'fs/promises';
2
+ export async function readJson(filePath) {
3
+ try {
4
+ const value = JSON.parse(await fs.readFile(filePath, 'utf8'));
5
+ return value !== null && typeof value === 'object' && !Array.isArray(value) ? value : null;
6
+ } catch {
7
+ return null;
8
+ }
9
+ }
@@ -0,0 +1,8 @@
1
+ interface NitroOutputLayout {
2
+ buildId?: string;
3
+ outputPath: string;
4
+ publicPath: string;
5
+ serverEntryPath: string;
6
+ }
7
+ export declare function resolveNitroOutputLayout(outputPath: string): Promise<NitroOutputLayout>;
8
+ export {};
@@ -0,0 +1,16 @@
1
+ import path from 'path';
2
+ import { readJson } from './readJson.js';
3
+ import { resolveWithin } from './resolveWithin.js';
4
+ const DEFAULT_PUBLIC_DIR = 'public';
5
+ const DEFAULT_SERVER_ENTRY = 'server/index.mjs';
6
+ export async function resolveNitroOutputLayout(outputPath) {
7
+ const manifest = await readJson(path.join(outputPath, 'nitro.json'));
8
+ const serverEntry = typeof manifest?.serverEntry === 'string' ? manifest.serverEntry : DEFAULT_SERVER_ENTRY;
9
+ const publicDir = typeof manifest?.publicDir === 'string' ? manifest.publicDir : DEFAULT_PUBLIC_DIR;
10
+ return {
11
+ buildId: typeof manifest?.date === 'string' ? manifest.date : undefined,
12
+ outputPath,
13
+ publicPath: resolveWithin(outputPath, publicDir, 'publicDir'),
14
+ serverEntryPath: resolveWithin(outputPath, serverEntry, 'serverEntry')
15
+ };
16
+ }
@@ -0,0 +1,2 @@
1
+ import type { AdapterName } from '../types.js';
2
+ export declare function resolveOutputPath(projectPath: string, adapter: AdapterName, output?: string): string;
@@ -0,0 +1,9 @@
1
+ import path from 'path';
2
+ const DEFAULT_OUTPUT_DIRS = {
3
+ nextjs: '.next',
4
+ nitro: '.output',
5
+ vite: 'dist'
6
+ };
7
+ export function resolveOutputPath(projectPath, adapter, output) {
8
+ return output ? path.resolve(projectPath, output) : path.join(projectPath, DEFAULT_OUTPUT_DIRS[adapter]);
9
+ }