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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (352) hide show
  1. package/dist/api/control-plane.d.ts +52 -6
  2. package/dist/api/control-plane.js +174 -72
  3. package/dist/api/figma-api.d.ts +22 -1
  4. package/dist/api/figma-api.js +78 -25
  5. package/dist/auth/callback-server.js +2 -1
  6. package/dist/auth/credentials.d.ts +21 -0
  7. package/dist/auth/credentials.js +21 -0
  8. package/dist/auth/crypto-utils.d.ts +6 -0
  9. package/dist/auth/crypto-utils.js +16 -14
  10. package/dist/auth/jwt-validator.d.ts +2 -1
  11. package/dist/auth/jwt-validator.js +2 -2
  12. package/dist/auth/oauth-flow.d.ts +17 -3
  13. package/dist/auth/oauth-flow.js +63 -16
  14. package/dist/auth/project-token.js +16 -11
  15. package/dist/auth/refresh.d.ts +2 -1
  16. package/dist/auth/refresh.js +25 -12
  17. package/dist/auth/token-store.d.ts +42 -1
  18. package/dist/auth/token-store.js +118 -14
  19. package/dist/auth/types.d.ts +17 -4
  20. package/dist/cli.js +68 -5
  21. package/dist/commands/build-lambda-zip.d.ts +5 -0
  22. package/dist/commands/build-lambda-zip.js +19 -0
  23. package/dist/commands/debug.d.ts +8 -0
  24. package/dist/commands/debug.js +176 -0
  25. package/dist/commands/deploy.d.ts +9 -0
  26. package/dist/commands/deploy.js +178 -151
  27. package/dist/commands/env.d.ts +13 -0
  28. package/dist/commands/env.js +88 -0
  29. package/dist/commands/init.d.ts +3 -5
  30. package/dist/commands/init.js +165 -148
  31. package/dist/commands/list-tokens.d.ts +3 -3
  32. package/dist/commands/list-tokens.js +22 -7
  33. package/dist/commands/login.d.ts +8 -1
  34. package/dist/commands/login.js +33 -15
  35. package/dist/commands/logout.d.ts +5 -4
  36. package/dist/commands/logout.js +56 -13
  37. package/dist/commands/upgrade.d.ts +5 -0
  38. package/dist/commands/upgrade.js +331 -0
  39. package/dist/config/oauth.d.ts +4 -14
  40. package/dist/config/oauth.js +18 -40
  41. package/dist/constants.d.ts +44 -19
  42. package/dist/constants.js +73 -20
  43. package/dist/db-content-api/README.md +98 -0
  44. package/dist/db-content-api/generated/content-api-types.d.ts +3972 -0
  45. package/dist/db-content-api/generated/content-api-types.js +7 -0
  46. package/dist/db-content-api/index.d.ts +21 -0
  47. package/dist/db-content-api/index.js +787 -0
  48. package/dist/db-content-api/temp-utilities/slug.d.ts +2 -0
  49. package/dist/db-content-api/temp-utilities/slug.js +3 -0
  50. package/dist/db-content-api/temp-utilities/sorting.d.ts +3 -0
  51. package/dist/db-content-api/temp-utilities/sorting.js +39 -0
  52. package/dist/db-content-api/temp-utilities/types.d.ts +22 -0
  53. package/dist/db-content-api/temp-utilities/types.js +15 -0
  54. package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +39 -0
  55. package/dist/db-content-api/temp-utilities/unwrapDocument.js +59 -0
  56. package/dist/db-content-api/utilities/auth.d.ts +30 -0
  57. package/dist/db-content-api/utilities/auth.js +81 -0
  58. package/dist/db-content-api/utilities/data/applyDefaults.d.ts +7 -0
  59. package/dist/db-content-api/utilities/data/applyDefaults.js +59 -0
  60. package/dist/db-content-api/utilities/data/castFieldValue.d.ts +11 -0
  61. package/dist/db-content-api/utilities/data/castFieldValue.js +68 -0
  62. package/dist/db-content-api/utilities/data/index.d.ts +49 -0
  63. package/dist/db-content-api/utilities/data/index.js +284 -0
  64. package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +12 -0
  65. package/dist/db-content-api/utilities/data/removeVirtualFields.js +54 -0
  66. package/dist/db-content-api/utilities/data/stripFields.d.ts +48 -0
  67. package/dist/db-content-api/utilities/data/stripFields.js +195 -0
  68. package/dist/db-content-api/utilities/data/transformPublishedLocale.d.ts +23 -0
  69. package/dist/db-content-api/utilities/data/transformPublishedLocale.js +42 -0
  70. package/dist/db-content-api/utilities/joins.d.ts +55 -0
  71. package/dist/db-content-api/utilities/joins.js +135 -0
  72. package/dist/db-content-api/utilities/locale/index.d.ts +10 -0
  73. package/dist/db-content-api/utilities/locale/index.js +21 -0
  74. package/dist/db-content-api/utilities/meta/buildLocalizedPaths.d.ts +11 -0
  75. package/dist/db-content-api/utilities/meta/buildLocalizedPaths.js +74 -0
  76. package/dist/db-content-api/utilities/meta/buildMeta.d.ts +42 -0
  77. package/dist/db-content-api/utilities/meta/buildMeta.js +41 -0
  78. package/dist/db-content-api/utilities/meta/buildPathTypes.d.ts +17 -0
  79. package/dist/db-content-api/utilities/meta/buildPathTypes.js +244 -0
  80. package/dist/db-content-api/utilities/meta/buildUniquePaths.d.ts +13 -0
  81. package/dist/db-content-api/utilities/meta/buildUniquePaths.js +62 -0
  82. package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.d.ts +10 -0
  83. package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.js +102 -0
  84. package/dist/db-content-api/utilities/where.d.ts +20 -0
  85. package/dist/db-content-api/utilities/where.js +104 -0
  86. package/dist/deploy/schedule-extract-plugin.d.ts +11 -0
  87. package/dist/deploy/schedule-extract-plugin.js +34 -0
  88. package/dist/endpoints/health.d.ts +3 -0
  89. package/dist/endpoints/health.js +11 -0
  90. package/dist/endpoints/schema.d.ts +3 -0
  91. package/dist/endpoints/schema.js +29 -0
  92. package/dist/exports/client.d.ts +3 -0
  93. package/dist/exports/client.js +3 -0
  94. package/dist/index.d.ts +2 -1
  95. package/dist/index.js +3 -1
  96. package/dist/oauth/components/FigmaAvatar/index.d.ts +4 -0
  97. package/dist/oauth/components/FigmaAvatar/index.js +27 -0
  98. package/dist/oauth/components/FigmaAvatar/index.scss +12 -0
  99. package/dist/oauth/components/FigmaAvatarCell/index.d.ts +5 -0
  100. package/dist/oauth/components/FigmaAvatarCell/index.js +25 -0
  101. package/dist/oauth/components/FigmaAvatarCell/index.scss +5 -0
  102. package/dist/oauth/components/FigmaAvatarPlaceholder/index.d.ts +9 -0
  103. package/dist/oauth/components/FigmaAvatarPlaceholder/index.js +37 -0
  104. package/dist/oauth/components/FigmaAvatarPlaceholder/index.scss +28 -0
  105. package/dist/oauth/components/LoginButton/index.js +50 -6
  106. package/dist/oauth/components/LoginButton/index.scss +50 -3
  107. package/dist/oauth/components/LogoutButton/index.js +5 -4
  108. package/dist/oauth/defaults.js +67 -10
  109. package/dist/oauth/endpoints/getLoginEndpoint.js +77 -24
  110. package/dist/oauth/endpoints/getLogoutEndpoint.js +7 -4
  111. package/dist/oauth/index.js +40 -13
  112. package/dist/oauth/strategy/index.d.ts +0 -2
  113. package/dist/oauth/strategy/index.js +40 -17
  114. package/dist/oauth/types.d.ts +6 -6
  115. package/dist/oauth/utilities/isDuplicateKeyError.d.ts +7 -0
  116. package/dist/oauth/utilities/isDuplicateKeyError.js +14 -0
  117. package/dist/oauth/utilities/refreshTokens.js +6 -3
  118. package/dist/plugin/build-config.d.ts +18 -15
  119. package/dist/plugin/build-config.js +213 -18
  120. package/dist/storage-content-api/api-types.d.ts +168 -0
  121. package/dist/storage-content-api/api-types.js +6 -0
  122. package/dist/storage-content-api/client-uploads/ClientUploadHandler.d.ts +9 -0
  123. package/dist/storage-content-api/client-uploads/ClientUploadHandler.js +42 -0
  124. package/dist/storage-content-api/client-uploads/generateSignedURL.d.ts +13 -0
  125. package/dist/storage-content-api/client-uploads/generateSignedURL.js +39 -0
  126. package/dist/storage-content-api/client.d.ts +6 -0
  127. package/dist/storage-content-api/client.js +36 -0
  128. package/dist/storage-content-api/generateURL.d.ts +7 -0
  129. package/dist/storage-content-api/generateURL.js +8 -0
  130. package/dist/storage-content-api/handleDelete.d.ts +8 -0
  131. package/dist/storage-content-api/handleDelete.js +17 -0
  132. package/dist/storage-content-api/handleUpload.d.ts +11 -0
  133. package/dist/storage-content-api/handleUpload.js +144 -0
  134. package/dist/storage-content-api/index.d.ts +5 -0
  135. package/dist/storage-content-api/index.js +31 -0
  136. package/dist/storage-content-api/staticHandler.d.ts +10 -0
  137. package/dist/storage-content-api/staticHandler.js +56 -0
  138. package/dist/storage-content-api/types.d.ts +10 -0
  139. package/dist/storage-content-api/types.js +3 -0
  140. package/dist/storage-content-api/utilities/getSafeFilename.d.ts +12 -0
  141. package/dist/storage-content-api/utilities/getSafeFilename.js +61 -0
  142. package/dist/storage-content-api/utilities/index.d.ts +2 -0
  143. package/dist/storage-content-api/utilities/index.js +3 -0
  144. package/dist/templates/.env.example +5 -0
  145. package/dist/templates/README.md +19 -0
  146. package/dist/types/config.d.ts +2 -1
  147. package/dist/types/config.js +0 -2
  148. package/dist/types.d.ts +8 -1
  149. package/dist/utils/adapters/nextjs.d.ts +9 -0
  150. package/dist/utils/adapters/nextjs.js +64 -0
  151. package/dist/utils/adapters/nitro.d.ts +9 -0
  152. package/dist/utils/adapters/nitro.js +169 -0
  153. package/dist/utils/adapters/vite.d.ts +10 -0
  154. package/dist/utils/adapters/vite.js +33 -0
  155. package/dist/utils/asset-collection.d.ts +27 -6
  156. package/dist/utils/asset-collection.js +59 -30
  157. package/dist/utils/build-detection.d.ts +5 -11
  158. package/dist/utils/build-detection.js +74 -11
  159. package/dist/utils/build-lambda-zip.d.ts +14 -0
  160. package/dist/utils/build-lambda-zip.js +81 -0
  161. package/dist/utils/cache-bootstrap.d.ts +8 -0
  162. package/dist/utils/cache-bootstrap.js +18 -0
  163. package/dist/utils/config.js +1 -1
  164. package/dist/utils/deploy-adapter.d.ts +40 -0
  165. package/dist/utils/deploy-adapter.js +58 -0
  166. package/dist/utils/download-template.js +3 -2
  167. package/dist/utils/env-management.d.ts +24 -7
  168. package/dist/utils/env-management.js +119 -64
  169. package/dist/utils/format-env-suffix.d.ts +12 -0
  170. package/dist/utils/format-env-suffix.js +13 -0
  171. package/dist/utils/formatter.js +23 -11
  172. package/dist/utils/fs-utils.d.ts +6 -0
  173. package/dist/utils/fs-utils.js +27 -0
  174. package/dist/utils/handle-upgrade.d.ts +9 -0
  175. package/dist/utils/handle-upgrade.js +41 -0
  176. package/dist/utils/lambda-config.d.ts +3 -1
  177. package/dist/utils/lambda-config.js +87 -79
  178. package/dist/utils/messages.d.ts +1 -2
  179. package/dist/utils/messages.js +29 -11
  180. package/dist/utils/package-manager.d.ts +24 -0
  181. package/dist/utils/package-manager.js +53 -0
  182. package/dist/utils/payload-config-ast.d.ts +27 -6
  183. package/dist/utils/payload-config-ast.js +84 -54
  184. package/dist/utils/payload-config-finder.d.ts +2 -2
  185. package/dist/utils/payload-config-finder.js +48 -9
  186. package/dist/utils/payload-config-modifier.d.ts +1 -1
  187. package/dist/utils/payload-config-modifier.js +70 -11
  188. package/dist/utils/payload-package-check.d.ts +12 -1
  189. package/dist/utils/payload-package-check.js +63 -5
  190. package/dist/utils/project.d.ts +3 -2
  191. package/dist/utils/project.js +29 -15
  192. package/dist/utils/resolve-environment.d.ts +14 -0
  193. package/dist/utils/resolve-environment.js +31 -0
  194. package/dist/utils/s3-upload.d.ts +7 -2
  195. package/dist/utils/s3-upload.js +39 -6
  196. package/dist/utils/token-display.js +11 -5
  197. package/dist/utils/typescript-validator.js +4 -6
  198. package/dist/utils/version-check.d.ts +3 -0
  199. package/dist/utils/version-check.js +38 -0
  200. package/package.json +29 -11
  201. package/dist/api/control-plane.d.ts.map +0 -1
  202. package/dist/api/control-plane.js.map +0 -1
  203. package/dist/api/figma-api.d.ts.map +0 -1
  204. package/dist/api/figma-api.js.map +0 -1
  205. package/dist/auth/browser.d.ts.map +0 -1
  206. package/dist/auth/browser.js.map +0 -1
  207. package/dist/auth/callback-server.d.ts.map +0 -1
  208. package/dist/auth/callback-server.js.map +0 -1
  209. package/dist/auth/crypto-utils.d.ts.map +0 -1
  210. package/dist/auth/crypto-utils.js.map +0 -1
  211. package/dist/auth/jwt-validator.d.ts.map +0 -1
  212. package/dist/auth/jwt-validator.js.map +0 -1
  213. package/dist/auth/oauth-flow.d.ts.map +0 -1
  214. package/dist/auth/oauth-flow.js.map +0 -1
  215. package/dist/auth/pkce.d.ts.map +0 -1
  216. package/dist/auth/pkce.js.map +0 -1
  217. package/dist/auth/project-token.d.ts.map +0 -1
  218. package/dist/auth/project-token.js.map +0 -1
  219. package/dist/auth/refresh.d.ts.map +0 -1
  220. package/dist/auth/refresh.js.map +0 -1
  221. package/dist/auth/token-store.d.ts.map +0 -1
  222. package/dist/auth/token-store.js.map +0 -1
  223. package/dist/auth/types.d.ts.map +0 -1
  224. package/dist/auth/types.js.map +0 -1
  225. package/dist/cli.d.ts.map +0 -1
  226. package/dist/cli.js.map +0 -1
  227. package/dist/commands/deploy.d.ts.map +0 -1
  228. package/dist/commands/deploy.js.map +0 -1
  229. package/dist/commands/init.d.ts.map +0 -1
  230. package/dist/commands/init.js.map +0 -1
  231. package/dist/commands/list-tokens.d.ts.map +0 -1
  232. package/dist/commands/list-tokens.js.map +0 -1
  233. package/dist/commands/login.d.ts.map +0 -1
  234. package/dist/commands/login.js.map +0 -1
  235. package/dist/commands/logout.d.ts.map +0 -1
  236. package/dist/commands/logout.js.map +0 -1
  237. package/dist/config/oauth.d.ts.map +0 -1
  238. package/dist/config/oauth.js.map +0 -1
  239. package/dist/constants.d.ts.map +0 -1
  240. package/dist/constants.js.map +0 -1
  241. package/dist/exports/client.d.ts.map +0 -1
  242. package/dist/exports/client.js.map +0 -1
  243. package/dist/index.d.ts.map +0 -1
  244. package/dist/index.js.map +0 -1
  245. package/dist/oauth/components/LoginButton/index.d.ts.map +0 -1
  246. package/dist/oauth/components/LoginButton/index.js.map +0 -1
  247. package/dist/oauth/components/LogoutButton/index.d.ts.map +0 -1
  248. package/dist/oauth/components/LogoutButton/index.js.map +0 -1
  249. package/dist/oauth/defaults.d.ts.map +0 -1
  250. package/dist/oauth/defaults.js.map +0 -1
  251. package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +0 -1
  252. package/dist/oauth/endpoints/getLoginEndpoint.js.map +0 -1
  253. package/dist/oauth/endpoints/getLogoutEndpoint.d.ts.map +0 -1
  254. package/dist/oauth/endpoints/getLogoutEndpoint.js.map +0 -1
  255. package/dist/oauth/endpoints/getMetaEndpoint.d.ts.map +0 -1
  256. package/dist/oauth/endpoints/getMetaEndpoint.js.map +0 -1
  257. package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts.map +0 -1
  258. package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js.map +0 -1
  259. package/dist/oauth/exports/client.d.ts.map +0 -1
  260. package/dist/oauth/exports/client.js.map +0 -1
  261. package/dist/oauth/hooks/afterLogout.d.ts.map +0 -1
  262. package/dist/oauth/hooks/afterLogout.js.map +0 -1
  263. package/dist/oauth/hooks/me.d.ts.map +0 -1
  264. package/dist/oauth/hooks/me.js.map +0 -1
  265. package/dist/oauth/hooks/refresh.d.ts.map +0 -1
  266. package/dist/oauth/hooks/refresh.js.map +0 -1
  267. package/dist/oauth/index.d.ts.map +0 -1
  268. package/dist/oauth/index.js.map +0 -1
  269. package/dist/oauth/strategy/index.d.ts.map +0 -1
  270. package/dist/oauth/strategy/index.js.map +0 -1
  271. package/dist/oauth/types.d.ts.map +0 -1
  272. package/dist/oauth/types.js.map +0 -1
  273. package/dist/oauth/utilities/clearCookie.d.ts.map +0 -1
  274. package/dist/oauth/utilities/clearCookie.js.map +0 -1
  275. package/dist/oauth/utilities/createCookieOptions.d.ts.map +0 -1
  276. package/dist/oauth/utilities/createCookieOptions.js.map +0 -1
  277. package/dist/oauth/utilities/createDebugLogger.d.ts.map +0 -1
  278. package/dist/oauth/utilities/createDebugLogger.js.map +0 -1
  279. package/dist/oauth/utilities/extractOrigin.d.ts.map +0 -1
  280. package/dist/oauth/utilities/extractOrigin.js.map +0 -1
  281. package/dist/oauth/utilities/getAdminCollectionSlug.d.ts.map +0 -1
  282. package/dist/oauth/utilities/getAdminCollectionSlug.js.map +0 -1
  283. package/dist/oauth/utilities/getAdminPath.d.ts +0 -8
  284. package/dist/oauth/utilities/getAdminPath.d.ts.map +0 -1
  285. package/dist/oauth/utilities/getAdminPath.js +0 -9
  286. package/dist/oauth/utilities/getAdminPath.js.map +0 -1
  287. package/dist/oauth/utilities/getAuthorizeURL.d.ts.map +0 -1
  288. package/dist/oauth/utilities/getAuthorizeURL.js.map +0 -1
  289. package/dist/oauth/utilities/getCookieExpiration.d.ts.map +0 -1
  290. package/dist/oauth/utilities/getCookieExpiration.js.map +0 -1
  291. package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts.map +0 -1
  292. package/dist/oauth/utilities/getSecondsFromTokenExp.js.map +0 -1
  293. package/dist/oauth/utilities/getTokenExp.d.ts.map +0 -1
  294. package/dist/oauth/utilities/getTokenExp.js.map +0 -1
  295. package/dist/oauth/utilities/getUsernameField.d.ts.map +0 -1
  296. package/dist/oauth/utilities/getUsernameField.js.map +0 -1
  297. package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts.map +0 -1
  298. package/dist/oauth/utilities/hasUserTokenPropsChanged.js.map +0 -1
  299. package/dist/oauth/utilities/mergeHeaders.d.ts.map +0 -1
  300. package/dist/oauth/utilities/mergeHeaders.js.map +0 -1
  301. package/dist/oauth/utilities/refreshTokens.d.ts.map +0 -1
  302. package/dist/oauth/utilities/refreshTokens.js.map +0 -1
  303. package/dist/plugin/adapter.d.ts.map +0 -1
  304. package/dist/plugin/adapter.js.map +0 -1
  305. package/dist/plugin/build-config.d.ts.map +0 -1
  306. package/dist/plugin/build-config.js.map +0 -1
  307. package/dist/types/config.d.ts.map +0 -1
  308. package/dist/types/config.js.map +0 -1
  309. package/dist/types.d.ts.map +0 -1
  310. package/dist/types.js.map +0 -1
  311. package/dist/utils/asset-collection.d.ts.map +0 -1
  312. package/dist/utils/asset-collection.js.map +0 -1
  313. package/dist/utils/build-detection.d.ts.map +0 -1
  314. package/dist/utils/build-detection.js.map +0 -1
  315. package/dist/utils/config.d.ts.map +0 -1
  316. package/dist/utils/config.js.map +0 -1
  317. package/dist/utils/download-template.d.ts.map +0 -1
  318. package/dist/utils/download-template.js.map +0 -1
  319. package/dist/utils/env-management.d.ts.map +0 -1
  320. package/dist/utils/env-management.js.map +0 -1
  321. package/dist/utils/format.d.ts.map +0 -1
  322. package/dist/utils/format.js.map +0 -1
  323. package/dist/utils/formatter.d.ts.map +0 -1
  324. package/dist/utils/formatter.js.map +0 -1
  325. package/dist/utils/git.d.ts.map +0 -1
  326. package/dist/utils/git.js.map +0 -1
  327. package/dist/utils/is-debug.d.ts.map +0 -1
  328. package/dist/utils/is-debug.js.map +0 -1
  329. package/dist/utils/lambda-config.d.ts.map +0 -1
  330. package/dist/utils/lambda-config.js.map +0 -1
  331. package/dist/utils/log.d.ts.map +0 -1
  332. package/dist/utils/log.js.map +0 -1
  333. package/dist/utils/messages.d.ts.map +0 -1
  334. package/dist/utils/messages.js.map +0 -1
  335. package/dist/utils/package-manager.d.ts.map +0 -1
  336. package/dist/utils/package-manager.js.map +0 -1
  337. package/dist/utils/payload-config-ast.d.ts.map +0 -1
  338. package/dist/utils/payload-config-ast.js.map +0 -1
  339. package/dist/utils/payload-config-finder.d.ts.map +0 -1
  340. package/dist/utils/payload-config-finder.js.map +0 -1
  341. package/dist/utils/payload-config-modifier.d.ts.map +0 -1
  342. package/dist/utils/payload-config-modifier.js.map +0 -1
  343. package/dist/utils/payload-package-check.d.ts.map +0 -1
  344. package/dist/utils/payload-package-check.js.map +0 -1
  345. package/dist/utils/project.d.ts.map +0 -1
  346. package/dist/utils/project.js.map +0 -1
  347. package/dist/utils/s3-upload.d.ts.map +0 -1
  348. package/dist/utils/s3-upload.js.map +0 -1
  349. package/dist/utils/token-display.d.ts.map +0 -1
  350. package/dist/utils/token-display.js.map +0 -1
  351. package/dist/utils/typescript-validator.d.ts.map +0 -1
  352. package/dist/utils/typescript-validator.js.map +0 -1
@@ -0,0 +1,55 @@
1
+ import type { JoinQuery, Payload } from 'payload';
2
+ import type { components } from '../generated/content-api-types.js';
3
+ type ContentAPIJoin = components['schemas']['JoinClause'][number];
4
+ /**
5
+ * Convert Payload's JoinQuery to Content API's join format.
6
+ *
7
+ * ## Content API Join Limitations
8
+ *
9
+ * The following Payload join features are NOT YET supported by Content API:
10
+ *
11
+ * 1. **hasMany relationships** - Content API's join uses `data#>'{path}'#>>'{}'` to extract
12
+ * a single ID. HasMany relationships store arrays `["id1", "id2"]` which can't match.
13
+ *
14
+ * 2. **Array field relationships** - `on: 'array.category'` expects iteration over array
15
+ * elements, but Content API treats the path as a single JSONB extraction.
16
+ *
17
+ * 3. **Polymorphic relationships** - Stored as `{ relationTo, value }` objects, but
18
+ * Content API expects a simple ID string.
19
+ *
20
+ * 4. **Localized relationship fields** - Locale-aware joins not implemented.
21
+ *
22
+ * Note: "Where querying through joins" (e.g., `where: { 'relatedPosts.title': { equals: 'x' } }`)
23
+ * is a separate Payload feature that filters documents based on joined data. This is NOT
24
+ * a join feature but a where clause feature, and would need separate Content API support.
25
+ *
26
+ * Payload's JoinQuery format (at runtime):
27
+ * {
28
+ * 'group.relatedPosts': { // joinPath - where results go in the document
29
+ * sort: '-title',
30
+ * limit: 10,
31
+ * page: 2, // page-based pagination
32
+ * where: { ... }, // Payload where format
33
+ * count: true
34
+ * }
35
+ * }
36
+ *
37
+ * Content API's join format:
38
+ * [{
39
+ * collectionId: 'posts', // collection to join FROM
40
+ * on: 'group.category', // field in joined collection pointing to this doc
41
+ * path: 'group.relatedPosts', // where to put results
42
+ * count: false,
43
+ * where: { ... }, // Content API where format
44
+ * sort: '-title',
45
+ * limit: 10,
46
+ * page: 2
47
+ * }]
48
+ *
49
+ * The mapping requires the collection config to resolve:
50
+ * - Which collection each join field refers to
51
+ * - What the 'on' field is for each join
52
+ */
53
+ export declare function convertPayloadJoinsToContentAPI(payload: Payload, collectionSlug: string, joins: false | JoinQuery | undefined): ContentAPIJoin[] | undefined;
54
+ export {};
55
+ //# sourceMappingURL=joins.d.ts.map
@@ -0,0 +1,135 @@
1
+ import { addFallbackSort } from '../temp-utilities/sorting.js';
2
+ import { convertPayloadWhereToContentAPI } from './where.js';
3
+ /**
4
+ * Convert Payload's JoinQuery to Content API's join format.
5
+ *
6
+ * ## Content API Join Limitations
7
+ *
8
+ * The following Payload join features are NOT YET supported by Content API:
9
+ *
10
+ * 1. **hasMany relationships** - Content API's join uses `data#>'{path}'#>>'{}'` to extract
11
+ * a single ID. HasMany relationships store arrays `["id1", "id2"]` which can't match.
12
+ *
13
+ * 2. **Array field relationships** - `on: 'array.category'` expects iteration over array
14
+ * elements, but Content API treats the path as a single JSONB extraction.
15
+ *
16
+ * 3. **Polymorphic relationships** - Stored as `{ relationTo, value }` objects, but
17
+ * Content API expects a simple ID string.
18
+ *
19
+ * 4. **Localized relationship fields** - Locale-aware joins not implemented.
20
+ *
21
+ * Note: "Where querying through joins" (e.g., `where: { 'relatedPosts.title': { equals: 'x' } }`)
22
+ * is a separate Payload feature that filters documents based on joined data. This is NOT
23
+ * a join feature but a where clause feature, and would need separate Content API support.
24
+ *
25
+ * Payload's JoinQuery format (at runtime):
26
+ * {
27
+ * 'group.relatedPosts': { // joinPath - where results go in the document
28
+ * sort: '-title',
29
+ * limit: 10,
30
+ * page: 2, // page-based pagination
31
+ * where: { ... }, // Payload where format
32
+ * count: true
33
+ * }
34
+ * }
35
+ *
36
+ * Content API's join format:
37
+ * [{
38
+ * collectionId: 'posts', // collection to join FROM
39
+ * on: 'group.category', // field in joined collection pointing to this doc
40
+ * path: 'group.relatedPosts', // where to put results
41
+ * count: false,
42
+ * where: { ... }, // Content API where format
43
+ * sort: '-title',
44
+ * limit: 10,
45
+ * page: 2
46
+ * }]
47
+ *
48
+ * The mapping requires the collection config to resolve:
49
+ * - Which collection each join field refers to
50
+ * - What the 'on' field is for each join
51
+ */ export function convertPayloadJoinsToContentAPI(payload, collectionSlug, joins) {
52
+ const collectionConfig = payload.config.collections.find((c)=>c.slug === collectionSlug);
53
+ if (!collectionConfig) {
54
+ return undefined;
55
+ }
56
+ // joins === false means explicitly disable all joins
57
+ // joins === undefined means use defaults (no custom query params)
58
+ if (joins === false || !joins) {
59
+ return undefined;
60
+ }
61
+ const result = [];
62
+ // Iterate through all join paths in the query
63
+ for (const [joinPath, joinQueryValue] of Object.entries(joins)){
64
+ // joinQuery === false means skip this specific join
65
+ if (joinQueryValue === false) {
66
+ continue;
67
+ }
68
+ // Normalize undefined/empty to empty object
69
+ const joinQuery = joinQueryValue ?? {};
70
+ // Find the SanitizedJoin config for this joinPath
71
+ // SanitizedJoins is indexed by the collection being joined FROM
72
+ let foundJoin;
73
+ // Search through all collections in the joins config
74
+ for (const [collectionSlug, sanitizedJoins] of Object.entries(collectionConfig.joins)){
75
+ for (const sanitizedJoin of sanitizedJoins){
76
+ if (sanitizedJoin.joinPath === joinPath) {
77
+ foundJoin = {
78
+ collectionSlug,
79
+ defaultLimit: sanitizedJoin.field.defaultLimit,
80
+ defaultSort: sanitizedJoin.field.defaultSort,
81
+ on: sanitizedJoin.field.on
82
+ };
83
+ break;
84
+ }
85
+ }
86
+ if (foundJoin) {
87
+ break;
88
+ }
89
+ }
90
+ // Also check polymorphic joins
91
+ if (!foundJoin) {
92
+ for (const sanitizedJoin of collectionConfig.polymorphicJoins){
93
+ if (sanitizedJoin.joinPath === joinPath) {
94
+ const collections = sanitizedJoin.field.collection;
95
+ foundJoin = {
96
+ collectionSlug: collections,
97
+ defaultSort: sanitizedJoin.field.defaultSort,
98
+ on: sanitizedJoin.field.on
99
+ };
100
+ break;
101
+ }
102
+ }
103
+ }
104
+ if (!foundJoin) {
105
+ payload.logger.warn(`Join path '${joinPath}' not found in collection config for '${collectionConfig.slug}'`);
106
+ continue;
107
+ }
108
+ // Fall back to the default limit if not specified in the query
109
+ const effectiveLimit = joinQuery.limit ?? foundJoin.defaultLimit;
110
+ // Add fallback sort for the joined collection
111
+ const sortWithFallback = addFallbackSort(joinQuery.sort, payload, foundJoin.collectionSlug, foundJoin.defaultSort);
112
+ const contentAPIJoin = {
113
+ collectionId: foundJoin.collectionSlug,
114
+ count: joinQuery.count ?? false,
115
+ on: foundJoin.on,
116
+ path: joinPath,
117
+ ...effectiveLimit !== undefined && {
118
+ limit: effectiveLimit
119
+ },
120
+ ...joinQuery.page && {
121
+ page: joinQuery.page
122
+ },
123
+ ...sortWithFallback && {
124
+ sort: sortWithFallback
125
+ },
126
+ ...joinQuery.where && {
127
+ where: convertPayloadWhereToContentAPI(joinQuery.where)
128
+ }
129
+ };
130
+ result.push(contentAPIJoin);
131
+ }
132
+ return result.length > 0 ? result : undefined;
133
+ }
134
+
135
+ //# sourceMappingURL=joins.js.map
@@ -0,0 +1,10 @@
1
+ import type { Payload } from 'payload';
2
+ /**
3
+ * Determines what locale to send to Content API based on request locale value
4
+ * and config's defaultLocale.
5
+ *
6
+ * If no locale is provided, falls back to the default locale from config.
7
+ * Returns undefined for 'all' and '*' (special Payload values for returning all locales).
8
+ */
9
+ export declare function addFallbackLocale(locale: null | string | undefined, payload: Payload): string | undefined;
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Determines what locale to send to Content API based on request locale value
3
+ * and config's defaultLocale.
4
+ *
5
+ * If no locale is provided, falls back to the default locale from config.
6
+ * Returns undefined for 'all' and '*' (special Payload values for returning all locales).
7
+ */ export function addFallbackLocale(locale, payload) {
8
+ const defaultLocale = payload.config.localization ? payload.config.localization.defaultLocale : undefined;
9
+ if (locale) {
10
+ // 'all' and '*' are special Payload values meaning "return all locales" - don't send to Content API
11
+ if (locale === 'all' || locale === '*') {
12
+ return undefined;
13
+ }
14
+ return locale;
15
+ } else if (defaultLocale) {
16
+ return defaultLocale;
17
+ }
18
+ return undefined;
19
+ }
20
+
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,11 @@
1
+ import type { Payload } from 'payload';
2
+ /**
3
+ * Extracts all localized field paths from a collection's field configuration.
4
+ * Recursively traverses nested structures (groups, arrays, blocks, tabs) to find fields marked as localized.
5
+ *
6
+ * @param payload - The Payload instance containing collection configurations
7
+ * @param collectionSlug - The slug of the collection to extract localized paths from
8
+ * @returns Array of dot-notation paths to localized fields (e.g., ['title', 'metadata.description'])
9
+ */
10
+ export declare function buildLocalizedPaths(payload: Payload, collectionSlug: string): string[];
11
+ //# sourceMappingURL=buildLocalizedPaths.d.ts.map
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Extracts all localized field paths from a collection's field configuration.
3
+ * Recursively traverses nested structures (groups, arrays, blocks, tabs) to find fields marked as localized.
4
+ *
5
+ * @param payload - The Payload instance containing collection configurations
6
+ * @param collectionSlug - The slug of the collection to extract localized paths from
7
+ * @returns Array of dot-notation paths to localized fields (e.g., ['title', 'metadata.description'])
8
+ */ export function buildLocalizedPaths(payload, collectionSlug) {
9
+ const collectionConfig = payload.config.collections.find((c)=>c.slug === collectionSlug);
10
+ if (!collectionConfig) {
11
+ return [];
12
+ }
13
+ const localizedPaths = [];
14
+ traverseFields(collectionConfig.fields, localizedPaths);
15
+ // Add _status to localized paths if localizeStatus is enabled for this collection
16
+ // _status is a base field added by Payload when versions.drafts is enabled,
17
+ // and it becomes localized when versions.drafts.localizeStatus is true
18
+ // localizeStatus requires both experimental flag AND collection-level config
19
+ const experimentalLocalizeStatus = 'experimental' in payload.config && payload.config.experimental && typeof payload.config.experimental === 'object' && 'localizeStatus' in payload.config.experimental && payload.config.experimental.localizeStatus === true;
20
+ const drafts = collectionConfig.versions && typeof collectionConfig.versions === 'object' ? collectionConfig.versions.drafts : false;
21
+ const collectionLocalizeStatus = drafts && typeof drafts === 'object' && 'localizeStatus' in drafts && drafts.localizeStatus === true;
22
+ const hasLocalizeStatus = payload.config.localization && experimentalLocalizeStatus && collectionLocalizeStatus;
23
+ if (hasLocalizeStatus && !localizedPaths.includes('_status')) {
24
+ localizedPaths.push('_status');
25
+ }
26
+ return localizedPaths;
27
+ }
28
+ /** Recursively traverses fields to find and collect localized paths */ function traverseFields(fields, localizedPaths, parentPath = '', parentIsLocalized = false) {
29
+ for (const field of fields){
30
+ // Unnamed layout fields (row, collapsible, unnamed group, unnamed tabs) don't store data
31
+ // at their own level, but their child fields may be localized. Recurse into them with
32
+ // the same parent path so localized fields bubble up correctly.
33
+ if (!('name' in field)) {
34
+ if ('fields' in field && Array.isArray(field.fields)) {
35
+ traverseFields(field.fields, localizedPaths, parentPath, parentIsLocalized);
36
+ }
37
+ if ('tabs' in field && Array.isArray(field.tabs)) {
38
+ for (const tab of field.tabs){
39
+ if (tab.fields) {
40
+ const tabPath = tab.name ? buildPath(parentPath, tab.name) : parentPath;
41
+ traverseFields(tab.fields, localizedPaths, tabPath, parentIsLocalized);
42
+ }
43
+ }
44
+ }
45
+ continue;
46
+ }
47
+ const fieldPath = buildPath(parentPath, field.name);
48
+ const isLocalized = 'localized' in field && field.localized === true;
49
+ const includeNestedPaths = isLocalized || parentIsLocalized;
50
+ // Add field to results if localized or parent is localized
51
+ if (includeNestedPaths) {
52
+ localizedPaths.push(fieldPath);
53
+ }
54
+ // Handle blocks field - has a special 'blocks' array structure and each block has its own nested fields
55
+ if (field.type === 'blocks' && 'blocks' in field) {
56
+ for (const block of field.blocks){
57
+ if ('fields' in block) {
58
+ traverseFields(block.fields, localizedPaths, fieldPath, includeNestedPaths);
59
+ }
60
+ }
61
+ continue;
62
+ }
63
+ // Handle field type that support nested fields
64
+ // Recursively handle nested structures (groups, arrays, tab, etc)
65
+ if ('fields' in field) {
66
+ traverseFields(field.fields, localizedPaths, fieldPath, includeNestedPaths);
67
+ }
68
+ }
69
+ }
70
+ /** Builds a dot-notation path from parent path and field name */ function buildPath(parentPath, fieldName) {
71
+ return parentPath ? `${parentPath}.${fieldName}` : fieldName;
72
+ }
73
+
74
+ //# sourceMappingURL=buildLocalizedPaths.js.map
@@ -0,0 +1,42 @@
1
+ import type { Payload, Where } from 'payload';
2
+ import type { components } from '../../generated/content-api-types.js';
3
+ import type { PathTypesRecord } from '../../temp-utilities/types.js';
4
+ /**
5
+ * Metadata sent to Content API for query processing.
6
+ *
7
+ * TODO: This interface is defined here temporarily so Content API can test the integration.
8
+ * Once Content API implements support for pathTypes with relationship info, this type
9
+ * should be generated from openapi.json and ContentAPIMeta can be removed.
10
+ */
11
+ export interface ContentAPIMeta {
12
+ localizedPaths?: string[];
13
+ pathTypes?: PathTypesRecord;
14
+ uniquePaths?: {
15
+ paths: string[];
16
+ }[];
17
+ }
18
+ /**
19
+ * The type that Content API currently expects (from generated types).
20
+ * This is more restrictive than ContentAPIMeta until Content API is updated.
21
+ */
22
+ type ContentAPIMetaGenerated = components['schemas']['RequestMeta'];
23
+ export interface BuildMetaOptions {
24
+ collection: string;
25
+ /** Document data — when provided, unique field constraints are included in meta. */
26
+ data?: Record<string, unknown>;
27
+ locale: string | undefined;
28
+ where?: Where;
29
+ }
30
+ /**
31
+ * Builds the `meta` object for Content API requests.
32
+ * Combines pathTypes (for array field handling) and localizedPaths (for locale queries).
33
+ *
34
+ * @param payload - The Payload instance
35
+ * @param options - Options including collection slug, locale, and where clause
36
+ * @returns Object with meta property ready to spread into request body, or empty object if no meta needed
37
+ */
38
+ export declare function buildMeta(payload: Payload, options: BuildMetaOptions): {
39
+ meta?: ContentAPIMetaGenerated;
40
+ };
41
+ export {};
42
+ //# sourceMappingURL=buildMeta.d.ts.map
@@ -0,0 +1,41 @@
1
+ import { buildLocalizedPaths } from './buildLocalizedPaths.js';
2
+ import { buildPathTypes } from './buildPathTypes.js';
3
+ import { buildUniquePaths } from './buildUniquePaths.js';
4
+ /**
5
+ * Builds the `meta` object for Content API requests.
6
+ * Combines pathTypes (for array field handling) and localizedPaths (for locale queries).
7
+ *
8
+ * @param payload - The Payload instance
9
+ * @param options - Options including collection slug, locale, and where clause
10
+ * @returns Object with meta property ready to spread into request body, or empty object if no meta needed
11
+ */ export function buildMeta(payload, options) {
12
+ const { collection, data, locale, where } = options;
13
+ const meta = {};
14
+ // Add pathTypes if there are array fields in the where clause
15
+ const pathTypes = buildPathTypes(payload, collection, where);
16
+ if (Object.keys(pathTypes).length > 0) {
17
+ meta.pathTypes = pathTypes;
18
+ }
19
+ // Add localizedPaths if locale is specified (but not 'all')
20
+ if (locale && locale !== 'all') {
21
+ const localizedPaths = buildLocalizedPaths(payload, collection);
22
+ if (localizedPaths.length > 0) {
23
+ meta.localizedPaths = localizedPaths;
24
+ }
25
+ }
26
+ // Add uniquePaths when data is provided (create/upsert operations)
27
+ if (data) {
28
+ const uniquePaths = buildUniquePaths(payload, collection, data);
29
+ if (uniquePaths.length > 0) {
30
+ meta.uniquePaths = uniquePaths;
31
+ }
32
+ }
33
+ // Cast to generated type - Content API will need to be updated to handle
34
+ // the new pathTypes format with relationship info. Until then, it will
35
+ // ignore the extra fields but still receive the data for testing.
36
+ return Object.keys(meta).length > 0 ? {
37
+ meta: meta
38
+ } : {};
39
+ }
40
+
41
+ //# sourceMappingURL=buildMeta.js.map
@@ -0,0 +1,17 @@
1
+ import type { Payload, Where } from 'payload';
2
+ import type { PathTypesRecord } from '../../temp-utilities/types.js';
3
+ /**
4
+ * Builds pathTypes metadata for Content API request.
5
+ * Returns a record of paths with their types for proper query generation.
6
+ *
7
+ * Includes:
8
+ * - Array fields (type: "array")
9
+ * - Relationship fields (type: { type: "relationship", collection, hasMany })
10
+ * - Join fields (type: { type: "join", collection, hasMany, on })
11
+ *
12
+ * Localized array/blocks fields (stored as locale maps) are handled specially:
13
+ * - The localized field itself is NOT marked as 'array' (it's a locale map object)
14
+ * - The locale-specific path (e.g. "localizedBlocks.en") IS marked as 'array'
15
+ */
16
+ export declare function buildPathTypes(payload: Payload, collectionSlug: string, where: undefined | Where): PathTypesRecord;
17
+ //# sourceMappingURL=buildPathTypes.d.ts.map
@@ -0,0 +1,244 @@
1
+ /**
2
+ * Extracts all field paths from a where clause recursively
3
+ */ function extractPathsFromWhere(where, paths = new Set()) {
4
+ if (!where || typeof where !== 'object') {
5
+ return paths;
6
+ }
7
+ // Handle 'and' operator
8
+ if ('and' in where && Array.isArray(where.and)) {
9
+ for (const clause of where.and){
10
+ extractPathsFromWhere(clause, paths);
11
+ }
12
+ return paths;
13
+ }
14
+ // Handle 'or' operator
15
+ if ('or' in where && Array.isArray(where.or)) {
16
+ for (const clause of where.or){
17
+ extractPathsFromWhere(clause, paths);
18
+ }
19
+ return paths;
20
+ }
21
+ // Handle regular conditions - keys are field paths
22
+ for(const key in where){
23
+ if (key === 'and' || key === 'or') {
24
+ continue;
25
+ }
26
+ // Add the path
27
+ paths.add(key.replace(/__/g, '.'));
28
+ // Check if the value is a nested where clause (for relationships)
29
+ const value = where[key];
30
+ if (value && typeof value === 'object' && !('equals' in value) && !('in' in value)) {
31
+ // Might be a nested where, recurse
32
+ extractPathsFromWhere(value, paths);
33
+ }
34
+ }
35
+ return paths;
36
+ }
37
+ /**
38
+ * Determines the type of a field based on its configuration.
39
+ * Returns PathTypeValue for fields that need special handling in Content API queries.
40
+ */ function getFieldType(field) {
41
+ // Array field
42
+ if (field.type === 'array') {
43
+ return 'array';
44
+ }
45
+ // Blocks field (array of objects)
46
+ if (field.type === 'blocks') {
47
+ return 'array';
48
+ }
49
+ // Relationship field - always include for JOIN support
50
+ if (field.type === 'relationship') {
51
+ const { hasMany = false, relationTo: collection } = field;
52
+ return {
53
+ type: 'relationship',
54
+ collection,
55
+ hasMany
56
+ };
57
+ }
58
+ // Upload field - treated like relationship
59
+ if (field.type === 'upload') {
60
+ const { hasMany = false, relationTo: collection } = field;
61
+ return {
62
+ type: 'relationship',
63
+ collection,
64
+ hasMany
65
+ };
66
+ }
67
+ // Join field - virtual reverse lookup
68
+ if (field.type === 'join') {
69
+ const { collection, on } = field;
70
+ return {
71
+ type: 'join',
72
+ collection,
73
+ hasMany: true,
74
+ on
75
+ };
76
+ }
77
+ // Text field with hasMany (array of strings)
78
+ if (field.type === 'text' && 'hasMany' in field && field.hasMany) {
79
+ return 'array';
80
+ }
81
+ // Number field with hasMany (array of numbers)
82
+ if (field.type === 'number' && 'hasMany' in field && field.hasMany) {
83
+ return 'array';
84
+ }
85
+ // Select field with hasMany (array)
86
+ if (field.type === 'select' && 'hasMany' in field && field.hasMany) {
87
+ return 'array';
88
+ }
89
+ // Objects (group, collapsible, row, tabs) don't need traversal
90
+ return null;
91
+ }
92
+ /**
93
+ * Finds a field in the collection schema by its path.
94
+ * Supports nested paths like "access.read.users".
95
+ * For localized array/blocks fields, locale key segments (e.g. "en") are skipped transparently,
96
+ * so "localizedBlocks.en.richText" resolves to the richText field inside localizedBlocks.
97
+ */ function findFieldByPath(payload, collectionSlug, path) {
98
+ const collectionConfig = payload.config.collections.find((c)=>c.slug === collectionSlug);
99
+ if (!collectionConfig) {
100
+ return undefined;
101
+ }
102
+ const localeCodes = payload.config.localization ? payload.config.localization.localeCodes : [];
103
+ const pathSegments = path.split('.');
104
+ // Walk through the path segments to find the field
105
+ let currentFields = collectionConfig.fields;
106
+ let currentField = undefined;
107
+ for(let i = 0; i < pathSegments.length; i++){
108
+ const segment = pathSegments[i];
109
+ // If this segment is a locale key for the previously found localized array/blocks field,
110
+ // skip it transparently (the locale key is the wrapping object key, not a real field).
111
+ if (localeCodes.includes(segment) && currentField && 'localized' in currentField && currentField.localized && (currentField.type === 'blocks' || currentField.type === 'array')) {
112
+ if (i === pathSegments.length - 1) {
113
+ // Last segment is a locale key → return the localized field (represents locale-specific array)
114
+ return currentField;
115
+ }
116
+ continue;
117
+ }
118
+ // First try to find a direct match
119
+ currentField = currentFields.find((f)=>'name' in f && f.name === segment);
120
+ // If not found, check if any unnamed container fields (collapsible, row) contain it
121
+ if (!currentField) {
122
+ for (const field of currentFields){
123
+ if (!('name' in field) || !field.name) {
124
+ // This is an unnamed field, check its contents
125
+ if ('fields' in field && field.type === 'collapsible' || 'fields' in field && field.type === 'row' || 'fields' in field && field.type === 'group') {
126
+ currentField = field.fields.find((f)=>'name' in f && f.name === segment);
127
+ if (currentField) {
128
+ break;
129
+ }
130
+ } else if ('tabs' in field && field.type === 'tabs') {
131
+ // Check all tabs
132
+ for (const tab of field.tabs){
133
+ // Named tab: the tab name itself is a path segment (acts like a group)
134
+ if ('name' in tab && tab.name === segment) {
135
+ currentField = {
136
+ name: tab.name,
137
+ type: 'group',
138
+ fields: tab.fields
139
+ };
140
+ break;
141
+ }
142
+ // Unnamed tab: search its fields for the segment
143
+ const found = tab.fields.find((f)=>'name' in f && f.name === segment);
144
+ if (found) {
145
+ currentField = found;
146
+ break;
147
+ }
148
+ }
149
+ if (currentField) {
150
+ break;
151
+ }
152
+ }
153
+ }
154
+ }
155
+ }
156
+ if (!currentField) {
157
+ return undefined;
158
+ }
159
+ // If we're not at the end, get nested fields
160
+ if (i < pathSegments.length - 1) {
161
+ if (currentField.type === 'group' && 'fields' in currentField) {
162
+ currentFields = currentField.fields;
163
+ } else if (currentField.type === 'array' && 'fields' in currentField) {
164
+ currentFields = currentField.fields;
165
+ } else if (currentField.type === 'blocks' && 'blocks' in currentField) {
166
+ // Collect all fields from all block definitions to continue traversal
167
+ const allBlockFields = [];
168
+ for (const block of currentField.blocks){
169
+ allBlockFields.push(...block.fields);
170
+ }
171
+ currentFields = allBlockFields;
172
+ } else if ((currentField.type === 'relationship' || currentField.type === 'upload') && typeof currentField.relationTo === 'string') {
173
+ // Traverse into the related collection's fields
174
+ const { relationTo } = currentField;
175
+ const relatedConfig = payload.config.collections.find((c)=>c.slug === relationTo);
176
+ if (relatedConfig) {
177
+ currentFields = relatedConfig.fields;
178
+ } else {
179
+ return undefined;
180
+ }
181
+ } else {
182
+ // Field doesn't have nested fields, can't continue
183
+ return undefined;
184
+ }
185
+ }
186
+ }
187
+ return currentField;
188
+ }
189
+ /**
190
+ * Builds pathTypes metadata for Content API request.
191
+ * Returns a record of paths with their types for proper query generation.
192
+ *
193
+ * Includes:
194
+ * - Array fields (type: "array")
195
+ * - Relationship fields (type: { type: "relationship", collection, hasMany })
196
+ * - Join fields (type: { type: "join", collection, hasMany, on })
197
+ *
198
+ * Localized array/blocks fields (stored as locale maps) are handled specially:
199
+ * - The localized field itself is NOT marked as 'array' (it's a locale map object)
200
+ * - The locale-specific path (e.g. "localizedBlocks.en") IS marked as 'array'
201
+ */ export function buildPathTypes(payload, collectionSlug, where) {
202
+ if (!where) {
203
+ return {};
204
+ }
205
+ const localeCodes = payload.config.localization ? payload.config.localization.localeCodes : [];
206
+ const pathTypes = {};
207
+ const paths = extractPathsFromWhere(where);
208
+ for (const path of paths){
209
+ // For each path, we need to check all segments to see if any intermediate ones are arrays/relationships
210
+ const segments = path.split('.');
211
+ for(let i = 0; i < segments.length; i++){
212
+ const partialPath = segments.slice(0, i + 1).join('.');
213
+ // Skip if we already have this path
214
+ if (partialPath in pathTypes) {
215
+ continue;
216
+ }
217
+ // If the current segment is a locale code and the parent field is a localized array/blocks,
218
+ // mark this locale-specific path as 'array' (the per-locale content is the actual array).
219
+ if (i > 0 && localeCodes.includes(segments[i])) {
220
+ const parentPath = segments.slice(0, i).join('.');
221
+ const parentField = findFieldByPath(payload, collectionSlug, parentPath);
222
+ if (parentField && 'localized' in parentField && parentField.localized && (parentField.type === 'blocks' || parentField.type === 'array')) {
223
+ pathTypes[partialPath] = 'array';
224
+ continue;
225
+ }
226
+ }
227
+ const field = findFieldByPath(payload, collectionSlug, partialPath);
228
+ if (field) {
229
+ // Localized array/blocks fields are stored as locale maps (not arrays).
230
+ // Skip them here — the locale-specific path (e.g. "localizedBlocks.en") is marked above.
231
+ if ('localized' in field && field.localized && (field.type === 'blocks' || field.type === 'array')) {
232
+ continue;
233
+ }
234
+ const fieldType = getFieldType(field);
235
+ if (fieldType !== null) {
236
+ pathTypes[partialPath] = fieldType;
237
+ }
238
+ }
239
+ }
240
+ }
241
+ return pathTypes;
242
+ }
243
+
244
+ //# sourceMappingURL=buildPathTypes.js.map