@payloadcms/db-postgres 3.0.0-canary.92e4997 → 3.0.0-canary.a78fca3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (258) hide show
  1. package/README.md +1 -1
  2. package/dist/connect.d.ts +1 -1
  3. package/dist/connect.d.ts.map +1 -1
  4. package/dist/connect.js +12 -7
  5. package/dist/connect.js.map +1 -1
  6. package/dist/count.d.ts +1 -1
  7. package/dist/count.d.ts.map +1 -1
  8. package/dist/count.js +1 -10
  9. package/dist/count.js.map +1 -1
  10. package/dist/create.d.ts +1 -1
  11. package/dist/create.d.ts.map +1 -1
  12. package/dist/create.js.map +1 -1
  13. package/dist/createGlobal.d.ts +1 -2
  14. package/dist/createGlobal.d.ts.map +1 -1
  15. package/dist/createGlobal.js.map +1 -1
  16. package/dist/createGlobalVersion.d.ts +2 -3
  17. package/dist/createGlobalVersion.d.ts.map +1 -1
  18. package/dist/createGlobalVersion.js +1 -1
  19. package/dist/createGlobalVersion.js.map +1 -1
  20. package/dist/createMigration.d.ts +1 -1
  21. package/dist/createMigration.d.ts.map +1 -1
  22. package/dist/createMigration.js +56 -35
  23. package/dist/createMigration.js.map +1 -1
  24. package/dist/createVersion.d.ts +1 -2
  25. package/dist/createVersion.d.ts.map +1 -1
  26. package/dist/createVersion.js +3 -7
  27. package/dist/createVersion.js.map +1 -1
  28. package/dist/deleteMany.d.ts +1 -1
  29. package/dist/deleteMany.d.ts.map +1 -1
  30. package/dist/deleteMany.js.map +1 -1
  31. package/dist/deleteOne.d.ts +1 -1
  32. package/dist/deleteOne.d.ts.map +1 -1
  33. package/dist/deleteOne.js +2 -2
  34. package/dist/deleteOne.js.map +1 -1
  35. package/dist/deleteVersions.d.ts +1 -1
  36. package/dist/deleteVersions.d.ts.map +1 -1
  37. package/dist/deleteVersions.js +1 -1
  38. package/dist/deleteVersions.js.map +1 -1
  39. package/dist/destroy.d.ts +1 -1
  40. package/dist/destroy.d.ts.map +1 -1
  41. package/dist/destroy.js +4 -0
  42. package/dist/destroy.js.map +1 -1
  43. package/dist/exports/migration-utils.d.ts +2 -0
  44. package/dist/exports/migration-utils.d.ts.map +1 -0
  45. package/dist/exports/migration-utils.js +3 -0
  46. package/dist/exports/migration-utils.js.map +1 -0
  47. package/dist/find/buildFindManyArgs.d.ts +6 -2
  48. package/dist/find/buildFindManyArgs.d.ts.map +1 -1
  49. package/dist/find/buildFindManyArgs.js +2 -1
  50. package/dist/find/buildFindManyArgs.js.map +1 -1
  51. package/dist/find/findMany.d.ts +1 -2
  52. package/dist/find/findMany.d.ts.map +1 -1
  53. package/dist/find/findMany.js +4 -15
  54. package/dist/find/findMany.js.map +1 -1
  55. package/dist/find/traverseFields.d.ts +4 -3
  56. package/dist/find/traverseFields.d.ts.map +1 -1
  57. package/dist/find/traverseFields.js +23 -5
  58. package/dist/find/traverseFields.js.map +1 -1
  59. package/dist/find.d.ts +1 -1
  60. package/dist/find.d.ts.map +1 -1
  61. package/dist/find.js.map +1 -1
  62. package/dist/findGlobal.d.ts +1 -1
  63. package/dist/findGlobal.d.ts.map +1 -1
  64. package/dist/findGlobal.js.map +1 -1
  65. package/dist/findGlobalVersions.d.ts +1 -1
  66. package/dist/findGlobalVersions.d.ts.map +1 -1
  67. package/dist/findGlobalVersions.js +1 -1
  68. package/dist/findGlobalVersions.js.map +1 -1
  69. package/dist/findOne.d.ts +1 -2
  70. package/dist/findOne.d.ts.map +1 -1
  71. package/dist/findOne.js.map +1 -1
  72. package/dist/findVersions.d.ts +1 -1
  73. package/dist/findVersions.d.ts.map +1 -1
  74. package/dist/findVersions.js +1 -1
  75. package/dist/findVersions.js.map +1 -1
  76. package/dist/index.d.ts +1 -1
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/index.js +10 -1
  79. package/dist/index.js.map +1 -1
  80. package/dist/init.d.ts +1 -1
  81. package/dist/init.d.ts.map +1 -1
  82. package/dist/init.js +15 -20
  83. package/dist/init.js.map +1 -1
  84. package/dist/migrate.d.ts.map +1 -1
  85. package/dist/migrate.js +1 -1
  86. package/dist/migrate.js.map +1 -1
  87. package/dist/migrateDown.js +1 -1
  88. package/dist/migrateDown.js.map +1 -1
  89. package/dist/migrateFresh.d.ts.map +1 -1
  90. package/dist/migrateFresh.js +1 -1
  91. package/dist/migrateFresh.js.map +1 -1
  92. package/dist/migrateRefresh.js +1 -1
  93. package/dist/migrateRefresh.js.map +1 -1
  94. package/dist/migrateReset.js +1 -1
  95. package/dist/migrateReset.js.map +1 -1
  96. package/dist/migrateStatus.js +1 -1
  97. package/dist/migrateStatus.js.map +1 -1
  98. package/dist/predefinedMigrations/relationships-v2-v3.d.ts +4 -0
  99. package/dist/predefinedMigrations/relationships-v2-v3.d.ts.map +1 -0
  100. package/dist/predefinedMigrations/relationships-v2-v3.js.map +1 -0
  101. package/dist/predefinedMigrations/relationships-v2-v3.mjs +11 -0
  102. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts +19 -0
  103. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts.map +1 -0
  104. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js +170 -0
  105. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js.map +1 -0
  106. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts +11 -0
  107. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts.map +1 -0
  108. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js +191 -0
  109. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js.map +1 -0
  110. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts +3 -0
  111. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts.map +1 -0
  112. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.js +56 -0
  113. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.js.map +1 -0
  114. package/dist/predefinedMigrations/v2-v3/index.d.ts +23 -0
  115. package/dist/predefinedMigrations/v2-v3/index.d.ts.map +1 -0
  116. package/dist/predefinedMigrations/v2-v3/index.js +211 -0
  117. package/dist/predefinedMigrations/v2-v3/index.js.map +1 -0
  118. package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts +19 -0
  119. package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts.map +1 -0
  120. package/dist/predefinedMigrations/v2-v3/migrateRelationships.js +57 -0
  121. package/dist/predefinedMigrations/v2-v3/migrateRelationships.js.map +1 -0
  122. package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts +22 -0
  123. package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts.map +1 -0
  124. package/dist/predefinedMigrations/v2-v3/traverseFields.js +85 -0
  125. package/dist/predefinedMigrations/v2-v3/traverseFields.js.map +1 -0
  126. package/dist/predefinedMigrations/v2-v3/types.d.ts +9 -0
  127. package/dist/predefinedMigrations/v2-v3/types.d.ts.map +1 -0
  128. package/dist/predefinedMigrations/v2-v3/types.js +6 -0
  129. package/dist/predefinedMigrations/v2-v3/types.js.map +1 -0
  130. package/dist/queries/buildAndOrConditions.d.ts +4 -5
  131. package/dist/queries/buildAndOrConditions.d.ts.map +1 -1
  132. package/dist/queries/buildAndOrConditions.js +1 -2
  133. package/dist/queries/buildAndOrConditions.js.map +1 -1
  134. package/dist/queries/buildQuery.d.ts +2 -3
  135. package/dist/queries/buildQuery.d.ts.map +1 -1
  136. package/dist/queries/buildQuery.js +1 -5
  137. package/dist/queries/buildQuery.js.map +1 -1
  138. package/dist/queries/getTableColumnFromPath.d.ts +4 -5
  139. package/dist/queries/getTableColumnFromPath.d.ts.map +1 -1
  140. package/dist/queries/getTableColumnFromPath.js +170 -99
  141. package/dist/queries/getTableColumnFromPath.js.map +1 -1
  142. package/dist/queries/parseParams.d.ts +4 -5
  143. package/dist/queries/parseParams.d.ts.map +1 -1
  144. package/dist/queries/parseParams.js +9 -8
  145. package/dist/queries/parseParams.js.map +1 -1
  146. package/dist/queries/sanitizeQueryValue.d.ts +1 -1
  147. package/dist/queries/sanitizeQueryValue.d.ts.map +1 -1
  148. package/dist/queries/sanitizeQueryValue.js +2 -3
  149. package/dist/queries/sanitizeQueryValue.js.map +1 -1
  150. package/dist/queries/selectDistinct.d.ts +3 -4
  151. package/dist/queries/selectDistinct.d.ts.map +1 -1
  152. package/dist/queries/selectDistinct.js +3 -14
  153. package/dist/queries/selectDistinct.js.map +1 -1
  154. package/dist/queryDrafts.d.ts +1 -1
  155. package/dist/queryDrafts.d.ts.map +1 -1
  156. package/dist/queryDrafts.js +1 -2
  157. package/dist/queryDrafts.js.map +1 -1
  158. package/dist/schema/build.d.ts +9 -5
  159. package/dist/schema/build.d.ts.map +1 -1
  160. package/dist/schema/build.js +161 -112
  161. package/dist/schema/build.js.map +1 -1
  162. package/dist/schema/createTableName.d.ts +1 -1
  163. package/dist/schema/createTableName.d.ts.map +1 -1
  164. package/dist/schema/createTableName.js +1 -1
  165. package/dist/schema/createTableName.js.map +1 -1
  166. package/dist/schema/idToUUID.d.ts +1 -1
  167. package/dist/schema/idToUUID.d.ts.map +1 -1
  168. package/dist/schema/idToUUID.js.map +1 -1
  169. package/dist/schema/setColumnID.d.ts +1 -1
  170. package/dist/schema/setColumnID.d.ts.map +1 -1
  171. package/dist/schema/setColumnID.js +2 -2
  172. package/dist/schema/setColumnID.js.map +1 -1
  173. package/dist/schema/traverseFields.d.ts +5 -7
  174. package/dist/schema/traverseFields.d.ts.map +1 -1
  175. package/dist/schema/traverseFields.js +105 -42
  176. package/dist/schema/traverseFields.js.map +1 -1
  177. package/dist/schema/validateExistingBlockIsIdentical.d.ts +1 -1
  178. package/dist/schema/validateExistingBlockIsIdentical.d.ts.map +1 -1
  179. package/dist/schema/validateExistingBlockIsIdentical.js +2 -2
  180. package/dist/schema/validateExistingBlockIsIdentical.js.map +1 -1
  181. package/dist/transactions/beginTransaction.d.ts +1 -1
  182. package/dist/transactions/beginTransaction.d.ts.map +1 -1
  183. package/dist/transactions/beginTransaction.js +4 -0
  184. package/dist/transactions/beginTransaction.js.map +1 -1
  185. package/dist/transactions/commitTransaction.d.ts +1 -1
  186. package/dist/transactions/commitTransaction.d.ts.map +1 -1
  187. package/dist/transactions/commitTransaction.js.map +1 -1
  188. package/dist/transactions/rollbackTransaction.d.ts +1 -1
  189. package/dist/transactions/rollbackTransaction.d.ts.map +1 -1
  190. package/dist/transactions/rollbackTransaction.js.map +1 -1
  191. package/dist/transform/read/hasManyNumber.d.ts +1 -1
  192. package/dist/transform/read/hasManyNumber.d.ts.map +1 -1
  193. package/dist/transform/read/hasManyNumber.js.map +1 -1
  194. package/dist/transform/read/hasManyText.d.ts +1 -1
  195. package/dist/transform/read/hasManyText.d.ts.map +1 -1
  196. package/dist/transform/read/hasManyText.js.map +1 -1
  197. package/dist/transform/read/index.d.ts +5 -3
  198. package/dist/transform/read/index.d.ts.map +1 -1
  199. package/dist/transform/read/index.js +2 -1
  200. package/dist/transform/read/index.js.map +1 -1
  201. package/dist/transform/read/relationship.d.ts +1 -1
  202. package/dist/transform/read/relationship.d.ts.map +1 -1
  203. package/dist/transform/read/relationship.js +0 -4
  204. package/dist/transform/read/relationship.js.map +1 -1
  205. package/dist/transform/read/traverseFields.d.ts +8 -3
  206. package/dist/transform/read/traverseFields.d.ts.map +1 -1
  207. package/dist/transform/read/traverseFields.js +70 -56
  208. package/dist/transform/read/traverseFields.js.map +1 -1
  209. package/dist/transform/write/array.d.ts +1 -1
  210. package/dist/transform/write/array.d.ts.map +1 -1
  211. package/dist/transform/write/array.js.map +1 -1
  212. package/dist/transform/write/blocks.d.ts +1 -1
  213. package/dist/transform/write/blocks.d.ts.map +1 -1
  214. package/dist/transform/write/blocks.js.map +1 -1
  215. package/dist/transform/write/index.d.ts +1 -1
  216. package/dist/transform/write/index.d.ts.map +1 -1
  217. package/dist/transform/write/index.js.map +1 -1
  218. package/dist/transform/write/relationships.d.ts +1 -1
  219. package/dist/transform/write/relationships.d.ts.map +1 -1
  220. package/dist/transform/write/relationships.js +1 -1
  221. package/dist/transform/write/relationships.js.map +1 -1
  222. package/dist/transform/write/traverseFields.d.ts +1 -1
  223. package/dist/transform/write/traverseFields.d.ts.map +1 -1
  224. package/dist/transform/write/traverseFields.js +21 -4
  225. package/dist/transform/write/traverseFields.js.map +1 -1
  226. package/dist/types.d.ts +4 -3
  227. package/dist/types.d.ts.map +1 -1
  228. package/dist/types.js.map +1 -1
  229. package/dist/update.d.ts +1 -1
  230. package/dist/update.d.ts.map +1 -1
  231. package/dist/update.js +1 -2
  232. package/dist/update.js.map +1 -1
  233. package/dist/updateGlobal.d.ts +1 -2
  234. package/dist/updateGlobal.d.ts.map +1 -1
  235. package/dist/updateGlobal.js.map +1 -1
  236. package/dist/updateGlobalVersion.d.ts +1 -2
  237. package/dist/updateGlobalVersion.d.ts.map +1 -1
  238. package/dist/updateGlobalVersion.js +1 -1
  239. package/dist/updateGlobalVersion.js.map +1 -1
  240. package/dist/updateVersion.d.ts +1 -2
  241. package/dist/updateVersion.d.ts.map +1 -1
  242. package/dist/updateVersion.js +1 -1
  243. package/dist/updateVersion.js.map +1 -1
  244. package/dist/upsertRow/index.d.ts +2 -2
  245. package/dist/upsertRow/index.d.ts.map +1 -1
  246. package/dist/upsertRow/index.js +4 -2
  247. package/dist/upsertRow/index.js.map +1 -1
  248. package/dist/upsertRow/types.d.ts +6 -1
  249. package/dist/upsertRow/types.d.ts.map +1 -1
  250. package/dist/upsertRow/types.js.map +1 -1
  251. package/dist/utilities/hasLocalesTable.d.ts +1 -1
  252. package/dist/utilities/hasLocalesTable.d.ts.map +1 -1
  253. package/dist/utilities/hasLocalesTable.js +1 -1
  254. package/dist/utilities/hasLocalesTable.js.map +1 -1
  255. package/dist/utilities/pushDevSchema.d.ts.map +1 -1
  256. package/dist/utilities/pushDevSchema.js +1 -1
  257. package/dist/utilities/pushDevSchema.js.map +1 -1
  258. package/package.json +16 -7
@@ -1,3 +1,3 @@
1
- import type { CommitTransaction } from 'payload/database';
1
+ import type { CommitTransaction } from 'payload';
2
2
  export declare const commitTransaction: CommitTransaction;
3
3
  //# sourceMappingURL=commitTransaction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"commitTransaction.d.ts","sourceRoot":"","sources":["../../src/transactions/commitTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAEzD,eAAO,MAAM,iBAAiB,EAAE,iBAa/B,CAAA"}
1
+ {"version":3,"file":"commitTransaction.d.ts","sourceRoot":"","sources":["../../src/transactions/commitTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEhD,eAAO,MAAM,iBAAiB,EAAE,iBAa/B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/transactions/commitTransaction.ts"],"sourcesContent":["import type { CommitTransaction } from 'payload/database'\n\nexport const commitTransaction: CommitTransaction = async function commitTransaction(id) {\n // if the session was deleted it has already been aborted\n if (!this.sessions[id]) {\n return\n }\n\n try {\n await this.sessions[id].resolve()\n } catch (err: unknown) {\n await this.sessions[id].reject()\n }\n\n delete this.sessions[id]\n}\n"],"names":["commitTransaction","id","sessions","resolve","err","reject"],"rangeMappings":";;;;;;;;;;;","mappings":"AAEA,OAAO,MAAMA,oBAAuC,eAAeA,kBAAkBC,EAAE;IACrF,yDAAyD;IACzD,IAAI,CAAC,IAAI,CAACC,QAAQ,CAACD,GAAG,EAAE;QACtB;IACF;IAEA,IAAI;QACF,MAAM,IAAI,CAACC,QAAQ,CAACD,GAAG,CAACE,OAAO;IACjC,EAAE,OAAOC,KAAc;QACrB,MAAM,IAAI,CAACF,QAAQ,CAACD,GAAG,CAACI,MAAM;IAChC;IAEA,OAAO,IAAI,CAACH,QAAQ,CAACD,GAAG;AAC1B,EAAC"}
1
+ {"version":3,"sources":["../../src/transactions/commitTransaction.ts"],"sourcesContent":["import type { CommitTransaction } from 'payload'\n\nexport const commitTransaction: CommitTransaction = async function commitTransaction(id) {\n // if the session was deleted it has already been aborted\n if (!this.sessions[id]) {\n return\n }\n\n try {\n await this.sessions[id].resolve()\n } catch (err: unknown) {\n await this.sessions[id].reject()\n }\n\n delete this.sessions[id]\n}\n"],"names":["commitTransaction","id","sessions","resolve","err","reject"],"rangeMappings":";;;;;;;;;;;","mappings":"AAEA,OAAO,MAAMA,oBAAuC,eAAeA,kBAAkBC,EAAE;IACrF,yDAAyD;IACzD,IAAI,CAAC,IAAI,CAACC,QAAQ,CAACD,GAAG,EAAE;QACtB;IACF;IAEA,IAAI;QACF,MAAM,IAAI,CAACC,QAAQ,CAACD,GAAG,CAACE,OAAO;IACjC,EAAE,OAAOC,KAAc;QACrB,MAAM,IAAI,CAACF,QAAQ,CAACD,GAAG,CAACI,MAAM;IAChC;IAEA,OAAO,IAAI,CAACH,QAAQ,CAACD,GAAG;AAC1B,EAAC"}
@@ -1,3 +1,3 @@
1
- import type { RollbackTransaction } from 'payload/database';
1
+ import type { RollbackTransaction } from 'payload';
2
2
  export declare const rollbackTransaction: RollbackTransaction;
3
3
  //# sourceMappingURL=rollbackTransaction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rollbackTransaction.d.ts","sourceRoot":"","sources":["../../src/transactions/rollbackTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAE3D,eAAO,MAAM,mBAAmB,EAAE,mBAcjC,CAAA"}
1
+ {"version":3,"file":"rollbackTransaction.d.ts","sourceRoot":"","sources":["../../src/transactions/rollbackTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAElD,eAAO,MAAM,mBAAmB,EAAE,mBAcjC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/transactions/rollbackTransaction.ts"],"sourcesContent":["import type { RollbackTransaction } from 'payload/database'\n\nexport const rollbackTransaction: RollbackTransaction = async function rollbackTransaction(\n id = '',\n) {\n // if multiple operations are using the same transaction, the first will flow through and delete the session.\n // subsequent calls should be ignored.\n if (!this.sessions[id]) {\n return\n }\n\n // end the session promise in failure by calling reject\n await this.sessions[id].reject()\n\n // delete the session causing any other operations with the same transaction to fail\n delete this.sessions[id]\n}\n"],"names":["rollbackTransaction","id","sessions","reject"],"rangeMappings":";;;;;;;;;;","mappings":"AAEA,OAAO,MAAMA,sBAA2C,eAAeA,oBACrEC,KAAK,EAAE;IAEP,6GAA6G;IAC7G,sCAAsC;IACtC,IAAI,CAAC,IAAI,CAACC,QAAQ,CAACD,GAAG,EAAE;QACtB;IACF;IAEA,uDAAuD;IACvD,MAAM,IAAI,CAACC,QAAQ,CAACD,GAAG,CAACE,MAAM;IAE9B,oFAAoF;IACpF,OAAO,IAAI,CAACD,QAAQ,CAACD,GAAG;AAC1B,EAAC"}
1
+ {"version":3,"sources":["../../src/transactions/rollbackTransaction.ts"],"sourcesContent":["import type { RollbackTransaction } from 'payload'\n\nexport const rollbackTransaction: RollbackTransaction = async function rollbackTransaction(\n id = '',\n) {\n // if multiple operations are using the same transaction, the first will flow through and delete the session.\n // subsequent calls should be ignored.\n if (!this.sessions[id]) {\n return\n }\n\n // end the session promise in failure by calling reject\n await this.sessions[id].reject()\n\n // delete the session causing any other operations with the same transaction to fail\n delete this.sessions[id]\n}\n"],"names":["rollbackTransaction","id","sessions","reject"],"rangeMappings":";;;;;;;;;;","mappings":"AAEA,OAAO,MAAMA,sBAA2C,eAAeA,oBACrEC,KAAK,EAAE;IAEP,6GAA6G;IAC7G,sCAAsC;IACtC,IAAI,CAAC,IAAI,CAACC,QAAQ,CAACD,GAAG,EAAE;QACtB;IACF;IAEA,uDAAuD;IACvD,MAAM,IAAI,CAACC,QAAQ,CAACD,GAAG,CAACE,MAAM;IAE9B,oFAAoF;IACpF,OAAO,IAAI,CAACD,QAAQ,CAACD,GAAG;AAC1B,EAAC"}
@@ -1,4 +1,4 @@
1
- import type { NumberField } from 'payload/types';
1
+ import type { NumberField } from 'payload';
2
2
  type Args = {
3
3
  field: NumberField;
4
4
  locale?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"hasManyNumber.d.ts","sourceRoot":"","sources":["../../../src/transform/read/hasManyNumber.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAEhD,KAAK,IAAI,GAAG;IACV,KAAK,EAAE,WAAW,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IACrC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC7B,CAAA;AAED,eAAO,MAAM,sBAAsB,uCAAwC,IAAI,SAQ9E,CAAA"}
1
+ {"version":3,"file":"hasManyNumber.d.ts","sourceRoot":"","sources":["../../../src/transform/read/hasManyNumber.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C,KAAK,IAAI,GAAG;IACV,KAAK,EAAE,WAAW,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IACrC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC7B,CAAA;AAED,eAAO,MAAM,sBAAsB,uCAAwC,IAAI,SAQ9E,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/transform/read/hasManyNumber.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { NumberField } from 'payload/types'\n\ntype Args = {\n field: NumberField\n locale?: string\n numberRows: Record<string, unknown>[]\n ref: Record<string, unknown>\n}\n\nexport const transformHasManyNumber = ({ field, locale, numberRows, ref }: Args) => {\n const result = numberRows.map(({ number }) => number)\n\n if (locale) {\n ref[field.name][locale] = result\n } else {\n ref[field.name] = result\n }\n}\n"],"names":["transformHasManyNumber","field","locale","numberRows","ref","result","map","number","name"],"rangeMappings":";;;;;;;","mappings":"AAAA,oCAAoC,GAUpC,OAAO,MAAMA,yBAAyB,CAAC,EAAEC,KAAK,EAAEC,MAAM,EAAEC,UAAU,EAAEC,GAAG,EAAQ;IAC7E,MAAMC,SAASF,WAAWG,GAAG,CAAC,CAAC,EAAEC,MAAM,EAAE,GAAKA;IAE9C,IAAIL,QAAQ;QACVE,GAAG,CAACH,MAAMO,IAAI,CAAC,CAACN,OAAO,GAAGG;IAC5B,OAAO;QACLD,GAAG,CAACH,MAAMO,IAAI,CAAC,GAAGH;IACpB;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/transform/read/hasManyNumber.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { NumberField } from 'payload'\n\ntype Args = {\n field: NumberField\n locale?: string\n numberRows: Record<string, unknown>[]\n ref: Record<string, unknown>\n}\n\nexport const transformHasManyNumber = ({ field, locale, numberRows, ref }: Args) => {\n const result = numberRows.map(({ number }) => number)\n\n if (locale) {\n ref[field.name][locale] = result\n } else {\n ref[field.name] = result\n }\n}\n"],"names":["transformHasManyNumber","field","locale","numberRows","ref","result","map","number","name"],"rangeMappings":";;;;;;;","mappings":"AAAA,oCAAoC,GAUpC,OAAO,MAAMA,yBAAyB,CAAC,EAAEC,KAAK,EAAEC,MAAM,EAAEC,UAAU,EAAEC,GAAG,EAAQ;IAC7E,MAAMC,SAASF,WAAWG,GAAG,CAAC,CAAC,EAAEC,MAAM,EAAE,GAAKA;IAE9C,IAAIL,QAAQ;QACVE,GAAG,CAACH,MAAMO,IAAI,CAAC,CAACN,OAAO,GAAGG;IAC5B,OAAO;QACLD,GAAG,CAACH,MAAMO,IAAI,CAAC,GAAGH;IACpB;AACF,EAAC"}
@@ -1,4 +1,4 @@
1
- import type { TextField } from 'payload/types';
1
+ import type { TextField } from 'payload';
2
2
  type Args = {
3
3
  field: TextField;
4
4
  locale?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"hasManyText.d.ts","sourceRoot":"","sources":["../../../src/transform/read/hasManyText.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C,KAAK,IAAI,GAAG;IACV,KAAK,EAAE,SAAS,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC5B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,oBAAoB,qCAAsC,IAAI,SAQ1E,CAAA"}
1
+ {"version":3,"file":"hasManyText.d.ts","sourceRoot":"","sources":["../../../src/transform/read/hasManyText.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAExC,KAAK,IAAI,GAAG;IACV,KAAK,EAAE,SAAS,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC5B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,oBAAoB,qCAAsC,IAAI,SAQ1E,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/transform/read/hasManyText.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { TextField } from 'payload/types'\n\ntype Args = {\n field: TextField\n locale?: string\n ref: Record<string, unknown>\n textRows: Record<string, unknown>[]\n}\n\nexport const transformHasManyText = ({ field, locale, ref, textRows }: Args) => {\n const result = textRows.map(({ text }) => text)\n\n if (locale) {\n ref[field.name][locale] = result\n } else {\n ref[field.name] = result\n }\n}\n"],"names":["transformHasManyText","field","locale","ref","textRows","result","map","text","name"],"rangeMappings":";;;;;;;","mappings":"AAAA,oCAAoC,GAUpC,OAAO,MAAMA,uBAAuB,CAAC,EAAEC,KAAK,EAAEC,MAAM,EAAEC,GAAG,EAAEC,QAAQ,EAAQ;IACzE,MAAMC,SAASD,SAASE,GAAG,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKA;IAE1C,IAAIL,QAAQ;QACVC,GAAG,CAACF,MAAMO,IAAI,CAAC,CAACN,OAAO,GAAGG;IAC5B,OAAO;QACLF,GAAG,CAACF,MAAMO,IAAI,CAAC,GAAGH;IACpB;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/transform/read/hasManyText.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { TextField } from 'payload'\n\ntype Args = {\n field: TextField\n locale?: string\n ref: Record<string, unknown>\n textRows: Record<string, unknown>[]\n}\n\nexport const transformHasManyText = ({ field, locale, ref, textRows }: Args) => {\n const result = textRows.map(({ text }) => text)\n\n if (locale) {\n ref[field.name][locale] = result\n } else {\n ref[field.name] = result\n }\n}\n"],"names":["transformHasManyText","field","locale","ref","textRows","result","map","text","name"],"rangeMappings":";;;;;;;","mappings":"AAAA,oCAAoC,GAUpC,OAAO,MAAMA,uBAAuB,CAAC,EAAEC,KAAK,EAAEC,MAAM,EAAEC,GAAG,EAAEC,QAAQ,EAAQ;IACzE,MAAMC,SAASD,SAASE,GAAG,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKA;IAE1C,IAAIL,QAAQ;QACVC,GAAG,CAACF,MAAMO,IAAI,CAAC,CAACN,OAAO,GAAGG;IAC5B,OAAO;QACLF,GAAG,CAACF,MAAMO,IAAI,CAAC,GAAGH;IACpB;AACF,EAAC"}
@@ -1,12 +1,14 @@
1
- import type { SanitizedConfig } from 'payload/config';
2
- import type { Field, TypeWithID } from 'payload/types';
1
+ import type { Field, TypeWithID } from 'payload';
2
+ import type { SanitizedConfig } from 'payload';
3
+ import type { PostgresAdapter } from '../../types.js';
3
4
  type TransformArgs = {
5
+ adapter: PostgresAdapter;
4
6
  config: SanitizedConfig;
5
7
  data: Record<string, unknown>;
6
8
  fallbackLocale?: false | string;
7
9
  fields: Field[];
8
10
  locale?: string;
9
11
  };
10
- export declare const transform: <T extends TypeWithID>({ config, data, fields }: TransformArgs) => T;
12
+ export declare const transform: <T extends TypeWithID>({ adapter, config, data, fields, }: TransformArgs) => T;
11
13
  export {};
12
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transform/read/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAMtD,KAAK,aAAa,GAAG;IACnB,MAAM,EAAE,eAAe,CAAA;IACvB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,cAAc,CAAC,EAAE,KAAK,GAAG,MAAM,CAAA;IAC/B,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAID,eAAO,MAAM,SAAS,mDAAoD,aAAa,KAAG,CA0CzF,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transform/read/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAMrD,KAAK,aAAa,GAAG;IACnB,OAAO,EAAE,eAAe,CAAA;IACxB,MAAM,EAAE,eAAe,CAAA;IACvB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,cAAc,CAAC,EAAE,KAAK,GAAG,MAAM,CAAA;IAC/B,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAID,eAAO,MAAM,SAAS,6DAKnB,aAAa,KAAG,CA2ClB,CAAA"}
@@ -3,7 +3,7 @@ import { createPathMap } from '../../utilities/createRelationshipMap.js';
3
3
  import { traverseFields } from './traverseFields.js';
4
4
  // This is the entry point to transform Drizzle output data
5
5
  // into the shape Payload expects based on field schema
6
- export const transform = ({ config, data, fields })=>{
6
+ export const transform = ({ adapter, config, data, fields })=>{
7
7
  let relationships = {};
8
8
  let texts = {};
9
9
  let numbers = {};
@@ -22,6 +22,7 @@ export const transform = ({ config, data, fields })=>{
22
22
  const blocks = createBlocksMap(data);
23
23
  const deletions = [];
24
24
  const result = traverseFields({
25
+ adapter,
25
26
  blocks,
26
27
  config,
27
28
  dataRef: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/transform/read/index.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { SanitizedConfig } from 'payload/config'\nimport type { Field, TypeWithID } from 'payload/types'\n\nimport { createBlocksMap } from '../../utilities/createBlocksMap.js'\nimport { createPathMap } from '../../utilities/createRelationshipMap.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype TransformArgs = {\n config: SanitizedConfig\n data: Record<string, unknown>\n fallbackLocale?: false | string\n fields: Field[]\n locale?: string\n}\n\n// This is the entry point to transform Drizzle output data\n// into the shape Payload expects based on field schema\nexport const transform = <T extends TypeWithID>({ config, data, fields }: TransformArgs): T => {\n let relationships: Record<string, Record<string, unknown>[]> = {}\n let texts: Record<string, Record<string, unknown>[]> = {}\n let numbers: Record<string, Record<string, unknown>[]> = {}\n\n if ('_rels' in data) {\n relationships = createPathMap(data._rels)\n delete data._rels\n }\n\n if ('_texts' in data) {\n texts = createPathMap(data._texts)\n delete data._texts\n }\n\n if ('_numbers' in data) {\n numbers = createPathMap(data._numbers)\n delete data._numbers\n }\n\n const blocks = createBlocksMap(data)\n const deletions = []\n\n const result = traverseFields<T>({\n blocks,\n config,\n dataRef: {\n id: data.id,\n },\n deletions,\n fieldPrefix: '',\n fields,\n numbers,\n path: '',\n relationships,\n table: data,\n texts,\n })\n\n deletions.forEach((deletion) => deletion())\n\n return result\n}\n"],"names":["createBlocksMap","createPathMap","traverseFields","transform","config","data","fields","relationships","texts","numbers","_rels","_texts","_numbers","blocks","deletions","result","dataRef","id","fieldPrefix","path","table","forEach","deletion"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,oCAAoC,GAIpC,SAASA,eAAe,QAAQ,qCAAoC;AACpE,SAASC,aAAa,QAAQ,2CAA0C;AACxE,SAASC,cAAc,QAAQ,sBAAqB;AAUpD,2DAA2D;AAC3D,uDAAuD;AACvD,OAAO,MAAMC,YAAY,CAAuB,EAAEC,MAAM,EAAEC,IAAI,EAAEC,MAAM,EAAiB;IACrF,IAAIC,gBAA2D,CAAC;IAChE,IAAIC,QAAmD,CAAC;IACxD,IAAIC,UAAqD,CAAC;IAE1D,IAAI,WAAWJ,MAAM;QACnBE,gBAAgBN,cAAcI,KAAKK,KAAK;QACxC,OAAOL,KAAKK,KAAK;IACnB;IAEA,IAAI,YAAYL,MAAM;QACpBG,QAAQP,cAAcI,KAAKM,MAAM;QACjC,OAAON,KAAKM,MAAM;IACpB;IAEA,IAAI,cAAcN,MAAM;QACtBI,UAAUR,cAAcI,KAAKO,QAAQ;QACrC,OAAOP,KAAKO,QAAQ;IACtB;IAEA,MAAMC,SAASb,gBAAgBK;IAC/B,MAAMS,YAAY,EAAE;IAEpB,MAAMC,SAASb,eAAkB;QAC/BW;QACAT;QACAY,SAAS;YACPC,IAAIZ,KAAKY,EAAE;QACb;QACAH;QACAI,aAAa;QACbZ;QACAG;QACAU,MAAM;QACNZ;QACAa,OAAOf;QACPG;IACF;IAEAM,UAAUO,OAAO,CAAC,CAACC,WAAaA;IAEhC,OAAOP;AACT,EAAC"}
1
+ {"version":3,"sources":["../../../src/transform/read/index.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { Field, TypeWithID } from 'payload'\nimport type { SanitizedConfig } from 'payload'\n\nimport type { PostgresAdapter } from '../../types.js'\n\nimport { createBlocksMap } from '../../utilities/createBlocksMap.js'\nimport { createPathMap } from '../../utilities/createRelationshipMap.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype TransformArgs = {\n adapter: PostgresAdapter\n config: SanitizedConfig\n data: Record<string, unknown>\n fallbackLocale?: false | string\n fields: Field[]\n locale?: string\n}\n\n// This is the entry point to transform Drizzle output data\n// into the shape Payload expects based on field schema\nexport const transform = <T extends TypeWithID>({\n adapter,\n config,\n data,\n fields,\n}: TransformArgs): T => {\n let relationships: Record<string, Record<string, unknown>[]> = {}\n let texts: Record<string, Record<string, unknown>[]> = {}\n let numbers: Record<string, Record<string, unknown>[]> = {}\n\n if ('_rels' in data) {\n relationships = createPathMap(data._rels)\n delete data._rels\n }\n\n if ('_texts' in data) {\n texts = createPathMap(data._texts)\n delete data._texts\n }\n\n if ('_numbers' in data) {\n numbers = createPathMap(data._numbers)\n delete data._numbers\n }\n\n const blocks = createBlocksMap(data)\n const deletions = []\n\n const result = traverseFields<T>({\n adapter,\n blocks,\n config,\n dataRef: {\n id: data.id,\n },\n deletions,\n fieldPrefix: '',\n fields,\n numbers,\n path: '',\n relationships,\n table: data,\n texts,\n })\n\n deletions.forEach((deletion) => deletion())\n\n return result\n}\n"],"names":["createBlocksMap","createPathMap","traverseFields","transform","adapter","config","data","fields","relationships","texts","numbers","_rels","_texts","_numbers","blocks","deletions","result","dataRef","id","fieldPrefix","path","table","forEach","deletion"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,oCAAoC,GAMpC,SAASA,eAAe,QAAQ,qCAAoC;AACpE,SAASC,aAAa,QAAQ,2CAA0C;AACxE,SAASC,cAAc,QAAQ,sBAAqB;AAWpD,2DAA2D;AAC3D,uDAAuD;AACvD,OAAO,MAAMC,YAAY,CAAuB,EAC9CC,OAAO,EACPC,MAAM,EACNC,IAAI,EACJC,MAAM,EACQ;IACd,IAAIC,gBAA2D,CAAC;IAChE,IAAIC,QAAmD,CAAC;IACxD,IAAIC,UAAqD,CAAC;IAE1D,IAAI,WAAWJ,MAAM;QACnBE,gBAAgBP,cAAcK,KAAKK,KAAK;QACxC,OAAOL,KAAKK,KAAK;IACnB;IAEA,IAAI,YAAYL,MAAM;QACpBG,QAAQR,cAAcK,KAAKM,MAAM;QACjC,OAAON,KAAKM,MAAM;IACpB;IAEA,IAAI,cAAcN,MAAM;QACtBI,UAAUT,cAAcK,KAAKO,QAAQ;QACrC,OAAOP,KAAKO,QAAQ;IACtB;IAEA,MAAMC,SAASd,gBAAgBM;IAC/B,MAAMS,YAAY,EAAE;IAEpB,MAAMC,SAASd,eAAkB;QAC/BE;QACAU;QACAT;QACAY,SAAS;YACPC,IAAIZ,KAAKY,EAAE;QACb;QACAH;QACAI,aAAa;QACbZ;QACAG;QACAU,MAAM;QACNZ;QACAa,OAAOf;QACPG;IACF;IAEAM,UAAUO,OAAO,CAAC,CAACC,WAAaA;IAEhC,OAAOP;AACT,EAAC"}
@@ -1,4 +1,4 @@
1
- import type { RelationshipField, UploadField } from 'payload/types';
1
+ import type { RelationshipField, UploadField } from 'payload';
2
2
  type Args = {
3
3
  field: RelationshipField | UploadField;
4
4
  locale?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"relationship.d.ts","sourceRoot":"","sources":["../../../src/transform/read/relationship.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAEnE,KAAK,IAAI,GAAG;IACV,KAAK,EAAE,iBAAiB,GAAG,WAAW,CAAA;IACtC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC5B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;CACrC,CAAA;AAED,eAAO,MAAM,qBAAqB,sCAAuC,IAAI,SAiE5E,CAAA"}
1
+ {"version":3,"file":"relationship.d.ts","sourceRoot":"","sources":["../../../src/transform/read/relationship.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE7D,KAAK,IAAI,GAAG;IACV,KAAK,EAAE,iBAAiB,GAAG,WAAW,CAAA;IACtC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC5B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;CACrC,CAAA;AAED,eAAO,MAAM,qBAAqB,sCAAuC,IAAI,SA6D5E,CAAA"}
@@ -19,10 +19,6 @@
19
19
  value: matchedRelation[1]
20
20
  };
21
21
  }
22
- } else {
23
- // Handle hasOne
24
- const relatedData = relation[`${field.relationTo}ID`];
25
- result = relatedData;
26
22
  }
27
23
  }
28
24
  } else {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/transform/read/relationship.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { RelationshipField, UploadField } from 'payload/types'\n\ntype Args = {\n field: RelationshipField | UploadField\n locale?: string\n ref: Record<string, unknown>\n relations: Record<string, unknown>[]\n}\n\nexport const transformRelationship = ({ field, locale, ref, relations }: Args) => {\n let result: unknown\n\n if (!('hasMany' in field) || field.hasMany === false) {\n const relation = relations[0]\n\n if (relation) {\n // Handle hasOne Poly\n if (Array.isArray(field.relationTo)) {\n const matchedRelation = Object.entries(relation).find(\n ([key, val]) =>\n val !== null && !['id', 'locale', 'order', 'parent', 'path'].includes(key),\n )\n\n if (matchedRelation) {\n const relationTo = matchedRelation[0].replace('ID', '')\n\n result = {\n relationTo,\n value: matchedRelation[1],\n }\n }\n } else {\n // Handle hasOne\n const relatedData = relation[`${field.relationTo}ID`]\n result = relatedData\n }\n }\n } else {\n const transformedRelations = []\n\n relations.forEach((relation) => {\n // Handle hasMany\n if (!Array.isArray(field.relationTo)) {\n const relatedData = relation[`${field.relationTo}ID`]\n\n if (relatedData) {\n transformedRelations.push(relatedData)\n }\n } else {\n // Handle hasMany Poly\n const matchedRelation = Object.entries(relation).find(\n ([key, val]) =>\n val !== null && !['id', 'locale', 'order', 'parent', 'path'].includes(key),\n )\n\n if (matchedRelation) {\n const relationTo = matchedRelation[0].replace('ID', '')\n\n transformedRelations.push({\n relationTo,\n value: matchedRelation[1],\n })\n }\n }\n })\n\n result = transformedRelations\n }\n\n if (locale) {\n ref[field.name][locale] = result\n } else {\n ref[field.name] = result\n }\n}\n"],"names":["transformRelationship","field","locale","ref","relations","result","hasMany","relation","Array","isArray","relationTo","matchedRelation","Object","entries","find","key","val","includes","replace","value","relatedData","transformedRelations","forEach","push","name"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,oCAAoC,GAUpC,OAAO,MAAMA,wBAAwB,CAAC,EAAEC,KAAK,EAAEC,MAAM,EAAEC,GAAG,EAAEC,SAAS,EAAQ;IAC3E,IAAIC;IAEJ,IAAI,CAAE,CAAA,aAAaJ,KAAI,KAAMA,MAAMK,OAAO,KAAK,OAAO;QACpD,MAAMC,WAAWH,SAAS,CAAC,EAAE;QAE7B,IAAIG,UAAU;YACZ,qBAAqB;YACrB,IAAIC,MAAMC,OAAO,CAACR,MAAMS,UAAU,GAAG;gBACnC,MAAMC,kBAAkBC,OAAOC,OAAO,CAACN,UAAUO,IAAI,CACnD,CAAC,CAACC,KAAKC,IAAI,GACTA,QAAQ,QAAQ,CAAC;wBAAC;wBAAM;wBAAU;wBAAS;wBAAU;qBAAO,CAACC,QAAQ,CAACF;gBAG1E,IAAIJ,iBAAiB;oBACnB,MAAMD,aAAaC,eAAe,CAAC,EAAE,CAACO,OAAO,CAAC,MAAM;oBAEpDb,SAAS;wBACPK;wBACAS,OAAOR,eAAe,CAAC,EAAE;oBAC3B;gBACF;YACF,OAAO;gBACL,gBAAgB;gBAChB,MAAMS,cAAcb,QAAQ,CAAC,CAAC,EAAEN,MAAMS,UAAU,CAAC,EAAE,CAAC,CAAC;gBACrDL,SAASe;YACX;QACF;IACF,OAAO;QACL,MAAMC,uBAAuB,EAAE;QAE/BjB,UAAUkB,OAAO,CAAC,CAACf;YACjB,iBAAiB;YACjB,IAAI,CAACC,MAAMC,OAAO,CAACR,MAAMS,UAAU,GAAG;gBACpC,MAAMU,cAAcb,QAAQ,CAAC,CAAC,EAAEN,MAAMS,UAAU,CAAC,EAAE,CAAC,CAAC;gBAErD,IAAIU,aAAa;oBACfC,qBAAqBE,IAAI,CAACH;gBAC5B;YACF,OAAO;gBACL,sBAAsB;gBACtB,MAAMT,kBAAkBC,OAAOC,OAAO,CAACN,UAAUO,IAAI,CACnD,CAAC,CAACC,KAAKC,IAAI,GACTA,QAAQ,QAAQ,CAAC;wBAAC;wBAAM;wBAAU;wBAAS;wBAAU;qBAAO,CAACC,QAAQ,CAACF;gBAG1E,IAAIJ,iBAAiB;oBACnB,MAAMD,aAAaC,eAAe,CAAC,EAAE,CAACO,OAAO,CAAC,MAAM;oBAEpDG,qBAAqBE,IAAI,CAAC;wBACxBb;wBACAS,OAAOR,eAAe,CAAC,EAAE;oBAC3B;gBACF;YACF;QACF;QAEAN,SAASgB;IACX;IAEA,IAAInB,QAAQ;QACVC,GAAG,CAACF,MAAMuB,IAAI,CAAC,CAACtB,OAAO,GAAGG;IAC5B,OAAO;QACLF,GAAG,CAACF,MAAMuB,IAAI,CAAC,GAAGnB;IACpB;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/transform/read/relationship.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { RelationshipField, UploadField } from 'payload'\n\ntype Args = {\n field: RelationshipField | UploadField\n locale?: string\n ref: Record<string, unknown>\n relations: Record<string, unknown>[]\n}\n\nexport const transformRelationship = ({ field, locale, ref, relations }: Args) => {\n let result: unknown\n\n if (!('hasMany' in field) || field.hasMany === false) {\n const relation = relations[0]\n\n if (relation) {\n // Handle hasOne Poly\n if (Array.isArray(field.relationTo)) {\n const matchedRelation = Object.entries(relation).find(\n ([key, val]) =>\n val !== null && !['id', 'locale', 'order', 'parent', 'path'].includes(key),\n )\n\n if (matchedRelation) {\n const relationTo = matchedRelation[0].replace('ID', '')\n\n result = {\n relationTo,\n value: matchedRelation[1],\n }\n }\n }\n }\n } else {\n const transformedRelations = []\n\n relations.forEach((relation) => {\n // Handle hasMany\n if (!Array.isArray(field.relationTo)) {\n const relatedData = relation[`${field.relationTo}ID`]\n\n if (relatedData) {\n transformedRelations.push(relatedData)\n }\n } else {\n // Handle hasMany Poly\n const matchedRelation = Object.entries(relation).find(\n ([key, val]) =>\n val !== null && !['id', 'locale', 'order', 'parent', 'path'].includes(key),\n )\n\n if (matchedRelation) {\n const relationTo = matchedRelation[0].replace('ID', '')\n\n transformedRelations.push({\n relationTo,\n value: matchedRelation[1],\n })\n }\n }\n })\n\n result = transformedRelations\n }\n\n if (locale) {\n ref[field.name][locale] = result\n } else {\n ref[field.name] = result\n }\n}\n"],"names":["transformRelationship","field","locale","ref","relations","result","hasMany","relation","Array","isArray","relationTo","matchedRelation","Object","entries","find","key","val","includes","replace","value","transformedRelations","forEach","relatedData","push","name"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,oCAAoC,GAUpC,OAAO,MAAMA,wBAAwB,CAAC,EAAEC,KAAK,EAAEC,MAAM,EAAEC,GAAG,EAAEC,SAAS,EAAQ;IAC3E,IAAIC;IAEJ,IAAI,CAAE,CAAA,aAAaJ,KAAI,KAAMA,MAAMK,OAAO,KAAK,OAAO;QACpD,MAAMC,WAAWH,SAAS,CAAC,EAAE;QAE7B,IAAIG,UAAU;YACZ,qBAAqB;YACrB,IAAIC,MAAMC,OAAO,CAACR,MAAMS,UAAU,GAAG;gBACnC,MAAMC,kBAAkBC,OAAOC,OAAO,CAACN,UAAUO,IAAI,CACnD,CAAC,CAACC,KAAKC,IAAI,GACTA,QAAQ,QAAQ,CAAC;wBAAC;wBAAM;wBAAU;wBAAS;wBAAU;qBAAO,CAACC,QAAQ,CAACF;gBAG1E,IAAIJ,iBAAiB;oBACnB,MAAMD,aAAaC,eAAe,CAAC,EAAE,CAACO,OAAO,CAAC,MAAM;oBAEpDb,SAAS;wBACPK;wBACAS,OAAOR,eAAe,CAAC,EAAE;oBAC3B;gBACF;YACF;QACF;IACF,OAAO;QACL,MAAMS,uBAAuB,EAAE;QAE/BhB,UAAUiB,OAAO,CAAC,CAACd;YACjB,iBAAiB;YACjB,IAAI,CAACC,MAAMC,OAAO,CAACR,MAAMS,UAAU,GAAG;gBACpC,MAAMY,cAAcf,QAAQ,CAAC,CAAC,EAAEN,MAAMS,UAAU,CAAC,EAAE,CAAC,CAAC;gBAErD,IAAIY,aAAa;oBACfF,qBAAqBG,IAAI,CAACD;gBAC5B;YACF,OAAO;gBACL,sBAAsB;gBACtB,MAAMX,kBAAkBC,OAAOC,OAAO,CAACN,UAAUO,IAAI,CACnD,CAAC,CAACC,KAAKC,IAAI,GACTA,QAAQ,QAAQ,CAAC;wBAAC;wBAAM;wBAAU;wBAAS;wBAAU;qBAAO,CAACC,QAAQ,CAACF;gBAG1E,IAAIJ,iBAAiB;oBACnB,MAAMD,aAAaC,eAAe,CAAC,EAAE,CAACO,OAAO,CAAC,MAAM;oBAEpDE,qBAAqBG,IAAI,CAAC;wBACxBb;wBACAS,OAAOR,eAAe,CAAC,EAAE;oBAC3B;gBACF;YACF;QACF;QAEAN,SAASe;IACX;IAEA,IAAIlB,QAAQ;QACVC,GAAG,CAACF,MAAMuB,IAAI,CAAC,CAACtB,OAAO,GAAGG;IAC5B,OAAO;QACLF,GAAG,CAACF,MAAMuB,IAAI,CAAC,GAAGnB;IACpB;AACF,EAAC"}
@@ -1,7 +1,12 @@
1
- import type { SanitizedConfig } from 'payload/config';
2
- import type { Field, TabAsField } from 'payload/types';
1
+ import type { Field, TabAsField } from 'payload';
2
+ import type { SanitizedConfig } from 'payload';
3
+ import type { PostgresAdapter } from '../../types.js';
3
4
  import type { BlocksMap } from '../../utilities/createBlocksMap.js';
4
5
  type TraverseFieldsArgs = {
6
+ /**
7
+ * The DB adapter
8
+ */
9
+ adapter: PostgresAdapter;
5
10
  /**
6
11
  * Pre-formatted blocks map
7
12
  */
@@ -47,6 +52,6 @@ type TraverseFieldsArgs = {
47
52
  */
48
53
  texts: Record<string, Record<string, unknown>[]>;
49
54
  };
50
- export declare const traverseFields: <T extends Record<string, unknown>>({ blocks, config, dataRef, deletions, fieldPrefix, fields, numbers, path, relationships, table, texts, }: TraverseFieldsArgs) => T;
55
+ export declare const traverseFields: <T extends Record<string, unknown>>({ adapter, blocks, config, dataRef, deletions, fieldPrefix, fields, numbers, path, relationships, table, texts, }: TraverseFieldsArgs) => T;
51
56
  export {};
52
57
  //# sourceMappingURL=traverseFields.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../src/transform/read/traverseFields.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAItD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAA;AAMnE,KAAK,kBAAkB,GAAG;IACxB;;OAEG;IACH,MAAM,EAAE,SAAS,CAAA;IACjB;;OAEG;IACH,MAAM,EAAE,eAAe,CAAA;IACvB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAChC;;OAEG;IACH,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,CAAA;IACzB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,MAAM,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,EAAE,CAAA;IAC9B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAA;IAClD;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAA;IACxD;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAA;CACjD,CAAA;AAID,eAAO,MAAM,cAAc,gJAYxB,kBAAkB,KAAG,CAsdvB,CAAA"}
1
+ {"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../src/transform/read/traverseFields.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAA;AAMnE,KAAK,kBAAkB,GAAG;IACxB;;OAEG;IACH,OAAO,EAAE,eAAe,CAAA;IACxB;;OAEG;IACH,MAAM,EAAE,SAAS,CAAA;IACjB;;OAEG;IACH,MAAM,EAAE,eAAe,CAAA;IACvB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAChC;;OAEG;IACH,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,CAAA;IACzB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,MAAM,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,EAAE,CAAA;IAC9B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAA;IAClD;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAA;IACxD;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAA;CACjD,CAAA;AAID,eAAO,MAAM,cAAc,yJAaxB,kBAAkB,KAAG,CAkevB,CAAA"}
@@ -1,14 +1,15 @@
1
- /* eslint-disable no-param-reassign */ import { fieldAffectsData } from 'payload/types';
1
+ /* eslint-disable no-param-reassign */ import { fieldAffectsData } from 'payload/shared';
2
2
  import { transformHasManyNumber } from './hasManyNumber.js';
3
3
  import { transformHasManyText } from './hasManyText.js';
4
4
  import { transformRelationship } from './relationship.js';
5
5
  // Traverse fields recursively, transforming data
6
6
  // for each field type into required Payload shape
7
- export const traverseFields = ({ blocks, config, dataRef, deletions, fieldPrefix, fields, numbers, path, relationships, table, texts })=>{
7
+ export const traverseFields = ({ adapter, blocks, config, dataRef, deletions, fieldPrefix, fields, numbers, path, relationships, table, texts })=>{
8
8
  const sanitizedPath = path ? `${path}.` : path;
9
9
  const formatted = fields.reduce((result, field)=>{
10
10
  if (field.type === 'tabs') {
11
11
  traverseFields({
12
+ adapter,
12
13
  blocks,
13
14
  config,
14
15
  dataRef,
@@ -27,6 +28,7 @@ export const traverseFields = ({ blocks, config, dataRef, deletions, fieldPrefix
27
28
  }
28
29
  if (field.type === 'collapsible' || field.type === 'row' || field.type === 'tab' && !('name' in field)) {
29
30
  traverseFields({
31
+ adapter,
30
32
  blocks,
31
33
  config,
32
34
  dataRef,
@@ -43,6 +45,8 @@ export const traverseFields = ({ blocks, config, dataRef, deletions, fieldPrefix
43
45
  if (fieldAffectsData(field)) {
44
46
  const fieldName = `${fieldPrefix || ''}${field.name}`;
45
47
  const fieldData = table[fieldName];
48
+ const localizedFieldData = {};
49
+ const valuesToTransform = [];
46
50
  if (fieldPrefix) {
47
51
  deletions.push(()=>delete table[fieldName]);
48
52
  }
@@ -60,6 +64,7 @@ export const traverseFields = ({ blocks, config, dataRef, deletions, fieldPrefix
60
64
  delete row._uuid;
61
65
  }
62
66
  const rowResult = traverseFields({
67
+ adapter,
63
68
  blocks,
64
69
  config,
65
70
  dataRef: data,
@@ -89,6 +94,7 @@ export const traverseFields = ({ blocks, config, dataRef, deletions, fieldPrefix
89
94
  delete row._order;
90
95
  }
91
96
  return traverseFields({
97
+ adapter,
92
98
  blocks,
93
99
  config,
94
100
  dataRef: row,
@@ -127,6 +133,7 @@ export const traverseFields = ({ blocks, config, dataRef, deletions, fieldPrefix
127
133
  const block = field.blocks.find(({ slug })=>slug === row.blockType);
128
134
  if (block) {
129
135
  const blockResult = traverseFields({
136
+ adapter,
130
137
  blocks,
131
138
  config,
132
139
  dataRef: row,
@@ -155,6 +162,7 @@ export const traverseFields = ({ blocks, config, dataRef, deletions, fieldPrefix
155
162
  const block = field.blocks.find(({ slug })=>slug === row.blockType);
156
163
  if (block) {
157
164
  return traverseFields({
165
+ adapter,
158
166
  blocks,
159
167
  config,
160
168
  dataRef: row,
@@ -175,44 +183,59 @@ export const traverseFields = ({ blocks, config, dataRef, deletions, fieldPrefix
175
183
  return result;
176
184
  }
177
185
  if (field.type === 'relationship' || field.type === 'upload') {
178
- const relationPathMatch = relationships[`${sanitizedPath}${field.name}`];
179
- if (!relationPathMatch) {
180
- if ('hasMany' in field && field.hasMany) {
181
- if (field.localized && config.localization && config.localization.locales) {
186
+ if (typeof field.relationTo === 'string' && !('hasMany' in field && field.hasMany)) {
187
+ if (field.localized && config.localization && config.localization.locales && Array.isArray(table?._locales)) {
188
+ table._locales.forEach((localeRow)=>{
182
189
  result[field.name] = {
183
- [config.localization.defaultLocale]: []
190
+ [localeRow._locale]: localeRow[fieldName]
184
191
  };
185
- } else {
186
- result[field.name] = [];
187
- }
192
+ });
193
+ } else {
194
+ valuesToTransform.push({
195
+ ref: result,
196
+ table
197
+ });
188
198
  }
189
- return result;
190
- }
191
- if (field.localized) {
192
- result[field.name] = {};
193
- const relationsByLocale = {};
194
- relationPathMatch.forEach((row)=>{
195
- if (typeof row.locale === 'string') {
196
- if (!relationsByLocale[row.locale]) relationsByLocale[row.locale] = [];
197
- relationsByLocale[row.locale].push(row);
199
+ } else {
200
+ const relationPathMatch = relationships[`${sanitizedPath}${field.name}`];
201
+ if (!relationPathMatch) {
202
+ if ('hasMany' in field && field.hasMany) {
203
+ if (field.localized && config.localization && config.localization.locales) {
204
+ result[field.name] = {
205
+ [config.localization.defaultLocale]: []
206
+ };
207
+ } else {
208
+ result[field.name] = [];
209
+ }
198
210
  }
199
- });
200
- Object.entries(relationsByLocale).forEach(([locale, relations])=>{
211
+ return result;
212
+ }
213
+ if (field.localized) {
214
+ result[field.name] = {};
215
+ const relationsByLocale = {};
216
+ relationPathMatch.forEach((row)=>{
217
+ if (typeof row.locale === 'string') {
218
+ if (!relationsByLocale[row.locale]) relationsByLocale[row.locale] = [];
219
+ relationsByLocale[row.locale].push(row);
220
+ }
221
+ });
222
+ Object.entries(relationsByLocale).forEach(([locale, relations])=>{
223
+ transformRelationship({
224
+ field,
225
+ locale,
226
+ ref: result,
227
+ relations
228
+ });
229
+ });
230
+ } else {
201
231
  transformRelationship({
202
232
  field,
203
- locale,
204
233
  ref: result,
205
- relations
234
+ relations: relationPathMatch
206
235
  });
207
- });
208
- } else {
209
- transformRelationship({
210
- field,
211
- ref: result,
212
- relations: relationPathMatch
213
- });
236
+ }
237
+ return result;
214
238
  }
215
- return result;
216
239
  }
217
240
  if (field.type === 'text' && field?.hasMany) {
218
241
  const textPathMatch = texts[`${sanitizedPath}${field.name}`];
@@ -288,8 +311,6 @@ export const traverseFields = ({ blocks, config, dataRef, deletions, fieldPrefix
288
311
  }
289
312
  return result;
290
313
  }
291
- const localizedFieldData = {};
292
- const valuesToTransform = [];
293
314
  if (field.localized && Array.isArray(table._locales)) {
294
315
  table._locales.forEach((localeRow)=>{
295
316
  valuesToTransform.push({
@@ -306,6 +327,7 @@ export const traverseFields = ({ blocks, config, dataRef, deletions, fieldPrefix
306
327
  valuesToTransform.forEach(({ ref, table })=>{
307
328
  const fieldData = table[`${fieldPrefix || ''}${field.name}`];
308
329
  const locale = table?._locale;
330
+ let val = fieldData;
309
331
  switch(field.type){
310
332
  case 'tab':
311
333
  case 'group':
@@ -318,6 +340,7 @@ export const traverseFields = ({ blocks, config, dataRef, deletions, fieldPrefix
318
340
  }
319
341
  Object.entries(ref).forEach(([groupLocale, groupLocaleData])=>{
320
342
  ref[groupLocale] = traverseFields({
343
+ adapter,
321
344
  blocks,
322
345
  config,
323
346
  dataRef: groupLocaleData,
@@ -337,6 +360,7 @@ export const traverseFields = ({ blocks, config, dataRef, deletions, fieldPrefix
337
360
  } else {
338
361
  const groupData = {};
339
362
  ref[field.name] = traverseFields({
363
+ adapter,
340
364
  blocks,
341
365
  config,
342
366
  dataRef: groupData,
@@ -353,57 +377,47 @@ export const traverseFields = ({ blocks, config, dataRef, deletions, fieldPrefix
353
377
  delete ref._order;
354
378
  }
355
379
  }
356
- break;
380
+ return;
357
381
  }
358
382
  case 'text':
359
383
  {
360
- let val = fieldData;
361
384
  if (typeof fieldData === 'string') {
362
385
  val = String(fieldData);
363
386
  }
364
- if (typeof locale === 'string') {
365
- ref[locale] = val;
366
- } else {
367
- result[field.name] = val;
368
- }
369
387
  break;
370
388
  }
371
389
  case 'number':
372
390
  {
373
- let val = fieldData;
374
391
  if (typeof fieldData === 'string') {
375
392
  val = Number.parseFloat(fieldData);
376
393
  }
377
- if (typeof locale === 'string') {
378
- ref[locale] = val;
379
- } else {
380
- result[field.name] = val;
381
- }
382
394
  break;
383
395
  }
384
396
  case 'date':
385
397
  {
386
- let val = fieldData;
387
398
  if (typeof fieldData === 'string') {
388
399
  val = new Date(fieldData).toISOString();
389
400
  }
390
- if (typeof locale === 'string') {
391
- ref[locale] = val;
392
- } else {
393
- result[field.name] = val;
401
+ break;
402
+ }
403
+ case 'relationship':
404
+ case 'upload':
405
+ {
406
+ if (val && typeof field.relationTo === 'string' && adapter.payload.collections[field.relationTo].customIDType === 'number') {
407
+ val = Number(val);
394
408
  }
395
409
  break;
396
410
  }
397
411
  default:
398
412
  {
399
- if (typeof locale === 'string') {
400
- ref[locale] = fieldData;
401
- } else {
402
- result[field.name] = fieldData;
403
- }
404
413
  break;
405
414
  }
406
415
  }
416
+ if (typeof locale === 'string') {
417
+ ref[locale] = val;
418
+ } else {
419
+ result[field.name] = val;
420
+ }
407
421
  });
408
422
  if (Object.keys(localizedFieldData).length > 0) {
409
423
  result[field.name] = localizedFieldData;