@payloadcms/figma 0.0.1-alpha.7 → 0.0.1-alpha.71

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 (390) hide show
  1. package/dist/api/control-plane.d.ts +56 -6
  2. package/dist/api/control-plane.js +181 -72
  3. package/dist/api/figma-api.d.ts +22 -1
  4. package/dist/api/figma-api.js +78 -25
  5. package/dist/auth/callback-server.d.ts +19 -7
  6. package/dist/auth/callback-server.js +72 -30
  7. package/dist/auth/credentials.d.ts +21 -0
  8. package/dist/auth/credentials.js +21 -0
  9. package/dist/auth/crypto-utils.d.ts +28 -0
  10. package/dist/auth/crypto-utils.js +132 -21
  11. package/dist/auth/jwt-validator.d.ts +2 -1
  12. package/dist/auth/jwt-validator.js +2 -2
  13. package/dist/auth/oauth-flow.d.ts +19 -3
  14. package/dist/auth/oauth-flow.js +77 -22
  15. package/dist/auth/project-token.d.ts +32 -16
  16. package/dist/auth/project-token.js +171 -65
  17. package/dist/auth/refresh.d.ts +2 -1
  18. package/dist/auth/refresh.js +25 -12
  19. package/dist/auth/token-store-migration.d.ts +58 -0
  20. package/dist/auth/token-store-migration.js +156 -0
  21. package/dist/auth/token-store.d.ts +63 -97
  22. package/dist/auth/token-store.js +405 -122
  23. package/dist/auth/types.d.ts +35 -4
  24. package/dist/cli.js +93 -6
  25. package/dist/commands/bootstrap.d.ts +18 -0
  26. package/dist/commands/bootstrap.js +90 -0
  27. package/dist/commands/build-lambda-zip.d.ts +5 -0
  28. package/dist/commands/build-lambda-zip.js +19 -0
  29. package/dist/commands/debug.d.ts +8 -0
  30. package/dist/commands/debug.js +180 -0
  31. package/dist/commands/deploy.d.ts +9 -0
  32. package/dist/commands/deploy.js +180 -151
  33. package/dist/commands/dump-tokens.d.ts +12 -0
  34. package/dist/commands/dump-tokens.js +69 -0
  35. package/dist/commands/env.d.ts +13 -0
  36. package/dist/commands/env.js +88 -0
  37. package/dist/commands/init.d.ts +9 -5
  38. package/dist/commands/init.js +241 -148
  39. package/dist/commands/list-tokens.d.ts +3 -3
  40. package/dist/commands/list-tokens.js +24 -9
  41. package/dist/commands/login.d.ts +8 -1
  42. package/dist/commands/login.js +34 -16
  43. package/dist/commands/logout.d.ts +5 -4
  44. package/dist/commands/logout.js +77 -15
  45. package/dist/commands/upgrade.d.ts +5 -0
  46. package/dist/commands/upgrade.js +331 -0
  47. package/dist/config/oauth.d.ts +17 -11
  48. package/dist/config/oauth.js +38 -37
  49. package/dist/constants.d.ts +63 -18
  50. package/dist/constants.js +158 -18
  51. package/dist/db-content-api/generated/content-api-types.d.ts +3978 -0
  52. package/dist/db-content-api/generated/content-api-types.js +7 -0
  53. package/dist/db-content-api/index.d.ts +37 -0
  54. package/dist/db-content-api/index.js +923 -0
  55. package/dist/db-content-api/temp-utilities/slug.d.ts +2 -0
  56. package/dist/db-content-api/temp-utilities/slug.js +3 -0
  57. package/dist/db-content-api/temp-utilities/sorting.d.ts +3 -0
  58. package/dist/db-content-api/temp-utilities/sorting.js +39 -0
  59. package/dist/db-content-api/temp-utilities/types.d.ts +22 -0
  60. package/dist/db-content-api/temp-utilities/types.js +15 -0
  61. package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +39 -0
  62. package/dist/db-content-api/temp-utilities/unwrapDocument.js +64 -0
  63. package/dist/db-content-api/utilities/auth.d.ts +30 -0
  64. package/dist/db-content-api/utilities/auth.js +84 -0
  65. package/dist/db-content-api/utilities/data/applyDefaults.d.ts +7 -0
  66. package/dist/db-content-api/utilities/data/applyDefaults.js +75 -0
  67. package/dist/db-content-api/utilities/data/castFieldValue.d.ts +11 -0
  68. package/dist/db-content-api/utilities/data/castFieldValue.js +68 -0
  69. package/dist/db-content-api/utilities/data/index.d.ts +49 -0
  70. package/dist/db-content-api/utilities/data/index.js +301 -0
  71. package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +12 -0
  72. package/dist/db-content-api/utilities/data/removeVirtualFields.js +54 -0
  73. package/dist/db-content-api/utilities/data/stripFields.d.ts +48 -0
  74. package/dist/db-content-api/utilities/data/stripFields.js +195 -0
  75. package/dist/db-content-api/utilities/data/transformPublishedLocale.d.ts +23 -0
  76. package/dist/db-content-api/utilities/data/transformPublishedLocale.js +42 -0
  77. package/dist/db-content-api/utilities/data/validateRelationships.d.ts +7 -0
  78. package/dist/db-content-api/utilities/data/validateRelationships.js +102 -0
  79. package/dist/db-content-api/utilities/joins.d.ts +53 -0
  80. package/dist/db-content-api/utilities/joins.js +139 -0
  81. package/dist/db-content-api/utilities/locale/index.d.ts +10 -0
  82. package/dist/db-content-api/utilities/locale/index.js +21 -0
  83. package/dist/db-content-api/utilities/meta/buildLocalizedPaths.d.ts +11 -0
  84. package/dist/db-content-api/utilities/meta/buildLocalizedPaths.js +74 -0
  85. package/dist/db-content-api/utilities/meta/buildMeta.d.ts +42 -0
  86. package/dist/db-content-api/utilities/meta/buildMeta.js +41 -0
  87. package/dist/db-content-api/utilities/meta/buildPathTypes.d.ts +17 -0
  88. package/dist/db-content-api/utilities/meta/buildPathTypes.js +244 -0
  89. package/dist/db-content-api/utilities/meta/buildUniquePaths.d.ts +13 -0
  90. package/dist/db-content-api/utilities/meta/buildUniquePaths.js +62 -0
  91. package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.d.ts +10 -0
  92. package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.js +102 -0
  93. package/dist/db-content-api/utilities/where.d.ts +20 -0
  94. package/dist/db-content-api/utilities/where.js +108 -0
  95. package/dist/deploy/schedule-extract-plugin.d.ts +11 -0
  96. package/dist/deploy/schedule-extract-plugin.js +34 -0
  97. package/dist/endpoints/health.d.ts +3 -0
  98. package/dist/endpoints/health.js +11 -0
  99. package/dist/endpoints/schema.d.ts +3 -0
  100. package/dist/endpoints/schema.js +29 -0
  101. package/dist/exports/client.d.ts +3 -0
  102. package/dist/exports/client.js +3 -0
  103. package/dist/index.d.ts +2 -1
  104. package/dist/index.js +3 -1
  105. package/dist/lib/download-skill.d.ts +13 -0
  106. package/dist/lib/download-skill.js +79 -0
  107. package/dist/oauth/components/FigmaAvatar/index.d.ts +4 -0
  108. package/dist/oauth/components/FigmaAvatar/index.js +27 -0
  109. package/dist/oauth/components/FigmaAvatar/index.scss +12 -0
  110. package/dist/oauth/components/FigmaAvatarCell/index.d.ts +5 -0
  111. package/dist/oauth/components/FigmaAvatarCell/index.js +25 -0
  112. package/dist/oauth/components/FigmaAvatarCell/index.scss +5 -0
  113. package/dist/oauth/components/FigmaAvatarPlaceholder/index.d.ts +9 -0
  114. package/dist/oauth/components/FigmaAvatarPlaceholder/index.js +37 -0
  115. package/dist/oauth/components/FigmaAvatarPlaceholder/index.scss +28 -0
  116. package/dist/oauth/components/LoginButton/iframeAutoLogin.d.ts +82 -0
  117. package/dist/oauth/components/LoginButton/iframeAutoLogin.js +170 -0
  118. package/dist/oauth/components/LoginButton/index.js +150 -12
  119. package/dist/oauth/components/LoginButton/index.scss +75 -3
  120. package/dist/oauth/components/LogoutButton/index.js +20 -7
  121. package/dist/oauth/defaults.d.ts +3 -1
  122. package/dist/oauth/defaults.js +68 -10
  123. package/dist/oauth/endpoints/getLoginEndpoint.js +72 -77
  124. package/dist/oauth/endpoints/getLogoutEndpoint.js +7 -4
  125. package/dist/oauth/endpoints/getMetaEndpoint.js +18 -3
  126. package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js +11 -2
  127. package/dist/oauth/index.js +27 -5
  128. package/dist/oauth/strategy/index.d.ts +0 -2
  129. package/dist/oauth/strategy/index.js +40 -17
  130. package/dist/oauth/types.d.ts +23 -6
  131. package/dist/oauth/utilities/establishSession.d.ts +23 -0
  132. package/dist/oauth/utilities/establishSession.js +82 -0
  133. package/dist/oauth/utilities/exchangeCodeForAccessToken.d.ts +24 -0
  134. package/dist/oauth/utilities/exchangeCodeForAccessToken.js +28 -0
  135. package/dist/oauth/utilities/figmaHostnames.d.ts +3 -0
  136. package/dist/oauth/utilities/figmaHostnames.js +26 -0
  137. package/dist/oauth/utilities/getAuthorizeURL.d.ts +65 -1
  138. package/dist/oauth/utilities/getAuthorizeURL.js +57 -2
  139. package/dist/oauth/utilities/isAbsoluteURL.d.ts +2 -0
  140. package/dist/oauth/utilities/isAbsoluteURL.js +3 -0
  141. package/dist/oauth/utilities/isDuplicateKeyError.d.ts +7 -0
  142. package/dist/oauth/utilities/isDuplicateKeyError.js +14 -0
  143. package/dist/oauth/utilities/refreshTokens.js +6 -3
  144. package/dist/plugin/auth-preflight.d.ts +8 -0
  145. package/dist/plugin/auth-preflight.js +20 -0
  146. package/dist/plugin/bootstrap-preflight.d.ts +23 -0
  147. package/dist/plugin/bootstrap-preflight.js +45 -0
  148. package/dist/plugin/build-config.d.ts +27 -15
  149. package/dist/plugin/build-config.js +327 -17
  150. package/dist/plugin/dev-cookie-names.d.ts +14 -0
  151. package/dist/plugin/dev-cookie-names.js +19 -0
  152. package/dist/storage-content-api/api-types.d.ts +168 -0
  153. package/dist/storage-content-api/api-types.js +6 -0
  154. package/dist/storage-content-api/client-uploads/ClientUploadHandler.d.ts +9 -0
  155. package/dist/storage-content-api/client-uploads/ClientUploadHandler.js +43 -0
  156. package/dist/storage-content-api/client-uploads/generateSignedURL.d.ts +13 -0
  157. package/dist/storage-content-api/client-uploads/generateSignedURL.js +39 -0
  158. package/dist/storage-content-api/client.d.ts +6 -0
  159. package/dist/storage-content-api/client.js +39 -0
  160. package/dist/storage-content-api/generateURL.d.ts +7 -0
  161. package/dist/storage-content-api/generateURL.js +8 -0
  162. package/dist/storage-content-api/handleDelete.d.ts +8 -0
  163. package/dist/storage-content-api/handleDelete.js +17 -0
  164. package/dist/storage-content-api/handleUpload.d.ts +11 -0
  165. package/dist/storage-content-api/handleUpload.js +144 -0
  166. package/dist/storage-content-api/index.d.ts +5 -0
  167. package/dist/storage-content-api/index.js +31 -0
  168. package/dist/storage-content-api/staticHandler.d.ts +10 -0
  169. package/dist/storage-content-api/staticHandler.js +63 -0
  170. package/dist/storage-content-api/types.d.ts +10 -0
  171. package/dist/storage-content-api/types.js +3 -0
  172. package/dist/storage-content-api/utilities/getSafeFilename.d.ts +12 -0
  173. package/dist/storage-content-api/utilities/getSafeFilename.js +61 -0
  174. package/dist/storage-content-api/utilities/index.d.ts +3 -0
  175. package/dist/storage-content-api/utilities/index.js +4 -0
  176. package/dist/storage-content-api/utilities/parseClientUploadContext.d.ts +19 -0
  177. package/dist/storage-content-api/utilities/parseClientUploadContext.js +30 -0
  178. package/dist/templates/.env.example +5 -0
  179. package/dist/templates/README.md +19 -0
  180. package/dist/types/config.d.ts +2 -1
  181. package/dist/types/config.js +0 -2
  182. package/dist/types.d.ts +10 -1
  183. package/dist/utils/adapters/nextjs.d.ts +9 -0
  184. package/dist/utils/adapters/nextjs.js +64 -0
  185. package/dist/utils/adapters/nitro.d.ts +9 -0
  186. package/dist/utils/adapters/nitro.js +169 -0
  187. package/dist/utils/adapters/vite.d.ts +10 -0
  188. package/dist/utils/adapters/vite.js +33 -0
  189. package/dist/utils/asset-collection.d.ts +27 -6
  190. package/dist/utils/asset-collection.js +59 -30
  191. package/dist/utils/build-detection.d.ts +5 -11
  192. package/dist/utils/build-detection.js +74 -11
  193. package/dist/utils/build-lambda-zip.d.ts +16 -0
  194. package/dist/utils/build-lambda-zip.js +78 -0
  195. package/dist/utils/cache-bootstrap.d.ts +8 -0
  196. package/dist/utils/cache-bootstrap.js +18 -0
  197. package/dist/utils/config.js +1 -1
  198. package/dist/utils/deploy-adapter.d.ts +40 -0
  199. package/dist/utils/deploy-adapter.js +58 -0
  200. package/dist/utils/download-template.d.ts +9 -1
  201. package/dist/utils/download-template.js +24 -18
  202. package/dist/utils/env-management.d.ts +24 -7
  203. package/dist/utils/env-management.js +119 -64
  204. package/dist/utils/format-env-suffix.d.ts +12 -0
  205. package/dist/utils/format-env-suffix.js +13 -0
  206. package/dist/utils/formatter.js +23 -11
  207. package/dist/utils/fs-utils.d.ts +6 -0
  208. package/dist/utils/fs-utils.js +27 -0
  209. package/dist/utils/handle-upgrade.d.ts +9 -0
  210. package/dist/utils/handle-upgrade.js +41 -0
  211. package/dist/utils/lambda-config.d.ts +3 -1
  212. package/dist/utils/lambda-config.js +75 -78
  213. package/dist/utils/messages.d.ts +1 -2
  214. package/dist/utils/messages.js +39 -11
  215. package/dist/utils/package-manager.d.ts +24 -0
  216. package/dist/utils/package-manager.js +53 -0
  217. package/dist/utils/parse-template-spec.d.ts +12 -0
  218. package/dist/utils/parse-template-spec.js +62 -0
  219. package/dist/utils/payload-config-ast.d.ts +27 -6
  220. package/dist/utils/payload-config-ast.js +106 -58
  221. package/dist/utils/payload-config-finder.d.ts +2 -2
  222. package/dist/utils/payload-config-finder.js +48 -9
  223. package/dist/utils/payload-config-modifier.d.ts +1 -1
  224. package/dist/utils/payload-config-modifier.js +114 -66
  225. package/dist/utils/payload-package-check.d.ts +33 -2
  226. package/dist/utils/payload-package-check.js +129 -28
  227. package/dist/utils/project.d.ts +7 -2
  228. package/dist/utils/project.js +60 -32
  229. package/dist/utils/resolve-environment.d.ts +14 -0
  230. package/dist/utils/resolve-environment.js +31 -0
  231. package/dist/utils/s3-upload.d.ts +7 -2
  232. package/dist/utils/s3-upload.js +39 -6
  233. package/dist/utils/token-display.d.ts +5 -1
  234. package/dist/utils/token-display.js +49 -22
  235. package/dist/utils/typescript-validator.js +4 -6
  236. package/dist/utils/version-check.d.ts +3 -0
  237. package/dist/utils/version-check.js +38 -0
  238. package/package.json +44 -15
  239. package/dist/api/control-plane.d.ts.map +0 -1
  240. package/dist/api/control-plane.js.map +0 -1
  241. package/dist/api/figma-api.d.ts.map +0 -1
  242. package/dist/api/figma-api.js.map +0 -1
  243. package/dist/auth/browser.d.ts.map +0 -1
  244. package/dist/auth/browser.js.map +0 -1
  245. package/dist/auth/callback-server.d.ts.map +0 -1
  246. package/dist/auth/callback-server.js.map +0 -1
  247. package/dist/auth/crypto-utils.d.ts.map +0 -1
  248. package/dist/auth/crypto-utils.js.map +0 -1
  249. package/dist/auth/jwt-validator.d.ts.map +0 -1
  250. package/dist/auth/jwt-validator.js.map +0 -1
  251. package/dist/auth/oauth-flow.d.ts.map +0 -1
  252. package/dist/auth/oauth-flow.js.map +0 -1
  253. package/dist/auth/pkce.d.ts.map +0 -1
  254. package/dist/auth/pkce.js.map +0 -1
  255. package/dist/auth/project-token.d.ts.map +0 -1
  256. package/dist/auth/project-token.js.map +0 -1
  257. package/dist/auth/refresh.d.ts.map +0 -1
  258. package/dist/auth/refresh.js.map +0 -1
  259. package/dist/auth/token-store.d.ts.map +0 -1
  260. package/dist/auth/token-store.js.map +0 -1
  261. package/dist/auth/types.d.ts.map +0 -1
  262. package/dist/auth/types.js.map +0 -1
  263. package/dist/cli.d.ts.map +0 -1
  264. package/dist/cli.js.map +0 -1
  265. package/dist/commands/deploy.d.ts.map +0 -1
  266. package/dist/commands/deploy.js.map +0 -1
  267. package/dist/commands/init.d.ts.map +0 -1
  268. package/dist/commands/init.js.map +0 -1
  269. package/dist/commands/list-tokens.d.ts.map +0 -1
  270. package/dist/commands/list-tokens.js.map +0 -1
  271. package/dist/commands/login.d.ts.map +0 -1
  272. package/dist/commands/login.js.map +0 -1
  273. package/dist/commands/logout.d.ts.map +0 -1
  274. package/dist/commands/logout.js.map +0 -1
  275. package/dist/config/oauth.d.ts.map +0 -1
  276. package/dist/config/oauth.js.map +0 -1
  277. package/dist/constants.d.ts.map +0 -1
  278. package/dist/constants.js.map +0 -1
  279. package/dist/exports/client.d.ts.map +0 -1
  280. package/dist/exports/client.js.map +0 -1
  281. package/dist/index.d.ts.map +0 -1
  282. package/dist/index.js.map +0 -1
  283. package/dist/oauth/components/LoginButton/index.d.ts.map +0 -1
  284. package/dist/oauth/components/LoginButton/index.js.map +0 -1
  285. package/dist/oauth/components/LogoutButton/index.d.ts.map +0 -1
  286. package/dist/oauth/components/LogoutButton/index.js.map +0 -1
  287. package/dist/oauth/defaults.d.ts.map +0 -1
  288. package/dist/oauth/defaults.js.map +0 -1
  289. package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +0 -1
  290. package/dist/oauth/endpoints/getLoginEndpoint.js.map +0 -1
  291. package/dist/oauth/endpoints/getLogoutEndpoint.d.ts.map +0 -1
  292. package/dist/oauth/endpoints/getLogoutEndpoint.js.map +0 -1
  293. package/dist/oauth/endpoints/getMetaEndpoint.d.ts.map +0 -1
  294. package/dist/oauth/endpoints/getMetaEndpoint.js.map +0 -1
  295. package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts.map +0 -1
  296. package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js.map +0 -1
  297. package/dist/oauth/exports/client.d.ts.map +0 -1
  298. package/dist/oauth/exports/client.js.map +0 -1
  299. package/dist/oauth/hooks/afterLogout.d.ts.map +0 -1
  300. package/dist/oauth/hooks/afterLogout.js.map +0 -1
  301. package/dist/oauth/hooks/me.d.ts.map +0 -1
  302. package/dist/oauth/hooks/me.js.map +0 -1
  303. package/dist/oauth/hooks/refresh.d.ts.map +0 -1
  304. package/dist/oauth/hooks/refresh.js.map +0 -1
  305. package/dist/oauth/index.d.ts.map +0 -1
  306. package/dist/oauth/index.js.map +0 -1
  307. package/dist/oauth/strategy/index.d.ts.map +0 -1
  308. package/dist/oauth/strategy/index.js.map +0 -1
  309. package/dist/oauth/types.d.ts.map +0 -1
  310. package/dist/oauth/types.js.map +0 -1
  311. package/dist/oauth/utilities/clearCookie.d.ts.map +0 -1
  312. package/dist/oauth/utilities/clearCookie.js.map +0 -1
  313. package/dist/oauth/utilities/createCookieOptions.d.ts.map +0 -1
  314. package/dist/oauth/utilities/createCookieOptions.js.map +0 -1
  315. package/dist/oauth/utilities/createDebugLogger.d.ts.map +0 -1
  316. package/dist/oauth/utilities/createDebugLogger.js.map +0 -1
  317. package/dist/oauth/utilities/extractOrigin.d.ts.map +0 -1
  318. package/dist/oauth/utilities/extractOrigin.js.map +0 -1
  319. package/dist/oauth/utilities/getAdminCollectionSlug.d.ts.map +0 -1
  320. package/dist/oauth/utilities/getAdminCollectionSlug.js.map +0 -1
  321. package/dist/oauth/utilities/getAdminPath.d.ts +0 -8
  322. package/dist/oauth/utilities/getAdminPath.d.ts.map +0 -1
  323. package/dist/oauth/utilities/getAdminPath.js +0 -9
  324. package/dist/oauth/utilities/getAdminPath.js.map +0 -1
  325. package/dist/oauth/utilities/getAuthorizeURL.d.ts.map +0 -1
  326. package/dist/oauth/utilities/getAuthorizeURL.js.map +0 -1
  327. package/dist/oauth/utilities/getCookieExpiration.d.ts.map +0 -1
  328. package/dist/oauth/utilities/getCookieExpiration.js.map +0 -1
  329. package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts.map +0 -1
  330. package/dist/oauth/utilities/getSecondsFromTokenExp.js.map +0 -1
  331. package/dist/oauth/utilities/getTokenExp.d.ts.map +0 -1
  332. package/dist/oauth/utilities/getTokenExp.js.map +0 -1
  333. package/dist/oauth/utilities/getUsernameField.d.ts.map +0 -1
  334. package/dist/oauth/utilities/getUsernameField.js.map +0 -1
  335. package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts.map +0 -1
  336. package/dist/oauth/utilities/hasUserTokenPropsChanged.js.map +0 -1
  337. package/dist/oauth/utilities/mergeHeaders.d.ts.map +0 -1
  338. package/dist/oauth/utilities/mergeHeaders.js.map +0 -1
  339. package/dist/oauth/utilities/refreshTokens.d.ts.map +0 -1
  340. package/dist/oauth/utilities/refreshTokens.js.map +0 -1
  341. package/dist/plugin/adapter.d.ts.map +0 -1
  342. package/dist/plugin/adapter.js.map +0 -1
  343. package/dist/plugin/build-config.d.ts.map +0 -1
  344. package/dist/plugin/build-config.js.map +0 -1
  345. package/dist/types/config.d.ts.map +0 -1
  346. package/dist/types/config.js.map +0 -1
  347. package/dist/types.d.ts.map +0 -1
  348. package/dist/types.js.map +0 -1
  349. package/dist/utils/asset-collection.d.ts.map +0 -1
  350. package/dist/utils/asset-collection.js.map +0 -1
  351. package/dist/utils/build-detection.d.ts.map +0 -1
  352. package/dist/utils/build-detection.js.map +0 -1
  353. package/dist/utils/config.d.ts.map +0 -1
  354. package/dist/utils/config.js.map +0 -1
  355. package/dist/utils/download-template.d.ts.map +0 -1
  356. package/dist/utils/download-template.js.map +0 -1
  357. package/dist/utils/env-management.d.ts.map +0 -1
  358. package/dist/utils/env-management.js.map +0 -1
  359. package/dist/utils/format.d.ts.map +0 -1
  360. package/dist/utils/format.js.map +0 -1
  361. package/dist/utils/formatter.d.ts.map +0 -1
  362. package/dist/utils/formatter.js.map +0 -1
  363. package/dist/utils/git.d.ts.map +0 -1
  364. package/dist/utils/git.js.map +0 -1
  365. package/dist/utils/is-debug.d.ts.map +0 -1
  366. package/dist/utils/is-debug.js.map +0 -1
  367. package/dist/utils/lambda-config.d.ts.map +0 -1
  368. package/dist/utils/lambda-config.js.map +0 -1
  369. package/dist/utils/log.d.ts.map +0 -1
  370. package/dist/utils/log.js.map +0 -1
  371. package/dist/utils/messages.d.ts.map +0 -1
  372. package/dist/utils/messages.js.map +0 -1
  373. package/dist/utils/package-manager.d.ts.map +0 -1
  374. package/dist/utils/package-manager.js.map +0 -1
  375. package/dist/utils/payload-config-ast.d.ts.map +0 -1
  376. package/dist/utils/payload-config-ast.js.map +0 -1
  377. package/dist/utils/payload-config-finder.d.ts.map +0 -1
  378. package/dist/utils/payload-config-finder.js.map +0 -1
  379. package/dist/utils/payload-config-modifier.d.ts.map +0 -1
  380. package/dist/utils/payload-config-modifier.js.map +0 -1
  381. package/dist/utils/payload-package-check.d.ts.map +0 -1
  382. package/dist/utils/payload-package-check.js.map +0 -1
  383. package/dist/utils/project.d.ts.map +0 -1
  384. package/dist/utils/project.js.map +0 -1
  385. package/dist/utils/s3-upload.d.ts.map +0 -1
  386. package/dist/utils/s3-upload.js.map +0 -1
  387. package/dist/utils/token-display.d.ts.map +0 -1
  388. package/dist/utils/token-display.js.map +0 -1
  389. package/dist/utils/typescript-validator.d.ts.map +0 -1
  390. package/dist/utils/typescript-validator.js.map +0 -1
@@ -0,0 +1,301 @@
1
+ import { flattenAllFields, traverseFields } from 'payload';
2
+ import { applyDefaults } from './applyDefaults.js';
3
+ import { castFieldValue } from './castFieldValue.js';
4
+ import { removeVirtualFields } from './removeVirtualFields.js';
5
+ import { stripFields } from './stripFields.js';
6
+ import { transformToLocalizeStatus } from './transformPublishedLocale.js';
7
+ const ATOMIC_OPERATION_KEYS = [
8
+ '$push',
9
+ '$remove',
10
+ '$inc'
11
+ ];
12
+ function isAtomicOperation(value) {
13
+ if (value === null || value === undefined || typeof value !== 'object' || Array.isArray(value)) {
14
+ return false;
15
+ }
16
+ const keys = Object.keys(value);
17
+ return keys.length === 1 && ATOMIC_OPERATION_KEYS.includes(keys[0]);
18
+ }
19
+ /**
20
+ * Transform data before sending to Content API (WRITE operations)
21
+ *
22
+ * Conversions applied:
23
+ * - Default values: Apply static defaults for undefined fields (when applyDefaults=true)
24
+ * - Type casting: Convert values to match field types (e.g., number -> string for text fields)
25
+ * - RichText fields: Objects -> JSON strings
26
+ * - Virtual fields: Remove fields with `virtual: true` (pure virtual fields should never be saved)
27
+ * - Timestamps: Add updatedAt (always), and createdAt (when createdAt=true)
28
+ * - publishedLocale: Transform to localizeStatus format (when publishedLocale is provided)
29
+ *
30
+ * Note: Date fields are automatically converted to ISO strings by JSON.stringify()
31
+ */ export function dataToContentAPI(payload, collectionSlug, data, options) {
32
+ if (!data || typeof data !== 'object') {
33
+ return data;
34
+ }
35
+ // Transform publishedLocale to localizeStatus format before other transformations
36
+ const dataWithLocalizedStatus = transformToLocalizeStatus(data, options?.publishedLocale);
37
+ // Deep clone to avoid mutating original data
38
+ const transformed = JSON.parse(JSON.stringify(dataWithLocalizedStatus));
39
+ // Get collection config
40
+ const isGlobal = collectionSlug.startsWith('_global-');
41
+ const actualSlug = isGlobal ? collectionSlug.substring(8) : collectionSlug;
42
+ const collectionConfig = isGlobal ? payload.config.globals?.find((g)=>g.slug === actualSlug) : payload.config.collections.find((c)=>c.slug === actualSlug);
43
+ if (!collectionConfig?.fields) {
44
+ return transformed;
45
+ }
46
+ // Apply static defaults recursively to handle nested structures (arrays, groups)
47
+ // This must happen before traverseFields to ensure defaults are in place
48
+ if (options?.applyDefaults) {
49
+ applyDefaults(transformed, collectionConfig.fields);
50
+ }
51
+ // Use Payload's traverseFields to iterate over all fields for transformations
52
+ const callback = ({ field, ref })=>{
53
+ if (!('name' in field) || !field.name) {
54
+ return;
55
+ }
56
+ if (!ref || typeof ref !== 'object') {
57
+ return;
58
+ }
59
+ const current = ref;
60
+ let value = current[field.name];
61
+ if (isAtomicOperation(value)) {
62
+ return;
63
+ }
64
+ // null → [] for non-localized array-like fields. SQL adapters return null for empty join
65
+ // tables; Content API stores JSON null which breaks jsonb_array_elements queries.
66
+ if (value === null && !('localized' in field && field.localized)) {
67
+ const isHasManyArray = (field.type === 'relationship' || field.type === 'upload') && 'hasMany' in field && field.hasMany;
68
+ const isArrayLike = field.type === 'array' || field.type === 'blocks';
69
+ const isHasManySelect = field.type === 'select' && 'hasMany' in field && field.hasMany;
70
+ if (isHasManyArray || isArrayLike || isHasManySelect) {
71
+ current[field.name] = [];
72
+ return;
73
+ }
74
+ }
75
+ if (value !== null && value !== undefined) {
76
+ value = castFieldValue(field, value);
77
+ current[field.name] = value;
78
+ // Normalize non-localized hasMany relationship/upload: single value → array.
79
+ // Payload may not wrap in array before calling db.update (e.g. children: 'uuid').
80
+ const isNonLocalizedHasMany = !('localized' in field && field.localized) && (field.type === 'relationship' || field.type === 'upload') && 'hasMany' in field && field.hasMany;
81
+ if (isNonLocalizedHasMany && !Array.isArray(value)) {
82
+ current[field.name] = [
83
+ value
84
+ ];
85
+ }
86
+ // RichText: object -> JSON string
87
+ if (field.type === 'richText' && typeof value !== 'string') {
88
+ current[field.name] = JSON.stringify(value);
89
+ }
90
+ }
91
+ };
92
+ traverseFields({
93
+ callback,
94
+ fields: collectionConfig.fields,
95
+ fillEmpty: false,
96
+ ref: transformed
97
+ });
98
+ stripFields({
99
+ config: payload.config,
100
+ data: transformed,
101
+ fields: flattenAllFields({
102
+ cache: true,
103
+ fields: collectionConfig.fields
104
+ }),
105
+ reservedKeys: [
106
+ 'id',
107
+ 'globalType'
108
+ ]
109
+ });
110
+ removeVirtualFields(transformed, collectionConfig.fields);
111
+ // Convert numeric ID to string for Content API
112
+ const customIDType = payload.collections?.[collectionSlug]?.customIDType;
113
+ if (customIDType === 'number') {
114
+ transformed.id = String(transformed.id);
115
+ }
116
+ // Add timestamps (Content API no longer auto-sets these in DB)
117
+ // Preserve existing timestamps when already present (e.g. version data that carries
118
+ // the parent document's timestamps), otherwise generate new ones.
119
+ // Explicit null means "don't change" — strip it so the API keeps the existing value.
120
+ const now = new Date().toISOString();
121
+ if (transformed.updatedAt === null) {
122
+ delete transformed.updatedAt;
123
+ } else if (transformed.updatedAt === undefined) {
124
+ transformed.updatedAt = now;
125
+ }
126
+ if (options?.createdAt && !transformed.createdAt) {
127
+ transformed.createdAt = now;
128
+ }
129
+ return transformed;
130
+ }
131
+ /**
132
+ * Transform data received from Content API (READ operations)
133
+ *
134
+ * Conversions applied:
135
+ * - RichText fields: JSON strings -> Objects
136
+ * - Virtual fields: Remove fields with `virtual: true` (should not be in DB but Content API backend may add them)
137
+ *
138
+ * Note: Date fields come as ISO strings from Content API and stay as strings
139
+ * (matching MongoDB and other adapters' behavior)
140
+ */ /**
141
+ * Extract version content from versionData that may be flat (no nested `version` key).
142
+ * Some callers spread version content at the top level alongside metadata
143
+ * (e.g. `{ ...version.version, createdAt }`), so we reconstruct the `version`
144
+ * object by filtering out known metadata keys.
145
+ */ export function resolveVersionContent(version, versionMeta) {
146
+ if (version !== undefined) {
147
+ return version;
148
+ }
149
+ const metaKeys = [
150
+ 'createdAt',
151
+ 'updatedAt',
152
+ 'latest',
153
+ 'parent'
154
+ ];
155
+ return Object.fromEntries(Object.entries(versionMeta).filter(([key])=>!metaKeys.includes(key)));
156
+ }
157
+ export function dataFromContentAPI(payload, collectionSlug, data, locale) {
158
+ if (!data || typeof data !== 'object') {
159
+ return data;
160
+ }
161
+ // Deep clone to avoid mutating original data
162
+ const transformed = JSON.parse(JSON.stringify(data));
163
+ // Get collection config
164
+ const isGlobal = collectionSlug.startsWith('_global-');
165
+ const actualSlug = isGlobal ? collectionSlug.substring(8) : collectionSlug;
166
+ const collectionConfig = isGlobal ? payload.config.globals?.find((g)=>g.slug === actualSlug) : payload.config.collections.find((c)=>c.slug === actualSlug);
167
+ if (!collectionConfig?.fields) {
168
+ return transformed;
169
+ }
170
+ const isAllLocales = locale === 'all' || locale === '*';
171
+ // Use Payload's traverseFields to iterate over all fields
172
+ const callback = ({ field, parentPath, ref })=>{
173
+ if (!('name' in field) || !field.name) {
174
+ return;
175
+ }
176
+ if (!ref || typeof ref !== 'object') {
177
+ return;
178
+ }
179
+ const current = ref;
180
+ const value = current[field.name];
181
+ const isLocalized = 'localized' in field && field.localized;
182
+ // Group fields must always be an object so Payload can traverse sub-fields
183
+ // (e.g. join fields inside a group). A null/undefined group crashes afterRead.
184
+ if (field.type === 'group') {
185
+ if (value == null || typeof value !== 'object') {
186
+ current[field.name] = {};
187
+ }
188
+ return;
189
+ }
190
+ // Localized join fields: wrap in locale map so afterRead can hoist the value.
191
+ // Content API returns join data directly at the field path (e.g. { docs: [...] }),
192
+ // but Payload's afterRead expects localized fields as { [locale]: value }.
193
+ if (field.type === 'join' && isLocalized && value !== undefined && !isAllLocales && locale) {
194
+ current[field.name] = {
195
+ [locale]: value
196
+ };
197
+ return;
198
+ }
199
+ // Content API may omit fields; Payload expects null for optional fields.
200
+ // In all-locales mode, localized fields use {} so afterRead can safely iterate locale keys.
201
+ if (value === undefined) {
202
+ const isRequired = 'required' in field && field.required;
203
+ const isJoin = field.type === 'join';
204
+ if (!isRequired && !isJoin) {
205
+ current[field.name] = isLocalized && isAllLocales ? {} : null;
206
+ }
207
+ return;
208
+ }
209
+ // null localized field in all-locales mode → {} (empty locale map)
210
+ if (value === null && isLocalized && isAllLocales) {
211
+ current[field.name] = {};
212
+ return;
213
+ }
214
+ if (value !== null) {
215
+ // hasMany relationships: normalize to array (non-localized only).
216
+ // We store raw JSON so a single value stays as-is; Payload expects arrays.
217
+ if (field.type === 'relationship' && field.hasMany && !Array.isArray(value) && !('localized' in field && field.localized)) {
218
+ current[field.name] = [
219
+ value
220
+ ];
221
+ }
222
+ // Localized array/blocks: empty per-locale arrays → null in single-locale mode.
223
+ // Payload's afterRead fallback triggers on null (not []), matching SQL adapter behavior.
224
+ if (isLocalized && !isAllLocales && (field.type === 'array' || field.type === 'blocks') && typeof value === 'object' && !Array.isArray(value)) {
225
+ const localeMap = value;
226
+ for (const localeKey of Object.keys(localeMap)){
227
+ const localeValue = localeMap[localeKey];
228
+ if (Array.isArray(localeValue) && localeValue.length === 0) {
229
+ localeMap[localeKey] = null;
230
+ }
231
+ }
232
+ }
233
+ // Localized fields: JSON string → parsed object (locale map).
234
+ // Simple strings that fail to parse as objects are kept as-is (expected for single-locale).
235
+ if ('localized' in field && field.localized && typeof value === 'string') {
236
+ try {
237
+ const parsed = JSON.parse(value);
238
+ if (typeof parsed === 'object' && parsed !== null) {
239
+ current[field.name] = parsed;
240
+ }
241
+ } catch {
242
+ // Not valid JSON - keep original value
243
+ }
244
+ } else if (field.type === 'richText' && typeof value === 'string') {
245
+ try {
246
+ current[field.name] = JSON.parse(value);
247
+ } catch (error) {
248
+ const fieldPath = parentPath ? `${parentPath}.${field.name}` : field.name;
249
+ payload.logger.warn({
250
+ err: error instanceof Error ? error : new Error(String(error)),
251
+ msg: `Failed to parse richtext field '${fieldPath}' in collection '${collectionSlug}'`
252
+ });
253
+ }
254
+ }
255
+ // Date fields: Already ISO strings from Content API, no conversion needed
256
+ }
257
+ };
258
+ traverseFields({
259
+ callback,
260
+ fields: collectionConfig.fields,
261
+ fillEmpty: false,
262
+ ref: transformed
263
+ });
264
+ // Convert string ID to number if collection uses numeric custom ID
265
+ const customIDType = payload.collections?.[collectionSlug]?.customIDType;
266
+ if (customIDType === 'number') {
267
+ transformed.id = Number(transformed.id);
268
+ }
269
+ stripFields({
270
+ config: payload.config,
271
+ data: transformed,
272
+ fields: flattenAllFields({
273
+ cache: true,
274
+ fields: collectionConfig.fields
275
+ }),
276
+ reservedKeys: [
277
+ 'id',
278
+ 'globalType'
279
+ ]
280
+ });
281
+ // Remove virtual fields - must happen AFTER stripFields
282
+ removeVirtualFields(transformed, collectionConfig.fields);
283
+ // Handle auth-specific fields that aren't in the field schema
284
+ // When these fields are null in DB, Content API omits them from response (undefined)
285
+ // But Payload expects them to be null, not undefined
286
+ // Only add them if the collection has auth enabled
287
+ if ('auth' in collectionConfig && collectionConfig.auth) {
288
+ const authFields = [
289
+ 'resetPasswordExpiration',
290
+ 'lockUntil'
291
+ ];
292
+ for (const fieldName of authFields){
293
+ if (!(fieldName in transformed)) {
294
+ transformed[fieldName] = null;
295
+ }
296
+ }
297
+ }
298
+ return transformed;
299
+ }
300
+
301
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,12 @@
1
+ import type { CollectionConfig } from 'payload';
2
+ /**
3
+ * Removes virtual fields (fields with virtual: true) from data recursively.
4
+ * Virtual fields should never be persisted in the database.
5
+ *
6
+ * @todo It might be a good idea to combine `stripFields` with `stripFields`
7
+ * in a new utility that receives a callback with conditions. I didn't do
8
+ * it now because `stripFields` was copied from db-mongo and I'd like to
9
+ * find a way to unify everything.
10
+ */
11
+ export declare function removeVirtualFields(data: Record<string, unknown>, fieldConfigs: CollectionConfig['fields']): void;
12
+ //# sourceMappingURL=removeVirtualFields.d.ts.map
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Removes virtual fields (fields with virtual: true) from data recursively.
3
+ * Virtual fields should never be persisted in the database.
4
+ *
5
+ * @todo It might be a good idea to combine `stripFields` with `stripFields`
6
+ * in a new utility that receives a callback with conditions. I didn't do
7
+ * it now because `stripFields` was copied from db-mongo and I'd like to
8
+ * find a way to unify everything.
9
+ */ export function removeVirtualFields(data, fieldConfigs) {
10
+ for (const field of fieldConfigs){
11
+ // Handle UI fields (row, collapsible, tabs) - they don't have names
12
+ // but contain other fields that might be virtual
13
+ if (field.type === 'row' || field.type === 'collapsible') {
14
+ if ('fields' in field) {
15
+ removeVirtualFields(data, field.fields);
16
+ }
17
+ continue;
18
+ }
19
+ if (field.type === 'tabs' && 'tabs' in field) {
20
+ for (const tab of field.tabs){
21
+ if ('fields' in tab) {
22
+ removeVirtualFields(data, tab.fields);
23
+ }
24
+ }
25
+ continue;
26
+ }
27
+ // Skip fields without names
28
+ if (!('name' in field) || !field.name) {
29
+ continue;
30
+ }
31
+ // Remove field if it has virtual: true
32
+ if ('virtual' in field && field.virtual === true) {
33
+ delete data[field.name];
34
+ continue;
35
+ }
36
+ // Recursively handle nested structures (groups, arrays with items, etc.)
37
+ if ('fields' in field && field.name in data) {
38
+ const value = data[field.name];
39
+ if (field.type === 'array' && Array.isArray(value)) {
40
+ // Process each array item
41
+ for (const item of value){
42
+ if (item && typeof item === 'object') {
43
+ removeVirtualFields(item, field.fields);
44
+ }
45
+ }
46
+ } else if (field.type === 'group' && value && typeof value === 'object') {
47
+ // Process group
48
+ removeVirtualFields(value, field.fields);
49
+ }
50
+ }
51
+ }
52
+ }
53
+
54
+ //# sourceMappingURL=removeVirtualFields.js.map
@@ -0,0 +1,48 @@
1
+ import type { FlattenedField, SanitizedConfig } from 'payload';
2
+ /**
3
+ * Strips fields from data that are not defined in the schema or are invalid.
4
+ *
5
+ * This function was copied from the MongoDB adapter's implementation:
6
+ * @see packages/db-mongodb/src/utilities/transform.ts (stripFields function)
7
+ *
8
+ * @description
9
+ * This utility performs deep sanitization of document data by:
10
+ * 1. **Removing undefined fields**: Strips any field not present in the collection's schema
11
+ * (e.g., sensitive fields like `password`, `apiKey`, or any extra fields not in config)
12
+ * 2. **Removing invalid locales**: Deletes locale keys that don't exist in `config.localization.localeCodes`
13
+ * (e.g., if data contains `{ "es-MX": "..." }` but only `"en"` is configured)
14
+ * 3. **Removing invalid blocks**: Filters out blocks with unknown `blockType` values
15
+ * (prevents data corruption from blocks that don't exist in the schema)
16
+ * 4. **Recursive sanitization**: Processes nested structures (arrays, groups, blocks, localized fields)
17
+ * to ensure deep data integrity
18
+ *
19
+ * @remarks
20
+ * Unlike MongoDB's adapter which uses Mongoose schemas with `strict: true` (rejecting extra fields
21
+ * on write), Content API uses flexible JSONB storage that accepts any fields. Therefore, this
22
+ * function is called on **both read and write operations** to ensure data consistency.
23
+ *
24
+ * The MongoDB adapter also supports an `allowAdditionalKeys` option that allows reading/writing
25
+ * fields not in the schema. For now, Content API does not support this feature - we always
26
+ * sanitize data. If users request this functionality in the future, we can consider adding it.
27
+ *
28
+ * @todo
29
+ * 1. Consider moving this utility to `payload/shared` so both MongoDB and Content API adapters
30
+ * can use the same implementation, reducing code duplication and maintenance burden.
31
+ *
32
+ * 2. Performance optimization: This function iterates through all fields recursively.
33
+ * The `dataToContentAPI` and `dataFromContentAPI` functions in
34
+ * `packages/figma/src/db-content-api/utilities/data.ts` also iterate through fields
35
+ * to transform richText (object ↔ JSON string), custom IDs (number ↔ string), and dates.
36
+ * Consider combining both traversals into a single abstraction to avoid iterating twice.
37
+ *
38
+ * 3. Feature parity: MongoDB adapter has `allowAdditionalKeys` option. We currently always
39
+ * strip additional keys, but could add this as a configurable option if users need it.
40
+ */
41
+ export declare const stripFields: ({ config, data, fields, parentIsLocalized, reservedKeys, }: {
42
+ config: SanitizedConfig;
43
+ data: any;
44
+ fields: FlattenedField[];
45
+ parentIsLocalized?: boolean;
46
+ reservedKeys?: string[];
47
+ }) => void;
48
+ //# sourceMappingURL=stripFields.d.ts.map
@@ -0,0 +1,195 @@
1
+ import { fieldShouldBeLocalized } from 'payload/shared';
2
+ /**
3
+ * Strips fields from data that are not defined in the schema or are invalid.
4
+ *
5
+ * This function was copied from the MongoDB adapter's implementation:
6
+ * @see packages/db-mongodb/src/utilities/transform.ts (stripFields function)
7
+ *
8
+ * @description
9
+ * This utility performs deep sanitization of document data by:
10
+ * 1. **Removing undefined fields**: Strips any field not present in the collection's schema
11
+ * (e.g., sensitive fields like `password`, `apiKey`, or any extra fields not in config)
12
+ * 2. **Removing invalid locales**: Deletes locale keys that don't exist in `config.localization.localeCodes`
13
+ * (e.g., if data contains `{ "es-MX": "..." }` but only `"en"` is configured)
14
+ * 3. **Removing invalid blocks**: Filters out blocks with unknown `blockType` values
15
+ * (prevents data corruption from blocks that don't exist in the schema)
16
+ * 4. **Recursive sanitization**: Processes nested structures (arrays, groups, blocks, localized fields)
17
+ * to ensure deep data integrity
18
+ *
19
+ * @remarks
20
+ * Unlike MongoDB's adapter which uses Mongoose schemas with `strict: true` (rejecting extra fields
21
+ * on write), Content API uses flexible JSONB storage that accepts any fields. Therefore, this
22
+ * function is called on **both read and write operations** to ensure data consistency.
23
+ *
24
+ * The MongoDB adapter also supports an `allowAdditionalKeys` option that allows reading/writing
25
+ * fields not in the schema. For now, Content API does not support this feature - we always
26
+ * sanitize data. If users request this functionality in the future, we can consider adding it.
27
+ *
28
+ * @todo
29
+ * 1. Consider moving this utility to `payload/shared` so both MongoDB and Content API adapters
30
+ * can use the same implementation, reducing code duplication and maintenance burden.
31
+ *
32
+ * 2. Performance optimization: This function iterates through all fields recursively.
33
+ * The `dataToContentAPI` and `dataFromContentAPI` functions in
34
+ * `packages/figma/src/db-content-api/utilities/data.ts` also iterate through fields
35
+ * to transform richText (object ↔ JSON string), custom IDs (number ↔ string), and dates.
36
+ * Consider combining both traversals into a single abstraction to avoid iterating twice.
37
+ *
38
+ * 3. Feature parity: MongoDB adapter has `allowAdditionalKeys` option. We currently always
39
+ * strip additional keys, but could add this as a configurable option if users need it.
40
+ */ export const stripFields = ({ config, data, fields, parentIsLocalized = false, reservedKeys = [] })=>{
41
+ for(const k in data){
42
+ if (!fields.some((field)=>field.name === k) && !reservedKeys.includes(k)) {
43
+ delete data[k];
44
+ }
45
+ }
46
+ for (const field of fields){
47
+ reservedKeys = [];
48
+ const fieldData = data[field.name];
49
+ if (!fieldData || typeof fieldData !== 'object') {
50
+ continue;
51
+ }
52
+ const shouldLocalizeField = fieldShouldBeLocalized({
53
+ field,
54
+ parentIsLocalized
55
+ });
56
+ if (field.type === 'blocks') {
57
+ reservedKeys.push('blockType');
58
+ }
59
+ if ('flattenedFields' in field || 'blocks' in field) {
60
+ if (shouldLocalizeField && config.localization) {
61
+ for(const localeKey in fieldData){
62
+ if (!config.localization.localeCodes.some((code)=>code === localeKey)) {
63
+ delete fieldData[localeKey];
64
+ continue;
65
+ }
66
+ const localeData = fieldData[localeKey];
67
+ if (!localeData || typeof localeData !== 'object') {
68
+ continue;
69
+ }
70
+ if (field.type === 'array' || field.type === 'blocks') {
71
+ if (!Array.isArray(localeData)) {
72
+ continue;
73
+ }
74
+ let hasNull = false;
75
+ for(let i = 0; i < localeData.length; i++){
76
+ const data = localeData[i];
77
+ let fields = null;
78
+ if (field.type === 'array') {
79
+ fields = field.flattenedFields;
80
+ } else {
81
+ let maybeBlock = undefined;
82
+ if (field.blockReferences) {
83
+ const maybeBlockReference = field.blockReferences.find((each)=>{
84
+ const slug = typeof each === 'string' ? each : each.slug;
85
+ return slug === data.blockType;
86
+ });
87
+ if (maybeBlockReference) {
88
+ if (typeof maybeBlockReference === 'object') {
89
+ maybeBlock = maybeBlockReference;
90
+ } else {
91
+ maybeBlock = config.blocks?.find((each)=>each.slug === maybeBlockReference);
92
+ }
93
+ }
94
+ }
95
+ if (!maybeBlock) {
96
+ maybeBlock = field.blocks.find((each)=>each.slug === data.blockType);
97
+ }
98
+ if (maybeBlock) {
99
+ fields = maybeBlock.flattenedFields;
100
+ } else {
101
+ localeData[i] = null;
102
+ hasNull = true;
103
+ }
104
+ }
105
+ if (!fields) {
106
+ continue;
107
+ }
108
+ stripFields({
109
+ config,
110
+ data,
111
+ fields,
112
+ parentIsLocalized: parentIsLocalized || field.localized,
113
+ reservedKeys
114
+ });
115
+ }
116
+ if (hasNull) {
117
+ fieldData[localeKey] = localeData.filter(Boolean);
118
+ }
119
+ continue;
120
+ } else {
121
+ stripFields({
122
+ config,
123
+ data: localeData,
124
+ fields: field.flattenedFields,
125
+ parentIsLocalized: parentIsLocalized || field.localized,
126
+ reservedKeys
127
+ });
128
+ }
129
+ }
130
+ continue;
131
+ }
132
+ if (field.type === 'array' || field.type === 'blocks') {
133
+ if (!Array.isArray(fieldData)) {
134
+ continue;
135
+ }
136
+ let hasNull = false;
137
+ for(let i = 0; i < fieldData.length; i++){
138
+ const data = fieldData[i];
139
+ let fields = null;
140
+ if (field.type === 'array') {
141
+ fields = field.flattenedFields;
142
+ } else {
143
+ let maybeBlock = undefined;
144
+ if (field.blockReferences) {
145
+ const maybeBlockReference = field.blockReferences.find((each)=>{
146
+ const slug = typeof each === 'string' ? each : each.slug;
147
+ return slug === data.blockType;
148
+ });
149
+ if (maybeBlockReference) {
150
+ if (typeof maybeBlockReference === 'object') {
151
+ maybeBlock = maybeBlockReference;
152
+ } else {
153
+ maybeBlock = config.blocks?.find((each)=>each.slug === maybeBlockReference);
154
+ }
155
+ }
156
+ }
157
+ if (!maybeBlock) {
158
+ maybeBlock = field.blocks.find((each)=>each.slug === data.blockType);
159
+ }
160
+ if (maybeBlock) {
161
+ fields = maybeBlock.flattenedFields;
162
+ } else {
163
+ fieldData[i] = null;
164
+ hasNull = true;
165
+ }
166
+ }
167
+ if (!fields) {
168
+ continue;
169
+ }
170
+ stripFields({
171
+ config,
172
+ data,
173
+ fields,
174
+ parentIsLocalized: parentIsLocalized || field.localized,
175
+ reservedKeys
176
+ });
177
+ }
178
+ if (hasNull) {
179
+ data[field.name] = fieldData.filter(Boolean);
180
+ }
181
+ continue;
182
+ } else {
183
+ stripFields({
184
+ config,
185
+ data: fieldData,
186
+ fields: field.flattenedFields,
187
+ parentIsLocalized: parentIsLocalized || field.localized,
188
+ reservedKeys
189
+ });
190
+ }
191
+ }
192
+ }
193
+ };
194
+
195
+ //# sourceMappingURL=stripFields.js.map
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Transform publishedLocale to localizeStatus format
3
+ *
4
+ * publishedLocale is a legacy API that is going to be removed in Payload v4 in favor of localizeStatus.
5
+ * The db-adapter transforms publishedLocale here so Content API doesn't need to know about it.
6
+ */
7
+ type VersionData = Record<string, unknown>;
8
+ /**
9
+ * Transforms version data to use localizeStatus format
10
+ *
11
+ * If `publishedLocale` is provided and `_status` is a string, transforms to object format.
12
+ * If `_status` is already an object, leaves it unchanged.
13
+ *
14
+ * @example
15
+ * // Input (old format):
16
+ * { _status: 'published', text: 'Hello' }, publishedLocale: 'en'
17
+ *
18
+ * // Output (new format):
19
+ * { _status: { en: 'published' }, text: 'Hello' }
20
+ */
21
+ export declare function transformToLocalizeStatus(versionData: VersionData, publishedLocale?: string): VersionData;
22
+ export {};
23
+ //# sourceMappingURL=transformPublishedLocale.d.ts.map