@payloadcms/db-postgres 3.0.0-beta.6 → 3.0.0-beta.61

Sign up to get free protection for your applications and to get access to all the features.
Files changed (303) 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 +3 -0
  7. package/dist/count.d.ts.map +1 -0
  8. package/dist/count.js +41 -0
  9. package/dist/count.js.map +1 -0
  10. package/dist/create.d.ts +1 -1
  11. package/dist/create.d.ts.map +1 -1
  12. package/dist/create.js +4 -6
  13. package/dist/create.js.map +1 -1
  14. package/dist/createGlobal.d.ts +2 -3
  15. package/dist/createGlobal.d.ts.map +1 -1
  16. package/dist/createGlobal.js +4 -6
  17. package/dist/createGlobal.js.map +1 -1
  18. package/dist/createGlobalVersion.d.ts +1 -3
  19. package/dist/createGlobalVersion.d.ts.map +1 -1
  20. package/dist/createGlobalVersion.js +4 -8
  21. package/dist/createGlobalVersion.js.map +1 -1
  22. package/dist/createMigration.d.ts +1 -1
  23. package/dist/createMigration.d.ts.map +1 -1
  24. package/dist/createMigration.js +56 -35
  25. package/dist/createMigration.js.map +1 -1
  26. package/dist/createVersion.d.ts +1 -2
  27. package/dist/createVersion.d.ts.map +1 -1
  28. package/dist/createVersion.js +12 -20
  29. package/dist/createVersion.js.map +1 -1
  30. package/dist/deleteMany.d.ts +1 -1
  31. package/dist/deleteMany.d.ts.map +1 -1
  32. package/dist/deleteMany.js +3 -6
  33. package/dist/deleteMany.js.map +1 -1
  34. package/dist/deleteOne.d.ts +1 -1
  35. package/dist/deleteOne.d.ts.map +1 -1
  36. package/dist/deleteOne.js +5 -8
  37. package/dist/deleteOne.js.map +1 -1
  38. package/dist/deleteVersions.d.ts +1 -1
  39. package/dist/deleteVersions.d.ts.map +1 -1
  40. package/dist/deleteVersions.js +4 -8
  41. package/dist/deleteVersions.js.map +1 -1
  42. package/dist/destroy.d.ts +1 -1
  43. package/dist/destroy.d.ts.map +1 -1
  44. package/dist/destroy.js +11 -7
  45. package/dist/destroy.js.map +1 -1
  46. package/dist/exports/migration-utils.d.ts +2 -0
  47. package/dist/exports/migration-utils.d.ts.map +1 -0
  48. package/dist/exports/migration-utils.js +3 -0
  49. package/dist/exports/migration-utils.js.map +1 -0
  50. package/dist/find/buildFindManyArgs.d.ts +6 -2
  51. package/dist/find/buildFindManyArgs.d.ts.map +1 -1
  52. package/dist/find/buildFindManyArgs.js +4 -3
  53. package/dist/find/buildFindManyArgs.js.map +1 -1
  54. package/dist/find/chainMethods.d.ts.map +1 -1
  55. package/dist/find/chainMethods.js.map +1 -1
  56. package/dist/find/findMany.d.ts +1 -2
  57. package/dist/find/findMany.d.ts.map +1 -1
  58. package/dist/find/findMany.js +6 -17
  59. package/dist/find/findMany.js.map +1 -1
  60. package/dist/find/traverseFields.d.ts +4 -3
  61. package/dist/find/traverseFields.d.ts.map +1 -1
  62. package/dist/find/traverseFields.js +27 -25
  63. package/dist/find/traverseFields.js.map +1 -1
  64. package/dist/find.d.ts +1 -1
  65. package/dist/find.d.ts.map +1 -1
  66. package/dist/find.js +2 -5
  67. package/dist/find.js.map +1 -1
  68. package/dist/findGlobal.d.ts +1 -1
  69. package/dist/findGlobal.d.ts.map +1 -1
  70. package/dist/findGlobal.js +2 -5
  71. package/dist/findGlobal.js.map +1 -1
  72. package/dist/findGlobalVersions.d.ts +1 -1
  73. package/dist/findGlobalVersions.d.ts.map +1 -1
  74. package/dist/findGlobalVersions.js +3 -7
  75. package/dist/findGlobalVersions.js.map +1 -1
  76. package/dist/findOne.d.ts +1 -2
  77. package/dist/findOne.d.ts.map +1 -1
  78. package/dist/findOne.js +2 -5
  79. package/dist/findOne.js.map +1 -1
  80. package/dist/findVersions.d.ts +1 -1
  81. package/dist/findVersions.d.ts.map +1 -1
  82. package/dist/findVersions.js +3 -7
  83. package/dist/findVersions.js.map +1 -1
  84. package/dist/index.d.ts +1 -1
  85. package/dist/index.d.ts.map +1 -1
  86. package/dist/index.js +18 -9
  87. package/dist/index.js.map +1 -1
  88. package/dist/init.d.ts +1 -1
  89. package/dist/init.d.ts.map +1 -1
  90. package/dist/init.js +20 -23
  91. package/dist/init.js.map +1 -1
  92. package/dist/migrate.d.ts.map +1 -1
  93. package/dist/migrate.js +1 -1
  94. package/dist/migrate.js.map +1 -1
  95. package/dist/migrateDown.js +1 -1
  96. package/dist/migrateDown.js.map +1 -1
  97. package/dist/migrateFresh.d.ts.map +1 -1
  98. package/dist/migrateFresh.js +1 -1
  99. package/dist/migrateFresh.js.map +1 -1
  100. package/dist/migrateRefresh.js +1 -1
  101. package/dist/migrateRefresh.js.map +1 -1
  102. package/dist/migrateReset.js +1 -1
  103. package/dist/migrateReset.js.map +1 -1
  104. package/dist/migrateStatus.js +1 -1
  105. package/dist/migrateStatus.js.map +1 -1
  106. package/dist/predefinedMigrations/relationships-v2-v3.d.ts +4 -0
  107. package/dist/predefinedMigrations/relationships-v2-v3.d.ts.map +1 -0
  108. package/dist/predefinedMigrations/relationships-v2-v3.js.map +1 -0
  109. package/dist/predefinedMigrations/relationships-v2-v3.mjs +11 -0
  110. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts +19 -0
  111. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts.map +1 -0
  112. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js +169 -0
  113. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js.map +1 -0
  114. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts +11 -0
  115. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts.map +1 -0
  116. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js +191 -0
  117. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js.map +1 -0
  118. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts +3 -0
  119. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts.map +1 -0
  120. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.js +56 -0
  121. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.js.map +1 -0
  122. package/dist/predefinedMigrations/v2-v3/index.d.ts +23 -0
  123. package/dist/predefinedMigrations/v2-v3/index.d.ts.map +1 -0
  124. package/dist/predefinedMigrations/v2-v3/index.js +211 -0
  125. package/dist/predefinedMigrations/v2-v3/index.js.map +1 -0
  126. package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts +19 -0
  127. package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts.map +1 -0
  128. package/dist/predefinedMigrations/v2-v3/migrateRelationships.js +57 -0
  129. package/dist/predefinedMigrations/v2-v3/migrateRelationships.js.map +1 -0
  130. package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts +22 -0
  131. package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts.map +1 -0
  132. package/dist/predefinedMigrations/v2-v3/traverseFields.js +85 -0
  133. package/dist/predefinedMigrations/v2-v3/traverseFields.js.map +1 -0
  134. package/dist/predefinedMigrations/v2-v3/types.d.ts +9 -0
  135. package/dist/predefinedMigrations/v2-v3/types.d.ts.map +1 -0
  136. package/dist/predefinedMigrations/v2-v3/types.js +6 -0
  137. package/dist/predefinedMigrations/v2-v3/types.js.map +1 -0
  138. package/dist/queries/buildAndOrConditions.d.ts +4 -5
  139. package/dist/queries/buildAndOrConditions.d.ts.map +1 -1
  140. package/dist/queries/buildAndOrConditions.js +1 -2
  141. package/dist/queries/buildAndOrConditions.js.map +1 -1
  142. package/dist/queries/buildQuery.d.ts +2 -3
  143. package/dist/queries/buildQuery.d.ts.map +1 -1
  144. package/dist/queries/buildQuery.js +1 -5
  145. package/dist/queries/buildQuery.js.map +1 -1
  146. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js.map +1 -1
  147. package/dist/queries/createJSONQuery/formatJSONPathSegment.js.map +1 -1
  148. package/dist/queries/createJSONQuery/index.js.map +1 -1
  149. package/dist/queries/getTableColumnFromPath.d.ts +4 -5
  150. package/dist/queries/getTableColumnFromPath.d.ts.map +1 -1
  151. package/dist/queries/getTableColumnFromPath.js +250 -146
  152. package/dist/queries/getTableColumnFromPath.js.map +1 -1
  153. package/dist/queries/operatorMap.js.map +1 -1
  154. package/dist/queries/parseParams.d.ts +4 -5
  155. package/dist/queries/parseParams.d.ts.map +1 -1
  156. package/dist/queries/parseParams.js +9 -8
  157. package/dist/queries/parseParams.js.map +1 -1
  158. package/dist/queries/sanitizeQueryValue.d.ts +1 -1
  159. package/dist/queries/sanitizeQueryValue.d.ts.map +1 -1
  160. package/dist/queries/sanitizeQueryValue.js +2 -3
  161. package/dist/queries/sanitizeQueryValue.js.map +1 -1
  162. package/dist/queries/selectDistinct.d.ts +3 -4
  163. package/dist/queries/selectDistinct.d.ts.map +1 -1
  164. package/dist/queries/selectDistinct.js +3 -14
  165. package/dist/queries/selectDistinct.js.map +1 -1
  166. package/dist/queryDrafts.d.ts +1 -1
  167. package/dist/queryDrafts.d.ts.map +1 -1
  168. package/dist/queryDrafts.js +3 -8
  169. package/dist/queryDrafts.js.map +1 -1
  170. package/dist/schema/build.d.ts +12 -7
  171. package/dist/schema/build.d.ts.map +1 -1
  172. package/dist/schema/build.js +208 -124
  173. package/dist/schema/build.js.map +1 -1
  174. package/dist/schema/createIndex.js.map +1 -1
  175. package/dist/schema/{getTableName.d.ts → createTableName.d.ts} +6 -8
  176. package/dist/schema/createTableName.d.ts.map +1 -0
  177. package/dist/schema/createTableName.js +31 -0
  178. package/dist/schema/createTableName.js.map +1 -0
  179. package/dist/schema/idToUUID.d.ts +1 -1
  180. package/dist/schema/idToUUID.d.ts.map +1 -1
  181. package/dist/schema/idToUUID.js.map +1 -1
  182. package/dist/schema/parentIDColumnMap.js.map +1 -1
  183. package/dist/schema/setColumnID.d.ts +1 -1
  184. package/dist/schema/setColumnID.d.ts.map +1 -1
  185. package/dist/schema/setColumnID.js +2 -2
  186. package/dist/schema/setColumnID.js.map +1 -1
  187. package/dist/schema/traverseFields.d.ts +5 -7
  188. package/dist/schema/traverseFields.d.ts.map +1 -1
  189. package/dist/schema/traverseFields.js +147 -63
  190. package/dist/schema/traverseFields.js.map +1 -1
  191. package/dist/schema/validateExistingBlockIsIdentical.d.ts +3 -2
  192. package/dist/schema/validateExistingBlockIsIdentical.d.ts.map +1 -1
  193. package/dist/schema/validateExistingBlockIsIdentical.js +15 -9
  194. package/dist/schema/validateExistingBlockIsIdentical.js.map +1 -1
  195. package/dist/transactions/beginTransaction.d.ts +1 -1
  196. package/dist/transactions/beginTransaction.d.ts.map +1 -1
  197. package/dist/transactions/beginTransaction.js +4 -0
  198. package/dist/transactions/beginTransaction.js.map +1 -1
  199. package/dist/transactions/commitTransaction.d.ts +1 -1
  200. package/dist/transactions/commitTransaction.d.ts.map +1 -1
  201. package/dist/transactions/commitTransaction.js +1 -0
  202. package/dist/transactions/commitTransaction.js.map +1 -1
  203. package/dist/transactions/rollbackTransaction.d.ts +1 -1
  204. package/dist/transactions/rollbackTransaction.d.ts.map +1 -1
  205. package/dist/transactions/rollbackTransaction.js +5 -4
  206. package/dist/transactions/rollbackTransaction.js.map +1 -1
  207. package/dist/transform/read/hasManyNumber.d.ts +1 -1
  208. package/dist/transform/read/hasManyNumber.d.ts.map +1 -1
  209. package/dist/transform/read/hasManyNumber.js.map +1 -1
  210. package/dist/transform/read/hasManyText.d.ts +1 -1
  211. package/dist/transform/read/hasManyText.d.ts.map +1 -1
  212. package/dist/transform/read/hasManyText.js.map +1 -1
  213. package/dist/transform/read/index.d.ts +4 -3
  214. package/dist/transform/read/index.d.ts.map +1 -1
  215. package/dist/transform/read/index.js +2 -1
  216. package/dist/transform/read/index.js.map +1 -1
  217. package/dist/transform/read/relationship.d.ts +1 -1
  218. package/dist/transform/read/relationship.d.ts.map +1 -1
  219. package/dist/transform/read/relationship.js +0 -4
  220. package/dist/transform/read/relationship.js.map +1 -1
  221. package/dist/transform/read/traverseFields.d.ts +8 -3
  222. package/dist/transform/read/traverseFields.d.ts.map +1 -1
  223. package/dist/transform/read/traverseFields.js +70 -56
  224. package/dist/transform/read/traverseFields.js.map +1 -1
  225. package/dist/transform/write/array.d.ts +1 -1
  226. package/dist/transform/write/array.d.ts.map +1 -1
  227. package/dist/transform/write/array.js.map +1 -1
  228. package/dist/transform/write/blocks.d.ts +1 -1
  229. package/dist/transform/write/blocks.d.ts.map +1 -1
  230. package/dist/transform/write/blocks.js +1 -1
  231. package/dist/transform/write/blocks.js.map +1 -1
  232. package/dist/transform/write/index.d.ts +1 -1
  233. package/dist/transform/write/index.d.ts.map +1 -1
  234. package/dist/transform/write/index.js.map +1 -1
  235. package/dist/transform/write/numbers.js.map +1 -1
  236. package/dist/transform/write/relationships.d.ts +1 -1
  237. package/dist/transform/write/relationships.d.ts.map +1 -1
  238. package/dist/transform/write/relationships.js +1 -1
  239. package/dist/transform/write/relationships.js.map +1 -1
  240. package/dist/transform/write/selects.js.map +1 -1
  241. package/dist/transform/write/texts.js.map +1 -1
  242. package/dist/transform/write/traverseFields.d.ts +1 -1
  243. package/dist/transform/write/traverseFields.d.ts.map +1 -1
  244. package/dist/transform/write/traverseFields.js +23 -6
  245. package/dist/transform/write/traverseFields.js.map +1 -1
  246. package/dist/transform/write/types.js.map +1 -1
  247. package/dist/types.d.ts +5 -7
  248. package/dist/types.d.ts.map +1 -1
  249. package/dist/types.js.map +1 -1
  250. package/dist/update.d.ts +1 -1
  251. package/dist/update.d.ts.map +1 -1
  252. package/dist/update.js +4 -8
  253. package/dist/update.js.map +1 -1
  254. package/dist/updateGlobal.d.ts +2 -3
  255. package/dist/updateGlobal.d.ts.map +1 -1
  256. package/dist/updateGlobal.js +3 -6
  257. package/dist/updateGlobal.js.map +1 -1
  258. package/dist/updateGlobalVersion.d.ts +1 -2
  259. package/dist/updateGlobalVersion.d.ts.map +1 -1
  260. package/dist/updateGlobalVersion.js +4 -8
  261. package/dist/updateGlobalVersion.js.map +1 -1
  262. package/dist/updateVersion.d.ts +1 -2
  263. package/dist/updateVersion.d.ts.map +1 -1
  264. package/dist/updateVersion.js +4 -8
  265. package/dist/updateVersion.js.map +1 -1
  266. package/dist/upsertRow/deleteExistingArrayRows.d.ts.map +1 -1
  267. package/dist/upsertRow/deleteExistingArrayRows.js.map +1 -1
  268. package/dist/upsertRow/deleteExistingRowsByPath.d.ts.map +1 -1
  269. package/dist/upsertRow/deleteExistingRowsByPath.js.map +1 -1
  270. package/dist/upsertRow/index.d.ts +2 -2
  271. package/dist/upsertRow/index.d.ts.map +1 -1
  272. package/dist/upsertRow/index.js +18 -13
  273. package/dist/upsertRow/index.js.map +1 -1
  274. package/dist/upsertRow/insertArrays.d.ts.map +1 -1
  275. package/dist/upsertRow/insertArrays.js +3 -3
  276. package/dist/upsertRow/insertArrays.js.map +1 -1
  277. package/dist/upsertRow/types.d.ts +6 -1
  278. package/dist/upsertRow/types.d.ts.map +1 -1
  279. package/dist/upsertRow/types.js.map +1 -1
  280. package/dist/utilities/appendPrefixToKeys.d.ts.map +1 -1
  281. package/dist/utilities/appendPrefixToKeys.js.map +1 -1
  282. package/dist/utilities/createBlocksMap.d.ts.map +1 -1
  283. package/dist/utilities/createBlocksMap.js.map +1 -1
  284. package/dist/utilities/createMigrationTable.d.ts.map +1 -1
  285. package/dist/utilities/createMigrationTable.js.map +1 -1
  286. package/dist/utilities/createRelationshipMap.d.ts.map +1 -1
  287. package/dist/utilities/createRelationshipMap.js.map +1 -1
  288. package/dist/utilities/hasLocalesTable.d.ts +1 -1
  289. package/dist/utilities/hasLocalesTable.d.ts.map +1 -1
  290. package/dist/utilities/hasLocalesTable.js +1 -1
  291. package/dist/utilities/hasLocalesTable.js.map +1 -1
  292. package/dist/utilities/isArrayOfRows.js.map +1 -1
  293. package/dist/utilities/migrationTableExists.d.ts.map +1 -1
  294. package/dist/utilities/migrationTableExists.js.map +1 -1
  295. package/dist/utilities/parseError.js.map +1 -1
  296. package/dist/utilities/pushDevSchema.d.ts.map +1 -1
  297. package/dist/utilities/pushDevSchema.js +1 -1
  298. package/dist/utilities/pushDevSchema.js.map +1 -1
  299. package/package.json +34 -29
  300. package/dist/schema/getTableName.d.ts.map +0 -1
  301. package/dist/schema/getTableName.js +0 -31
  302. package/dist/schema/getTableName.js.map +0 -1
  303. package/src/index.ts +0 -156
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/find/traverseFields.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { Field } from 'payload/types'\n\nimport { fieldAffectsData, tabHasName } from 'payload/types'\n\nimport type { PostgresAdapter } from '../types.js'\nimport type { Result } from './buildFindManyArgs.js'\n\nimport { getTableName } from '../schema/getTableName.js'\n\ntype TraverseFieldArgs = {\n _locales: Record<string, unknown>\n adapter: PostgresAdapter\n currentArgs: Record<string, unknown>\n currentTableName: string\n depth?: number\n fields: Field[]\n path: string\n topLevelArgs: Record<string, unknown>\n topLevelTableName: string\n}\n\nexport const traverseFields = ({\n _locales,\n adapter,\n currentArgs,\n currentTableName,\n depth,\n fields,\n path,\n topLevelArgs,\n topLevelTableName,\n}: TraverseFieldArgs) => {\n fields.forEach((field) => {\n if (field.type === 'collapsible' || field.type === 'row') {\n traverseFields({\n _locales,\n adapter,\n currentArgs,\n currentTableName,\n depth,\n fields: field.fields,\n path,\n topLevelArgs,\n topLevelTableName,\n })\n\n return\n }\n\n if (field.type === 'tabs') {\n field.tabs.forEach((tab) => {\n const tabPath = tabHasName(tab) ? `${path}${tab.name}_` : path\n\n traverseFields({\n _locales,\n adapter,\n currentArgs,\n currentTableName,\n depth,\n fields: tab.fields,\n path: tabPath,\n topLevelArgs,\n topLevelTableName,\n })\n })\n\n return\n }\n\n if (fieldAffectsData(field)) {\n switch (field.type) {\n case 'array': {\n const withArray: Result = {\n columns: {\n _parentID: false,\n },\n orderBy: ({ _order }, { asc }) => [asc(_order)],\n with: {},\n }\n\n const arrayTableName = getTableName({\n adapter,\n config: field,\n parentTableName: currentTableName,\n prefix: `${currentTableName}_${path}`,\n })\n\n const arrayTableNameWithLocales = getTableName({\n adapter,\n config: field,\n locales: true,\n parentTableName: currentTableName,\n prefix: `${currentTableName}_${path}`,\n })\n\n if (adapter.tables[arrayTableNameWithLocales]) withArray.with._locales = _locales\n currentArgs.with[`${path}${field.name}`] = withArray\n\n traverseFields({\n _locales,\n adapter,\n currentArgs: withArray,\n currentTableName: arrayTableName,\n depth,\n fields: field.fields,\n path: '',\n topLevelArgs,\n topLevelTableName,\n })\n\n break\n }\n\n case 'select': {\n if (field.hasMany) {\n const withSelect: Result = {\n columns: {\n id: false,\n order: false,\n parent: false,\n },\n orderBy: ({ order }, { asc }) => [asc(order)],\n }\n\n currentArgs.with[`${path}${field.name}`] = withSelect\n }\n\n break\n }\n\n case 'blocks':\n field.blocks.forEach((block) => {\n const blockKey = `_blocks_${block.slug}`\n\n if (!topLevelArgs[blockKey]) {\n const withBlock: Result = {\n columns: {\n _parentID: false,\n },\n orderBy: ({ _order }, { asc }) => [asc(_order)],\n with: {},\n }\n\n const tableName = getTableName({\n adapter,\n config: block,\n parentTableName: topLevelTableName,\n prefix: `${topLevelTableName}_blocks_`,\n })\n\n if (adapter.tables[`${tableName}${adapter.localesSuffix}`]) {\n withBlock.with._locales = _locales\n }\n topLevelArgs.with[blockKey] = withBlock\n\n traverseFields({\n _locales,\n adapter,\n currentArgs: withBlock,\n currentTableName: tableName,\n depth,\n fields: block.fields,\n path: '',\n topLevelArgs,\n topLevelTableName,\n })\n }\n })\n\n break\n\n case 'group':\n traverseFields({\n _locales,\n adapter,\n currentArgs,\n currentTableName,\n depth,\n fields: field.fields,\n path: `${path}${field.name}_`,\n topLevelArgs,\n topLevelTableName,\n })\n\n break\n\n default: {\n break\n }\n }\n }\n })\n\n return topLevelArgs\n}\n"],"names":["fieldAffectsData","tabHasName","getTableName","traverseFields","_locales","adapter","currentArgs","currentTableName","depth","fields","path","topLevelArgs","topLevelTableName","forEach","field","type","tabs","tab","tabPath","name","withArray","columns","_parentID","orderBy","_order","asc","with","arrayTableName","config","parentTableName","prefix","arrayTableNameWithLocales","locales","tables","hasMany","withSelect","id","order","parent","blocks","block","blockKey","slug","withBlock","tableName","localesSuffix"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,oCAAoC,GAGpC,SAASA,gBAAgB,EAAEC,UAAU,QAAQ,gBAAe;AAK5D,SAASC,YAAY,QAAQ,4BAA2B;AAcxD,OAAO,MAAMC,iBAAiB,CAAC,EAC7BC,QAAQ,EACRC,OAAO,EACPC,WAAW,EACXC,gBAAgB,EAChBC,KAAK,EACLC,MAAM,EACNC,IAAI,EACJC,YAAY,EACZC,iBAAiB,EACC;IAClBH,OAAOI,OAAO,CAAC,CAACC;QACd,IAAIA,MAAMC,IAAI,KAAK,iBAAiBD,MAAMC,IAAI,KAAK,OAAO;YACxDZ,eAAe;gBACbC;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC,QAAQK,MAAML,MAAM;gBACpBC;gBACAC;gBACAC;YACF;YAEA;QACF;QAEA,IAAIE,MAAMC,IAAI,KAAK,QAAQ;YACzBD,MAAME,IAAI,CAACH,OAAO,CAAC,CAACI;gBAClB,MAAMC,UAAUjB,WAAWgB,OAAO,CAAC,EAAEP,KAAK,EAAEO,IAAIE,IAAI,CAAC,CAAC,CAAC,GAAGT;gBAE1DP,eAAe;oBACbC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC,QAAQQ,IAAIR,MAAM;oBAClBC,MAAMQ;oBACNP;oBACAC;gBACF;YACF;YAEA;QACF;QAEA,IAAIZ,iBAAiBc,QAAQ;YAC3B,OAAQA,MAAMC,IAAI;gBAChB,KAAK;oBAAS;wBACZ,MAAMK,YAAoB;4BACxBC,SAAS;gCACPC,WAAW;4BACb;4BACAC,SAAS,CAAC,EAAE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AAC/B,YAAY,CAAC8B,SAAS,EAAE;4BAC3B,MAAME,YAAoB;gCACxBtB,SAAS;oCACPC,WAAW;gCACb;gCACAC,SAAS,CAAC,EAAEC,MAAM,EAAE,EAAE,EAAEC,GAAG,EAAE,GAAK;wCAACA,IAAID;qCAAQ;gCAC/CE,MAAM,CAAC;4BACT;4BAEA,MAAMkB,YAAY1C,aAAa;gCAC7BG;gCACAuB,QAAQY;gCACRX,iBAAiBjB;gCACjBkB,QAAQ,CAAC,EAAElB,kBAAkB,QAAQ,CAAC;4BACxC;4BAEA,IAAIP,QAAQ4B,MAAM,CAAC,CAAC,EAAEW,UAAU,EAAEvC,QAAQwC,aAAa,CAAC,CAAC,CAAC,EAAE;gCAC1DF,UAAUjB,IAAI,CAACtB,QAAQ,GAAGA;4BAC5B;4BACAO,aAAae,IAAI,CAACe,SAAS,GAAGE;4BAE9BxC,eAAe;gCACbC;gCACAC;gCACAC,aAAaqC;gCACbpC,kBAAkBqC;gCAClBpC;gCACAC,QAAQ+B,MAAM/B,MAAM;gCACpBC,MAAM;gCACNC;gCACAC;4BACF;wBACF;oBACF;oBAEA;gBAEF,KAAK;oBACHT,eAAe;wBACbC;wBACAC;wBACAC;wBACAC;wBACAC;wBACAC,QAAQK,MAAML,MAAM;wBACpBC,MAAM,CAAC,EAAEA,KAAK,EAAEI,MAAMK,IAAI,CAAC,CAAC,CAAC;wBAC7BR;wBACAC;oBACF;oBAEA;gBAEF;oBAAS;wBACP;oBACF;YACF;QACF;IACF;IAEA,OAAOD;AACT,EAAC"}
1
+ {"version":3,"sources":["../../src/find/traverseFields.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { Field } from 'payload'\n\nimport { fieldAffectsData, tabHasName } from 'payload/shared'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from '../types.js'\nimport type { Result } from './buildFindManyArgs.js'\n\ntype TraverseFieldArgs = {\n _locales: Result\n adapter: PostgresAdapter\n currentArgs: Result\n currentTableName: string\n depth?: number\n fields: Field[]\n path: string\n topLevelArgs: Record<string, unknown>\n topLevelTableName: string\n}\n\nexport const traverseFields = ({\n _locales,\n adapter,\n currentArgs,\n currentTableName,\n depth,\n fields,\n path,\n topLevelArgs,\n topLevelTableName,\n}: TraverseFieldArgs) => {\n fields.forEach((field) => {\n // handle simple relationship\n if (\n depth > 0 &&\n (field.type === 'upload' ||\n (field.type === 'relationship' && !field.hasMany && typeof field.relationTo === 'string'))\n ) {\n if (field.localized) {\n _locales.with[`${path}${field.name}`] = true\n } else {\n currentArgs.with[`${path}${field.name}`] = true\n }\n }\n\n if (field.type === 'collapsible' || field.type === 'row') {\n traverseFields({\n _locales,\n adapter,\n currentArgs,\n currentTableName,\n depth,\n fields: field.fields,\n path,\n topLevelArgs,\n topLevelTableName,\n })\n\n return\n }\n\n if (field.type === 'tabs') {\n field.tabs.forEach((tab) => {\n const tabPath = tabHasName(tab) ? `${path}${tab.name}_` : path\n\n traverseFields({\n _locales,\n adapter,\n currentArgs,\n currentTableName,\n depth,\n fields: tab.fields,\n path: tabPath,\n topLevelArgs,\n topLevelTableName,\n })\n })\n\n return\n }\n\n if (fieldAffectsData(field)) {\n switch (field.type) {\n case 'array': {\n const withArray: Result = {\n columns: {\n _parentID: false,\n },\n orderBy: ({ _order }, { asc }) => [asc(_order)],\n with: {},\n }\n\n const arrayTableName = adapter.tableNameMap.get(\n `${currentTableName}_${path}${toSnakeCase(field.name)}`,\n )\n\n const arrayTableNameWithLocales = `${arrayTableName}${adapter.localesSuffix}`\n\n if (adapter.tables[arrayTableNameWithLocales]) {\n withArray.with._locales = {\n columns: {\n id: false,\n _parentID: false,\n },\n with: {},\n }\n }\n currentArgs.with[`${path}${field.name}`] = withArray\n\n traverseFields({\n _locales: withArray.with._locales,\n adapter,\n currentArgs: withArray,\n currentTableName: arrayTableName,\n depth,\n fields: field.fields,\n path: '',\n topLevelArgs,\n topLevelTableName,\n })\n\n break\n }\n\n case 'select': {\n if (field.hasMany) {\n const withSelect: Result = {\n columns: {\n id: false,\n order: false,\n parent: false,\n },\n orderBy: ({ order }, { asc }) => [asc(order)],\n }\n\n currentArgs.with[`${path}${field.name}`] = withSelect\n }\n\n break\n }\n\n case 'blocks':\n field.blocks.forEach((block) => {\n const blockKey = `_blocks_${block.slug}`\n\n if (!topLevelArgs[blockKey]) {\n const withBlock: Result = {\n columns: {\n _parentID: false,\n },\n orderBy: ({ _order }, { asc }) => [asc(_order)],\n with: {},\n }\n\n const tableName = adapter.tableNameMap.get(\n `${topLevelTableName}_blocks_${toSnakeCase(block.slug)}`,\n )\n\n if (adapter.tables[`${tableName}${adapter.localesSuffix}`]) {\n withBlock.with._locales = {\n with: {},\n }\n }\n topLevelArgs.with[blockKey] = withBlock\n\n traverseFields({\n _locales: withBlock.with._locales,\n adapter,\n currentArgs: withBlock,\n currentTableName: tableName,\n depth,\n fields: block.fields,\n path: '',\n topLevelArgs,\n topLevelTableName,\n })\n }\n })\n\n break\n\n case 'group':\n traverseFields({\n _locales,\n adapter,\n currentArgs,\n currentTableName,\n depth,\n fields: field.fields,\n path: `${path}${field.name}_`,\n topLevelArgs,\n topLevelTableName,\n })\n\n break\n\n default: {\n break\n }\n }\n }\n })\n\n return topLevelArgs\n}\n"],"names":["fieldAffectsData","tabHasName","toSnakeCase","traverseFields","_locales","adapter","currentArgs","currentTableName","depth","fields","path","topLevelArgs","topLevelTableName","forEach","field","type","hasMany","relationTo","localized","with","name","tabs","tab","tabPath","withArray","columns","_parentID","orderBy","_order","asc","arrayTableName","tableNameMap","get","arrayTableNameWithLocales","localesSuffix","tables","id","withSelect","order","parent","blocks","block","blockKey","slug","withBlock","tableName"],"mappings":"AAAA,oCAAoC,GAGpC,SAASA,gBAAgB,EAAEC,UAAU,QAAQ,iBAAgB;AAC7D,OAAOC,iBAAiB,gBAAe;AAiBvC,OAAO,MAAMC,iBAAiB,CAAC,EAC7BC,QAAQ,EACRC,OAAO,EACPC,WAAW,EACXC,gBAAgB,EAChBC,KAAK,EACLC,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nB,SAAS;oCACPC,WAAW;gCACb;gCACAC,SAAS,CAAC,EAAEC,MAAM,EAAE,EAAE,EAAEC,GAAG,EAAE,GAAK;wCAACA,IAAID;qCAAQ;gCAC/CT,MAAM,CAAC;4BACT;4BAEA,MAAM0B,YAAYxC,QAAQ0B,YAAY,CAACC,GAAG,CACxC,CAAC,EAAEpB,kBAAkB,QAAQ,EAAEV,YAAYuC,MAAME,IAAI,EAAE,CAAC;4BAG1D,IAAItC,QAAQ8B,MAAM,CAAC,CAAC,EAAEU,UAAU,EAAExC,QAAQ6B,aAAa,CAAC,CAAC,CAAC,EAAE;gCAC1DU,UAAUzB,IAAI,CAACf,QAAQ,GAAG;oCACxBe,MAAM,CAAC;gCACT;4BACF;4BACAR,aAAaQ,IAAI,CAACuB,SAAS,GAAGE;4BAE9BzC,eAAe;gCACbC,UAAUwC,UAAUzB,IAAI,CAACf,QAAQ;gCACjCC;gCACAC,aAAasC;gCACbrC,kBAAkBsC;gCAClBrC;gCACAC,QAAQgC,MAAMhC,MAAM;gCACpBC,MAAM;gCACNC;gCACAC;4BACF;wBACF;oBACF;oBAEA;gBAEF,KAAK;oBACHT,eAAe;wBACbC;wBACAC;wBACAC;wBACAC;wBACAC;wBACAC,QAAQK,MAAML,MAAM;wBACpBC,MAAM,CAAC,EAAEA,KAAK,EAAEI,MAAMM,IAAI,CAAC,CAAC,CAAC;wBAC7BT;wBACAC;oBACF;oBAEA;gBAEF;oBAAS;wBACP;oBACF;YACF;QACF;IACF;IAEA,OAAOD;AACT,EAAC"}
package/dist/find.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import type { Find } from 'payload/database';
1
+ import type { Find } from 'payload';
2
2
  export declare const find: Find;
3
3
  //# sourceMappingURL=find.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../src/find.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAQ5C,eAAO,MAAM,IAAI,EAAE,IAgClB,CAAA"}
1
+ {"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../src/find.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAA6C,MAAM,SAAS,CAAA;AAQ9E,eAAO,MAAM,IAAI,EAAE,IA8BlB,CAAA"}
package/dist/find.js CHANGED
@@ -1,12 +1,9 @@
1
+ import toSnakeCase from 'to-snake-case';
1
2
  import { findMany } from './find/findMany.js';
2
- import { getTableName } from './schema/getTableName.js';
3
3
  export const find = async function find({ collection, limit, locale, page = 1, pagination, req = {}, sort: sortArg, where }) {
4
4
  const collectionConfig = this.payload.collections[collection].config;
5
5
  const sort = typeof sortArg === 'string' ? sortArg : collectionConfig.defaultSort;
6
- const tableName = getTableName({
7
- adapter: this,
8
- config: collectionConfig
9
- });
6
+ const tableName = this.tableNameMap.get(toSnakeCase(collectionConfig.slug));
10
7
  return findMany({
11
8
  adapter: this,
12
9
  fields: collectionConfig.fields,
package/dist/find.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/find.ts"],"sourcesContent":["import type { Find } from 'payload/database'\nimport type { PayloadRequest, SanitizedCollectionConfig } from 'payload/types'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\nimport { getTableName } from './schema/getTableName.js'\n\nexport const find: Find = async function find(\n this: PostgresAdapter,\n {\n collection,\n limit,\n locale,\n page = 1,\n pagination,\n req = {} as PayloadRequest,\n sort: sortArg,\n where,\n },\n) {\n const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config\n const sort = typeof sortArg === 'string' ? sortArg : collectionConfig.defaultSort\n const tableName = getTableName({\n adapter: this,\n config: collectionConfig,\n })\n\n return findMany({\n adapter: this,\n fields: collectionConfig.fields,\n limit,\n locale,\n page,\n pagination,\n req,\n sort,\n tableName,\n where,\n })\n}\n"],"names":["findMany","getTableName","find","collection","limit","locale","page","pagination","req","sort","sortArg","where","collectionConfig","payload","collections","config","defaultSort","tableName","adapter","fields"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;","mappings":"AAKA,SAASA,QAAQ,QAAQ,qBAAoB;AAC7C,SAASC,YAAY,QAAQ,2BAA0B;AAEvD,OAAO,MAAMC,OAAa,eAAeA,KAEvC,EACEC,UAAU,EACVC,KAAK,EACLC,MAAM,EACNC,OAAO,CAAC,EACRC,UAAU,EACVC,MAAM,CAAC,CAAmB,EAC1BC,MAAMC,OAAO,EACbC,KAAK,EACN;IAED,MAAMC,mBAA8C,IAAI,CAACC,OAAO,CAACC,WAAW,CAACX,WAAW,CAACY,MAAM;IAC/F,MAAMN,OAAO,OAAOC,YAAY,WAAWA,UAAUE,iBAAiBI,WAAW;IACjF,MAAMC,YAAYhB,aAAa;QAC7BiB,SAAS,IAAI;QACbH,QAAQH;IACV;IAEA,OAAOZ,SAAS;QACdkB,SAAS,IAAI;QACbC,QAAQP,iBAAiBO,MAAM;QAC/Bf;QACAC;QACAC;QACAC;QACAC;QACAC;QACAQ;QACAN;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../src/find.ts"],"sourcesContent":["import type { Find, PayloadRequest, SanitizedCollectionConfig } from 'payload'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\n\nexport const find: Find = async function find(\n this: PostgresAdapter,\n {\n collection,\n limit,\n locale,\n page = 1,\n pagination,\n req = {} as PayloadRequest,\n sort: sortArg,\n where,\n },\n) {\n const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config\n const sort = typeof sortArg === 'string' ? sortArg : collectionConfig.defaultSort\n\n const tableName = this.tableNameMap.get(toSnakeCase(collectionConfig.slug))\n\n return findMany({\n adapter: this,\n fields: collectionConfig.fields,\n limit,\n locale,\n page,\n pagination,\n req,\n sort,\n tableName,\n where,\n })\n}\n"],"names":["toSnakeCase","findMany","find","collection","limit","locale","page","pagination","req","sort","sortArg","where","collectionConfig","payload","collections","config","defaultSort","tableName","tableNameMap","get","slug","adapter","fields"],"mappings":"AAEA,OAAOA,iBAAiB,gBAAe;AAIvC,SAASC,QAAQ,QAAQ,qBAAoB;AAE7C,OAAO,MAAMC,OAAa,eAAeA,KAEvC,EACEC,UAAU,EACVC,KAAK,EACLC,MAAM,EACNC,OAAO,CAAC,EACRC,UAAU,EACVC,MAAM,CAAC,CAAmB,EAC1BC,MAAMC,OAAO,EACbC,KAAK,EACN;IAED,MAAMC,mBAA8C,IAAI,CAACC,OAAO,CAACC,WAAW,CAACX,WAAW,CAACY,MAAM;IAC/F,MAAMN,OAAO,OAAOC,YAAY,WAAWA,UAAUE,iBAAiBI,WAAW;IAEjF,MAAMC,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CAACnB,YAAYY,iBAAiBQ,IAAI;IAEzE,OAAOnB,SAAS;QACdoB,SAAS,IAAI;QACbC,QAAQV,iBAAiBU,MAAM;QAC/BlB;QACAC;QACAC;QACAC;QACAC;QACAC;QACAQ;QACAN;IACF;AACF,EAAC"}
@@ -1,3 +1,3 @@
1
- import type { FindGlobal } from 'payload/database';
1
+ import type { FindGlobal } from 'payload';
2
2
  export declare const findGlobal: FindGlobal;
3
3
  //# sourceMappingURL=findGlobal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"findGlobal.d.ts","sourceRoot":"","sources":["../src/findGlobal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAOlD,eAAO,MAAM,UAAU,EAAE,UA6BxB,CAAA"}
1
+ {"version":3,"file":"findGlobal.d.ts","sourceRoot":"","sources":["../src/findGlobal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAQzC,eAAO,MAAM,UAAU,EAAE,UA2BxB,CAAA"}
@@ -1,11 +1,8 @@
1
+ import toSnakeCase from 'to-snake-case';
1
2
  import { findMany } from './find/findMany.js';
2
- import { getTableName } from './schema/getTableName.js';
3
3
  export const findGlobal = async function findGlobal({ slug, locale, req, where }) {
4
4
  const globalConfig = this.payload.globals.config.find((config)=>config.slug === slug);
5
- const tableName = getTableName({
6
- adapter: this,
7
- config: globalConfig
8
- });
5
+ const tableName = this.tableNameMap.get(toSnakeCase(globalConfig.slug));
9
6
  const { docs: [doc] } = await findMany({
10
7
  adapter: this,
11
8
  fields: globalConfig.fields,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/findGlobal.ts"],"sourcesContent":["import type { FindGlobal } from 'payload/database'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\nimport { getTableName } from './schema/getTableName.js'\n\nexport const findGlobal: FindGlobal = async function findGlobal(\n this: PostgresAdapter,\n { slug, locale, req, where },\n) {\n const globalConfig = this.payload.globals.config.find((config) => config.slug === slug)\n const tableName = getTableName({\n adapter: this,\n config: globalConfig,\n })\n\n const {\n docs: [doc],\n } = await findMany({\n adapter: this,\n fields: globalConfig.fields,\n limit: 1,\n locale,\n pagination: false,\n req,\n tableName,\n where,\n })\n\n if (doc) {\n doc.globalType = slug\n return doc\n }\n\n return {}\n}\n"],"names":["findMany","getTableName","findGlobal","slug","locale","req","where","globalConfig","payload","globals","config","find","tableName","adapter","docs","doc","fields","limit","pagination","globalType"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,QAAQ,QAAQ,qBAAoB;AAC7C,SAASC,YAAY,QAAQ,2BAA0B;AAEvD,OAAO,MAAMC,aAAyB,eAAeA,WAEnD,EAAEC,IAAI,EAAEC,MAAM,EAAEC,GAAG,EAAEC,KAAK,EAAE;IAE5B,MAAMC,eAAe,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAACD,SAAWA,OAAOP,IAAI,KAAKA;IAClF,MAAMS,YAAYX,aAAa;QAC7BY,SAAS,IAAI;QACbH,QAAQH;IACV;IAEA,MAAM,EACJO,MAAM,CAACC,IAAI,EACZ,GAAG,MAAMf,SAAS;QACjBa,SAAS,IAAI;QACbG,QAAQT,aAAaS,MAAM;QAC3BC,OAAO;QACPb;QACAc,YAAY;QACZb;QACAO;QACAN;IACF;IAEA,IAAIS,KAAK;QACPA,IAAII,UAAU,GAAGhB;QACjB,OAAOY;IACT;IAEA,OAAO,CAAC;AACV,EAAC"}
1
+ {"version":3,"sources":["../src/findGlobal.ts"],"sourcesContent":["import type { FindGlobal } from 'payload'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\n\nexport const findGlobal: FindGlobal = async function findGlobal(\n this: PostgresAdapter,\n { slug, locale, req, where },\n) {\n const globalConfig = this.payload.globals.config.find((config) => config.slug === slug)\n\n const tableName = this.tableNameMap.get(toSnakeCase(globalConfig.slug))\n\n const {\n docs: [doc],\n } = await findMany({\n adapter: this,\n fields: globalConfig.fields,\n limit: 1,\n locale,\n pagination: false,\n req,\n tableName,\n where,\n })\n\n if (doc) {\n doc.globalType = slug\n return doc\n }\n\n return {}\n}\n"],"names":["toSnakeCase","findMany","findGlobal","slug","locale","req","where","globalConfig","payload","globals","config","find","tableName","tableNameMap","get","docs","doc","adapter","fields","limit","pagination","globalType"],"mappings":"AAEA,OAAOA,iBAAiB,gBAAe;AAIvC,SAASC,QAAQ,QAAQ,qBAAoB;AAE7C,OAAO,MAAMC,aAAyB,eAAeA,WAEnD,EAAEC,IAAI,EAAEC,MAAM,EAAEC,GAAG,EAAEC,KAAK,EAAE;IAE5B,MAAMC,eAAe,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAACD,SAAWA,OAAOP,IAAI,KAAKA;IAElF,MAAMS,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CAACd,YAAYO,aAAaJ,IAAI;IAErE,MAAM,EACJY,MAAM,CAACC,IAAI,EACZ,GAAG,MAAMf,SAAS;QACjBgB,SAAS,IAAI;QACbC,QAAQX,aAAaW,MAAM;QAC3BC,OAAO;QACPf;QACAgB,YAAY;QACZf;QACAO;QACAN;IACF;IAEA,IAAIU,KAAK;QACPA,IAAIK,UAAU,GAAGlB;QACjB,OAAOa;IACT;IAEA,OAAO,CAAC;AACV,EAAC"}
@@ -1,3 +1,3 @@
1
- import type { FindGlobalVersions } from 'payload/database';
1
+ import type { FindGlobalVersions } from 'payload';
2
2
  export declare const findGlobalVersions: FindGlobalVersions;
3
3
  //# sourceMappingURL=findGlobalVersions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"findGlobalVersions.d.ts","sourceRoot":"","sources":["../src/findGlobalVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAU1D,eAAO,MAAM,kBAAkB,EAAE,kBAuChC,CAAA"}
1
+ {"version":3,"file":"findGlobalVersions.d.ts","sourceRoot":"","sources":["../src/findGlobalVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAyC,MAAM,SAAS,CAAA;AASxF,eAAO,MAAM,kBAAkB,EAAE,kBAsChC,CAAA"}
@@ -1,14 +1,10 @@
1
- import { buildVersionGlobalFields } from 'payload/versions';
1
+ import { buildVersionGlobalFields } from 'payload';
2
+ import toSnakeCase from 'to-snake-case';
2
3
  import { findMany } from './find/findMany.js';
3
- import { getTableName } from './schema/getTableName.js';
4
4
  export const findGlobalVersions = async function findGlobalVersions({ global, limit, locale, page, pagination, req = {}, skip, sort: sortArg, where }) {
5
5
  const globalConfig = this.payload.globals.config.find(({ slug })=>slug === global);
6
6
  const sort = typeof sortArg === 'string' ? sortArg : '-createdAt';
7
- const tableName = getTableName({
8
- adapter: this,
9
- config: globalConfig,
10
- versions: true
11
- });
7
+ const tableName = this.tableNameMap.get(`_${toSnakeCase(globalConfig.slug)}${this.versionsSuffix}`);
12
8
  const fields = buildVersionGlobalFields(globalConfig);
13
9
  return findMany({
14
10
  adapter: this,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/findGlobalVersions.ts"],"sourcesContent":["import type { FindGlobalVersions } from 'payload/database'\nimport type { PayloadRequest, SanitizedGlobalConfig } from 'payload/types'\n\nimport { buildVersionGlobalFields } from 'payload/versions'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\nimport { getTableName } from './schema/getTableName.js'\n\nexport const findGlobalVersions: FindGlobalVersions = async function findGlobalVersions(\n this: PostgresAdapter,\n {\n global,\n limit,\n locale,\n page,\n pagination,\n req = {} as PayloadRequest,\n skip,\n sort: sortArg,\n where,\n },\n) {\n const globalConfig: SanitizedGlobalConfig = this.payload.globals.config.find(\n ({ slug }) => slug === global,\n )\n const sort = typeof sortArg === 'string' ? sortArg : '-createdAt'\n\n const tableName = getTableName({\n adapter: this,\n config: globalConfig,\n versions: true,\n })\n const fields = buildVersionGlobalFields(globalConfig)\n\n return findMany({\n adapter: this,\n fields,\n limit,\n locale,\n page,\n pagination,\n req,\n skip,\n sort,\n tableName,\n where,\n })\n}\n"],"names":["buildVersionGlobalFields","findMany","getTableName","findGlobalVersions","global","limit","locale","page","pagination","req","skip","sort","sortArg","where","globalConfig","payload","globals","config","find","slug","tableName","adapter","versions","fields"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,wBAAwB,QAAQ,mBAAkB;AAI3D,SAASC,QAAQ,QAAQ,qBAAoB;AAC7C,SAASC,YAAY,QAAQ,2BAA0B;AAEvD,OAAO,MAAMC,qBAAyC,eAAeA,mBAEnE,EACEC,MAAM,EACNC,KAAK,EACLC,MAAM,EACNC,IAAI,EACJC,UAAU,EACVC,MAAM,CAAC,CAAmB,EAC1BC,IAAI,EACJC,MAAMC,OAAO,EACbC,KAAK,EACN;IAED,MAAMC,eAAsC,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,MAAM,CAACC,IAAI,CAC1E,CAAC,EAAEC,IAAI,EAAE,GAAKA,SAASf;IAEzB,MAAMO,OAAO,OAAOC,YAAY,WAAWA,UAAU;IAErD,MAAMQ,YAAYlB,aAAa;QAC7BmB,SAAS,IAAI;QACbJ,QAAQH;QACRQ,UAAU;IACZ;IACA,MAAMC,SAASvB,yBAAyBc;IAExC,OAAOb,SAAS;QACdoB,SAAS,IAAI;QACbE;QACAlB;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAS;QACAP;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../src/findGlobalVersions.ts"],"sourcesContent":["import type { FindGlobalVersions, PayloadRequest, SanitizedGlobalConfig } from 'payload'\n\nimport { buildVersionGlobalFields } from 'payload'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\n\nexport const findGlobalVersions: FindGlobalVersions = async function findGlobalVersions(\n this: PostgresAdapter,\n {\n global,\n limit,\n locale,\n page,\n pagination,\n req = {} as PayloadRequest,\n skip,\n sort: sortArg,\n where,\n },\n) {\n const globalConfig: SanitizedGlobalConfig = this.payload.globals.config.find(\n ({ slug }) => slug === global,\n )\n const sort = typeof sortArg === 'string' ? sortArg : '-createdAt'\n\n const tableName = this.tableNameMap.get(\n `_${toSnakeCase(globalConfig.slug)}${this.versionsSuffix}`,\n )\n\n const fields = buildVersionGlobalFields(globalConfig)\n\n return findMany({\n adapter: this,\n fields,\n limit,\n locale,\n page,\n pagination,\n req,\n skip,\n sort,\n tableName,\n where,\n })\n}\n"],"names":["buildVersionGlobalFields","toSnakeCase","findMany","findGlobalVersions","global","limit","locale","page","pagination","req","skip","sort","sortArg","where","globalConfig","payload","globals","config","find","slug","tableName","tableNameMap","get","versionsSuffix","fields","adapter"],"mappings":"AAEA,SAASA,wBAAwB,QAAQ,UAAS;AAClD,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,QAAQ,QAAQ,qBAAoB;AAE7C,OAAO,MAAMC,qBAAyC,eAAeA,mBAEnE,EACEC,MAAM,EACNC,KAAK,EACLC,MAAM,EACNC,IAAI,EACJC,UAAU,EACVC,MAAM,CAAC,CAAmB,EAC1BC,IAAI,EACJC,MAAMC,OAAO,EACbC,KAAK,EACN;IAED,MAAMC,eAAsC,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,MAAM,CAACC,IAAI,CAC1E,CAAC,EAAEC,IAAI,EAAE,GAAKA,SAASf;IAEzB,MAAMO,OAAO,OAAOC,YAAY,WAAWA,UAAU;IAErD,MAAMQ,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CACrC,CAAC,CAAC,EAAErB,YAAYa,aAAaK,IAAI,EAAE,EAAE,IAAI,CAACI,cAAc,CAAC,CAAC;IAG5D,MAAMC,SAASxB,yBAAyBc;IAExC,OAAOZ,SAAS;QACduB,SAAS,IAAI;QACbD;QACAnB;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAS;QACAP;IACF;AACF,EAAC"}
package/dist/findOne.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import type { FindOneArgs } from 'payload/database';
2
- import type { TypeWithID } from 'payload/types';
1
+ import type { FindOneArgs, TypeWithID } from 'payload';
3
2
  import type { PostgresAdapter } from './types.js';
4
3
  export declare function findOne<T extends TypeWithID>(this: PostgresAdapter, { collection, locale, req, where }: FindOneArgs): Promise<T>;
5
4
  //# sourceMappingURL=findOne.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"findOne.d.ts","sourceRoot":"","sources":["../src/findOne.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,KAAK,EAA6C,UAAU,EAAE,MAAM,eAAe,CAAA;AAE1F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAKjD,wBAAsB,OAAO,CAAC,CAAC,SAAS,UAAU,EAChD,IAAI,EAAE,eAAe,EACrB,EAAE,UAAU,EAAE,MAAM,EAAE,GAA0B,EAAE,KAAK,EAAE,EAAE,WAAW,GACrE,OAAO,CAAC,CAAC,CAAC,CAqBZ"}
1
+ {"version":3,"file":"findOne.d.ts","sourceRoot":"","sources":["../src/findOne.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAA6C,UAAU,EAAE,MAAM,SAAS,CAAA;AAIjG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAIjD,wBAAsB,OAAO,CAAC,CAAC,SAAS,UAAU,EAChD,IAAI,EAAE,eAAe,EACrB,EAAE,UAAU,EAAE,MAAM,EAAE,GAA0B,EAAE,KAAK,EAAE,EAAE,WAAW,GACrE,OAAO,CAAC,CAAC,CAAC,CAmBZ"}
package/dist/findOne.js CHANGED
@@ -1,11 +1,8 @@
1
+ import toSnakeCase from 'to-snake-case';
1
2
  import { findMany } from './find/findMany.js';
2
- import { getTableName } from './schema/getTableName.js';
3
3
  export async function findOne({ collection, locale, req = {}, where }) {
4
4
  const collectionConfig = this.payload.collections[collection].config;
5
- const tableName = getTableName({
6
- adapter: this,
7
- config: collectionConfig
8
- });
5
+ const tableName = this.tableNameMap.get(toSnakeCase(collectionConfig.slug));
9
6
  const { docs } = await findMany({
10
7
  adapter: this,
11
8
  fields: collectionConfig.fields,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/findOne.ts"],"sourcesContent":["import type { FindOneArgs } from 'payload/database'\nimport type { PayloadRequest, SanitizedCollectionConfig, TypeWithID } from 'payload/types'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\nimport { getTableName } from './schema/getTableName.js'\n\nexport async function findOne<T extends TypeWithID>(\n this: PostgresAdapter,\n { collection, locale, req = {} as PayloadRequest, where }: FindOneArgs,\n): Promise<T> {\n const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config\n const tableName = getTableName({\n adapter: this,\n config: collectionConfig,\n })\n\n const { docs } = await findMany({\n adapter: this,\n fields: collectionConfig.fields,\n limit: 1,\n locale,\n page: 1,\n pagination: false,\n req,\n sort: undefined,\n tableName,\n where,\n })\n\n return docs?.[0] || null\n}\n"],"names":["findMany","getTableName","findOne","collection","locale","req","where","collectionConfig","payload","collections","config","tableName","adapter","docs","fields","limit","page","pagination","sort","undefined"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;","mappings":"AAKA,SAASA,QAAQ,QAAQ,qBAAoB;AAC7C,SAASC,YAAY,QAAQ,2BAA0B;AAEvD,OAAO,eAAeC,QAEpB,EAAEC,UAAU,EAAEC,MAAM,EAAEC,MAAM,CAAC,CAAmB,EAAEC,KAAK,EAAe;IAEtE,MAAMC,mBAA8C,IAAI,CAACC,OAAO,CAACC,WAAW,CAACN,WAAW,CAACO,MAAM;IAC/F,MAAMC,YAAYV,aAAa;QAC7BW,SAAS,IAAI;QACbF,QAAQH;IACV;IAEA,MAAM,EAAEM,IAAI,EAAE,GAAG,MAAMb,SAAS;QAC9BY,SAAS,IAAI;QACbE,QAAQP,iBAAiBO,MAAM;QAC/BC,OAAO;QACPX;QACAY,MAAM;QACNC,YAAY;QACZZ;QACAa,MAAMC;QACNR;QACAL;IACF;IAEA,OAAOO,MAAM,CAAC,EAAE,IAAI;AACtB"}
1
+ {"version":3,"sources":["../src/findOne.ts"],"sourcesContent":["import type { FindOneArgs, PayloadRequest, SanitizedCollectionConfig, TypeWithID } from 'payload'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\n\nexport async function findOne<T extends TypeWithID>(\n this: PostgresAdapter,\n { collection, locale, req = {} as PayloadRequest, where }: FindOneArgs,\n): Promise<T> {\n const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config\n\n const tableName = this.tableNameMap.get(toSnakeCase(collectionConfig.slug))\n\n const { docs } = await findMany({\n adapter: this,\n fields: collectionConfig.fields,\n limit: 1,\n locale,\n page: 1,\n pagination: false,\n req,\n sort: undefined,\n tableName,\n where,\n })\n\n return docs?.[0] || null\n}\n"],"names":["toSnakeCase","findMany","findOne","collection","locale","req","where","collectionConfig","payload","collections","config","tableName","tableNameMap","get","slug","docs","adapter","fields","limit","page","pagination","sort","undefined"],"mappings":"AAEA,OAAOA,iBAAiB,gBAAe;AAIvC,SAASC,QAAQ,QAAQ,qBAAoB;AAE7C,OAAO,eAAeC,QAEpB,EAAEC,UAAU,EAAEC,MAAM,EAAEC,MAAM,CAAC,CAAmB,EAAEC,KAAK,EAAe;IAEtE,MAAMC,mBAA8C,IAAI,CAACC,OAAO,CAACC,WAAW,CAACN,WAAW,CAACO,MAAM;IAE/F,MAAMC,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CAACb,YAAYO,iBAAiBO,IAAI;IAEzE,MAAM,EAAEC,IAAI,EAAE,GAAG,MAAMd,SAAS;QAC9Be,SAAS,IAAI;QACbC,QAAQV,iBAAiBU,MAAM;QAC/BC,OAAO;QACPd;QACAe,MAAM;QACNC,YAAY;QACZf;QACAgB,MAAMC;QACNX;QACAL;IACF;IAEA,OAAOS,MAAM,CAAC,EAAE,IAAI;AACtB"}
@@ -1,3 +1,3 @@
1
- import type { FindVersions } from 'payload/database';
1
+ import type { FindVersions } from 'payload';
2
2
  export declare const findVersions: FindVersions;
3
3
  //# sourceMappingURL=findVersions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"findVersions.d.ts","sourceRoot":"","sources":["../src/findVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAUpD,eAAO,MAAM,YAAY,EAAE,YAqC1B,CAAA"}
1
+ {"version":3,"file":"findVersions.d.ts","sourceRoot":"","sources":["../src/findVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAA6C,MAAM,SAAS,CAAA;AAStF,eAAO,MAAM,YAAY,EAAE,YAoC1B,CAAA"}
@@ -1,14 +1,10 @@
1
- import { buildVersionCollectionFields } from 'payload/versions';
1
+ import { buildVersionCollectionFields } from 'payload';
2
+ import toSnakeCase from 'to-snake-case';
2
3
  import { findMany } from './find/findMany.js';
3
- import { getTableName } from './schema/getTableName.js';
4
4
  export const findVersions = async function findVersions({ collection, limit, locale, page, pagination, req = {}, skip, sort: sortArg, where }) {
5
5
  const collectionConfig = this.payload.collections[collection].config;
6
6
  const sort = typeof sortArg === 'string' ? sortArg : collectionConfig.defaultSort;
7
- const tableName = getTableName({
8
- adapter: this,
9
- config: collectionConfig,
10
- versions: true
11
- });
7
+ const tableName = this.tableNameMap.get(`_${toSnakeCase(collectionConfig.slug)}${this.versionsSuffix}`);
12
8
  const fields = buildVersionCollectionFields(collectionConfig);
13
9
  return findMany({
14
10
  adapter: this,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/findVersions.ts"],"sourcesContent":["import type { FindVersions } from 'payload/database'\nimport type { PayloadRequest, SanitizedCollectionConfig } from 'payload/types'\n\nimport { buildVersionCollectionFields } from 'payload/versions'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\nimport { getTableName } from './schema/getTableName.js'\n\nexport const findVersions: FindVersions = async function findVersions(\n this: PostgresAdapter,\n {\n collection,\n limit,\n locale,\n page,\n pagination,\n req = {} as PayloadRequest,\n skip,\n sort: sortArg,\n where,\n },\n) {\n const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config\n const sort = typeof sortArg === 'string' ? sortArg : collectionConfig.defaultSort\n\n const tableName = getTableName({\n adapter: this,\n config: collectionConfig,\n versions: true,\n })\n const fields = buildVersionCollectionFields(collectionConfig)\n\n return findMany({\n adapter: this,\n fields,\n limit,\n locale,\n page,\n pagination,\n req,\n skip,\n sort,\n tableName,\n where,\n })\n}\n"],"names":["buildVersionCollectionFields","findMany","getTableName","findVersions","collection","limit","locale","page","pagination","req","skip","sort","sortArg","where","collectionConfig","payload","collections","config","defaultSort","tableName","adapter","versions","fields"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,4BAA4B,QAAQ,mBAAkB;AAI/D,SAASC,QAAQ,QAAQ,qBAAoB;AAC7C,SAASC,YAAY,QAAQ,2BAA0B;AAEvD,OAAO,MAAMC,eAA6B,eAAeA,aAEvD,EACEC,UAAU,EACVC,KAAK,EACLC,MAAM,EACNC,IAAI,EACJC,UAAU,EACVC,MAAM,CAAC,CAAmB,EAC1BC,IAAI,EACJC,MAAMC,OAAO,EACbC,KAAK,EACN;IAED,MAAMC,mBAA8C,IAAI,CAACC,OAAO,CAACC,WAAW,CAACZ,WAAW,CAACa,MAAM;IAC/F,MAAMN,OAAO,OAAOC,YAAY,WAAWA,UAAUE,iBAAiBI,WAAW;IAEjF,MAAMC,YAAYjB,aAAa;QAC7BkB,SAAS,IAAI;QACbH,QAAQH;QACRO,UAAU;IACZ;IACA,MAAMC,SAAStB,6BAA6Bc;IAE5C,OAAOb,SAAS;QACdmB,SAAS,IAAI;QACbE;QACAjB;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAQ;QACAN;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../src/findVersions.ts"],"sourcesContent":["import type { FindVersions, PayloadRequest, SanitizedCollectionConfig } from 'payload'\n\nimport { buildVersionCollectionFields } from 'payload'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\n\nexport const findVersions: FindVersions = async function findVersions(\n this: PostgresAdapter,\n {\n collection,\n limit,\n locale,\n page,\n pagination,\n req = {} as PayloadRequest,\n skip,\n sort: sortArg,\n where,\n },\n) {\n const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config\n const sort = typeof sortArg === 'string' ? sortArg : collectionConfig.defaultSort\n\n const tableName = this.tableNameMap.get(\n `_${toSnakeCase(collectionConfig.slug)}${this.versionsSuffix}`,\n )\n\n const fields = buildVersionCollectionFields(collectionConfig)\n\n return findMany({\n adapter: this,\n fields,\n limit,\n locale,\n page,\n pagination,\n req,\n skip,\n sort,\n tableName,\n where,\n })\n}\n"],"names":["buildVersionCollectionFields","toSnakeCase","findMany","findVersions","collection","limit","locale","page","pagination","req","skip","sort","sortArg","where","collectionConfig","payload","collections","config","defaultSort","tableName","tableNameMap","get","slug","versionsSuffix","fields","adapter"],"mappings":"AAEA,SAASA,4BAA4B,QAAQ,UAAS;AACtD,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,QAAQ,QAAQ,qBAAoB;AAE7C,OAAO,MAAMC,eAA6B,eAAeA,aAEvD,EACEC,UAAU,EACVC,KAAK,EACLC,MAAM,EACNC,IAAI,EACJC,UAAU,EACVC,MAAM,CAAC,CAAmB,EAC1BC,IAAI,EACJC,MAAMC,OAAO,EACbC,KAAK,EACN;IAED,MAAMC,mBAA8C,IAAI,CAACC,OAAO,CAACC,WAAW,CAACZ,WAAW,CAACa,MAAM;IAC/F,MAAMN,OAAO,OAAOC,YAAY,WAAWA,UAAUE,iBAAiBI,WAAW;IAEjF,MAAMC,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CACrC,CAAC,CAAC,EAAEpB,YAAYa,iBAAiBQ,IAAI,EAAE,EAAE,IAAI,CAACC,cAAc,CAAC,CAAC;IAGhE,MAAMC,SAASxB,6BAA6Bc;IAE5C,OAAOZ,SAAS;QACduB,SAAS,IAAI;QACbD;QACAnB;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAQ;QACAN;IACF;AACF,EAAC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { DatabaseAdapterObj } from 'payload/database';
1
+ import type { DatabaseAdapterObj } from 'payload';
2
2
  import type { Args, PostgresAdapter } from './types.js';
3
3
  export type { MigrateDownArgs, MigrateUpArgs } from './types.js';
4
4
  export { sql } from 'drizzle-orm';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAM1D,OAAO,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAiCvD,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAEhE,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAEjC,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,kBAAkB,CAAC,eAAe,CAAC,CAwE/E"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAW,MAAM,SAAS,CAAA;AAM1D,OAAO,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAkCvD,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAEhE,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAEjC,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,kBAAkB,CAAC,eAAe,CAAC,CAgF/E"}
package/dist/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
- import { createDatabaseAdapter } from 'payload/database';
3
+ import { createDatabaseAdapter } from 'payload';
4
4
  import { connect } from './connect.js';
5
+ import { count } from './count.js';
5
6
  import { create } from './create.js';
6
7
  import { createGlobal } from './createGlobal.js';
7
8
  import { createGlobalVersion } from './createGlobalVersion.js';
@@ -33,17 +34,23 @@ import { updateGlobalVersion } from './updateGlobalVersion.js';
33
34
  import { updateVersion } from './updateVersion.js';
34
35
  export { sql } from 'drizzle-orm';
35
36
  export function postgresAdapter(args) {
37
+ const postgresIDType = args.idType || 'serial';
38
+ const payloadIDType = postgresIDType === 'serial' ? 'number' : 'text';
36
39
  function adapter({ payload }) {
37
40
  const migrationDir = findMigrationDir(args.migrationDir);
38
- const idType = args.idType || 'serial';
41
+ let resolveInitializing;
42
+ let rejectInitializing;
43
+ const initializing = new Promise((res, rej)=>{
44
+ resolveInitializing = res;
45
+ rejectInitializing = rej;
46
+ });
39
47
  return createDatabaseAdapter({
40
48
  name: 'postgres',
41
- // Postgres-specific
42
- blockTableNames: {},
43
49
  drizzle: undefined,
44
50
  enums: {},
45
51
  fieldConstraints: {},
46
- idType,
52
+ idType: postgresIDType,
53
+ initializing,
47
54
  localesSuffix: args.localesSuffix || '_locales',
48
55
  logger: args.logger,
49
56
  pgSchema: undefined,
@@ -55,20 +62,20 @@ export function postgresAdapter(args) {
55
62
  schema: {},
56
63
  schemaName: args.schemaName,
57
64
  sessions: {},
65
+ tableNameMap: new Map(),
58
66
  tables: {},
59
67
  versionsSuffix: args.versionsSuffix || '_v',
60
68
  // DatabaseAdapter
61
69
  beginTransaction,
62
70
  commitTransaction,
63
71
  connect,
72
+ count,
64
73
  create,
65
74
  createGlobal,
66
75
  createGlobalVersion,
67
76
  createMigration,
68
77
  createVersion,
69
- /**
70
- * This represents how a default ID is treated in Payload as were a field type
71
- */ defaultIDType: idType === 'serial' ? 'number' : 'text',
78
+ defaultIDType: payloadIDType,
72
79
  deleteMany,
73
80
  deleteOne,
74
81
  deleteVersions,
@@ -88,6 +95,8 @@ export function postgresAdapter(args) {
88
95
  migrationDir,
89
96
  payload,
90
97
  queryDrafts,
98
+ rejectInitializing,
99
+ resolveInitializing,
91
100
  rollbackTransaction,
92
101
  updateGlobal,
93
102
  updateGlobalVersion,
@@ -96,7 +105,7 @@ export function postgresAdapter(args) {
96
105
  });
97
106
  }
98
107
  return {
99
- defaultIDType: 'number',
108
+ defaultIDType: payloadIDType,
100
109
  init: adapter
101
110
  };
102
111
  }
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Payload } from 'payload'\nimport type { DatabaseAdapterObj } from 'payload/database'\n\nimport fs from 'fs'\nimport path from 'path'\nimport { createDatabaseAdapter } from 'payload/database'\n\nimport type { Args, PostgresAdapter } from './types.js'\n\nimport { connect } from './connect.js'\nimport { create } from './create.js'\nimport { createGlobal } from './createGlobal.js'\nimport { createGlobalVersion } from './createGlobalVersion.js'\nimport { createMigration } from './createMigration.js'\nimport { createVersion } from './createVersion.js'\nimport { deleteMany } from './deleteMany.js'\nimport { deleteOne } from './deleteOne.js'\nimport { deleteVersions } from './deleteVersions.js'\nimport { destroy } from './destroy.js'\nimport { find } from './find.js'\nimport { findGlobal } from './findGlobal.js'\nimport { findGlobalVersions } from './findGlobalVersions.js'\nimport { findOne } from './findOne.js'\nimport { findVersions } from './findVersions.js'\nimport { init } from './init.js'\nimport { migrate } from './migrate.js'\nimport { migrateDown } from './migrateDown.js'\nimport { migrateFresh } from './migrateFresh.js'\nimport { migrateRefresh } from './migrateRefresh.js'\nimport { migrateReset } from './migrateReset.js'\nimport { migrateStatus } from './migrateStatus.js'\nimport { queryDrafts } from './queryDrafts.js'\nimport { beginTransaction } from './transactions/beginTransaction.js'\nimport { commitTransaction } from './transactions/commitTransaction.js'\nimport { rollbackTransaction } from './transactions/rollbackTransaction.js'\nimport { updateOne } from './update.js'\nimport { updateGlobal } from './updateGlobal.js'\nimport { updateGlobalVersion } from './updateGlobalVersion.js'\nimport { updateVersion } from './updateVersion.js'\n\nexport type { MigrateDownArgs, MigrateUpArgs } from './types.js'\n\nexport { sql } from 'drizzle-orm'\n\nexport function postgresAdapter(args: Args): DatabaseAdapterObj<PostgresAdapter> {\n function adapter({ payload }: { payload: Payload }) {\n const migrationDir = findMigrationDir(args.migrationDir)\n const idType = args.idType || 'serial'\n\n return createDatabaseAdapter<PostgresAdapter>({\n name: 'postgres',\n\n // Postgres-specific\n blockTableNames: {},\n drizzle: undefined,\n enums: {},\n fieldConstraints: {},\n idType,\n localesSuffix: args.localesSuffix || '_locales',\n logger: args.logger,\n pgSchema: undefined,\n pool: undefined,\n poolOptions: args.pool,\n push: args.push,\n relations: {},\n relationshipsSuffix: args.relationshipsSuffix || '_rels',\n schema: {},\n schemaName: args.schemaName,\n sessions: {},\n tables: {},\n versionsSuffix: args.versionsSuffix || '_v',\n\n // DatabaseAdapter\n beginTransaction,\n commitTransaction,\n connect,\n create,\n createGlobal,\n createGlobalVersion,\n createMigration,\n createVersion,\n /**\n * This represents how a default ID is treated in Payload as were a field type\n */\n defaultIDType: idType === 'serial' ? 'number' : 'text',\n deleteMany,\n deleteOne,\n deleteVersions,\n destroy,\n find,\n findGlobal,\n findGlobalVersions,\n findOne,\n findVersions,\n init,\n migrate,\n migrateDown,\n migrateFresh,\n migrateRefresh,\n migrateReset,\n migrateStatus,\n migrationDir,\n payload,\n queryDrafts,\n rollbackTransaction,\n updateGlobal,\n updateGlobalVersion,\n updateOne,\n updateVersion,\n })\n }\n\n return {\n defaultIDType: 'number',\n init: adapter,\n }\n}\n\n/**\n * Attempt to find migrations directory.\n *\n * Checks for the following directories in order:\n * - `migrationDir` argument from Payload config\n * - `src/migrations`\n * - `dist/migrations`\n * - `migrations`\n *\n * Defaults to `src/migrations`\n *\n * @param migrationDir\n * @returns\n */\nfunction findMigrationDir(migrationDir?: string): string {\n const cwd = process.cwd()\n const srcDir = path.resolve(cwd, 'src/migrations')\n const distDir = path.resolve(cwd, 'dist/migrations')\n const relativeMigrations = path.resolve(cwd, 'migrations')\n\n // Use arg if provided\n if (migrationDir) return migrationDir\n\n // Check other common locations\n if (fs.existsSync(srcDir)) {\n return srcDir\n }\n\n if (fs.existsSync(distDir)) {\n return distDir\n }\n\n if (fs.existsSync(relativeMigrations)) {\n return relativeMigrations\n }\n\n return srcDir\n}\n"],"names":["fs","path","createDatabaseAdapter","connect","create","createGlobal","createGlobalVersion","createMigration","createVersion","deleteMany","deleteOne","deleteVersions","destroy","find","findGlobal","findGlobalVersions","findOne","findVersions","init","migrate","migrateDown","migrateFresh","migrateRefresh","migrateReset","migrateStatus","queryDrafts","beginTransaction","commitTransaction","rollbackTransaction","updateOne","updateGlobal","updateGlobalVersion","updateVersion","sql","postgresAdapter","args","adapter","payload","migrationDir","findMigrationDir","idType","name","blockTableNames","drizzle","undefined","enums","fieldConstraints","localesSuffix","logger","pgSchema","pool","poolOptions","push","relations","relationshipsSuffix","schema","schemaName","sessions","tables","versionsSuffix","defaultIDType","cwd","process","srcDir","resolve","distDir","relativeMigrations","existsSync"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,OAAOA,QAAQ,KAAI;AACnB,OAAOC,UAAU,OAAM;AACvB,SAASC,qBAAqB,QAAQ,mBAAkB;AAIxD,SAASC,OAAO,QAAQ,eAAc;AACtC,SAASC,MAAM,QAAQ,cAAa;AACpC,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,UAAU,QAAQ,kBAAiB;AAC5C,SAASC,SAAS,QAAQ,iBAAgB;AAC1C,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,OAAO,QAAQ,eAAc;AACtC,SAASC,IAAI,QAAQ,YAAW;AAChC,SAASC,UAAU,QAAQ,kBAAiB;AAC5C,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,OAAO,QAAQ,eAAc;AACtC,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,IAAI,QAAQ,YAAW;AAChC,SAASC,OAAO,QAAQ,eAAc;AACtC,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,SAASC,gBAAgB,QAAQ,qCAAoC;AACrE,SAASC,iBAAiB,QAAQ,sCAAqC;AACvE,SAASC,mBAAmB,QAAQ,wCA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D,OAAO,CAACH,KAAK;IACjC,MAAMI,UAAUhE,KAAK+D,OAAO,CAACH,KAAK;IAClC,MAAMK,qBAAqBjE,KAAK+D,OAAO,CAACH,KAAK;IAE7C,sBAAsB;IACtB,IAAIvB,cAAc,OAAOA;IAEzB,+BAA+B;IAC/B,IAAItC,GAAGmE,UAAU,CAACJ,SAAS;QACzB,OAAOA;IACT;IAEA,IAAI/D,GAAGmE,UAAU,CAACF,UAAU;QAC1B,OAAOA;IACT;IAEA,IAAIjE,GAAGmE,UAAU,CAACD,qBAAqB;QACrC,OAAOA;IACT;IAEA,OAAOH;AACT"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { DatabaseAdapterObj, Payload } from 'payload'\n\nimport fs from 'fs'\nimport path from 'path'\nimport { createDatabaseAdapter } from 'payload'\n\nimport type { Args, PostgresAdapter } from './types.js'\n\nimport { connect } from './connect.js'\nimport { count } from './count.js'\nimport { create } from './create.js'\nimport { createGlobal } from './createGlobal.js'\nimport { createGlobalVersion } from './createGlobalVersion.js'\nimport { createMigration } from './createMigration.js'\nimport { createVersion } from './createVersion.js'\nimport { deleteMany } from './deleteMany.js'\nimport { deleteOne } from './deleteOne.js'\nimport { deleteVersions } from './deleteVersions.js'\nimport { destroy } from './destroy.js'\nimport { find } from './find.js'\nimport { findGlobal } from './findGlobal.js'\nimport { findGlobalVersions } from './findGlobalVersions.js'\nimport { findOne } from './findOne.js'\nimport { findVersions } from './findVersions.js'\nimport { init } from './init.js'\nimport { migrate } from './migrate.js'\nimport { migrateDown } from './migrateDown.js'\nimport { migrateFresh } from './migrateFresh.js'\nimport { migrateRefresh } from './migrateRefresh.js'\nimport { migrateReset } from './migrateReset.js'\nimport { migrateStatus } from './migrateStatus.js'\nimport { queryDrafts } from './queryDrafts.js'\nimport { beginTransaction } from './transactions/beginTransaction.js'\nimport { commitTransaction } from './transactions/commitTransaction.js'\nimport { rollbackTransaction } from './transactions/rollbackTransaction.js'\nimport { updateOne } from './update.js'\nimport { updateGlobal } from './updateGlobal.js'\nimport { updateGlobalVersion } from './updateGlobalVersion.js'\nimport { updateVersion } from './updateVersion.js'\n\nexport type { MigrateDownArgs, MigrateUpArgs } from './types.js'\n\nexport { sql } from 'drizzle-orm'\n\nexport function postgresAdapter(args: Args): DatabaseAdapterObj<PostgresAdapter> {\n const postgresIDType = args.idType || 'serial'\n const payloadIDType = postgresIDType === 'serial' ? 'number' : 'text'\n\n function adapter({ payload }: { payload: Payload }) {\n const migrationDir = findMigrationDir(args.migrationDir)\n let resolveInitializing\n let rejectInitializing\n\n const initializing = new Promise<void>((res, rej) => {\n resolveInitializing = res\n rejectInitializing = rej\n })\n\n return createDatabaseAdapter<PostgresAdapter>({\n name: 'postgres',\n drizzle: undefined,\n enums: {},\n fieldConstraints: {},\n idType: postgresIDType,\n initializing,\n localesSuffix: args.localesSuffix || '_locales',\n logger: args.logger,\n pgSchema: undefined,\n pool: undefined,\n poolOptions: args.pool,\n push: args.push,\n relations: {},\n relationshipsSuffix: args.relationshipsSuffix || '_rels',\n schema: {},\n schemaName: args.schemaName,\n sessions: {},\n tableNameMap: new Map<string, string>(),\n tables: {},\n versionsSuffix: args.versionsSuffix || '_v',\n\n // DatabaseAdapter\n beginTransaction,\n commitTransaction,\n connect,\n count,\n create,\n createGlobal,\n createGlobalVersion,\n createMigration,\n createVersion,\n defaultIDType: payloadIDType,\n deleteMany,\n deleteOne,\n deleteVersions,\n destroy,\n find,\n findGlobal,\n findGlobalVersions,\n findOne,\n findVersions,\n init,\n migrate,\n migrateDown,\n migrateFresh,\n migrateRefresh,\n migrateReset,\n migrateStatus,\n migrationDir,\n payload,\n queryDrafts,\n rejectInitializing,\n resolveInitializing,\n rollbackTransaction,\n updateGlobal,\n updateGlobalVersion,\n updateOne,\n updateVersion,\n })\n }\n\n return {\n defaultIDType: payloadIDType,\n init: adapter,\n }\n}\n\n/**\n * Attempt to find migrations directory.\n *\n * Checks for the following directories in order:\n * - `migrationDir` argument from Payload config\n * - `src/migrations`\n * - `dist/migrations`\n * - `migrations`\n *\n * Defaults to `src/migrations`\n *\n * @param migrationDir\n * @returns\n */\nfunction findMigrationDir(migrationDir?: string): string {\n const cwd = process.cwd()\n const srcDir = path.resolve(cwd, 'src/migrations')\n const distDir = path.resolve(cwd, 'dist/migrations')\n const relativeMigrations = path.resolve(cwd, 'migrations')\n\n // Use arg if provided\n if (migrationDir) return migrationDir\n\n // Check other common locations\n if (fs.existsSync(srcDir)) {\n return srcDir\n }\n\n if (fs.existsSync(distDir)) {\n return distDir\n }\n\n if (fs.existsSync(relativeMigrations)) {\n return relativeMigrations\n }\n\n return srcDir\n}\n"],"names":["fs","path","createDatabaseAdapter","connect","count","create","createGlobal","createGlobalVersion","createMigration","createVersion","deleteMany","deleteOne","deleteVersions","destroy","find","findGlobal","findGlobalVersions","findOne","findVersions","init","migrate","migrateDown","migrateFresh","migrateRefresh","migrateReset","migrateStatus","queryDrafts","beginTransaction","commitTransaction","rollbackTransaction","updateOne","updateGlobal","updateGlobalVersion","updateVersion","sql","postgresAdapter","args","postgresIDType","idType","payloadIDType","adapter","payload","migrationDir","findMigrationDir","resolveInitializing","rejectInitializing","initializing","Promise","res","rej","name","drizzle","undefined","enums","fieldConstraints","localesSuffix","logger","pgSchema","pool","poolOptions","push","relations","relationshipsSuffix","schema","schemaName","sessions","tableNameMap","Map","tables","versionsSuffix","defaultIDType","cwd","process","srcDir","resolve","distDir","relativeMigrations","existsSync"],"mappings":"AAEA,OAAOA,QAAQ,KAAI;AACnB,OAAOC,UAAU,OAAM;AACvB,SAASC,qBAAqB,QAAQ,UAAS;AAI/C,SAASC,OAAO,QAAQ,eAAc;AACtC,SAASC,KAAK,QAAQ,aAAY;AAClC,SAASC,MAAM,QAAQ,cAAa;AACpC,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,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@@
1
- import type { Init } from 'payload/database';
1
+ import type { Init } from 'payload';
2
2
  export declare const init: Init;
3
3
  //# sourceMappingURL=init.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAW5C,eAAO,MAAM,IAAI,EAAE,IA0FlB,CAAA"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAWnC,eAAO,MAAM,IAAI,EAAE,IA6FlB,CAAA"}
package/dist/init.js CHANGED
@@ -1,7 +1,8 @@
1
1
  /* eslint-disable no-param-reassign */ import { pgEnum, pgSchema, pgTable } from 'drizzle-orm/pg-core';
2
- import { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload/versions';
2
+ import { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload';
3
+ import toSnakeCase from 'to-snake-case';
3
4
  import { buildTable } from './schema/build.js';
4
- import { getTableName } from './schema/getTableName.js';
5
+ import { createTableName } from './schema/createTableName.js';
5
6
  export const init = function init() {
6
7
  if (this.schemaName) {
7
8
  this.pgSchema = pgSchema(this.schemaName);
@@ -14,15 +15,23 @@ export const init = function init() {
14
15
  this.enums.enum__locales = pgEnum('_locales', this.payload.config.localization.locales.map(({ code })=>code));
15
16
  }
16
17
  this.payload.config.collections.forEach((collection)=>{
17
- const tableName = getTableName({
18
+ createTableName({
18
19
  adapter: this,
19
20
  config: collection
20
21
  });
22
+ if (collection.versions) {
23
+ createTableName({
24
+ adapter: this,
25
+ config: collection,
26
+ versions: true,
27
+ versionsCustomName: true
28
+ });
29
+ }
30
+ });
31
+ this.payload.config.collections.forEach((collection)=>{
32
+ const tableName = this.tableNameMap.get(toSnakeCase(collection.slug));
21
33
  buildTable({
22
34
  adapter: this,
23
- buildNumbers: true,
24
- buildRelationships: true,
25
- buildTexts: true,
26
35
  disableNotNull: !!collection?.versions?.drafts,
27
36
  disableUnique: false,
28
37
  fields: collection.fields,
@@ -31,17 +40,10 @@ export const init = function init() {
31
40
  versions: false
32
41
  });
33
42
  if (collection.versions) {
34
- const versionsTableName = getTableName({
35
- adapter: this,
36
- config: collection,
37
- versions: true
38
- });
43
+ const versionsTableName = this.tableNameMap.get(`_${toSnakeCase(collection.slug)}${this.versionsSuffix}`);
39
44
  const versionFields = buildVersionCollectionFields(collection);
40
45
  buildTable({
41
46
  adapter: this,
42
- buildNumbers: true,
43
- buildRelationships: true,
44
- buildTexts: true,
45
47
  disableNotNull: !!collection.versions?.drafts,
46
48
  disableUnique: true,
47
49
  fields: versionFields,
@@ -52,15 +54,12 @@ export const init = function init() {
52
54
  }
53
55
  });
54
56
  this.payload.config.globals.forEach((global)=>{
55
- const tableName = getTableName({
57
+ const tableName = createTableName({
56
58
  adapter: this,
57
59
  config: global
58
60
  });
59
61
  buildTable({
60
62
  adapter: this,
61
- buildNumbers: true,
62
- buildRelationships: true,
63
- buildTexts: true,
64
63
  disableNotNull: !!global?.versions?.drafts,
65
64
  disableUnique: false,
66
65
  fields: global.fields,
@@ -69,17 +68,15 @@ export const init = function init() {
69
68
  versions: false
70
69
  });
71
70
  if (global.versions) {
72
- const versionsTableName = getTableName({
71
+ const versionsTableName = createTableName({
73
72
  adapter: this,
74
73
  config: global,
75
- versions: true
74
+ versions: true,
75
+ versionsCustomName: true
76
76
  });
77
77
  const versionFields = buildVersionGlobalFields(global);
78
78
  buildTable({
79
79
  adapter: this,
80
- buildNumbers: true,
81
- buildRelationships: true,
82
- buildTexts: true,
83
80
  disableNotNull: !!global.versions?.drafts,
84
81
  disableUnique: true,
85
82
  fields: versionFields,
package/dist/init.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/init.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { Init } from 'payload/database'\nimport type { SanitizedCollectionConfig } from 'payload/types'\n\nimport { pgEnum, pgSchema, pgTable } from 'drizzle-orm/pg-core'\nimport { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload/versions'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { buildTable } from './schema/build.js'\nimport { getTableName } from './schema/getTableName.js'\n\nexport const init: Init = function init(this: PostgresAdapter) {\n if (this.schemaName) {\n this.pgSchema = pgSchema(this.schemaName)\n } else {\n this.pgSchema = { table: pgTable }\n }\n\n if (this.payload.config.localization) {\n this.enums.enum__locales = pgEnum(\n '_locales',\n this.payload.config.localization.locales.map(({ code }) => code) as [string, ...string[]],\n )\n }\n\n this.payload.config.collections.forEach((collection: SanitizedCollectionConfig) => {\n const tableName = getTableName({\n adapter: this,\n config: collection,\n })\n\n buildTable({\n adapter: this,\n buildNumbers: true,\n buildRelationships: true,\n buildTexts: true,\n disableNotNull: !!collection?.versions?.drafts,\n disableUnique: false,\n fields: collection.fields,\n tableName,\n timestamps: collection.timestamps,\n versions: false,\n })\n\n if (collection.versions) {\n const versionsTableName = getTableName({\n adapter: this,\n config: collection,\n versions: true,\n })\n const versionFields = buildVersionCollectionFields(collection)\n\n buildTable({\n adapter: this,\n buildNumbers: true,\n buildRelationships: true,\n buildTexts: true,\n disableNotNull: !!collection.versions?.drafts,\n disableUnique: true,\n fields: versionFields,\n tableName: versionsTableName,\n timestamps: true,\n versions: true,\n })\n }\n })\n\n this.payload.config.globals.forEach((global) => {\n const tableName = getTableName({ adapter: this, config: global })\n\n buildTable({\n adapter: this,\n buildNumbers: true,\n buildRelationships: true,\n buildTexts: true,\n disableNotNull: !!global?.versions?.drafts,\n disableUnique: false,\n fields: global.fields,\n tableName,\n timestamps: false,\n versions: false,\n })\n\n if (global.versions) {\n const versionsTableName = getTableName({ adapter: this, config: global, versions: true })\n const versionFields = buildVersionGlobalFields(global)\n\n buildTable({\n adapter: this,\n buildNumbers: true,\n buildRelationships: true,\n buildTexts: true,\n disableNotNull: !!global.versions?.drafts,\n disableUnique: true,\n fields: versionFields,\n tableName: versionsTableName,\n timestamps: true,\n versions: true,\n })\n }\n })\n}\n"],"names":["pgEnum","pgSchema","pgTable","buildVersionCollectionFields","buildVersionGlobalFields","buildTable","getTableName","init","schemaName","table","payload","config","localization","enums","enum__locales","locales","map","code","collections","forEach","collection","tableName","adapter","buildNumbers","buildRelationships","buildTexts","disableNotNull","versions","drafts","disableUnique","fields","timestamps","versionsTableName","versionFields","globals","global"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,oCAAoC,GAIpC,SAASA,MAAM,EAAEC,QAAQ,EAAEC,OAAO,QAAQ,sBAAqB;AAC/D,SAASC,4BAA4B,EAAEC,wBAAwB,QAAQ,mBAAkB;AAIzF,SAASC,UAAU,QAAQ,oBAAmB;AAC9C,SAASC,YAAY,QAAQ,2BAA0B;AAEvD,OAAO,MAAMC,OAAa,SAASA;IACjC,IAAI,IAAI,CAACC,UAAU,EAAE;QACnB,IAAI,CAACP,QAAQ,GAAGA,SAAS,IAAI,CAACO,UAAU;IAC1C,OAAO;QACL,IAAI,CAACP,QAAQ,GAAG;YAAEQ,OAAOP;QAAQ;IACnC;IAEA,IAAI,IAAI,CAACQ,OAAO,CAACC,MAAM,CAACC,YAAY,EAAE;QACpC,IAAI,CAACC,KAAK,CAACC,aAAa,GAAGd,OACzB,YACA,IAAI,CAACU,OAAO,CAACC,MAAM,CAACC,YAAY,CAACG,OAAO,CAACC,GAAG,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKA;IAE/D;IAEA,IAAI,CAACP,OAAO,CAACC,MAAM,CAACO,WAAW,CAACC,OAAO,CAAC,CAACC;QACvC,MAAMC,YAAYf,aAAa;YAC7BgB,SAAS,IAAI;YACbX,QAAQS;QACV;QAEAf,WAAW;YACTiB,SAAS,IAAI;YACbC,cAAc;YACdC,oBAAoB;YACpBC,Y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}
1
+ {"version":3,"sources":["../src/init.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { SanitizedCollectionConfig } from 'payload'\nimport type { Init } from 'payload'\n\nimport { pgEnum, pgSchema, pgTable } from 'drizzle-orm/pg-core'\nimport { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { buildTable } from './schema/build.js'\nimport { createTableName } from './schema/createTableName.js'\n\nexport const init: Init = function init(this: PostgresAdapter) {\n if (this.schemaName) {\n this.pgSchema = pgSchema(this.schemaName)\n } else {\n this.pgSchema = { table: pgTable }\n }\n\n if (this.payload.config.localization) {\n this.enums.enum__locales = pgEnum(\n '_locales',\n this.payload.config.localization.locales.map(({ code }) => code) as [string, ...string[]],\n )\n }\n\n this.payload.config.collections.forEach((collection: SanitizedCollectionConfig) => {\n createTableName({\n adapter: this,\n config: collection,\n })\n\n if (collection.versions) {\n createTableName({\n adapter: this,\n config: collection,\n versions: true,\n versionsCustomName: true,\n })\n }\n })\n this.payload.config.collections.forEach((collection: SanitizedCollectionConfig) => {\n const tableName = this.tableNameMap.get(toSnakeCase(collection.slug))\n\n buildTable({\n adapter: this,\n disableNotNull: !!collection?.versions?.drafts,\n disableUnique: false,\n fields: collection.fields,\n tableName,\n timestamps: collection.timestamps,\n versions: false,\n })\n\n if (collection.versions) {\n const versionsTableName = this.tableNameMap.get(\n `_${toSnakeCase(collection.slug)}${this.versionsSuffix}`,\n )\n const versionFields = buildVersionCollectionFields(collection)\n\n buildTable({\n adapter: this,\n disableNotNull: !!collection.versions?.drafts,\n disableUnique: true,\n fields: versionFields,\n tableName: versionsTableName,\n timestamps: true,\n versions: true,\n })\n }\n })\n\n this.payload.config.globals.forEach((global) => {\n const tableName = createTableName({ adapter: this, config: global })\n\n buildTable({\n adapter: this,\n disableNotNull: !!global?.versions?.drafts,\n disableUnique: false,\n fields: global.fields,\n tableName,\n timestamps: false,\n versions: false,\n })\n\n if (global.versions) {\n const versionsTableName = createTableName({\n adapter: this,\n config: global,\n versions: true,\n versionsCustomName: true,\n })\n const versionFields = buildVersionGlobalFields(global)\n\n buildTable({\n adapter: this,\n disableNotNull: !!global.versions?.drafts,\n disableUnique: true,\n fields: versionFields,\n tableName: versionsTableName,\n timestamps: true,\n versions: true,\n })\n }\n })\n}\n"],"names":["pgEnum","pgSchema","pgTable","buildVersionCollectionFields","buildVersionGlobalFields","toSnakeCase","buildTable","createTableName","init","schemaName","table","payload","config","localization","enums","enum__locales","locales","map","code","collections","forEach","collection","adapter","versions","versionsCustomName","tableName","tableNameMap","get","slug","disableNotNull","drafts","disableUnique","fields","timestamps","versionsTableName","versionsSuffix","versionFields","globals","global"],"mappings":"AAAA,oCAAoC,GAIpC,SAASA,MAAM,EAAEC,QAAQ,EAAEC,OAAO,QAAQ,sBAAqB;AAC/D,SAASC,4BAA4B,EAAEC,wBAAwB,QAAQ,UAAS;AAChF,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,UAAU,QAAQ,oBAAmB;AAC9C,SAASC,eAAe,QAAQ,8BAA6B;AAE7D,OAAO,MAAMC,OAAa,SAASA;IACjC,IAAI,IAAI,CAACC,UAAU,EAAE;QACnB,IAAI,CAACR,QAAQ,GAAGA,SAAS,IAAI,CAACQ,UAAU;IAC1C,OAAO;QACL,IAAI,CAACR,QAAQ,GAAG;YAAES,OAAOR;QAAQ;IACnC;IAEA,IAAI,IAAI,CAACS,OAAO,CAACC,MAAM,CAACC,YAAY,EAAE;QACpC,IAAI,CAACC,KAAK,CAACC,aAAa,GAAGf,OACzB,YACA,IAAI,CAACW,OAAO,CAACC,MAAM,CAACC,YAAY,CAACG,OAAO,CAACC,GAAG,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKA;IAE/D;IAEA,IAAI,CAACP,OAAO,CAACC,MAAM,CAACO,WAAW,CAACC,OAAO,CAAC,CAACC;QACvCd,gBAAgB;YACde,SAAS,IAAI;YACbV,QAAQS;QACV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0B;gBACRf,UAAU;gBACVC,oBAAoB;YACtB;YACA,MAAMY,gBAAgBhC,yBAAyBkC;YAE/ChC,WAAW;gBACTgB,SAAS,IAAI;gBACbO,gBAAgB,CAAC,CAACS,OAAOf,QAAQ,EAAEO;gBACnCC,eAAe;gBACfC,QAAQI;gBACRX,WAAWS;gBACXD,YAAY;gBACZV,UAAU;YACZ;QACF;IACF;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../src/migrate.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAQjD,wBAAsB,OAAO,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CA8DlE"}
1
+ {"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../src/migrate.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAQjD,wBAAsB,OAAO,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CA8DlE"}
package/dist/migrate.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable no-restricted-syntax, no-await-in-loop */ import { createRequire } from 'module';
2
- import { commitTransaction, initTransaction, killTransaction, readMigrationFiles } from 'payload/database';
2
+ import { commitTransaction, initTransaction, killTransaction, readMigrationFiles } from 'payload';
3
3
  import prompts from 'prompts';
4
4
  import { createMigrationTable } from './utilities/createMigrationTable.js';
5
5
  import { migrationTableExists } from './utilities/migrationTableExists.js';