@payloadcms/db-postgres 3.0.0-alpha.40 → 3.0.0-alpha.42

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. package/dist/connect.d.ts.map +1 -1
  2. package/dist/connect.js +4 -48
  3. package/dist/connect.js.map +1 -0
  4. package/dist/create.js +1 -1
  5. package/dist/create.js.map +1 -0
  6. package/dist/createGlobal.js +1 -1
  7. package/dist/createGlobal.js.map +1 -0
  8. package/dist/createGlobalVersion.js +1 -1
  9. package/dist/createGlobalVersion.js.map +1 -0
  10. package/dist/createMigration.js +1 -1
  11. package/dist/createMigration.js.map +1 -0
  12. package/dist/createVersion.js +1 -1
  13. package/dist/createVersion.js.map +1 -0
  14. package/dist/deleteMany.js +1 -1
  15. package/dist/deleteMany.js.map +1 -0
  16. package/dist/deleteOne.js +1 -1
  17. package/dist/deleteOne.js.map +1 -0
  18. package/dist/deleteVersions.js +1 -1
  19. package/dist/deleteVersions.js.map +1 -0
  20. package/dist/destroy.d.ts.map +1 -1
  21. package/dist/destroy.js +8 -3
  22. package/dist/destroy.js.map +1 -0
  23. package/dist/find/buildFindManyArgs.js +1 -1
  24. package/dist/find/buildFindManyArgs.js.map +1 -0
  25. package/dist/find/chainMethods.js +1 -1
  26. package/dist/find/chainMethods.js.map +1 -0
  27. package/dist/find/findMany.js +1 -1
  28. package/dist/find/findMany.js.map +1 -0
  29. package/dist/find/traverseFields.js +1 -1
  30. package/dist/find/traverseFields.js.map +1 -0
  31. package/dist/find.js +1 -1
  32. package/dist/find.js.map +1 -0
  33. package/dist/findGlobal.js +1 -1
  34. package/dist/findGlobal.js.map +1 -0
  35. package/dist/findGlobalVersions.js +1 -1
  36. package/dist/findGlobalVersions.js.map +1 -0
  37. package/dist/findOne.js +1 -1
  38. package/dist/findOne.js.map +1 -0
  39. package/dist/findVersions.js +1 -1
  40. package/dist/findVersions.js.map +1 -0
  41. package/dist/index.js +1 -1
  42. package/dist/index.js.map +1 -0
  43. package/dist/init.js +1 -1
  44. package/dist/init.js.map +1 -0
  45. package/dist/migrate.js +1 -1
  46. package/dist/migrate.js.map +1 -0
  47. package/dist/migrateDown.js +1 -1
  48. package/dist/migrateDown.js.map +1 -0
  49. package/dist/migrateFresh.js +1 -1
  50. package/dist/migrateFresh.js.map +1 -0
  51. package/dist/migrateRefresh.js +1 -1
  52. package/dist/migrateRefresh.js.map +1 -0
  53. package/dist/migrateReset.js +1 -1
  54. package/dist/migrateReset.js.map +1 -0
  55. package/dist/migrateStatus.js +1 -1
  56. package/dist/migrateStatus.js.map +1 -0
  57. package/dist/queries/buildAndOrConditions.js +1 -1
  58. package/dist/queries/buildAndOrConditions.js.map +1 -0
  59. package/dist/queries/buildQuery.js +1 -1
  60. package/dist/queries/buildQuery.js.map +1 -0
  61. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js +1 -1
  62. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js.map +1 -0
  63. package/dist/queries/createJSONQuery/formatJSONPathSegment.js +1 -1
  64. package/dist/queries/createJSONQuery/formatJSONPathSegment.js.map +1 -0
  65. package/dist/queries/createJSONQuery/index.js +1 -1
  66. package/dist/queries/createJSONQuery/index.js.map +1 -0
  67. package/dist/queries/getTableColumnFromPath.js +1 -1
  68. package/dist/queries/getTableColumnFromPath.js.map +1 -0
  69. package/dist/queries/operatorMap.js +1 -1
  70. package/dist/queries/operatorMap.js.map +1 -0
  71. package/dist/queries/parseParams.js +1 -1
  72. package/dist/queries/parseParams.js.map +1 -0
  73. package/dist/queries/sanitizeQueryValue.js +1 -1
  74. package/dist/queries/sanitizeQueryValue.js.map +1 -0
  75. package/dist/queryDrafts.js +1 -1
  76. package/dist/queryDrafts.js.map +1 -0
  77. package/dist/schema/build.js +1 -1
  78. package/dist/schema/build.js.map +1 -0
  79. package/dist/schema/createIndex.js +1 -1
  80. package/dist/schema/createIndex.js.map +1 -0
  81. package/dist/schema/idToUUID.js +1 -1
  82. package/dist/schema/idToUUID.js.map +1 -0
  83. package/dist/schema/parentIDColumnMap.js +1 -1
  84. package/dist/schema/parentIDColumnMap.js.map +1 -0
  85. package/dist/schema/setColumnID.js +1 -1
  86. package/dist/schema/setColumnID.js.map +1 -0
  87. package/dist/schema/traverseFields.js +1 -1
  88. package/dist/schema/traverseFields.js.map +1 -0
  89. package/dist/schema/validateExistingBlockIsIdentical.js +1 -1
  90. package/dist/schema/validateExistingBlockIsIdentical.js.map +1 -0
  91. package/dist/transactions/beginTransaction.js +1 -1
  92. package/dist/transactions/beginTransaction.js.map +1 -0
  93. package/dist/transactions/commitTransaction.js +1 -1
  94. package/dist/transactions/commitTransaction.js.map +1 -0
  95. package/dist/transactions/rollbackTransaction.js +1 -1
  96. package/dist/transactions/rollbackTransaction.js.map +1 -0
  97. package/dist/transform/read/hasManyNumber.js +1 -1
  98. package/dist/transform/read/hasManyNumber.js.map +1 -0
  99. package/dist/transform/read/hasManyText.js +1 -1
  100. package/dist/transform/read/hasManyText.js.map +1 -0
  101. package/dist/transform/read/index.js +1 -1
  102. package/dist/transform/read/index.js.map +1 -0
  103. package/dist/transform/read/relationship.js +1 -1
  104. package/dist/transform/read/relationship.js.map +1 -0
  105. package/dist/transform/read/traverseFields.js +1 -1
  106. package/dist/transform/read/traverseFields.js.map +1 -0
  107. package/dist/transform/write/array.js +1 -1
  108. package/dist/transform/write/array.js.map +1 -0
  109. package/dist/transform/write/blocks.js +1 -1
  110. package/dist/transform/write/blocks.js.map +1 -0
  111. package/dist/transform/write/index.js +1 -1
  112. package/dist/transform/write/index.js.map +1 -0
  113. package/dist/transform/write/numbers.js +1 -1
  114. package/dist/transform/write/numbers.js.map +1 -0
  115. package/dist/transform/write/relationships.js +1 -1
  116. package/dist/transform/write/relationships.js.map +1 -0
  117. package/dist/transform/write/selects.js +1 -1
  118. package/dist/transform/write/selects.js.map +1 -0
  119. package/dist/transform/write/texts.js +1 -1
  120. package/dist/transform/write/texts.js.map +1 -0
  121. package/dist/transform/write/traverseFields.js +1 -1
  122. package/dist/transform/write/traverseFields.js.map +1 -0
  123. package/dist/transform/write/types.js +1 -1
  124. package/dist/transform/write/types.js.map +1 -0
  125. package/dist/types.js +1 -1
  126. package/dist/types.js.map +1 -0
  127. package/dist/update.js +1 -1
  128. package/dist/update.js.map +1 -0
  129. package/dist/updateGlobal.js +1 -1
  130. package/dist/updateGlobal.js.map +1 -0
  131. package/dist/updateGlobalVersion.js +1 -1
  132. package/dist/updateGlobalVersion.js.map +1 -0
  133. package/dist/updateVersion.js +1 -1
  134. package/dist/updateVersion.js.map +1 -0
  135. package/dist/upsertRow/deleteExistingArrayRows.js +1 -1
  136. package/dist/upsertRow/deleteExistingArrayRows.js.map +1 -0
  137. package/dist/upsertRow/deleteExistingRowsByPath.js +1 -1
  138. package/dist/upsertRow/deleteExistingRowsByPath.js.map +1 -0
  139. package/dist/upsertRow/index.js +1 -1
  140. package/dist/upsertRow/index.js.map +1 -0
  141. package/dist/upsertRow/insertArrays.js +1 -1
  142. package/dist/upsertRow/insertArrays.js.map +1 -0
  143. package/dist/upsertRow/types.js +1 -1
  144. package/dist/upsertRow/types.js.map +1 -0
  145. package/dist/utilities/appendPrefixToKeys.js +1 -1
  146. package/dist/utilities/appendPrefixToKeys.js.map +1 -0
  147. package/dist/utilities/createBlocksMap.js +1 -1
  148. package/dist/utilities/createBlocksMap.js.map +1 -0
  149. package/dist/utilities/createMigrationTable.js +1 -1
  150. package/dist/utilities/createMigrationTable.js.map +1 -0
  151. package/dist/utilities/createRelationshipMap.js +1 -1
  152. package/dist/utilities/createRelationshipMap.js.map +1 -0
  153. package/dist/utilities/hasLocalesTable.js +1 -1
  154. package/dist/utilities/hasLocalesTable.js.map +1 -0
  155. package/dist/utilities/isArrayOfRows.js +1 -1
  156. package/dist/utilities/isArrayOfRows.js.map +1 -0
  157. package/dist/utilities/migrationTableExists.js +1 -1
  158. package/dist/utilities/migrationTableExists.js.map +1 -0
  159. package/dist/utilities/parseError.js +1 -1
  160. package/dist/utilities/parseError.js.map +1 -0
  161. package/dist/utilities/pushDevSchema.d.ts +9 -0
  162. package/dist/utilities/pushDevSchema.d.ts.map +1 -0
  163. package/dist/utilities/pushDevSchema.js +56 -0
  164. package/dist/utilities/pushDevSchema.js.map +1 -0
  165. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AA+C/C,eAAO,MAAM,OAAO,EAAE,OAiHrB,CAAA"}
1
+ {"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AA+C/C,eAAO,MAAM,OAAO,EAAE,OAgDrB,CAAA"}
package/dist/connect.js CHANGED
@@ -1,8 +1,7 @@
1
- import { eq, sql } from 'drizzle-orm';
1
+ import { sql } from 'drizzle-orm';
2
2
  import { drizzle } from 'drizzle-orm/node-postgres';
3
- import { numeric, timestamp, varchar } from 'drizzle-orm/pg-core';
4
3
  import pg from 'pg';
5
- import prompts from 'prompts';
4
+ import { pushDevSchema } from './utilities/pushDevSchema.js';
6
5
  const connectWithReconnect = async function({ adapter, payload, reconnect = false }) {
7
6
  let result;
8
7
  if (!reconnect) {
@@ -74,50 +73,7 @@ export const connect = async function connect(options = {
74
73
  }
75
74
  // Only push schema if not in production
76
75
  if (process.env.NODE_ENV === 'production' || process.env.PAYLOAD_MIGRATING === 'true' || this.push === false) return;
77
- const { pushSchema } = await import('drizzle-kit/payload');
78
- // This will prompt if clarifications are needed for Drizzle to push new schema
79
- const { apply, hasDataLoss, statementsToExecute, warnings } = await pushSchema(this.schema, this.drizzle);
80
- if (warnings.length) {
81
- let message = `Warnings detected during schema push: \n\n${warnings.join('\n')}\n\n`;
82
- if (hasDataLoss) {
83
- message += `DATA LOSS WARNING: Possible data loss detected if schema is pushed.\n\n`;
84
- }
85
- message += `Accept warnings and push schema to database?`;
86
- const { confirm: acceptWarnings } = await prompts({
87
- name: 'confirm',
88
- type: 'confirm',
89
- initial: false,
90
- message
91
- }, {
92
- onCancel: ()=>{
93
- process.exit(0);
94
- }
95
- });
96
- // Exit if user does not accept warnings.
97
- // Q: Is this the right type of exit for this interaction?
98
- if (!acceptWarnings) {
99
- process.exit(0);
100
- }
101
- }
102
- await apply();
103
- // Migration table def in order to use query using drizzle
104
- const migrationsSchema = this.pgSchema.table('payload_migrations', {
105
- name: varchar('name'),
106
- batch: numeric('batch'),
107
- created_at: timestamp('created_at'),
108
- updated_at: timestamp('updated_at')
109
- });
110
- const devPush = await this.drizzle.select().from(migrationsSchema).where(eq(migrationsSchema.batch, '-1'));
111
- if (!devPush.length) {
112
- await this.drizzle.insert(migrationsSchema).values({
113
- name: 'dev',
114
- batch: '-1'
115
- });
116
- } else {
117
- await this.drizzle.update(migrationsSchema).set({
118
- updated_at: new Date()
119
- }).where(eq(migrationsSchema.batch, '-1'));
120
- }
76
+ await pushDevSchema(this);
121
77
  };
122
78
 
123
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9jb25uZWN0LnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB0eXBlIHsgUGF5bG9hZCB9IGZyb20gJ3BheWxvYWQnXG5pbXBvcnQgdHlwZSB7IENvbm5lY3QgfSBmcm9tICdwYXlsb2FkL2RhdGFiYXNlJ1xuXG5pbXBvcnQgeyBlcSwgc3FsIH0gZnJvbSAnZHJpenpsZS1vcm0nXG5pbXBvcnQgeyBkcml6emxlIH0gZnJvbSAnZHJpenpsZS1vcm0vbm9kZS1wb3N0Z3JlcydcbmltcG9ydCB7IG51bWVyaWMsIHRpbWVzdGFtcCwgdmFyY2hhciB9IGZyb20gJ2RyaXp6bGUtb3JtL3BnLWNvcmUnXG5pbXBvcnQgcGcgZnJvbSAncGcnXG5pbXBvcnQgcHJvbXB0cyBmcm9tICdwcm9tcHRzJ1xuXG5pbXB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UFRO1FBQ2RvRCxPQUFPdEQsUUFBUTtRQUNmdUQsWUFBWXRELFVBQVU7UUFDdEJ1RCxZQUFZdkQsVUFBVTtJQUN4QjtJQUVBLE1BQU13RCxVQUFVLE1BQU0sSUFBSSxDQUFDMUQsT0FBTyxDQUMvQjJELE1BQU0sR0FDTkMsSUFBSSxDQUFDUixrQkFDTFMsS0FBSyxDQUFDL0QsR0FBR3NELGlCQUFpQkcsS0FBSyxFQUFFO0lBRXBDLElBQUksQ0FBQ0csUUFBUWQsTUFBTSxFQUFFO1FBQ25CLE1BQU0sSUFBSSxDQUFDNUMsT0FBTyxDQUFDOEQsTUFBTSxDQUFDVixrQkFBa0JXLE1BQU0sQ0FBQztZQUNqRGYsTUFBTTtZQUNOTyxPQUFPO1FBQ1Q7SUFDRixPQUFPO1FBQ0wsTUFBTSxJQUFJLENBQUN2RCxPQUFPLENBQ2ZnRSxNQUFNLENBQUNaLGtCQUNQYSxHQUFHLENBQUM7WUFDSFIsWUFBWSxJQUFJUztRQUNsQixHQUNDTCxLQUFLLENBQUMvRCxHQUFHc0QsaUJBQWlCRyxLQUFLLEVBQUU7SUFDdEM7QUFDRixFQUFDIn0=
79
+ //# sourceMappingURL=connect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/connect.ts"],"sourcesContent":["import type { Payload } from 'payload'\nimport type { Connect } from 'payload/database'\n\nimport { sql } from 'drizzle-orm'\nimport { drizzle } from 'drizzle-orm/node-postgres'\nimport pg from 'pg'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { pushDevSchema } from './utilities/pushDevSchema.js'\n\nconst connectWithReconnect = async function ({\n adapter,\n payload,\n reconnect = false,\n}: {\n adapter: PostgresAdapter\n payload: Payload\n reconnect?: boolean\n}) {\n let result\n\n if (!reconnect) {\n result = await adapter.pool.connect()\n } else {\n try {\n result = await adapter.pool.connect()\n } catch (err) {\n setTimeout(() => {\n payload.logger.info('Reconnecting to postgres')\n void connectWithReconnect({ adapter, payload, reconnect: true })\n }, 1000)\n }\n }\n if (!result) {\n return\n }\n result.prependListener('error', (err) => {\n try {\n if (err.code === 'ECONNRESET') {\n void connectWithReconnect({ adapter, payload, reconnect: true })\n }\n } catch (err) {\n // swallow error\n }\n })\n}\n\nexport const connect: Connect = async function connect(\n this: PostgresAdapter,\n options = {\n hotReload: false,\n },\n) {\n const { hotReload } = options\n\n this.schema = {\n ...this.tables,\n ...this.relations,\n ...this.enums,\n }\n\n try {\n this.pool = new pg.Pool(this.poolOptions)\n await connectWithReconnect({ adapter: this, payload: this.payload })\n\n const logger = this.logger || false\n\n this.drizzle = drizzle(this.pool, { logger, schema: this.schema })\n\n if (!hotReload) {\n if (process.env.PAYLOAD_DROP_DATABASE === 'true') {\n this.payload.logger.info(`---- DROPPING TABLES SCHEMA(${this.schemaName || 'public'}) ----`)\n await this.drizzle.execute(\n sql.raw(`\n drop schema if exists ${this.schemaName || 'public'} cascade;\n create schema ${this.schemaName || 'public'};\n `),\n )\n this.payload.logger.info('---- DROPPED TABLES ----')\n }\n }\n } catch (err) {\n this.payload.logger.error(`Error: cannot connect to Postgres. Details: ${err.message}`, err)\n process.exit(1)\n }\n\n // Only push schema if not in production\n if (\n process.env.NODE_ENV === 'production' ||\n process.env.PAYLOAD_MIGRATING === 'true' ||\n this.push === false\n )\n return\n\n await pushDevSchema(this)\n}\n"],"names":["sql","drizzle","pg","pushDevSchema","connectWithReconnect","adapter","payload","reconnect","result","pool","connect","err","setTimeout","logger","info","prependListener","code","options","hotReload","schema","tables","relations","enums","Pool","poolOptions","process","env","PAYLOAD_DROP_DATABASE","schemaName","execute","raw","error","message","exit","NODE_ENV","PAYLOAD_MIGRATING","push"],"mappings":"AAGA,SAASA,GAAG,QAAQ,cAAa;AACjC,SAASC,OAAO,QAAQ,4BAA2B;AACnD,OAAOC,QAAQ,KAAI;AAInB,SAASC,aAAa,QAAQ,+BAA8B;AAE5D,MAAMC,uBAAuB,eAAgB,EAC3CC,OAAO,EACPC,OAAO,EACPC,Y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,MAAM,CAACC,IAAI,CAAC,CAAC,4BAA4B,EAAE,IAAI,CAACc,UAAU,IAAI,SAAS,MAAM,CAAC;gBAC3F,MAAM,IAAI,CAAC3B,OAAO,CAAC4B,OAAO,CACxB7B,IAAI8B,GAAG,CAAC,CAAC;gCACa,EAAE,IAAI,CAACF,UAAU,IAAI,SAAS;wBACtC,EAAE,IAAI,CAACA,UAAU,IAAI,SAAS;QAC9C,CAAC;gBAED,IAAI,CAACtB,OAAO,CAACO,MAAM,CAACC,IAAI,CAAC;YAC3B;QACF;IACF,EAAE,OAAOH,KAAK;QACZ,IAAI,CAACL,OAAO,CAACO,MAAM,CAACkB,KAAK,CAAC,CAAC,4CAA4C,EAAEpB,IAAIqB,OAAO,CAAC,CAAC,EAAErB;QACxFc,QAAQQ,IAAI,CAAC;IACf;IAEA,wCAAwC;IACxC,IACER,QAAQC,GAAG,CAACQ,QAAQ,KAAK,gBACzBT,QAAQC,GAAG,CAACS,iBAAiB,KAAK,UAClC,IAAI,CAACC,IAAI,KAAK,OAEd;IAEF,MAAMjC,cAAc,IAAI;AAC1B,EAAC"}
package/dist/create.js CHANGED
@@ -15,4 +15,4 @@ export const create = async function create({ collection: collectionSlug, data,
15
15
  return result;
16
16
  };
17
17
 
18
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9jcmVhdGUudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHR5cGUgeyBDcmVhdGUgfSBmcm9tICdwYXlsb2FkL2RhdGFiYXNlJ1xuXG5pbXBvcnQgdG9TbmFrZUNhc2UgZnJvbSAndG8tc25ha2UtY2FzZSdcblxuaW1wb3J0IHR5cGUgeyBQb3N0Z3Jlc0FkYXB0ZXIgfSBmcm9tICcuL3R5cGVzLmpzJ1xuXG5pbXBvcnQgeyB1cHNlcnRSb3cgfSBmcm9tICcuL3Vwc2VydFJvdy9pbmRleC5qcydcblxuZXhwb3J0IGNvbnN0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LFlBQVlDLGNBQWMsRUFBRUMsSUFBSSxFQUFFQyxHQUFHLEVBQUU7SUFFekMsTUFBTUMsS0FBSyxJQUFJLENBQUNDLFFBQVEsQ0FBQ0YsSUFBSUcsYUFBYSxDQUFDLEVBQUVGLE1BQU0sSUFBSSxDQUFDRyxPQUFPO0lBQy9ELE1BQU1QLGFBQWEsSUFBSSxDQUFDUSxPQUFPLENBQUNDLFdBQVcsQ0FBQ1IsZUFBZSxDQUFDUyxNQUFNO0lBRWxFLE1BQU1DLFNBQVMsTUFBTWIsVUFBVTtRQUM3QmMsU0FBUyxJQUFJO1FBQ2JWO1FBQ0FFO1FBQ0FTLFFBQVFiLFdBQVdhLE1BQU07UUFDekJDLFdBQVc7UUFDWEMsV0FBV2xCLFlBQVlJO1FBQ3ZCRTtJQUNGO0lBRUEsT0FBT1E7QUFDVCxFQUFDIn0=
18
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/create.ts"],"sourcesContent":["import type { Create } from 'payload/database'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { upsertRow } from './upsertRow/index.js'\n\nexport const create: Create = async function create(\n this: PostgresAdapter,\n { collection: collectionSlug, data, req },\n) {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const collection = this.payload.collections[collectionSlug].config\n\n const result = await upsertRow({\n adapter: this,\n data,\n db,\n fields: collection.fields,\n operation: 'create',\n tableName: toSnakeCase(collectionSlug),\n req,\n })\n\n return result\n}\n"],"names":["toSnakeCase","upsertRow","create","collection","collectionSlug","data","req","db","sessions","transactionID","drizzle","payload","collections","config","result","adapter","fields","operation","tableName"],"mappings":"AAEA,OAAOA,iBAAiB,gBAAe;AAIvC,SAASC,SAAS,QAAQ,uBAAsB;AAEhD,OAAO,MAAMC,SAAiB,eAAeA,OAE3C,EAAEC,YAAYC,cAAc,EAAEC,IAAI,EAAEC,GAAG,EAAE;IAEzC,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACF,IAAIG,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMP,aAAa,IAAI,CAACQ,OAAO,CAACC,WAAW,CAACR,eAAe,CAACS,MAAM;IAElE,MAAMC,SAAS,MAAMb,UAAU;QAC7Bc,SAAS,IAAI;QACbV;QACAE;QACAS,QAAQb,WAAWa,MAAM;QACzBC,WAAW;QACXC,WAAWlB,YAAYI;QACvBE;IACF;IAEA,OAAOQ;AACT,EAAC"}
@@ -15,4 +15,4 @@ export async function createGlobal({ data, req = {}, slug }) {
15
15
  return result;
16
16
  }
17
17
 
18
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9jcmVhdGVHbG9iYWwudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHR5cGUgeyBDcmVhdGVHbG9iYWxBcmdzIH0gZnJvbSAncGF5bG9hZC9kYXRhYmFzZSdcbmltcG9ydCB0eXBlIHsgUGF5bG9hZFJlcXVlc3QsIFR5cGVXaXRoSUQgfSBmcm9tICdwYXlsb2FkL3R5cGVzJ1xuXG5pbXBvcnQgdG9TbmFrZUNhc2UgZnJvbSAndG8tc25ha2UtY2FzZSdcblxuaW1wb3J0IHR5cGUgeyBQb3N0Z3Jlc0FkYXB0ZXIgfSBmcm9tICcuL3R5cGVzLmpzJ1xuXG5pbXBvcnQgeyB1cHNlcnRSb3cgfSBmcm9tICcuL3Vwc2VydFJvdy9pbmRleC5qcydcblxuZXhwb3J0IGFzeW5jIGZ1bmN0aW9uIGNyZWF0ZUdsb2JhbDxUIGV4dGVuZHMgVHlwZVdpdGhJRD4oXG4gIHRoaXM6IFBvc3RncmVzQWRhcHRlcixcbiAgeyBkYXRhLCByZXEgPSB7fSBhcyBQYXlsb2FkUmVxdWVzdCwgc2x1ZyB9OiBDcmVhdGVHbG9iYWxBcmdzLFxuKTogUHJvbWlzZTxUPiB7XG4gIGNvbn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U87SUFDL0QsTUFBTUMsZUFBZSxJQUFJLENBQUNDLE9BQU8sQ0FBQ0MsT0FBTyxDQUFDQyxNQUFNLENBQUNDLElBQUksQ0FBQyxDQUFDRCxTQUFXQSxPQUFPUixJQUFJLEtBQUtBO0lBRWxGLE1BQU1VLFNBQVMsTUFBTWQsVUFBYTtRQUNoQ2UsU0FBUyxJQUFJO1FBQ2JiO1FBQ0FHO1FBQ0FXLFFBQVFQLGFBQWFPLE1BQU07UUFDM0JDLFdBQVc7UUFDWEMsV0FBV25CLFlBQVlLO1FBQ3ZCRDtJQUNGO0lBRUEsT0FBT1c7QUFDVCJ9
18
+ //# sourceMappingURL=createGlobal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/createGlobal.ts"],"sourcesContent":["import type { CreateGlobalArgs } from 'payload/database'\nimport type { PayloadRequest, TypeWithID } from 'payload/types'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { upsertRow } from './upsertRow/index.js'\n\nexport async function createGlobal<T extends TypeWithID>(\n this: PostgresAdapter,\n { data, req = {} as PayloadRequest, slug }: CreateGlobalArgs,\n): Promise<T> {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const globalConfig = this.payload.globals.config.find((config) => config.slug === slug)\n\n const result = await upsertRow<T>({\n adapter: this,\n data,\n db,\n fields: globalConfig.fields,\n operation: 'create',\n tableName: toSnakeCase(slug),\n req,\n })\n\n return result\n}\n"],"names":["toSnakeCase","upsertRow","createGlobal","data","req","slug","db","sessions","transactionID","drizzle","globalConfig","payload","globals","config","find","result","adapter","fields","operation","tableName"],"mappings":"AAGA,OAAOA,iBAAiB,gBAAe;AAIvC,SAASC,SAAS,QAAQ,uBAAsB;AAEhD,OAAO,eAAeC,aAEpB,EAAEC,IAAI,EAAEC,MAAM,CAAC,CAAmB,EAAEC,IAAI,EAAoB;IAE5D,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACH,IAAII,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMC,eAAe,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAACD,SAAWA,OAAOR,IAAI,KAAKA;IAElF,MAAMU,SAAS,MAAMd,UAAa;QAChCe,SAAS,IAAI;QACbb;QACAG;QACAW,QAAQP,aAAaO,MAAM;QAC3BC,WAAW;QACXC,WAAWnB,YAAYK;QACvBD;IACF;IAEA,OAAOW;AACT"}
@@ -31,4 +31,4 @@ export async function createGlobalVersion({ autosave, globalSlug, req = {}, vers
31
31
  return result;
32
32
  }
33
33
 
34
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9jcmVhdGVHbG9iYWxWZXJzaW9uLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB0eXBlIHsgVHlwZVdpdGhWZXJzaW9uIH0gZnJvbSAncGF5bG9hZC9kYXRhYmFzZSdcbmltcG9ydCB7IHR5cGUgQ3JlYXRlR2xvYmFsVmVyc2lvbkFyZ3MgfSBmcm9tICdwYXlsb2FkL2RhdGFiYXNlJ1xuaW1wb3J0IHR5cGUgeyBQYXlsb2FkUmVxdWVzdCwgVHlwZVdpdGhJRCB9IGZyb20gJ3BheWxvYWQvdHlwZXMnXG5cbmltcG9ydCB7IHNxbCB9IGZyb20gJ2RyaXp6bGUtb3JtJ1xuaW1wb3J0IHsgYnVpbGRWZXJzaW9uR2xvYmFsRmllbGRzIH0gZnJvbSAncGF5bG9hZC92ZXJzaW9ucydcbmltcG9ydCB0b1NuYWtlQ2FzZSBmcm9tICd0by1zbmFrZS1jYXNlJ1xuXG5pbXBvcnQgdHlwZSB7IFBvc3RncmVzQWRhcHRlciB9IGZyb20gJy4vdHlwZXMuanMnXG5cbmltcG9ydCB7IHVwc2VydFJvdyB9IGZyb20gJy4vdXBzZXJ0Um93L2luZGV4LmpzJ1xuXG5leHBvcnQgYXN5bmMgZ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JQUFJLENBQUNHLE9BQU87SUFDL0QsTUFBTUMsU0FBUyxJQUFJLENBQUNDLE9BQU8sQ0FBQ0MsT0FBTyxDQUFDQyxNQUFNLENBQUNDLElBQUksQ0FBQyxDQUFDLEVBQUVDLElBQUksRUFBRSxHQUFLQSxTQUFTWjtJQUN2RSxNQUFNYSxrQkFBa0JqQixZQUFZSTtJQUNwQyxNQUFNYyxZQUFZLENBQUMsQ0FBQyxFQUFFRCxnQkFBZ0IsRUFBRSxDQUFDO0lBRXpDLE1BQU1FLFNBQVMsTUFBTWxCLFVBQThCO1FBQ2pEbUIsU0FBUyxJQUFJO1FBQ2JDLE1BQU07WUFDSmxCO1lBQ0FtQixRQUFRO1lBQ1JDLFNBQVNqQjtRQUNYO1FBQ0FDO1FBQ0FpQixRQUFRekIseUJBQXlCWTtRQUNqQ2MsV0FBVztRQUNYUDtRQUNBYjtJQUNGO0lBRUEsTUFBTXFCLFFBQVEsSUFBSSxDQUFDQyxNQUFNLENBQUNULFVBQVU7SUFFcEMsSUFBSVAsT0FBT2lCLFFBQVEsQ0FBQ0MsTUFBTSxFQUFFO1FBQzFCLE1BQU10QixHQUFHdUIsT0FBTyxDQUFDaEMsR0FBRyxDQUFDO2FBQ1osRUFBRTRCLE1BQU07O1lBRVQsRUFBRUEsTUFBTUssRUFBRSxDQUFDLElBQUksRUFBRVosT0FBT1ksRUFBRSxDQUFDO0lBQ25DLENBQUM7SUFDSDtJQUVBLE9BQU9aO0FBQ1QifQ==
34
+ //# sourceMappingURL=createGlobalVersion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/createGlobalVersion.ts"],"sourcesContent":["import type { TypeWithVersion } from 'payload/database'\nimport { type CreateGlobalVersionArgs } from 'payload/database'\nimport type { PayloadRequest, TypeWithID } from 'payload/types'\n\nimport { sql } from 'drizzle-orm'\nimport { buildVersionGlobalFields } from 'payload/versions'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { upsertRow } from './upsertRow/index.js'\n\nexport async function createGlobalVersion<T extends TypeWithID>(\n this: PostgresAdapter,\n { autosave, globalSlug, req = {} as PayloadRequest, versionData }: CreateGlobalVersionArgs,\n) {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const global = this.payload.globals.config.find(({ slug }) => slug === globalSlug)\n const globalTableName = toSnakeCase(globalSlug)\n const tableName = `_${globalTableName}_v`\n\n const result = await upsertRow<TypeWithVersion<T>>({\n adapter: this,\n data: {\n autosave,\n latest: true,\n version: versionData,\n },\n db,\n fields: buildVersionGlobalFields(global),\n operation: 'create',\n tableName,\n req,\n })\n\n const table = this.tables[tableName]\n\n if (global.versions.drafts) {\n await db.execute(sql`\n UPDATE ${table}\n SET latest = false\n WHERE ${table.id} != ${result.id};\n `)\n }\n\n return result\n}\n"],"names":["sql","buildVersionGlobalFields","toSnakeCase","upsertRow","createGlobalVersion","autosave","globalSlug","req","versionData","db","sessions","transactionID","drizzle","global","payload","globals","config","find","slug","globalTableName","tableName","result","adapter","data","latest","version","fields","operation","table","tables","versions","drafts","execute","id"],"mappings":"AAIA,SAASA,GAAG,QAAQ,cAAa;AACjC,SAASC,wBAAwB,QAAQ,mBAAkB;AAC3D,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,SAAS,QAAQ,uBAAsB;AAEhD,OAAO,eAAeC,oBAEpB,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,MAAM,CAAC,CAAmB,EAAEC,WAAW,EAA2B;IAE1F,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACH,IAAII,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMC,SAAS,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKA,SAASZ;IACvE,MAAMa,kBAAkBjB,YAAYI;IACpC,MAAMc,YAAY,CAAC,CAAC,EAAED,gBAAgB,EAAE,CAAC;IAEzC,MAAME,SAAS,MAAMlB,UAA8B;QACjDmB,SAAS,IAAI;QACbC,MAAM;YACJlB;YACAmB,QAAQ;YACRC,SAASjB;QACX;QACAC;QACAiB,QAAQzB,yBAAyBY;QACjCc,WAAW;QACXP;QACAb;IACF;IAEA,MAAMqB,QAAQ,IAAI,CAACC,MAAM,CAACT,UAAU;IAEpC,IAAIP,OAAOiB,QAAQ,CAACC,MAAM,EAAE;QAC1B,MAAMtB,GAAGuB,OAAO,CAAChC,GAAG,CAAC;aACZ,EAAE4B,MAAM;;YAET,EAAEA,MAAMK,EAAE,CAAC,IAAI,EAAEZ,OAAOY,EAAE,CAAC;IACnC,CAAC;IACH;IAEA,OAAOZ;AACT"}
@@ -77,4 +77,4 @@ export const createMigration = async function createMigration({ forceAcceptWarni
77
77
  });
78
78
  };
79
79
 
80
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9jcmVhdGVNaWdyYXRpb24udHMiXSwic291cmNlc0NvbnRlbnQiOlsiLyogZXNsaW50LWRpc2FibGUgbm8tcmVzdHJpY3RlZC1zeW50YXgsIG5vLWF3YWl0LWluLWxvb3AgKi9cbmltcG9ydCB0eXBlIHsgRHJpenpsZVNuYXBzaG90SlNPTiB9IGZyb20gJ2RyaXp6bGUta2l0L3BheWxvYWQnXG5pbXBvcnQgdHlwZSB7IENyZWF0ZU1pZ3JhdGlvbiB9IGZyb20gJ3BheWxvYWQvZGF0YWJhc2UnXG5cbmltcG9ydCBmcyBmcm9tICdmcydcbmltcG9ydCBwcm9tcHRzIGZyb20gJ3Byb21wdHMnXG5cbmltcG9ydCB0eXBlIHsgUG9zdGdyZXNBZGFwdGVyIH0gZnJvbSAnLi90eXBlcy5qcydcblxuY29uc3QgbWlncmF0aW9uVGVtcGxhdGUgPSAoXG4gIHVwU1FMPzogc3RyaW5nLFxuICBkb3duU1FMPzogc3RyaW5nLFxuKSA9PiBgaW1wb3J0IHsgTWlncmF0ZVVwQXJncywgT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0FBQ3JDLG9CQUFvQjtRQUMvRSxNQUFNLEVBQUVzQyxTQUFTQywwQkFBMEIsRUFBRSxHQUFHLE1BQU10RCxRQUNwRDtZQUNFdUQsTUFBTTtZQUNOQyxNQUFNO1lBQ05DLFNBQVM7WUFDVEMsU0FBUztRQUNYLEdBQ0E7WUFDRUMsVUFBVTtnQkFDUkMsUUFBUUMsSUFBSSxDQUFDO1lBQ2Y7UUFDRjtRQUdGLElBQUksQ0FBQ1AsNEJBQTRCO1lBQy9CTSxRQUFRQyxJQUFJLENBQUM7UUFDZjtJQUNGO0lBRUEsZUFBZTtJQUNmOUQsR0FBRytELGFBQWEsQ0FBQyxDQUFDLEVBQUUzQixTQUFTLEtBQUssQ0FBQyxFQUFFVSxLQUFLa0IsU0FBUyxDQUFDZixrQkFBa0IsTUFBTTtJQUU1RSxrQkFBa0I7SUFDbEJqRCxHQUFHK0QsYUFBYSxDQUNkLENBQUMsRUFBRTNCLFNBQVMsR0FBRyxDQUFDLEVBQ2hCbEMsa0JBQ0VpRCxnQkFBZ0JFLE1BQU0sR0FBR0YsaUJBQWlCYyxLQUFLLFFBQVFDLFdBQ3ZEZCxrQkFBa0JDLE1BQU0sR0FBR0QsbUJBQW1CYSxLQUFLLFFBQVFDO0lBRy9EaEQsUUFBUWlELE1BQU0sQ0FBQ0MsSUFBSSxDQUFDO1FBQUVDLEtBQUssQ0FBQyxxQkFBcUIsRUFBRWpDLFNBQVMsR0FBRyxDQUFDO0lBQUM7QUFDbkUsRUFBQyJ9
80
+ //# sourceMappingURL=createMigration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/createMigration.ts"],"sourcesContent":["/* eslint-disable no-restricted-syntax, no-await-in-loop */\nimport type { DrizzleSnapshotJSON } from 'drizzle-kit/payload'\nimport type { CreateMigration } from 'payload/database'\n\nimport fs from 'fs'\nimport prompts from 'prompts'\n\nimport type { PostgresAdapter } from './types.js'\n\nconst migrationTemplate = (\n upSQL?: string,\n downSQL?: string,\n) => `import { MigrateUpArgs, MigrateDownArgs } from '@payloadcms/db-postgres'\nimport { sql } from 'drizzle-orm'\n\nexport async function up({ payload }: MigrateUpArgs): Promise<void> {\n${\n upSQL\n ? `await payload.db.drizzle.execute(sql\\`\n\n${upSQL}\\`);\n`\n : '// Migration code'\n}\n};\n\nexport async function down({ payload }: MigrateDownArgs): Promise<void> {\n${\n downSQL\n ? `await payload.db.drizzle.execute(sql\\`\n\n${downSQL}\\`);\n`\n : '// Migration code'\n}\n};\n`\n\nconst getDefaultDrizzleSnapshot = (): DrizzleSnapshotJSON => ({\n id: '00000000-0000-0000-0000-000000000000',\n _meta: {\n columns: {},\n schemas: {},\n tables: {},\n },\n dialect: 'pg',\n enums: {},\n prevId: '00000000-0000-0000-0000-00000000000',\n schemas: {},\n tables: {},\n version: '5',\n})\n\nexport const createMigration: CreateMigration = async function createMigration(\n this: PostgresAdapter,\n { forceAcceptWarning, migrationName, payload },\n) {\n const dir = payload.db.migrationDir\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir)\n }\n\n const { generateDrizzleJson, generateMigration } = await import('drizzle-kit/payload')\n\n const [yyymmdd, hhmmss] = new Date().toISOString().split('T')\n const formattedDate = yyymmdd.replace(/\\D/g, '')\n const formattedTime = hhmmss.split('.')[0].replace(/\\D/g, '')\n\n const timestamp = `${formattedDate}_${formattedTime}`\n\n const fileName = migrationName\n ? `${timestamp}_${migrationName.replace(/\\W/g, '_')}`\n : `${timestamp}`\n\n const filePath = `${dir}/${fileName}`\n\n let drizzleJsonBefore = getDefaultDrizzleSnapshot()\n\n // Get latest migration snapshot\n const latestSnapshot = fs\n .readdirSync(dir)\n .filter((file) => file.endsWith('.json'))\n .sort()\n .reverse()?.[0]\n\n if (latestSnapshot) {\n const latestSnapshotJSON = JSON.parse(\n fs.readFileSync(`${dir}/${latestSnapshot}`, 'utf8'),\n ) as DrizzleSnapshotJSON\n\n drizzleJsonBefore = latestSnapshotJSON\n }\n\n const drizzleJsonAfter = generateDrizzleJson(this.schema)\n const sqlStatementsUp = await generateMigration(drizzleJsonBefore, drizzleJsonAfter)\n const sqlStatementsDown = await generateMigration(drizzleJsonAfter, drizzleJsonBefore)\n\n if (!sqlStatementsUp.length && !sqlStatementsDown.length && !forceAcceptWarning) {\n const { confirm: shouldCreateBlankMigration } = await prompts(\n {\n name: 'confirm',\n type: 'confirm',\n initial: false,\n message: 'No schema changes detected. Would you like to create a blank migration file?',\n },\n {\n onCancel: () => {\n process.exit(0)\n },\n },\n )\n\n if (!shouldCreateBlankMigration) {\n process.exit(0)\n }\n }\n\n // write schema\n fs.writeFileSync(`${filePath}.json`, JSON.stringify(drizzleJsonAfter, null, 2))\n\n // write migration\n fs.writeFileSync(\n `${filePath}.ts`,\n migrationTemplate(\n sqlStatementsUp.length ? sqlStatementsUp?.join('\\n') : undefined,\n sqlStatementsDown.length ? sqlStatementsDown?.join('\\n') : undefined,\n ),\n )\n payload.logger.info({ msg: `Migration created at ${filePath}.ts` })\n}\n"],"names":["fs","prompts","migrationTemplate","upSQL","downSQL","getDefaultDrizzleSnapshot","id","_meta","columns","schemas","tables","dialect","enums","prevId","version","createMigration","forceAcceptWarning","migrationName","payload","dir","db","migrationDir","existsSync","mkdirSync","generateDrizzleJson","generateMigration","yyymmdd","hhmmss","Date","toISOString","split","formattedDate","replace","formattedTime","timestamp","fileName","filePath","drizzleJsonBefore","latestSnapshot","readdirSync","filter","file","endsWith","sort","reverse","latestSnapshotJSON","JSON","parse","readFileSync","drizzleJsonAfter","schema","sqlStatementsUp","sqlStatementsDown","length","confirm","shouldCreateBlankMigration","name","type","initial","message","onCancel","process","exit","writeFileSync","stringify","join","undefined","logger","info","msg"],"mappings":"AAAA,yDAAyD,GAIzD,OAAOA,QAAQ,KAAI;AACnB,OAAOC,aAAa,UAAS;AAI7B,MAAMC,oBAAoB,CACxBC,OACAC,UACG,CAAC;;;;AAIN,EACED,QACI,CAAC;;AAEP,EAAEA,MAAM;AACR,CAAC,GACK,oBACL;;;;AAID,EAC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AAE;IAEjB,IAAIN,gBAAgB;QAClB,MAAMO,qBAAqBC,KAAKC,KAAK,CACnC/C,GAAGgD,YAAY,CAAC,CAAC,EAAE7B,IAAI,CAAC,EAAEmB,eAAe,CAAC,EAAE;QAG9CD,oBAAoBQ;IACtB;IAEA,MAAMI,mBAAmBzB,oBAAoB,IAAI,CAAC0B,MAAM;IACxD,MAAMC,kBAAkB,MAAM1B,kBAAkBY,mBAAmBY;IACnE,MAAMG,oBAAoB,MAAM3B,kBAAkBwB,kBAAkBZ;IAEpE,IAAI,CAACc,gBAAgBE,MAAM,IAAI,CAACD,kBAAkBC,MAAM,IAAI,CAACrC,oBAAoB;QAC/E,MAAM,EAAEsC,SAASC,0BAA0B,EAAE,GAAG,MAAMtD,QACpD;YACEuD,MAAM;YACNC,MAAM;YACNC,SAAS;YACTC,SAAS;QACX,GACA;YACEC,UAAU;gBACRC,QAAQC,IAAI,CAAC;YACf;QACF;QAGF,IAAI,CAACP,4BAA4B;YAC/BM,QAAQC,IAAI,CAAC;QACf;IACF;IAEA,eAAe;IACf9D,GAAG+D,aAAa,CAAC,CAAC,EAAE3B,SAAS,KAAK,CAAC,EAAEU,KAAKkB,SAAS,CAACf,kBAAkB,MAAM;IAE5E,kBAAkB;IAClBjD,GAAG+D,aAAa,CACd,CAAC,EAAE3B,SAAS,GAAG,CAAC,EAChBlC,kBACEiD,gBAAgBE,MAAM,GAAGF,iBAAiBc,KAAK,QAAQC,WACvDd,kBAAkBC,MAAM,GAAGD,mBAAmBa,KAAK,QAAQC;IAG/DhD,QAAQiD,MAAM,CAACC,IAAI,CAAC;QAAEC,KAAK,CAAC,qBAAqB,EAAEjC,SAAS,GAAG,CAAC;IAAC;AACnE,EAAC"}
@@ -37,4 +37,4 @@ export async function createVersion({ autosave, collectionSlug, parent, req = {}
37
37
  return result;
38
38
  }
39
39
 
40
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9jcmVhd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EVBQUUsQ0FBQztJQUNuQyxDQUFDO0lBQ0g7SUFFQSxPQUFPYjtBQUNUIn0=
40
+ //# sourceMappingURL=createVersion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/createVersion.ts"],"sourcesContent":["import type { CreateVersionArgs, TypeWithVersion } from 'payload/database'\nimport type { PayloadRequest, TypeWithID } from 'payload/types'\n\nimport { sql } from 'drizzle-orm'\nimport { buildVersionCollectionFields } from 'payload/versions'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { upsertRow } from './upsertRow/index.js'\n\nexport async function createVersion<T extends TypeWithID>(\n this: PostgresAdapter,\n {\n autosave,\n collectionSlug,\n parent,\n req = {} as PayloadRequest,\n versionData,\n }: CreateVersionArgs<T>,\n) {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const collection = this.payload.collections[collectionSlug].config\n const collectionTableName = toSnakeCase(collectionSlug)\n const tableName = `_${collectionTableName}_v`\n\n const result = await upsertRow<TypeWithVersion<T>>({\n adapter: this,\n data: {\n autosave,\n latest: true,\n parent,\n version: versionData,\n },\n db,\n fields: buildVersionCollectionFields(collection),\n operation: 'create',\n tableName,\n req,\n })\n\n const table = this.tables[tableName]\n const relationshipsTable = this.tables[`${tableName}_rels`]\n\n if (collection.versions.drafts) {\n await db.execute(sql`\n UPDATE ${table}\n SET latest = false\n FROM ${relationshipsTable}\n WHERE ${table.id} = ${relationshipsTable.parent}\n AND ${relationshipsTable.path} = ${'parent'}\n AND ${relationshipsTable[`${collectionSlug}ID`]} = ${parent}\n AND ${table.id} != ${result.id};\n `)\n }\n\n return result\n}\n"],"names":["sql","buildVersionCollectionFields","toSnakeCase","upsertRow","createVersion","autosave","collectionSlug","parent","req","versionData","db","sessions","transactionID","drizzle","collection","payload","collections","config","collectionTableName","tableName","result","adapter","data","latest","version","fields","operation","table","tables","relationshipsTable","versions","drafts","execute","id","path"],"mappings":"AAGA,SAASA,GAAG,QAAQ,cAAa;A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ACT"}
@@ -25,4 +25,4 @@ export const deleteMany = async function deleteMany({ collection, req = {}, wher
25
25
  }
26
26
  };
27
27
 
28
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9kZWxldGVNYW55LnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB0eXBlIHsgRGVsZXRlTWFueSB9IGZyb20gJ3BheWxvYWQvZGF0YWJhc2UnXG5pbXBvcnQgdHlwZSB7IFBheWxvYWRSZXF1ZXN0IH0gZnJvbSAncGF5bG9hZC90eXBlcydcblxuaW1wb3J0IHsgaW5BcnJheSB9IGZyb20gJ2RyaXp6bGUtb3JtJ1xuaW1wb3J0IHRvU25ha2VDYXNlIGZyb20gJ3RvLXNuYWtlLWNhc2UnXG5cbmltcG9ydCB0eXBlIHsgUG9zdGdyZXNBZGFwdGVyIH0gZnJvbSAnLi90eXBlcy5qcydcblxuaW1wb3J0IHsgZmluZE1hbnkgfSBmcm9tICcuL2ZpbmQvZmluZE1hbnkuanMnXG5cbmV4cG9ydCBjb25zdCBkZWxldGVNYW55OiBEZWxldGVNYW55ID0gYXN5bmMgZnVuY3Rpb24gZGVsZXRlTWFueShcbiAgdGhpczogUG9zdGdyZXNBZGFwdGVyLFxuICB7IGNvbGxlY3Rpb24sIHJlcSA9IHt9IGFzIFBheWxvYWRSZXF1ZXN0LCB3aGVyZSB9LFxuKSB7XG4gIGNvbnN0IGRiID0gdGhpcy5zZXNzaW9uc1tyZXEudHJhbnNhY3Rpb25JRF0/LmRiIHx8IHRoaXMuZHJpenpsZVxuICBjb25zdCBjb2xsZWN0aW9uQ29uZmlnID0gdGhpcy5wYXlsb2FkLmNvbGxlY3Rpb25zW2NvbGxlY3Rpb25dLmNvbmZpZ1xuICBjb25zdCB0YWJsZU5hbWUgPSB0b1NuYWtlQ2FzZShjb2xsZWN0aW9uKVxuXG4gIGNvbnN0IHJlc3VsdCA9IGF3YWl0IGZpbmRNYW55KH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Request } from 'payload/types'\n\nimport { inArray } from 'drizzle-orm'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\n\nexport const deleteMany: DeleteMany = async function deleteMany(\n this: PostgresAdapter,\n { collection, req = {} as PayloadRequest, where },\n) {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const collectionConfig = this.payload.collections[collection].config\n const tableName = toSnakeCase(collection)\n\n const result = await findMany({\n adapter: this,\n fields: collectionConfig.fields,\n limit: 0,\n locale: req.locale,\n page: 1,\n pagination: false,\n req,\n tableName,\n where,\n })\n\n const ids = []\n\n result.docs.forEach((data) => {\n ids.push(data.id)\n })\n\n if (ids.length > 0) {\n await db.delete(this.tables[tableName]).where(inArray(this.tables[tableName].id, ids))\n }\n}\n"],"names":["inArray","toSnakeCase","findMany","deleteMany","collection","req","where","db","sessions","transactionID","drizzle","collectionConfig","payload","collections","config","tableName","result","adapter","fields","limit","locale","page","pagination","ids","docs","forEach","data","push","id","length","delete","tables"],"mappings":"AAGA,SAASA,OAAO,QAAQ,cAAa;AACrC,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,QAAQ,QAAQ,qBAAoB;AAE7C,OAAO,MAAMC,aAAyB,eAAeA,WAEnD,EAAEC,UAAU,EAAEC,MAAM,CAAC,CAAmB,EAAEC,KAAK,EAAE;IAEjD,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACH,IAAII,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMC,mBAAmB,IAAI,CAACC,OAAO,CAACC,WAAW,CAACT,WAAW,CAACU,MAAM;IACpE,MAAMC,YAAYd,YAAYG;IAE9B,MAAMY,SAAS,MAAMd,SAAS;QAC5Be,SAAS,IAAI;QACbC,QAAQP,iBAAiBO,MAAM;QAC/BC,OAAO;QACPC,QAAQf,IAAIe,MAAM;QAClBC,MAAM;QACNC,YAAY;QACZjB;QACAU;QACAT;IACF;IAEA,MAAMiB,MAAM,EAAE;IAEdP,OAAOQ,IAAI,CAACC,OAAO,CAAC,CAACC;QACnBH,IAAII,IAAI,CAACD,KAAKE,EAAE;IAClB;IAEA,IAAIL,IAAIM,MAAM,GAAG,GAAG;QAClB,MAAMtB,GAAGuB,MAAM,CAAC,IAAI,CAACC,MAAM,CAAChB,UAAU,EAAET,KAAK,CAACN,QAAQ,IAAI,CAAC+B,MAAM,CAAChB,UAAU,CAACa,EAAE,EAAEL;IACnF;AACF,EAAC"}
package/dist/deleteOne.js CHANGED
@@ -29,4 +29,4 @@ export const deleteOne = async function deleteOne({ collection, req = {}, where:
29
29
  return result;
30
30
  };
31
31
 
32
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9kZWxldGVPbmUudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHR5cGUgeyBEZWxldGVPbmUgfSBmcm9tICdwYXlsb2FkL2RhdGFiYXNlJ1xuaW1wb3J0IHR5cGUgeyBQYXlsb2FkUmVxdWVzdCB9IGZyb20gJ3BheWxvYWQvdHlwZXMnXG5cbmltcG9ydCB0b1NuYWtlQ2FzZSBmcm9tICd0by1zbmFrZS1jYXNlJ1xuXG5pbXBvcnQgdHlwZSB7IFBvc3RncmVzQWRhcHRlciB9IGZyb20gJy4vdHlwZXMuanMnXG5cbmltcG9ydCB7IGJ1aWxkRmluZE1hbnlBcmdzIH0gZnJvbSAnLi9maW5kL2J1aWxkRmluZE1hbnlBcmdzLmpzJ1xuaW1wb3J0IGJ1aWxkUXVlcnkgZnJvbSAnLi9xdWVyaWVzL2J1aWxkUXVlcnkuanMnXG5pbXBvcnQgeyB0cmFuc2Zvcm0gfSBmcm9tICcuL3RyYW5zZm9ybS9yZWFkL2luZGV4LmpzJ1xuXG5leHBvcnQgY29uc3QgZGVsZXRlT25lOiBEZWxldGVPbmUgPSBhc3luYyBmdW5jdGlvbiBkZWxldGVPbmUoXG4gIHRoaXM6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WpCLFlBQVlLO0lBRTlCLE1BQU0sRUFBRUUsS0FBSyxFQUFFLEdBQUcsTUFBTUwsV0FBVztRQUNqQ2dCLFNBQVMsSUFBSTtRQUNiQyxRQUFRTixpQkFBaUJNLE1BQU07UUFDL0JGO1FBQ0FWLE9BQU9DO0lBQ1Q7SUFFQSxNQUFNWSxlQUFlbkIsa0JBQWtCO1FBQ3JDaUIsU0FBUyxJQUFJO1FBQ2JHLE9BQU87UUFDUEYsUUFBUU4saUJBQWlCTSxNQUFNO1FBQy9CRjtJQUNGO0lBRUFHLGFBQWFiLEtBQUssR0FBR0E7SUFFckIsTUFBTWUsY0FBYyxNQUFNYixHQUFHYyxLQUFLLENBQUNOLFVBQVUsQ0FBQ08sU0FBUyxDQUFDSjtJQUV4RCxNQUFNSyxTQUFTdEIsVUFBVTtRQUN2QmEsUUFBUSxJQUFJLENBQUNGLE9BQU8sQ0FBQ0UsTUFBTTtRQUMzQlUsTUFBTUo7UUFDTkgsUUFBUU4saUJBQWlCTSxNQUFNO0lBQ2pDO0lBRUEsTUFBTVYsR0FBR2tCLE1BQU0sQ0FBQyxJQUFJLENBQUNDLE1BQU0sQ0FBQ1gsVUFBVSxFQUFFVixLQUFLLENBQUNBO0lBRTlDLE9BQU9rQjtBQUNULEVBQUMifQ==
32
+ //# sourceMappingURL=deleteOne.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/deleteOne.ts"],"sourcesContent":["import type { DeleteOne } from 'payload/database'\nimport type { PayloadRequest } from 'payload/types'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { buildFindManyArgs } from './find/buildFindManyArgs.js'\nimport buildQuery from './queries/buildQuery.js'\nimport { transform } from './transform/read/index.js'\n\nexport const deleteOne: DeleteOne = async function deleteOne(\n this: PostgresAdapter,\n { collection, req = {} as PayloadRequest, where: incomingWhere },\n) {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const collectionConfig = this.payload.collections[collection].config\n const tableName = toSnakeCase(collection)\n\n const { where } = await buildQuery({\n adapter: this,\n fields: collectionConfig.fields,\n tableName,\n where: incomingWhere,\n })\n\n const findManyArgs = buildFindManyArgs({\n adapter: this,\n depth: 0,\n fields: collectionConfig.fields,\n tableName,\n })\n\n findManyArgs.where = where\n\n const docToDelete = await db.query[tableName].findFirst(findManyArgs)\n\n const result = transform({\n config: this.payload.config,\n data: docToDelete,\n fields: collectionConfig.fields,\n })\n\n await db.delete(this.tables[tableName]).where(where)\n\n return result\n}\n"],"names":["toSnakeCase","buildFindManyArgs","buildQuery","transform","deleteOne","collection","req","where","incomingWhere","db","sessions","transactionID","drizzle","collectionConfig","payload","collections","config","tableName","adapter","fields","findManyArgs","depth","docToDelete","query","findFirst","result","data","delete","tables"],"mappings":"AAGA,OAAOA,iBAAiB,gBAAe;AAIvC,SAASC,iBAAiB,QAAQ,8BAA6B;AAC/D,OAAOC,gBAAgB,0BAAyB;AAChD,SAASC,SAAS,QAAQ,4BAA2B;AAErD,OAAO,MAAMC,YAAuB,eAAeA,UAEjD,EAAEC,UAAU,EAAEC,MAAM,CAAC,CAAmB,EAAEC,OAAOC,aAAa,EAAE;IAEhE,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACJ,IAAIK,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMC,mBAAmB,IAAI,CAACC,OAAO,CAACC,WAAW,CAACV,WAAW,CAACW,MAAM;IACpE,MAAMC,YAAYjB,YAAYK;IAE9B,MAAM,EAAEE,KAAK,EAAE,GAAG,MAAML,WAAW;QACjCgB,SAAS,IAAI;QACbC,QAAQN,iBAAiBM,MAAM;QAC/BF;QACAV,OAAOC;IACT;IAEA,MAAMY,eAAenB,kBAAkB;QACrCiB,SAAS,IAAI;QACbG,OAAO;QACPF,QAAQN,iBAAiBM,MAAM;QAC/BF;IACF;IAEAG,aAAab,KAAK,GAAGA;IAErB,MAAMe,cAAc,MAAMb,GAAGc,KAAK,CAACN,UAAU,CAACO,SAAS,CAACJ;IAExD,MAAMK,SAAStB,UAAU;QACvBa,QAAQ,IAAI,CAACF,OAAO,CAACE,MAAM;QAC3BU,MAAMJ;QACNH,QAAQN,iBAAiBM,MAAM;IACjC;IAEA,MAAMV,GAAGkB,MAAM,CAAC,IAAI,CAACC,MAAM,CAACX,UAAU,EAAEV,KAAK,CAACA;IAE9C,OAAOkB;AACT,EAAC"}
@@ -28,4 +28,4 @@ export const deleteVersions = async function deleteVersion({ collection, locale,
28
28
  return docs;
29
29
  };
30
30
 
31
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9kZWxldGVWZXJzaW9ucy50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgdHlwZSB7IERlbGV0ZVZlcnNpb25zIH0gZnJvbSAncGF5bG9hZC9kYXRhYmFzZSdcbmltcG9ydCB0eXBlIHsgUGF5bG9hZFJlcXVlc3QsIFNhbml0aXplZENvbGxlY3Rpb25Db25maWcgfSBmcm9tICdwYXlsb2FkL3R5cGVzJ1xuXG5pbXBvcnQgeyBpbkFycmF5IH0gZnJvbSAnZHJpenpsZS1vcm0nXG5pbXBvcnQgeyBidWlsZFZlcnNpb25Db2xsZWN0aW9uRmllbGRzIH0gZnJvbSAncGF5bG9hZC92ZXJzaW9ucydcbmltcG9ydCB0b1NuYWtlQ2FzZSBmcm9tICd0by1zbmFrZS1jYXNlJ1xuXG5pbXBvcnQgdHlwZSB7IFBvc3RncmVzQWRhcHRlciB9IGZyb20gJy4vdHlwZXMuanMnXG5cbmltcG9ydCB7IGZpbmRNYW55IH0gZnJvbSAnLi9maW5kL2ZpbmRNYW55LmpzJ1xuXG5leHBvcnQgY29uc3QgZGVsZXRlVmVyc2lvbnM6IERlbGV0ZVZlcnNpb25zID0gYXN5bmMgZnVuY3Rpb24gZGVsZXRlVmVyc2lvbihcbiAgdGhpczogUG9zdGdyZXNBZGFwdGVyLFxuICB7IGN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FNLEVBQUVNLElBQUksRUFBRSxHQUFHLE1BQU1qQixTQUFTO1FBQzlCa0IsU0FBUyxJQUFJO1FBQ2JGO1FBQ0FHLE9BQU87UUFDUGY7UUFDQWdCLE1BQU07UUFDTkMsWUFBWTtRQUNaaEI7UUFDQVU7UUFDQVQ7SUFDRjtJQUVBLE1BQU1nQixNQUFNLEVBQUU7SUFFZEwsS0FBS00sT0FBTyxDQUFDLENBQUNDO1FBQ1pGLElBQUlHLElBQUksQ0FBQ0QsSUFBSUUsRUFBRTtJQUNqQjtJQUVBLElBQUlKLElBQUlLLE1BQU0sR0FBRyxHQUFHO1FBQ2xCLE1BQU1wQixHQUFHcUIsTUFBTSxDQUFDLElBQUksQ0FBQ0MsTUFBTSxDQUFDZCxVQUFVLEVBQUVULEtBQUssQ0FBQ1QsUUFBUSxJQUFJLENBQUNnQyxNQUFNLENBQUNkLFVBQVUsQ0FBQ1csRUFBRSxFQUFFSjtJQUNuRjtJQUVBLE9BQU9MO0FBQ1QsRUFBQyJ9
31
+ //# sourceMappingURL=deleteVersions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/deleteVersions.ts"],"sourcesContent":["import type { DeleteVersions } from 'payload/database'\nimport type { PayloadRequest, SanitizedCollectionConfig } from 'payload/types'\n\nimport { inArray } from 'drizzle-orm'\nimport { buildVersionCollectionFields } from 'payload/versions'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\n\nexport const deleteVersions: DeleteVersions = async function deleteVersion(\n this: PostgresAdapter,\n { collection, locale, req = {} as PayloadRequest, where: where },\n) {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config\n\n const tableName = `_${toSnakeCase(collection)}_v`\n const fields = buildVersionCollectionFields(collectionConfig)\n\n const { docs } = await findMany({\n adapter: this,\n fields,\n limit: 0,\n locale,\n page: 1,\n pagination: false,\n req,\n tableName,\n where,\n })\n\n const ids = []\n\n docs.forEach((doc) => {\n ids.push(doc.id)\n })\n\n if (ids.length > 0) {\n await db.delete(this.tables[tableName]).where(inArray(this.tables[tableName].id, ids))\n }\n\n return docs\n}\n"],"names":["inArray","buildVersionCollectionFields","toSnakeCase","findMany","deleteVersions","deleteVersion","collection","locale","req","where","db","sessions","transactionID","drizzle","collectionConfig","payload","collections","config","tableName","fields","docs","adapter","limit","page","pagination","ids","forEach","doc","push","id","length","delete","tables"],"mappings":"AAGA,SAASA,OAAO,QAAQ,cAAa;AACrC,SAASC,4BAA4B,QAAQ,mBAAkB;AAC/D,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,QAAQ,QAAQ,qBAAoB;AAE7C,OAAO,MAAMC,iBAAiC,eAAeC,cAE3D,EAAEC,UAAU,EAAEC,MAAM,EAAEC,MAAM,CAAC,CAAmB,EAAEC,OAAOA,KAAK,EAAE;IAEhE,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACH,IAAII,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMC,mBAA8C,IAAI,CAACC,OAAO,CAACC,WAAW,CAACV,WAAW,CAACW,MAAM;IAE/F,MAAMC,YAAY,CAAC,CAAC,EAAEhB,YAAYI,YAAY,EAAE,CAAC;IACjD,MAAMa,SAASlB,6BAA6Ba;IAE5C,MAAM,EAAEM,IAAI,EAAE,GAAG,MAAMjB,SAAS;QAC9BkB,SAAS,IAAI;QACbF;QACAG,OAAO;QACPf;QACAgB,MAAM;QACNC,YAAY;QACZhB;QACAU;QACAT;IACF;IAEA,MAAMgB,MAAM,EAAE;IAEdL,KAAKM,OAAO,CAAC,CAACC;QACZF,IAAIG,IAAI,CAACD,IAAIE,EAAE;IACjB;IAEA,IAAIJ,IAAIK,MAAM,GAAG,GAAG;QAClB,MAAMpB,GAAGqB,MAAM,CAAC,IAAI,CAACC,MAAM,CAACd,UAAU,EAAET,KAAK,CAACT,QAAQ,IAAI,CAACgC,MAAM,CAACd,UAAU,CAACW,EAAE,EAAEJ;IACnF;IAEA,OAAOL;AACT,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"destroy.d.ts","sourceRoot":"","sources":["../src/destroy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAI/C,eAAO,MAAM,OAAO,EAAE,OAGrB,CAAA"}
1
+ {"version":3,"file":"destroy.d.ts","sourceRoot":"","sources":["../src/destroy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAM/C,eAAO,MAAM,OAAO,EAAE,OAOrB,CAAA"}
package/dist/destroy.js CHANGED
@@ -1,6 +1,11 @@
1
+ import { pushDevSchema } from './utilities/pushDevSchema.js';
1
2
  export const destroy = async function destroy() {
2
- // TODO: this hangs test suite for some reason
3
- // await this.pool.end()
3
+ if (process.env.NODE_ENV !== 'production') {
4
+ await pushDevSchema(this);
5
+ } else {
6
+ // TODO: this hangs test suite for some reason
7
+ // await this.pool.end()
8
+ }
4
9
  };
5
10
 
6
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9kZXN0cm95LnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB0eXBlIHsgRGVzdHJveSB9IGZyb20gJ3BheWxvYWQvZGF0YWJhc2UnXG5cbmltcG9ydCB0eXBlIHsgUG9zdGdyZXNBZGFwdGVyIH0gZnJvbSAnLi90eXBlcy5qcydcblxuZXhwb3J0IGNvbnN0IGRlc3Ryb3k6IERlc3Ryb3kgPSBhc3luYyBmdW5jdGlvbiBkZXN0cm95KHRoaXM6IFBvc3RncmVzQWRhcHRlcikge1xuICAvLyBUT0RPOiB0aGlzIGhhbmdzIHRlc3Qgc3VpdGUgZm9yIHNvbWUgcmVhc29uXG4gIC8vIGF3YWl0IHRoaXMucG9vbC5lbmQoKVxufVxuIl0sIm5hbWVzIjpbImRlc3Ryb3kiXSwibWFwcGluZ3MiOiJBQUlBLE9BQU8sTUFBTUEsVUFBbUIsZUFBZUE7QUFDN0MsOENBQThDO0FBQzlDLHdCQUF3QjtBQUMxQixFQUFDIn0=
11
+ //# sourceMappingURL=destroy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/destroy.ts"],"sourcesContent":["import type { Destroy } from 'payload/database'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { pushDevSchema } from './utilities/pushDevSchema.js'\n\nexport const destroy: Destroy = async function destroy(this: PostgresAdapter) {\n if (process.env.NODE_ENV !== 'production') {\n await pushDevSchema(this)\n } else {\n // TODO: this hangs test suite for some reason\n // await this.pool.end()\n }\n}\n"],"names":["pushDevSchema","destroy","process","env","NODE_ENV"],"mappings":"AAIA,SAASA,aAAa,QAAQ,+BAA8B;AAE5D,OAAO,MAAMC,UAAmB,eAAeA;IAC7C,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,MAAMJ,cAAc,IAAI;IAC1B,OAAO;IACL,8CAA8C;IAC9C,wBAAwB;IAC1B;AACF,EAAC"}
@@ -61,4 +61,4 @@ export const buildFindManyArgs = ({ adapter, depth, fields, tableName })=>{
61
61
  return result;
62
62
  };
63
63
 
64
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9maW5kL2J1aWxkRmluZE1hbnlBcmdzLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB0eXBlIHsgREJRdWVyeUNvbmZpZyB9IGZyb20gJ2RyaXp6bGUtb3JtJ1xuaW1wb3J0IHR5cGUgeyBGaWVsZCB9IGZyb20gJ3BheWxvYWQvdHlwZXMnXG5cbmltcG9ydCB0eXBlIHsgUG9zdGdyZXNBZGFwdGVyIH0gZnJvbSAnLi4vdHlwZXMuanMnXG5cbmltcG9ydCB7IHRyYXZlcnNlRmllbGRzIH0gZnJv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EVBQUU7UUFDMUNDLE9BQU9DLElBQUksQ0FBQ1ksUUFBUSxHQUFHO1lBQ3JCVixTQUFTO2dCQUNQQyxJQUFJO2dCQUNKSSxRQUFRO1lBQ1Y7WUFDQUMsU0FBUyxDQUFDLEVBQUVDLEtBQUssRUFBRSxFQUFFLEVBQUVDLEtBQUtDLEdBQUcsRUFBRSxHQUFLO29CQUFDQSxJQUFJRjtpQkFBTztRQUNwRDtJQUNGO0lBRUEsSUFBSWQsUUFBUVUsTUFBTSxDQUFDLENBQUMsRUFBRVAsVUFBVSxLQUFLLENBQUMsQ0FBQyxFQUFFO1FBQ3ZDQyxPQUFPQyxJQUFJLENBQUNhLEtBQUssR0FBRztZQUNsQlgsU0FBUztnQkFDUEMsSUFBSTtnQkFDSkksUUFBUTtZQUNWO1lBQ0FDLFNBQVMsQ0FBQyxFQUFFQyxLQUFLLEVBQUUsRUFBRSxFQUFFQyxLQUFLQyxHQUFHLEVBQUUsR0FBSztvQkFBQ0EsSUFBSUY7aUJBQU87UUFDcEQ7SUFDRjtJQUVBLElBQUlkLFFBQVFVLE1BQU0sQ0FBQyxDQUFDLEVBQUVQLFVBQVUsUUFBUSxDQUFDLENBQUMsRUFBRTtRQUMxQ0MsT0FBT0MsSUFBSSxDQUFDQyxRQUFRLEdBQUdBO0lBQ3pCO0lBRUFSLGVBQWU7UUFDYlE7UUFDQU47UUFDQW1CLGFBQWFmO1FBQ2JnQixrQkFBa0JqQjtRQUNsQkY7UUFDQUM7UUFDQW1CLE1BQU07UUFDTkMsY0FBY2xCO1FBQ2RtQixtQkFBbUJwQjtJQUNyQjtJQUVBLE9BQU9DO0FBQ1QsRUFBQyJ9
64
+ //# sourceMappingURL=buildFindManyArgs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/find/buildFindManyArgs.ts"],"sourcesContent":["import type { DBQueryConfig } from 'drizzle-orm'\nimport type { Field } from 'payload/types'\n\nimport type { PostgresAdapter } from '../types.js'\n\nimport { traverseFields } from './traverseFields.js'\n\ntype BuildFindQueryArgs = {\n adapter: PostgresAdapter\n depth: number\n fields: Field[]\n tableName: string\n}\n\nexport type Result = DBQueryConfig<'many', true, any, any>\n\n// Generate the Drizzle query for findMany based on\n// a collection field structure\nexport const buildFindManyArgs = ({\n adapter,\n depth,\n fields,\n tableName,\n}: BuildFindQueryArgs): Record<string, unknown> => {\n const result: Result = {\n with: {},\n }\n\n const _locales: Result = {\n columns: {\n id: false,\n _parentID: false,\n },\n }\n\n if (adapter.tables[`${tableName}_texts`]) {\n result.with._texts = {\n columns: {\n id: false,\n parent: false,\n },\n orderBy: ({ order }, { asc: ASC }) => [ASC(order)],\n }\n }\n\n if (adapter.tables[`${tableName}_numbers`]) {\n result.with._numbers = {\n columns: {\n id: false,\n parent: false,\n },\n orderBy: ({ order }, { asc: ASC }) => [ASC(order)],\n }\n }\n\n if (adapter.tables[`${tableName}_rels`]) {\n result.with._rels = {\n columns: {\n id: false,\n parent: false,\n },\n orderBy: ({ order }, { asc: ASC }) => [ASC(order)],\n }\n }\n\n if (adapter.tables[`${tableName}_locales`]) {\n result.with._locales = _locales\n }\n\n traverseFields({\n _locales,\n adapter,\n currentArgs: result,\n currentTableName: tableName,\n depth,\n fields,\n path: '',\n topLevelArgs: result,\n topLevelTableName: tableName,\n })\n\n return result\n}\n"],"names":["traverseFields","buildFindManyArgs","adapter","depth","fields","tableName","result","with","_locales","columns","id","_parentID","tables","_texts","parent","orderBy","order","asc","ASC","_numbers","_rels","currentArgs","currentTableName","path","topLevelArgs","topLevelTableName"],"mappings":"AAKA,SAASA,cAAc,QAAQ,sBAAqB;AAWpD,mDAAmD;AACnD,+BAA+B;AAC/B,OAAO,MAAMC,oBAAoB,CAAC,EAChCC,OAAO,EACPC,KAAK,EACLC,MAAM,EACNC,SAAS,EACU;IACnB,MAAMC,SAAiB;QACrBC,MAAM,CAAC;IACT;IAEA,MAAMC,WAAmB;QACvBC,SAAS;YACPC,IAAI;YACJC,WAAW;QACb;IACF;IAEA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find/chainMethods.ts"],"sourcesContent":["export type ChainedMethods = {\n args: unknown[]\n method: string\n}[]\n\n/**\n * Call and returning methods that would normally be chained together but cannot be because of control logic\n * @param methods\n * @param query\n */\nconst chainMethods = ({ methods, query }): Promise<unknown> => {\n return methods.reduce((query, { args, method }) => {\n return query[method](...args)\n }, query)\n}\n\nexport { chainMethods }\n"],"names":["chainMethods","methods","query","reduce","args","method"],"mappings":"AAKA;;;;CAIC,GACD,MAAMA,eAAe,CAAC,EAAEC,OAAO,EAAEC,KAAK,EAAE;IACtC,OAAOD,QAAQE,MAAM,CAAC,CAACD,OAAO,EAAEE,IAAI,EAAEC,MAAM,EAAE;QAC5C,OAAOH,KAAK,CAACG,OAAO,IAAID;IAC1B,GAAGF;AACL;AAEA,SAASF,YAAY,GAAE"}
@@ -182,4 +182,4 @@ export const findMany = async function find({ adapter, fields, limit: limitArg,
182
182
  };
183
183
  };
184
184
 
185
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9maW5kL2ZpbmRNYW55LnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB0eXBlIHsgRmluZEFyZ3MgfSBmcm9tICdwYXlsb2FkL2RhdGFiYXNlJ1xuaW1wb3J0IHR5cGUgeyBGaWVsZCwgUGF5bG9hZFJlcXVlc3QsIFR5cGVXaXRoSUQgfSBmcm9tICdwYXlsb2FkL3R5cGVzJ1xuXG5pbXBvcnQgeyBpbkFycmF5LCBzcWwgfSBmcm9tICdkcml6emxlLW9ybSdcblxuaW1wb3J0IHR5cGUgeyBQb3N0Z3Jlc0FkYXB0ZXIgfSBmcm9tICcuLi90eXBlcy5qcydcbmltcG9ydCB0eXBlIHsgQ2hhaW5lZE1ldGhvZHMgfSBmcm9tICcuL2NoYWluTWV0aG9kcy5qcydcblxuaW1wb3J0IGJ1aWxkUXVlcnkgZnJvbSAnLi4vcXVlcmllcy9idWlsZFF1ZXJ5LmpzJ1xu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UFFYixFQUFFLENBQUMsR0FBR3pCLFlBQVksQ0FBQ3VDLEVBQUVkLEVBQUUsQ0FBQztJQUNoRTtJQUVBLElBQUloRCxlQUFlLFNBQVMsQ0FBQ2EsV0FBVztRQUN0Q0EsWUFBWStDLFFBQVF6QixNQUFNO1FBQzFCckIsYUFBYTtRQUNiRyxnQkFBZ0I7UUFDaEJGLGNBQWM7UUFDZEMsY0FBYztJQUNoQjtJQUVBLE1BQU02QixPQUFPZSxRQUFRRyxHQUFHLENBQUMsQ0FBQ0M7UUFDeEIsT0FBTzNFLFVBQVU7WUFDZjRFLFFBQVF2RSxRQUFRd0UsT0FBTyxDQUFDRCxNQUFNO1lBQzlCRDtZQUNBckU7UUFDRjtJQUNGO0lBRUEsT0FBTztRQUNMa0Q7UUFDQTdCO1FBQ0FEO1FBQ0FuQjtRQUNBa0QsVUFBVTlCLGNBQWNqQixPQUFPLElBQUk7UUFDbkNBO1FBQ0FrQjtRQUNBOEIsVUFBVWhDLGNBQWNoQixPQUFPLElBQUk7UUFDbkNjO1FBQ0FDO0lBQ0Y7QUFDRixFQUFDIn0=
185
+ //# sourceMappingURL=findMany.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/find/findMany.ts"],"sourcesContent":["import type { FindArgs } from 'payload/database'\nimport type { Field, PayloadRequest, TypeWithID } from 'payload/types'\n\nimport { inArray, sql } from 'drizzle-orm'\n\nimport type { PostgresAdapter } from '../types.js'\nimport type { ChainedMethods } from './chainMethods.js'\n\nimport buildQuery from '../queries/buildQuery.js'\nimport { transform } from '../transform/read/index.js'\nimport { buildFindManyArgs } from './buildFindManyArgs.js'\nimport { chainMethods } from './chainMethods.js'\n\ntype Args = Omit<FindArgs, 'collection'> & {\n adapter: PostgresAdapter\n fields: Field[]\n tableName: string\n}\n\nexport const findMany = async function find({\n adapter,\n fields,\n limit: limitArg,\n locale,\n page = 1,\n pagination,\n req = {} as PayloadRequest,\n skip,\n sort,\n tableName,\n where: whereArg,\n}: Args) {\n const db = adapter.sessions[req.transactionID]?.db || adapter.drizzle\n const table = adapter.tables[tableName]\n\n const limit = limitArg ?? 10\n let totalDocs: number\n let totalPages: number\n let hasPrevPage: boolean\n let hasNextPage: boolean\n let pagingCounter: number\n let selectDistinctResult\n\n const { joinAliases, joins, orderBy, selectFields, where } = await buildQuery({\n adapter,\n fields,\n locale,\n sort,\n tableName,\n where: whereArg,\n })\n\n const orderedIDMap: Record<number | string, number> = {}\n let orderedIDs: (number | string)[]\n\n const selectDistinctMethods: ChainedMethods = []\n\n if (orderBy?.order && orderBy?.column) {\n selectDistinctMethods.push({\n args: [orderBy.order(orderBy.column)],\n method: 'orderBy',\n })\n }\n\n const findManyArgs = buildFindManyArgs({\n adapter,\n depth: 0,\n fields,\n tableName,\n })\n\n // only fetch IDs when a sort or where query is used that needs to be done on join tables, otherwise these can be done directly on the table in findMany\n if (Object.keys(joins).length > 0 || joinAliases.length > 0) {\n if (where) {\n selectDistinctMethods.push({ args: [where], method: 'where' })\n }\n\n joinAliases.forEach(({ condition, table }) => {\n selectDistinctMethods.push({\n args: [table, condition],\n method: 'leftJoin',\n })\n })\n\n Object.entries(joins).forEach(([joinTable, condition]) => {\n if (joinTable) {\n selectDistinctMethods.push({\n args: [adapter.tables[joinTable], condition],\n method: 'leftJoin',\n })\n }\n })\n\n selectDistinctMethods.push({ args: [skip || (page - 1) * limit], method: 'offset' })\n selectDistinctMethods.push({ args: [limit === 0 ? undefined : limit], method: 'limit' })\n\n selectDistinctResult = await chainMethods({\n methods: selectDistinctMethods,\n query: db.selectDistinct(selectFields).from(table),\n })\n\n if (selectDistinctResult.length === 0) {\n return {\n docs: [],\n hasNextPage: false,\n hasPrevPage: false,\n limit,\n nextPage: null,\n page: 1,\n pagingCounter: 0,\n prevPage: null,\n totalDocs: 0,\n totalPages: 0,\n }\n }\n // set the id in an object for sorting later\n selectDistinctResult.forEach(({ id }, i) => {\n orderedIDMap[id as number | string] = i\n })\n orderedIDs = Object.keys(orderedIDMap)\n findManyArgs.where = inArray(adapter.tables[tableName].id, orderedIDs)\n } else {\n findManyArgs.limit = limitArg === 0 ? undefined : limitArg\n\n const offset = skip || (page - 1) * limitArg\n\n if (!Number.isNaN(offset)) findManyArgs.offset = offset\n\n if (where) {\n findManyArgs.where = where\n }\n findManyArgs.orderBy = orderBy.order(orderBy.column)\n }\n\n const findPromise = db.query[tableName].findMany(findManyArgs)\n\n if (pagination !== false && (orderedIDs ? orderedIDs?.length >= limit : true)) {\n const selectCountMethods: ChainedMethods = []\n\n joinAliases.forEach(({ condition, table }) => {\n selectCountMethods.push({\n args: [table, condition],\n method: 'leftJoin',\n })\n })\n\n Object.entries(joins).forEach(([joinTable, condition]) => {\n if (joinTable) {\n selectCountMethods.push({\n args: [adapter.tables[joinTable], condition],\n method: 'leftJoin',\n })\n }\n })\n\n const countResult = await chainMethods({\n methods: selectCountMethods,\n query: db\n .select({\n count: sql<number>`count\n (DISTINCT ${adapter.tables[tableName].id})`,\n })\n .from(table)\n .where(where),\n })\n totalDocs = Number(countResult[0].count)\n totalPages = typeof limit === 'number' && limit !== 0 ? Math.ceil(totalDocs / limit) : 1\n hasPrevPage = page > 1\n hasNextPage = totalPages > page\n pagingCounter = (page - 1) * limit + 1\n }\n\n const rawDocs = await findPromise\n // sort rawDocs from selectQuery\n if (Object.keys(orderedIDMap).length > 0) {\n rawDocs.sort((a, b) => orderedIDMap[a.id] - orderedIDMap[b.id])\n }\n\n if (pagination === false || !totalDocs) {\n totalDocs = rawDocs.length\n totalPages = 1\n pagingCounter = 1\n hasPrevPage = false\n hasNextPage = false\n }\n\n const docs = rawDocs.map((data: TypeWithID) => {\n return transform({\n config: adapter.payload.config,\n data,\n fields,\n })\n })\n\n return {\n docs,\n hasNextPage,\n hasPrevPage,\n limit,\n nextPage: hasNextPage ? page + 1 : null,\n page,\n pagingCounter,\n prevPage: hasPrevPage ? page - 1 : null,\n totalDocs,\n totalPages,\n }\n}\n"],"names":["inArray","sql","buildQuery","transform","buildFindManyArgs","chainMethods","findMany","find","adapter","fields","limit","limitArg","locale","page","pagination","req","skip","sort","tableName","where","whereArg","db","sessions","transactionID","drizzle","table","tables","totalDocs","totalPages","hasPrevPage","hasNextPage","pagingCounter","selectDistinctResult","joinAliases","joins","orderBy","selectFields","orderedIDMap","orderedIDs","selectDistinctMethods","order","column","push","args","method","findManyArgs","depth","Object","keys","length","forEach","condition","entries","joinTable","undefined","methods","query","selectDistinct","from","docs","nextPage","prevPage","id","i","offset","Number","isNaN","findPromise","selectCountMethods","countResult","select","count","Math","ceil","rawDocs","a","b","map","data","config","payload"],"mappings":"AAGA,SAASA,OAAO,EAAEC,GAAG,QAAQ,cAAa;AAK1C,OAAOC,gBAAgB,2BAA0B;AACjD,SAASC,SAAS,QAAQ,6BAA4B;AACtD,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,YAAY,QAAQ,oBAAmB;AAQhD,OAAO,MAAMC,WAAW,eAAeC,KAAK,EAC1CC,OAAO,EACPC,MAAM,EACNC,OAAOC,QAAQ,EACfC,MAAM,EACNC,OAAO,CAAC,EACRC,UAAU,EACVC,MAAM,CAAC,CAAmB,EAC1BC,IAAI,EACJC,IAAI,EACJC,SAAS,EACTC,OAAOC,QAAQ,EACV;IACL,MAAMC,KAAKb,QAAQc,QAAQ,CAACP,IAAIQ,aAAa,CAAC,EAAEF,MAAMb,QAAQgB,OAAO;IACrE,MAAMC,QAAQjB,QAAQkB,MAAM,CAACR,UAAU;IAEvC,MAAMR,QAAQC,YAAY;IAC1B,IAAIgB;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IAEJ,MAAM,EAAEC,WAAW,EAAEC,KAAK,EAAEC,OAAO,EAAEC,YAAY,EAAEjB,KAAK,EAAE,GAAG,MAAMjB,WAAW;QAC5EM;QACAC;QACAG;QACAK;QACAC;QACAC,OAAOC;IACT;IAEA,MAAMiB,eAAgD,CAAC;IACvD,IAAIC;IAEJ,MAAMC,wBAA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C5CP,QAAQ;gBACV;YACF;QACF;QAEA,MAAMyB,cAAc,MAAMhE,aAAa;YACrCkD,SAASa;YACTZ,OAAOnC,GACJiD,MAAM,CAAC;gBACNC,OAAOtE,GAAW,CAAC;wBACL,EAAEO,QAAQkB,MAAM,CAACR,UAAU,CAAC4C,EAAE,CAAC,CAAC,CAAC;YACjD,GACCJ,IAAI,CAACjC,OACLN,KAAK,CAACA;QACX;QACAQ,YAAYsC,OAAOI,WAAW,CAAC,EAAE,CAACE,KAAK;QACvC3C,aAAa,OAAOlB,UAAU,YAAYA,UAAU,IAAI8D,KAAKC,IAAI,CAAC9C,YAAYjB,SAAS;QACvFmB,cAAchB,OAAO;QACrBiB,cAAcF,aAAaf;QAC3BkB,gBAAgB,AAAClB,CAAAA,OAAO,CAAA,IAAKH,QAAQ;IACvC;IAEA,MAAMgE,UAAU,MAAMP;IACtB,gCAAgC;IAChC,IAAIpB,OAAOC,IAAI,CAACX,cAAcY,MAAM,GAAG,GAAG;QACxCyB,QAAQzD,IAAI,CAAC,CAAC0D,GAAGC,IAAMvC,YAAY,CAACsC,EAAEb,EAAE,CAAC,GAAGzB,YAAY,CAACuC,EAAEd,EAAE,CAAC;IAChE;IAEA,IAAIhD,eAAe,SAAS,CAACa,WAAW;QACtCA,YAAY+C,QAAQzB,MAAM;QAC1BrB,aAAa;QACbG,gBAAgB;QAChBF,cAAc;QACdC,cAAc;IAChB;IAEA,MAAM6B,OAAOe,QAAQG,GAAG,CAAC,CAACC;QACxB,OAAO3E,UAAU;YACf4E,QAAQvE,QAAQwE,OAAO,CAACD,MAAM;YAC9BD;YACArE;QACF;IACF;IAEA,OAAO;QACLkD;QACA7B;QACAD;QACAnB;QACAkD,UAAU9B,cAAcjB,OAAO,IAAI;QACnCA;QACAkB;QACA8B,UAAUhC,cAAchB,OAAO,IAAI;QACnCc;QACAC;IACF;AACF,EAAC"}
@@ -132,4 +132,4 @@ export const traverseFields = ({ _locales, adapter, currentArgs, currentTableNam
132
132
  return topL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pZWxkcyxcbiAgcGF0aCxcbiAgdG9wTGV2ZWxBcmdzLFxuICB0b3BMZXZlbFRhYmxlTmFtZSxcbn06IFRyYXZlcnNlRmllbGRBcmdzKSA9PiB7XG4gIGZpZWxkcy5mb3JFYWNoKChmaWVsZCkgPT4ge1xuICAgIGlmIChmaWVsZC50eXBlID09PSAnY29sbGFwc2libGUnIHx8IGZpZWxkLnR5cGUgPT09ICdyb3cnKSB7XG4gICAgICB0cmF2ZXJzZUZpZWxkcyh7XG4gICAgICAgIF9sb2NhbGVzLFxuICAgICAgICBhZGFwdGVyLFxuICAgICAgICBjdXJyZW50QXJncyxcbiAgICAgICAgY3VycmVudFRhYmxlTmFtZSxcbiAgICAgICAgZGVwdGgsXG4gICAgICAgIGZpZWxkczogZmllbGQuZmllbGRzLFxuICAgICAgICBwYXRoLFxuICAgICAgICB0b3BMZXZlbEFyZ3MsXG4gICAgICAgIHRvcExldmVsVGFibGVOYW1lLFxuICAgICAgfSlcblxuICAgICAgcmV0dXJuXG4gICAgfVxuXG4gICAgaWYgKGZpZWxkLnR5cGUgPT09ICd0YWJzJykge1xuICAgICAgZmllbGQudGFicy5mb3JFYWNoKCh0YWIpID0+IHtcbiAgICAgICAgY29uc3QgdGFiUGF0aCA9IHRhYkhhc05hbWUodGFiKSA/IGAke3BhdGh9JHt0YWIubmFtZX1fYCA6IHBhdGhcblxuICAgICAgICB0cmF2ZXJzZUZpZWxkcyh7XG4gICAgICAgICAgX2xvY2FsZXMsXG4gICAgICAgICAgYWRhcHRlcixcbiAgICAgICAgICBjdXJyZW50QXJncyxcbiAgICAgICAgICBjdXJyZW50VGFibGVOYW1lLFxuICAgICAgICAgIGRlcHRoLFxuICAgICAgICAgIGZpZWxkczogdGFiLmZpZWxkcyxcbiAgICAgICAgICBwYXRoOiB0YWJQYXRoLFxuICAgICAgICAgIHRvcExldmVsQXJncyxcbiAgICAgICAgICB0b3BMZXZlbFRhYmxlTmFtZSxcbiAgICAgICAgfSlcbiAgICAgIH0pXG5cbiAgICAgIHJldHVyblxuICAgIH1cblxuICAgIGlmIChmaWVsZEFmZmVjdHNEYXRhKGZpZWxkKSkge1xuICAgICAgc3dpdGNoIChmaWVsZC50eXBlKSB7XG4gICAgICAgIGNhc2UgJ2FycmF5Jzoge1xuICAgICAgICAgIGNvbnN0IHdpdGhBcnJheTogUmVzdWx0ID0ge1xuICAgICAgICAgICAgY29sdW1uczoge1xuICAgICAgICAgICAgICBfcGFyZW50SUQ6IGZhbHNlLFxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIG9yZGVyQnk6ICh7IF9vcmRlciB9LCB7IGFzYyB9KSA9PiBbYXNjKF9vcmRlcildLFxuICAgICAgICAgICAgd2l0aDoge30sXG4gICAgICAgICAgfVxuXG4gICAgICAgICAgY29uc3QgYXJyYXlUYWJsZU5hbWUgPSBgJHtjdXJyZW50VGFibGVOYW1lfV8ke3BhdGh9JHt0b1NuYWtlQ2FzZShmaWVsZC5uYW1lKX1gXG5cbiAgICAgICAgICBpZiAoYWRhcHRlci50YWJsZXNbYCR7YXJyYXlUYWJsZU5hbWV9X2xvY2FsZXNgXSkgd2l0aEFycmF5LndpdGguX2xvY2FsZXMgPSBfbG9jYWxlc1xuICAgICAgICAgIGN1cnJlbnRBcmdzLndpdGhbYCR7cGF0aH0ke2ZpZWxkLm5hbWV9YF0gPSB3aXRoQXJyYXlcblxuICAgICAgICAgIHRyYXZlcnNlRmllbGRzKHtcbiAgICAgICAgICAgIF9sb2NhbGVzLFxuICAgICAgICAgICAgYWRhcHRlcixcbiAgICAgICAgICAgIGN1cnJlbnRBcmdzOiB3aXRoQXJyYXksXG4gICAgICAgICAgICBjdXJyZW50VGFibGVOYW1lOiBhcnJheVRhYmxlTmFtZSxcbiAgICAgICAgICAgIGRlcHRoLFxuICAgICAgICAgICAgZmllbGRzOiBmaWVsZC5maWVsZHMsXG4gICAgICAgICAgICBwYXRoOiAnJyxcbiAgICAgICAgICAgIHRvcExldmVsQXJncyxcbiAgICAgICAgICAgIHRvcExldmVsVGFibGVOYW1lLFxuICAgICAgICAgIH0pXG5cbiAgICAgICAgICBicmVha1xuICAgICAgICB9XG5cbiAgICAgICAgY2FzZSAnc2VsZWN0Jzoge1xuICAgICAgICAgIGlmIChmaWVsZC5oYXNNYW55KSB7XG4gICAgICAgICAgICBjb25zdCB3aXRoU2VsZWN0OiBSZXN1bHQgPSB7XG4gICAgICAgICAgICAgIGNvbHVtbnM6IHtcbiAgICAgICAgICAgICAgICBpZDogZmFsc2UsXG4gICAgICAgICAgICAgICAgb3JkZXI6IGZhbHNlLFxuICAgICAgICAgICAgICAgIHBhcmVudDogZmFsc2UsXG4gICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgIG9yZGVyQnk6ICh7IG9yZGVyIH0sIHsgYXNjIH0pID0+IFthc2Mob3JkZXIpXSxcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgY3VycmVudEFyZ3Mud2l0aFtgJHtwYXRofSR7ZmllbGQubmFtZX1gXSA9IHdpdGhTZWxlY3RcbiAgICAgICAgICB9XG5cbiAgICAgICAgICBicmVha1xuICAgICAgICB9XG5cbiAgICAgICAgY2FzZSAnYmxvY2tzJzpcbiAgICAgICAgICBmaWVsZC5ibG9ja3MuZm9yRWFjaCgoYmxvY2spID0+IHtcbiAgICAgICAgICAgIGNvbnN0IGJsb2NrS2V5ID0gYF9ibG9ja3NfJHtibG9jay5zbHVnfWBcblxuICAgICAgICAgICAgaWYgKCF0b3BMZXZlbEFyZ3NbYmxvY2tLZXldKSB7XG4gICAgICAgICAgICAgIGNvbnN0IHdpdGhCbG9jazogUmVzdWx0ID0ge1xuICAgICAgICAgICAgICAgIGNvbHVtbnM6IHtcbiAgICAgICAgICAgICAgICAgIF9wYXJlbnRJRDogZmFsc2UsXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBvcmRlckJ5OiAoeyBfb3JkZXIgfSwgeyBhc2MgfSkgPT4gW2FzYyhfb3JkZXIpXSxcbiAgICAgICAgICAgICAgICB3aXRoOiB7fSxcbiAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgIGNvbnN0IHRhYmxlTmFtZSA9IGAke3RvcExldmVsVGFibGVOYW1lfV9ibG9ja3NfJHt0b1NuYWtlQ2FzZShibG9jay5zbHVnKX1gXG5cbiAgICAgICAgICAgICAgaWYgKGFkYXB0ZXIudGFibGVzW2Ake3RhYmxlTmFtZX1fbG9jYWxlc2BdKSB3aXRoQmxvY2sud2l0aC5fbG9jYWxlcyA9IF9sb2NhbGVzXG4gICAgICAgICAgICAgIHRvcExldmVsQXJncy53aXRoW2Jsb2NrS2V5XSA9IHdpdGhCbG9ja1xuXG4gICAgICAgICAgICAgIHRyYXZlcnNlRmllbGRzKHtcbiAgICAgICAgICAgICAgICBfbG9jYWxlcyxcbiAgICAgICAgICAgICAgICBhZGFwdGVyLFxuICAgICAgICAgICAgICAgIGN1cnJlbnRBcmdzOiB3aXRoQmxvY2ssXG4gICAgICAgICAgICAgICAgY3VycmVudFRhYmxlTmFtZTogdGFibGVOYW1lLFxuICAgICAgICAgICAgICAgIGRlcHRoLFxuICAgICAgICAgICAgICAgIGZpZWxkczogYmxvY2suZmllbGRzLFxuICAgICAgICAgICAgICAgIHBhdGg6ICcnLFxuICAgICAgICAgICAgICAgIHRvcExldmVsQXJncyxcbiAgICAgICAgICAgICAgICB0b3BMZXZlbFRhYmxlTmFtZSxcbiAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9KVxuXG4gICAgICAgICAgYnJlYWtcblxuICAgICAgICBjYXNlICdncm91cCc6XG4gICAgICAgICAgdHJhdmVyc2VGaWVsZHMoe1xuICAgICAgICAgICAgX2xvY2FsZXMsXG4gICAgICAgICAgICBhZGFwdGVyLFxuICAgICAgICAgICAgY3VycmVudEFyZ3MsXG4gICAgICAgICAgICBjdXJyZW50VGFibGVOYW1lLFxuICAgICAgICAgICAgZGVwdGgsXG4gICAgICAgICAgICBmaWVsZH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FDQUM7b0JBQ0Y7b0JBRUE7Z0JBRUY7b0JBQVM7d0JBQ1A7b0JBQ0Y7WUFDRjtRQUNGO0lBQ0Y7SUFFQSxPQUFPRDtBQUNULEVBQUMifQ==
135
+ //# sourceMappingURL=traverseFields.js.map
@@ -0,0 +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'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from '../types.js'\nimport type { Result } from './buildFindManyArgs.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 = `${currentTableName}_${path}${toSnakeCase(field.name)}`\n\n if (adapter.tables[`${arrayTableName}_locales`]) 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 = `${topLevelTableName}_blocks_${toSnakeCase(block.slug)}`\n\n if (adapter.tables[`${tableName}_locales`]) withBlock.with._locales = _locales\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","toSnakeCase","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","tables","hasMany","withSelect","id","order","parent","blocks","block","blockKey","slug","withBlock","tableName"],"mappings":"AAAA,oCAAoC,GAGpC,SAASA,gBAAgB,EAAEC,UAAU,QAAQ,gBAAe;AAC5D,OAAOC,iBAAiB,gBAAe;AAiBvC,OAAO,MAAMC,iBAAiB,CAAC,EAC7B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F;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"}
package/dist/find.js CHANGED
@@ -17,4 +17,4 @@ export const find = async function find({ collection, limit: limitArg, locale, p
17
17
  });
18
18
  };
19
19
 
20
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9maW5kLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB0eXBlIHsgRmluZCB9IGZyb20gJ3BheWxvYWQvZGF0YWJhc2UnXG5pbXBvcnQgdHlwZSB7IFBheWxvYWRSZXF1ZXN0LCBTYW5pdGl6ZWRDb2xsZWN0aW9uQ29uZmlnIH0gZnJvbSAncGF5bG9hZC90eXBlcydcblxuaW1wb3J0IHRvU25ha2VDYXNlIGZyb20gJ3RvLXNuYWtlLWNhc2UnXG5cbmltcG9ydCB0eXBlIHsgUG9zdGdyZXNBZGFwdGVyIH0gZnJvbSAnLi90eXBlcy5qcydcblxuaW1wb3J0IHsgZmluZE1hbnkgfSBmcm9tICcuL2ZpbmQvZmluZE1hbnkuanMnXG5cbmV4cG9ydCBjb25zdCBmaW5kOiBGaW5kID0gYXN5bmMgZnVuY3Rpb24gZmluZChcbiAgdGhpczogUG9zdGdyZXNBZGFwdGVyLFxuICB7XG4gICAgY29sbGVjdGlvbixcbiAgICBsaW1pdDogbGltaXRBcmcsXG4gICAgbG9jYWxlLFxuICAgIHBhZ2UgPSAxLFxuICAgIHBhZ2luYXRpb24sXG4gICAgcmVxID0ge30gYXMgUGF5bG9hZFJlcXVlc3QsXG4gICAgc29ydDogc29ydEFyZyxcbiAgICB3aGVyZ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MsT0FBT0MsUUFBUSxFQUNmQyxNQUFNLEVBQ05DLE9BQU8sQ0FBQyxFQUNSQyxVQUFVLEVBQ1ZDLE1BQU0sQ0FBQyxDQUFtQixFQUMxQkMsTUFBTUMsT0FBTyxFQUNiQyxPQUFPQyxRQUFRLEVBQ2hCO0lBRUQsTUFBTUMsbUJBQThDLElBQUksQ0FBQ0MsT0FBTyxDQUFDQyxXQUFXLENBQUNiLFdBQVcsQ0FBQ2MsTUFBTTtJQUMvRixNQUFNUCxPQUFPLE9BQU9DLFlBQVksV0FBV0EsVUFBVUcsaUJBQWlCSSxXQUFXO0lBRWpGLE9BQU9qQixTQUFTO1FBQ2RrQixTQUFTLElBQUk7UUFDYkMsUUFBUU4saUJBQWlCTSxNQUFNO1FBQy9CaEIsT0FBT0M7UUFDUEM7UUFDQUM7UUFDQUM7UUFDQUM7UUFDQUM7UUFDQVcsV0FBV3JCLFlBQVlHO1FBQ3ZCUyxPQUFPQztJQUNUO0FBQ0YsRUFBQyJ9
20
+ //# sourceMappingURL=find.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/find.ts"],"sourcesContent":["import type { Find } from 'payload/database'\nimport type { PayloadRequest, SanitizedCollectionConfig } from 'payload/types'\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: limitArg,\n locale,\n page = 1,\n pagination,\n req = {} as PayloadRequest,\n sort: sortArg,\n where: whereArg,\n },\n) {\n const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config\n const sort = typeof sortArg === 'string' ? sortArg : collectionConfig.defaultSort\n\n return findMany({\n adapter: this,\n fields: collectionConfig.fields,\n limit: limitArg,\n locale,\n page,\n pagination,\n req,\n sort,\n tableName: toSnakeCase(collection),\n where: whereArg,\n })\n}\n"],"names":["toSnakeCase","findMany","find","collection","limit","limitArg","locale","page","pagination","req","sort","sortArg","where","whereArg","collectionConfig","payload","collections","config","defaultSort","adapter","fields","tableName"],"mappings":"AAGA,OAAOA,iBAAiB,gBAAe;AAIvC,SAASC,QAAQ,QAAQ,qBAAoB;AAE7C,OAAO,MAAMC,OAAa,eAAeA,KAEvC,EACEC,UAAU,EACVC,OAAOC,QAAQ,EACfC,MAAM,EACNC,OAAO,CAAC,EACRC,UAAU,EACVC,MAAM,CAAC,CAAmB,EAC1BC,MAAMC,OAAO,EACbC,OAAOC,QAAQ,EAChB;IAED,MAAMC,mBAA8C,IAAI,CAACC,OAAO,CAACC,WAAW,CAACb,WAAW,CAACc,MAAM;IAC/F,MAAMP,OAAO,OAAOC,YAAY,WAAWA,UAAUG,iBAAiBI,WAAW;IAEjF,OAAOjB,SAAS;QACdkB,SAAS,IAAI;QACbC,QAAQN,iBAAiBM,MAAM;QAC/BhB,OAAOC;QACPC;QACAC;QACAC;QACAC;QACAC;QACAW,WAAWrB,YAAYG;QACvBS,OAAOC;IACT;AACF,EAAC"}
@@ -20,4 +20,4 @@ export const findGlobal = async function findGlobal({ locale, req, slug, where }
20
20
  return {};
21
21
  };
22
22
 
23
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9maW5kR2xvYmFsLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB0eXBlIHsgRmluZEdsb2JhbCB9IGZyb20gJ3BheWxvYWQvZGF0YWJhc2UnXG5cbmltcG9ydCB0b1NuYWtlQ2FzZSBmcm9tICd0by1zbmFrZS1jYXNlJ1xuXG5pbXBvcnQgdHlwZSB7IFBvc3RncmVzQWRhcHRlciB9IGZyb20gJy4vdHlwZXMuanMnXG5cbmltcG9ydCB7IGZpbmRNYW55IH0gZnJvbSAnLi9maW5kL2ZpbmRNYW55LmpzJ1xuXG5leHBvcnQgY29uc3QgZmluZEdsb2JhbDogRmluZEdsb2JhbCA9IGFzeW5jIGZ1bmN0aW9uIGZpbmRHbG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MsR0FBRyxFQUFFQyxJQUFJLEVBQUVDLEtBQUssRUFBRTtJQUU1QixNQUFNQyxlQUFlLElBQUksQ0FBQ0MsT0FBTyxDQUFDQyxPQUFPLENBQUNDLE1BQU0sQ0FBQ0MsSUFBSSxDQUFDLENBQUNELFNBQVdBLE9BQU9MLElBQUksS0FBS0E7SUFDbEYsTUFBTU8sWUFBWVosWUFBWUs7SUFFOUIsTUFBTSxFQUNKUSxNQUFNLENBQUNDLElBQUksRUFDWixHQUFHLE1BQU1iLFNBQVM7UUFDakJjLFNBQVMsSUFBSTtRQUNiQyxRQUFRVCxhQUFhUyxNQUFNO1FBQzNCQyxPQUFPO1FBQ1BkO1FBQ0FlLFlBQVk7UUFDWmQ7UUFDQVE7UUFDQU47SUFDRjtJQUVBLElBQUlRLEtBQUs7UUFDUEEsSUFBSUssVUFBVSxHQUFHZDtRQUNqQixPQUFPUztJQUNUO0lBRUEsT0FBTyxDQUFDO0FBQ1YsRUFBQyJ9
23
+ //# sourceMappingURL=findGlobal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/findGlobal.ts"],"sourcesContent":["import type { FindGlobal } from 'payload/database'\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 { locale, req, slug, where },\n) {\n const globalConfig = this.payload.globals.config.find((config) => config.slug === slug)\n const tableName = toSnakeCase(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","locale","req","slug","where","globalConfig","payload","globals","config","find","tableName","docs","doc","adapter","fields","limit","pagination","globalType"],"mappings":"AAEA,OAAOA,iBAAiB,gBAAe;AAIvC,SAASC,QAAQ,QAAQ,qBAAoB;AAE7C,OAAO,MAAMC,aAAyB,eAAeA,WAEnD,EAAEC,MAAM,EAAEC,GAAG,EAAEC,IAAI,EAAEC,KAAK,EAAE;IAE5B,MAAMC,eAAe,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAACD,SAAWA,OAAOL,IAAI,KAAKA;IAClF,MAAMO,YAAYZ,YAAYK;IAE9B,MAAM,EACJQ,MAAM,CAACC,IAAI,EACZ,GAAG,MAAMb,SAAS;QACjBc,SAAS,IAAI;QACbC,QAAQT,aAAaS,MAAM;QAC3BC,OAAO;QACPd;QACAe,YAAY;QACZd;QACAQ;QACAN;IACF;IAEA,IAAIQ,KAAK;QACPA,IAAIK,UAAU,GAAGd;QACjB,OAAOS;IACT;IAEA,OAAO,CAAC;AACV,EAAC"}
@@ -21,4 +21,4 @@ export const findGlobalVersions = async function findGlobalVersions({ global, li
21
21
  });
22
22
  };
23
23
 
24
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9maW5kR2xvYmFsVmVyc2lvbnMudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHR5cGUgeyBGaW5kR2xvYmFsVmVyc2lvbnMgfSBmcm9tICdwYXlsb2FkL2RhdGFiYXNlJ1xuaW1wb3J0IHR5cGUgeyBQYXlsb2FkUmVxdWVzdCwgU2FuaXRpemVkR2xvYmFsQ29uZmlnIH0gZnJvbSAncGF5bG9hZC90eXBlcydcblxuaW1wb3J0IHsgYnVpbGRWZXJzaW9uR2xvYmFsRmllbGRzIH0gZnJvbSAncGF5bG9hZC92ZXJzaW9ucydcbmltcG9ydCB0b1NuYWtlQ2FzZSBmcm9tICd0by1zbmFrZS1jYXNlJ1xuXG5pbXBvcnQgdHlwZSB7IFBvc3RncmVzQWRhcHRlciB9IGZyb20gJy4vdHlwZXMuanMnXG5cbmltcG9ydCB7IGZpbmRNYW55IH0gZnJ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QztRQUNBUztRQUNBUDtJQUNGO0FBQ0YsRUFBQyJ9
24
+ //# sourceMappingURL=findGlobalVersions.js.map
@@ -0,0 +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'\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 = `_${toSnakeCase(global)}_v`\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","fields","adapter"],"mappings":"AAGA,SAASA,wBAAwB,QAAQ,mBAAkB;AAC3D,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,CAAC,CAAC,EAAEnB,YAAYG,QAAQ,EAAE,CAAC;IAC7C,MAAMiB,SAASrB,yBAAyBc;IAExC,OAAOZ,SAAS;QACdoB,SAAS,IAAI;QACbD;QACAhB;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAS;QACAP;IACF;AACF,EAAC"}
package/dist/findOne.js CHANGED
@@ -17,4 +17,4 @@ export async function findOne({ collection, locale, req = {}, where: incomingWhe
17
17
  return docs?.[0] || null;
18
18
  }
19
19
 
20
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9maW5kT25lLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB0eXBlIHsgRmluZE9uZUFyZ3MgfSBmcm9tICdwYXlsb2FkL2RhdGFiYXNlJ1xuaW1wb3J0IHR5cGUgeyBQYXlsb2FkUmVxdWVzdCwgU2FuaXRpemVkQ29sbGVjdGlvbkNvbmZpZywgVHlwZVdpdGhJRCB9IGZyb20gJ3BheWxvYWQvdHlwZXMnXG5cbmltcG9ydCB0b1NuYWtlQ2FzZSBmcm9tICd0by1zbmFrZS1jYXNlJ1xuXG5pbXBvcnQgdHlwZSB7IFBvc3RncmVzQWRhcHRlciB9IGZyb20gJy4vdHlwZXMuanMnXG5cbmltcG9ydCB7IGZpbmRNYW55IH0gZnJvbSAnLi9maW5kL2ZpbmRNYW55LmpzJ1xuXG5leHBvcnQgYXN5bmMgZnVuY3Rpb24gZmluZE9uZTxUIGV4dGVuZHMgVHlwZVdpdGhJRD4oXG4gIHRoaXM6IFBvc3RncmVzQWRhcHRlcixcbiAgeyBjb2xsZWN0aW9uLCBsb2NhbGUsIHJlcSA9IHt9IGFzIFBheWxvYWRSZXF1ZXN0LCB3aGVyZTogaW5jb21pbmdXaGVyZSB9OiBGaW5kT25lQXJncyxcb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VBQWU7SUFFckYsTUFBTUMsbUJBQThDLElBQUksQ0FBQ0MsT0FBTyxDQUFDQyxXQUFXLENBQUNQLFdBQVcsQ0FBQ1EsTUFBTTtJQUUvRixNQUFNLEVBQUVDLElBQUksRUFBRSxHQUFHLE1BQU1YLFNBQVM7UUFDOUJZLFNBQVMsSUFBSTtRQUNiQyxRQUFRTixpQkFBaUJNLE1BQU07UUFDL0JDLE9BQU87UUFDUFg7UUFDQVksTUFBTTtRQUNOQyxZQUFZO1FBQ1paO1FBQ0FhLE1BQU1DO1FBQ05DLFdBQVdwQixZQUFZRztRQUN2QkcsT0FBT0M7SUFDVDtJQUVBLE9BQU9LLE1BQU0sQ0FBQyxFQUFFLElBQUk7QUFDdEIifQ==
20
+ //# sourceMappingURL=findOne.js.map
@@ -0,0 +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 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: incomingWhere }: FindOneArgs,\n): Promise<T> {\n const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config\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: toSnakeCase(collection),\n where: incomingWhere,\n })\n\n return docs?.[0] || null\n}\n"],"names":["toSnakeCase","findMany","findOne","collection","locale","req","where","incomingWhere","collectionConfig","payload","collections","config","docs","adapter","fields","limit","page","pagination","sort","undefined","tableName"],"mappings":"AAGA,OAAOA,iBAAiB,gBAAe;AAIvC,SAASC,QAAQ,QAAQ,qBAAoB;AAE7C,OAAO,eAAeC,QAEpB,EAAEC,UAAU,EAAEC,MAAM,EAAEC,MAAM,CAAC,CAAmB,EAAEC,OAAOC,aAAa,EAAe;IAErF,MAAMC,mBAA8C,IAAI,CAACC,OAAO,CAACC,WAAW,CAACP,WAAW,CAACQ,MAAM;IAE/F,MAAM,EAAEC,IAAI,EAAE,GAAG,MAAMX,SAAS;QAC9BY,SAAS,IAAI;QACbC,QAAQN,iBAAiBM,MAAM;QAC/BC,OAAO;QACPX;QACAY,MAAM;QACNC,YAAY;QACZZ;QACAa,MAAMC;QACNC,WAAWpB,YAAYG;QACvBG,OAAOC;IACT;IAEA,OAAOK,MAAM,CAAC,EAAE,IAAI;AACtB"}