@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
@@ -23,6 +23,59 @@ import path from 'path';
23
23
  return 'npm';
24
24
  }
25
25
  }
26
+ /**
27
+ * Resolve package manager for a project directory.
28
+ * Checks lockfiles first, falls back to environment detection.
29
+ *
30
+ * @param projectDir - Project directory to check
31
+ * @returns Resolved package manager
32
+ */ export async function resolvePackageManager(projectDir) {
33
+ const fromLockfile = await getPackageManager(projectDir);
34
+ if (fromLockfile !== 'npm') {
35
+ return fromLockfile;
36
+ }
37
+ // Check if there's actually a package-lock.json (explicit npm choice)
38
+ if (await fileExists(path.join(projectDir, 'package-lock.json'))) {
39
+ return 'npm';
40
+ }
41
+ // No lockfile found — check environment
42
+ return detectPackageManagerFromEnvironment();
43
+ }
44
+ /**
45
+ * Detect package manager from npm_config_user_agent environment variable.
46
+ * Set automatically by npm/pnpm/yarn when running via npx/pnpm dlx/yarn dlx.
47
+ *
48
+ * @returns Detected package manager, defaults to npm
49
+ */ export function detectPackageManagerFromEnvironment() {
50
+ const userAgent = process.env.npm_config_user_agent;
51
+ if (!userAgent) {
52
+ return 'npm';
53
+ }
54
+ if (userAgent.startsWith('pnpm/')) {
55
+ return 'pnpm';
56
+ }
57
+ if (userAgent.startsWith('yarn/')) {
58
+ return 'yarn';
59
+ }
60
+ return 'npm';
61
+ }
62
+ /**
63
+ * Get the run command prefix for a package manager.
64
+ * npm needs "npm run", pnpm/yarn can run scripts directly.
65
+ */ export function getRunCommand(packageManager) {
66
+ return packageManager === 'npm' ? 'npm run' : packageManager;
67
+ }
68
+ /**
69
+ * Get the add/install command for a package manager.
70
+ */ export function getAddCommand(packageManager) {
71
+ if (packageManager === 'npm') {
72
+ return 'npm install';
73
+ }
74
+ if (packageManager === 'pnpm') {
75
+ return 'pnpm add';
76
+ }
77
+ return 'yarn add';
78
+ }
26
79
  /**
27
80
  * Check if file exists
28
81
  */ async function fileExists(filePath) {
@@ -33,5 +86,3 @@ import path from 'path';
33
86
  return false;
34
87
  }
35
88
  }
36
-
37
- //# sourceMappingURL=package-manager.js.map
@@ -0,0 +1,11 @@
1
+ import type { TemplateSource } from './download-template.js';
2
+ export declare class TemplateSpecParseError extends Error {
3
+ constructor(message: string);
4
+ }
5
+ /**
6
+ * Parse a --template spec string into a partial TemplateSource override.
7
+ *
8
+ * Format: [<owner>/<repo>#]<ref>:<template-path>
9
+ * Shorthand: a bare token with no `#` and no `:` is treated as the template path.
10
+ */
11
+ export declare function parseTemplateSpec(spec: string): Partial<TemplateSource>;
@@ -0,0 +1,60 @@
1
+ export class TemplateSpecParseError extends Error {
2
+ constructor(message){
3
+ super(message);
4
+ this.name = 'TemplateSpecParseError';
5
+ }
6
+ }
7
+ /**
8
+ * Parse a --template spec string into a partial TemplateSource override.
9
+ *
10
+ * Format: [<owner>/<repo>#]<ref>:<template-path>
11
+ * Shorthand: a bare token with no `#` and no `:` is treated as the template path.
12
+ */ export function parseTemplateSpec(spec) {
13
+ const trimmed = spec.trim();
14
+ if (!trimmed) {
15
+ throw new TemplateSpecParseError('Template spec is empty');
16
+ }
17
+ let rest = trimmed;
18
+ const result = {};
19
+ const hashIndex = rest.indexOf('#');
20
+ if (hashIndex !== -1) {
21
+ const repoPart = rest.slice(0, hashIndex);
22
+ rest = rest.slice(hashIndex + 1);
23
+ const slashCount = (repoPart.match(/\//g) ?? []).length;
24
+ if (slashCount !== 1) {
25
+ throw new TemplateSpecParseError(`Expected "<owner>/<repo>" before "#", got "${repoPart}"`);
26
+ }
27
+ const [owner, repo] = repoPart.split('/');
28
+ if (!owner || !repo) {
29
+ throw new TemplateSpecParseError(`Invalid owner/repo: "${repoPart}"`);
30
+ }
31
+ result.owner = owner;
32
+ result.repo = repo;
33
+ } else {
34
+ // Check for slash only in the portion before the first colon (the ref part).
35
+ // Slashes after the colon are valid multi-segment template paths.
36
+ const beforeColon = rest.includes(':') ? rest.slice(0, rest.indexOf(':')) : rest;
37
+ if (beforeColon.includes('/')) {
38
+ throw new TemplateSpecParseError(`"<owner>/<repo>" must be followed by "#<ref>" (got "${trimmed}")`);
39
+ }
40
+ }
41
+ const colonIndex = rest.indexOf(':');
42
+ if (colonIndex !== -1) {
43
+ const ref = rest.slice(0, colonIndex);
44
+ const templatePath = rest.slice(colonIndex + 1);
45
+ if (!ref) {
46
+ throw new TemplateSpecParseError('Ref before ":" is empty');
47
+ }
48
+ if (!templatePath) {
49
+ throw new TemplateSpecParseError('Template path after ":" is empty');
50
+ }
51
+ result.ref = ref;
52
+ result.templatePath = templatePath;
53
+ return result;
54
+ }
55
+ if (hashIndex !== -1) {
56
+ throw new TemplateSpecParseError('Spec with "<owner>/<repo>#<ref>" must include ":<template-path>"');
57
+ }
58
+ result.templatePath = rest;
59
+ return result;
60
+ }
@@ -1,19 +1,39 @@
1
1
  import type { SourceFile } from 'ts-morph';
2
+ /**
3
+ * Result of detecting what changes are needed in a payload config file
4
+ */
2
5
  export type DetectionResult = {
6
+ /** Database adapter configuration if present */
3
7
  dbProperty?: {
8
+ /** Name of the adapter function (e.g., 'mongooseAdapter', 'postgresAdapter') */
4
9
  adapter: string;
10
+ /** NPM package the adapter is imported from (e.g., '@payloadcms/db-mongodb') */
5
11
  importSource: string;
6
12
  };
13
+ /** Editor configuration if present */
7
14
  editorProperty?: {
15
+ /** NPM package the editor is imported from (e.g., '@payloadcms/richtext-lexical') */
8
16
  importSource: string;
17
+ /** Whether this is a default editor with no custom configuration */
9
18
  isDefault: boolean;
10
19
  };
20
+ /** Whether the config already has a `figma` property */
11
21
  figmaObjectExists: boolean;
22
+ /** Whether buildConfig/buildFigmaConfig uses an import alias (e.g., 'buildConfig as createConfig') */
12
23
  hasAlias: boolean;
24
+ /** Whether a buildConfig or buildFigmaConfig call was found (undefined if not checked) */
13
25
  hasBuildConfig?: boolean;
26
+ /** Whether there are other imports from 'payload' besides buildConfig (e.g., types) */
14
27
  hasOtherPayloadImports: boolean;
28
+ /** Whether the import needs to be changed from 'payload' to '@payloadcms/figma' */
15
29
  needsImportChange: boolean;
30
+ /** Whether a `secret` property exists in the config */
16
31
  secretProperty?: boolean;
32
+ /** Sharp configuration if present */
33
+ sharpProperty?: {
34
+ /** NPM package sharp is imported from (always 'sharp') */
35
+ importSource: string;
36
+ };
17
37
  };
18
38
  /**
19
39
  * Detect what changes are needed in the payload config file
@@ -29,9 +49,8 @@ export type ASTModificationResult = {
29
49
  */
30
50
  export declare function applyModifications(sourceFile: SourceFile, detection: DetectionResult): ASTModificationResult;
31
51
  export type FigmaPropertyConfig = {
32
- region: string;
33
- tenantId: string;
34
- useContentSystem: boolean;
52
+ contentSystemId: string;
53
+ useContentSystem?: boolean;
35
54
  };
36
55
  /**
37
56
  * Add figma property to buildConfig if it doesn't exist
@@ -39,8 +58,9 @@ export type FigmaPropertyConfig = {
39
58
  */
40
59
  export declare function addFigmaProperty(sourceFile: SourceFile, config: FigmaPropertyConfig): ASTModificationResult;
41
60
  /**
42
- * Read figma configuration from payload.config.ts
43
- * Returns the figma object if it exists, null otherwise
61
+ * Remove the contentSystemId property from figma config object.
62
+ * Used during upgrade migration contentSystemId is now resolved from bootstrap data.
63
+ *
64
+ * @returns true if the property was found and removed
44
65
  */
45
- export declare function readFigmaConfig(sourceFile: SourceFile): FigmaPropertyConfig | null;
46
- //# sourceMappingURL=payload-config-ast.d.ts.map
66
+ export declare function removeFigmaContentSystemId(sourceFile: SourceFile): boolean;
@@ -9,9 +9,9 @@ import * as log from './log.js';
9
9
  hasOtherPayloadImports: false,
10
10
  needsImportChange: false
11
11
  };
12
- // Find buildConfig import
12
+ // Find buildConfig import — prefer @payloadcms/figma (already migrated) over payload
13
13
  const imports = sourceFile.getImportDeclarations();
14
- const payloadImport = imports.find((imp)=>imp.getModuleSpecifierValue() === 'payload' || imp.getModuleSpecifierValue() === '@payloadcms/figma');
14
+ const payloadImport = imports.find((imp)=>imp.getModuleSpecifierValue() === '@payloadcms/figma') || imports.find((imp)=>imp.getModuleSpecifierValue() === 'payload');
15
15
  if (!payloadImport) {
16
16
  log.debug('No payload or @payloadcms/figma import found');
17
17
  result.hasBuildConfig = false;
@@ -20,15 +20,18 @@ import * as log from './log.js';
20
20
  log.debug(`Found import from: ${payloadImport.getModuleSpecifierValue()}`);
21
21
  const moduleSpecifier = payloadImport.getModuleSpecifierValue();
22
22
  const namedImports = payloadImport.getNamedImports();
23
- // Check if buildConfig is imported
24
- const buildConfigImport = namedImports.find((ni)=>ni.getName() === 'buildConfig');
23
+ // Determine which function name to look for based on the import source
24
+ // - From 'payload': look for buildConfig (needs migration)
25
+ // - From '@payloadcms/figma': look for buildFigmaConfig (already migrated)
26
+ const expectedFunctionName = moduleSpecifier === 'payload' ? 'buildConfig' : 'buildFigmaConfig';
27
+ const buildConfigImport = namedImports.find((ni)=>ni.getName() === expectedFunctionName);
25
28
  if (!buildConfigImport) {
26
29
  result.hasBuildConfig = false;
27
30
  return result;
28
31
  }
29
32
  // Check for alias and get the actual name used in code
30
33
  const aliasNode = buildConfigImport.getAliasNode();
31
- const buildConfigName = aliasNode ? aliasNode.getText() : 'buildConfig';
34
+ const buildConfigName = aliasNode ? aliasNode.getText() : expectedFunctionName;
32
35
  if (aliasNode) {
33
36
  result.hasAlias = true;
34
37
  }
@@ -109,6 +112,15 @@ import * as log from './log.js';
109
112
  }
110
113
  }
111
114
  }
115
+ // Check for sharp property
116
+ const sharpProperty = configArg.getProperty('sharp');
117
+ if (sharpProperty) {
118
+ // Find the import source for sharp
119
+ const sharpImport = imports.find((imp)=>imp.getModuleSpecifierValue() === 'sharp' || imp.getNamedImports().some((ni)=>ni.getName() === 'sharp'));
120
+ result.sharpProperty = {
121
+ importSource: sharpImport?.getModuleSpecifierValue() || 'sharp'
122
+ };
123
+ }
112
124
  // Check for figma property
113
125
  const figmaProperty = configArg.getProperty('figma');
114
126
  if (figmaProperty) {
@@ -145,9 +157,27 @@ import * as log from './log.js';
145
157
  // Remove duplicates and sort in reverse order to avoid position shifts
146
158
  const uniqueRanges = Array.from(new Set(ranges.map((r)=>JSON.stringify(r)))).map((r)=>JSON.parse(r));
147
159
  uniqueRanges.sort((a, b)=>b[0] - a[0]);
148
- // Remove each comment range
160
+ // Remove each comment range, extending to the full line when the comment is the only content
149
161
  for (const [pos, end] of uniqueRanges){
150
- sourceFile.removeText(pos, end);
162
+ const fullText = sourceFile.getFullText();
163
+ let removeStart = pos;
164
+ let removeEnd = end;
165
+ // Find the start of the line containing this comment
166
+ let lineStart = pos;
167
+ while(lineStart > 0 && fullText[lineStart - 1] !== '\n'){
168
+ lineStart--;
169
+ }
170
+ const beforeComment = fullText.substring(lineStart, pos);
171
+ const nextNewline = fullText.indexOf('\n', end);
172
+ const afterComment = fullText.substring(end, nextNewline === -1 ? fullText.length : nextNewline);
173
+ // If the comment is the only content on this line, remove the entire line
174
+ if (beforeComment.trim() === '' && afterComment.trim() === '') {
175
+ removeStart = lineStart > 0 ? lineStart - 1 : lineStart;
176
+ if (nextNewline !== -1) {
177
+ removeEnd = nextNewline + 1;
178
+ }
179
+ }
180
+ sourceFile.removeText(removeStart, removeEnd);
151
181
  }
152
182
  return true;
153
183
  }
@@ -240,7 +270,16 @@ import * as log from './log.js';
240
270
  modified = true;
241
271
  }
242
272
  }
243
- // 4. Update buildConfig import
273
+ // 4. Remove sharp property
274
+ if (detection.sharpProperty) {
275
+ const sharpProperty = configArg.getProperty('sharp');
276
+ if (sharpProperty) {
277
+ sharpProperty.remove();
278
+ changes.push('Removed sharp property');
279
+ modified = true;
280
+ }
281
+ }
282
+ // 5. Update buildConfig import
244
283
  if (detection.needsImportChange) {
245
284
  if (payloadImport) {
246
285
  if (detection.hasOtherPayloadImports) {
@@ -258,19 +297,38 @@ import * as log from './log.js';
258
297
  sourceFile.addImportDeclaration({
259
298
  moduleSpecifier: '@payloadcms/figma',
260
299
  namedImports: [
261
- 'buildConfig'
300
+ 'buildFigmaConfig'
262
301
  ]
263
302
  });
303
+ // Rename all usages of 'buildConfig' to 'buildFigmaConfig'
304
+ const identifiers = sourceFile.getDescendantsOfKind(SyntaxKind.Identifier);
305
+ identifiers.forEach((identifier)=>{
306
+ if (identifier.getText() === 'buildConfig') {
307
+ identifier.replaceWithText('buildFigmaConfig');
308
+ }
309
+ });
264
310
  changes.push('Split buildConfig import to @payloadcms/figma');
265
311
  } else {
266
- // Replace entire import
312
+ // Replace entire import: change module specifier and rename all references
313
+ const buildConfigImport = payloadImport.getNamedImports().find((ni)=>ni.getName() === 'buildConfig');
314
+ if (buildConfigImport) {
315
+ // Change the import name
316
+ buildConfigImport.setName('buildFigmaConfig');
317
+ // Find and rename all usages of 'buildConfig' in the file
318
+ const identifiers = sourceFile.getDescendantsOfKind(SyntaxKind.Identifier);
319
+ identifiers.forEach((identifier)=>{
320
+ if (identifier.getText() === 'buildConfig') {
321
+ identifier.replaceWithText('buildFigmaConfig');
322
+ }
323
+ });
324
+ }
267
325
  payloadImport.setModuleSpecifier('@payloadcms/figma');
268
326
  changes.push('Changed buildConfig import to @payloadcms/figma');
269
327
  }
270
328
  modified = true;
271
329
  }
272
330
  }
273
- // 5. Remove orphaned imports
331
+ // 6. Remove orphaned imports
274
332
  // Re-fetch imports after each removal to avoid stale references
275
333
  if (detection.dbProperty) {
276
334
  const currentImports = sourceFile.getImportDeclarations();
@@ -290,6 +348,15 @@ import * as log from './log.js';
290
348
  modified = true;
291
349
  }
292
350
  }
351
+ if (detection.sharpProperty) {
352
+ const currentImports = sourceFile.getImportDeclarations();
353
+ const sharpImport = currentImports.find((imp)=>imp.getModuleSpecifierValue() === 'sharp');
354
+ if (sharpImport) {
355
+ sharpImport.remove();
356
+ changes.push('Removed sharp import');
357
+ modified = true;
358
+ }
359
+ }
293
360
  return {
294
361
  changes,
295
362
  modified
@@ -301,15 +368,15 @@ import * as log from './log.js';
301
368
  */ export function addFigmaProperty(sourceFile, config) {
302
369
  const changes = [];
303
370
  let modified = false;
304
- // Find buildConfig call
371
+ // Find buildFigmaConfig call (this function is only used with Figma configs)
305
372
  const callExpressions = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression);
306
373
  const buildConfigCall = callExpressions.find((ce)=>{
307
374
  const expr = ce.getExpression();
308
375
  const text = expr.getText();
309
- return text === 'buildConfig' || text.endsWith('.buildConfig');
376
+ return text === 'buildFigmaConfig' || text.endsWith('.buildFigmaConfig');
310
377
  });
311
378
  if (!buildConfigCall) {
312
- log.debug('No buildConfig call found');
379
+ log.debug('No buildFigmaConfig call found');
313
380
  return {
314
381
  changes: [],
315
382
  modified: false
@@ -336,15 +403,14 @@ import * as log from './log.js';
336
403
  };
337
404
  }
338
405
  // Add figma property
406
+ // contentSystemId is resolved automatically by buildFigmaConfig from env vars or bootstrap cache.
407
+ // useContentSystem defaults to true, so we only generate it when explicitly false.
408
+ const figmaObj = config.useContentSystem === false ? `{\nuseContentSystem: false,\n}` : '{}';
339
409
  configArg.addPropertyAssignment({
340
410
  name: 'figma',
341
- initializer: `{
342
- region: '${config.region}',
343
- tenantId: '${config.tenantId}',
344
- useContentSystem: ${config.useContentSystem},
345
- }`
411
+ initializer: figmaObj
346
412
  });
347
- changes.push(`Added figma property (region: ${config.region}, tenantId: ${config.tenantId}, useContentSystem: ${config.useContentSystem})`);
413
+ changes.push(`Added figma property (contentSystemId: ${config.contentSystemId})`);
348
414
  modified = true;
349
415
  return {
350
416
  changes,
@@ -352,60 +418,40 @@ import * as log from './log.js';
352
418
  };
353
419
  }
354
420
  /**
355
- * Read figma configuration from payload.config.ts
356
- * Returns the figma object if it exists, null otherwise
357
- */ export function readFigmaConfig(sourceFile) {
358
- // Find buildConfig call
421
+ * Remove the contentSystemId property from figma config object.
422
+ * Used during upgrade migration contentSystemId is now resolved from bootstrap data.
423
+ *
424
+ * @returns true if the property was found and removed
425
+ */ export function removeFigmaContentSystemId(sourceFile) {
359
426
  const callExpressions = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression);
360
427
  const buildConfigCall = callExpressions.find((ce)=>{
361
428
  const expr = ce.getExpression();
362
429
  const text = expr.getText();
363
- return text === 'buildConfig' || text.endsWith('.buildConfig');
430
+ return text === 'buildFigmaConfig' || text.endsWith('.buildFigmaConfig');
364
431
  });
365
432
  if (!buildConfigCall) {
366
- log.debug('No buildConfig call found');
367
- return null;
433
+ return false;
368
434
  }
369
- // Get config object argument
370
435
  const configArg = buildConfigCall.getArguments()[0];
371
436
  if (!configArg || !Node.isObjectLiteralExpression(configArg)) {
372
- log.debug('buildConfig argument is not an object literal');
373
- return null;
437
+ return false;
374
438
  }
375
- // Find figma property
376
439
  const figmaProperty = configArg.getProperty('figma');
377
440
  if (!figmaProperty || !Node.isPropertyAssignment(figmaProperty)) {
378
- log.debug('No figma property found in buildConfig');
379
- return null;
441
+ return false;
380
442
  }
381
- // Get initializer (the object value)
382
443
  const initializer = figmaProperty.getInitializer();
383
444
  if (!initializer || !Node.isObjectLiteralExpression(initializer)) {
384
- log.debug('figma property is not an object literal');
385
- return null;
386
- }
387
- // Extract values
388
- const regionProp = initializer.getProperty('region');
389
- const tenantIdProp = initializer.getProperty('tenantId');
390
- const useContentSystemProp = initializer.getProperty('useContentSystem');
391
- if (!regionProp || !tenantIdProp) {
392
- log.debug('Missing required figma properties (region or tenantId)');
393
- return null;
394
- }
395
- // Extract string values (remove quotes)
396
- const region = Node.isPropertyAssignment(regionProp) ? regionProp.getInitializer()?.getText().replace(/['"]/g, '') : undefined;
397
- const tenantId = Node.isPropertyAssignment(tenantIdProp) ? tenantIdProp.getInitializer()?.getText().replace(/['"]/g, '') : undefined;
398
- const useContentSystem = Node.isPropertyAssignment(useContentSystemProp) ? useContentSystemProp.getInitializer()?.getText() === 'true' : true // Default to true if not specified
399
- ;
400
- if (!region || !tenantId) {
401
- log.debug('Could not extract region or tenantId values');
402
- return null;
445
+ return false;
403
446
  }
404
- return {
405
- region,
406
- tenantId,
407
- useContentSystem
408
- };
447
+ const contentSystemIdProp = initializer.getProperty('contentSystemId');
448
+ if (!contentSystemIdProp) {
449
+ return false;
450
+ }
451
+ contentSystemIdProp.remove();
452
+ // Collapse empty object to avoid ts-morph whitespace artifacts
453
+ if (initializer.getProperties().length === 0) {
454
+ initializer.replaceWithText('{}');
455
+ }
456
+ return true;
409
457
  }
410
-
411
- //# sourceMappingURL=payload-config-ast.js.map
@@ -1,9 +1,8 @@
1
1
  /**
2
- * Find the Payload config file using Payload's built-in finder
3
- * Changes to project directory temporarily and restores afterward
2
+ * Find the Payload config file using Payload's built-in finder when available,
3
+ * with fallback to simple file search for npx environments where payload isn't installed.
4
4
  *
5
5
  * @param projectPath - Absolute path to project directory
6
6
  * @returns Absolute path to config file, or null if not found
7
7
  */
8
8
  export declare function findPayloadConfig(projectPath: string): Promise<null | string>;
9
- //# sourceMappingURL=payload-config-finder.d.ts.map
@@ -1,26 +1,63 @@
1
- import { findConfig } from 'payload/node';
1
+ import fs from 'fs/promises';
2
+ import path from 'path';
3
+ import * as log from './log.js';
4
+ // Standard Payload config file names in priority order
5
+ const CONFIG_FILES = [
6
+ 'payload.config.ts',
7
+ 'payload.config.js',
8
+ 'src/payload.config.ts',
9
+ 'src/payload.config.js'
10
+ ];
2
11
  /**
3
- * Find the Payload config file using Payload's built-in finder
4
- * Changes to project directory temporarily and restores afterward
12
+ * Find the Payload config file using Payload's built-in finder when available,
13
+ * with fallback to simple file search for npx environments where payload isn't installed.
5
14
  *
6
15
  * @param projectPath - Absolute path to project directory
7
16
  * @returns Absolute path to config file, or null if not found
8
17
  */ export async function findPayloadConfig(projectPath) {
18
+ // First, try using Payload's official config finder (if payload is installed)
19
+ const configFromPayload = await findConfigWithPayload(projectPath);
20
+ if (configFromPayload) {
21
+ return configFromPayload;
22
+ }
23
+ // Fallback: Simple file search for standard config locations
24
+ // This works when running via npx before payload is installed
25
+ log.debug('Payload not available, using fallback config finder');
26
+ return findConfigFallback(projectPath);
27
+ }
28
+ /**
29
+ * Try to find config using Payload's findConfig function.
30
+ * Returns null if payload is not installed (dynamic import fails).
31
+ */ async function findConfigWithPayload(projectPath) {
9
32
  const originalCwd = process.cwd();
10
33
  try {
34
+ // Dynamic import - will fail gracefully if payload is not installed
35
+ const { findConfig } = await import('payload/node');
11
36
  // findConfig requires being in the project directory
12
37
  process.chdir(projectPath);
13
- // Use Payload's official config finder
14
38
  const configPath = findConfig();
15
- // Wrap in Promise.resolve to satisfy async requirement
16
- return await Promise.resolve(configPath || null);
17
- } catch {
18
- // Config not found or error occurred
39
+ return configPath || null;
40
+ } catch (error) {
41
+ // payload not installed or other error - return null to use fallback
42
+ log.debug(`Could not use Payload findConfig: ${error instanceof Error ? error.message : 'unknown'}`);
19
43
  return null;
20
44
  } finally{
21
- // Always restore original working directory
22
45
  process.chdir(originalCwd);
23
46
  }
24
47
  }
25
-
26
- //# sourceMappingURL=payload-config-finder.js.map
48
+ /**
49
+ * Fallback config finder that checks standard locations.
50
+ * Used when payload is not installed (e.g., running via npx).
51
+ */ async function findConfigFallback(projectPath) {
52
+ for (const configFile of CONFIG_FILES){
53
+ const fullPath = path.join(projectPath, configFile);
54
+ try {
55
+ await fs.access(fullPath);
56
+ log.debug(`Found config at: ${fullPath}`);
57
+ return fullPath;
58
+ } catch {
59
+ // File doesn't exist, try next
60
+ }
61
+ }
62
+ return null;
63
+ }
@@ -15,5 +15,4 @@ export declare function ensurePayloadFigmaConfig(projectPath: string, packageMan
15
15
  /**
16
16
  * Display manual configuration instructions
17
17
  */
18
- export declare function displayManualInstructions(reason: string): void;
19
- //# sourceMappingURL=payload-config-modifier.d.ts.map
18
+ export declare function displayManualInstructions(reason: string, packageManager?: PackageManager): void;