@payloadcms/figma 0.0.1-alpha.9 → 0.1.0-alpha.1

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 (472) hide show
  1. package/dist/api/control-plane.d.ts +56 -7
  2. package/dist/api/control-plane.js +188 -74
  3. package/dist/api/error-response.d.ts +36 -0
  4. package/dist/api/error-response.js +66 -0
  5. package/dist/api/figma-api.d.ts +24 -3
  6. package/dist/api/figma-api.js +110 -34
  7. package/dist/auth/browser.d.ts +0 -1
  8. package/dist/auth/browser.js +0 -2
  9. package/dist/auth/callback-server.d.ts +19 -8
  10. package/dist/auth/callback-server.js +72 -32
  11. package/dist/auth/credentials.d.ts +20 -0
  12. package/dist/auth/credentials.js +19 -0
  13. package/dist/auth/crypto-utils.d.ts +28 -1
  14. package/dist/auth/crypto-utils.js +132 -23
  15. package/dist/auth/jwt-validator.d.ts +23 -6
  16. package/dist/auth/jwt-validator.js +35 -9
  17. package/dist/auth/oauth-flow.d.ts +19 -4
  18. package/dist/auth/oauth-flow.js +151 -34
  19. package/dist/auth/paste-code.d.ts +33 -0
  20. package/dist/auth/paste-code.js +87 -0
  21. package/dist/auth/pkce.d.ts +0 -1
  22. package/dist/auth/pkce.js +0 -2
  23. package/dist/auth/project-token.d.ts +32 -17
  24. package/dist/auth/project-token.js +176 -68
  25. package/dist/auth/refresh.d.ts +2 -2
  26. package/dist/auth/refresh.js +25 -14
  27. package/dist/auth/token-store-migration.d.ts +57 -0
  28. package/dist/auth/token-store-migration.js +154 -0
  29. package/dist/auth/token-store.d.ts +63 -98
  30. package/dist/auth/token-store.js +405 -124
  31. package/dist/auth/types.d.ts +40 -6
  32. package/dist/auth/types.js +1 -3
  33. package/dist/cli.d.ts +0 -1
  34. package/dist/cli.js +102 -8
  35. package/dist/commands/bootstrap.d.ts +17 -0
  36. package/dist/commands/bootstrap.js +88 -0
  37. package/dist/commands/build-lambda-zip.d.ts +4 -0
  38. package/dist/commands/build-lambda-zip.js +17 -0
  39. package/dist/commands/debug.d.ts +7 -0
  40. package/dist/commands/debug.js +178 -0
  41. package/dist/commands/deploy.d.ts +11 -1
  42. package/dist/commands/deploy.js +193 -153
  43. package/dist/commands/dump-tokens.d.ts +11 -0
  44. package/dist/commands/dump-tokens.js +67 -0
  45. package/dist/commands/env.d.ts +12 -0
  46. package/dist/commands/env.js +86 -0
  47. package/dist/commands/init.d.ts +9 -6
  48. package/dist/commands/init.js +232 -152
  49. package/dist/commands/list-tokens.d.ts +3 -4
  50. package/dist/commands/list-tokens.js +24 -11
  51. package/dist/commands/login.d.ts +8 -2
  52. package/dist/commands/login.js +34 -18
  53. package/dist/commands/logout.d.ts +5 -5
  54. package/dist/commands/logout.js +77 -17
  55. package/dist/commands/upgrade.d.ts +4 -0
  56. package/dist/commands/upgrade.js +329 -0
  57. package/dist/commands/upload-schema.d.ts +8 -0
  58. package/dist/commands/upload-schema.js +91 -0
  59. package/dist/config/oauth.d.ts +17 -12
  60. package/dist/config/oauth.js +38 -39
  61. package/dist/constants.d.ts +63 -19
  62. package/dist/constants.js +158 -20
  63. package/dist/db-content-api/generated/content-api-types.d.ts +8215 -0
  64. package/dist/db-content-api/generated/content-api-types.js +5 -0
  65. package/dist/db-content-api/index.d.ts +40 -0
  66. package/dist/db-content-api/index.js +883 -0
  67. package/dist/db-content-api/temp-utilities/slug.d.ts +1 -0
  68. package/dist/db-content-api/temp-utilities/slug.js +1 -0
  69. package/dist/db-content-api/temp-utilities/sorting.d.ts +2 -0
  70. package/dist/db-content-api/temp-utilities/sorting.js +37 -0
  71. package/dist/db-content-api/temp-utilities/types.d.ts +21 -0
  72. package/dist/db-content-api/temp-utilities/types.js +13 -0
  73. package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +38 -0
  74. package/dist/db-content-api/temp-utilities/unwrapDocument.js +62 -0
  75. package/dist/db-content-api/utilities/auth.d.ts +29 -0
  76. package/dist/db-content-api/utilities/auth.js +82 -0
  77. package/dist/db-content-api/utilities/clientVersionHeaders.d.ts +7 -0
  78. package/dist/db-content-api/utilities/clientVersionHeaders.js +15 -0
  79. package/dist/db-content-api/utilities/data/applyDefaults.d.ts +6 -0
  80. package/dist/db-content-api/utilities/data/applyDefaults.js +75 -0
  81. package/dist/db-content-api/utilities/data/atomicOperations.d.ts +16 -0
  82. package/dist/db-content-api/utilities/data/atomicOperations.js +48 -0
  83. package/dist/db-content-api/utilities/data/castFieldValue.d.ts +10 -0
  84. package/dist/db-content-api/utilities/data/castFieldValue.js +66 -0
  85. package/dist/db-content-api/utilities/data/convertRelationshipIds.d.ts +25 -0
  86. package/dist/db-content-api/utilities/data/convertRelationshipIds.js +109 -0
  87. package/dist/db-content-api/utilities/data/index.d.ts +48 -0
  88. package/dist/db-content-api/utilities/data/index.js +315 -0
  89. package/dist/db-content-api/utilities/data/isLocaleMap.d.ts +10 -0
  90. package/dist/db-content-api/utilities/data/isLocaleMap.js +13 -0
  91. package/dist/db-content-api/utilities/data/pointShape.d.ts +3 -0
  92. package/dist/db-content-api/utilities/data/pointShape.js +43 -0
  93. package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +11 -0
  94. package/dist/db-content-api/utilities/data/removeVirtualFields.js +52 -0
  95. package/dist/db-content-api/utilities/data/resolveFieldLocalization.d.ts +18 -0
  96. package/dist/db-content-api/utilities/data/resolveFieldLocalization.js +21 -0
  97. package/dist/db-content-api/utilities/data/richTextShape.d.ts +3 -0
  98. package/dist/db-content-api/utilities/data/richTextShape.js +56 -0
  99. package/dist/db-content-api/utilities/data/stripFields.d.ts +47 -0
  100. package/dist/db-content-api/utilities/data/stripFields.js +170 -0
  101. package/dist/db-content-api/utilities/data/transformPublishedLocale.d.ts +22 -0
  102. package/dist/db-content-api/utilities/data/transformPublishedLocale.js +40 -0
  103. package/dist/db-content-api/utilities/data/validateRelationships.d.ts +6 -0
  104. package/dist/db-content-api/utilities/data/validateRelationships.js +107 -0
  105. package/dist/db-content-api/utilities/joins.d.ts +50 -0
  106. package/dist/db-content-api/utilities/joins.js +124 -0
  107. package/dist/db-content-api/utilities/locale/index.d.ts +9 -0
  108. package/dist/db-content-api/utilities/locale/index.js +19 -0
  109. package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.d.ts +9 -0
  110. package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.js +100 -0
  111. package/dist/db-content-api/utilities/resolveBlocks.d.ts +19 -0
  112. package/dist/db-content-api/utilities/resolveBlocks.js +31 -0
  113. package/dist/db-content-api/utilities/schema/buildDocumentSchema.d.ts +72 -0
  114. package/dist/db-content-api/utilities/schema/buildDocumentSchema.js +264 -0
  115. package/dist/db-content-api/utilities/where.d.ts +9 -0
  116. package/dist/db-content-api/utilities/where.js +95 -0
  117. package/dist/deploy/schedule-extract-plugin.d.ts +10 -0
  118. package/dist/deploy/schedule-extract-plugin.js +32 -0
  119. package/dist/endpoints/health.d.ts +2 -0
  120. package/dist/endpoints/health.js +9 -0
  121. package/dist/endpoints/schema.d.ts +2 -0
  122. package/dist/endpoints/schema.js +27 -0
  123. package/dist/exports/client.d.ts +2 -1
  124. package/dist/exports/client.js +2 -2
  125. package/dist/index.d.ts +2 -2
  126. package/dist/index.js +3 -3
  127. package/dist/lib/download-skill.d.ts +12 -0
  128. package/dist/lib/download-skill.js +77 -0
  129. package/dist/oauth/components/FigmaAvatar/index.d.ts +3 -0
  130. package/dist/oauth/components/FigmaAvatar/index.js +25 -0
  131. package/dist/oauth/components/FigmaAvatar/index.scss +12 -0
  132. package/dist/oauth/components/FigmaAvatarCell/index.d.ts +4 -0
  133. package/dist/oauth/components/FigmaAvatarCell/index.js +23 -0
  134. package/dist/oauth/components/FigmaAvatarCell/index.scss +5 -0
  135. package/dist/oauth/components/FigmaAvatarPlaceholder/index.d.ts +8 -0
  136. package/dist/oauth/components/FigmaAvatarPlaceholder/index.js +35 -0
  137. package/dist/oauth/components/FigmaAvatarPlaceholder/index.scss +28 -0
  138. package/dist/oauth/components/LoginButton/iframeAutoLogin.d.ts +81 -0
  139. package/dist/oauth/components/LoginButton/iframeAutoLogin.js +168 -0
  140. package/dist/oauth/components/LoginButton/index.d.ts +0 -1
  141. package/dist/oauth/components/LoginButton/index.js +156 -18
  142. package/dist/oauth/components/LoginButton/index.scss +75 -3
  143. package/dist/oauth/components/LogoutButton/index.d.ts +0 -1
  144. package/dist/oauth/components/LogoutButton/index.js +20 -9
  145. package/dist/oauth/defaults.d.ts +3 -2
  146. package/dist/oauth/defaults.js +79 -12
  147. package/dist/oauth/endpoints/getLoginEndpoint.d.ts +0 -1
  148. package/dist/oauth/endpoints/getLoginEndpoint.js +87 -84
  149. package/dist/oauth/endpoints/getLogoutEndpoint.d.ts +0 -1
  150. package/dist/oauth/endpoints/getLogoutEndpoint.js +7 -6
  151. package/dist/oauth/endpoints/getMetaEndpoint.d.ts +0 -1
  152. package/dist/oauth/endpoints/getMetaEndpoint.js +18 -5
  153. package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts +0 -1
  154. package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js +11 -4
  155. package/dist/oauth/exports/client.d.ts +0 -1
  156. package/dist/oauth/exports/client.js +0 -2
  157. package/dist/oauth/hooks/afterLogout.d.ts +0 -1
  158. package/dist/oauth/hooks/afterLogout.js +0 -2
  159. package/dist/oauth/hooks/me.d.ts +0 -1
  160. package/dist/oauth/hooks/me.js +0 -2
  161. package/dist/oauth/hooks/refresh.d.ts +0 -1
  162. package/dist/oauth/hooks/refresh.js +2 -3
  163. package/dist/oauth/index.d.ts +0 -1
  164. package/dist/oauth/index.js +27 -7
  165. package/dist/oauth/strategy/index.d.ts +0 -3
  166. package/dist/oauth/strategy/index.js +55 -34
  167. package/dist/oauth/types.d.ts +23 -7
  168. package/dist/oauth/types.js +0 -2
  169. package/dist/oauth/utilities/buildUnauthorizedRedirect.d.ts +14 -0
  170. package/dist/oauth/utilities/buildUnauthorizedRedirect.js +28 -0
  171. package/dist/oauth/utilities/clearCookie.d.ts +0 -1
  172. package/dist/oauth/utilities/clearCookie.js +5 -3
  173. package/dist/oauth/utilities/createCookieOptions.d.ts +0 -1
  174. package/dist/oauth/utilities/createCookieOptions.js +9 -4
  175. package/dist/oauth/utilities/createDebugLogger.d.ts +0 -1
  176. package/dist/oauth/utilities/createDebugLogger.js +0 -2
  177. package/dist/oauth/utilities/establishSession.d.ts +22 -0
  178. package/dist/oauth/utilities/establishSession.js +80 -0
  179. package/dist/oauth/utilities/exchangeCodeForAccessToken.d.ts +23 -0
  180. package/dist/oauth/utilities/exchangeCodeForAccessToken.js +26 -0
  181. package/dist/oauth/utilities/extractOrigin.d.ts +0 -1
  182. package/dist/oauth/utilities/extractOrigin.js +0 -2
  183. package/dist/oauth/utilities/figmaHostnames.d.ts +2 -0
  184. package/dist/oauth/utilities/figmaHostnames.js +24 -0
  185. package/dist/oauth/utilities/getAdminCollectionSlug.d.ts +0 -1
  186. package/dist/oauth/utilities/getAdminCollectionSlug.js +0 -2
  187. package/dist/oauth/utilities/getAuthorizeURL.d.ts +65 -2
  188. package/dist/oauth/utilities/getAuthorizeURL.js +57 -4
  189. package/dist/oauth/utilities/getCookieExpiration.d.ts +0 -1
  190. package/dist/oauth/utilities/getCookieExpiration.js +0 -2
  191. package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts +0 -1
  192. package/dist/oauth/utilities/getSecondsFromTokenExp.js +0 -2
  193. package/dist/oauth/utilities/getTokenExp.d.ts +0 -1
  194. package/dist/oauth/utilities/getTokenExp.js +0 -2
  195. package/dist/oauth/utilities/getUsernameField.d.ts +0 -1
  196. package/dist/oauth/utilities/getUsernameField.js +0 -2
  197. package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts +0 -1
  198. package/dist/oauth/utilities/hasUserTokenPropsChanged.js +0 -2
  199. package/dist/oauth/utilities/isAbsoluteURL.d.ts +1 -0
  200. package/dist/oauth/utilities/isAbsoluteURL.js +1 -0
  201. package/dist/oauth/utilities/isDuplicateKeyError.d.ts +6 -0
  202. package/dist/oauth/utilities/isDuplicateKeyError.js +12 -0
  203. package/dist/oauth/utilities/mergeHeaders.d.ts +0 -1
  204. package/dist/oauth/utilities/mergeHeaders.js +0 -2
  205. package/dist/oauth/utilities/refreshTokens.d.ts +0 -1
  206. package/dist/oauth/utilities/refreshTokens.js +21 -13
  207. package/dist/oauth/utilities/withPartitionedCookie.d.ts +19 -0
  208. package/dist/oauth/utilities/withPartitionedCookie.js +26 -0
  209. package/dist/oauth/utils/getSearchParam.d.ts +17 -0
  210. package/dist/oauth/utils/getSearchParam.js +22 -0
  211. package/dist/plugin/adapter.d.ts +0 -1
  212. package/dist/plugin/adapter.js +0 -2
  213. package/dist/plugin/auth-preflight.d.ts +7 -0
  214. package/dist/plugin/auth-preflight.js +18 -0
  215. package/dist/plugin/bootstrap-preflight.d.ts +22 -0
  216. package/dist/plugin/bootstrap-preflight.js +43 -0
  217. package/dist/plugin/build-config.d.ts +27 -15
  218. package/dist/plugin/build-config.js +380 -16
  219. package/dist/plugin/dev-cookie-names.d.ts +13 -0
  220. package/dist/plugin/dev-cookie-names.js +17 -0
  221. package/dist/scss.d.js +2 -0
  222. package/dist/storage-content-api/api-types.d.ts +183 -0
  223. package/dist/storage-content-api/api-types.js +4 -0
  224. package/dist/storage-content-api/client-uploads/generate.d.ts +14 -0
  225. package/dist/storage-content-api/client-uploads/generate.js +69 -0
  226. package/dist/storage-content-api/client.d.ts +5 -0
  227. package/dist/storage-content-api/client.js +37 -0
  228. package/dist/storage-content-api/generateURL.d.ts +6 -0
  229. package/dist/storage-content-api/generateURL.js +6 -0
  230. package/dist/storage-content-api/handleDelete.d.ts +7 -0
  231. package/dist/storage-content-api/handleDelete.js +15 -0
  232. package/dist/storage-content-api/handleUpload.d.ts +10 -0
  233. package/dist/storage-content-api/handleUpload.js +162 -0
  234. package/dist/storage-content-api/index.d.ts +4 -0
  235. package/dist/storage-content-api/index.js +37 -0
  236. package/dist/storage-content-api/staticHandler.d.ts +9 -0
  237. package/dist/storage-content-api/staticHandler.js +61 -0
  238. package/dist/storage-content-api/types.d.ts +9 -0
  239. package/dist/storage-content-api/types.js +1 -0
  240. package/dist/storage-content-api/utilities/getSafeFilename.d.ts +11 -0
  241. package/dist/storage-content-api/utilities/getSafeFilename.js +59 -0
  242. package/dist/storage-content-api/utilities/index.d.ts +2 -0
  243. package/dist/storage-content-api/utilities/index.js +2 -0
  244. package/dist/storage-content-api/utilities/parseUploadReference.d.ts +17 -0
  245. package/dist/storage-content-api/utilities/parseUploadReference.js +27 -0
  246. package/dist/templates/.env.example +5 -0
  247. package/dist/templates/README.md +19 -0
  248. package/dist/types/config.d.ts +2 -2
  249. package/dist/types/config.js +0 -4
  250. package/dist/types.d.ts +10 -2
  251. package/dist/types.js +0 -2
  252. package/dist/utils/adapters/nextjs.d.ts +8 -0
  253. package/dist/utils/adapters/nextjs.js +61 -0
  254. package/dist/utils/adapters/nitro.d.ts +8 -0
  255. package/dist/utils/adapters/nitro.js +172 -0
  256. package/dist/utils/adapters/vite.d.ts +9 -0
  257. package/dist/utils/adapters/vite.js +31 -0
  258. package/dist/utils/asset-collection.d.ts +27 -7
  259. package/dist/utils/asset-collection.js +59 -32
  260. package/dist/utils/build-detection.d.ts +5 -12
  261. package/dist/utils/build-detection.js +74 -13
  262. package/dist/utils/build-lambda-zip.d.ts +25 -0
  263. package/dist/utils/build-lambda-zip.js +90 -0
  264. package/dist/utils/cache-bootstrap.d.ts +7 -0
  265. package/dist/utils/cache-bootstrap.js +16 -0
  266. package/dist/utils/config.d.ts +0 -1
  267. package/dist/utils/config.js +1 -3
  268. package/dist/utils/deploy-adapter.d.ts +45 -0
  269. package/dist/utils/deploy-adapter.js +56 -0
  270. package/dist/utils/download-template.d.ts +9 -2
  271. package/dist/utils/download-template.js +24 -20
  272. package/dist/utils/env-management.d.ts +24 -8
  273. package/dist/utils/env-management.js +119 -66
  274. package/dist/utils/format-env-suffix.d.ts +11 -0
  275. package/dist/utils/format-env-suffix.js +11 -0
  276. package/dist/utils/format.d.ts +0 -1
  277. package/dist/utils/format.js +0 -2
  278. package/dist/utils/formatter.d.ts +0 -1
  279. package/dist/utils/formatter.js +23 -13
  280. package/dist/utils/fs-utils.d.ts +12 -0
  281. package/dist/utils/fs-utils.js +55 -0
  282. package/dist/utils/git.d.ts +0 -1
  283. package/dist/utils/git.js +0 -2
  284. package/dist/utils/handle-upgrade.d.ts +8 -0
  285. package/dist/utils/handle-upgrade.js +39 -0
  286. package/dist/utils/is-debug.d.ts +0 -1
  287. package/dist/utils/is-debug.js +0 -2
  288. package/dist/utils/lambda-config.d.ts +3 -2
  289. package/dist/utils/lambda-config.js +75 -80
  290. package/dist/utils/load-payload-config.d.ts +9 -0
  291. package/dist/utils/load-payload-config.js +27 -0
  292. package/dist/utils/log.d.ts +0 -1
  293. package/dist/utils/log.js +0 -2
  294. package/dist/utils/messages.d.ts +1 -3
  295. package/dist/utils/messages.js +47 -13
  296. package/dist/utils/package-manager.d.ts +24 -1
  297. package/dist/utils/package-manager.js +53 -2
  298. package/dist/utils/parse-template-spec.d.ts +11 -0
  299. package/dist/utils/parse-template-spec.js +60 -0
  300. package/dist/utils/payload-config-ast.d.ts +27 -7
  301. package/dist/utils/payload-config-ast.js +106 -60
  302. package/dist/utils/payload-config-finder.d.ts +2 -3
  303. package/dist/utils/payload-config-finder.js +48 -11
  304. package/dist/utils/payload-config-modifier.d.ts +1 -2
  305. package/dist/utils/payload-config-modifier.js +114 -68
  306. package/dist/utils/payload-package-check.d.ts +28 -3
  307. package/dist/utils/payload-package-check.js +90 -31
  308. package/dist/utils/project.d.ts +8 -4
  309. package/dist/utils/project.js +63 -37
  310. package/dist/utils/resolve-environment.d.ts +13 -0
  311. package/dist/utils/resolve-environment.js +29 -0
  312. package/dist/utils/s3-upload.d.ts +7 -3
  313. package/dist/utils/s3-upload.js +44 -9
  314. package/dist/utils/token-display.d.ts +5 -2
  315. package/dist/utils/token-display.js +49 -24
  316. package/dist/utils/typescript-validator.d.ts +0 -1
  317. package/dist/utils/typescript-validator.js +4 -8
  318. package/dist/utils/version-check.d.ts +2 -0
  319. package/dist/utils/version-check.js +43 -0
  320. package/package.json +47 -16
  321. package/dist/api/control-plane.d.ts.map +0 -1
  322. package/dist/api/control-plane.js.map +0 -1
  323. package/dist/api/figma-api.d.ts.map +0 -1
  324. package/dist/api/figma-api.js.map +0 -1
  325. package/dist/auth/browser.d.ts.map +0 -1
  326. package/dist/auth/browser.js.map +0 -1
  327. package/dist/auth/callback-server.d.ts.map +0 -1
  328. package/dist/auth/callback-server.js.map +0 -1
  329. package/dist/auth/crypto-utils.d.ts.map +0 -1
  330. package/dist/auth/crypto-utils.js.map +0 -1
  331. package/dist/auth/jwt-validator.d.ts.map +0 -1
  332. package/dist/auth/jwt-validator.js.map +0 -1
  333. package/dist/auth/oauth-flow.d.ts.map +0 -1
  334. package/dist/auth/oauth-flow.js.map +0 -1
  335. package/dist/auth/pkce.d.ts.map +0 -1
  336. package/dist/auth/pkce.js.map +0 -1
  337. package/dist/auth/project-token.d.ts.map +0 -1
  338. package/dist/auth/project-token.js.map +0 -1
  339. package/dist/auth/refresh.d.ts.map +0 -1
  340. package/dist/auth/refresh.js.map +0 -1
  341. package/dist/auth/token-store.d.ts.map +0 -1
  342. package/dist/auth/token-store.js.map +0 -1
  343. package/dist/auth/types.d.ts.map +0 -1
  344. package/dist/auth/types.js.map +0 -1
  345. package/dist/cli.d.ts.map +0 -1
  346. package/dist/cli.js.map +0 -1
  347. package/dist/commands/deploy.d.ts.map +0 -1
  348. package/dist/commands/deploy.js.map +0 -1
  349. package/dist/commands/init.d.ts.map +0 -1
  350. package/dist/commands/init.js.map +0 -1
  351. package/dist/commands/list-tokens.d.ts.map +0 -1
  352. package/dist/commands/list-tokens.js.map +0 -1
  353. package/dist/commands/login.d.ts.map +0 -1
  354. package/dist/commands/login.js.map +0 -1
  355. package/dist/commands/logout.d.ts.map +0 -1
  356. package/dist/commands/logout.js.map +0 -1
  357. package/dist/config/oauth.d.ts.map +0 -1
  358. package/dist/config/oauth.js.map +0 -1
  359. package/dist/constants.d.ts.map +0 -1
  360. package/dist/constants.js.map +0 -1
  361. package/dist/exports/client.d.ts.map +0 -1
  362. package/dist/exports/client.js.map +0 -1
  363. package/dist/index.d.ts.map +0 -1
  364. package/dist/index.js.map +0 -1
  365. package/dist/oauth/components/LoginButton/index.d.ts.map +0 -1
  366. package/dist/oauth/components/LoginButton/index.js.map +0 -1
  367. package/dist/oauth/components/LogoutButton/index.d.ts.map +0 -1
  368. package/dist/oauth/components/LogoutButton/index.js.map +0 -1
  369. package/dist/oauth/defaults.d.ts.map +0 -1
  370. package/dist/oauth/defaults.js.map +0 -1
  371. package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +0 -1
  372. package/dist/oauth/endpoints/getLoginEndpoint.js.map +0 -1
  373. package/dist/oauth/endpoints/getLogoutEndpoint.d.ts.map +0 -1
  374. package/dist/oauth/endpoints/getLogoutEndpoint.js.map +0 -1
  375. package/dist/oauth/endpoints/getMetaEndpoint.d.ts.map +0 -1
  376. package/dist/oauth/endpoints/getMetaEndpoint.js.map +0 -1
  377. package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts.map +0 -1
  378. package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js.map +0 -1
  379. package/dist/oauth/exports/client.d.ts.map +0 -1
  380. package/dist/oauth/exports/client.js.map +0 -1
  381. package/dist/oauth/hooks/afterLogout.d.ts.map +0 -1
  382. package/dist/oauth/hooks/afterLogout.js.map +0 -1
  383. package/dist/oauth/hooks/me.d.ts.map +0 -1
  384. package/dist/oauth/hooks/me.js.map +0 -1
  385. package/dist/oauth/hooks/refresh.d.ts.map +0 -1
  386. package/dist/oauth/hooks/refresh.js.map +0 -1
  387. package/dist/oauth/index.d.ts.map +0 -1
  388. package/dist/oauth/index.js.map +0 -1
  389. package/dist/oauth/strategy/index.d.ts.map +0 -1
  390. package/dist/oauth/strategy/index.js.map +0 -1
  391. package/dist/oauth/types.d.ts.map +0 -1
  392. package/dist/oauth/types.js.map +0 -1
  393. package/dist/oauth/utilities/clearCookie.d.ts.map +0 -1
  394. package/dist/oauth/utilities/clearCookie.js.map +0 -1
  395. package/dist/oauth/utilities/createCookieOptions.d.ts.map +0 -1
  396. package/dist/oauth/utilities/createCookieOptions.js.map +0 -1
  397. package/dist/oauth/utilities/createDebugLogger.d.ts.map +0 -1
  398. package/dist/oauth/utilities/createDebugLogger.js.map +0 -1
  399. package/dist/oauth/utilities/extractOrigin.d.ts.map +0 -1
  400. package/dist/oauth/utilities/extractOrigin.js.map +0 -1
  401. package/dist/oauth/utilities/getAdminCollectionSlug.d.ts.map +0 -1
  402. package/dist/oauth/utilities/getAdminCollectionSlug.js.map +0 -1
  403. package/dist/oauth/utilities/getAdminPath.d.ts +0 -8
  404. package/dist/oauth/utilities/getAdminPath.d.ts.map +0 -1
  405. package/dist/oauth/utilities/getAdminPath.js +0 -9
  406. package/dist/oauth/utilities/getAdminPath.js.map +0 -1
  407. package/dist/oauth/utilities/getAuthorizeURL.d.ts.map +0 -1
  408. package/dist/oauth/utilities/getAuthorizeURL.js.map +0 -1
  409. package/dist/oauth/utilities/getCookieExpiration.d.ts.map +0 -1
  410. package/dist/oauth/utilities/getCookieExpiration.js.map +0 -1
  411. package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts.map +0 -1
  412. package/dist/oauth/utilities/getSecondsFromTokenExp.js.map +0 -1
  413. package/dist/oauth/utilities/getTokenExp.d.ts.map +0 -1
  414. package/dist/oauth/utilities/getTokenExp.js.map +0 -1
  415. package/dist/oauth/utilities/getUsernameField.d.ts.map +0 -1
  416. package/dist/oauth/utilities/getUsernameField.js.map +0 -1
  417. package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts.map +0 -1
  418. package/dist/oauth/utilities/hasUserTokenPropsChanged.js.map +0 -1
  419. package/dist/oauth/utilities/mergeHeaders.d.ts.map +0 -1
  420. package/dist/oauth/utilities/mergeHeaders.js.map +0 -1
  421. package/dist/oauth/utilities/refreshTokens.d.ts.map +0 -1
  422. package/dist/oauth/utilities/refreshTokens.js.map +0 -1
  423. package/dist/plugin/adapter.d.ts.map +0 -1
  424. package/dist/plugin/adapter.js.map +0 -1
  425. package/dist/plugin/build-config.d.ts.map +0 -1
  426. package/dist/plugin/build-config.js.map +0 -1
  427. package/dist/types/config.d.ts.map +0 -1
  428. package/dist/types/config.js.map +0 -1
  429. package/dist/types.d.ts.map +0 -1
  430. package/dist/types.js.map +0 -1
  431. package/dist/utils/asset-collection.d.ts.map +0 -1
  432. package/dist/utils/asset-collection.js.map +0 -1
  433. package/dist/utils/build-detection.d.ts.map +0 -1
  434. package/dist/utils/build-detection.js.map +0 -1
  435. package/dist/utils/config.d.ts.map +0 -1
  436. package/dist/utils/config.js.map +0 -1
  437. package/dist/utils/download-template.d.ts.map +0 -1
  438. package/dist/utils/download-template.js.map +0 -1
  439. package/dist/utils/env-management.d.ts.map +0 -1
  440. package/dist/utils/env-management.js.map +0 -1
  441. package/dist/utils/format.d.ts.map +0 -1
  442. package/dist/utils/format.js.map +0 -1
  443. package/dist/utils/formatter.d.ts.map +0 -1
  444. package/dist/utils/formatter.js.map +0 -1
  445. package/dist/utils/git.d.ts.map +0 -1
  446. package/dist/utils/git.js.map +0 -1
  447. package/dist/utils/is-debug.d.ts.map +0 -1
  448. package/dist/utils/is-debug.js.map +0 -1
  449. package/dist/utils/lambda-config.d.ts.map +0 -1
  450. package/dist/utils/lambda-config.js.map +0 -1
  451. package/dist/utils/log.d.ts.map +0 -1
  452. package/dist/utils/log.js.map +0 -1
  453. package/dist/utils/messages.d.ts.map +0 -1
  454. package/dist/utils/messages.js.map +0 -1
  455. package/dist/utils/package-manager.d.ts.map +0 -1
  456. package/dist/utils/package-manager.js.map +0 -1
  457. package/dist/utils/payload-config-ast.d.ts.map +0 -1
  458. package/dist/utils/payload-config-ast.js.map +0 -1
  459. package/dist/utils/payload-config-finder.d.ts.map +0 -1
  460. package/dist/utils/payload-config-finder.js.map +0 -1
  461. package/dist/utils/payload-config-modifier.d.ts.map +0 -1
  462. package/dist/utils/payload-config-modifier.js.map +0 -1
  463. package/dist/utils/payload-package-check.d.ts.map +0 -1
  464. package/dist/utils/payload-package-check.js.map +0 -1
  465. package/dist/utils/project.d.ts.map +0 -1
  466. package/dist/utils/project.js.map +0 -1
  467. package/dist/utils/s3-upload.d.ts.map +0 -1
  468. package/dist/utils/s3-upload.js.map +0 -1
  469. package/dist/utils/token-display.d.ts.map +0 -1
  470. package/dist/utils/token-display.js.map +0 -1
  471. package/dist/utils/typescript-validator.d.ts.map +0 -1
  472. package/dist/utils/typescript-validator.js.map +0 -1
@@ -1,13 +1,15 @@
1
1
  /**
2
2
  * Project detection and scaffolding utilities
3
- */ import { spawn } from 'child_process';
3
+ */ import spawn from 'cross-spawn';
4
4
  import fs from 'fs/promises';
5
5
  import path from 'path';
6
+ import { fileURLToPath } from 'url';
6
7
  import { ensureGitignore } from './config.js';
7
8
  import { downloadTemplateFromGitHub } from './download-template.js';
8
- import { manageEnvFiles } from './env-management.js';
9
9
  import { tryInitRepoAndCommit } from './git.js';
10
10
  import { applyLambdaModifications } from './lambda-config.js';
11
+ import { getRunCommand } from './package-manager.js';
12
+ import { getOwnVersion } from './version-check.js';
11
13
  /**
12
14
  * Detect if current directory has a Payload project
13
15
  *
@@ -51,63 +53,76 @@ import { applyLambdaModifications } from './lambda-config.js';
51
53
  }
52
54
  }
53
55
  /**
54
- * Validate Payload version (must be 3.x)
56
+ * Validate Payload version (must be 4.x or newer)
55
57
  *
56
58
  * @param version - Version string from package.json
57
59
  * @returns True if version is valid
58
60
  */ export function validatePayloadVersion(version) {
59
- // Extract major version (handle ^3.0.0, ~3.0.0, 3.0.0, etc.)
61
+ // Extract major version (handle ^4.0.0, ~4.0.0, 4.0.0, 4.0.0-canary.16, etc.)
60
62
  const match = version.match(/(\d+)/);
61
63
  if (!match) {
62
64
  return false;
63
65
  }
64
66
  const majorVersion = parseInt(match[1], 10);
65
- return majorVersion === 3;
67
+ return majorVersion >= 4;
66
68
  }
67
69
  /**
68
- * Fetch the latest version of a package from npm registry
70
+ * Resolve a package version from an npm dist-tag or an explicit version.
69
71
  *
70
- * @param packageName - Package name to fetch version for
71
- * @returns Latest version string
72
- */ async function getLatestPackageVersion(packageName) {
73
- const response = await fetch(`https://registry.npmjs.org/-/package/${packageName}/dist-tags`);
74
- if (!response.ok) {
75
- throw new Error(`Failed to fetch version for ${packageName}: ${response.statusText}`);
72
+ * A value matching a published dist-tag (e.g. 'latest', 'canary') resolves to
73
+ * that tag's concrete version. Any other value is treated as an explicit version
74
+ * and verified against the registry.
75
+ *
76
+ * @param packageName - Package name to look up
77
+ * @param versionOrTag - npm dist-tag or explicit semver version; defaults to 'latest'
78
+ * @returns The concrete version string to pin
79
+ */ async function resolvePackageVersion(packageName, versionOrTag = 'latest') {
80
+ const distTagsResponse = await fetch(`https://registry.npmjs.org/-/package/${packageName}/dist-tags`);
81
+ if (!distTagsResponse.ok) {
82
+ throw new Error(`Failed to fetch versions for ${packageName}: ${distTagsResponse.statusText}`);
83
+ }
84
+ const distTags = await distTagsResponse.json();
85
+ const tagged = distTags[versionOrTag];
86
+ if (typeof tagged === 'string') {
87
+ return tagged;
76
88
  }
77
- const data = await response.json();
78
- if (typeof data.latest !== 'string') {
79
- throw new Error(`Invalid version data received for ${packageName}`);
89
+ // Not a dist-tag — treat as an explicit version and verify it's published.
90
+ const versionResponse = await fetch(`https://registry.npmjs.org/${packageName}/${versionOrTag}`);
91
+ if (versionResponse.ok) {
92
+ return versionOrTag;
80
93
  }
81
- return data.latest;
94
+ throw new Error(`No "${versionOrTag}" version or dist-tag published for ${packageName}. Available dist-tags: ${Object.keys(distTags).join(', ')}`);
82
95
  }
83
96
  /**
84
97
  * Replace workspace versions in package.json with actual versions
85
98
  *
86
99
  * @param packageJson - Package JSON object to update
87
- * @param latestVersion - Latest Payload version to use
88
- */ function replaceWorkspaceVersions(packageJson, latestVersion) {
100
+ * @param coreVersion - Resolved core Payload version to use
101
+ */ function replaceWorkspaceVersions(packageJson, coreVersion, figmaVersion) {
89
102
  const deps = packageJson.dependencies;
90
103
  if (!deps) {
91
104
  return;
92
105
  }
93
106
  for (const [key, value] of Object.entries(deps)){
94
- // Replace workspace:* or workspace:^ with actual version
95
- if (typeof value === 'string' && value.startsWith('workspace:')) {
96
- deps[key] = latestVersion;
107
+ if (key === '@payloadcms/figma') {
108
+ deps[key] = figmaVersion;
109
+ } else if (typeof value === 'string' && value.startsWith('workspace:')) {
110
+ deps[key] = coreVersion;
97
111
  } else if (key === 'payload' || key.startsWith('@payloadcms/')) {
98
- deps[key] = latestVersion;
112
+ deps[key] = coreVersion;
99
113
  }
100
114
  }
101
- // Also handle devDependencies if present
102
115
  const devDeps = packageJson.devDependencies;
103
116
  if (!devDeps) {
104
117
  return;
105
118
  }
106
119
  for (const [key, value] of Object.entries(devDeps)){
107
- if (typeof value === 'string' && value.startsWith('workspace:')) {
108
- devDeps[key] = latestVersion;
120
+ if (key === '@payloadcms/figma') {
121
+ devDeps[key] = figmaVersion;
122
+ } else if (typeof value === 'string' && value.startsWith('workspace:')) {
123
+ devDeps[key] = coreVersion;
109
124
  } else if (key === 'payload' || key.startsWith('@payloadcms/')) {
110
- devDeps[key] = latestVersion;
125
+ devDeps[key] = coreVersion;
111
126
  }
112
127
  }
113
128
  }
@@ -116,18 +131,24 @@ import { applyLambdaModifications } from './lambda-config.js';
116
131
  *
117
132
  * @param projectPath - Path where to create the project
118
133
  * @param projectName - Name for the project
119
- */ export async function scaffoldProject(projectPath, projectName) {
134
+ * @param packageManager - Package manager to use
135
+ * @param templateSource - Optional template source override
136
+ * @param payloadVersion - npm dist-tag or explicit version for core payload packages (default 'canary')
137
+ */ export async function scaffoldProject(projectPath, projectName, packageManager = 'npm', templateSource, payloadVersion = 'canary') {
120
138
  // Create project directory if it doesn't exist
121
139
  await fs.mkdir(projectPath, {
122
140
  recursive: true
123
141
  });
124
142
  // Download template from GitHub
125
- await downloadTemplateFromGitHub(projectPath);
143
+ await downloadTemplateFromGitHub(projectPath, templateSource);
126
144
  // Apply Lambda modifications BEFORE updating package.json
127
145
  // This ensures we don't overwrite version replacements
128
- await applyLambdaModifications(projectPath);
129
- // Get latest Payload version from npm
130
- const latestVersion = await getLatestPackageVersion('payload');
146
+ await applyLambdaModifications(projectPath, packageManager);
147
+ // Resolve core Payload version from the selected dist-tag or version; figma uses CLI version
148
+ const [coreVersion, figmaVersion] = await Promise.all([
149
+ resolvePackageVersion('payload', payloadVersion),
150
+ getOwnVersion()
151
+ ]);
131
152
  // Delete any existing lock files from template (they reference workspace:* versions)
132
153
  // This ensures pnpm install creates a fresh lock file with actual versions
133
154
  const lockFiles = [
@@ -149,16 +170,24 @@ import { applyLambdaModifications } from './lambda-config.js';
149
170
  const packageJson = JSON.parse(packageJsonContent);
150
171
  packageJson.name = projectName;
151
172
  // Replace workspace:* versions with actual versions
152
- replaceWorkspaceVersions(packageJson, latestVersion);
173
+ replaceWorkspaceVersions(packageJson, coreVersion, figmaVersion);
153
174
  await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n', 'utf-8');
154
- // Manage environment files (generate PAYLOAD_SECRET)
155
- await manageEnvFiles(projectPath);
156
175
  // Ensure .gitignore has required entries
176
+ // Note: .env file is created by init command with FIGMA_CONTENT_API_CONTENT_SYSTEM_ID
157
177
  await ensureGitignore(projectPath, [
158
178
  '.env',
159
179
  '.env.local',
160
180
  'lambda.zip'
161
181
  ]);
182
+ // Replace README with Figma-specific version
183
+ const readmeTemplatePath = fileURLToPath(new URL('../templates/README.md', import.meta.url));
184
+ let readmeContent = await fs.readFile(readmeTemplatePath, 'utf-8');
185
+ readmeContent = readmeContent.replace(/\{\{PROJECT_NAME\}\}/g, projectName);
186
+ readmeContent = readmeContent.replace(/\{\{RUN_COMMAND\}\}/g, getRunCommand(packageManager));
187
+ await fs.writeFile(path.join(projectPath, 'README.md'), readmeContent, 'utf-8');
188
+ // Copy .env.example template
189
+ const envExampleTemplatePath = fileURLToPath(new URL('../templates/.env.example', import.meta.url));
190
+ await fs.copyFile(envExampleTemplatePath, path.join(projectPath, '.env.example'));
162
191
  }
163
192
  /**
164
193
  * Initialize git repository after all setup is complete
@@ -181,7 +210,6 @@ import { applyLambdaModifications } from './lambda-config.js';
181
210
  'install'
182
211
  ], {
183
212
  cwd: projectPath,
184
- shell: true,
185
213
  stdio: 'pipe'
186
214
  });
187
215
  let stdout = '';
@@ -246,5 +274,3 @@ import { applyLambdaModifications } from './lambda-config.js';
246
274
  return false;
247
275
  }
248
276
  }
249
-
250
- //# sourceMappingURL=project.js.map
@@ -0,0 +1,13 @@
1
+ import type { BootstrapEnvironment } from '../api/control-plane.js';
2
+ /**
3
+ * Resolve which environment to use from the bootstrap response.
4
+ *
5
+ * - Single environment: auto-select (environmentName optional, validated if provided)
6
+ * - Multiple environments: environmentName required, must match
7
+ *
8
+ * @throws Error if resolution fails (with available environment names)
9
+ */
10
+ export declare function resolveEnvironment(params: {
11
+ environmentName?: string;
12
+ environments: BootstrapEnvironment[];
13
+ }): BootstrapEnvironment;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Resolve which environment to use from the bootstrap response.
3
+ *
4
+ * - Single environment: auto-select (environmentName optional, validated if provided)
5
+ * - Multiple environments: environmentName required, must match
6
+ *
7
+ * @throws Error if resolution fails (with available environment names)
8
+ */ export function resolveEnvironment(params) {
9
+ const { environmentName, environments } = params;
10
+ if (environments.length === 0) {
11
+ throw new Error('No environments found for this project.');
12
+ }
13
+ if (environments.length === 1) {
14
+ if (environmentName && environments[0].name !== environmentName) {
15
+ throw new Error(`Environment "${environmentName}" not found. Available: ${environments[0].name}`);
16
+ }
17
+ return environments[0];
18
+ }
19
+ // Multiple environments — name required
20
+ const availableNames = environments.map((e)=>e.name).join(', ');
21
+ if (!environmentName) {
22
+ throw new Error(`Multiple environments available. Use --env to specify one: ${availableNames}`);
23
+ }
24
+ const matched = environments.find((e)=>e.name === environmentName);
25
+ if (!matched) {
26
+ throw new Error(`Environment "${environmentName}" not found. Available: ${availableNames}`);
27
+ }
28
+ return matched;
29
+ }
@@ -18,7 +18,6 @@ export interface UploadResults {
18
18
  *
19
19
  * @param filePath - Absolute path to file to upload
20
20
  * @param signedUrl - Signed S3 upload URL
21
- * @param contentType - MIME type (optional)
22
21
  * @throws Error if upload fails after retries
23
22
  */
24
23
  export declare function uploadFile(filePath: string, signedUrl: string, contentType?: string): Promise<void>;
@@ -39,5 +38,10 @@ export declare function uploadLambdaZip(zipPath: string, signedUrl: string): Pro
39
38
  * @param onProgress - Optional callback for progress updates (uploaded, total)
40
39
  * @returns Upload results with counts
41
40
  */
42
- export declare function uploadStaticAssets(projectPath: string, assetUrls: Record<string, string>, onProgress?: (uploaded: number, total: number) => void): Promise<UploadResults>;
43
- //# sourceMappingURL=s3-upload.d.ts.map
41
+ export declare function uploadStaticAssets(params: {
42
+ assetUrls: Record<string, string>;
43
+ onProgress?: (uploaded: number, total: number) => void;
44
+ /** Map of S3 key → relative filesystem path (overrides default _next/ → .next/ resolution) */
45
+ pathMap?: Record<string, string>;
46
+ projectPath: string;
47
+ }): Promise<UploadResults>;
@@ -1,5 +1,6 @@
1
1
  import fs from 'fs/promises';
2
2
  import path from 'path';
3
+ import { parseS3Error } from '../api/error-response.js';
3
4
  import * as log from './log.js';
4
5
  /**
5
6
  * Retry configuration
@@ -11,6 +12,37 @@ const INITIAL_RETRY_DELAY = 1000 // 1 second
11
12
  */ function sleep(ms) {
12
13
  return new Promise((resolve)=>setTimeout(resolve, ms));
13
14
  }
15
+ /** Common MIME types for web assets, keyed by file extension */ const MIME_TYPES = {
16
+ '.avif': 'image/avif',
17
+ '.css': 'text/css',
18
+ '.csv': 'text/csv',
19
+ '.eot': 'application/vnd.ms-fontobject',
20
+ '.gif': 'image/gif',
21
+ '.html': 'text/html',
22
+ '.ico': 'image/x-icon',
23
+ '.jpeg': 'image/jpeg',
24
+ '.jpg': 'image/jpeg',
25
+ '.js': 'application/javascript',
26
+ '.json': 'application/json',
27
+ '.map': 'application/json',
28
+ '.meta': 'application/json',
29
+ '.mjs': 'application/javascript',
30
+ '.mp4': 'video/mp4',
31
+ '.otf': 'font/otf',
32
+ '.pdf': 'application/pdf',
33
+ '.png': 'image/png',
34
+ '.rsc': 'text/x-component',
35
+ '.svg': 'image/svg+xml',
36
+ '.ttf': 'font/ttf',
37
+ '.txt': 'text/plain',
38
+ '.wasm': 'application/wasm',
39
+ '.webm': 'video/webm',
40
+ '.webp': 'image/webp',
41
+ '.woff': 'font/woff',
42
+ '.woff2': 'font/woff2',
43
+ '.xml': 'application/xml',
44
+ '.zip': 'application/zip'
45
+ };
14
46
  /**
15
47
  * Check if a signed URL is a mock URL
16
48
  */ function isMockUrl(signedUrl) {
@@ -23,7 +55,6 @@ const INITIAL_RETRY_DELAY = 1000 // 1 second
23
55
  *
24
56
  * @param filePath - Absolute path to file to upload
25
57
  * @param signedUrl - Signed S3 upload URL
26
- * @param contentType - MIME type (optional)
27
58
  * @throws Error if upload fails after retries
28
59
  */ export async function uploadFile(filePath, signedUrl, contentType) {
29
60
  // Skip actual upload for mock URLs
@@ -45,17 +76,22 @@ const INITIAL_RETRY_DELAY = 1000 // 1 second
45
76
  let lastError = null;
46
77
  for(let attempt = 0; attempt < MAX_RETRIES; attempt++){
47
78
  try {
79
+ const ext = path.extname(filePath).toLowerCase();
80
+ const determinedContentType = contentType ?? MIME_TYPES[ext];
48
81
  const response = await fetch(signedUrl, {
49
82
  body: fileBuffer,
50
- headers: contentType ? {
51
- 'Content-Type': contentType
83
+ headers: determinedContentType ? {
84
+ 'Content-Type': determinedContentType
52
85
  } : {},
53
86
  method: 'PUT'
54
87
  });
55
88
  if (response.ok) {
56
89
  return; // Success
57
90
  }
58
- lastError = new Error(`Upload failed: ${response.status} ${response.statusText}`);
91
+ lastError = new Error(await parseS3Error({
92
+ context: `upload ${path.basename(filePath)}`,
93
+ response
94
+ }));
59
95
  } catch (error) {
60
96
  lastError = error instanceof Error ? error : new Error('Unknown error');
61
97
  }
@@ -83,7 +119,8 @@ const INITIAL_RETRY_DELAY = 1000 // 1 second
83
119
  * @param assetUrls - Map of asset paths to signed URLs
84
120
  * @param onProgress - Optional callback for progress updates (uploaded, total)
85
121
  * @returns Upload results with counts
86
- */ export async function uploadStaticAssets(projectPath, assetUrls, onProgress) {
122
+ */ export async function uploadStaticAssets(params) {
123
+ const { assetUrls, onProgress, pathMap, projectPath } = params;
87
124
  const results = {
88
125
  assetsFailed: 0,
89
126
  assetsUploaded: 0,
@@ -100,8 +137,8 @@ const INITIAL_RETRY_DELAY = 1000 // 1 second
100
137
  const batch = assetPaths.slice(i, i + CONCURRENCY);
101
138
  await Promise.all(batch.map(async (assetPath)=>{
102
139
  try {
103
- // Convert _next back to .next for file system
104
- const fsPath = assetPath.replace(/^_next\//, '.next/');
140
+ // Resolve filesystem path: use pathMap if available, else default _next/ → .next/
141
+ const fsPath = pathMap?.[assetPath] ?? assetPath.replace(/^_next\//, '.next/');
105
142
  const fullPath = path.join(projectPath, fsPath);
106
143
  const signedUrl = assetUrls[assetPath];
107
144
  await uploadFile(fullPath, signedUrl);
@@ -119,5 +156,3 @@ const INITIAL_RETRY_DELAY = 1000 // 1 second
119
156
  }
120
157
  return results;
121
158
  }
122
-
123
- //# sourceMappingURL=s3-upload.js.map
@@ -8,7 +8,10 @@ export declare function maskToken(token: string): string;
8
8
  */
9
9
  export declare function formatTimestamp(timestamp: number): string;
10
10
  /**
11
- * Show all stored project tokens
11
+ * Show the project token for the current project + environment scope.
12
+ *
13
+ * Resolves `projectId` and `environmentName` from env vars
14
+ * (`FIGMA_PROJECT_ID`, `FIGMA_ENVIRONMENT_NAME`) — the *user's* project
15
+ * environment, which is independent of the infra env (production/staging).
12
16
  */
13
17
  export declare function showProjectTokens(tokenStore: TokenStore): void;
14
- //# sourceMappingURL=token-display.d.ts.map
@@ -1,5 +1,6 @@
1
1
  import * as p from '@clack/prompts';
2
2
  import pc from 'picocolors';
3
+ import { getEnvVarSync } from './env-management.js';
3
4
  import { isDebug } from './is-debug.js';
4
5
  /**
5
6
  * Mask token for display (show first 4 and last 4 characters)
@@ -32,32 +33,56 @@ import { isDebug } from './is-debug.js';
32
33
  return pc.red(`${minutes}m`);
33
34
  }
34
35
  /**
35
- * Show all stored project tokens
36
+ * Show the project token for the current project + environment scope.
37
+ *
38
+ * Resolves `projectId` and `environmentName` from env vars
39
+ * (`FIGMA_PROJECT_ID`, `FIGMA_ENVIRONMENT_NAME`) — the *user's* project
40
+ * environment, which is independent of the infra env (production/staging).
36
41
  */ export function showProjectTokens(tokenStore) {
37
- // Get all tenant IDs that have project tokens
38
- const tenantIds = tokenStore.getAllProjectTokenTenantIds();
39
- if (tenantIds.length === 0) {
40
- p.log.step(pc.dim('No project tokens stored.'));
41
- p.note(`Run ${pc.cyan('@payloadcms/figma init')} to create a CMS instance`, 'Tip');
42
+ const cwd = process.cwd();
43
+ const projectId = getEnvVarSync(cwd, 'FIGMA_PROJECT_ID');
44
+ const environmentName = getEnvVarSync(cwd, 'FIGMA_ENVIRONMENT_NAME');
45
+ if (!projectId || !environmentName) {
46
+ p.note(pc.dim('Set FIGMA_PROJECT_ID and FIGMA_ENVIRONMENT_NAME in your .env to view project tokens.'), 'Project Tokens');
42
47
  return;
43
48
  }
44
- const projectTokenLines = [];
45
- tenantIds.forEach((tenantId, index)=>{
46
- const projectToken = tokenStore.getProjectToken(tenantId);
47
- if (!projectToken) {
48
- return;
49
- }
50
- const isValid = tokenStore.hasValidProjectToken(tenantId);
51
- const status = isValid ? pc.green('✓ Valid') : pc.red('✗ Expired');
52
- if (index > 0) {
53
- projectTokenLines.push(''); // Blank line between tokens
54
- }
55
- projectTokenLines.push(`Tenant ID: ${tenantId}`);
56
- projectTokenLines.push(`Status: ${status}`);
57
- projectTokenLines.push(`Token: ${isDebug() ? projectToken.token : maskToken(projectToken.token)}`);
58
- projectTokenLines.push(`Expires: ${formatTimestamp(projectToken.expiresAt)}`);
49
+ const header = [
50
+ `Project ID: ${projectId}`,
51
+ `Environment: ${environmentName}`
52
+ ];
53
+ const bootstrapData = tokenStore.getBootstrapData(projectId, environmentName);
54
+ if (!bootstrapData) {
55
+ p.note([
56
+ ...header,
57
+ pc.dim('No bootstrap data. Run `@payloadcms/figma init` to set up.')
58
+ ].join('\n'), 'Project Token');
59
+ return;
60
+ }
61
+ const projectInfo = {
62
+ environmentName,
63
+ projectId
64
+ };
65
+ const projectToken = tokenStore.getProjectToken({
66
+ projectInfo
67
+ });
68
+ if (!projectToken) {
69
+ p.note([
70
+ ...header,
71
+ `Tenant ID: ${bootstrapData.contentSystemId}`,
72
+ pc.dim('No stored token.')
73
+ ].join('\n'), 'Project Token');
74
+ return;
75
+ }
76
+ const isValid = tokenStore.hasValidProjectToken({
77
+ projectInfo
59
78
  });
60
- p.note(projectTokenLines.join('\n'), `Project Tokens (${tenantIds.length})`);
79
+ const status = isValid ? pc.green('✓ Valid') : pc.red('✗ Expired');
80
+ const projectTokenLines = [
81
+ ...header,
82
+ `Tenant ID: ${bootstrapData.contentSystemId}`,
83
+ `Status: ${status}`,
84
+ `Token: ${isDebug() ? projectToken.token : maskToken(projectToken.token)}`,
85
+ `Expires: ${formatTimestamp(projectToken.expiresAt)}`
86
+ ];
87
+ p.note(projectTokenLines.join('\n'), 'Project Token');
61
88
  }
62
-
63
- //# sourceMappingURL=token-display.js.map
@@ -8,4 +8,3 @@ export type TypeScriptCheckResult = {
8
8
  * Skips silently if TypeScript not available
9
9
  */
10
10
  export declare function runTypeScriptCheck(projectPath: string, packageManager: PackageManager): Promise<TypeScriptCheckResult>;
11
- //# sourceMappingURL=typescript-validator.d.ts.map
@@ -1,18 +1,16 @@
1
- import { spawn } from 'child_process';
1
+ import spawn from 'cross-spawn';
2
2
  /**
3
3
  * Run TypeScript type checking (tsc --noEmit)
4
4
  * Skips silently if TypeScript not available
5
5
  */ export async function runTypeScriptCheck(projectPath, packageManager) {
6
6
  return new Promise((resolve)=>{
7
7
  try {
8
- const args = [
8
+ const child = spawn(packageManager, [
9
9
  'exec',
10
10
  'tsc',
11
11
  '--noEmit'
12
- ];
13
- const child = spawn(packageManager, args, {
12
+ ], {
14
13
  cwd: projectPath,
15
- shell: true,
16
14
  stdio: 'pipe'
17
15
  });
18
16
  let output = '';
@@ -52,7 +50,5 @@ import { spawn } from 'child_process';
52
50
  /**
53
51
  * Parse TypeScript error output
54
52
  */ function parseTypeScriptErrors(output) {
55
- return output.split('\n').filter((line)=>line.includes('error TS')).map((line)=>line.trim());
53
+ return output.split(/\r?\n/).filter((line)=>line.includes('error TS')).map((line)=>line.trim());
56
54
  }
57
-
58
- //# sourceMappingURL=typescript-validator.js.map
@@ -0,0 +1,2 @@
1
+ export declare function checkForUpdates(currentVersion: string): Promise<void>;
2
+ export declare function getOwnVersion(): Promise<string>;
@@ -0,0 +1,43 @@
1
+ import * as p from '@clack/prompts';
2
+ import fs from 'fs/promises';
3
+ import path from 'path';
4
+ import pc from 'picocolors';
5
+ import { fileURLToPath } from 'url';
6
+ const REGISTRY_URL = 'https://registry.npmjs.org/@payloadcms/figma';
7
+ const TIMEOUT_MS = 3000;
8
+ export async function checkForUpdates(currentVersion) {
9
+ try {
10
+ const controller = new AbortController();
11
+ const timeoutId = setTimeout(()=>controller.abort(), TIMEOUT_MS);
12
+ const response = await fetch(REGISTRY_URL, {
13
+ signal: controller.signal
14
+ });
15
+ clearTimeout(timeoutId);
16
+ if (!response.ok) {
17
+ return;
18
+ }
19
+ const data = await response.json();
20
+ const latestVersion = data['dist-tags']?.latest;
21
+ if (!latestVersion || latestVersion === currentVersion) {
22
+ return;
23
+ }
24
+ p.log.warn(pc.yellow(`@payloadcms/figma ${currentVersion} differs from latest. Latest: ${latestVersion}`));
25
+ p.log.message(pc.dim(` Run: npx @payloadcms/figma@${latestVersion} init --id <your-id>`));
26
+ } catch {
27
+ // Silent catch - network errors, timeouts, parse errors should not interrupt CLI
28
+ }
29
+ }
30
+ export async function getOwnVersion() {
31
+ // Test/CI seam: e2e runs scaffold with the CLI's own version, but a locally
32
+ // built (unpublished) version isn't npm-resolvable. Allow overriding with a
33
+ // published version so `init`'s dependency install resolves.
34
+ const override = process.env.FIGMA_CLI_VERSION_OVERRIDE;
35
+ if (override) {
36
+ return override;
37
+ }
38
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
39
+ const packageJsonPath = path.join(__dirname, '../../package.json');
40
+ const content = await fs.readFile(packageJsonPath, 'utf-8');
41
+ const pkg = JSON.parse(content);
42
+ return pkg.version;
43
+ }