@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
@@ -0,0 +1,90 @@
1
+ import archiver from 'archiver';
2
+ import { createWriteStream } from 'fs';
3
+ import fs from 'fs/promises';
4
+ import path from 'path';
5
+ import { getDirectorySize } from './fs-utils.js';
6
+ /**
7
+ * AWS Lambda's hard limit on unzipped deployment code size (250 MB). The unzipped
8
+ * total must be strictly less than this value, so a bundle exactly equal to it is
9
+ * rejected. The server enforces this too and now returns a clear message, so a
10
+ * client-side check against this value is an early-exit convenience, not the
11
+ * source of truth.
12
+ */ export const LAMBDA_MAX_UNZIPPED_BYTES = 250 * 1024 * 1024;
13
+ /**
14
+ * Build Lambda deployment zip using pure Node.js
15
+ *
16
+ * Cross-platform replacement for build_for_lambda.sh:
17
+ * 1. Copies .next/static to .next/standalone/.next/static
18
+ * 2. Copies run.sh to .next/standalone/run.sh
19
+ * 3. Creates lambda.zip from .next/standalone/
20
+ *
21
+ * Note: public/ is NOT included in the zip — those files are uploaded
22
+ * as static assets and served via CDN, not from the Lambda function.
23
+ *
24
+ * @param projectPath - Path to project root
25
+ * @returns The built bundle: its unzipped byte size and the absolute zip path.
26
+ * @throws Error if standalone directory missing or zip creation fails
27
+ */ export async function buildLambdaZip(projectPath) {
28
+ const standalonePath = path.join(projectPath, '.next', 'standalone');
29
+ const staticPath = path.join(projectPath, '.next', 'static');
30
+ const runShPath = path.join(projectPath, 'run.sh');
31
+ const zipPath = path.join(projectPath, 'lambda.zip');
32
+ if (!await isDirectory(standalonePath)) {
33
+ throw new Error('Standalone build not found at .next/standalone. ' + 'Ensure next.config has output: "standalone" and run build first.');
34
+ }
35
+ if (await isDirectory(staticPath)) {
36
+ const destStatic = path.join(standalonePath, '.next', 'static');
37
+ await copyDirectory(staticPath, destStatic);
38
+ }
39
+ try {
40
+ await fs.copyFile(runShPath, path.join(standalonePath, 'run.sh'));
41
+ } catch {
42
+ // run.sh may not exist in all setups
43
+ }
44
+ const unzippedBytes = await getDirectorySize(standalonePath);
45
+ await createZip(standalonePath, zipPath);
46
+ return {
47
+ unzippedBytes,
48
+ zipPath
49
+ };
50
+ }
51
+ async function isDirectory(dirPath) {
52
+ try {
53
+ const stats = await fs.stat(dirPath);
54
+ return stats.isDirectory();
55
+ } catch {
56
+ return false;
57
+ }
58
+ }
59
+ async function copyDirectory(src, dest) {
60
+ await fs.mkdir(dest, {
61
+ recursive: true
62
+ });
63
+ const entries = await fs.readdir(src, {
64
+ withFileTypes: true
65
+ });
66
+ for (const entry of entries){
67
+ const srcPath = path.join(src, entry.name);
68
+ const destPath = path.join(dest, entry.name);
69
+ if (entry.isDirectory()) {
70
+ await copyDirectory(srcPath, destPath);
71
+ } else {
72
+ await fs.copyFile(srcPath, destPath);
73
+ }
74
+ }
75
+ }
76
+ function createZip(sourceDir, zipPath) {
77
+ return new Promise((resolve, reject)=>{
78
+ const output = createWriteStream(zipPath);
79
+ const archive = archiver('zip', {
80
+ zlib: {
81
+ level: 9
82
+ }
83
+ });
84
+ output.on('close', ()=>resolve());
85
+ archive.on('error', (err)=>reject(err));
86
+ archive.pipe(output);
87
+ archive.directory(sourceDir, false);
88
+ void archive.finalize();
89
+ });
90
+ }
@@ -0,0 +1,7 @@
1
+ import type { BootstrapInfo } from '../api/control-plane.js';
2
+ import type { TokenStore } from '../auth/token-store.js';
3
+ /**
4
+ * Cache bootstrap data for all environments in the local encrypted store.
5
+ * Called from init, env, and build-config to keep the store populated.
6
+ */
7
+ export declare function cacheAllEnvironments(tokenStore: TokenStore, projectId: string, bootstrapInfo: BootstrapInfo): void;
@@ -0,0 +1,16 @@
1
+ import * as log from './log.js';
2
+ /**
3
+ * Cache bootstrap data for all environments in the local encrypted store.
4
+ * Called from init, env, and build-config to keep the store populated.
5
+ */ export function cacheAllEnvironments(tokenStore, projectId, bootstrapInfo) {
6
+ const { oauthCredentials } = bootstrapInfo;
7
+ for (const env of bootstrapInfo.environments){
8
+ tokenStore.setBootstrapData(projectId, env.name, {
9
+ contentSystemId: env.contentSystemId,
10
+ oauthClientId: oauthCredentials.oauthClientId,
11
+ oauthClientSecret: oauthCredentials.oauthClientSecret,
12
+ tenantInstanceId: env.tenantInstanceId
13
+ });
14
+ }
15
+ log.debug(`Cached bootstrap data for environments: ${bootstrapInfo.environments.map((e)=>e.name).join(', ')}`);
16
+ }
@@ -8,4 +8,3 @@
8
8
  * @param entries - Optional entries to add to .gitignore
9
9
  */
10
10
  export declare function ensureGitignore(projectPath: string, entries?: string[]): Promise<void>;
11
- //# sourceMappingURL=config.d.ts.map
@@ -19,7 +19,7 @@ const GITIGNORE_FILENAME = '.gitignore';
19
19
  }
20
20
  }
21
21
  // Parse existing entries
22
- const existingLines = existingContent.split('\n').filter((line)=>line.trim());
22
+ const existingLines = existingContent.split(/\r?\n/).filter((line)=>line.trim());
23
23
  const existingSet = new Set(existingLines);
24
24
  // Add new entries that don't exist
25
25
  const newEntries = entries.filter((entry)=>!existingSet.has(entry));
@@ -28,5 +28,3 @@ const GITIGNORE_FILENAME = '.gitignore';
28
28
  await fs.writeFile(gitignorePath, newContent, 'utf-8');
29
29
  }
30
30
  }
31
-
32
- //# sourceMappingURL=config.js.map
@@ -0,0 +1,45 @@
1
+ export interface PageCollection {
2
+ /** S3 key → relative filesystem path from project root */
3
+ pathMap: Record<string, string>;
4
+ /** Route → S3 upload keys for that route (e.g., { "/products": ["products.html", "products.rsc"] }) */
5
+ routeAssetMap: Record<string, string[]>;
6
+ /** Route paths for the manifest pages array (e.g., ["/products", "/blog"]) */
7
+ routes: string[];
8
+ /** S3 keys to upload (e.g., ["products.html", "products.rsc", "products.meta"]) */
9
+ uploadKeys: string[];
10
+ }
11
+ export interface AssetCollection {
12
+ /** S3 key → relative filesystem path from project root */
13
+ pathMap: Record<string, string>;
14
+ /** Route paths for the manifest assets array (e.g., ["/favicon.ico"]) */
15
+ routes: string[];
16
+ /** S3 keys to upload (same as routes for assets, without leading slash) */
17
+ uploadKeys: string[];
18
+ }
19
+ export type AdapterName = 'nextjs' | 'nitro' | 'vite';
20
+ export interface LambdaBundle {
21
+ /** Total size in bytes of the bundle contents before compression. */
22
+ unzippedBytes: number;
23
+ /** Absolute path to the built lambda.zip. */
24
+ zipPath: string;
25
+ }
26
+ export interface DeployAdapter {
27
+ collectAssets(projectPath: string): Promise<AssetCollection>;
28
+ collectPages(projectPath: string): Promise<PageCollection>;
29
+ /** SPA fallback path (e.g., "/index.html"). Undefined for SSR/SSG apps. */
30
+ fallback?: string;
31
+ name: AdapterName;
32
+ /** Assembles and zips the server bundle. Returns the bundle, or null if no server (e.g., Vite SPA). */
33
+ prepareLambdaBundle(projectPath: string): Promise<LambdaBundle | null>;
34
+ }
35
+ /**
36
+ * Auto-detect the framework adapter based on build output.
37
+ *
38
+ * - .next/ exists → nextjs
39
+ * - .output/nitro.json exists → nitro
40
+ * - dist/index.html exists (no .next/, no .output/) → vite
41
+ *
42
+ * @param projectPath - Path to project root
43
+ * @param override - Explicit adapter name from --adapter flag
44
+ */
45
+ export declare function detectAdapter(projectPath: string, override?: AdapterName): Promise<DeployAdapter>;
@@ -0,0 +1,56 @@
1
+ import fs from 'fs/promises';
2
+ import path from 'path';
3
+ /**
4
+ * Auto-detect the framework adapter based on build output.
5
+ *
6
+ * - .next/ exists → nextjs
7
+ * - .output/nitro.json exists → nitro
8
+ * - dist/index.html exists (no .next/, no .output/) → vite
9
+ *
10
+ * @param projectPath - Path to project root
11
+ * @param override - Explicit adapter name from --adapter flag
12
+ */ export async function detectAdapter(projectPath, override) {
13
+ if (override) {
14
+ return loadAdapter(override);
15
+ }
16
+ const hasNext = await exists(path.join(projectPath, '.next'));
17
+ const hasNitro = await exists(path.join(projectPath, '.output', 'nitro.json'));
18
+ const hasViteDist = await exists(path.join(projectPath, 'dist', 'index.html'));
19
+ if (hasNext) {
20
+ return loadAdapter('nextjs');
21
+ }
22
+ if (hasNitro) {
23
+ return loadAdapter('nitro');
24
+ }
25
+ if (hasViteDist) {
26
+ return loadAdapter('vite');
27
+ }
28
+ throw new Error('Could not detect framework. Expected .next/ (NextJS), .output/nitro.json (Nitro), or dist/index.html (Vite). ' + 'Use --adapter to specify explicitly.');
29
+ }
30
+ async function loadAdapter(name) {
31
+ switch(name){
32
+ case 'nextjs':
33
+ {
34
+ const mod = await import('./adapters/nextjs.js');
35
+ return mod.nextjsAdapter;
36
+ }
37
+ case 'nitro':
38
+ {
39
+ const mod = await import('./adapters/nitro.js');
40
+ return mod.nitroAdapter;
41
+ }
42
+ case 'vite':
43
+ {
44
+ const mod = await import('./adapters/vite.js');
45
+ return mod.viteAdapter;
46
+ }
47
+ }
48
+ }
49
+ async function exists(filePath) {
50
+ try {
51
+ await fs.stat(filePath);
52
+ return true;
53
+ } catch {
54
+ return false;
55
+ }
56
+ }
@@ -5,11 +5,18 @@ export declare class TemplateDownloadError extends Error {
5
5
  cause?: Error | undefined;
6
6
  constructor(message: string, cause?: Error | undefined);
7
7
  }
8
+ export type TemplateSource = {
9
+ owner: string;
10
+ ref: string;
11
+ repo: string;
12
+ templatePath: string;
13
+ };
14
+ export declare const DEFAULT_TEMPLATE_SOURCE: TemplateSource;
8
15
  /**
9
16
  * Download Payload template from GitHub with retry logic
10
17
  *
11
18
  * @param projectDir - Directory to extract template into
19
+ * @param source - Optional override of repo / ref / template path
12
20
  * @throws TemplateDownloadError if download fails
13
21
  */
14
- export declare function downloadTemplateFromGitHub(projectDir: string): Promise<void>;
15
- //# sourceMappingURL=download-template.d.ts.map
22
+ export declare function downloadTemplateFromGitHub(projectDir: string, source?: Partial<TemplateSource>): Promise<void>;
@@ -11,22 +11,30 @@ import { x } from 'tar';
11
11
  this.name = 'TemplateDownloadError';
12
12
  }
13
13
  }
14
- const BRANCH_OR_TAG = 'main';
15
- const TEMPLATE_NAME = 'blank';
14
+ export const DEFAULT_TEMPLATE_SOURCE = {
15
+ owner: 'payloadcms',
16
+ ref: 'main',
17
+ repo: 'payload',
18
+ templatePath: 'blank'
19
+ };
16
20
  const MAX_RETRIES = 3;
17
- const INITIAL_RETRY_DELAY = 1000 // 1 second
18
- ;
21
+ const INITIAL_RETRY_DELAY = 1000;
19
22
  /**
20
23
  * Download Payload template from GitHub with retry logic
21
24
  *
22
25
  * @param projectDir - Directory to extract template into
26
+ * @param source - Optional override of repo / ref / template path
23
27
  * @throws TemplateDownloadError if download fails
24
- */ export async function downloadTemplateFromGitHub(projectDir) {
28
+ */ export async function downloadTemplateFromGitHub(projectDir, source) {
29
+ const resolved = {
30
+ ...DEFAULT_TEMPLATE_SOURCE,
31
+ ...source
32
+ };
25
33
  let lastError;
26
34
  for(let attempt = 1; attempt <= MAX_RETRIES; attempt++){
27
35
  try {
28
- await downloadTemplateAttempt(projectDir);
29
- return; // Success
36
+ await downloadTemplateAttempt(projectDir, resolved);
37
+ return;
30
38
  } catch (error) {
31
39
  lastError = error instanceof Error ? error : new Error('Unknown error');
32
40
  if (attempt < MAX_RETRIES) {
@@ -36,31 +44,29 @@ const INITIAL_RETRY_DELAY = 1000 // 1 second
36
44
  }
37
45
  }
38
46
  }
39
- // All retries failed
40
47
  throw new TemplateDownloadError(`Failed to download template after ${MAX_RETRIES} attempts`, lastError);
41
48
  }
42
- /**
43
- * Single attempt to download template (extracted for retry logic)
44
- */ async function downloadTemplateAttempt(projectDir) {
45
- const url = `https://codeload.github.com/payloadcms/payload/tar.gz/${BRANCH_OR_TAG}`;
46
- const filter = `payload-${BRANCH_OR_TAG}/templates/${TEMPLATE_NAME}/`;
49
+ async function downloadTemplateAttempt(projectDir, source) {
50
+ const url = `https://codeload.github.com/${source.owner}/${source.repo}/tar.gz/${source.ref}`;
51
+ // GitHub strips the leading 'v' and replaces '/' with '-' when naming the tarball root dir
52
+ const refSlug = source.ref.replace(/^v/, '').replace(/\//g, '-');
53
+ const tarballPrefix = `${source.repo}-${refSlug}`;
54
+ const filter = `${tarballPrefix}/templates/${source.templatePath}/`;
55
+ const strip = 2 + source.templatePath.split('/').length;
47
56
  try {
48
- // Ensure target directory exists
49
57
  await fs.mkdir(projectDir, {
50
58
  recursive: true
51
59
  });
52
60
  await pipeline(await downloadTarStream(url), x({
53
61
  cwd: projectDir,
54
62
  filter: (p)=>p.includes(filter),
55
- strip: 2 + TEMPLATE_NAME.split('/').length
63
+ strip
56
64
  }));
57
65
  } catch (error) {
58
66
  throw new TemplateDownloadError('Failed to download template from GitHub', error instanceof Error ? error : undefined);
59
67
  }
60
68
  }
61
- /**
62
- * Download tar stream from URL
63
- */ async function downloadTarStream(url) {
69
+ async function downloadTarStream(url) {
64
70
  const res = await fetch(url);
65
71
  if (!res.ok) {
66
72
  throw new Error(`HTTP ${res.status}: ${res.statusText}`);
@@ -70,5 +76,3 @@ const INITIAL_RETRY_DELAY = 1000 // 1 second
70
76
  }
71
77
  return Readable.from(res.body);
72
78
  }
73
-
74
- //# sourceMappingURL=download-template.js.map
@@ -1,16 +1,32 @@
1
1
  /**
2
- * Generate a cryptographically secure secret for PAYLOAD_SECRET
2
+ * Get an environment variable value from .env file (async)
3
3
  *
4
- * @returns 24-character hexadecimal string
4
+ * @param projectPath - Path to project directory
5
+ * @param key - Environment variable name to retrieve
6
+ * @returns The value if found, null otherwise
7
+ */
8
+ export declare function getEnvVar(projectPath: string, key: string): Promise<null | string>;
9
+ /**
10
+ * Get an environment variable value from .env file (sync)
11
+ *
12
+ * @param projectPath - Path to project directory
13
+ * @param key - Environment variable name to retrieve
14
+ * @returns The value if found, null otherwise
5
15
  */
6
- export declare function generateSecret(): string;
16
+ export declare function getEnvVarSync(projectPath: string, key: string): null | string;
7
17
  /**
8
- * Manage environment files for a new project
18
+ * Add or update an environment variable in .env file
9
19
  *
10
- * Creates .env from .env.example (if exists) and populates PAYLOAD_SECRET
20
+ * @param projectPath - Path to project directory
21
+ * @param key - Environment variable name
22
+ * @param value - Environment variable value
23
+ */
24
+ export declare function addOrUpdateEnvVar(projectPath: string, key: string, value: string): Promise<void>;
25
+ /**
26
+ * Remove an environment variable from .env file
11
27
  *
12
28
  * @param projectPath - Path to project directory
13
- * @returns The generated payload secret
29
+ * @param key - Environment variable name to remove
30
+ * @returns true if key was found and removed, false otherwise
14
31
  */
15
- export declare function manageEnvFiles(projectPath: string): Promise<string>;
16
- //# sourceMappingURL=env-management.d.ts.map
32
+ export declare function removeEnvVar(projectPath: string, key: string): Promise<boolean>;
@@ -1,98 +1,151 @@
1
- import { randomBytes } from 'crypto';
2
1
  import fs from 'fs/promises';
2
+ import fsSync from 'node:fs';
3
3
  import path from 'path';
4
4
  /**
5
- * Generate a cryptographically secure secret for PAYLOAD_SECRET
6
- *
7
- * @returns 24-character hexadecimal string
8
- */ export function generateSecret() {
9
- return randomBytes(32).toString('hex').slice(0, 24);
10
- }
11
- /**
12
- * Sanitize and process environment file contents
13
- *
14
- * @param contents - Raw .env file contents
15
- * @param payloadSecret - Secret to use for PAYLOAD_SECRET
16
- * @returns Processed .env contents
17
- */ function sanitizeEnv(contents, payloadSecret) {
18
- const lines = contents.split('\n');
19
- const seenKeys = new Set();
20
- const processedLines = [];
5
+ * Parse .env file contents and extract value for a key
6
+ */ function parseEnvValue(contents, key) {
7
+ const lines = contents.split(/\r?\n/);
21
8
  for (const line of lines){
22
9
  // Skip empty lines and comments
23
10
  if (!line.trim() || line.trim().startsWith('#')) {
24
- processedLines.push(line);
25
11
  continue;
26
12
  }
27
13
  // Skip lines without =
28
14
  if (!line.includes('=')) {
29
- processedLines.push(line);
30
15
  continue;
31
16
  }
32
- const [key] = line.split('=');
33
- const trimmedKey = key.trim();
34
- // Skip duplicate keys
35
- if (seenKeys.has(trimmedKey)) {
36
- continue;
37
- }
38
- seenKeys.add(trimmedKey);
39
- // Replace PAYLOAD_SECRET with actual value
40
- if (trimmedKey === 'PAYLOAD_SECRET' || trimmedKey === 'PAYLOAD_SECRET_KEY') {
41
- processedLines.push(`PAYLOAD_SECRET=${payloadSecret}`);
42
- } else {
43
- processedLines.push(line);
17
+ const equalsIndex = line.indexOf('=');
18
+ const lineKey = line.substring(0, equalsIndex).trim();
19
+ if (lineKey === key) {
20
+ return line.substring(equalsIndex + 1);
44
21
  }
45
22
  }
46
- // Add PAYLOAD_SECRET if not present
47
- if (!seenKeys.has('PAYLOAD_SECRET') && !seenKeys.has('PAYLOAD_SECRET_KEY')) {
48
- processedLines.push(`PAYLOAD_SECRET=${payloadSecret}`);
23
+ return null;
24
+ }
25
+ /**
26
+ * Get an environment variable value from .env file (async)
27
+ *
28
+ * @param projectPath - Path to project directory
29
+ * @param key - Environment variable name to retrieve
30
+ * @returns The value if found, null otherwise
31
+ */ export async function getEnvVar(projectPath, key) {
32
+ const envPath = path.join(projectPath, '.env');
33
+ try {
34
+ const contents = await fs.readFile(envPath, 'utf-8');
35
+ return parseEnvValue(contents, key);
36
+ } catch {
37
+ // File doesn't exist or can't be read
38
+ return null;
49
39
  }
50
- return processedLines.join('\n');
51
40
  }
52
41
  /**
53
- * Manage environment files for a new project
42
+ * Get an environment variable value from .env file (sync)
54
43
  *
55
- * Creates .env from .env.example (if exists) and populates PAYLOAD_SECRET
44
+ * @param projectPath - Path to project directory
45
+ * @param key - Environment variable name to retrieve
46
+ * @returns The value if found, null otherwise
47
+ */ export function getEnvVarSync(projectPath, key) {
48
+ const envPath = path.join(projectPath, '.env');
49
+ try {
50
+ const contents = fsSync.readFileSync(envPath, 'utf-8');
51
+ return parseEnvValue(contents, key);
52
+ } catch {
53
+ // File doesn't exist or can't be read
54
+ return null;
55
+ }
56
+ }
57
+ /**
58
+ * Add or update an environment variable in .env file
56
59
  *
57
60
  * @param projectPath - Path to project directory
58
- * @returns The generated payload secret
59
- */ export async function manageEnvFiles(projectPath) {
60
- const payloadSecret = generateSecret();
61
- const envExamplePath = path.join(projectPath, '.env.example');
61
+ * @param key - Environment variable name
62
+ * @param value - Environment variable value
63
+ */ export async function addOrUpdateEnvVar(projectPath, key, value) {
62
64
  const envPath = path.join(projectPath, '.env');
63
65
  try {
64
- // Check if .env.example exists
65
- let envExampleContents = '';
66
- try {
67
- envExampleContents = await fs.readFile(envExamplePath, 'utf-8');
68
- } catch {
69
- // No .env.example, create minimal .env
70
- envExampleContents = '';
71
- }
72
- // Check if .env already exists
66
+ let contents = '';
73
67
  let envExists = false;
68
+ // Try to read existing .env file
74
69
  try {
75
- await fs.access(envPath);
70
+ contents = await fs.readFile(envPath, 'utf-8');
76
71
  envExists = true;
77
72
  } catch {
78
- // .env doesn't exist
73
+ // .env doesn't exist, will create it
79
74
  }
80
- if (!envExists) {
81
- // Create .env from .env.example
82
- const sanitized = sanitizeEnv(envExampleContents, payloadSecret);
83
- await fs.writeFile(envPath, sanitized, 'utf-8');
84
- } else {
85
- // Update existing .env if it doesn't have PAYLOAD_SECRET
86
- const existingContents = await fs.readFile(envPath, 'utf-8');
87
- if (!existingContents.includes('PAYLOAD_SECRET=') && !existingContents.includes('PAYLOAD_SECRET_KEY=')) {
88
- const sanitized = sanitizeEnv(existingContents, payloadSecret);
89
- await fs.writeFile(envPath, sanitized, 'utf-8');
75
+ const lines = contents.split(/\r?\n/);
76
+ const seenKeys = new Set();
77
+ const processedLines = [];
78
+ let keyUpdated = false;
79
+ for (const line of lines){
80
+ // Skip empty lines at start if file didn't exist
81
+ if (!envExists && !line.trim()) {
82
+ continue;
83
+ }
84
+ // Preserve empty lines and comments
85
+ if (!line.trim() || line.trim().startsWith('#')) {
86
+ processedLines.push(line);
87
+ continue;
88
+ }
89
+ // Skip lines without =
90
+ if (!line.includes('=')) {
91
+ processedLines.push(line);
92
+ continue;
93
+ }
94
+ const [lineKey] = line.split('=');
95
+ const trimmedKey = lineKey.trim();
96
+ // Skip duplicate keys (keep first occurrence)
97
+ if (seenKeys.has(trimmedKey)) {
98
+ continue;
99
+ }
100
+ seenKeys.add(trimmedKey);
101
+ // Update or keep the line
102
+ if (trimmedKey === key) {
103
+ processedLines.push(`${key}=${value}`);
104
+ keyUpdated = true;
105
+ } else {
106
+ processedLines.push(line);
90
107
  }
91
108
  }
92
- return payloadSecret;
109
+ // Add key if not present
110
+ if (!keyUpdated) {
111
+ processedLines.push(`${key}=${value}`);
112
+ }
113
+ await fs.writeFile(envPath, processedLines.join('\n'), 'utf-8');
93
114
  } catch (error) {
94
- throw new Error(`Failed to manage environment files: ${error instanceof Error ? error.message : 'Unknown error'}`);
115
+ throw new Error(`Failed to update .env file: ${error instanceof Error ? error.message : 'Unknown error'}`);
116
+ }
117
+ }
118
+ /**
119
+ * Remove an environment variable from .env file
120
+ *
121
+ * @param projectPath - Path to project directory
122
+ * @param key - Environment variable name to remove
123
+ * @returns true if key was found and removed, false otherwise
124
+ */ export async function removeEnvVar(projectPath, key) {
125
+ const envPath = path.join(projectPath, '.env');
126
+ try {
127
+ const contents = await fs.readFile(envPath, 'utf-8');
128
+ const lines = contents.split(/\r?\n/);
129
+ const filteredLines = [];
130
+ let found = false;
131
+ for (const line of lines){
132
+ if (line.trim() && !line.trim().startsWith('#') && line.includes('=')) {
133
+ const equalsIndex = line.indexOf('=');
134
+ const lineKey = line.substring(0, equalsIndex).trim();
135
+ if (lineKey === key) {
136
+ found = true;
137
+ continue;
138
+ }
139
+ }
140
+ filteredLines.push(line);
141
+ }
142
+ if (found) {
143
+ // Collapse consecutive blank lines and trim leading/trailing blank lines
144
+ const collapsed = filteredLines.join('\n').replace(/\n{3,}/g, '\n\n').replace(/^\n+/, '');
145
+ await fs.writeFile(envPath, collapsed, 'utf-8');
146
+ }
147
+ return found;
148
+ } catch {
149
+ return false;
95
150
  }
96
151
  }
97
-
98
- //# sourceMappingURL=env-management.js.map
@@ -0,0 +1,11 @@
1
+ import type { Environment } from '../constants.js';
2
+ /**
3
+ * Format environment suffix for user-facing messages.
4
+ * Returns empty string for production (default), suffix for other environments.
5
+ *
6
+ * @param env - The environment
7
+ * @param prefix - Prefix before environment name (default: ' to ')
8
+ * @param suffix - Suffix after environment name (default: '')
9
+ * @returns Formatted string or empty string for production
10
+ */
11
+ export declare function formatEnvSuffix(env: Environment, prefix?: string, suffix?: string): string;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Format environment suffix for user-facing messages.
3
+ * Returns empty string for production (default), suffix for other environments.
4
+ *
5
+ * @param env - The environment
6
+ * @param prefix - Prefix before environment name (default: ' to ')
7
+ * @param suffix - Suffix after environment name (default: '')
8
+ * @returns Formatted string or empty string for production
9
+ */ export function formatEnvSuffix(env, prefix = ' to ', suffix = '') {
10
+ return env !== 'production' ? `${prefix}${env}${suffix}` : '';
11
+ }
@@ -20,4 +20,3 @@ export declare function getTimeUntilExpiry(expiresAt: number): string;
20
20
  * @returns Masked token string (e.g., "eyJh********************************mFbc")
21
21
  */
22
22
  export declare function maskToken(token: string): string;
23
- //# sourceMappingURL=format.d.ts.map
@@ -45,5 +45,3 @@
45
45
  }
46
46
  return `${token.slice(0, 4)}${'*'.repeat(Math.min(token.length - 8, 32))}${token.slice(-4)}`;
47
47
  }
48
-
49
- //# sourceMappingURL=format.js.map
@@ -8,4 +8,3 @@ export type FormatResult = {
8
8
  * Returns warning if formatting fails but does not throw
9
9
  */
10
10
  export declare function formatFile(filePath: string, packageManager: PackageManager): Promise<FormatResult>;
11
- //# sourceMappingURL=formatter.d.ts.map