@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
package/package.json CHANGED
@@ -1,22 +1,39 @@
1
1
  {
2
2
  "name": "@payloadcms/db-postgres",
3
- "version": "3.0.0-beta.6",
3
+ "version": "3.0.0-beta.61",
4
4
  "description": "The officially supported Postgres database adapter for Payload",
5
+ "homepage": "https://payloadcms.com",
5
6
  "repository": {
6
7
  "type": "git",
7
8
  "url": "https://github.com/payloadcms/payload.git",
8
9
  "directory": "packages/db-postgres"
9
10
  },
10
11
  "license": "MIT",
11
- "homepage": "https://payloadcms.com",
12
+ "author": "Payload <dev@payloadcms.com> (https://payloadcms.com)",
12
13
  "type": "module",
13
- "author": {
14
- "email": "info@payloadcms.com",
15
- "name": "Payload",
16
- "url": "https://payloadcms.com"
14
+ "exports": {
15
+ ".": {
16
+ "import": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
18
+ "default": "./dist/index.js"
19
+ },
20
+ "./types": {
21
+ "import": "./dist/types.js",
22
+ "types": "./dist/types.d.ts",
23
+ "default": "./dist/types.js"
24
+ },
25
+ "./migration-utils": {
26
+ "import": "./dist/exports/migration-utils.js",
27
+ "types": "./dist/exports/migration-utils.d.ts",
28
+ "default": "./dist/exports/migration-utils.js"
29
+ }
17
30
  },
18
31
  "main": "./dist/index.js",
19
32
  "types": "./dist/index.d.ts",
33
+ "files": [
34
+ "dist",
35
+ "mock.js"
36
+ ],
20
37
  "dependencies": {
21
38
  "@libsql/client": "^0.5.2",
22
39
  "console-table-printer": "2.11.2",
@@ -25,37 +42,25 @@
25
42
  "pg": "8.11.3",
26
43
  "prompts": "2.4.2",
27
44
  "to-snake-case": "1.0.0",
28
- "uuid": "9.0.0"
45
+ "uuid": "10.0.0"
29
46
  },
30
47
  "devDependencies": {
48
+ "@hyrious/esbuild-plugin-commonjs": "^0.2.4",
31
49
  "@types/pg": "8.10.2",
32
50
  "@types/to-snake-case": "1.0.0",
33
- "payload": "3.0.0-beta.6",
34
- "@payloadcms/eslint-config": "1.1.1"
51
+ "esbuild": "0.23.0",
52
+ "@payloadcms/eslint-config": "3.0.0-beta.59",
53
+ "payload": "3.0.0-beta.61"
35
54
  },
36
55
  "peerDependencies": {
37
- "payload": "3.0.0-beta.6"
56
+ "payload": "3.0.0-beta.61"
38
57
  },
39
- "exports": {
40
- ".": {
41
- "import": "./dist/index.js",
42
- "require": "./dist/index.js",
43
- "types": "./dist/index.d.ts"
44
- },
45
- "./types": {
46
- "import": "./dist/types.js",
47
- "require": "./dist/types.js",
48
- "types": "./dist/types.d.ts"
49
- }
50
- },
51
- "files": [
52
- "dist",
53
- "mock.js"
54
- ],
55
58
  "scripts": {
56
- "build": "pnpm build:swc && pnpm build:types",
57
- "build:swc": "swc ./src -d ./dist --config-file .swcrc",
59
+ "build": "rimraf .dist && rimraf tsconfig.tsbuildinfo && pnpm build:types && pnpm build:swc && pnpm build:esbuild && pnpm renamePredefinedMigrations",
60
+ "build:esbuild": "echo skipping esbuild",
61
+ "build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
58
62
  "build:types": "tsc --emitDeclarationOnly --outDir dist",
59
- "clean": "rimraf {dist,*.tsbuildinfo}"
63
+ "clean": "rimraf {dist,*.tsbuildinfo}",
64
+ "renamePredefinedMigrations": "tsx ./scripts/renamePredefinedMigrations.ts"
60
65
  }
61
66
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"getTableName.d.ts","sourceRoot":"","sources":["../../src/schema/getTableName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAKxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAElD,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,eAAe,CAAA;IACxB,8CAA8C;IAC9C,MAAM,EAAE;QACN,MAAM,CAAC,EAAE,gBAAgB,CAAA;QACzB,QAAQ,CAAC,EAAE,gBAAgB,CAAA;QAC3B,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,IAAI,CAAC,EAAE,MAAM,CAAA;KACd,CAAA;IACD,2DAA2D;IAC3D,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,mGAAmG;IACnG,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,mFAAmF;IACnF,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,oCAAoC;IACpC,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,uHAAuH;IACvH,MAAM,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAA;IAC9B,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,kGAAkG;IAClG,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,0IAWtB,IAAI,KAAG,MA4BT,CAAA"}
@@ -1,31 +0,0 @@
1
- import { APIError } from 'payload/errors';
2
- import toSnakeCase from 'to-snake-case';
3
- /**
4
- * Used to name database enums and tables
5
- * Returns the table or enum name for a given entity
6
- */ export const getTableName = ({ adapter, config: { name, slug }, config, locales = false, parentTableName, prefix = '', relationships = false, target = 'dbName', throwValidationError = false, versions = false })=>{
7
- let result;
8
- let custom = config[target];
9
- if (!custom && target === 'enumName') {
10
- custom = config['dbName'];
11
- }
12
- if (custom) {
13
- result = typeof custom === 'function' ? custom({
14
- tableName: parentTableName
15
- }) : custom;
16
- } else {
17
- result = `${prefix}${toSnakeCase(name ?? slug)}`;
18
- }
19
- if (locales) result = `${result}${adapter.localesSuffix}`;
20
- if (versions) result = `_${result}${adapter.versionsSuffix}`;
21
- if (relationships) result = `${result}${adapter.relationshipsSuffix}`;
22
- if (!throwValidationError) {
23
- return result;
24
- }
25
- if (result.length > 63) {
26
- throw new APIError(`Exceeded max identifier length for table or enum name of 63 characters. Invalid name: ${result}`);
27
- }
28
- return result;
29
- };
30
-
31
- //# sourceMappingURL=getTableName.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/schema/getTableName.ts"],"sourcesContent":["import type { DBIdentifierName } from 'payload/database'\n\nimport { APIError } from 'payload/errors'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from '../types.js'\n\ntype Args = {\n adapter: PostgresAdapter\n /** The collection, global or field config **/\n config: {\n dbName?: DBIdentifierName\n enumName?: DBIdentifierName\n name?: string\n slug?: string\n }\n /** Localized tables need to be given the locales suffix */\n locales?: boolean\n /** For nested tables passed for the user custom dbName functions to handle their own iterations */\n parentTableName?: string\n /** For sub tables (array for example) this needs to include the parentTableName */\n prefix?: string\n /** Adds the relationships suffix */\n relationships?: boolean\n /** For tables based on fields that could have both enumName and dbName (ie: select with hasMany), default: 'dbName' */\n target?: 'dbName' | 'enumName'\n throwValidationError?: boolean\n /** Adds the versions suffix, should only be used on the base collection to duplicate suffixing */\n versions?: boolean\n}\n\n/**\n * Used to name database enums and tables\n * Returns the table or enum name for a given entity\n */\nexport const getTableName = ({\n adapter,\n config: { name, slug },\n config,\n locales = false,\n parentTableName,\n prefix = '',\n relationships = false,\n target = 'dbName',\n throwValidationError = false,\n versions = false,\n}: Args): string => {\n let result: string\n let custom = config[target]\n\n if (!custom && target === 'enumName') {\n custom = config['dbName']\n }\n\n if (custom) {\n result = typeof custom === 'function' ? custom({ tableName: parentTableName }) : custom\n } else {\n result = `${prefix}${toSnakeCase(name ?? slug)}`\n }\n\n if (locales) result = `${result}${adapter.localesSuffix}`\n if (versions) result = `_${result}${adapter.versionsSuffix}`\n if (relationships) result = `${result}${adapter.relationshipsSuffix}`\n\n if (!throwValidationError) {\n return result\n }\n\n if (result.length > 63) {\n throw new APIError(\n `Exceeded max identifier length for table or enum name of 63 characters. Invalid name: ${result}`,\n )\n }\n return result\n}\n"],"names":["APIError","toSnakeCase","getTableName","adapter","config","name","slug","locales","parentTableName","prefix","relationships","target","throwValidationError","versions","result","custom","tableName","localesSuffix","versionsSuffix","relationshipsSuffix","length"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,QAAQ,QAAQ,iBAAgB;AACzC,OAAOC,iBAAiB,gBAAe;AA4BvC;;;CAGC,GACD,OAAO,MAAMC,eAAe,CAAC,EAC3BC,OAAO,EACPC,QAAQ,EAAEC,IAAI,EAAEC,IAAI,EAAE,EACtBF,MAAM,EACNG,UAAU,KAAK,EACfC,eAAe,EACfC,SAAS,EAAE,EACXC,gBAAgB,KAAK,EACrBC,SAAS,QAAQ,EACjBC,uBAAuB,KAAK,EAC5BC,WAAW,KAAK,EACX;IACL,IAAIC;IACJ,IAAIC,SAASX,MAAM,CAACO,OAAO;IAE3B,IAAI,CAACI,UAAUJ,WAAW,YAAY;QACpCI,SAASX,MAAM,CAAC,SAAS;IAC3B;IAEA,IAAIW,QAAQ;QACVD,SAAS,OAAOC,WAAW,aAAaA,OAAO;YAAEC,WAAWR;QAAgB,KAAKO;IACnF,OAAO;QACLD,SAAS,CAAC,EAAEL,OAAO,EAAER,YAAYI,QAAQC,MAAM,CAAC;IAClD;IAEA,IAAIC,SAASO,SAAS,CAAC,EAAEA,OAAO,EAAEX,QAAQc,aAAa,CAAC,CAAC;IACzD,IAAIJ,UAAUC,SAAS,CAAC,CAAC,EAAEA,OAAO,EAAEX,QAAQe,cAAc,CAAC,CAAC;IAC5D,IAAIR,eAAeI,SAAS,CAAC,EAAEA,OAAO,EAAEX,QAAQgB,mBAAmB,CAAC,CAAC;IAErE,IAAI,CAACP,sBAAsB;QACzB,OAAOE;IACT;IAEA,IAAIA,OAAOM,MAAM,GAAG,IAAI;QACtB,MAAM,IAAIpB,SACR,CAAC,sFAAsF,EAAEc,OAAO,CAAC;IAErG;IACA,OAAOA;AACT,EAAC"}
package/src/index.ts DELETED
@@ -1,156 +0,0 @@
1
- import type { Payload } from 'payload'
2
- import type { DatabaseAdapterObj } from 'payload/database'
3
-
4
- import fs from 'fs'
5
- import path from 'path'
6
- import { createDatabaseAdapter } from 'payload/database'
7
-
8
- import type { Args, PostgresAdapter } from './types.js'
9
-
10
- import { connect } from './connect.js'
11
- import { create } from './create.js'
12
- import { createGlobal } from './createGlobal.js'
13
- import { createGlobalVersion } from './createGlobalVersion.js'
14
- import { createMigration } from './createMigration.js'
15
- import { createVersion } from './createVersion.js'
16
- import { deleteMany } from './deleteMany.js'
17
- import { deleteOne } from './deleteOne.js'
18
- import { deleteVersions } from './deleteVersions.js'
19
- import { destroy } from './destroy.js'
20
- import { find } from './find.js'
21
- import { findGlobal } from './findGlobal.js'
22
- import { findGlobalVersions } from './findGlobalVersions.js'
23
- import { findOne } from './findOne.js'
24
- import { findVersions } from './findVersions.js'
25
- import { init } from './init.js'
26
- import { migrate } from './migrate.js'
27
- import { migrateDown } from './migrateDown.js'
28
- import { migrateFresh } from './migrateFresh.js'
29
- import { migrateRefresh } from './migrateRefresh.js'
30
- import { migrateReset } from './migrateReset.js'
31
- import { migrateStatus } from './migrateStatus.js'
32
- import { queryDrafts } from './queryDrafts.js'
33
- import { beginTransaction } from './transactions/beginTransaction.js'
34
- import { commitTransaction } from './transactions/commitTransaction.js'
35
- import { rollbackTransaction } from './transactions/rollbackTransaction.js'
36
- import { updateOne } from './update.js'
37
- import { updateGlobal } from './updateGlobal.js'
38
- import { updateGlobalVersion } from './updateGlobalVersion.js'
39
- import { updateVersion } from './updateVersion.js'
40
-
41
- export type { MigrateDownArgs, MigrateUpArgs } from './types.js'
42
-
43
- export { sql } from 'drizzle-orm'
44
-
45
- export function postgresAdapter(args: Args): DatabaseAdapterObj<PostgresAdapter> {
46
- function adapter({ payload }: { payload: Payload }) {
47
- const migrationDir = findMigrationDir(args.migrationDir)
48
- const idType = args.idType || 'serial'
49
-
50
- return createDatabaseAdapter<PostgresAdapter>({
51
- name: 'postgres',
52
-
53
- // Postgres-specific
54
- blockTableNames: {},
55
- drizzle: undefined,
56
- enums: {},
57
- fieldConstraints: {},
58
- idType,
59
- localesSuffix: args.localesSuffix || '_locales',
60
- logger: args.logger,
61
- pgSchema: undefined,
62
- pool: undefined,
63
- poolOptions: args.pool,
64
- push: args.push,
65
- relations: {},
66
- relationshipsSuffix: args.relationshipsSuffix || '_rels',
67
- schema: {},
68
- schemaName: args.schemaName,
69
- sessions: {},
70
- tables: {},
71
- versionsSuffix: args.versionsSuffix || '_v',
72
-
73
- // DatabaseAdapter
74
- beginTransaction,
75
- commitTransaction,
76
- connect,
77
- create,
78
- createGlobal,
79
- createGlobalVersion,
80
- createMigration,
81
- createVersion,
82
- /**
83
- * This represents how a default ID is treated in Payload as were a field type
84
- */
85
- defaultIDType: idType === 'serial' ? 'number' : 'text',
86
- deleteMany,
87
- deleteOne,
88
- deleteVersions,
89
- destroy,
90
- find,
91
- findGlobal,
92
- findGlobalVersions,
93
- findOne,
94
- findVersions,
95
- init,
96
- migrate,
97
- migrateDown,
98
- migrateFresh,
99
- migrateRefresh,
100
- migrateReset,
101
- migrateStatus,
102
- migrationDir,
103
- payload,
104
- queryDrafts,
105
- rollbackTransaction,
106
- updateGlobal,
107
- updateGlobalVersion,
108
- updateOne,
109
- updateVersion,
110
- })
111
- }
112
-
113
- return {
114
- defaultIDType: 'number',
115
- init: adapter,
116
- }
117
- }
118
-
119
- /**
120
- * Attempt to find migrations directory.
121
- *
122
- * Checks for the following directories in order:
123
- * - `migrationDir` argument from Payload config
124
- * - `src/migrations`
125
- * - `dist/migrations`
126
- * - `migrations`
127
- *
128
- * Defaults to `src/migrations`
129
- *
130
- * @param migrationDir
131
- * @returns
132
- */
133
- function findMigrationDir(migrationDir?: string): string {
134
- const cwd = process.cwd()
135
- const srcDir = path.resolve(cwd, 'src/migrations')
136
- const distDir = path.resolve(cwd, 'dist/migrations')
137
- const relativeMigrations = path.resolve(cwd, 'migrations')
138
-
139
- // Use arg if provided
140
- if (migrationDir) return migrationDir
141
-
142
- // Check other common locations
143
- if (fs.existsSync(srcDir)) {
144
- return srcDir
145
- }
146
-
147
- if (fs.existsSync(distDir)) {
148
- return distDir
149
- }
150
-
151
- if (fs.existsSync(relativeMigrations)) {
152
- return relativeMigrations
153
- }
154
-
155
- return srcDir
156
- }