@payloadcms/figma 0.0.1-alpha.6 → 0.0.1-alpha.61

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 (352) hide show
  1. package/dist/api/control-plane.d.ts +52 -6
  2. package/dist/api/control-plane.js +174 -72
  3. package/dist/api/figma-api.d.ts +22 -1
  4. package/dist/api/figma-api.js +78 -25
  5. package/dist/auth/callback-server.js +2 -1
  6. package/dist/auth/credentials.d.ts +21 -0
  7. package/dist/auth/credentials.js +21 -0
  8. package/dist/auth/crypto-utils.d.ts +6 -0
  9. package/dist/auth/crypto-utils.js +16 -14
  10. package/dist/auth/jwt-validator.d.ts +2 -1
  11. package/dist/auth/jwt-validator.js +2 -2
  12. package/dist/auth/oauth-flow.d.ts +17 -3
  13. package/dist/auth/oauth-flow.js +63 -16
  14. package/dist/auth/project-token.js +16 -11
  15. package/dist/auth/refresh.d.ts +2 -1
  16. package/dist/auth/refresh.js +25 -12
  17. package/dist/auth/token-store.d.ts +42 -1
  18. package/dist/auth/token-store.js +118 -14
  19. package/dist/auth/types.d.ts +17 -4
  20. package/dist/cli.js +68 -5
  21. package/dist/commands/build-lambda-zip.d.ts +5 -0
  22. package/dist/commands/build-lambda-zip.js +19 -0
  23. package/dist/commands/debug.d.ts +8 -0
  24. package/dist/commands/debug.js +176 -0
  25. package/dist/commands/deploy.d.ts +9 -0
  26. package/dist/commands/deploy.js +178 -151
  27. package/dist/commands/env.d.ts +13 -0
  28. package/dist/commands/env.js +88 -0
  29. package/dist/commands/init.d.ts +3 -5
  30. package/dist/commands/init.js +165 -148
  31. package/dist/commands/list-tokens.d.ts +3 -3
  32. package/dist/commands/list-tokens.js +22 -7
  33. package/dist/commands/login.d.ts +8 -1
  34. package/dist/commands/login.js +33 -15
  35. package/dist/commands/logout.d.ts +5 -4
  36. package/dist/commands/logout.js +56 -13
  37. package/dist/commands/upgrade.d.ts +5 -0
  38. package/dist/commands/upgrade.js +331 -0
  39. package/dist/config/oauth.d.ts +4 -14
  40. package/dist/config/oauth.js +18 -40
  41. package/dist/constants.d.ts +44 -19
  42. package/dist/constants.js +73 -20
  43. package/dist/db-content-api/README.md +98 -0
  44. package/dist/db-content-api/generated/content-api-types.d.ts +3972 -0
  45. package/dist/db-content-api/generated/content-api-types.js +7 -0
  46. package/dist/db-content-api/index.d.ts +21 -0
  47. package/dist/db-content-api/index.js +914 -0
  48. package/dist/db-content-api/temp-utilities/slug.d.ts +2 -0
  49. package/dist/db-content-api/temp-utilities/slug.js +3 -0
  50. package/dist/db-content-api/temp-utilities/sorting.d.ts +3 -0
  51. package/dist/db-content-api/temp-utilities/sorting.js +39 -0
  52. package/dist/db-content-api/temp-utilities/types.d.ts +22 -0
  53. package/dist/db-content-api/temp-utilities/types.js +15 -0
  54. package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +39 -0
  55. package/dist/db-content-api/temp-utilities/unwrapDocument.js +59 -0
  56. package/dist/db-content-api/utilities/auth.d.ts +30 -0
  57. package/dist/db-content-api/utilities/auth.js +81 -0
  58. package/dist/db-content-api/utilities/data/applyDefaults.d.ts +7 -0
  59. package/dist/db-content-api/utilities/data/applyDefaults.js +75 -0
  60. package/dist/db-content-api/utilities/data/castFieldValue.d.ts +11 -0
  61. package/dist/db-content-api/utilities/data/castFieldValue.js +68 -0
  62. package/dist/db-content-api/utilities/data/index.d.ts +49 -0
  63. package/dist/db-content-api/utilities/data/index.js +301 -0
  64. package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +12 -0
  65. package/dist/db-content-api/utilities/data/removeVirtualFields.js +54 -0
  66. package/dist/db-content-api/utilities/data/stripFields.d.ts +48 -0
  67. package/dist/db-content-api/utilities/data/stripFields.js +195 -0
  68. package/dist/db-content-api/utilities/data/transformPublishedLocale.d.ts +23 -0
  69. package/dist/db-content-api/utilities/data/transformPublishedLocale.js +42 -0
  70. package/dist/db-content-api/utilities/joins.d.ts +53 -0
  71. package/dist/db-content-api/utilities/joins.js +139 -0
  72. package/dist/db-content-api/utilities/locale/index.d.ts +10 -0
  73. package/dist/db-content-api/utilities/locale/index.js +21 -0
  74. package/dist/db-content-api/utilities/meta/buildLocalizedPaths.d.ts +11 -0
  75. package/dist/db-content-api/utilities/meta/buildLocalizedPaths.js +74 -0
  76. package/dist/db-content-api/utilities/meta/buildMeta.d.ts +42 -0
  77. package/dist/db-content-api/utilities/meta/buildMeta.js +41 -0
  78. package/dist/db-content-api/utilities/meta/buildPathTypes.d.ts +17 -0
  79. package/dist/db-content-api/utilities/meta/buildPathTypes.js +244 -0
  80. package/dist/db-content-api/utilities/meta/buildUniquePaths.d.ts +13 -0
  81. package/dist/db-content-api/utilities/meta/buildUniquePaths.js +62 -0
  82. package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.d.ts +10 -0
  83. package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.js +102 -0
  84. package/dist/db-content-api/utilities/where.d.ts +20 -0
  85. package/dist/db-content-api/utilities/where.js +108 -0
  86. package/dist/deploy/schedule-extract-plugin.d.ts +11 -0
  87. package/dist/deploy/schedule-extract-plugin.js +34 -0
  88. package/dist/endpoints/health.d.ts +3 -0
  89. package/dist/endpoints/health.js +11 -0
  90. package/dist/endpoints/schema.d.ts +3 -0
  91. package/dist/endpoints/schema.js +29 -0
  92. package/dist/exports/client.d.ts +3 -0
  93. package/dist/exports/client.js +3 -0
  94. package/dist/index.d.ts +2 -1
  95. package/dist/index.js +3 -1
  96. package/dist/oauth/components/FigmaAvatar/index.d.ts +4 -0
  97. package/dist/oauth/components/FigmaAvatar/index.js +27 -0
  98. package/dist/oauth/components/FigmaAvatar/index.scss +12 -0
  99. package/dist/oauth/components/FigmaAvatarCell/index.d.ts +5 -0
  100. package/dist/oauth/components/FigmaAvatarCell/index.js +25 -0
  101. package/dist/oauth/components/FigmaAvatarCell/index.scss +5 -0
  102. package/dist/oauth/components/FigmaAvatarPlaceholder/index.d.ts +9 -0
  103. package/dist/oauth/components/FigmaAvatarPlaceholder/index.js +37 -0
  104. package/dist/oauth/components/FigmaAvatarPlaceholder/index.scss +28 -0
  105. package/dist/oauth/components/LoginButton/index.js +50 -6
  106. package/dist/oauth/components/LoginButton/index.scss +50 -3
  107. package/dist/oauth/components/LogoutButton/index.js +5 -4
  108. package/dist/oauth/defaults.js +67 -10
  109. package/dist/oauth/endpoints/getLoginEndpoint.js +77 -24
  110. package/dist/oauth/endpoints/getLogoutEndpoint.js +7 -4
  111. package/dist/oauth/index.js +40 -13
  112. package/dist/oauth/strategy/index.d.ts +0 -2
  113. package/dist/oauth/strategy/index.js +40 -17
  114. package/dist/oauth/types.d.ts +6 -6
  115. package/dist/oauth/utilities/isDuplicateKeyError.d.ts +7 -0
  116. package/dist/oauth/utilities/isDuplicateKeyError.js +14 -0
  117. package/dist/oauth/utilities/refreshTokens.js +6 -3
  118. package/dist/plugin/build-config.d.ts +18 -15
  119. package/dist/plugin/build-config.js +213 -18
  120. package/dist/storage-content-api/api-types.d.ts +168 -0
  121. package/dist/storage-content-api/api-types.js +6 -0
  122. package/dist/storage-content-api/client-uploads/ClientUploadHandler.d.ts +9 -0
  123. package/dist/storage-content-api/client-uploads/ClientUploadHandler.js +42 -0
  124. package/dist/storage-content-api/client-uploads/generateSignedURL.d.ts +13 -0
  125. package/dist/storage-content-api/client-uploads/generateSignedURL.js +39 -0
  126. package/dist/storage-content-api/client.d.ts +6 -0
  127. package/dist/storage-content-api/client.js +36 -0
  128. package/dist/storage-content-api/generateURL.d.ts +7 -0
  129. package/dist/storage-content-api/generateURL.js +8 -0
  130. package/dist/storage-content-api/handleDelete.d.ts +8 -0
  131. package/dist/storage-content-api/handleDelete.js +17 -0
  132. package/dist/storage-content-api/handleUpload.d.ts +11 -0
  133. package/dist/storage-content-api/handleUpload.js +144 -0
  134. package/dist/storage-content-api/index.d.ts +5 -0
  135. package/dist/storage-content-api/index.js +31 -0
  136. package/dist/storage-content-api/staticHandler.d.ts +10 -0
  137. package/dist/storage-content-api/staticHandler.js +56 -0
  138. package/dist/storage-content-api/types.d.ts +10 -0
  139. package/dist/storage-content-api/types.js +3 -0
  140. package/dist/storage-content-api/utilities/getSafeFilename.d.ts +12 -0
  141. package/dist/storage-content-api/utilities/getSafeFilename.js +61 -0
  142. package/dist/storage-content-api/utilities/index.d.ts +2 -0
  143. package/dist/storage-content-api/utilities/index.js +3 -0
  144. package/dist/templates/.env.example +5 -0
  145. package/dist/templates/README.md +19 -0
  146. package/dist/types/config.d.ts +2 -1
  147. package/dist/types/config.js +0 -2
  148. package/dist/types.d.ts +8 -1
  149. package/dist/utils/adapters/nextjs.d.ts +9 -0
  150. package/dist/utils/adapters/nextjs.js +64 -0
  151. package/dist/utils/adapters/nitro.d.ts +9 -0
  152. package/dist/utils/adapters/nitro.js +169 -0
  153. package/dist/utils/adapters/vite.d.ts +10 -0
  154. package/dist/utils/adapters/vite.js +33 -0
  155. package/dist/utils/asset-collection.d.ts +27 -6
  156. package/dist/utils/asset-collection.js +59 -30
  157. package/dist/utils/build-detection.d.ts +5 -11
  158. package/dist/utils/build-detection.js +74 -11
  159. package/dist/utils/build-lambda-zip.d.ts +14 -0
  160. package/dist/utils/build-lambda-zip.js +81 -0
  161. package/dist/utils/cache-bootstrap.d.ts +8 -0
  162. package/dist/utils/cache-bootstrap.js +18 -0
  163. package/dist/utils/config.js +1 -1
  164. package/dist/utils/deploy-adapter.d.ts +40 -0
  165. package/dist/utils/deploy-adapter.js +58 -0
  166. package/dist/utils/download-template.js +3 -2
  167. package/dist/utils/env-management.d.ts +24 -7
  168. package/dist/utils/env-management.js +119 -64
  169. package/dist/utils/format-env-suffix.d.ts +12 -0
  170. package/dist/utils/format-env-suffix.js +13 -0
  171. package/dist/utils/formatter.js +23 -11
  172. package/dist/utils/fs-utils.d.ts +6 -0
  173. package/dist/utils/fs-utils.js +27 -0
  174. package/dist/utils/handle-upgrade.d.ts +9 -0
  175. package/dist/utils/handle-upgrade.js +41 -0
  176. package/dist/utils/lambda-config.d.ts +3 -1
  177. package/dist/utils/lambda-config.js +75 -78
  178. package/dist/utils/messages.d.ts +1 -2
  179. package/dist/utils/messages.js +29 -11
  180. package/dist/utils/package-manager.d.ts +24 -0
  181. package/dist/utils/package-manager.js +53 -0
  182. package/dist/utils/payload-config-ast.d.ts +27 -6
  183. package/dist/utils/payload-config-ast.js +106 -58
  184. package/dist/utils/payload-config-finder.d.ts +2 -2
  185. package/dist/utils/payload-config-finder.js +48 -9
  186. package/dist/utils/payload-config-modifier.d.ts +1 -1
  187. package/dist/utils/payload-config-modifier.js +70 -11
  188. package/dist/utils/payload-package-check.d.ts +12 -1
  189. package/dist/utils/payload-package-check.js +63 -5
  190. package/dist/utils/project.d.ts +3 -2
  191. package/dist/utils/project.js +29 -15
  192. package/dist/utils/resolve-environment.d.ts +14 -0
  193. package/dist/utils/resolve-environment.js +31 -0
  194. package/dist/utils/s3-upload.d.ts +7 -2
  195. package/dist/utils/s3-upload.js +39 -6
  196. package/dist/utils/token-display.js +11 -5
  197. package/dist/utils/typescript-validator.js +4 -6
  198. package/dist/utils/version-check.d.ts +3 -0
  199. package/dist/utils/version-check.js +38 -0
  200. package/package.json +33 -15
  201. package/dist/api/control-plane.d.ts.map +0 -1
  202. package/dist/api/control-plane.js.map +0 -1
  203. package/dist/api/figma-api.d.ts.map +0 -1
  204. package/dist/api/figma-api.js.map +0 -1
  205. package/dist/auth/browser.d.ts.map +0 -1
  206. package/dist/auth/browser.js.map +0 -1
  207. package/dist/auth/callback-server.d.ts.map +0 -1
  208. package/dist/auth/callback-server.js.map +0 -1
  209. package/dist/auth/crypto-utils.d.ts.map +0 -1
  210. package/dist/auth/crypto-utils.js.map +0 -1
  211. package/dist/auth/jwt-validator.d.ts.map +0 -1
  212. package/dist/auth/jwt-validator.js.map +0 -1
  213. package/dist/auth/oauth-flow.d.ts.map +0 -1
  214. package/dist/auth/oauth-flow.js.map +0 -1
  215. package/dist/auth/pkce.d.ts.map +0 -1
  216. package/dist/auth/pkce.js.map +0 -1
  217. package/dist/auth/project-token.d.ts.map +0 -1
  218. package/dist/auth/project-token.js.map +0 -1
  219. package/dist/auth/refresh.d.ts.map +0 -1
  220. package/dist/auth/refresh.js.map +0 -1
  221. package/dist/auth/token-store.d.ts.map +0 -1
  222. package/dist/auth/token-store.js.map +0 -1
  223. package/dist/auth/types.d.ts.map +0 -1
  224. package/dist/auth/types.js.map +0 -1
  225. package/dist/cli.d.ts.map +0 -1
  226. package/dist/cli.js.map +0 -1
  227. package/dist/commands/deploy.d.ts.map +0 -1
  228. package/dist/commands/deploy.js.map +0 -1
  229. package/dist/commands/init.d.ts.map +0 -1
  230. package/dist/commands/init.js.map +0 -1
  231. package/dist/commands/list-tokens.d.ts.map +0 -1
  232. package/dist/commands/list-tokens.js.map +0 -1
  233. package/dist/commands/login.d.ts.map +0 -1
  234. package/dist/commands/login.js.map +0 -1
  235. package/dist/commands/logout.d.ts.map +0 -1
  236. package/dist/commands/logout.js.map +0 -1
  237. package/dist/config/oauth.d.ts.map +0 -1
  238. package/dist/config/oauth.js.map +0 -1
  239. package/dist/constants.d.ts.map +0 -1
  240. package/dist/constants.js.map +0 -1
  241. package/dist/exports/client.d.ts.map +0 -1
  242. package/dist/exports/client.js.map +0 -1
  243. package/dist/index.d.ts.map +0 -1
  244. package/dist/index.js.map +0 -1
  245. package/dist/oauth/components/LoginButton/index.d.ts.map +0 -1
  246. package/dist/oauth/components/LoginButton/index.js.map +0 -1
  247. package/dist/oauth/components/LogoutButton/index.d.ts.map +0 -1
  248. package/dist/oauth/components/LogoutButton/index.js.map +0 -1
  249. package/dist/oauth/defaults.d.ts.map +0 -1
  250. package/dist/oauth/defaults.js.map +0 -1
  251. package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +0 -1
  252. package/dist/oauth/endpoints/getLoginEndpoint.js.map +0 -1
  253. package/dist/oauth/endpoints/getLogoutEndpoint.d.ts.map +0 -1
  254. package/dist/oauth/endpoints/getLogoutEndpoint.js.map +0 -1
  255. package/dist/oauth/endpoints/getMetaEndpoint.d.ts.map +0 -1
  256. package/dist/oauth/endpoints/getMetaEndpoint.js.map +0 -1
  257. package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts.map +0 -1
  258. package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js.map +0 -1
  259. package/dist/oauth/exports/client.d.ts.map +0 -1
  260. package/dist/oauth/exports/client.js.map +0 -1
  261. package/dist/oauth/hooks/afterLogout.d.ts.map +0 -1
  262. package/dist/oauth/hooks/afterLogout.js.map +0 -1
  263. package/dist/oauth/hooks/me.d.ts.map +0 -1
  264. package/dist/oauth/hooks/me.js.map +0 -1
  265. package/dist/oauth/hooks/refresh.d.ts.map +0 -1
  266. package/dist/oauth/hooks/refresh.js.map +0 -1
  267. package/dist/oauth/index.d.ts.map +0 -1
  268. package/dist/oauth/index.js.map +0 -1
  269. package/dist/oauth/strategy/index.d.ts.map +0 -1
  270. package/dist/oauth/strategy/index.js.map +0 -1
  271. package/dist/oauth/types.d.ts.map +0 -1
  272. package/dist/oauth/types.js.map +0 -1
  273. package/dist/oauth/utilities/clearCookie.d.ts.map +0 -1
  274. package/dist/oauth/utilities/clearCookie.js.map +0 -1
  275. package/dist/oauth/utilities/createCookieOptions.d.ts.map +0 -1
  276. package/dist/oauth/utilities/createCookieOptions.js.map +0 -1
  277. package/dist/oauth/utilities/createDebugLogger.d.ts.map +0 -1
  278. package/dist/oauth/utilities/createDebugLogger.js.map +0 -1
  279. package/dist/oauth/utilities/extractOrigin.d.ts.map +0 -1
  280. package/dist/oauth/utilities/extractOrigin.js.map +0 -1
  281. package/dist/oauth/utilities/getAdminCollectionSlug.d.ts.map +0 -1
  282. package/dist/oauth/utilities/getAdminCollectionSlug.js.map +0 -1
  283. package/dist/oauth/utilities/getAdminPath.d.ts +0 -8
  284. package/dist/oauth/utilities/getAdminPath.d.ts.map +0 -1
  285. package/dist/oauth/utilities/getAdminPath.js +0 -9
  286. package/dist/oauth/utilities/getAdminPath.js.map +0 -1
  287. package/dist/oauth/utilities/getAuthorizeURL.d.ts.map +0 -1
  288. package/dist/oauth/utilities/getAuthorizeURL.js.map +0 -1
  289. package/dist/oauth/utilities/getCookieExpiration.d.ts.map +0 -1
  290. package/dist/oauth/utilities/getCookieExpiration.js.map +0 -1
  291. package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts.map +0 -1
  292. package/dist/oauth/utilities/getSecondsFromTokenExp.js.map +0 -1
  293. package/dist/oauth/utilities/getTokenExp.d.ts.map +0 -1
  294. package/dist/oauth/utilities/getTokenExp.js.map +0 -1
  295. package/dist/oauth/utilities/getUsernameField.d.ts.map +0 -1
  296. package/dist/oauth/utilities/getUsernameField.js.map +0 -1
  297. package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts.map +0 -1
  298. package/dist/oauth/utilities/hasUserTokenPropsChanged.js.map +0 -1
  299. package/dist/oauth/utilities/mergeHeaders.d.ts.map +0 -1
  300. package/dist/oauth/utilities/mergeHeaders.js.map +0 -1
  301. package/dist/oauth/utilities/refreshTokens.d.ts.map +0 -1
  302. package/dist/oauth/utilities/refreshTokens.js.map +0 -1
  303. package/dist/plugin/adapter.d.ts.map +0 -1
  304. package/dist/plugin/adapter.js.map +0 -1
  305. package/dist/plugin/build-config.d.ts.map +0 -1
  306. package/dist/plugin/build-config.js.map +0 -1
  307. package/dist/types/config.d.ts.map +0 -1
  308. package/dist/types/config.js.map +0 -1
  309. package/dist/types.d.ts.map +0 -1
  310. package/dist/types.js.map +0 -1
  311. package/dist/utils/asset-collection.d.ts.map +0 -1
  312. package/dist/utils/asset-collection.js.map +0 -1
  313. package/dist/utils/build-detection.d.ts.map +0 -1
  314. package/dist/utils/build-detection.js.map +0 -1
  315. package/dist/utils/config.d.ts.map +0 -1
  316. package/dist/utils/config.js.map +0 -1
  317. package/dist/utils/download-template.d.ts.map +0 -1
  318. package/dist/utils/download-template.js.map +0 -1
  319. package/dist/utils/env-management.d.ts.map +0 -1
  320. package/dist/utils/env-management.js.map +0 -1
  321. package/dist/utils/format.d.ts.map +0 -1
  322. package/dist/utils/format.js.map +0 -1
  323. package/dist/utils/formatter.d.ts.map +0 -1
  324. package/dist/utils/formatter.js.map +0 -1
  325. package/dist/utils/git.d.ts.map +0 -1
  326. package/dist/utils/git.js.map +0 -1
  327. package/dist/utils/is-debug.d.ts.map +0 -1
  328. package/dist/utils/is-debug.js.map +0 -1
  329. package/dist/utils/lambda-config.d.ts.map +0 -1
  330. package/dist/utils/lambda-config.js.map +0 -1
  331. package/dist/utils/log.d.ts.map +0 -1
  332. package/dist/utils/log.js.map +0 -1
  333. package/dist/utils/messages.d.ts.map +0 -1
  334. package/dist/utils/messages.js.map +0 -1
  335. package/dist/utils/package-manager.d.ts.map +0 -1
  336. package/dist/utils/package-manager.js.map +0 -1
  337. package/dist/utils/payload-config-ast.d.ts.map +0 -1
  338. package/dist/utils/payload-config-ast.js.map +0 -1
  339. package/dist/utils/payload-config-finder.d.ts.map +0 -1
  340. package/dist/utils/payload-config-finder.js.map +0 -1
  341. package/dist/utils/payload-config-modifier.d.ts.map +0 -1
  342. package/dist/utils/payload-config-modifier.js.map +0 -1
  343. package/dist/utils/payload-package-check.d.ts.map +0 -1
  344. package/dist/utils/payload-package-check.js.map +0 -1
  345. package/dist/utils/project.d.ts.map +0 -1
  346. package/dist/utils/project.js.map +0 -1
  347. package/dist/utils/s3-upload.d.ts.map +0 -1
  348. package/dist/utils/s3-upload.js.map +0 -1
  349. package/dist/utils/token-display.d.ts.map +0 -1
  350. package/dist/utils/token-display.js.map +0 -1
  351. package/dist/utils/typescript-validator.d.ts.map +0 -1
  352. package/dist/utils/typescript-validator.js.map +0 -1
@@ -1,6 +1,26 @@
1
1
  /* eslint-disable perfectionist/sort-classes */ import Conf from 'conf';
2
+ import fsSync from 'node:fs';
2
3
  import { TOKEN_EXPIRY_BUFFER_SECONDS } from '../config/oauth.js';
4
+ import { getInfraEnvironment } from '../constants.js';
5
+ import * as log from '../utils/log.js';
3
6
  import { deriveEncryptionKey } from './crypto-utils.js';
7
+ /**
8
+ * Environment-keyed instances for singleton pattern
9
+ */ const instances = {};
10
+ /**
11
+ * Get the singleton TokenStore instance for an environment
12
+ * Use this for all production code to ensure a single shared instance per environment
13
+ *
14
+ * @param environment - The environment to get the token store for
15
+ * @returns The singleton TokenStore instance for that environment
16
+ */ export function getTokenStore(environment = getInfraEnvironment()) {
17
+ if (!instances[environment]) {
18
+ instances[environment] = new TokenStore({
19
+ environment
20
+ });
21
+ }
22
+ return instances[environment];
23
+ }
4
24
  /**
5
25
  * Secure storage manager for Figma OAuth2 tokens
6
26
  *
@@ -11,23 +31,62 @@ import { deriveEncryptionKey } from './crypto-utils.js';
11
31
  *
12
32
  * Tokens are encrypted at rest with a machine-specific key and file permissions
13
33
  * are set to 0600 (owner read/write only)
34
+ *
35
+ * For production code, use getTokenStore() to get the singleton instance.
36
+ * The constructor is still exported for test isolation.
14
37
  */ export class TokenStore {
15
38
  config;
39
+ environment;
16
40
  constructor(options){
17
- this.config = new Conf({
18
- configName: options?.configName || 'payloadcms-figma',
19
- projectName: 'payloadcms-figma',
20
- // Enable encryption with machine-specific key for better security
41
+ if (process.env.AWS_EXECUTION_ENV) {
42
+ throw new Error('TokenStore cannot be used in AWS Lambda environments');
43
+ }
44
+ const environment = options?.environment ?? 'production';
45
+ const projectName = environment === 'production' ? 'payloadcms-figma' : `payloadcms-figma-${environment}`;
46
+ this.environment = environment;
47
+ const confOptions = {
48
+ clearInvalidConfig: false,
49
+ configName: options?.configName || projectName,
21
50
  encryptionKey: options?.encryptionKey || deriveEncryptionKey(),
22
- // Clear schema to avoid validation issues
23
- clearInvalidConfig: true
24
- });
51
+ projectName
52
+ };
53
+ try {
54
+ this.config = new Conf(confOptions);
55
+ } catch (error) {
56
+ // Deserialization failed (e.g. encryption key changed).
57
+ // Log diagnostics, clear the corrupted file, then create a fresh store.
58
+ if (environment === 'staging') {
59
+ log.warning(`Token store corrupted, resetting. ` + `Error: ${error instanceof Error ? error.message : 'Unknown'}`);
60
+ }
61
+ // Temporarily allow clearing so Conf can reinitialize
62
+ this.config = new Conf({
63
+ ...confOptions,
64
+ clearInvalidConfig: true
65
+ });
66
+ // Force a write so the corrupt file is replaced with an empty store.
67
+ // Without this, clearInvalidConfig only ignores bad reads in memory
68
+ // and the corrupt file persists, triggering this fallback every time.
69
+ this.config.clear();
70
+ }
71
+ }
72
+ safeGet(key) {
73
+ try {
74
+ return this.config.get(key);
75
+ } catch (error) {
76
+ if (this.environment === 'staging') {
77
+ const filePath = this.config.path;
78
+ const fileExists = fsSync.existsSync(filePath);
79
+ const fileSize = fileExists ? fsSync.statSync(filePath).size : 0;
80
+ log.warning(`Token store read failed (key: ${key}). ` + `File: ${filePath}, exists: ${fileExists}, size: ${fileSize}B. ` + `Error: ${error instanceof Error ? error.message : 'Unknown'}`);
81
+ }
82
+ return undefined;
83
+ }
25
84
  }
26
85
  /**
27
86
  * Retrieve stored tokens
28
87
  * @returns FigmaTokens if stored, null otherwise
29
88
  */ getTokens() {
30
- const tokens = this.config.get('tokens');
89
+ const tokens = this.safeGet('tokens');
31
90
  return tokens || null;
32
91
  }
33
92
  /**
@@ -35,6 +94,16 @@ import { deriveEncryptionKey } from './crypto-utils.js';
35
94
  * @param tokens - Figma OAuth2 tokens to store
36
95
  */ setTokens(tokens) {
37
96
  this.config.set('tokens', tokens);
97
+ // Verify the round-trip: read back what we just wrote
98
+ const readBack = this.safeGet('tokens');
99
+ if (!readBack || readBack.accessToken !== tokens.accessToken) {
100
+ if (this.environment === 'staging') {
101
+ const filePath = this.config.path;
102
+ const fileExists = fsSync.existsSync(filePath);
103
+ const fileSize = fileExists ? fsSync.statSync(filePath).size : 0;
104
+ log.warning(`Token verify-after-write FAILED. ` + `File: ${filePath}, exists: ${fileExists}, size: ${fileSize}B. ` + `Written accessToken starts: ${tokens.accessToken.substring(0, 10)}..., ` + `Read back: ${readBack ? readBack.accessToken.substring(0, 10) + '...' : 'null'}`);
105
+ }
106
+ }
38
107
  }
39
108
  /**
40
109
  * Clear all stored tokens (used for logout)
@@ -56,8 +125,7 @@ import { deriveEncryptionKey } from './crypto-utils.js';
56
125
  * Includes a buffer time to avoid using tokens that are about to expire
57
126
  * @returns true if token is expired or will expire within buffer time
58
127
  */ isExpired() {
59
- // Access config directly to avoid circular dependency with getTokens()
60
- const tokens = this.config.get('tokens');
128
+ const tokens = this.safeGet('tokens');
61
129
  if (!tokens) {
62
130
  return true;
63
131
  }
@@ -112,7 +180,7 @@ import { deriveEncryptionKey } from './crypto-utils.js';
112
180
  * @param tenantId - The tenant/CMS ID
113
181
  * @returns ProjectToken if stored and valid, null otherwise
114
182
  */ getProjectToken(tenantId) {
115
- const projectTokens = this.config.get('projectTokens') || {};
183
+ const projectTokens = this.safeGet('projectTokens') || {};
116
184
  const projectToken = projectTokens[tenantId];
117
185
  if (!projectToken) {
118
186
  return null;
@@ -129,7 +197,7 @@ import { deriveEncryptionKey } from './crypto-utils.js';
129
197
  * @param tenantId - The tenant/CMS ID
130
198
  * @param projectToken - The project token to store
131
199
  */ setProjectToken(tenantId, projectToken) {
132
- const projectTokens = this.config.get('projectTokens') || {};
200
+ const projectTokens = this.safeGet('projectTokens') || {};
133
201
  projectTokens[tenantId] = projectToken;
134
202
  this.config.set('projectTokens', projectTokens);
135
203
  }
@@ -137,7 +205,7 @@ import { deriveEncryptionKey } from './crypto-utils.js';
137
205
  * Clear a project token for a specific tenant
138
206
  * @param tenantId - The tenant/CMS ID
139
207
  */ clearProjectToken(tenantId) {
140
- const projectTokens = this.config.get('projectTokens') || {};
208
+ const projectTokens = this.safeGet('projectTokens') || {};
141
209
  delete projectTokens[tenantId];
142
210
  this.config.set('projectTokens', projectTokens);
143
211
  }
@@ -180,9 +248,45 @@ import { deriveEncryptionKey } from './crypto-utils.js';
180
248
  * Get all tenant IDs that have stored project tokens
181
249
  * @returns Array of tenant IDs
182
250
  */ getAllProjectTokenTenantIds() {
183
- const projectTokens = this.config.get('projectTokens') || {};
251
+ const projectTokens = this.safeGet('projectTokens') || {};
184
252
  return Object.keys(projectTokens);
185
253
  }
254
+ /**
255
+ * Build the composite key for bootstrap data storage
256
+ * @param projectId - The CMS resource/project ID
257
+ * @param environmentName - The environment name (e.g. 'production', 'staging')
258
+ * @returns Composite key string
259
+ */ bootstrapKey(projectId, environmentName) {
260
+ return `${projectId}:${environmentName}`;
261
+ }
262
+ /**
263
+ * Retrieve bootstrap data for a project + environment
264
+ * @param projectId - The CMS resource/project ID
265
+ * @param environmentName - The environment name
266
+ * @returns BootstrapData if stored, null otherwise
267
+ */ getBootstrapData(projectId, environmentName) {
268
+ const allData = this.safeGet('bootstrapData') || {};
269
+ return allData[this.bootstrapKey(projectId, environmentName)] || null;
270
+ }
271
+ /**
272
+ * Store bootstrap data for a project + environment
273
+ * @param projectId - The CMS resource/project ID
274
+ * @param environmentName - The environment name
275
+ * @param data - The bootstrap data to store
276
+ */ setBootstrapData(projectId, environmentName, data) {
277
+ const allData = this.safeGet('bootstrapData') || {};
278
+ allData[this.bootstrapKey(projectId, environmentName)] = data;
279
+ this.config.set('bootstrapData', allData);
280
+ }
281
+ /**
282
+ * Clear bootstrap data for a project + environment
283
+ * @param projectId - The CMS resource/project ID
284
+ * @param environmentName - The environment name
285
+ */ clearBootstrapData(projectId, environmentName) {
286
+ const allData = this.safeGet('bootstrapData') || {};
287
+ delete allData[this.bootstrapKey(projectId, environmentName)];
288
+ this.config.set('bootstrapData', allData);
289
+ }
186
290
  }
187
291
 
188
292
  //# sourceMappingURL=token-store.js.map
@@ -1,5 +1,6 @@
1
1
  import type { ErrorResponsePayloadWithErrMessage, ErrorResponsePayloadWithErrorBoolean, User } from '@figma/rest-api-spec';
2
2
  import type { JWTPayload as JoseJWTPayload } from 'jose';
3
+ import type { Environment } from '../constants.js';
3
4
  /**
4
5
  * Standard OAuth2 scopes for user-level permissions
5
6
  * @see https://www.figma.com/developers/api#oauth2
@@ -105,12 +106,14 @@ export interface OAuthTokenRefreshParams {
105
106
  /**
106
107
  * Configuration for token storage
107
108
  */
108
- export interface TokenStoreConfig {
109
- /** Custom config name (defaults to 'payloadcms-figma') */
109
+ export type TokenStoreConfig = {
110
+ /** Config file name (for testing) */
110
111
  configName?: string;
111
- /** Enable encryption (defaults to true) */
112
+ /** Encryption key (for testing) */
112
113
  encryptionKey?: string;
113
- }
114
+ /** Environment for config file naming */
115
+ environment?: Environment;
116
+ };
114
117
  /**
115
118
  * PKCE (Proof Key for Code Exchange) pair for OAuth2 public clients
116
119
  * @see https://datatracker.ietf.org/doc/html/rfc7636
@@ -158,6 +161,16 @@ export type FigmaErrorResponse = ErrorResponsePayloadWithErrMessage | ErrorRespo
158
161
  * Re-exported from @figma/rest-api-spec
159
162
  */
160
163
  export type FigmaUser = User;
164
+ /**
165
+ * Bootstrap data cached in the local encrypted store
166
+ * Keyed by projectId:environmentName
167
+ */
168
+ export type BootstrapData = {
169
+ contentSystemId: string;
170
+ oauthClientId: string;
171
+ oauthClientSecret: string;
172
+ tenantInstanceId: string;
173
+ };
161
174
  /**
162
175
  * JWT payload structure from Figma project tokens
163
176
  * Extends jose's standard JWTPayload with Figma-specific claims
package/dist/cli.js CHANGED
@@ -1,12 +1,17 @@
1
1
  import * as p from '@clack/prompts';
2
2
  import arg from 'arg';
3
3
  import pc from 'picocolors';
4
+ import { buildLambdaZipCommand } from './commands/build-lambda-zip.js';
5
+ import { debugCommand } from './commands/debug.js';
4
6
  import { deployCommand } from './commands/deploy.js';
7
+ import { envCommand } from './commands/env.js';
5
8
  import { initCommand } from './commands/init.js';
6
9
  import { listTokensCommand } from './commands/list-tokens.js';
7
10
  import { loginCommand } from './commands/login.js';
8
11
  import { logoutCommand } from './commands/logout.js';
9
- import { feedbackOutro, helpMessage } from './utils/messages.js';
12
+ import { upgradeCommand } from './commands/upgrade.js';
13
+ import { setInfraEnvironment } from './constants.js';
14
+ import { helpMessage } from './utils/messages.js';
10
15
  /**
11
16
  * Entrypoint for bin/cli.js
12
17
  */ export async function main() {
@@ -24,16 +29,30 @@ class Main {
24
29
  constructor(){
25
30
  // @ts-expect-error bad typings
26
31
  this.args = arg({
32
+ // Hidden flag — intentionally not displayed in help output yet.
33
+ // Auto-detection covers most cases; this is an escape hatch for testing.
34
+ // May expose in help text once multi-framework support is public.
35
+ '--adapter': String,
36
+ '--all': Boolean,
27
37
  '--debug': Boolean,
38
+ '--dry-run': Boolean,
39
+ '--env': String,
28
40
  '--force': Boolean,
29
41
  '--help': Boolean,
30
42
  '--id': String,
43
+ '--infra-env': String,
31
44
  '--name': String,
32
45
  '--skip-auth': Boolean,
46
+ '--skip-build': Boolean,
47
+ '--version': Boolean,
33
48
  '--yes': Boolean,
34
49
  // Aliases
50
+ '--environment': '--env',
51
+ '-e': '--env',
35
52
  '-f': '--force',
36
53
  '-h': '--help',
54
+ '-n': '--name',
55
+ '-v': '--version',
37
56
  '-y': '--yes'
38
57
  }, {
39
58
  permissive: true
@@ -42,6 +61,19 @@ class Main {
42
61
  if (this.args['--debug']) {
43
62
  process.env.DEBUG = 'true';
44
63
  }
64
+ // Handle --infra-env flag for infrastructure environment switching
65
+ if (this.args['--infra-env']) {
66
+ const infraEnvArg = this.args['--infra-env'].toLowerCase();
67
+ if (infraEnvArg === 'prod' || infraEnvArg === 'production') {
68
+ setInfraEnvironment('production');
69
+ } else if (infraEnvArg === 'staging') {
70
+ setInfraEnvironment('staging');
71
+ } else {
72
+ // eslint-disable-next-line no-console
73
+ console.error(`Invalid --infra-env value: ${this.args['--infra-env']}. Use 'production' or 'staging'.`);
74
+ process.exit(1);
75
+ }
76
+ }
45
77
  }
46
78
  async init() {
47
79
  try {
@@ -49,30 +81,60 @@ class Main {
49
81
  helpMessage();
50
82
  process.exit(0);
51
83
  }
84
+ if (this.args['--version']) {
85
+ const { getOwnVersion } = await import('./utils/version-check.js');
86
+ const version = await getOwnVersion();
87
+ // eslint-disable-next-line no-console
88
+ console.log(version);
89
+ process.exit(0);
90
+ }
52
91
  // Get the subcommand (first non-flag argument)
53
92
  const subcommand = this.args._[0];
93
+ if (!subcommand) {
94
+ helpMessage();
95
+ process.exit(0);
96
+ }
97
+ // Debug command outputs plain text for copy-paste — skip styled intro
98
+ if (subcommand === 'debug') {
99
+ await debugCommand();
100
+ process.exit(0);
101
+ }
54
102
  // eslint-disable-next-line no-console
55
103
  console.log('\n');
56
104
  p.intro(pc.bgCyan(pc.black(' @payloadcms/figma ')));
57
105
  // Route to appropriate command handler
58
106
  switch(subcommand){
107
+ case 'build-lambda-zip':
108
+ await buildLambdaZipCommand();
109
+ break;
59
110
  case 'deploy':
60
111
  await deployCommand({
112
+ id: this.args['--id'],
113
+ adapter: this.args['--adapter'],
61
114
  debug: this.args['--debug'],
115
+ env: this.args['--env'],
116
+ skipBuild: this.args['--skip-build'],
62
117
  yes: this.args['--yes']
63
118
  });
64
119
  break;
120
+ case 'env':
121
+ await envCommand({
122
+ name: this.args._[1]
123
+ });
124
+ break;
65
125
  case 'init':
66
126
  await initCommand({
67
127
  id: this.args['--id'],
68
128
  name: this.args['--name'],
69
129
  debug: this.args['--debug'],
130
+ env: this.args['--env'],
70
131
  force: this.args['--force'],
71
132
  skipAuth: this.args['--skip-auth']
72
133
  });
73
134
  break;
74
135
  case 'list-tokens':
75
136
  listTokensCommand({
137
+ all: this.args['--all'],
76
138
  debug: this.args['--debug']
77
139
  });
78
140
  break;
@@ -81,13 +143,14 @@ class Main {
81
143
  break;
82
144
  case 'logout':
83
145
  await logoutCommand({
146
+ all: this.args['--all'],
84
147
  debug: this.args['--debug']
85
148
  });
86
149
  break;
87
- case undefined:
88
- // No subcommand - show default message
89
- p.note("Let's create a new CMS!");
90
- p.outro(feedbackOutro());
150
+ case 'upgrade':
151
+ await upgradeCommand({
152
+ isDryRun: this.args['--dry-run']
153
+ });
91
154
  break;
92
155
  default:
93
156
  p.log.error(pc.red(`Unknown command: ${subcommand}`));
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Build Lambda deployment zip from current directory
3
+ */
4
+ export declare function buildLambdaZipCommand(): Promise<void>;
5
+ //# sourceMappingURL=build-lambda-zip.d.ts.map
@@ -0,0 +1,19 @@
1
+ import * as p from '@clack/prompts';
2
+ import pc from 'picocolors';
3
+ import { buildLambdaZip } from '../utils/build-lambda-zip.js';
4
+ /**
5
+ * Build Lambda deployment zip from current directory
6
+ */ export async function buildLambdaZipCommand() {
7
+ const projectPath = process.cwd();
8
+ const s = p.spinner();
9
+ s.start('Creating lambda.zip');
10
+ try {
11
+ await buildLambdaZip(projectPath);
12
+ s.stop(pc.green('✓ Created lambda.zip'));
13
+ } catch (error) {
14
+ s.stop(pc.red('✗ Failed to create lambda.zip'));
15
+ throw error;
16
+ }
17
+ }
18
+
19
+ //# sourceMappingURL=build-lambda-zip.js.map
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Handle the `@payloadcms/figma debug` command
3
+ *
4
+ * Outputs environment, auth, project, and package info for debugging.
5
+ * All data is local — no network calls are made.
6
+ */
7
+ export declare function debugCommand(): Promise<void>;
8
+ //# sourceMappingURL=debug.d.ts.map
@@ -0,0 +1,176 @@
1
+ import fsSync from 'node:fs';
2
+ import { createRequire } from 'node:module';
3
+ import os from 'node:os';
4
+ import path from 'node:path';
5
+ import { getEncryptionKeyHash } from '../auth/crypto-utils.js';
6
+ import { getTokenStore } from '../auth/token-store.js';
7
+ import { getInfraEnvironment } from '../constants.js';
8
+ import { getEnvVarSync } from '../utils/env-management.js';
9
+ import { maskToken } from '../utils/token-display.js';
10
+ import { getOwnVersion } from '../utils/version-check.js';
11
+ /**
12
+ * Handle the `@payloadcms/figma debug` command
13
+ *
14
+ * Outputs environment, auth, project, and package info for debugging.
15
+ * All data is local — no network calls are made.
16
+ */ export async function debugCommand() {
17
+ const env = getInfraEnvironment();
18
+ const tokenStore = getTokenStore(env);
19
+ const cwd = process.cwd();
20
+ const lines = [
21
+ 'Debug Info:',
22
+ ''
23
+ ];
24
+ appendSystemSection(lines, env);
25
+ appendAuthSection(lines, tokenStore, cwd);
26
+ appendTokenStoreDiagnostics(lines, tokenStore);
27
+ appendProjectSection(lines, tokenStore, cwd);
28
+ await appendPackagesSection(lines);
29
+ // eslint-disable-next-line no-console
30
+ console.log(lines.join('\n'));
31
+ }
32
+ function appendSystemSection(lines, env) {
33
+ lines.push(`Infra Environment: ${env}`);
34
+ lines.push(`Node: ${process.version}`);
35
+ lines.push(`OS: ${os.platform()} ${os.arch()}`);
36
+ lines.push('');
37
+ }
38
+ function appendAuthSection(lines, tokenStore, cwd) {
39
+ const tokens = tokenStore.getTokens();
40
+ lines.push('Auth:');
41
+ if (!tokens) {
42
+ lines.push(' Status: Not authenticated');
43
+ lines.push('');
44
+ return;
45
+ }
46
+ const isValid = tokenStore.hasValidTokens();
47
+ lines.push(` Status: ${isValid ? 'Authenticated' : 'Token expired'}`);
48
+ const email = getEmailFromClaims(tokenStore, cwd);
49
+ if (email) {
50
+ lines.push(` Email: ${email}`);
51
+ } else if (tokens.userId) {
52
+ lines.push(` User ID: ${tokens.userId}`);
53
+ }
54
+ lines.push(` Token Expires: ${formatExpiryTime(tokens.expiresAt)}`);
55
+ lines.push('');
56
+ }
57
+ function appendTokenStoreDiagnostics(lines, tokenStore) {
58
+ lines.push('Token Store:');
59
+ const filePath = tokenStore.getStoragePath();
60
+ const fileExists = fsSync.existsSync(filePath);
61
+ const fileSize = fileExists ? fsSync.statSync(filePath).size : 0;
62
+ lines.push(` File: ${filePath}`);
63
+ lines.push(` File Exists: ${fileExists}`);
64
+ lines.push(` File Size: ${fileSize}B`);
65
+ const canRead = tokenStore.getTokens() !== null || tokenStore.getRefreshToken() !== null;
66
+ lines.push(` Decryption: ${fileExists ? canRead || fileSize === 0 ? 'OK' : 'FAILED' : 'N/A'}`);
67
+ lines.push(` Key Hash: ${getEncryptionKeyHash()}`);
68
+ lines.push('');
69
+ }
70
+ function appendProjectSection(lines, tokenStore, cwd) {
71
+ const projectId = getEnvVarSync(cwd, 'FIGMA_PROJECT_ID');
72
+ const environmentName = getEnvVarSync(cwd, 'FIGMA_ENVIRONMENT_NAME');
73
+ lines.push('Project:');
74
+ if (!projectId) {
75
+ lines.push(" Not initialized (run 'init' first)");
76
+ lines.push('');
77
+ return;
78
+ }
79
+ lines.push(` Project ID: ${projectId}`);
80
+ lines.push(` Environment: ${environmentName ?? '(not set)'}`);
81
+ // Show bootstrap data from local store
82
+ if (projectId && environmentName) {
83
+ const bootstrapData = tokenStore.getBootstrapData(projectId, environmentName);
84
+ if (bootstrapData) {
85
+ lines.push(` Content System ID: ${bootstrapData.contentSystemId}`);
86
+ lines.push(` Tenant Instance ID: ${bootstrapData.tenantInstanceId}`);
87
+ lines.push(` OAuth Client ID: ${maskToken(bootstrapData.oauthClientId)}`);
88
+ const projectToken = tokenStore.getProjectToken(bootstrapData.contentSystemId);
89
+ if (projectToken) {
90
+ lines.push(` Project Token: ${formatExpiryTime(projectToken.expiresAt)}`);
91
+ }
92
+ } else {
93
+ lines.push(' Bootstrap Data: (not cached)');
94
+ }
95
+ }
96
+ lines.push('');
97
+ }
98
+ async function appendPackagesSection(lines) {
99
+ lines.push('Packages:');
100
+ const cliVersion = await getOwnVersion();
101
+ lines.push(` @payloadcms/figma: ${cliVersion}`);
102
+ const payloadVersion = getPayloadVersion();
103
+ lines.push(` payload: ${payloadVersion}`);
104
+ }
105
+ /**
106
+ * Try resolving email from bootstrap data, then iterate all stored project tokens.
107
+ */ function getEmailFromClaims(tokenStore, cwd) {
108
+ const projectId = getEnvVarSync(cwd, 'FIGMA_PROJECT_ID');
109
+ const environmentName = getEnvVarSync(cwd, 'FIGMA_ENVIRONMENT_NAME');
110
+ if (projectId && environmentName) {
111
+ const bootstrapData = tokenStore.getBootstrapData(projectId, environmentName);
112
+ if (bootstrapData) {
113
+ const email = tokenStore.getProjectTokenClaims(bootstrapData.contentSystemId)?.email;
114
+ if (email) {
115
+ return email;
116
+ }
117
+ }
118
+ }
119
+ for (const id of tokenStore.getAllProjectTokenTenantIds()){
120
+ const email = tokenStore.getProjectTokenClaims(id)?.email;
121
+ if (email) {
122
+ return email;
123
+ }
124
+ }
125
+ return null;
126
+ }
127
+ function getPayloadVersion() {
128
+ try {
129
+ const require = createRequire(path.join(process.cwd(), 'noop.js'));
130
+ const resolved = require.resolve('payload');
131
+ const packageJsonPath = findPackageJson(path.dirname(resolved));
132
+ if (!packageJsonPath) {
133
+ return 'not found';
134
+ }
135
+ const content = fsSync.readFileSync(packageJsonPath, 'utf-8');
136
+ return JSON.parse(content).version;
137
+ } catch {
138
+ return 'not found';
139
+ }
140
+ }
141
+ function findPackageJson(dir) {
142
+ const { root } = path.parse(dir);
143
+ while(dir !== root){
144
+ const candidate = path.join(dir, 'package.json');
145
+ if (fsSync.existsSync(candidate)) {
146
+ return candidate;
147
+ }
148
+ dir = path.dirname(dir);
149
+ }
150
+ return null;
151
+ }
152
+ /**
153
+ * Format expiry timestamp as ISO string with relative time
154
+ * e.g. "2026-02-11T10:30:00.000Z (in 23h 15m)" or "2026-02-10T08:00:00.000Z (expired 2h ago)"
155
+ */ function formatExpiryTime(expiresAt) {
156
+ const iso = new Date(expiresAt).toISOString();
157
+ const diff = expiresAt - Date.now();
158
+ if (diff < 0) {
159
+ return `${iso} (expired ${formatDuration(Math.abs(diff))} ago)`;
160
+ }
161
+ return `${iso} (in ${formatDuration(diff)})`;
162
+ }
163
+ function formatDuration(ms) {
164
+ const minutes = Math.floor(ms / 60000);
165
+ const hours = Math.floor(minutes / 60);
166
+ const days = Math.floor(hours / 24);
167
+ if (days > 0) {
168
+ return `${days}d ${hours % 24}h`;
169
+ }
170
+ if (hours > 0) {
171
+ return `${hours}h ${minutes % 60}m`;
172
+ }
173
+ return `${minutes}m`;
174
+ }
175
+
176
+ //# sourceMappingURL=debug.js.map
@@ -1,9 +1,18 @@
1
+ import type { AdapterName } from '../utils/deploy-adapter.js';
1
2
  /**
2
3
  * Options for deploy command
3
4
  */
4
5
  export interface DeployCommandOptions {
6
+ /** Framework adapter (nextjs, nitro, vite). Auto-detected if omitted. */
7
+ adapter?: AdapterName;
5
8
  /** Enable debug mode */
6
9
  debug?: boolean;
10
+ /** Figma environment name (e.g. 'production', 'staging') */
11
+ env?: string;
12
+ /** CMS Resource ID (overrides FIGMA_PROJECT_ID) */
13
+ id?: string;
14
+ /** Skip the build step (use existing build) */
15
+ skipBuild?: boolean;
7
16
  /** Skip confirmation prompts */
8
17
  yes?: boolean;
9
18
  }