@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
@@ -0,0 +1,193 @@
1
+ import archiver from 'archiver';
2
+ import { createWriteStream } from 'fs';
3
+ import fs from 'fs/promises';
4
+ import path from 'path';
5
+ import { resolveNitroOutputLayout } from './deploy-output/resolveNitroOutputLayout.js';
6
+ import { resolveOutputPath } from './deploy-output/resolveOutputPath.js';
7
+ import { collectFilesRecursive, EscapingSymlinkError, walkBundleFiles } from './fs-utils.js';
8
+ import { isBundlableFile, isPublishableAsset } from './secret-files.js';
9
+ /** Framework asset directories that are not pre-rendered pages. */ const NON_PAGE_DIRS = new Set([
10
+ '_build',
11
+ '_nuxt',
12
+ 'assets'
13
+ ]);
14
+ export class NitroAdapter {
15
+ name = 'nitro';
16
+ async collectAssets(projectPath, output) {
17
+ const { publicPath } = await getLayout(projectPath, output);
18
+ const pageKeys = new Set((await scanForPages(publicPath, publicPath)).map(toPageUploadKey));
19
+ const assets = (await collectFilesRecursive(publicPath, publicPath)).filter((file)=>!pageKeys.has(file) && isPublishableAsset(file));
20
+ const pathMap = Object.fromEntries(assets.map((file)=>[
21
+ file,
22
+ path.relative(projectPath, path.join(publicPath, file))
23
+ ]));
24
+ return {
25
+ pathMap,
26
+ routes: assets.map((k)=>`/${k}`),
27
+ uploadKeys: assets
28
+ };
29
+ }
30
+ async collectPages(projectPath, output) {
31
+ const { publicPath } = await getLayout(projectPath, output);
32
+ const pages = (await scanForPages(publicPath, publicPath)).filter((page)=>isPublishableAsset(toPageUploadKey(page)));
33
+ const routes = pages.map((p)=>p === 'index' ? '/' : `/${p}`);
34
+ const uploadKeys = pages.map(toPageUploadKey);
35
+ const pathMap = {};
36
+ const routeAssetMap = {};
37
+ for(let i = 0; i < uploadKeys.length; i++){
38
+ pathMap[uploadKeys[i]] = path.relative(projectPath, path.join(publicPath, uploadKeys[i]));
39
+ routeAssetMap[routes[i]] = [
40
+ uploadKeys[i]
41
+ ];
42
+ }
43
+ return {
44
+ pathMap,
45
+ routeAssetMap,
46
+ routes,
47
+ uploadKeys
48
+ };
49
+ }
50
+ async prepareLambdaBundle(projectPath, output, options = {}) {
51
+ const layout = await getLayout(projectPath, output);
52
+ try {
53
+ const stat = await fs.stat(layout.serverEntryPath);
54
+ if (!stat.isFile()) {
55
+ throw new Error('not a file');
56
+ }
57
+ } catch {
58
+ throw new Error(`Nitro server build not found at ${layout.outputPath}`);
59
+ }
60
+ const serverDir = path.dirname(layout.serverEntryPath);
61
+ const serverPrefix = zipPrefix(path.relative(layout.outputPath, serverDir).split(path.sep).join('/'));
62
+ const publicPrefix = zipPrefix(path.relative(layout.outputPath, layout.publicPath).split(path.sep).join('/'));
63
+ const serverEntry = path.relative(layout.outputPath, layout.serverEntryPath).split(path.sep).join('/');
64
+ const runShPath = path.join(layout.outputPath, 'run.sh');
65
+ await fs.writeFile(runShPath, createRunScript(serverEntry), {
66
+ mode: 0o755
67
+ });
68
+ const artifactDir = options.artifactDir ?? projectPath;
69
+ await fs.mkdir(artifactDir, {
70
+ recursive: true
71
+ });
72
+ const zipPath = path.join(artifactDir, 'lambda.zip');
73
+ try {
74
+ const runShStat = await fs.stat(runShPath);
75
+ const [allServerFiles, publicFiles] = await Promise.all([
76
+ walkBundleFiles(serverDir),
77
+ walkPublicBundleFiles(layout.publicPath)
78
+ ]);
79
+ const bundlableServerFiles = allServerFiles.filter((file)=>isBundlableFile(file.relativePath));
80
+ const unzippedBytes = bundlableServerFiles.reduce((total, file)=>total + file.size, 0) + publicFiles.reduce((total, file)=>total + file.size, 0) + runShStat.size;
81
+ await createZip(zipPath, [
82
+ {
83
+ files: bundlableServerFiles,
84
+ prefix: serverPrefix
85
+ },
86
+ {
87
+ files: publicFiles,
88
+ prefix: publicPrefix
89
+ },
90
+ {
91
+ files: [
92
+ {
93
+ relativePath: 'run.sh',
94
+ size: runShStat.size,
95
+ sourcePath: runShPath
96
+ }
97
+ ],
98
+ prefix: ''
99
+ }
100
+ ]);
101
+ return {
102
+ unzippedBytes,
103
+ zipPath
104
+ };
105
+ } finally{
106
+ await fs.rm(runShPath, {
107
+ force: true
108
+ });
109
+ }
110
+ }
111
+ }
112
+ export const nitroAdapter = new NitroAdapter();
113
+ function getLayout(projectPath, output) {
114
+ const outputPath = resolveOutputPath(projectPath, 'nitro', output);
115
+ return resolveNitroOutputLayout(outputPath);
116
+ }
117
+ function createRunScript(serverEntry) {
118
+ const escapedEntry = serverEntry.replaceAll("'", "'\\''");
119
+ return `#!/bin/bash -x
120
+ [ ! -d '/tmp/cache' ] && mkdir -p /tmp/cache
121
+ NODE_ENV=production exec node '${escapedEntry}'
122
+ `;
123
+ }
124
+ /**
125
+ * Recursively scan for pre-rendered pages (directories containing index.html).
126
+ * Skips known framework asset directories.
127
+ */ async function scanForPages(dir, baseDir) {
128
+ const pages = [];
129
+ // Check if this directory has an index.html (it's a page)
130
+ const indexPath = path.join(dir, 'index.html');
131
+ try {
132
+ await fs.stat(indexPath);
133
+ const relative = path.relative(baseDir, dir);
134
+ pages.push(relative || 'index'); // root dir -> 'index'
135
+ } catch {
136
+ // Not a page directory
137
+ }
138
+ // Recurse into subdirectories
139
+ try {
140
+ const entries = await fs.readdir(dir, {
141
+ withFileTypes: true
142
+ });
143
+ for (const entry of entries){
144
+ if (entry.isDirectory() && !NON_PAGE_DIRS.has(entry.name)) {
145
+ const subPages = await scanForPages(path.join(dir, entry.name), baseDir);
146
+ pages.push(...subPages);
147
+ }
148
+ }
149
+ } catch {
150
+ // Directory not readable
151
+ }
152
+ return pages;
153
+ }
154
+ function zipPrefix(relativeDir) {
155
+ return relativeDir ? `${relativeDir}/` : '';
156
+ }
157
+ function toPageUploadKey(page) {
158
+ return page === 'index' ? 'index.html' : `${page}/index.html`;
159
+ }
160
+ async function walkPublicBundleFiles(publicPath) {
161
+ try {
162
+ // The Nitro server serves this tree statically, so secrets copied into the
163
+ // public directory must not reach the Lambda bundle either.
164
+ const files = await walkBundleFiles(publicPath);
165
+ return files.filter((file)=>isPublishableAsset(file.relativePath));
166
+ } catch (error) {
167
+ if (error instanceof EscapingSymlinkError) {
168
+ throw error;
169
+ }
170
+ return [];
171
+ }
172
+ }
173
+ async function createZip(zipPath, entries) {
174
+ return new Promise((resolve, reject)=>{
175
+ const output = createWriteStream(zipPath);
176
+ const archive = archiver('zip', {
177
+ zlib: {
178
+ level: 9
179
+ }
180
+ });
181
+ output.on('close', ()=>resolve());
182
+ archive.on('error', (err)=>reject(err));
183
+ archive.pipe(output);
184
+ for (const entry of entries){
185
+ for (const file of entry.files){
186
+ archive.file(file.sourcePath, {
187
+ name: entry.prefix + file.relativePath
188
+ });
189
+ }
190
+ }
191
+ void archive.finalize();
192
+ });
193
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * True when a forward-slash asset key holds no secret or private-history path
3
+ * segment.
4
+ *
5
+ * A deploy can point `--output` at a directory that also holds those files (a
6
+ * buildless static root, or a framework output folder that copied them in).
7
+ * Every collected asset becomes a publicly reachable route, so `node_modules`
8
+ * is excluded here too.
9
+ */
10
+ export declare function isPublishableAsset(key: string): boolean;
11
+ /**
12
+ * True when a forward-slash bundle path belongs in a Lambda zip.
13
+ *
14
+ * A server bundle needs its `node_modules`, but never the project's `.env`
15
+ * files or credentials: a deployed function reads its configuration from
16
+ * deploy environment variables, and a packed secret only widens the blast
17
+ * radius of any later path that serves bundle files. `.env.production` is the
18
+ * deliberate exception, an escape hatch for configuration too large for the
19
+ * Lambda environment-variable limit.
20
+ *
21
+ * Paths inside `node_modules` are kept as-is. A dependency's own dotfiles are
22
+ * not the developer's secrets, and removing files a package may read at
23
+ * runtime would break the bundle.
24
+ */
25
+ export declare function isBundlableFile(relativePath: string): boolean;
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Local secrets and private history that must never leave the developer's
3
+ * machine: environment files, git history, and credential files.
4
+ */ const SECRET_NAMES = new Set([
5
+ '.git',
6
+ '.netrc',
7
+ '.npmrc',
8
+ '.ssh'
9
+ ]);
10
+ /** Installed dependencies: private for static hosting, required by a server bundle. */ const DEPENDENCY_DIR = 'node_modules';
11
+ /**
12
+ * The one environment file a Lambda zip may carry. AWS caps a function's
13
+ * environment variables at 4 KB total, so a project with more configuration
14
+ * than that has no way to pass it except inside the bundle. It is still never
15
+ * publishable: `isPublishableAsset` rejects it like any other `.env` file.
16
+ */ const BUNDLABLE_ENV_FILE = '.env.production';
17
+ /**
18
+ * True when a forward-slash asset key holds no secret or private-history path
19
+ * segment.
20
+ *
21
+ * A deploy can point `--output` at a directory that also holds those files (a
22
+ * buildless static root, or a framework output folder that copied them in).
23
+ * Every collected asset becomes a publicly reachable route, so `node_modules`
24
+ * is excluded here too.
25
+ */ export function isPublishableAsset(key) {
26
+ return key.split('/').every((segment)=>segment !== DEPENDENCY_DIR && !isSecretName(segment));
27
+ }
28
+ /**
29
+ * True when a forward-slash bundle path belongs in a Lambda zip.
30
+ *
31
+ * A server bundle needs its `node_modules`, but never the project's `.env`
32
+ * files or credentials: a deployed function reads its configuration from
33
+ * deploy environment variables, and a packed secret only widens the blast
34
+ * radius of any later path that serves bundle files. `.env.production` is the
35
+ * deliberate exception, an escape hatch for configuration too large for the
36
+ * Lambda environment-variable limit.
37
+ *
38
+ * Paths inside `node_modules` are kept as-is. A dependency's own dotfiles are
39
+ * not the developer's secrets, and removing files a package may read at
40
+ * runtime would break the bundle.
41
+ */ export function isBundlableFile(relativePath) {
42
+ const segments = relativePath.split('/');
43
+ if (segments.includes(DEPENDENCY_DIR)) {
44
+ return true;
45
+ }
46
+ return segments.every((segment)=>segment === BUNDLABLE_ENV_FILE || !isSecretName(segment));
47
+ }
48
+ function isSecretName(segment) {
49
+ return SECRET_NAMES.has(segment) || segment.startsWith('.env');
50
+ }
@@ -0,0 +1,42 @@
1
+ export interface PageCollection {
2
+ /** S3 key → relative filesystem path from project root */
3
+ pathMap: Record<string, string>;
4
+ /** Route → S3 upload keys for that route (e.g., { "/products": ["products.html", "products.rsc"] }) */
5
+ routeAssetMap: Record<string, string[]>;
6
+ /** Route paths for the manifest pages array (e.g., ["/products", "/blog"]) */
7
+ routes: string[];
8
+ /** S3 keys to upload (e.g., ["products.html", "products.rsc", "products.meta"]) */
9
+ uploadKeys: string[];
10
+ }
11
+ export interface AssetCollection {
12
+ /** S3 key → relative filesystem path from project root */
13
+ pathMap: Record<string, string>;
14
+ /** Route paths for the manifest assets array (e.g., ["/favicon.ico"]) */
15
+ routes: string[];
16
+ /** S3 keys to upload (same as routes for assets, without leading slash) */
17
+ uploadKeys: string[];
18
+ }
19
+ export type AdapterName = 'nextjs' | 'nitro' | 'vite';
20
+ export interface AdapterLogger {
21
+ info(message: string): void;
22
+ warning(message: string): void;
23
+ }
24
+ export interface LambdaBundle {
25
+ /** Total size in bytes of the bundle contents before compression. */
26
+ unzippedBytes: number;
27
+ /** Absolute path to the built lambda.zip. */
28
+ zipPath: string;
29
+ }
30
+ export interface PrepareLambdaBundleOptions {
31
+ /** Directory where lambda.zip is written. Defaults to the project root. */
32
+ artifactDir?: string;
33
+ }
34
+ export interface DeployAdapter {
35
+ collectAssets(projectPath: string, output?: string): Promise<AssetCollection>;
36
+ collectPages(projectPath: string, output?: string): Promise<PageCollection>;
37
+ /** SPA fallback path (e.g., "/index.html"). Undefined for SSR/SSG apps. */
38
+ fallback?: string;
39
+ name: AdapterName;
40
+ /** Assembles and zips the server bundle. Returns null if the adapter has no server. */
41
+ prepareLambdaBundle(projectPath: string, output?: string, options?: PrepareLambdaBundleOptions): Promise<LambdaBundle | null>;
42
+ }
@@ -0,0 +1 @@
1
+ export { };
@@ -1,8 +1,8 @@
1
- import type { AssetCollection, DeployAdapter, LambdaBundle, PageCollection } from '../deploy-adapter.js';
1
+ import type { AssetCollection, DeployAdapter, LambdaBundle, PageCollection } from './types.js';
2
2
  export declare class ViteAdapter implements DeployAdapter {
3
3
  fallback: string;
4
4
  name: "vite";
5
- collectAssets(projectPath: string): Promise<AssetCollection>;
5
+ collectAssets(projectPath: string, output?: string): Promise<AssetCollection>;
6
6
  collectPages(): Promise<PageCollection>;
7
7
  prepareLambdaBundle(): Promise<LambdaBundle | null>;
8
8
  }
@@ -0,0 +1,33 @@
1
+ import path from 'path';
2
+ import { resolveOutputPath } from './deploy-output/resolveOutputPath.js';
3
+ import { collectFilesRecursive } from './fs-utils.js';
4
+ import { isPublishableAsset } from './secret-files.js';
5
+ export class ViteAdapter {
6
+ fallback = '/index.html';
7
+ name = 'vite';
8
+ async collectAssets(projectPath, output) {
9
+ const outputPath = resolveOutputPath(projectPath, 'vite', output);
10
+ const files = (await collectFilesRecursive(outputPath, outputPath)).filter(isPublishableAsset);
11
+ const pathMap = Object.fromEntries(files.map((file)=>[
12
+ file,
13
+ path.relative(projectPath, path.join(outputPath, file))
14
+ ]));
15
+ return {
16
+ pathMap,
17
+ routes: files.map((k)=>`/${k}`),
18
+ uploadKeys: files
19
+ };
20
+ }
21
+ collectPages() {
22
+ return Promise.resolve({
23
+ pathMap: {},
24
+ routeAssetMap: {},
25
+ routes: [],
26
+ uploadKeys: []
27
+ });
28
+ }
29
+ prepareLambdaBundle() {
30
+ return Promise.resolve(null);
31
+ }
32
+ }
33
+ export const viteAdapter = new ViteAdapter();
@@ -0,0 +1,12 @@
1
+ import type { AuthCredential } from '../auth/credentials.js';
2
+ interface CheckProjectSubdomainAvailabilityArgs {
3
+ credential: AuthCredential;
4
+ subdomain: string;
5
+ }
6
+ interface ProjectSubdomainAvailability {
7
+ available: boolean;
8
+ domainName: string;
9
+ reason: string;
10
+ }
11
+ export declare function checkProjectSubdomainAvailability({ credential, subdomain, }: CheckProjectSubdomainAvailabilityArgs): Promise<ProjectSubdomainAvailability>;
12
+ export {};
@@ -0,0 +1,32 @@
1
+ import { getAuthHeaders } from '../auth/credentials.js';
2
+ import { getEnvConfig } from '../constants.js';
3
+ import { controlPlaneFetch } from './control-plane-fetch.js';
4
+ export async function checkProjectSubdomainAvailability({ credential, subdomain }) {
5
+ if (process.env.FIGMA_MOCK_CONTROL_PLANE === 'true') {
6
+ return {
7
+ available: true,
8
+ domainName: `${subdomain}.pung.site`,
9
+ reason: ''
10
+ };
11
+ }
12
+ const response = await controlPlaneFetch({
13
+ context: 'check project subdomain availability',
14
+ options: {
15
+ body: JSON.stringify({
16
+ subdomain
17
+ }),
18
+ headers: {
19
+ ...getAuthHeaders(credential),
20
+ 'Content-Type': 'application/json'
21
+ },
22
+ method: 'POST'
23
+ },
24
+ url: `${getEnvConfig().apiBaseUrl}/v1/cms/check_domain_availability`
25
+ });
26
+ const availabilityResponse = await response.json();
27
+ return {
28
+ available: availabilityResponse.meta.available,
29
+ domainName: availabilityResponse.meta.domain_name,
30
+ reason: availabilityResponse.meta.reason
31
+ };
32
+ }
@@ -0,0 +1,6 @@
1
+ /** Error thrown when Control Plane API calls fail. */
2
+ export declare class ControlPlaneError extends Error {
3
+ statusCode?: number | undefined;
4
+ cause?: Error | undefined;
5
+ constructor(message: string, statusCode?: number | undefined, cause?: Error | undefined);
6
+ }
@@ -0,0 +1,8 @@
1
+ /** Error thrown when Control Plane API calls fail. */ export class ControlPlaneError extends Error {
2
+ statusCode;
3
+ cause;
4
+ constructor(message, statusCode, cause){
5
+ super(message), this.statusCode = statusCode, this.cause = cause;
6
+ this.name = 'ControlPlaneError';
7
+ }
8
+ }
@@ -0,0 +1,7 @@
1
+ interface ControlPlaneFetchArgs {
2
+ context: string;
3
+ options: RequestInit;
4
+ url: string;
5
+ }
6
+ export declare function controlPlaneFetch({ context, options, url }: ControlPlaneFetchArgs): Promise<Response>;
7
+ export {};
@@ -0,0 +1,37 @@
1
+ import { ControlPlaneError } from './control-plane-error.js';
2
+ import { parseControlPlaneApiError } from './error-response.js';
3
+ const MAX_RETRIES = 3;
4
+ const INITIAL_RETRY_DELAY = 1000;
5
+ export async function controlPlaneFetch({ context, options, url }) {
6
+ let lastError;
7
+ for(let attempt = 0; attempt < MAX_RETRIES; attempt++){
8
+ try {
9
+ const response = await fetch(url, options);
10
+ if (response.ok) {
11
+ return response;
12
+ }
13
+ if (response.status < 500) {
14
+ throw new ControlPlaneError(await parseControlPlaneApiError({
15
+ context,
16
+ response
17
+ }), response.status);
18
+ }
19
+ lastError = new ControlPlaneError(await parseControlPlaneApiError({
20
+ context,
21
+ response
22
+ }), response.status);
23
+ } catch (error) {
24
+ if (error instanceof ControlPlaneError) {
25
+ throw error;
26
+ }
27
+ lastError = error instanceof Error ? error : new Error('Unknown error');
28
+ }
29
+ if (attempt < MAX_RETRIES - 1) {
30
+ await sleep(INITIAL_RETRY_DELAY * Math.pow(2, attempt));
31
+ }
32
+ }
33
+ throw new ControlPlaneError(`Network error while ${context}: ${lastError?.message || 'Unknown error'}`, undefined, lastError);
34
+ }
35
+ function sleep(ms) {
36
+ return new Promise((resolve)=>setTimeout(resolve, ms));
37
+ }
@@ -5,14 +5,6 @@
5
5
  */
6
6
  import type { AuthCredential } from '../auth/credentials.js';
7
7
  import type { Tenant } from '../types/config.js';
8
- /**
9
- * Error thrown when Control Plane API calls fail
10
- */
11
- export declare class ControlPlaneError extends Error {
12
- statusCode?: number | undefined;
13
- cause?: Error | undefined;
14
- constructor(message: string, statusCode?: number | undefined, cause?: Error | undefined);
15
- }
16
8
  /**
17
9
  * Options for creating a new tenant
18
10
  */
@@ -77,7 +69,7 @@ export interface PerformDeploymentResponse {
77
69
  deploymentId: string;
78
70
  /** Status message */
79
71
  message: string;
80
- /** List of tenant domains */
72
+ /** SiteDomain hostnames returned through the compatibility tenant_domains key */
81
73
  tenantDomains: string[];
82
74
  }
83
75
  export interface PerformDeploymentApiResponse {
@@ -140,6 +132,8 @@ export declare function performDeployment(credential: AuthCredential, tenantId:
140
132
  * A single environment returned by the bootstrap endpoint
141
133
  */
142
134
  export type BootstrapEnvironment = {
135
+ /** Regional Content API base URL. Absent when the server predates the field. */
136
+ contentApiUrl?: string;
143
137
  contentSystemId: string;
144
138
  name: string;
145
139
  tenantInstanceId: string;
@@ -163,6 +157,15 @@ export type BootstrapInfo = {
163
157
  * @param environmentName - Optional environment name filter
164
158
  */
165
159
  export declare function getBootstrapInfo(credential: AuthCredential, cmsResourceId: string, environmentName?: string): Promise<BootstrapInfo>;
160
+ /**
161
+ * Fetch the decrypted value of a tenant environment variable by name.
162
+ * Maps to: GET /v1/environments/:tenant_instance_id/environment_variables/by_name?name=...
163
+ *
164
+ * Only variables with `user_visibility: name_and_value` are returned; the
165
+ * endpoint answers 404 otherwise. Used by init and buildFigmaConfig to
166
+ * resolve PAYLOAD_SECRET on developer machines.
167
+ */
168
+ export declare function getEnvironmentVariableByName(credential: AuthCredential, tenantInstanceId: string, name: string): Promise<string>;
166
169
  /**
167
170
  * Resolve a CMS Resource ID from a legacy dataset (content system) ID.
168
171
  * Maps to: GET /v1/cms/dataset/:datasetId
@@ -5,22 +5,12 @@
5
5
  */ import { getAuthHeaders } from '../auth/credentials.js';
6
6
  import { getEnvConfig } from '../constants.js';
7
7
  import * as log from '../utils/log.js';
8
- import { parseControlPlaneApiError } from './error-response.js';
8
+ import { controlPlaneFetch } from './control-plane-fetch.js';
9
9
  /**
10
10
  * Get the Control Plane API base URL based on environment
11
11
  */ function getControlPlaneBaseUrl() {
12
12
  return getEnvConfig().apiBaseUrl;
13
13
  }
14
- /**
15
- * Error thrown when Control Plane API calls fail
16
- */ export class ControlPlaneError extends Error {
17
- statusCode;
18
- cause;
19
- constructor(message, statusCode, cause){
20
- super(message), this.statusCode = statusCode, this.cause = cause;
21
- this.name = 'ControlPlaneError';
22
- }
23
- }
24
14
  /**
25
15
  * List all tenant instances for the authenticated user
26
16
  * Maps to: GET /v1/tenant
@@ -234,7 +224,7 @@ import { parseControlPlaneApiError } from './error-response.js';
234
224
  deploymentId: options.deploymentId,
235
225
  message: 'Deployment initiated successfully',
236
226
  tenantDomains: [
237
- 'example.figmasource.site'
227
+ 'example.figma.site'
238
228
  ]
239
229
  };
240
230
  }
@@ -288,6 +278,7 @@ import { parseControlPlaneApiError } from './error-response.js';
288
278
  return {
289
279
  environments: data.meta.environments.map((env)=>({
290
280
  name: env.name,
281
+ contentApiUrl: env.content_api_url,
291
282
  contentSystemId: env.content_system_id,
292
283
  tenantInstanceId: env.tenant_instance_id
293
284
  })),
@@ -297,6 +288,31 @@ import { parseControlPlaneApiError } from './error-response.js';
297
288
  }
298
289
  };
299
290
  }
291
+ /**
292
+ * Fetch the decrypted value of a tenant environment variable by name.
293
+ * Maps to: GET /v1/environments/:tenant_instance_id/environment_variables/by_name?name=...
294
+ *
295
+ * Only variables with `user_visibility: name_and_value` are returned; the
296
+ * endpoint answers 404 otherwise. Used by init and buildFigmaConfig to
297
+ * resolve PAYLOAD_SECRET on developer machines.
298
+ */ export async function getEnvironmentVariableByName(credential, tenantInstanceId, name) {
299
+ const shouldMock = process.env.FIGMA_MOCK_CONTROL_PLANE === 'true';
300
+ if (shouldMock) {
301
+ log.debug('Using mock Control Plane API for getEnvironmentVariableByName (FIGMA_MOCK_CONTROL_PLANE === "true")');
302
+ return `mock-${name.toLowerCase()}-${tenantInstanceId}`;
303
+ }
304
+ const url = `${getControlPlaneBaseUrl()}/v1/environments/${encodeURIComponent(tenantInstanceId)}` + `/environment_variables/by_name?name=${encodeURIComponent(name)}`;
305
+ log.debug(`Calling getEnvironmentVariableByName API at ${url}`);
306
+ const response = await controlPlaneFetch({
307
+ context: `get environment variable ${name}`,
308
+ options: {
309
+ headers: getAuthHeaders(credential)
310
+ },
311
+ url
312
+ });
313
+ const data = await response.json();
314
+ return data.meta.value;
315
+ }
300
316
  /**
301
317
  * Resolve a CMS Resource ID from a legacy dataset (content system) ID.
302
318
  * Maps to: GET /v1/cms/dataset/:datasetId
@@ -316,39 +332,3 @@ import { parseControlPlaneApiError } from './error-response.js';
316
332
  const data = await response.json();
317
333
  return data.meta.cms_resource_id;
318
334
  }
319
- const MAX_RETRIES = 3;
320
- const INITIAL_RETRY_DELAY = 1000;
321
- function sleep(ms) {
322
- return new Promise((resolve)=>setTimeout(resolve, ms));
323
- }
324
- async function controlPlaneFetch(params) {
325
- const { context, options, url } = params;
326
- let lastError;
327
- for(let attempt = 0; attempt < MAX_RETRIES; attempt++){
328
- try {
329
- const response = await fetch(url, options);
330
- if (response.ok) {
331
- return response;
332
- }
333
- if (response.status < 500) {
334
- throw new ControlPlaneError(await parseControlPlaneApiError({
335
- context,
336
- response
337
- }), response.status);
338
- }
339
- lastError = new ControlPlaneError(await parseControlPlaneApiError({
340
- context,
341
- response
342
- }), response.status);
343
- } catch (error) {
344
- if (error instanceof ControlPlaneError) {
345
- throw error;
346
- }
347
- lastError = error instanceof Error ? error : new Error('Unknown error');
348
- }
349
- if (attempt < MAX_RETRIES - 1) {
350
- await sleep(INITIAL_RETRY_DELAY * Math.pow(2, attempt));
351
- }
352
- }
353
- throw new ControlPlaneError(`Network error while ${context}: ${lastError?.message || 'Unknown error'}`, undefined, lastError);
354
- }
@@ -0,0 +1,18 @@
1
+ import type { AuthCredential } from '../auth/credentials.js';
2
+ import type { ProjectResourceType } from './project-resource-type.js';
3
+ interface CreateProjectArgs {
4
+ credential: AuthCredential;
5
+ description: string;
6
+ name: string;
7
+ parentPlanKey: string;
8
+ region: string;
9
+ resourceType: ProjectResourceType;
10
+ subdomain: string;
11
+ }
12
+ interface CreateProjectResponse {
13
+ domainName: string;
14
+ id: string;
15
+ name: string;
16
+ }
17
+ export declare function createProject({ name, credential, description, parentPlanKey, region, resourceType, subdomain, }: CreateProjectArgs): Promise<CreateProjectResponse>;
18
+ export {};