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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (472) hide show
  1. package/dist/api/control-plane.d.ts +56 -7
  2. package/dist/api/control-plane.js +188 -74
  3. package/dist/api/error-response.d.ts +36 -0
  4. package/dist/api/error-response.js +66 -0
  5. package/dist/api/figma-api.d.ts +24 -3
  6. package/dist/api/figma-api.js +110 -34
  7. package/dist/auth/browser.d.ts +0 -1
  8. package/dist/auth/browser.js +0 -2
  9. package/dist/auth/callback-server.d.ts +19 -8
  10. package/dist/auth/callback-server.js +72 -32
  11. package/dist/auth/credentials.d.ts +20 -0
  12. package/dist/auth/credentials.js +19 -0
  13. package/dist/auth/crypto-utils.d.ts +28 -1
  14. package/dist/auth/crypto-utils.js +132 -23
  15. package/dist/auth/jwt-validator.d.ts +23 -6
  16. package/dist/auth/jwt-validator.js +35 -9
  17. package/dist/auth/oauth-flow.d.ts +19 -4
  18. package/dist/auth/oauth-flow.js +151 -34
  19. package/dist/auth/paste-code.d.ts +33 -0
  20. package/dist/auth/paste-code.js +87 -0
  21. package/dist/auth/pkce.d.ts +0 -1
  22. package/dist/auth/pkce.js +0 -2
  23. package/dist/auth/project-token.d.ts +32 -17
  24. package/dist/auth/project-token.js +176 -68
  25. package/dist/auth/refresh.d.ts +2 -2
  26. package/dist/auth/refresh.js +25 -14
  27. package/dist/auth/token-store-migration.d.ts +57 -0
  28. package/dist/auth/token-store-migration.js +154 -0
  29. package/dist/auth/token-store.d.ts +63 -98
  30. package/dist/auth/token-store.js +405 -124
  31. package/dist/auth/types.d.ts +40 -6
  32. package/dist/auth/types.js +1 -3
  33. package/dist/cli.d.ts +0 -1
  34. package/dist/cli.js +102 -8
  35. package/dist/commands/bootstrap.d.ts +17 -0
  36. package/dist/commands/bootstrap.js +88 -0
  37. package/dist/commands/build-lambda-zip.d.ts +4 -0
  38. package/dist/commands/build-lambda-zip.js +17 -0
  39. package/dist/commands/debug.d.ts +7 -0
  40. package/dist/commands/debug.js +178 -0
  41. package/dist/commands/deploy.d.ts +11 -1
  42. package/dist/commands/deploy.js +193 -153
  43. package/dist/commands/dump-tokens.d.ts +11 -0
  44. package/dist/commands/dump-tokens.js +67 -0
  45. package/dist/commands/env.d.ts +12 -0
  46. package/dist/commands/env.js +86 -0
  47. package/dist/commands/init.d.ts +9 -6
  48. package/dist/commands/init.js +232 -152
  49. package/dist/commands/list-tokens.d.ts +3 -4
  50. package/dist/commands/list-tokens.js +24 -11
  51. package/dist/commands/login.d.ts +8 -2
  52. package/dist/commands/login.js +34 -18
  53. package/dist/commands/logout.d.ts +5 -5
  54. package/dist/commands/logout.js +77 -17
  55. package/dist/commands/upgrade.d.ts +4 -0
  56. package/dist/commands/upgrade.js +329 -0
  57. package/dist/commands/upload-schema.d.ts +8 -0
  58. package/dist/commands/upload-schema.js +91 -0
  59. package/dist/config/oauth.d.ts +17 -12
  60. package/dist/config/oauth.js +38 -39
  61. package/dist/constants.d.ts +63 -19
  62. package/dist/constants.js +158 -20
  63. package/dist/db-content-api/generated/content-api-types.d.ts +8215 -0
  64. package/dist/db-content-api/generated/content-api-types.js +5 -0
  65. package/dist/db-content-api/index.d.ts +40 -0
  66. package/dist/db-content-api/index.js +883 -0
  67. package/dist/db-content-api/temp-utilities/slug.d.ts +1 -0
  68. package/dist/db-content-api/temp-utilities/slug.js +1 -0
  69. package/dist/db-content-api/temp-utilities/sorting.d.ts +2 -0
  70. package/dist/db-content-api/temp-utilities/sorting.js +37 -0
  71. package/dist/db-content-api/temp-utilities/types.d.ts +21 -0
  72. package/dist/db-content-api/temp-utilities/types.js +13 -0
  73. package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +38 -0
  74. package/dist/db-content-api/temp-utilities/unwrapDocument.js +62 -0
  75. package/dist/db-content-api/utilities/auth.d.ts +29 -0
  76. package/dist/db-content-api/utilities/auth.js +82 -0
  77. package/dist/db-content-api/utilities/clientVersionHeaders.d.ts +7 -0
  78. package/dist/db-content-api/utilities/clientVersionHeaders.js +15 -0
  79. package/dist/db-content-api/utilities/data/applyDefaults.d.ts +6 -0
  80. package/dist/db-content-api/utilities/data/applyDefaults.js +75 -0
  81. package/dist/db-content-api/utilities/data/atomicOperations.d.ts +16 -0
  82. package/dist/db-content-api/utilities/data/atomicOperations.js +48 -0
  83. package/dist/db-content-api/utilities/data/castFieldValue.d.ts +10 -0
  84. package/dist/db-content-api/utilities/data/castFieldValue.js +66 -0
  85. package/dist/db-content-api/utilities/data/convertRelationshipIds.d.ts +25 -0
  86. package/dist/db-content-api/utilities/data/convertRelationshipIds.js +109 -0
  87. package/dist/db-content-api/utilities/data/index.d.ts +48 -0
  88. package/dist/db-content-api/utilities/data/index.js +315 -0
  89. package/dist/db-content-api/utilities/data/isLocaleMap.d.ts +10 -0
  90. package/dist/db-content-api/utilities/data/isLocaleMap.js +13 -0
  91. package/dist/db-content-api/utilities/data/pointShape.d.ts +3 -0
  92. package/dist/db-content-api/utilities/data/pointShape.js +43 -0
  93. package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +11 -0
  94. package/dist/db-content-api/utilities/data/removeVirtualFields.js +52 -0
  95. package/dist/db-content-api/utilities/data/resolveFieldLocalization.d.ts +18 -0
  96. package/dist/db-content-api/utilities/data/resolveFieldLocalization.js +21 -0
  97. package/dist/db-content-api/utilities/data/richTextShape.d.ts +3 -0
  98. package/dist/db-content-api/utilities/data/richTextShape.js +56 -0
  99. package/dist/db-content-api/utilities/data/stripFields.d.ts +47 -0
  100. package/dist/db-content-api/utilities/data/stripFields.js +170 -0
  101. package/dist/db-content-api/utilities/data/transformPublishedLocale.d.ts +22 -0
  102. package/dist/db-content-api/utilities/data/transformPublishedLocale.js +40 -0
  103. package/dist/db-content-api/utilities/data/validateRelationships.d.ts +6 -0
  104. package/dist/db-content-api/utilities/data/validateRelationships.js +107 -0
  105. package/dist/db-content-api/utilities/joins.d.ts +50 -0
  106. package/dist/db-content-api/utilities/joins.js +124 -0
  107. package/dist/db-content-api/utilities/locale/index.d.ts +9 -0
  108. package/dist/db-content-api/utilities/locale/index.js +19 -0
  109. package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.d.ts +9 -0
  110. package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.js +100 -0
  111. package/dist/db-content-api/utilities/resolveBlocks.d.ts +19 -0
  112. package/dist/db-content-api/utilities/resolveBlocks.js +31 -0
  113. package/dist/db-content-api/utilities/schema/buildDocumentSchema.d.ts +72 -0
  114. package/dist/db-content-api/utilities/schema/buildDocumentSchema.js +264 -0
  115. package/dist/db-content-api/utilities/where.d.ts +9 -0
  116. package/dist/db-content-api/utilities/where.js +95 -0
  117. package/dist/deploy/schedule-extract-plugin.d.ts +10 -0
  118. package/dist/deploy/schedule-extract-plugin.js +32 -0
  119. package/dist/endpoints/health.d.ts +2 -0
  120. package/dist/endpoints/health.js +9 -0
  121. package/dist/endpoints/schema.d.ts +2 -0
  122. package/dist/endpoints/schema.js +27 -0
  123. package/dist/exports/client.d.ts +2 -1
  124. package/dist/exports/client.js +2 -2
  125. package/dist/index.d.ts +2 -2
  126. package/dist/index.js +3 -3
  127. package/dist/lib/download-skill.d.ts +12 -0
  128. package/dist/lib/download-skill.js +77 -0
  129. package/dist/oauth/components/FigmaAvatar/index.d.ts +3 -0
  130. package/dist/oauth/components/FigmaAvatar/index.js +25 -0
  131. package/dist/oauth/components/FigmaAvatar/index.scss +12 -0
  132. package/dist/oauth/components/FigmaAvatarCell/index.d.ts +4 -0
  133. package/dist/oauth/components/FigmaAvatarCell/index.js +23 -0
  134. package/dist/oauth/components/FigmaAvatarCell/index.scss +5 -0
  135. package/dist/oauth/components/FigmaAvatarPlaceholder/index.d.ts +8 -0
  136. package/dist/oauth/components/FigmaAvatarPlaceholder/index.js +35 -0
  137. package/dist/oauth/components/FigmaAvatarPlaceholder/index.scss +28 -0
  138. package/dist/oauth/components/LoginButton/iframeAutoLogin.d.ts +81 -0
  139. package/dist/oauth/components/LoginButton/iframeAutoLogin.js +168 -0
  140. package/dist/oauth/components/LoginButton/index.d.ts +0 -1
  141. package/dist/oauth/components/LoginButton/index.js +156 -18
  142. package/dist/oauth/components/LoginButton/index.scss +75 -3
  143. package/dist/oauth/components/LogoutButton/index.d.ts +0 -1
  144. package/dist/oauth/components/LogoutButton/index.js +20 -9
  145. package/dist/oauth/defaults.d.ts +3 -2
  146. package/dist/oauth/defaults.js +79 -12
  147. package/dist/oauth/endpoints/getLoginEndpoint.d.ts +0 -1
  148. package/dist/oauth/endpoints/getLoginEndpoint.js +87 -84
  149. package/dist/oauth/endpoints/getLogoutEndpoint.d.ts +0 -1
  150. package/dist/oauth/endpoints/getLogoutEndpoint.js +7 -6
  151. package/dist/oauth/endpoints/getMetaEndpoint.d.ts +0 -1
  152. package/dist/oauth/endpoints/getMetaEndpoint.js +18 -5
  153. package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts +0 -1
  154. package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js +11 -4
  155. package/dist/oauth/exports/client.d.ts +0 -1
  156. package/dist/oauth/exports/client.js +0 -2
  157. package/dist/oauth/hooks/afterLogout.d.ts +0 -1
  158. package/dist/oauth/hooks/afterLogout.js +0 -2
  159. package/dist/oauth/hooks/me.d.ts +0 -1
  160. package/dist/oauth/hooks/me.js +0 -2
  161. package/dist/oauth/hooks/refresh.d.ts +0 -1
  162. package/dist/oauth/hooks/refresh.js +2 -3
  163. package/dist/oauth/index.d.ts +0 -1
  164. package/dist/oauth/index.js +27 -7
  165. package/dist/oauth/strategy/index.d.ts +0 -3
  166. package/dist/oauth/strategy/index.js +55 -34
  167. package/dist/oauth/types.d.ts +23 -7
  168. package/dist/oauth/types.js +0 -2
  169. package/dist/oauth/utilities/buildUnauthorizedRedirect.d.ts +14 -0
  170. package/dist/oauth/utilities/buildUnauthorizedRedirect.js +28 -0
  171. package/dist/oauth/utilities/clearCookie.d.ts +0 -1
  172. package/dist/oauth/utilities/clearCookie.js +5 -3
  173. package/dist/oauth/utilities/createCookieOptions.d.ts +0 -1
  174. package/dist/oauth/utilities/createCookieOptions.js +9 -4
  175. package/dist/oauth/utilities/createDebugLogger.d.ts +0 -1
  176. package/dist/oauth/utilities/createDebugLogger.js +0 -2
  177. package/dist/oauth/utilities/establishSession.d.ts +22 -0
  178. package/dist/oauth/utilities/establishSession.js +80 -0
  179. package/dist/oauth/utilities/exchangeCodeForAccessToken.d.ts +23 -0
  180. package/dist/oauth/utilities/exchangeCodeForAccessToken.js +26 -0
  181. package/dist/oauth/utilities/extractOrigin.d.ts +0 -1
  182. package/dist/oauth/utilities/extractOrigin.js +0 -2
  183. package/dist/oauth/utilities/figmaHostnames.d.ts +2 -0
  184. package/dist/oauth/utilities/figmaHostnames.js +24 -0
  185. package/dist/oauth/utilities/getAdminCollectionSlug.d.ts +0 -1
  186. package/dist/oauth/utilities/getAdminCollectionSlug.js +0 -2
  187. package/dist/oauth/utilities/getAuthorizeURL.d.ts +65 -2
  188. package/dist/oauth/utilities/getAuthorizeURL.js +57 -4
  189. package/dist/oauth/utilities/getCookieExpiration.d.ts +0 -1
  190. package/dist/oauth/utilities/getCookieExpiration.js +0 -2
  191. package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts +0 -1
  192. package/dist/oauth/utilities/getSecondsFromTokenExp.js +0 -2
  193. package/dist/oauth/utilities/getTokenExp.d.ts +0 -1
  194. package/dist/oauth/utilities/getTokenExp.js +0 -2
  195. package/dist/oauth/utilities/getUsernameField.d.ts +0 -1
  196. package/dist/oauth/utilities/getUsernameField.js +0 -2
  197. package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts +0 -1
  198. package/dist/oauth/utilities/hasUserTokenPropsChanged.js +0 -2
  199. package/dist/oauth/utilities/isAbsoluteURL.d.ts +1 -0
  200. package/dist/oauth/utilities/isAbsoluteURL.js +1 -0
  201. package/dist/oauth/utilities/isDuplicateKeyError.d.ts +6 -0
  202. package/dist/oauth/utilities/isDuplicateKeyError.js +12 -0
  203. package/dist/oauth/utilities/mergeHeaders.d.ts +0 -1
  204. package/dist/oauth/utilities/mergeHeaders.js +0 -2
  205. package/dist/oauth/utilities/refreshTokens.d.ts +0 -1
  206. package/dist/oauth/utilities/refreshTokens.js +21 -13
  207. package/dist/oauth/utilities/withPartitionedCookie.d.ts +19 -0
  208. package/dist/oauth/utilities/withPartitionedCookie.js +26 -0
  209. package/dist/oauth/utils/getSearchParam.d.ts +17 -0
  210. package/dist/oauth/utils/getSearchParam.js +22 -0
  211. package/dist/plugin/adapter.d.ts +0 -1
  212. package/dist/plugin/adapter.js +0 -2
  213. package/dist/plugin/auth-preflight.d.ts +7 -0
  214. package/dist/plugin/auth-preflight.js +18 -0
  215. package/dist/plugin/bootstrap-preflight.d.ts +22 -0
  216. package/dist/plugin/bootstrap-preflight.js +43 -0
  217. package/dist/plugin/build-config.d.ts +27 -15
  218. package/dist/plugin/build-config.js +380 -16
  219. package/dist/plugin/dev-cookie-names.d.ts +13 -0
  220. package/dist/plugin/dev-cookie-names.js +17 -0
  221. package/dist/scss.d.js +2 -0
  222. package/dist/storage-content-api/api-types.d.ts +183 -0
  223. package/dist/storage-content-api/api-types.js +4 -0
  224. package/dist/storage-content-api/client-uploads/generate.d.ts +14 -0
  225. package/dist/storage-content-api/client-uploads/generate.js +69 -0
  226. package/dist/storage-content-api/client.d.ts +5 -0
  227. package/dist/storage-content-api/client.js +37 -0
  228. package/dist/storage-content-api/generateURL.d.ts +6 -0
  229. package/dist/storage-content-api/generateURL.js +6 -0
  230. package/dist/storage-content-api/handleDelete.d.ts +7 -0
  231. package/dist/storage-content-api/handleDelete.js +15 -0
  232. package/dist/storage-content-api/handleUpload.d.ts +10 -0
  233. package/dist/storage-content-api/handleUpload.js +162 -0
  234. package/dist/storage-content-api/index.d.ts +4 -0
  235. package/dist/storage-content-api/index.js +37 -0
  236. package/dist/storage-content-api/staticHandler.d.ts +9 -0
  237. package/dist/storage-content-api/staticHandler.js +61 -0
  238. package/dist/storage-content-api/types.d.ts +9 -0
  239. package/dist/storage-content-api/types.js +1 -0
  240. package/dist/storage-content-api/utilities/getSafeFilename.d.ts +11 -0
  241. package/dist/storage-content-api/utilities/getSafeFilename.js +59 -0
  242. package/dist/storage-content-api/utilities/index.d.ts +2 -0
  243. package/dist/storage-content-api/utilities/index.js +2 -0
  244. package/dist/storage-content-api/utilities/parseUploadReference.d.ts +17 -0
  245. package/dist/storage-content-api/utilities/parseUploadReference.js +27 -0
  246. package/dist/templates/.env.example +5 -0
  247. package/dist/templates/README.md +19 -0
  248. package/dist/types/config.d.ts +2 -2
  249. package/dist/types/config.js +0 -4
  250. package/dist/types.d.ts +10 -2
  251. package/dist/types.js +0 -2
  252. package/dist/utils/adapters/nextjs.d.ts +8 -0
  253. package/dist/utils/adapters/nextjs.js +61 -0
  254. package/dist/utils/adapters/nitro.d.ts +8 -0
  255. package/dist/utils/adapters/nitro.js +172 -0
  256. package/dist/utils/adapters/vite.d.ts +9 -0
  257. package/dist/utils/adapters/vite.js +31 -0
  258. package/dist/utils/asset-collection.d.ts +27 -7
  259. package/dist/utils/asset-collection.js +59 -32
  260. package/dist/utils/build-detection.d.ts +5 -12
  261. package/dist/utils/build-detection.js +74 -13
  262. package/dist/utils/build-lambda-zip.d.ts +25 -0
  263. package/dist/utils/build-lambda-zip.js +90 -0
  264. package/dist/utils/cache-bootstrap.d.ts +7 -0
  265. package/dist/utils/cache-bootstrap.js +16 -0
  266. package/dist/utils/config.d.ts +0 -1
  267. package/dist/utils/config.js +1 -3
  268. package/dist/utils/deploy-adapter.d.ts +45 -0
  269. package/dist/utils/deploy-adapter.js +56 -0
  270. package/dist/utils/download-template.d.ts +9 -2
  271. package/dist/utils/download-template.js +24 -20
  272. package/dist/utils/env-management.d.ts +24 -8
  273. package/dist/utils/env-management.js +119 -66
  274. package/dist/utils/format-env-suffix.d.ts +11 -0
  275. package/dist/utils/format-env-suffix.js +11 -0
  276. package/dist/utils/format.d.ts +0 -1
  277. package/dist/utils/format.js +0 -2
  278. package/dist/utils/formatter.d.ts +0 -1
  279. package/dist/utils/formatter.js +23 -13
  280. package/dist/utils/fs-utils.d.ts +12 -0
  281. package/dist/utils/fs-utils.js +55 -0
  282. package/dist/utils/git.d.ts +0 -1
  283. package/dist/utils/git.js +0 -2
  284. package/dist/utils/handle-upgrade.d.ts +8 -0
  285. package/dist/utils/handle-upgrade.js +39 -0
  286. package/dist/utils/is-debug.d.ts +0 -1
  287. package/dist/utils/is-debug.js +0 -2
  288. package/dist/utils/lambda-config.d.ts +3 -2
  289. package/dist/utils/lambda-config.js +75 -80
  290. package/dist/utils/load-payload-config.d.ts +9 -0
  291. package/dist/utils/load-payload-config.js +27 -0
  292. package/dist/utils/log.d.ts +0 -1
  293. package/dist/utils/log.js +0 -2
  294. package/dist/utils/messages.d.ts +1 -3
  295. package/dist/utils/messages.js +47 -13
  296. package/dist/utils/package-manager.d.ts +24 -1
  297. package/dist/utils/package-manager.js +53 -2
  298. package/dist/utils/parse-template-spec.d.ts +11 -0
  299. package/dist/utils/parse-template-spec.js +60 -0
  300. package/dist/utils/payload-config-ast.d.ts +27 -7
  301. package/dist/utils/payload-config-ast.js +106 -60
  302. package/dist/utils/payload-config-finder.d.ts +2 -3
  303. package/dist/utils/payload-config-finder.js +48 -11
  304. package/dist/utils/payload-config-modifier.d.ts +1 -2
  305. package/dist/utils/payload-config-modifier.js +114 -68
  306. package/dist/utils/payload-package-check.d.ts +28 -3
  307. package/dist/utils/payload-package-check.js +90 -31
  308. package/dist/utils/project.d.ts +8 -4
  309. package/dist/utils/project.js +63 -37
  310. package/dist/utils/resolve-environment.d.ts +13 -0
  311. package/dist/utils/resolve-environment.js +29 -0
  312. package/dist/utils/s3-upload.d.ts +7 -3
  313. package/dist/utils/s3-upload.js +44 -9
  314. package/dist/utils/token-display.d.ts +5 -2
  315. package/dist/utils/token-display.js +49 -24
  316. package/dist/utils/typescript-validator.d.ts +0 -1
  317. package/dist/utils/typescript-validator.js +4 -8
  318. package/dist/utils/version-check.d.ts +2 -0
  319. package/dist/utils/version-check.js +43 -0
  320. package/package.json +47 -16
  321. package/dist/api/control-plane.d.ts.map +0 -1
  322. package/dist/api/control-plane.js.map +0 -1
  323. package/dist/api/figma-api.d.ts.map +0 -1
  324. package/dist/api/figma-api.js.map +0 -1
  325. package/dist/auth/browser.d.ts.map +0 -1
  326. package/dist/auth/browser.js.map +0 -1
  327. package/dist/auth/callback-server.d.ts.map +0 -1
  328. package/dist/auth/callback-server.js.map +0 -1
  329. package/dist/auth/crypto-utils.d.ts.map +0 -1
  330. package/dist/auth/crypto-utils.js.map +0 -1
  331. package/dist/auth/jwt-validator.d.ts.map +0 -1
  332. package/dist/auth/jwt-validator.js.map +0 -1
  333. package/dist/auth/oauth-flow.d.ts.map +0 -1
  334. package/dist/auth/oauth-flow.js.map +0 -1
  335. package/dist/auth/pkce.d.ts.map +0 -1
  336. package/dist/auth/pkce.js.map +0 -1
  337. package/dist/auth/project-token.d.ts.map +0 -1
  338. package/dist/auth/project-token.js.map +0 -1
  339. package/dist/auth/refresh.d.ts.map +0 -1
  340. package/dist/auth/refresh.js.map +0 -1
  341. package/dist/auth/token-store.d.ts.map +0 -1
  342. package/dist/auth/token-store.js.map +0 -1
  343. package/dist/auth/types.d.ts.map +0 -1
  344. package/dist/auth/types.js.map +0 -1
  345. package/dist/cli.d.ts.map +0 -1
  346. package/dist/cli.js.map +0 -1
  347. package/dist/commands/deploy.d.ts.map +0 -1
  348. package/dist/commands/deploy.js.map +0 -1
  349. package/dist/commands/init.d.ts.map +0 -1
  350. package/dist/commands/init.js.map +0 -1
  351. package/dist/commands/list-tokens.d.ts.map +0 -1
  352. package/dist/commands/list-tokens.js.map +0 -1
  353. package/dist/commands/login.d.ts.map +0 -1
  354. package/dist/commands/login.js.map +0 -1
  355. package/dist/commands/logout.d.ts.map +0 -1
  356. package/dist/commands/logout.js.map +0 -1
  357. package/dist/config/oauth.d.ts.map +0 -1
  358. package/dist/config/oauth.js.map +0 -1
  359. package/dist/constants.d.ts.map +0 -1
  360. package/dist/constants.js.map +0 -1
  361. package/dist/exports/client.d.ts.map +0 -1
  362. package/dist/exports/client.js.map +0 -1
  363. package/dist/index.d.ts.map +0 -1
  364. package/dist/index.js.map +0 -1
  365. package/dist/oauth/components/LoginButton/index.d.ts.map +0 -1
  366. package/dist/oauth/components/LoginButton/index.js.map +0 -1
  367. package/dist/oauth/components/LogoutButton/index.d.ts.map +0 -1
  368. package/dist/oauth/components/LogoutButton/index.js.map +0 -1
  369. package/dist/oauth/defaults.d.ts.map +0 -1
  370. package/dist/oauth/defaults.js.map +0 -1
  371. package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +0 -1
  372. package/dist/oauth/endpoints/getLoginEndpoint.js.map +0 -1
  373. package/dist/oauth/endpoints/getLogoutEndpoint.d.ts.map +0 -1
  374. package/dist/oauth/endpoints/getLogoutEndpoint.js.map +0 -1
  375. package/dist/oauth/endpoints/getMetaEndpoint.d.ts.map +0 -1
  376. package/dist/oauth/endpoints/getMetaEndpoint.js.map +0 -1
  377. package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts.map +0 -1
  378. package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js.map +0 -1
  379. package/dist/oauth/exports/client.d.ts.map +0 -1
  380. package/dist/oauth/exports/client.js.map +0 -1
  381. package/dist/oauth/hooks/afterLogout.d.ts.map +0 -1
  382. package/dist/oauth/hooks/afterLogout.js.map +0 -1
  383. package/dist/oauth/hooks/me.d.ts.map +0 -1
  384. package/dist/oauth/hooks/me.js.map +0 -1
  385. package/dist/oauth/hooks/refresh.d.ts.map +0 -1
  386. package/dist/oauth/hooks/refresh.js.map +0 -1
  387. package/dist/oauth/index.d.ts.map +0 -1
  388. package/dist/oauth/index.js.map +0 -1
  389. package/dist/oauth/strategy/index.d.ts.map +0 -1
  390. package/dist/oauth/strategy/index.js.map +0 -1
  391. package/dist/oauth/types.d.ts.map +0 -1
  392. package/dist/oauth/types.js.map +0 -1
  393. package/dist/oauth/utilities/clearCookie.d.ts.map +0 -1
  394. package/dist/oauth/utilities/clearCookie.js.map +0 -1
  395. package/dist/oauth/utilities/createCookieOptions.d.ts.map +0 -1
  396. package/dist/oauth/utilities/createCookieOptions.js.map +0 -1
  397. package/dist/oauth/utilities/createDebugLogger.d.ts.map +0 -1
  398. package/dist/oauth/utilities/createDebugLogger.js.map +0 -1
  399. package/dist/oauth/utilities/extractOrigin.d.ts.map +0 -1
  400. package/dist/oauth/utilities/extractOrigin.js.map +0 -1
  401. package/dist/oauth/utilities/getAdminCollectionSlug.d.ts.map +0 -1
  402. package/dist/oauth/utilities/getAdminCollectionSlug.js.map +0 -1
  403. package/dist/oauth/utilities/getAdminPath.d.ts +0 -8
  404. package/dist/oauth/utilities/getAdminPath.d.ts.map +0 -1
  405. package/dist/oauth/utilities/getAdminPath.js +0 -9
  406. package/dist/oauth/utilities/getAdminPath.js.map +0 -1
  407. package/dist/oauth/utilities/getAuthorizeURL.d.ts.map +0 -1
  408. package/dist/oauth/utilities/getAuthorizeURL.js.map +0 -1
  409. package/dist/oauth/utilities/getCookieExpiration.d.ts.map +0 -1
  410. package/dist/oauth/utilities/getCookieExpiration.js.map +0 -1
  411. package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts.map +0 -1
  412. package/dist/oauth/utilities/getSecondsFromTokenExp.js.map +0 -1
  413. package/dist/oauth/utilities/getTokenExp.d.ts.map +0 -1
  414. package/dist/oauth/utilities/getTokenExp.js.map +0 -1
  415. package/dist/oauth/utilities/getUsernameField.d.ts.map +0 -1
  416. package/dist/oauth/utilities/getUsernameField.js.map +0 -1
  417. package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts.map +0 -1
  418. package/dist/oauth/utilities/hasUserTokenPropsChanged.js.map +0 -1
  419. package/dist/oauth/utilities/mergeHeaders.d.ts.map +0 -1
  420. package/dist/oauth/utilities/mergeHeaders.js.map +0 -1
  421. package/dist/oauth/utilities/refreshTokens.d.ts.map +0 -1
  422. package/dist/oauth/utilities/refreshTokens.js.map +0 -1
  423. package/dist/plugin/adapter.d.ts.map +0 -1
  424. package/dist/plugin/adapter.js.map +0 -1
  425. package/dist/plugin/build-config.d.ts.map +0 -1
  426. package/dist/plugin/build-config.js.map +0 -1
  427. package/dist/types/config.d.ts.map +0 -1
  428. package/dist/types/config.js.map +0 -1
  429. package/dist/types.d.ts.map +0 -1
  430. package/dist/types.js.map +0 -1
  431. package/dist/utils/asset-collection.d.ts.map +0 -1
  432. package/dist/utils/asset-collection.js.map +0 -1
  433. package/dist/utils/build-detection.d.ts.map +0 -1
  434. package/dist/utils/build-detection.js.map +0 -1
  435. package/dist/utils/config.d.ts.map +0 -1
  436. package/dist/utils/config.js.map +0 -1
  437. package/dist/utils/download-template.d.ts.map +0 -1
  438. package/dist/utils/download-template.js.map +0 -1
  439. package/dist/utils/env-management.d.ts.map +0 -1
  440. package/dist/utils/env-management.js.map +0 -1
  441. package/dist/utils/format.d.ts.map +0 -1
  442. package/dist/utils/format.js.map +0 -1
  443. package/dist/utils/formatter.d.ts.map +0 -1
  444. package/dist/utils/formatter.js.map +0 -1
  445. package/dist/utils/git.d.ts.map +0 -1
  446. package/dist/utils/git.js.map +0 -1
  447. package/dist/utils/is-debug.d.ts.map +0 -1
  448. package/dist/utils/is-debug.js.map +0 -1
  449. package/dist/utils/lambda-config.d.ts.map +0 -1
  450. package/dist/utils/lambda-config.js.map +0 -1
  451. package/dist/utils/log.d.ts.map +0 -1
  452. package/dist/utils/log.js.map +0 -1
  453. package/dist/utils/messages.d.ts.map +0 -1
  454. package/dist/utils/messages.js.map +0 -1
  455. package/dist/utils/package-manager.d.ts.map +0 -1
  456. package/dist/utils/package-manager.js.map +0 -1
  457. package/dist/utils/payload-config-ast.d.ts.map +0 -1
  458. package/dist/utils/payload-config-ast.js.map +0 -1
  459. package/dist/utils/payload-config-finder.d.ts.map +0 -1
  460. package/dist/utils/payload-config-finder.js.map +0 -1
  461. package/dist/utils/payload-config-modifier.d.ts.map +0 -1
  462. package/dist/utils/payload-config-modifier.js.map +0 -1
  463. package/dist/utils/payload-package-check.d.ts.map +0 -1
  464. package/dist/utils/payload-package-check.js.map +0 -1
  465. package/dist/utils/project.d.ts.map +0 -1
  466. package/dist/utils/project.js.map +0 -1
  467. package/dist/utils/s3-upload.d.ts.map +0 -1
  468. package/dist/utils/s3-upload.js.map +0 -1
  469. package/dist/utils/token-display.d.ts.map +0 -1
  470. package/dist/utils/token-display.js.map +0 -1
  471. package/dist/utils/typescript-validator.d.ts.map +0 -1
  472. package/dist/utils/typescript-validator.js.map +0 -1
@@ -0,0 +1,109 @@
1
+ import { valueIsValueWithRelation } from 'payload/shared';
2
+ import { matchAtomicOperation, RELATIONSHIP_ATOMIC_OPERATORS } from './atomicOperations.js';
3
+ import { isLocaleMap } from './isLocaleMap.js';
4
+ export function convertRelationshipFieldIdsFromWire(options) {
5
+ return convertRelationshipFieldIds({
6
+ ...options,
7
+ direction: 'fromWire'
8
+ });
9
+ }
10
+ export function convertRelationshipFieldIdsToWire(options) {
11
+ return convertRelationshipFieldIds({
12
+ ...options,
13
+ direction: 'toWire'
14
+ });
15
+ }
16
+ /**
17
+ * Converts the id(s) inside a relationship/upload field value between Payload's
18
+ * representation (numeric ids kept as numbers) and the Content API wire form
19
+ * (all ids as strings). No-op for uuid/text targets. Preserves has-many arrays,
20
+ * polymorphic shapes, localized locale-maps, and atomic operators.
21
+ */ export function convertRelationshipFieldIds(options) {
22
+ const { direction, field, payload, value } = options;
23
+ if (value == null) {
24
+ return value;
25
+ }
26
+ const relationTo = field.relationTo;
27
+ const localized = field.localized ?? false;
28
+ const hasMany = field.hasMany ?? false;
29
+ // The value shape is fully determined by the localized × hasMany combination:
30
+ // !localized, !hasMany → a single value
31
+ // !localized, hasMany → an array of values (or a `$push`/`$remove` wrapper)
32
+ // localized, !hasMany → a locale-map of single values
33
+ // localized, hasMany → a locale-map of arrays
34
+ // Localized values arrive as a locale-map on write and all-locales reads, but
35
+ // as the bare per-locale value on single-locale reads, so a localized field
36
+ // dispatches through `convertLocalized`, which handles both.
37
+ const convertValue = (entry)=>hasMany ? convertHasManyValue(entry, relationTo, payload, direction) : convertSingleValue(entry, relationTo, payload, direction);
38
+ return localized ? convertLocalized(value, convertValue) : convertValue(value);
39
+ }
40
+ // Applies `convertValue` to each entry of a localized locale-map. A single-locale
41
+ // read delivers the bare per-locale value instead of a map (a plain object then
42
+ // is a polymorphic ref, not a locale-map), so that case is converted directly.
43
+ function convertLocalized(value, convertValue) {
44
+ if (!isLocaleMap(value)) {
45
+ return convertValue(value);
46
+ }
47
+ const out = {};
48
+ for (const [locale, localeValue] of Object.entries(value)){
49
+ out[locale] = localeValue == null ? localeValue : convertValue(localeValue);
50
+ }
51
+ return out;
52
+ }
53
+ // A has-many value normalizes to an array of single values: Payload may pass a
54
+ // lone value (e.g. `children: 'uuid'`), which is wrapped into a single-element
55
+ // array. Writes may instead wrap the value in an atomic `$push`/`$remove`
56
+ // operator, which is preserved — its payload is converted but not array-wrapped,
57
+ // since those operators accept a single value or an array.
58
+ function convertHasManyValue(value, relationTo, payload, direction) {
59
+ const atomic = matchAtomicOperation(value, RELATIONSHIP_ATOMIC_OPERATORS);
60
+ if (atomic) {
61
+ return {
62
+ [atomic.operator]: convertAtomicPayload(atomic.inner, relationTo, payload, direction)
63
+ };
64
+ }
65
+ if (Array.isArray(value)) {
66
+ return value.map((entry)=>convertSingleValue(entry, relationTo, payload, direction));
67
+ }
68
+ return [
69
+ convertSingleValue(value, relationTo, payload, direction)
70
+ ];
71
+ }
72
+ // The payload of a `$push`/`$remove` operator may be a single value or an array;
73
+ // convert either without changing its arity.
74
+ function convertAtomicPayload(value, relationTo, payload, direction) {
75
+ return Array.isArray(value) ? value.map((entry)=>convertSingleValue(entry, relationTo, payload, direction)) : convertSingleValue(value, relationTo, payload, direction);
76
+ }
77
+ // A single relationship value is a polymorphic `{ relationTo, value }` (when the
78
+ // field targets multiple collections) or a bare id (when it targets one). The id
79
+ // type comes from the referenced collection.
80
+ function convertSingleValue(value, relationTo, payload, direction) {
81
+ if (value == null) {
82
+ return value;
83
+ }
84
+ if (valueIsValueWithRelation(value)) {
85
+ return {
86
+ ...value,
87
+ value: convertLeafId(value.value, customIdTypeFor(payload, value.relationTo), direction)
88
+ };
89
+ }
90
+ // A non-polymorphic field targets a single collection (string `relationTo`).
91
+ const customIDType = typeof relationTo === 'string' ? customIdTypeFor(payload, relationTo) : undefined;
92
+ return convertLeafId(value, customIDType, direction);
93
+ }
94
+ function customIdTypeFor(payload, slug) {
95
+ return payload.collections?.[slug]?.customIDType;
96
+ }
97
+ function convertLeafId(id, customIDType, direction) {
98
+ if (id == null || id === '') {
99
+ return id;
100
+ }
101
+ // Only numeric custom ids differ between Payload (number) and the wire (string).
102
+ if (customIDType !== 'number') {
103
+ return id;
104
+ }
105
+ if (direction === 'toWire') {
106
+ return typeof id === 'number' ? String(id) : id;
107
+ }
108
+ return typeof id === 'string' ? Number(id) : id;
109
+ }
@@ -0,0 +1,48 @@
1
+ import type { Payload } from 'payload';
2
+ import type { components } from '../../generated/content-api-types.js';
3
+ type DataWithOperations = components['schemas']['DataWithOperations'];
4
+ interface DataToContentAPIOptions {
5
+ /** Apply static defaults for undefined fields */
6
+ applyDefaults?: boolean;
7
+ /** Add createdAt timestamp */
8
+ createdAt?: boolean;
9
+ /**
10
+ * Transform publishedLocale to localizeStatus format.
11
+ * When provided, converts `_status: 'published'` + `publishedLocale: 'en'`
12
+ * to `_status: { en: 'published' }` format.
13
+ */
14
+ publishedLocale?: string;
15
+ }
16
+ /**
17
+ * Transform data before sending to Content API (WRITE operations)
18
+ *
19
+ * Conversions applied:
20
+ * - Default values: Apply static defaults for undefined fields (when applyDefaults=true)
21
+ * - Type casting: Convert values to match field types (e.g., number -> string for text fields)
22
+ * - RichText fields: Objects -> JSON strings
23
+ * - Virtual fields: Remove fields with `virtual: true` (pure virtual fields should never be saved)
24
+ * - Timestamps: Add updatedAt (always), and createdAt (when createdAt=true)
25
+ * - publishedLocale: Transform to localizeStatus format (when publishedLocale is provided)
26
+ *
27
+ * Note: Date fields are automatically converted to ISO strings by JSON.stringify()
28
+ */
29
+ export declare function dataToContentAPI(payload: Payload, collectionSlug: string, data: unknown, options?: DataToContentAPIOptions): DataWithOperations;
30
+ /**
31
+ * Transform data received from Content API (READ operations)
32
+ *
33
+ * Conversions applied:
34
+ * - RichText fields: JSON strings -> Objects
35
+ * - Virtual fields: Remove fields with `virtual: true` (should not be in DB but Content API backend may add them)
36
+ *
37
+ * Note: Date fields come as ISO strings from Content API and stay as strings
38
+ * (matching MongoDB and other adapters' behavior)
39
+ */
40
+ /**
41
+ * Extract version content from versionData that may be flat (no nested `version` key).
42
+ * Some callers spread version content at the top level alongside metadata
43
+ * (e.g. `{ ...version.version, createdAt }`), so we reconstruct the `version`
44
+ * object by filtering out known metadata keys.
45
+ */
46
+ export declare function resolveVersionContent(version: unknown, versionMeta: Record<string, unknown>): unknown;
47
+ export declare function dataFromContentAPI(payload: Payload, collectionSlug: string, data: unknown, locale?: string): unknown;
48
+ export {};
@@ -0,0 +1,315 @@
1
+ import { flattenAllFields, traverseFields } from 'payload';
2
+ import { applyDefaults } from './applyDefaults.js';
3
+ import { ATOMIC_OPERATORS, isAtomicOperation } from './atomicOperations.js';
4
+ import { castFieldValue } from './castFieldValue.js';
5
+ import { convertRelationshipFieldIds } from './convertRelationshipIds.js';
6
+ import { decodePointFromRead, encodePointForWrite } from './pointShape.js';
7
+ import { removeVirtualFields } from './removeVirtualFields.js';
8
+ import { resolveFieldLocalization } from './resolveFieldLocalization.js';
9
+ import { decodeRichTextFromRead, encodeRichTextForWrite } from './richTextShape.js';
10
+ import { stripFields } from './stripFields.js';
11
+ import { transformToLocalizeStatus } from './transformPublishedLocale.js';
12
+ /**
13
+ * Transform data before sending to Content API (WRITE operations)
14
+ *
15
+ * Conversions applied:
16
+ * - Default values: Apply static defaults for undefined fields (when applyDefaults=true)
17
+ * - Type casting: Convert values to match field types (e.g., number -> string for text fields)
18
+ * - RichText fields: Objects -> JSON strings
19
+ * - Virtual fields: Remove fields with `virtual: true` (pure virtual fields should never be saved)
20
+ * - Timestamps: Add updatedAt (always), and createdAt (when createdAt=true)
21
+ * - publishedLocale: Transform to localizeStatus format (when publishedLocale is provided)
22
+ *
23
+ * Note: Date fields are automatically converted to ISO strings by JSON.stringify()
24
+ */ export function dataToContentAPI(payload, collectionSlug, data, options) {
25
+ if (!data || typeof data !== 'object') {
26
+ return data;
27
+ }
28
+ // Transform publishedLocale to localizeStatus format before other transformations
29
+ const dataWithLocalizedStatus = transformToLocalizeStatus(data, options?.publishedLocale);
30
+ // Deep clone to avoid mutating original data
31
+ const transformed = JSON.parse(JSON.stringify(dataWithLocalizedStatus));
32
+ // Get collection config
33
+ const isGlobal = collectionSlug.startsWith('_global-');
34
+ const actualSlug = isGlobal ? collectionSlug.substring(8) : collectionSlug;
35
+ const collectionConfig = isGlobal ? payload.config.globals?.find((g)=>g.slug === actualSlug) : payload.config.collections.find((c)=>c.slug === actualSlug);
36
+ if (!collectionConfig?.fields) {
37
+ return transformed;
38
+ }
39
+ // Apply static defaults recursively to handle nested structures (arrays, groups)
40
+ // This must happen before traverseFields to ensure defaults are in place
41
+ if (options?.applyDefaults) {
42
+ applyDefaults(transformed, collectionConfig.fields, payload.config.blocks);
43
+ }
44
+ // Use Payload's traverseFields to iterate over all fields for transformations
45
+ const callback = ({ field: declaredField, parentIsLocalized, ref })=>{
46
+ if (!('name' in declaredField) || declaredField.name == null) {
47
+ return;
48
+ }
49
+ if (!ref || typeof ref !== 'object') {
50
+ return;
51
+ }
52
+ const fieldName = declaredField.name;
53
+ const field = resolveFieldLocalization({
54
+ field: declaredField,
55
+ isAbsorbed: parentIsLocalized
56
+ });
57
+ const current = ref;
58
+ let value = current[fieldName];
59
+ if (isAtomicOperation(value, ATOMIC_OPERATORS) && field.type !== 'relationship' && field.type !== 'upload') {
60
+ return;
61
+ }
62
+ // null → [] for non-localized array-like fields. SQL adapters return null for empty join
63
+ // tables; Content API stores JSON null which breaks jsonb_array_elements queries.
64
+ if (value === null && !('localized' in field && field.localized)) {
65
+ const isHasManyArray = (field.type === 'relationship' || field.type === 'upload') && 'hasMany' in field && field.hasMany;
66
+ const isArrayLike = field.type === 'array' || field.type === 'blocks';
67
+ const isHasManySelect = field.type === 'select' && 'hasMany' in field && field.hasMany;
68
+ if (isHasManyArray || isArrayLike || isHasManySelect) {
69
+ current[fieldName] = [];
70
+ return;
71
+ }
72
+ }
73
+ if (value !== null && value !== undefined) {
74
+ if (field.type === 'relationship' || field.type === 'upload') {
75
+ // Convert ids that point at a numeric-custom-id collection to strings —
76
+ // the wire (and the server's relationshipSchema) only accepts string ids —
77
+ // and normalize a has-many value to an array.
78
+ current[fieldName] = convertRelationshipFieldIds({
79
+ direction: 'toWire',
80
+ field,
81
+ payload,
82
+ value
83
+ });
84
+ return;
85
+ }
86
+ if (field.type === 'point') {
87
+ current[fieldName] = encodePointForWrite(field, value);
88
+ return;
89
+ }
90
+ if (field.type === 'richText') {
91
+ current[fieldName] = encodeRichTextForWrite(field, value);
92
+ return;
93
+ }
94
+ value = castFieldValue(field, value);
95
+ current[fieldName] = value;
96
+ }
97
+ };
98
+ traverseFields({
99
+ callback,
100
+ fields: collectionConfig.fields,
101
+ fillEmpty: false,
102
+ ref: transformed
103
+ });
104
+ stripFields({
105
+ config: payload.config,
106
+ data: transformed,
107
+ fields: flattenAllFields({
108
+ cache: true,
109
+ fields: collectionConfig.fields
110
+ }),
111
+ reservedKeys: [
112
+ 'id'
113
+ ]
114
+ });
115
+ removeVirtualFields(transformed, collectionConfig.fields);
116
+ // Convert numeric ID to string for Content API
117
+ const customIDType = payload.collections?.[collectionSlug]?.customIDType;
118
+ if (customIDType === 'number') {
119
+ transformed.id = String(transformed.id);
120
+ }
121
+ // Add timestamps (Content API no longer auto-sets these in DB)
122
+ // Preserve existing timestamps when already present (e.g. version data that carries
123
+ // the parent document's timestamps), otherwise generate new ones.
124
+ // Explicit null means "don't change" — strip it so the API keeps the existing value.
125
+ const now = new Date().toISOString();
126
+ if (transformed.updatedAt === null) {
127
+ delete transformed.updatedAt;
128
+ } else if (transformed.updatedAt === undefined) {
129
+ transformed.updatedAt = now;
130
+ }
131
+ if (options?.createdAt && !transformed.createdAt) {
132
+ transformed.createdAt = now;
133
+ }
134
+ return transformed;
135
+ }
136
+ /**
137
+ * Transform data received from Content API (READ operations)
138
+ *
139
+ * Conversions applied:
140
+ * - RichText fields: JSON strings -> Objects
141
+ * - Virtual fields: Remove fields with `virtual: true` (should not be in DB but Content API backend may add them)
142
+ *
143
+ * Note: Date fields come as ISO strings from Content API and stay as strings
144
+ * (matching MongoDB and other adapters' behavior)
145
+ */ /**
146
+ * Extract version content from versionData that may be flat (no nested `version` key).
147
+ * Some callers spread version content at the top level alongside metadata
148
+ * (e.g. `{ ...version.version, createdAt }`), so we reconstruct the `version`
149
+ * object by filtering out known metadata keys.
150
+ */ export function resolveVersionContent(version, versionMeta) {
151
+ if (version !== undefined) {
152
+ return version;
153
+ }
154
+ const metaKeys = [
155
+ 'createdAt',
156
+ 'updatedAt',
157
+ 'latest',
158
+ 'parent'
159
+ ];
160
+ return Object.fromEntries(Object.entries(versionMeta).filter(([key])=>!metaKeys.includes(key)));
161
+ }
162
+ export function dataFromContentAPI(payload, collectionSlug, data, locale) {
163
+ if (!data || typeof data !== 'object') {
164
+ return data;
165
+ }
166
+ // Deep clone to avoid mutating original data
167
+ const transformed = JSON.parse(JSON.stringify(data));
168
+ // Get collection config
169
+ const isGlobal = collectionSlug.startsWith('_global-');
170
+ const actualSlug = isGlobal ? collectionSlug.substring(8) : collectionSlug;
171
+ const collectionConfig = isGlobal ? payload.config.globals?.find((g)=>g.slug === actualSlug) : payload.config.collections.find((c)=>c.slug === actualSlug);
172
+ if (!collectionConfig?.fields) {
173
+ return transformed;
174
+ }
175
+ const isAllLocales = locale === 'all' || locale === '*';
176
+ // Use Payload's traverseFields to iterate over all fields
177
+ const callback = ({ field: declaredField, parentIsLocalized, parentPath, ref })=>{
178
+ if (!('name' in declaredField) || !declaredField.name) {
179
+ return;
180
+ }
181
+ if (!ref || typeof ref !== 'object') {
182
+ return;
183
+ }
184
+ // Value shaping below depends on whether locale keys appear at this path, so
185
+ // work from the resolved field rather than the declared one.
186
+ const fieldName = declaredField.name;
187
+ const field = resolveFieldLocalization({
188
+ field: declaredField,
189
+ isAbsorbed: parentIsLocalized
190
+ });
191
+ const current = ref;
192
+ const value = current[fieldName];
193
+ const isLocalized = 'localized' in field && field.localized === true;
194
+ // Group fields must always be an object so Payload can traverse sub-fields
195
+ // (e.g. join fields inside a group). A null/undefined group crashes afterRead.
196
+ if (field.type === 'group') {
197
+ if (value == null || typeof value !== 'object') {
198
+ current[fieldName] = {};
199
+ }
200
+ return;
201
+ }
202
+ // Localized join fields: wrap in locale map so afterRead can hoist the value.
203
+ // Content API returns join data directly at the field path (e.g. { docs: [...] }),
204
+ // but Payload's afterRead expects localized fields as { [locale]: value }.
205
+ if (field.type === 'join' && isLocalized && value !== undefined && !isAllLocales && locale) {
206
+ current[fieldName] = {
207
+ [locale]: value
208
+ };
209
+ return;
210
+ }
211
+ // Content API may omit fields; Payload expects null for optional fields.
212
+ // In all-locales mode, localized fields use {} so afterRead can safely iterate locale keys.
213
+ if (value === undefined) {
214
+ const isRequired = 'required' in field && field.required;
215
+ const isJoin = field.type === 'join';
216
+ if (!isRequired && !isJoin) {
217
+ current[fieldName] = isLocalized && isAllLocales ? {} : null;
218
+ }
219
+ return;
220
+ }
221
+ // null localized field in all-locales mode → {} (empty locale map)
222
+ if (value === null && isLocalized && isAllLocales) {
223
+ current[fieldName] = {};
224
+ return;
225
+ }
226
+ if (value !== null) {
227
+ if (field.type === 'relationship' || field.type === 'upload') {
228
+ // The Content API returns ids as strings; convert back to numbers for
229
+ // relationships that point at a numeric-custom-id collection so Payload
230
+ // sees its native type, and normalize a has-many value to an array.
231
+ current[fieldName] = convertRelationshipFieldIds({
232
+ direction: 'fromWire',
233
+ field,
234
+ payload,
235
+ value
236
+ });
237
+ return;
238
+ }
239
+ if (field.type === 'point') {
240
+ current[fieldName] = decodePointFromRead(field, value);
241
+ return;
242
+ }
243
+ if (field.type === 'richText') {
244
+ const fieldPath = parentPath ? `${parentPath}.${field.name}` : field.name;
245
+ current[fieldName] = decodeRichTextFromRead(field, value, payload, fieldPath, collectionSlug);
246
+ return;
247
+ }
248
+ // Localized array/blocks: empty per-locale arrays → null in single-locale mode.
249
+ // Payload's afterRead fallback triggers on null (not []), matching SQL adapter behavior.
250
+ if (isLocalized && !isAllLocales && (field.type === 'array' || field.type === 'blocks') && typeof value === 'object' && !Array.isArray(value)) {
251
+ const localeMap = value;
252
+ for (const localeKey of Object.keys(localeMap)){
253
+ const localeValue = localeMap[localeKey];
254
+ if (Array.isArray(localeValue) && localeValue.length === 0) {
255
+ localeMap[localeKey] = null;
256
+ }
257
+ }
258
+ }
259
+ // Localized fields: JSON string → parsed object (locale map).
260
+ // Simple strings that fail to parse as objects are kept as-is (expected for single-locale).
261
+ if (isLocalized && typeof value === 'string') {
262
+ try {
263
+ const parsed = JSON.parse(value);
264
+ if (typeof parsed === 'object' && parsed !== null) {
265
+ current[fieldName] = parsed;
266
+ }
267
+ } catch {
268
+ // Not valid JSON - keep original value
269
+ }
270
+ }
271
+ // Date fields: Already ISO strings from Content API, no conversion needed
272
+ }
273
+ };
274
+ traverseFields({
275
+ callback,
276
+ fields: collectionConfig.fields,
277
+ fillEmpty: false,
278
+ ref: transformed
279
+ });
280
+ // Convert string ID to number if collection uses numeric custom ID
281
+ const customIDType = payload.collections?.[collectionSlug]?.customIDType;
282
+ if (customIDType === 'number') {
283
+ transformed.id = Number(transformed.id);
284
+ }
285
+ stripFields({
286
+ config: payload.config,
287
+ data: transformed,
288
+ fields: flattenAllFields({
289
+ cache: true,
290
+ fields: collectionConfig.fields
291
+ }),
292
+ reservedKeys: [
293
+ 'id',
294
+ 'globalType'
295
+ ]
296
+ });
297
+ // Remove virtual fields - must happen AFTER stripFields
298
+ removeVirtualFields(transformed, collectionConfig.fields);
299
+ // Handle auth-specific fields that aren't in the field schema
300
+ // When these fields are null in DB, Content API omits them from response (undefined)
301
+ // But Payload expects them to be null, not undefined
302
+ // Only add them if the collection has auth enabled
303
+ if ('auth' in collectionConfig && collectionConfig.auth) {
304
+ const authFields = [
305
+ 'resetPasswordExpiration',
306
+ 'lockUntil'
307
+ ];
308
+ for (const fieldName of authFields){
309
+ if (!(fieldName in transformed)) {
310
+ transformed[fieldName] = null;
311
+ }
312
+ }
313
+ }
314
+ return transformed;
315
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * A locale-map is a plain object keyed by locale (e.g. `{ en: 'id', fr: 'id' }`) —
3
+ * distinct from the other object shapes a field value can take: a polymorphic
4
+ * relationship ref (`{ relationTo, value }`) or an atomic wrapper (`{ $push: … }`).
5
+ *
6
+ * Localized values arrive as a locale-map on write and all-locales reads, but as
7
+ * the bare per-locale value on single-locale reads, so a localized field cannot
8
+ * assume the map and has to discriminate on the shape.
9
+ */
10
+ export declare function isLocaleMap(value: unknown): value is Record<string, unknown>;
@@ -0,0 +1,13 @@
1
+ import { valueIsValueWithRelation } from 'payload/shared';
2
+ import { ATOMIC_OPERATORS, isAtomicOperation } from './atomicOperations.js';
3
+ /**
4
+ * A locale-map is a plain object keyed by locale (e.g. `{ en: 'id', fr: 'id' }`) —
5
+ * distinct from the other object shapes a field value can take: a polymorphic
6
+ * relationship ref (`{ relationTo, value }`) or an atomic wrapper (`{ $push: … }`).
7
+ *
8
+ * Localized values arrive as a locale-map on write and all-locales reads, but as
9
+ * the bare per-locale value on single-locale reads, so a localized field cannot
10
+ * assume the map and has to discriminate on the shape.
11
+ */ export function isLocaleMap(value) {
12
+ return !!value && typeof value === 'object' && !Array.isArray(value) && !valueIsValueWithRelation(value) && !isAtomicOperation(value, ATOMIC_OPERATORS);
13
+ }
@@ -0,0 +1,3 @@
1
+ import type { Field, TabAsField } from 'payload';
2
+ export declare function encodePointForWrite(field: Field | TabAsField, value: unknown): unknown;
3
+ export declare function decodePointFromRead(field: Field | TabAsField, value: unknown): unknown;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Payload stores a point as GeoJSON; the v1 server uses a bare `[lng, lat]`
3
+ * tuple. Unwrap on write, re-wrap on read so afterRead can restore the tuple.
4
+ */ function isPlainObject(value) {
5
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
6
+ }
7
+ function isCoordinateTuple(value) {
8
+ return Array.isArray(value) && value.length === 2 && value.every((v)=>typeof v === 'number');
9
+ }
10
+ function pointLeafToWire(value) {
11
+ if (isPlainObject(value) && isCoordinateTuple(value.coordinates)) {
12
+ return value.coordinates;
13
+ }
14
+ return value;
15
+ }
16
+ function pointLeafFromWire(value) {
17
+ if (isCoordinateTuple(value)) {
18
+ return {
19
+ type: 'Point',
20
+ coordinates: value
21
+ };
22
+ }
23
+ return value;
24
+ }
25
+ function mapPoint(field, value, mapLeaf) {
26
+ if (field.type !== 'point' || value === null || value === undefined) {
27
+ return value;
28
+ }
29
+ if ('localized' in field && field.localized && isPlainObject(value)) {
30
+ const result = {};
31
+ for (const [locale, localeValue] of Object.entries(value)){
32
+ result[locale] = mapLeaf(localeValue);
33
+ }
34
+ return result;
35
+ }
36
+ return mapLeaf(value);
37
+ }
38
+ export function encodePointForWrite(field, value) {
39
+ return mapPoint(field, value, pointLeafToWire);
40
+ }
41
+ export function decodePointFromRead(field, value) {
42
+ return mapPoint(field, value, pointLeafFromWire);
43
+ }
@@ -0,0 +1,11 @@
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;
@@ -0,0 +1,52 @@
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
+ }
@@ -0,0 +1,18 @@
1
+ import type { Field, TabAsField } from 'payload';
2
+ interface ResolveFieldLocalizationOptions<TField extends Field | TabAsField> {
3
+ field: TField;
4
+ isAbsorbed: boolean;
5
+ }
6
+ /**
7
+ * Returns the field with `localized` collapsed to whether locale keys actually
8
+ * appear in its data — `false` for a field whose localized ancestor already
9
+ * absorbed them (see `createIsLocaleAbsorbed`).
10
+ *
11
+ * Every value-shaping helper keys off `field.localized` to decide whether it is
12
+ * looking at a locale map or a bare value, so handing them the resolved field
13
+ * keeps that decision correct without each one needing to know about absorption.
14
+ * The field is returned as-is when nothing changes, so the common path allocates
15
+ * nothing and any narrowing the caller has already done survives.
16
+ */
17
+ export declare function resolveFieldLocalization<TField extends Field | TabAsField>({ field, isAbsorbed, }: ResolveFieldLocalizationOptions<TField>): TField;
18
+ export {};
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Returns the field with `localized` collapsed to whether locale keys actually
3
+ * appear in its data — `false` for a field whose localized ancestor already
4
+ * absorbed them (see `createIsLocaleAbsorbed`).
5
+ *
6
+ * Every value-shaping helper keys off `field.localized` to decide whether it is
7
+ * looking at a locale map or a bare value, so handing them the resolved field
8
+ * keeps that decision correct without each one needing to know about absorption.
9
+ * The field is returned as-is when nothing changes, so the common path allocates
10
+ * nothing and any narrowing the caller has already done survives.
11
+ */ export function resolveFieldLocalization({ field, isAbsorbed }) {
12
+ if (!isAbsorbed || !('localized' in field) || field.localized !== true) {
13
+ return field;
14
+ }
15
+ // Only `localized` changes, so the result is still the same field type; TypeScript
16
+ // cannot see that through a spread of a generic union member.
17
+ return {
18
+ ...field,
19
+ localized: false
20
+ };
21
+ }
@@ -0,0 +1,3 @@
1
+ import type { Field, Payload, TabAsField } from 'payload';
2
+ export declare function encodeRichTextForWrite(field: Field | TabAsField, value: unknown): unknown;
3
+ export declare function decodeRichTextFromRead(field: Field | TabAsField, value: unknown, payload: Payload, fieldPath: string, collectionSlug: string): unknown;