@payloadcms/db-postgres 3.0.0-alpha.41 → 3.0.0-alpha.43

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. package/dist/connect.js +1 -1
  2. package/dist/connect.js.map +1 -0
  3. package/dist/create.js +1 -1
  4. package/dist/create.js.map +1 -0
  5. package/dist/createGlobal.js +1 -1
  6. package/dist/createGlobal.js.map +1 -0
  7. package/dist/createGlobalVersion.js +1 -1
  8. package/dist/createGlobalVersion.js.map +1 -0
  9. package/dist/createMigration.d.ts.map +1 -1
  10. package/dist/createMigration.js +4 -2
  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.js +1 -1
  21. package/dist/destroy.js.map +1 -0
  22. package/dist/find/buildFindManyArgs.js +1 -1
  23. package/dist/find/buildFindManyArgs.js.map +1 -0
  24. package/dist/find/chainMethods.js +1 -1
  25. package/dist/find/chainMethods.js.map +1 -0
  26. package/dist/find/findMany.js +1 -1
  27. package/dist/find/findMany.js.map +1 -0
  28. package/dist/find/traverseFields.js +1 -1
  29. package/dist/find/traverseFields.js.map +1 -0
  30. package/dist/find.js +1 -1
  31. package/dist/find.js.map +1 -0
  32. package/dist/findGlobal.js +1 -1
  33. package/dist/findGlobal.js.map +1 -0
  34. package/dist/findGlobalVersions.js +1 -1
  35. package/dist/findGlobalVersions.js.map +1 -0
  36. package/dist/findOne.js +1 -1
  37. package/dist/findOne.js.map +1 -0
  38. package/dist/findVersions.js +1 -1
  39. package/dist/findVersions.js.map +1 -0
  40. package/dist/index.js +1 -1
  41. package/dist/index.js.map +1 -0
  42. package/dist/init.js +1 -1
  43. package/dist/init.js.map +1 -0
  44. package/dist/migrate.d.ts.map +1 -1
  45. package/dist/migrate.js +5 -3
  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.map +1 -1
  162. package/dist/utilities/pushDevSchema.js +4 -2
  163. package/dist/utilities/pushDevSchema.js.map +1 -0
  164. package/package.json +3 -3
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/transform/write/traverseFields.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { Field } from 'payload/types'\n\nimport { fieldAffectsData } from 'payload/types'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from '../../types.js'\nimport type { ArrayRowToInsert, BlockRowToInsert, RelationshipToDelete } from './types.js'\n\nimport { isArrayOfRows } from '../../utilities/isArrayOfRows.js'\nimport { transformArray } from './array.js'\nimport { transformBlocks } from './blocks.js'\nimport { transformNumbers } from './numbers.js'\nimport { transformRelationship } from './relationships.js'\nimport { transformSelects } from './selects.js'\nimport { transformTexts } from './texts.js'\n\ntype Args = {\n adapter: PostgresAdapter\n arrays: {\n [tableName: string]: ArrayRowToInsert[]\n }\n /**\n * This is the name of the base table\n */\n baseTableName: string\n blocks: {\n [blockType: string]: BlockRowToInsert[]\n }\n blocksToDelete: Set<string>\n /**\n * A snake-case field prefix, representing prior fields\n * Ex: my_group_my_named_tab_\n */\n columnPrefix: string\n data: Record<string, unknown>\n existingLocales?: Record<string, unknown>[]\n /**\n * A prefix that will retain camel-case formatting, representing prior fields\n * Ex: myGroup_myNamedTab_\n */\n fieldPrefix: string\n fields: Field[]\n forcedLocale?: string\n locales: {\n [locale: string]: Record<string, unknown>\n }\n texts: Record<string, unknown>[]\n numbers: Record<string, unknown>[]\n /**\n * This is the name of the parent table\n */\n parentTableName: string\n path: string\n relationships: Record<string, unknown>[]\n relationshipsToDelete: RelationshipToDelete[]\n row: Record<string, unknown>\n selects: {\n [tableName: string]: Record<string, unknown>[]\n }\n}\n\nexport const traverseFields = ({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix,\n data,\n existingLocales,\n fieldPrefix,\n fields,\n forcedLocale,\n locales,\n texts,\n numbers,\n parentTableName,\n path,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n}: Args) => {\n fields.forEach((field) => {\n let columnName = ''\n let fieldName = ''\n let fieldData: unknown\n\n if (fieldAffectsData(field)) {\n columnName = `${columnPrefix || ''}${toSnakeCase(field.name)}`\n fieldName = `${fieldPrefix || ''}${field.name}`\n fieldData = data[field.name]\n }\n\n if (field.type === 'array') {\n const arrayTableName = `${parentTableName}_${columnName}`\n\n if (!arrays[arrayTableName]) arrays[arrayTableName] = []\n\n if (field.localized) {\n if (typeof data[field.name] === 'object' && data[field.name] !== null) {\n Object.entries(data[field.name]).forEach(([localeKey, localeData]) => {\n if (Array.isArray(localeData)) {\n const newRows = transformArray({\n adapter,\n arrayTableName,\n baseTableName,\n blocks,\n blocksToDelete,\n data: localeData,\n field,\n locale: localeKey,\n texts,\n numbers,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n })\n\n arrays[arrayTableName] = arrays[arrayTableName].concat(newRows)\n }\n })\n }\n } else {\n const newRows = transformArray({\n adapter,\n arrayTableName,\n baseTableName,\n blocks,\n blocksToDelete,\n data: data[field.name],\n field,\n texts,\n numbers,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n })\n\n arrays[arrayTableName] = arrays[arrayTableName].concat(newRows)\n }\n\n return\n }\n\n if (field.type === 'blocks') {\n field.blocks.forEach(({ slug }) => {\n blocksToDelete.add(toSnakeCase(slug))\n })\n\n if (field.localized) {\n if (typeof data[field.name] === 'object' && data[field.name] !== null) {\n Object.entries(data[field.name]).forEach(([localeKey, localeData]) => {\n if (Array.isArray(localeData)) {\n transformBlocks({\n adapter,\n baseTableName,\n blocks,\n blocksToDelete,\n data: localeData,\n field,\n locale: localeKey,\n texts,\n numbers,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n })\n }\n })\n }\n } else if (isArrayOfRows(fieldData)) {\n transformBlocks({\n adapter,\n baseTableName,\n blocks,\n blocksToDelete,\n data: fieldData,\n field,\n texts,\n numbers,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n })\n }\n\n return\n }\n\n if (field.type === 'group') {\n if (typeof data[field.name] === 'object' && data[field.name] !== null) {\n if (field.localized) {\n Object.entries(data[field.name]).forEach(([localeKey, localeData]) => {\n traverseFields({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix: `${columnName}_`,\n data: localeData as Record<string, unknown>,\n existingLocales,\n fieldPrefix: `${fieldName}_`,\n fields: field.fields,\n forcedLocale: localeKey,\n locales,\n texts,\n numbers,\n parentTableName,\n path: `${path || ''}${field.name}.`,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n })\n })\n } else {\n traverseFields({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix: `${columnName}_`,\n data: data[field.name] as Record<string, unknown>,\n existingLocales,\n fieldPrefix: `${fieldName}_`,\n fields: field.fields,\n locales,\n texts,\n numbers,\n parentTableName,\n path: `${path || ''}${field.name}.`,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n })\n }\n }\n\n return\n }\n\n if (field.type === 'tabs') {\n field.tabs.forEach((tab) => {\n if ('name' in tab) {\n if (typeof data[tab.name] === 'object' && data[tab.name] !== null) {\n if (tab.localized) {\n Object.entries(data[tab.name]).forEach(([localeKey, localeData]) => {\n traverseFields({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix: `${columnPrefix || ''}${toSnakeCase(tab.name)}_`,\n data: localeData as Record<string, unknown>,\n existingLocales,\n fieldPrefix: `${fieldPrefix || ''}${tab.name}_`,\n fields: tab.fields,\n forcedLocale: localeKey,\n locales,\n texts,\n numbers,\n parentTableName,\n path: `${path || ''}${tab.name}.`,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n })\n })\n } else {\n traverseFields({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix: `${columnPrefix || ''}${toSnakeCase(tab.name)}_`,\n data: data[tab.name] as Record<string, unknown>,\n existingLocales,\n fieldPrefix: `${fieldPrefix || ''}${tab.name}_`,\n fields: tab.fields,\n locales,\n texts,\n numbers,\n parentTableName,\n path: `${path || ''}${tab.name}.`,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n })\n }\n }\n } else {\n traverseFields({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix,\n data,\n existingLocales,\n fieldPrefix,\n fields: tab.fields,\n locales,\n texts,\n numbers,\n parentTableName,\n path,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n })\n }\n })\n }\n\n if (field.type === 'row' || field.type === 'collapsible') {\n traverseFields({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix,\n data,\n existingLocales,\n fieldPrefix,\n fields: field.fields,\n locales,\n texts,\n numbers,\n parentTableName,\n path,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n })\n }\n\n if (field.type === 'relationship' || field.type === 'upload') {\n const relationshipPath = `${path || ''}${field.name}`\n\n if (field.localized) {\n if (typeof fieldData === 'object') {\n Object.entries(fieldData).forEach(([localeKey, localeData]) => {\n if (localeData === null) {\n relationshipsToDelete.push({\n locale: localeKey,\n path: relationshipPath,\n })\n return\n }\n\n transformRelationship({\n baseRow: {\n locale: localeKey,\n path: relationshipPath,\n },\n data: localeData,\n field,\n relationships,\n })\n })\n }\n } else {\n if (fieldData === null || (Array.isArray(fieldData) && fieldData.length === 0)) {\n relationshipsToDelete.push({ path: relationshipPath })\n return\n }\n\n transformRelationship({\n baseRow: {\n path: relationshipPath,\n },\n data: fieldData,\n field,\n relationships,\n })\n }\n\n return\n }\n\n if (field.type === 'text' && field.hasMany) {\n const textPath = `${path || ''}${field.name}`\n\n if (field.localized) {\n if (typeof fieldData === 'object') {\n Object.entries(fieldData).forEach(([localeKey, localeData]) => {\n if (Array.isArray(localeData)) {\n transformTexts({\n baseRow: {\n locale: localeKey,\n path: textPath,\n },\n data: localeData,\n texts,\n })\n }\n })\n }\n } else if (Array.isArray(fieldData)) {\n transformTexts({\n baseRow: {\n path: textPath,\n },\n data: fieldData,\n texts,\n })\n }\n\n return\n }\n\n if (field.type === 'number' && field.hasMany) {\n const numberPath = `${path || ''}${field.name}`\n\n if (field.localized) {\n if (typeof fieldData === 'object') {\n Object.entries(fieldData).forEach(([localeKey, localeData]) => {\n if (Array.isArray(localeData)) {\n transformNumbers({\n baseRow: {\n locale: localeKey,\n path: numberPath,\n },\n data: localeData,\n numbers,\n })\n }\n })\n }\n } else if (Array.isArray(fieldData)) {\n transformNumbers({\n baseRow: {\n path: numberPath,\n },\n data: fieldData,\n numbers,\n })\n }\n\n return\n }\n\n if (field.type === 'select' && field.hasMany) {\n const selectTableName = `${parentTableName}_${columnName}`\n if (!selects[selectTableName]) selects[selectTableName] = []\n\n if (field.localized) {\n if (typeof data[field.name] === 'object' && data[field.name] !== null) {\n Object.entries(data[field.name]).forEach(([localeKey, localeData]) => {\n if (Array.isArray(localeData)) {\n const newRows = transformSelects({\n id: data._uuid || data.id,\n data: localeData,\n locale: localeKey,\n })\n\n selects[selectTableName] = selects[selectTableName].concat(newRows)\n }\n })\n }\n } else if (Array.isArray(data[field.name])) {\n const newRows = transformSelects({\n id: data._uuid || data.id,\n data: data[field.name],\n })\n\n selects[selectTableName] = selects[selectTableName].concat(newRows)\n }\n\n return\n }\n\n if (fieldAffectsData(field)) {\n const valuesToTransform: { localeKey?: string; ref: unknown; value: unknown }[] = []\n\n if (field.localized) {\n if (typeof fieldData === 'object' && fieldData !== null) {\n Object.entries(fieldData).forEach(([localeKey, localeData]) => {\n if (!locales[localeKey]) locales[localeKey] = {}\n\n valuesToTransform.push({\n localeKey,\n ref: locales,\n value: localeData,\n })\n })\n }\n } else {\n let ref = row\n\n if (forcedLocale) {\n if (!locales[forcedLocale]) locales[forcedLocale] = {}\n ref = locales[forcedLocale]\n }\n\n valuesToTransform.push({ ref, value: fieldData })\n }\n\n valuesToTransform.forEach(({ localeKey, ref, value }) => {\n if (typeof value !== 'undefined') {\n let formattedValue = value\n\n if (field.type === 'date' && field.name === 'updatedAt') {\n formattedValue = new Date().toISOString()\n }\n\n if (localeKey) {\n ref[localeKey][fieldName] = formattedValue\n } else {\n ref[fieldName] = formattedValue\n }\n }\n })\n }\n })\n}\n"],"names":["fieldAffectsData","toSnakeCase","isArrayOfRows","transformArray","transformBlocks","transformNumbers","transformRelationship","transformSelects","transformTexts","traverseFields","adapter","arrays","baseTableName","blocks","blocksToDelete","columnPrefix","data","existingLocales","fieldPrefix","fields","forcedLocale","locales","texts","numbers","parentTableName","path","relationships","relationshipsToDelete","row","selects","forEach","field","columnName","fieldName","fieldData","name","type","arrayTableName","localized","Object","entries","localeKey","localeData","Array","isArray","newRows","locale","concat","slug","add","tabs","tab","relationshipPath","push","baseRow","length","hasMany","textPath","numberPath","selectTableName","id","_uuid","valuesToTransform","ref","value","formattedValue","Date","toISOString"],"mappings":"AAAA,oCAAoC,GAGpC,SAASA,gBAAgB,QAAQ,gBAAe;AAChD,OAAOC,iBAAiB,gBAAe;AAKvC,SAASC,aAAa,QAAQ,mCAAkC;AAChE,SAASC,cAAc,QAAQ,aAAY;AAC3C,SAASC,eAAe,QAAQ,cAAa;AAC7C,SAASC,gBAAgB,QAAQ,eAAc;AAC/C,SAASC,qBAAqB,QAAQ,qBAAoB;AAC1D,SAASC,gBAAgB,QAAQ,eAAc;AAC/C,SAASC,cAAc,QAAQ,aAAY;AA+C3C,OAAO,MAAMC,iBAAiB,CAAC,EAC7BC,OAAO,EACPC,MAAM,EACNC,aAAa,EACbC,MAAM,EACNC,cAAc,EACdC,YAAY,EACZC,IAAI,EACJC,eAAe,EACfC,WAAW,EACXC,MAAM,EACNC,YAAY,EACZC,OAAO,EACPC,KAAK,EACLC,OAAO,EACPC,eAAe,EACfC,IAAI,EACJC,aAAa,EACbC,qBAAqB,EACrBC,GAAG,EACHC,OAAO,EACF;IACLV,OAAOW,OAAO,CAAC,CAACC;QACd,IAAIC,aAAa;QACjB,IAAIC,YAAY;QAChB,IAAIC;QAEJ,IAAIlC,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RvSW5zZXJ0ID0ge1xuICBhcnJheXM6IHtcbiAgICBbdGFibGVOYW1lOiBzdHJpbmddOiBBcnJheVJvd1RvSW5zZXJ0W11cbiAgfVxuICBibG9ja3M6IHtcbiAgICBbYmxvY2tUeXBlOiBzdHJpbmddOiBCbG9ja1Jvd1RvSW5zZXJ0W11cbiAgfVxuICBibG9ja3NUb0RlbGV0ZTogU2V0PHN0cmluZz5cbiAgbG9jYWxlczoge1xuICAgIFtsb2NhbGU6IHN0cmluZ106IFJlY29yZDxzdHJpbmcsIHVua25vd24+XG4gIH1cbiAgdGV4dHM6IFJlY29yZDxzdHJpbmcsIHVua25vd24+W11cbiAgbnVtYmVyczogUmVjb3JkPHN0cmluZywgdW5rbm93bj5bXVxuICByZWxhdGlvbnNoaXBzOiBSZWNvcmQ8c3RyaW5nLCB1bmtub3duPltdXG4gIHJlbGF0aW9uc2hpcHNUb0RlbGV0ZTogUmVsYXRpb25zaGlwVG9EZWxldGVbXVxuICByb3c6IFJlY29yZDxzdHJpbmcsIHVua25vd24+XG4gIHNlbGVjdHM6IHtcbiAgICBbdGFibGVOYW1lOiBzdHJpbmddOiBSZWNvcmQ8c3RyaW5nLCB1bmtub3duPltdXG4gIH1cbn1cbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUF5QkEsV0FtQkMifQ==
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/transform/write/types.ts"],"sourcesContent":["export type ArrayRowToInsert = {\n arrays: {\n [tableName: string]: ArrayRowToInsert[]\n }\n locales: {\n [locale: string]: Record<string, unknown>\n }\n row: Record<string, unknown>\n}\n\nexport type BlockRowToInsert = {\n arrays: {\n [tableName: string]: ArrayRowToInsert[]\n }\n locales: {\n [locale: string]: Record<string, unknown>\n }\n row: Record<string, unknown>\n}\n\nexport type RelationshipToDelete = {\n locale?: string\n path: string\n}\n\nexport type RowToInsert = {\n arrays: {\n [tableName: string]: ArrayRowToInsert[]\n }\n blocks: {\n [blockType: string]: BlockRowToInsert[]\n }\n blocksToDelete: Set<string>\n locales: {\n [locale: string]: Record<string, unknown>\n }\n texts: Record<string, unknown>[]\n numbers: Record<string, unknown>[]\n relationships: Record<string, unknown>[]\n relationshipsToDelete: RelationshipToDelete[]\n row: Record<string, unknown>\n selects: {\n [tableName: string]: Record<string, unknown>[]\n }\n}\n"],"names":[],"mappings":"AAyBA,WAmBC"}
package/dist/types.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export { };
2
2
 
3
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy90eXBlcy50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgdHlwZSB7XG4gIENvbHVtbkJhc2VDb25maWcsXG4gIENvbHVtbkRhdGFUeXBlLFxuICBEcml6emxlQ29uZmlnLFxuICBFeHRyYWN0VGFibGVzV2l0aFJlbGF0aW9ucyxcbiAgUmVsYXRpb24sXG4gIFJlbGF0aW9ucyxcbn0gZnJvbSAnZHJpenpsZS1vcm0nXG5pbXBvcnQgdHlwZSB7IE5vZGVQZ0RhdGFiYXNlLCBOb2RlUGdRdWVyeVJlc3VsdEhLVCB9IGZyb20gJ2RyaXp6bGUtb3JtL25vZGUtcG9zdGdyZXMnXG5pbXBvcnQgdHlwZSB7XG4gIFBnQ29sdW1uLFxuICBQZ0VudW0sXG4gIFBnU2NoZW1hLFxuICBQZ1RhYmxlV2l0aENvbHVtbnMsXG4gIFBnVHJhbnNhY3Rpb24sXG59IGZyb20gJ2RyaXp6bGUtb3JtL3BnLWNvcmUnXG5pbXBvcnQgdHlwZSB7IFBnVGFibGVGbiB9IGZyb20gJ2RyaXp6bGUtb3JtL3BnLWNvcmUvdGFibGUnXG5pbXBvcnQgdHlwZSB7IFBheWxvYWQgfSBmcm9tICdwYXlsb2FkJ1xuaW1wb3J0IHR5cGUgeyBCYXNlRGF0YWJhc2VBZGFwdGVyIH0gZnJvbSAnc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AgZW51bXM6IFJlY29yZDxzdHJpbmcsIEdlbmVyaWNFbnVtPlxuICAgIGZpZWxkQ29uc3RyYWludHM6IFJlY29yZDxzdHJpbmcsIFJlY29yZDxzdHJpbmcsIHN0cmluZz4+XG4gICAgcG9vbDogUG9vbFxuICAgIHB1c2g6IGJvb2xlYW5cbiAgICByZWxhdGlvbnM6IFJlY29yZDxzdHJpbmcsIEdlbmVyaWNSZWxhdGlvbj5cbiAgICBzY2hlbWE6IFJlY29yZDxzdHJpbmcsIEdlbmVyaWNFbnVtIHwgR2VuZXJpY1JlbGF0aW9uIHwgR2VuZXJpY1RhYmxlPlxuICAgIHNlc3Npb25zOiB7XG4gICAgICBbaWQ6IHN0cmluZ106IHtcbiAgICAgICAgZGI6IERyaXp6bGVUcmFuc2FjdGlvblxuICAgICAgICByZWplY3Q6ICgpID0+IFByb21pc2U8dm9pZD5cbiAgICAgICAgcmVzb2x2ZTogKCkgPT4gUHJvbWlzZTx2b2lkPlxuICAgICAgfVxuICAgIH1cbiAgICB0YWJsZXM6IFJlY29yZDxzdHJpbmcsIEdlbmVyaWNUYWJsZT5cbiAgfVxufVxuIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQTJGQSxXQUFpRiJ9
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n ColumnBaseConfig,\n ColumnDataType,\n DrizzleConfig,\n ExtractTablesWithRelations,\n Relation,\n Relations,\n} from 'drizzle-orm'\nimport type { NodePgDatabase, NodePgQueryResultHKT } from 'drizzle-orm/node-postgres'\nimport type {\n PgColumn,\n PgEnum,\n PgSchema,\n PgTableWithColumns,\n PgTransaction,\n} from 'drizzle-orm/pg-core'\nimport type { PgTableFn } from 'drizzle-orm/pg-core/table'\nimport type { Payload } from 'payload'\nimport type { BaseDatabaseAdapter } from 'payload/database'\nimport type { PayloadRequest } from 'payload/types'\nimport type { Pool, PoolConfig } from 'pg'\n\nexport type DrizzleDB = NodePgDatabase<Record<string, unknown>>\n\nexport type Args = {\n idType?: 'serial' | 'uuid'\n logger?: DrizzleConfig['logger']\n migrationDir?: string\n pool: PoolConfig\n push?: boolean\n schemaName?: string\n}\n\nexport type GenericColumn = PgColumn<\n ColumnBaseConfig<ColumnDataType, string>,\n Record<string, unknown>\n>\n\nexport type GenericColumns = {\n [x: string]: GenericColumn\n}\n\nexport type GenericTable = PgTableWithColumns<{\n columns: GenericColumns\n dialect: string\n name: string\n schema: undefined\n}>\n\nexport type GenericEnum = PgEnum<[string, ...string[]]>\n\nexport type GenericRelation = Relations<string, Record<string, Relation<string>>>\n\nexport type DrizzleTransaction = PgTransaction<\n NodePgQueryResultHKT,\n Record<string, unknown>,\n ExtractTablesWithRelations<Record<string, unknown>>\n>\n\nexport type PostgresAdapter = BaseDatabaseAdapter & {\n drizzle: DrizzleDB\n enums: Record<string, GenericEnum>\n /**\n * An object keyed on each table, with a key value pair where the constraint name is the key, followed by the dot-notation field name\n * Used for returning properly formed errors from unique fields\n */\n fieldConstraints: Record<string, Record<string, string>>\n idType: Args['idType']\n logger: DrizzleConfig['logger']\n pgSchema?: { table: PgTableFn } | PgSchema\n pool: Pool\n poolOptions: Args['pool']\n push: boolean\n relations: Record<string, GenericRelation>\n schema: Record<string, GenericEnum | GenericRelation | GenericTable>\n schemaName?: Args['schemaName']\n sessions: {\n [id: string]: {\n db: DrizzleTransaction\n reject: () => Promise<void>\n resolve: () => Promise<void>\n }\n }\n tables: Record<string, GenericTable | PgTableWithColumns<any>>\n}\n\nexport type IDType = 'integer' | 'numeric' | 'uuid' | 'varchar'\n\nexport type PostgresAdapterResult = (args: { payload: Payload }) => PostgresAdapter\n\nexport type MigrateUpArgs = { payload: Payload; req?: Partial<PayloadRequest> }\nexport type MigrateDownArgs = { payload: Payload; req?: Partial<PayloadRequest> }\n\ndeclare module 'payload' {\n export interface DatabaseAdapter\n extends Omit<Args, 'migrationDir' | 'pool'>,\n BaseDatabaseAdapter {\n drizzle: DrizzleDB\n enums: Record<string, GenericEnum>\n fieldConstraints: Record<string, Record<string, string>>\n pool: Pool\n push: boolean\n relations: Record<string, GenericRelation>\n schema: Record<string, GenericEnum | GenericRelation | GenericTable>\n sessions: {\n [id: string]: {\n db: DrizzleTransaction\n reject: () => Promise<void>\n resolve: () => Promise<void>\n }\n }\n tables: Record<string, GenericTable>\n }\n}\n"],"names":[],"mappings":"AA2FA,WAAiF"}
package/dist/update.js CHANGED
@@ -77,4 +77,4 @@ export const updateOne = async function updateOne({ id, collection: collectionSl
77
77
  return result;
78
78
  };
79
79
 
80
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy91cGRhdGUudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHR5cGUgeyBVcGRhdGVPbmUgfSBmcm9tICdwYXlsb2FkL2RhdGFiYXNlJ1xuXG5pbXBvcnQgdG9TbmFrZUNhc2UgZnJvbSAndG8tc25ha2UtY2FzZSdcblxuaW1wb3J0IHR5cGUgeyBDaGFpbmVkTWV0aG9kcyB9IGZyb20gJy4vZmluZC9jaGFpbk1ldGhvZHMuanMnXG5pbXBvcnQgdHlwZSB7IFBvc3RncmVzQWRhcHRlciB9IGZyb20gJy4vdHlwZXMuanMnXG5pbXBvcnQgeyBjaGFpbk1ldGhvZHMgfSBmcm9tICcuL2ZpbmQvY2hhaW5NZXRob2RzLmpzJ1xuaW1wb3J0IGJ1aWxkUXVlcnkgZnJvbSAnLi9xdWVyaWVzL2J1aWxkUXVlcnkuanMnXG5pbXBvcnQgeyB1cHNlcnRSb3cgfSBmcm9tICcuL3Vwc2VydFJvdy9pbmRleC5qcydcblxuZXhwb3J0IGNvbnN0IHVwZGF0ZU9uZTogVXBkYXRlT25lID0gYXN5bmMgZnVuY3Rpb24gdXBkYXRlT25lKFxuICB0aGlzOiBQb3N0Z3Jlc0FkYXB0ZXIsXG4gIHsgaWQsIGNvbGxlY3Rpb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QVMsSUFBSTtRQUNibkI7UUFDQU07UUFDQWMsUUFBUXRCLFdBQVdzQixNQUFNO1FBQ3pCcUIsV0FBVztRQUNYNUIsV0FBV3JCLFlBQVlPO1FBQ3ZCSTtJQUNGO0lBRUEsT0FBT3FDO0FBQ1QsRUFBQyJ9
80
+ //# sourceMappingURL=update.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/update.ts"],"sourcesContent":["import type { UpdateOne } from 'payload/database'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { ChainedMethods } from './find/chainMethods.js'\nimport type { PostgresAdapter } from './types.js'\nimport { chainMethods } from './find/chainMethods.js'\nimport buildQuery from './queries/buildQuery.js'\nimport { upsertRow } from './upsertRow/index.js'\n\nexport const updateOne: UpdateOne = async function updateOne(\n this: PostgresAdapter,\n { id, collection: collectionSlug, data, draft, locale, req, where: whereArg },\n) {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const collection = this.payload.collections[collectionSlug].config\n const tableName = toSnakeCase(collectionSlug)\n const whereToUse = whereArg || { id: { equals: id } }\n\n const { joinAliases, joins, selectFields, where } = await buildQuery({\n adapter: this,\n fields: collection.fields,\n locale,\n tableName,\n where: whereToUse,\n })\n\n let idToUpdate = id\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 const selectDistinctMethods: ChainedMethods = []\n\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: [this.tables[joinTable], condition],\n method: 'leftJoin',\n })\n }\n })\n\n selectDistinctMethods.push({ args: [1], method: 'limit' })\n\n const selectDistinctResult = await chainMethods({\n methods: selectDistinctMethods,\n query: db.selectDistinct(selectFields).from(this.tables[tableName]),\n })\n\n if (selectDistinctResult?.[0]?.id) {\n idToUpdate = selectDistinctResult?.[0]?.id\n }\n }\n\n const result = await upsertRow({\n id: idToUpdate,\n adapter: this,\n data,\n db,\n fields: collection.fields,\n operation: 'update',\n tableName: toSnakeCase(collectionSlug),\n req,\n })\n\n return result\n}\n"],"names":["toSnakeCase","chainMethods","buildQuery","upsertRow","updateOne","id","collection","collectionSlug","data","draft","locale","req","where","whereArg","db","sessions","transactionID","drizzle","payload","collections","config","tableName","whereToUse","equals","joinAliases","joins","selectFields","adapter","fields","idToUpdate","Object","keys","length","selectDistinctMethods","push","args","method","forEach","condition","table","entries","joinTable","tables","selectDistinctResult","methods","query","selectDistinct","from","result","operation"],"mappings":"AAEA,OAAOA,iBAAiB,gBAAe;AAIvC,SAASC,YAAY,QAAQ,yBAAwB;AACrD,OAAOC,gBAAgB,0BAAyB;AAChD,SAASC,SAAS,QAAQ,uBAAsB;AAEhD,OAAO,MAAMC,YAAuB,eAAeA,UAEjD,EAAEC,EAAE,EAAEC,YAAYC,cAAc,EAAEC,IAAI,EAAEC,KAAK,EAAEC,MAAM,EAAEC,GAAG,EAAEC,OAAOC,QAAQ,EAAE;IAE7E,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACJ,IAAIK,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMX,aAAa,IAAI,CAACY,OAAO,CAACC,WAAW,CAACZ,eAAe,CAACa,MAAM;IAClE,MAAMC,YAAYrB,YAAYO;IAC9B,MAAMe,aAAaT,YAAY;QAAER,IAAI;YAAEkB,QAAQlB;QAAG;IAAE;IAEpD,MAAM,EAAEmB,WAAW,EAAEC,KAAK,EAAEC,YAAY,EAAEd,KAAK,EAAE,GAAG,MAAMV,WAAW;QACnEyB,SAAS,IAAI;QACbC,QAAQtB,WAAWsB,MAAM;QACzBlB;QACAW;QACAT,OAAOU;IACT;IAEA,IAAIO,aAAaxB;IAEjB,wJAAwJ;IACxJ,IAAIyB,OAAOC,IAAI,CAACN,OAAOO,MAAM,GAAG,KAAKR,YAAYQ,MAAM,GAAG,GAAG;QAC3D,MAAMC,wBAAwC,EAAE;QAEhD,IAAIrB,OAAO;YACTqB,sBAAsBC,IAAI,CAAC;gBAAEC,MAAM;oBAACvB;iBAAM;gBAAEwB,QAAQ;YAAQ;QAC9D;QAEAZ,YAAYa,OAAO,CAAC,CAAC,EAAEC,SAAS,EAAEC,KAAK,EAAE;YACvCN,sBAAsBC,IAAI,CAAC;gBACzBC,MAAM;oBAACI;oBAAOD;iBAAU;gBACxBF,QAAQ;YACV;QACF;QAEAN,OAAOU,OAAO,CAACf,OAAOY,OAAO,CAAC,CAAC,CAACI,WAAWH,UAAU;YACnD,IAAIG,WAAW;gBACbR,sBAAsBC,IAAI,CAAC;oBACzBC,MAAM;wBAAC,IAAI,CAACO,MAAM,CAACD,UAAU;wBAAEH;qBAAU;oBACzCF,QAAQ;gBACV;YACF;QACF;QAEAH,sBAAsBC,IAAI,CAAC;YAAEC,MAAM;gBAAC;aAAE;YAAEC,QAAQ;QAAQ;QAExD,MAAMO,uBAAuB,MAAM1C,aAAa;YAC9C2C,SAASX;YACTY,OAAO/B,GAAGgC,cAAc,CAACpB,cAAcqB,IAAI,CAAC,IAAI,CAACL,MAAM,CAACrB,UAAU;QACpE;QAEA,IAAIsB,sBAAsB,CAAC,EAAE,EAAEtC,IAAI;YACjCwB,aAAac,sBAAsB,CAAC,EAAE,EAAEtC;QAC1C;IACF;IAEA,MAAM2C,SAAS,MAAM7C,UAAU;QAC7BE,IAAIwB;QACJF,SAAS,IAAI;QACbnB;QACAM;QACAc,QAAQtB,WAAWsB,MAAM;QACzBqB,WAAW;QACX5B,WAAWrB,YAAYO;QACvBI;IACF;IAEA,OAAOqC;AACT,EAAC"}
@@ -22,4 +22,4 @@ export async function updateGlobal({ data, req = {}, slug }) {
22
22
  return result;
23
23
  }
24
24
 
25
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozL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QsU0FBV0EsT0FBT1IsSUFBSSxLQUFLQTtJQUNsRixNQUFNVSxZQUFZZixZQUFZSztJQUU5QixNQUFNVyxpQkFBaUIsTUFBTVYsR0FBR1csS0FBSyxDQUFDRixVQUFVLENBQUNHLFNBQVMsQ0FBQyxDQUFDO0lBRTVELE1BQU1DLFNBQVMsTUFBTWxCLFVBQWE7UUFDaEMsR0FBSWUsaUJBQWlCO1lBQUVJLElBQUlKLGVBQWVJLEVBQUU7WUFBRUMsV0FBVztRQUFTLElBQUk7WUFBRUEsV0FBVztRQUFTLENBQUM7UUFDN0ZDLFNBQVMsSUFBSTtRQUNibkI7UUFDQUc7UUFDQWlCLFFBQVFiLGFBQWFhLE1BQU07UUFDM0JSO1FBQ0FYO0lBQ0Y7SUFFQSxPQUFPZTtBQUNUIn0=
25
+ //# sourceMappingURL=updateGlobal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/updateGlobal.ts"],"sourcesContent":["import type { UpdateGlobalArgs } 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 updateGlobal<T extends TypeWithID>(\n this: PostgresAdapter,\n { data, req = {} as PayloadRequest, slug }: UpdateGlobalArgs,\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 const tableName = toSnakeCase(slug)\n\n const existingGlobal = await db.query[tableName].findFirst({})\n\n const result = await upsertRow<T>({\n ...(existingGlobal ? { id: existingGlobal.id, operation: 'update' } : { operation: 'create' }),\n adapter: this,\n data,\n db,\n fields: globalConfig.fields,\n tableName,\n req,\n })\n\n return result\n}\n"],"names":["toSnakeCase","upsertRow","updateGlobal","data","req","slug","db","sessions","transactionID","drizzle","globalConfig","payload","globals","config","find","tableName","existingGlobal","query","findFirst","result","id","operation","adapter","fields"],"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;IAClF,MAAMU,YAAYf,YAAYK;IAE9B,MAAMW,iBAAiB,MAAMV,GAAGW,KAAK,CAACF,UAAU,CAACG,SAAS,CAAC,CAAC;IAE5D,MAAMC,SAAS,MAAMlB,UAAa;QAChC,GAAIe,iBAAiB;YAAEI,IAAIJ,eAAeI,EAAE;YAAEC,WAAW;QAAS,IAAI;YAAEA,WAAW;QAAS,CAAC;QAC7FC,SAAS,IAAI;QACbnB;QACAG;QACAiB,QAAQb,aAAaa,MAAM;QAC3BR;QACAX;IACF;IAEA,OAAOe;AACT"}
@@ -33,4 +33,4 @@ export async function updateGlobalVersion({ id, global, locale, req = {}, versio
33
33
  return result;
34
34
  }
35
35
 
36
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy91cGRhdGVHbG9iYWxWZXJzaW9uLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB0eXBlIHsgVHlwZVdpdGhWZXJzaW9uLCBVcGRhdGVHbG9iYWxWZXJzaW9uQXJncyB9IGZyb20gJ3BheWxvYWQvZGF0YWJhc2UnXG5pbXBvcnQgdHlwZSB7IFBheWxvYWRSZXF1ZXN0LCBTYW5pdGl6ZWRHbG9iYWxDb25maWcsIFR5cGVXaXRoSUQgfSBmcm9tICdwYXlsb2FkL3R5cGVzJ1xuXG5pbXBvcnQgeyBidWlsZFZlcnN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-0,0 +1 @@
1
+ {"version":3,"sources":["../src/updateGlobalVersion.ts"],"sourcesContent":["import type { TypeWithVersion, UpdateGlobalVersionArgs } from 'payload/database'\nimport type { PayloadRequest, SanitizedGlobalConfig, TypeWithID } from 'payload/types'\n\nimport { buildVersionGlobalFields } from 'payload/versions'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport buildQuery from './queries/buildQuery.js'\nimport { upsertRow } from './upsertRow/index.js'\n\nexport async function updateGlobalVersion<T extends TypeWithID>(\n this: PostgresAdapter,\n {\n id,\n global,\n locale,\n req = {} as PayloadRequest,\n versionData,\n where: whereArg,\n }: UpdateGlobalVersionArgs<T>,\n) {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const globalConfig: SanitizedGlobalConfig = this.payload.globals.config.find(\n ({ slug }) => slug === global,\n )\n const whereToUse = whereArg || { id: { equals: id } }\n const tableName = `_${toSnakeCase(global)}_v`\n const fields = buildVersionGlobalFields(globalConfig)\n\n const { where } = await buildQuery({\n adapter: this,\n fields,\n locale,\n tableName,\n where: whereToUse,\n })\n\n const result = await upsertRow<TypeWithVersion<T>>({\n id,\n adapter: this,\n data: versionData,\n db,\n fields,\n operation: 'update',\n tableName,\n where,\n req,\n })\n\n return result\n}\n"],"names":["buildVersionGlobalFields","toSnakeCase","buildQuery","upsertRow","updateGlobalVersion","id","global","locale","req","versionData","where","whereArg","db","sessions","transactionID","drizzle","globalConfig","payload","globals","config","find","slug","whereToUse","equals","tableName","fields","adapter","result","data","operation"],"mappings":"AAGA,SAASA,wBAAwB,QAAQ,mBAAkB;AAC3D,OAAOC,iBAAiB,gBAAe;AAIvC,OAAOC,gBAAgB,0BAAyB;AAChD,SAASC,SAAS,QAAQ,uBAAsB;AAEhD,OAAO,eAAeC,oBAEpB,EACEC,EAAE,EACFC,MAAM,EACNC,MAAM,EACNC,MAAM,CAAC,CAAmB,EAC1BC,WAAW,EACXC,OAAOC,QAAQ,EACY;IAE7B,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACL,IAAIM,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMC,eAAsC,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,MAAM,CAACC,IAAI,CAC1E,CAAC,EAAEC,IAAI,EAAE,GAAKA,SAASf;IAEzB,MAAMgB,aAAaX,YAAY;QAAEN,IAAI;YAAEkB,QAAQlB;QAAG;IAAE;IACpD,MAAMmB,YAAY,CAAC,CAAC,EAAEvB,YAAYK,QAAQ,EAAE,CAAC;IAC7C,MAAMmB,SAASzB,yBAAyBgB;IAExC,MAAM,EAAEN,KAAK,EAAE,GAAG,MAAMR,WAAW;QACjCwB,SAAS,IAAI;QACbD;QACAlB;QACAiB;QACAd,OAAOY;IACT;IAEA,MAAMK,SAAS,MAAMxB,UAA8B;QACjDE;QACAqB,SAAS,IAAI;QACbE,MAAMnB;QACNG;QACAa;QACAI,WAAW;QACXL;QACAd;QACAF;IACF;IAEA,OAAOmB;AACT"}
@@ -33,4 +33,4 @@ export async function updateVersion({ id, collection, locale, req = {}, versionD
33
33
  return result;
34
34
  }
35
35
 
36
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy91cGRhdGVWZXJzaW9uLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB0eXBlIHsgVHlwZVdpdGhWZXJzaW9uLCBVcGRhdGVWZXJzaW9uQXJncyB9IGZyb20gJ3BheWxvYWQvZGF0YWJhc2UnXG5pbXBvcnQgdHlwZSB7IFBheWxvYWRSZXF1ZXN0LCBTYW5pdGl6ZWRDb2xsZWN0aW9uQ29uZmlnLCBUeXBlV2l0aElEIH0gZnJvbSAncGF5bG9hZC90eXBlcydcblxuaW1wb3J0IHsgYnVpbGRWZXJzaW9uQ29sbGVjdGlvbkZpZWxkcyB9IGZyb20gJ3BheWxvYWQvdmVyc2lvbnMnXG5pbXBvcnQgdG9TbmF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PLGVBQWVDLGNBRXBCLEVBQ0VDLEVBQUUsRUFDRkMsVUFBVSxFQUNWQyxNQUFNLEVBQ05DLE1BQU0sQ0FBQyxDQUFtQixFQUMxQkMsV0FBVyxFQUNYQyxPQUFPQyxRQUFRLEVBQ007SUFFdkIsTUFBTUMsS0FBSyxJQUFJLENBQUNDLFFBQVEsQ0FBQ0wsSUFBSU0sYUFBYSxDQUFDLEVBQUVGLE1BQU0sSUFBSSxDQUFDRyxPQUFPO0lBQy9ELE1BQU1DLG1CQUE4QyxJQUFJLENBQUNDLE9BQU8sQ0FBQ0MsV0FBVyxDQUFDWixXQUFXLENBQUNhLE1BQU07SUFDL0YsTUFBTUMsYUFBYVQsWUFBWTtRQUFFTixJQUFJO1lBQUVnQixRQUFRaEI7UUFBRztJQUFFO0lBQ3BELE1BQU1pQixZQUFZLENBQUMsQ0FBQyxFQUFFckIsWUFBWUssWUFBWSxFQUFFLENBQUM7SUFDakQsTUFBTWlCLFNBQVN2Qiw2QkFBNkJnQjtJQUU1QyxNQUFNLEVBQUVOLEtBQUssRUFBRSxHQUFHLE1BQU1SLFdBQVc7UUFDakNzQixTQUFTLElBQUk7UUFDYkQ7UUFDQWhCO1FBQ0FlO1FBQ0FaLE9BQU9VO0lBQ1Q7SUFFQSxNQUFNSyxTQUFTLE1BQU10QixVQUE4QjtRQUNqREU7UUFDQW1CLFNBQVMsSUFBSTtRQUNiRSxNQUFNakI7UUFDTkc7UUFDQVc7UUFDQUksV0FBVztRQUNYTDtRQUNBWjtRQUNBRjtJQUNGO0lBRUEsT0FBT2lCO0FBQ1QifQ==
36
+ //# sourceMappingURL=updateVersion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/updateVersion.ts"],"sourcesContent":["import type { TypeWithVersion, UpdateVersionArgs } from 'payload/database'\nimport type { PayloadRequest, SanitizedCollectionConfig, TypeWithID } from 'payload/types'\n\nimport { buildVersionCollectionFields } from 'payload/versions'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport buildQuery from './queries/buildQuery.js'\nimport { upsertRow } from './upsertRow/index.js'\n\nexport async function updateVersion<T extends TypeWithID>(\n this: PostgresAdapter,\n {\n id,\n collection,\n locale,\n req = {} as PayloadRequest,\n versionData,\n where: whereArg,\n }: UpdateVersionArgs<T>,\n) {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config\n const whereToUse = whereArg || { id: { equals: id } }\n const tableName = `_${toSnakeCase(collection)}_v`\n const fields = buildVersionCollectionFields(collectionConfig)\n\n const { where } = await buildQuery({\n adapter: this,\n fields,\n locale,\n tableName,\n where: whereToUse,\n })\n\n const result = await upsertRow<TypeWithVersion<T>>({\n id,\n adapter: this,\n data: versionData,\n db,\n fields,\n operation: 'update',\n tableName,\n where,\n req,\n })\n\n return result\n}\n"],"names":["buildVersionCollectionFields","toSnakeCase","buildQuery","upsertRow","updateVersion","id","collection","locale","req","versionData","where","whereArg","db","sessions","transactionID","drizzle","collectionConfig","payload","collections","config","whereToUse","equals","tableName","fields","adapter","result","data","operation"],"mappings":"AAGA,SAASA,4BAA4B,QAAQ,mBAAkB;AAC/D,OAAOC,iBAAiB,gBAAe;AAIvC,OAAOC,gBAAgB,0BAAyB;AAChD,SAASC,SAAS,QAAQ,uBAAsB;AAEhD,OAAO,eAAeC,cAEpB,EACEC,EAAE,EACFC,UAAU,EACVC,MAAM,EACNC,MAAM,CAAC,CAAmB,EAC1BC,WAAW,EACXC,OAAOC,QAAQ,EACM;IAEvB,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACL,IAAIM,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMC,mBAA8C,IAAI,CAACC,OAAO,CAACC,WAAW,CAACZ,WAAW,CAACa,MAAM;IAC/F,MAAMC,aAAaT,YAAY;QAAEN,IAAI;YAAEgB,QAAQhB;QAAG;IAAE;IACpD,MAAMiB,YAAY,CAAC,CAAC,EAAErB,YAAYK,YAAY,EAAE,CAAC;IACjD,MAAMiB,SAASvB,6BAA6BgB;IAE5C,MAAM,EAAEN,KAAK,EAAE,GAAG,MAAMR,WAAW;QACjCsB,SAAS,IAAI;QACbD;QACAhB;QACAe;QACAZ,OAAOU;IACT;IAEA,MAAMK,SAAS,MAAMtB,UAA8B;QACjDE;QACAmB,SAAS,IAAI;QACbE,MAAMjB;QACNG;QACAW;QACAI,WAAW;QACXL;QACAZ;QACAF;IACF;IAEA,OAAOiB;AACT"}
@@ -7,4 +7,4 @@ export const deleteExistingArrayRows = async ({ adapter, db, parentID, tableName
7
7
  await db.delete(table).where(and(...whereConstraints));
8
8
  };
9
9
 
10
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91cHNlcnRSb3cvZGVsZXRlRXhpc3RpbmdBcnJheVJvd3MudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgYW5kLCBlcSB9IGZyb20gJ2RyaXp6bGUtb3JtJ1xuXG5pbXBvcnQgdHlwZSB7IERyaXp6bGVEQiwgUG9zdGdyZXNBZGFwdGVyIH0gZnJvbSAnLi4vdHlwZXMuanMnXG5cbnR5cGUgQXJncyA9IHtcbiAgYWRhcHRlcjogUG9zdGdyZXNBZGFwdGVyXG4gIGRiOiBEcml6emxlREJcbiAgcGFyZW50SUQ6IHVua25vd25cbiAgdGFibGVOYW1lOiBzdHJpbmdcbn1cblxuZXhwb3J0IGNvbnN0IGRlbGV0ZUV4aXN0aW5nQXJyYXlSb3dzID0gYXN5bmMgKHtcbiAgYWRhcHRlcixcbiAgZGIsXG4gIHBhcmVudElELFxuICB0YWJsZU5hbWUsXG59OiBBcmdzKTogUHJvbWlzZTx2b2lkPiA9PiB7XG4gIGNvbnN0IHRhYmxlID0gYWRhcHRlci50YWJsZXNbdGFibGVOYW1lXVxuXG4gIGNvbnN0IHdoZXJlQ29uc3RyYWludHMgPSBbZXEodGFibGUuX3BhcmVudElELCBwYXJlbnRJRCldXG5cbiAgYXdhaXQgZGIuZGVsZXRlKHRhYmxlKS53aGVyZShhbmQoLi4ud2hlcmVDb25zdHJhaW50cykpXG59XG4iXSwibmFtZXMiOlsiYW5kIiwiZXEiLCJkZWxldGVFeGlzdGluZ0FycmF5Um93cyIsImFkYXB0ZXIiLCJkYiIsInBhcmVudElEIiwidGFibGVOYW1lIiwidGFibGUiLCJ0YWJsZXMiLCJ3aGVyZUNvbnN0cmFpbnRzIiwiX3BhcmVudElEIiwiZGVsZXRlIiwid2hlcmUiXSwibWFwcGluZ3MiOiJBQUFBLFNBQVNBLEdBQUcsRUFBRUMsRUFBRSxRQUFRLGNBQWE7QUFXckMsT0FBTyxNQUFNQywwQkFBMEIsT0FBTyxFQUM1Q0MsT0FBTyxFQUNQQyxFQUFFLEVBQ0ZDLFFBQVEsRUFDUkMsU0FBUyxFQUNKO0lBQ0wsTUFBTUMsUUFBUUosUUFBUUssTUFBTSxDQUFDRixVQUFVO0lBRXZDLE1BQU1HLG1CQUFtQjtRQUFDUixHQUFHTSxNQUFNRyxTQUFTLEVBQUVMO0tBQVU7SUFFeEQsTUFBTUQsR0FBR08sTUFBTSxDQUFDSixPQUFPSyxLQUFLLENBQUNaLE9BQU9TO0FBQ3RDLEVBQUMifQ==
10
+ //# sourceMappingURL=deleteExistingArrayRows.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/upsertRow/deleteExistingArrayRows.ts"],"sourcesContent":["import { and, eq } from 'drizzle-orm'\n\nimport type { DrizzleDB, PostgresAdapter } from '../types.js'\n\ntype Args = {\n adapter: PostgresAdapter\n db: DrizzleDB\n parentID: unknown\n tableName: string\n}\n\nexport const deleteExistingArrayRows = async ({\n adapter,\n db,\n parentID,\n tableName,\n}: Args): Promise<void> => {\n const table = adapter.tables[tableName]\n\n const whereConstraints = [eq(table._parentID, parentID)]\n\n await db.delete(table).where(and(...whereConstraints))\n}\n"],"names":["and","eq","deleteExistingArrayRows","adapter","db","parentID","tableName","table","tables","whereConstraints","_parentID","delete","where"],"mappings":"AAAA,SAASA,GAAG,EAAEC,EAAE,QAAQ,cAAa;AAWrC,OAAO,MAAMC,0BAA0B,OAAO,EAC5CC,OAAO,EACPC,EAAE,EACFC,QAAQ,EACRC,SAAS,EACJ;IACL,MAAMC,QAAQJ,QAAQK,MAAM,CAACF,UAAU;IAEvC,MAAMG,mBAAmB;QAACR,GAAGM,MAAMG,SAAS,EAAEL;KAAU;IAExD,MAAMD,GAAGO,MAAM,CAACJ,OAAOK,KAAK,CAACZ,OAAOS;AACtC,EAAC"}
@@ -30,4 +30,4 @@ export const deleteExistingRowsByPath = async ({ adapter, db, localeColumnName =
30
30
  }
31
31
  };
32
32
 
33
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91cHNlcnRSb3cvZGVsZXRlRXhpc3RpbmdSb3dzQnlQYXRoLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IGFuZCwgZXEsIGluQXJyYXkgfSBmcm9tICdkcml6emxlLW9ybSdcblxuaW1wb3J0IHR5cGUgeyBEcml6emxlREIsIFBvc3RncmVzQWRhcHRlciB9IGZyb20gJy4uL3R5cGVzLmpzJ1xuXG50eXBlIEFyZ3MgPSB7XG4gIGFkYXB0ZXI6IFBvc3RncmVzQWRhcHRlclxuICBkYjogRHJpenpsZURCXG4gIGxvY2FsZUNvbHVtbk5hbWU/OiBzdHJpbmdcbiAgcGFyZW50Q29sdW1uTmFtZT86IHN0cmluZ1xuICBwYXJlbnRJRDogdW5rbm93blxuICBwYXRoQ29sdW1uTmFtZT86IHN0cmluZ1xuICByb3dzOiBSZWNvcmQ8c3RyaW5nLCB1bmtub3duPltdXG4gIHRhYmxlTmFtZTogc3RyaW5nXG59XG5cbmV4cG9ydCBjb25zdCBkZWxldGVFeGlzdGluZ1Jvd3NCeVBhdGggPSBhc3luYyAo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FFaEUsSUFBSUMsZ0JBQ0ZjLGlCQUFpQkMsSUFBSSxDQUFDdEIsUUFBUWEsS0FBSyxDQUFDTixlQUFlLEVBQUVnQixNQUFNQyxJQUFJLENBQUNaO1FBRWxFLE1BQU1ULEdBQUdzQixNQUFNLENBQUNaLE9BQU9hLEtBQUssQ0FBQzVCLE9BQU91QjtJQUN0QztBQUNGLEVBQUMifQ==
33
+ //# sourceMappingURL=deleteExistingRowsByPath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/upsertRow/deleteExistingRowsByPath.ts"],"sourcesContent":["import { and, eq, inArray } from 'drizzle-orm'\n\nimport type { DrizzleDB, PostgresAdapter } from '../types.js'\n\ntype Args = {\n adapter: PostgresAdapter\n db: DrizzleDB\n localeColumnName?: string\n parentColumnName?: string\n parentID: unknown\n pathColumnName?: string\n rows: Record<string, unknown>[]\n tableName: string\n}\n\nexport const deleteExistingRowsByPath = async ({\n adapter,\n db,\n localeColumnName = '_locale',\n parentColumnName = '_parentID',\n parentID,\n pathColumnName = '_path',\n rows,\n tableName,\n}: Args): Promise<void> => {\n const localizedPathsToDelete = new Set<string>()\n const pathsToDelete = new Set<string>()\n const table = adapter.tables[tableName]\n\n rows.forEach((row) => {\n const path = row[pathColumnName]\n const localeData = row[localeColumnName]\n if (typeof path === 'string') {\n if (typeof localeData === 'string') {\n localizedPathsToDelete.add(path)\n } else {\n pathsToDelete.add(path)\n }\n }\n })\n\n if (localizedPathsToDelete.size > 0) {\n const whereConstraints = [eq(table[parentColumnName], parentID)]\n\n if (pathColumnName)\n whereConstraints.push(inArray(table[pathColumnName], Array.from(localizedPathsToDelete)))\n\n await db.delete(table).where(and(...whereConstraints))\n }\n\n if (pathsToDelete.size > 0) {\n const whereConstraints = [eq(table[parentColumnName], parentID)]\n\n if (pathColumnName)\n whereConstraints.push(inArray(table[pathColumnName], Array.from(pathsToDelete)))\n\n await db.delete(table).where(and(...whereConstraints))\n }\n}\n"],"names":["and","eq","inArray","deleteExistingRowsByPath","adapter","db","localeColumnName","parentColumnName","parentID","pathColumnName","rows","tableName","localizedPathsToDelete","Set","pathsToDelete","table","tables","forEach","row","path","localeData","add","size","whereConstraints","push","Array","from","delete","where"],"mappings":"AAAA,SAASA,GAAG,EAAEC,EAAE,EAAEC,OAAO,QAAQ,cAAa;AAe9C,OAAO,MAAMC,2BAA2B,OAAO,EAC7CC,OAAO,EACPC,EAAE,EACFC,mBAAmB,SAAS,EAC5BC,mBAAmB,WAAW,EAC9BC,QAAQ,EACRC,iBAAiB,OAAO,EACxBC,IAAI,EACJC,SAAS,EACJ;IACL,MAAMC,yBAAyB,IAAIC;IACnC,MAAMC,gBAAgB,IAAID;IAC1B,MAAME,QAAQX,QAAQY,MAAM,CAACL,UAAU;IAEvCD,KAAKO,OAAO,CAAC,CAACC;QACZ,MAAMC,OAAOD,GAAG,CAACT,eAAe;QAChC,MAAMW,aAAaF,GAAG,CAACZ,iBAAiB;QACxC,IAAI,OAAOa,SAAS,UAAU;YAC5B,IAAI,OAAOC,eAAe,UAAU;gBAClCR,uBAAuBS,GAAG,CAACF;YAC7B,OAAO;gBACLL,cAAcO,GAAG,CAACF;YACpB;QACF;IACF;IAEA,IAAIP,uBAAuBU,IAAI,GAAG,GAAG;QACnC,MAAMC,mBAAmB;YAACtB,GAAGc,KAAK,CAACR,iBAAiB,EAAEC;SAAU;QAEhE,IAAIC,gBACFc,iBAAiBC,IAAI,CAACtB,QAAQa,KAAK,CAACN,eAAe,EAAEgB,MAAMC,IAAI,CAACd;QAElE,MAAMP,GAAGsB,MAAM,CAACZ,OAAOa,KAAK,CAAC5B,OAAOuB;IACtC;IAEA,IAAIT,cAAcQ,IAAI,GAAG,GAAG;QAC1B,MAAMC,mBAAmB;YAACtB,GAAGc,KAAK,CAACR,iBAAiB,EAAEC;SAAU;QAEhE,IAAIC,gBACFc,iBAAiBC,IAAI,CAACtB,QAAQa,KAAK,CAACN,eAAe,EAAEgB,MAAMC,IAAI,CAACZ;QAElE,MAAMT,GAAGsB,MAAM,CAACZ,OAAOa,KAAK,CAAC5B,OAAOuB;IACtC;AACF,EAAC"}
@@ -273,4 +273,4 @@ export const upsertRow = async ({ id, adapter, data, db, fields, operation, path
273
273
  return result;
274
274
  };
275
275
 
276
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91cHNlcnRSb3cvaW5kZXgudHMiXSwic291cmNlc0NvbnRlbnQiOlsiLyogZXNsaW50LWRpc2FibGUgbm8tcGFyYW0tcmVhc3NpZ24gKi9cbmltcG9ydCB0eXBlIHsgVHlwZVdpdGhJRCB9IGZyb20gJ3BheWxvYWQvdHlwZXMnXG5cbmltcG9ydCB7IGVxIH0gZnJvbSAnZHJpenpsZS1vcm0nXG5pbXBvcnQgeyBWYWxpZGF0aW9uRXJyb3IgfSBmcm9tICdwYXlsb2FkL2Vycm9ycydcblxuaW1wb3J0IHR5cGUgeyBCbG9ja1Jvd1RvSW5zZXJ0IH0gZnJvbSAnLi4vdHJhbnNmb3JtL3dyaXRlL3R5cGVzLmpzJ1xuaW1wb3J0IHR5cGUgeyBBcmdzIH0gZnJvbSAnLi90eXBlcy5qcydcblxuaW1wb3J0IHsgYnVpbGRGaW5kTWFueUFyZ3MgfSBmcm9tICcuLi9maW5kL2J1aWxkRmluZE1hbnlBcmdzLmpzJ1xuaW1wb3J0IHsgdHJhbnNmb3JtIH0gZnJvbSAnLi4vdHJhbnNmb3JtL3JlYWQvaW5kZXguanMnXG5pbXBvcnQgeyB0cmFuc2Zvcm1Gb3JXcml0ZSB9IGZyb20gJy4uL3RyYW5zZm9ybS93cml0ZS9pbmRleC5qcydcbmltcG9ydCB7IGRlbGV0ZUV4aXN0aW5nQXJyYXlSb3dzIH0gZnJvbSAnLi9kZWxldGVFeGlzdGluZ0FycmF5Um93cy5qcydcbmltcG9ydCB7IGRlbGV0ZUV4aXN0aW5nUm93c0J5UGF0aCB9IGZyb20gJy4vZGVsZXRlR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lBRXBFLE1BQU0wRixNQUFNLE1BQU12RixHQUFHd0YsS0FBSyxDQUFDbkYsVUFBVSxDQUFDb0YsU0FBUyxDQUFDSjtJQUVoRCxxQ0FBcUM7SUFDckMsaUJBQWlCO0lBQ2pCLHFDQUFxQztJQUVyQyxNQUFNSyxTQUFTbkcsVUFBYTtRQUMxQm9HLFFBQVE3RixRQUFROEYsT0FBTyxDQUFDRCxNQUFNO1FBQzlCNUYsTUFBTXdGO1FBQ050RjtJQUNGO0lBRUEsT0FBT3lGO0FBQ1QsRUFBQyJ9
276
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/upsertRow/index.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { TypeWithID } from 'payload/types'\n\nimport { eq } from 'drizzle-orm'\nimport { ValidationError } from 'payload/errors'\n\nimport type { BlockRowToInsert } from '../transform/write/types.js'\nimport type { Args } from './types.js'\n\nimport { buildFindManyArgs } from '../find/buildFindManyArgs.js'\nimport { transform } from '../transform/read/index.js'\nimport { transformForWrite } from '../transform/write/index.js'\nimport { deleteExistingArrayRows } from './deleteExistingArrayRows.js'\nimport { deleteExistingRowsByPath } from './deleteExistingRowsByPath.js'\nimport { insertArrays } from './insertArrays.js'\n\nexport const upsertRow = async <T extends TypeWithID>({\n id,\n adapter,\n data,\n db,\n fields,\n operation,\n path = '',\n req,\n tableName,\n upsertTarget,\n where,\n}: Args): Promise<T> => {\n // Split out the incoming data into the corresponding:\n // base row, locales, relationships, blocks, and arrays\n const rowToInsert = transformForWrite({\n adapter,\n data,\n fields,\n path,\n tableName,\n })\n\n // First, we insert the main row\n let insertedRow: Record<string, unknown>\n\n try {\n if (operation === 'update') {\n const target = upsertTarget || adapter.tables[tableName].id\n\n if (id) {\n rowToInsert.row.id = id\n ;[insertedRow] = await db\n .insert(adapter.tables[tableName])\n .values(rowToInsert.row)\n .onConflictDoUpdate({ set: rowToInsert.row, target })\n .returning()\n } else {\n ;[insertedRow] = await db\n .insert(adapter.tables[tableName])\n .values(rowToInsert.row)\n .onConflictDoUpdate({ set: rowToInsert.row, target, where })\n .returning()\n }\n } else {\n ;[insertedRow] = await db\n .insert(adapter.tables[tableName])\n .values(rowToInsert.row)\n .returning()\n }\n\n const localesToInsert: Record<string, unknown>[] = []\n const relationsToInsert: Record<string, unknown>[] = []\n const textsToInsert: Record<string, unknown>[] = []\n const numbersToInsert: Record<string, unknown>[] = []\n const blocksToInsert: { [blockType: string]: BlockRowToInsert[] } = {}\n const selectsToInsert: { [selectTableName: string]: Record<string, unknown>[] } = {}\n\n // If there are locale rows with data, add the parent and locale to each\n if (Object.keys(rowToInsert.locales).length > 0) {\n Object.entries(rowToInsert.locales).forEach(([locale, localeRow]) => {\n localeRow._parentID = insertedRow.id\n localeRow._locale = locale\n localesToInsert.push(localeRow)\n })\n }\n\n // If there are relationships, add parent to each\n if (rowToInsert.relationships.length > 0) {\n rowToInsert.relationships.forEach((relation) => {\n relation.parent = insertedRow.id\n relationsToInsert.push(relation)\n })\n }\n\n // If there are texts, add parent to each\n if (rowToInsert.texts.length > 0) {\n rowToInsert.texts.forEach((textRow) => {\n textRow.parent = insertedRow.id\n textsToInsert.push(textRow)\n })\n }\n\n // If there are numbers, add parent to each\n if (rowToInsert.numbers.length > 0) {\n rowToInsert.numbers.forEach((numberRow) => {\n numberRow.parent = insertedRow.id\n numbersToInsert.push(numberRow)\n })\n }\n\n // If there are selects, add parent to each, and then\n // store by table name and rows\n if (Object.keys(rowToInsert.selects).length > 0) {\n Object.entries(rowToInsert.selects).forEach(([selectTableName, selectRows]) => {\n selectRows.forEach((row) => {\n if (typeof row.parent === 'undefined') {\n row.parent = insertedRow.id\n }\n if (!selectsToInsert[selectTableName]) selectsToInsert[selectTableName] = []\n selectsToInsert[selectTableName].push(row)\n })\n })\n }\n\n // If there are blocks, add parent to each, and then\n // store by table name and rows\n Object.keys(rowToInsert.blocks).forEach((blockName) => {\n rowToInsert.blocks[blockName].forEach((blockRow) => {\n blockRow.row._parentID = insertedRow.id\n if (!blocksToInsert[blockName]) blocksToInsert[blockName] = []\n if (blockRow.row.uuid) {\n delete blockRow.row.uuid\n }\n blocksToInsert[blockName].push(blockRow)\n })\n })\n\n // //////////////////////////////////\n // INSERT LOCALES\n // //////////////////////////////////\n\n if (localesToInsert.length > 0) {\n const localeTable = adapter.tables[`${tableName}_locales`]\n\n if (operation === 'update') {\n await db.delete(localeTable).where(eq(localeTable._parentID, insertedRow.id))\n }\n\n await db.insert(localeTable).values(localesToInsert)\n }\n\n // //////////////////////////////////\n // INSERT RELATIONSHIPS\n // //////////////////////////////////\n\n const relationshipsTableName = `${tableName}_rels`\n\n if (operation === 'update') {\n await deleteExistingRowsByPath({\n adapter,\n db,\n localeColumnName: 'locale',\n parentColumnName: 'parent',\n parentID: insertedRow.id,\n pathColumnName: 'path',\n rows: [...relationsToInsert, ...rowToInsert.relationshipsToDelete],\n tableName: relationshipsTableName,\n })\n }\n\n if (relationsToInsert.length > 0) {\n await db.insert(adapter.tables[relationshipsTableName]).values(relationsToInsert)\n }\n\n // //////////////////////////////////\n // INSERT hasMany TEXTS\n // //////////////////////////////////\n\n const textsTableName = `${tableName}_texts`\n\n if (operation === 'update') {\n await deleteExistingRowsByPath({\n adapter,\n db,\n localeColumnName: 'locale',\n parentColumnName: 'parent',\n parentID: insertedRow.id,\n pathColumnName: 'path',\n rows: textsToInsert,\n tableName: textsTableName,\n })\n }\n\n if (textsToInsert.length > 0) {\n await db.insert(adapter.tables[textsTableName]).values(textsToInsert).returning()\n }\n\n // //////////////////////////////////\n // INSERT hasMany NUMBERS\n // //////////////////////////////////\n\n const numbersTableName = `${tableName}_numbers`\n\n if (operation === 'update') {\n await deleteExistingRowsByPath({\n adapter,\n db,\n localeColumnName: 'locale',\n parentColumnName: 'parent',\n parentID: insertedRow.id,\n pathColumnName: 'path',\n rows: numbersToInsert,\n tableName: numbersTableName,\n })\n }\n\n if (numbersToInsert.length > 0) {\n await db.insert(adapter.tables[numbersTableName]).values(numbersToInsert).returning()\n }\n\n // //////////////////////////////////\n // INSERT BLOCKS\n // //////////////////////////////////\n\n const insertedBlockRows: Record<string, Record<string, unknown>[]> = {}\n\n if (operation === 'update') {\n for (const blockName of rowToInsert.blocksToDelete) {\n const blockTableName = `${tableName}_blocks_${blockName}`\n const blockTable = adapter.tables[blockTableName]\n await db.delete(blockTable).where(eq(blockTable._parentID, insertedRow.id))\n }\n }\n\n for (const [blockName, blockRows] of Object.entries(blocksToInsert)) {\n insertedBlockRows[blockName] = await db\n .insert(adapter.tables[`${tableName}_blocks_${blockName}`])\n .values(blockRows.map(({ row }) => row))\n .returning()\n\n insertedBlockRows[blockName].forEach((row, i) => {\n blockRows[i].row = row\n })\n\n const blockLocaleIndexMap: number[] = []\n\n const blockLocaleRowsToInsert = blockRows.reduce((acc, blockRow, i) => {\n if (Object.entries(blockRow.locales).length > 0) {\n Object.entries(blockRow.locales).forEach(([blockLocale, blockLocaleData]) => {\n if (Object.keys(blockLocaleData).length > 0) {\n blockLocaleData._parentID = blockRow.row.id\n blockLocaleData._locale = blockLocale\n acc.push(blockLocaleData)\n blockLocaleIndexMap.push(i)\n }\n })\n }\n\n return acc\n }, [])\n\n if (blockLocaleRowsToInsert.length > 0) {\n await db\n .insert(adapter.tables[`${tableName}_blocks_${blockName}_locales`])\n .values(blockLocaleRowsToInsert)\n .returning()\n }\n\n await insertArrays({\n adapter,\n arrays: blockRows.map(({ arrays }) => arrays),\n db,\n parentRows: insertedBlockRows[blockName],\n })\n }\n\n // //////////////////////////////////\n // INSERT ARRAYS RECURSIVELY\n // //////////////////////////////////\n\n if (operation === 'update') {\n for (const arrayTableName of Object.keys(rowToInsert.arrays)) {\n await deleteExistingArrayRows({\n adapter,\n db,\n parentID: insertedRow.id,\n tableName: arrayTableName,\n })\n }\n }\n\n await insertArrays({\n adapter,\n arrays: [rowToInsert.arrays],\n db,\n parentRows: [insertedRow],\n })\n\n // //////////////////////////////////\n // INSERT hasMany SELECTS\n // //////////////////////////////////\n\n for (const [selectTableName, tableRows] of Object.entries(selectsToInsert)) {\n const selectTable = adapter.tables[selectTableName]\n if (operation === 'update') {\n await db.delete(selectTable).where(eq(selectTable.parent, insertedRow.id))\n }\n await db.insert(selectTable).values(tableRows).returning()\n }\n\n // //////////////////////////////////\n // Error Handling\n // //////////////////////////////////\n } catch (error) {\n throw error.code === '23505'\n ? new ValidationError(\n [\n {\n field: adapter.fieldConstraints[tableName][error.constraint],\n message: req.t('error:valueMustBeUnique'),\n },\n ],\n req.t,\n )\n : error\n }\n\n // //////////////////////////////////\n // RETRIEVE NEWLY UPDATED ROW\n // //////////////////////////////////\n\n const findManyArgs = buildFindManyArgs({\n adapter,\n depth: 0,\n fields,\n tableName,\n })\n\n findManyArgs.where = eq(adapter.tables[tableName].id, insertedRow.id)\n\n const doc = await db.query[tableName].findFirst(findManyArgs)\n\n // //////////////////////////////////\n // TRANSFORM DATA\n // //////////////////////////////////\n\n const result = transform<T>({\n config: adapter.payload.config,\n data: doc,\n fields,\n })\n\n return result\n}\n"],"names":["eq","ValidationError","buildFindManyArgs","transform","transformForWrite","deleteExistingArrayRows","deleteExistingRowsByPath","insertArrays","upsertRow","id","adapter","data","db","fields","operation","path","req","tableName","upsertTarget","where","rowToInsert","insertedRow","target","tables","row","insert","values","onConflictDoUpdate","set","returning","localesToInsert","relationsToInsert","textsToInsert","numbersToInsert","blocksToInsert","selectsToInsert","Object","keys","locales","length","entries","forEach","locale","localeRow","_parentID","_locale","push","relationships","relation","parent","texts","textRow","numbers","numberRow","selects","selectTableName","selectRows","blocks","blockName","blockRow","uuid","localeTable","delete","relationshipsTableName","localeColumnName","parentColumnName","parentID","pathColumnName","rows","relationshipsToDelete","textsTableName","numbersTableName","insertedBlockRows","blocksToDelete","blockTableName","blockTable","blockRows","map","i","blockLocaleIndexMap","blockLocaleRowsToInsert","reduce","acc","blockLocale","blockLocaleData","arrays","parentRows","arrayTableName","tableRows","selectTable","error","code","field","fieldConstraints","constraint","message","t","findManyArgs","depth","doc","query","findFirst","result","config","payload"],"mappings":"AAAA,oCAAoC,GAGpC,SAASA,EAAE,QAAQ,cAAa;AAChC,SAASC,eAAe,QAAQ,iBAAgB;AAKhD,SAASC,iBAAiB,QAAQ,+BAA8B;AAChE,SAASC,SAAS,QAAQ,6BAA4B;AACtD,SAASC,iBAAiB,QAAQ,8BAA6B;AAC/D,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,SAASC,wBAAwB,QAAQ,gCAA+B;AACxE,SAASC,YAAY,QAAQ,oBAAmB;AAEhD,OAAO,MAAMC,YAAY,OAA6B,EACpDC,EAAE,EACFC,OAAO,EACPC,IAAI,EACJC,EAAE,EACFC,MAAM,EACNC,SAAS,EACTC,OAAO,EAAE,EACTC,GAAG,EACHC,SAAS,EACTC,YAAY,EACZC,KAAK,EACA;IACL,sDAAsD;IACtD,uDAAuD;IACvD,MAAMC,cAAchB,kBAAkB;QACpCM;QACAC;QACAE;QACAE;QACAE;IACF;IAEA,gCAAgC;IAChC,IAAII;IAEJ,IAAI;QACF,IAAIP,cAAc,UAAU;YAC1B,MAAMQ,SAASJ,gBAAgBR,QAAQa,MAAM,CAACN,UAAU,CAACR,EAAE;YAE3D,IAAIA,IAAI;gBACNW,YAAYI,GAAG,CAACf,EAAE,GAAGA;gBACpB,CAACY,YAAY,GAAG,MAAMT,GACpBa,MAAM,CAACf,QAAQa,MAAM,CAACN,UAAU,EAChCS,MAAM,CAACN,YAAYI,GAAG,EACtBG,kBAAkB,CAAC;oBAAEC,KAAKR,YAAYI,GAAG;oBAAEF;gBAAO,GAClDO,SAAS;YACd,OAAO;gBACJ,CAACR,YAAY,GAAG,MAAMT,GACpBa,MAAM,CAACf,QAAQa,MAAM,CAACN,UAAU,EAChCS,MAAM,CAACN,YAAYI,GAAG,EACtBG,kBAAkB,CAAC;oBAAEC,KAAKR,YAAYI,GAAG;oBAAEF;oBAAQH;gBAAM,GACzDU,SAAS;YACd;QACF,OAAO;YACJ,CAACR,YAAY,GA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U0sR0FBRyxHQUFHO1lBQ3BFLElBQUksQ0FBQ0UsSUFBSVQsT0FBTyxDQUFDLEVBQUUsQ0FBQ1UsU0FBUyxFQUFFO2dCQUM3QkQsSUFBSVQsT0FBTyxHQUFHUyxJQUFJVCxPQUFPLENBQUNvQixHQUFHLENBQUMsQ0FBQ0MsV0FBV2hCO29CQUN4QyxJQUFJLE9BQU9nQixVQUFVUCxZQUFZLEtBQUssWUFBWTt3QkFDaERPLFVBQVVYLFNBQVMsR0FBR1csVUFBVVAsWUFBWSxDQUFDQzt3QkFDN0MsT0FBT00sVUFBVVAsWUFBWTtvQkFDL0I7b0JBQ0EsT0FBT087Z0JBQ1Q7WUFDRjtZQUNBLE1BQU0vQixHQUFHMEIsTUFBTSxDQUFDNUIsUUFBUTZCLE1BQU0sQ0FBQyxDQUFDLEVBQUVuQixVQUFVLFFBQVEsQ0FBQyxDQUFDLEVBQUVvQixNQUFNLENBQUNULElBQUlULE9BQU8sRUFBRW1CLFNBQVM7UUFDdkY7UUFFQSwwREFBMEQ7UUFDMUQsSUFBSVYsSUFBSXBCLE1BQU0sQ0FBQ2tCLE1BQU0sR0FBRyxHQUFHO1lBQ3pCLE1BQU1wQixhQUFhO2dCQUNqQkM7Z0JBQ0FDLFFBQVFvQixJQUFJcEIsTUFBTTtnQkFDbEJDO2dCQUNBQyxZQUFZd0I7WUFDZDtRQUNGO0lBQ0Y7QUFDRixFQUFDIn0=
68
+ //# sourceMappingURL=insertArrays.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/upsertRow/insertArrays.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { ArrayRowToInsert } from '../transform/write/types.js'\nimport type { DrizzleDB, PostgresAdapter } from '../types.js'\n\ntype Args = {\n adapter: PostgresAdapter\n arrays: {\n [tableName: string]: ArrayRowToInsert[]\n }[]\n db: DrizzleDB\n parentRows: Record<string, unknown>[]\n}\n\ntype RowsByTable = {\n [tableName: string]: {\n arrays: {\n [tableName: string]: ArrayRowToInsert[]\n }[]\n locales: Record<string, unknown>[]\n rows: Record<string, unknown>[]\n }\n}\n\nexport const insertArrays = async ({ adapter, arrays, db, parentRows }: Args): Promise<void> => {\n // Maintain a map of flattened rows by table\n const rowsByTable: RowsByTable = {}\n\n arrays.forEach((arraysByTable, parentRowIndex) => {\n Object.entries(arraysByTable).forEach(([tableName, arrayRows]) => {\n // If the table doesn't exist in map, initialize it\n if (!rowsByTable[tableName]) {\n rowsByTable[tableName] = {\n arrays: [],\n locales: [],\n rows: [],\n }\n }\n\n const parentID = parentRows[parentRowIndex].id\n\n // Add any sub arrays that need to be created\n // We will call this recursively below\n arrayRows.forEach((arrayRow, i) => {\n if (Object.keys(arrayRow.arrays).length > 0) {\n rowsByTable[tableName].arrays.push(arrayRow.arrays)\n }\n\n // Set up parent IDs for both row and locale row\n arrayRow.row._parentID = parentID\n rowsByTable[tableName].rows.push(arrayRow.row)\n\n Object.entries(arrayRow.locales).forEach(([arrayRowLocale, arrayRowLocaleData]) => {\n arrayRowLocaleData._parentID = arrayRow.row.id\n arrayRowLocaleData._locale = arrayRowLocale\n rowsByTable[tableName].locales.push(arrayRowLocaleData)\n if (!arrayRow.row.id) {\n arrayRowLocaleData._getParentID = (rows) => rows[i].id\n }\n })\n })\n })\n })\n\n // Insert all corresponding arrays\n // (one insert per array table)\n for (const [tableName, row] of Object.entries(rowsByTable)) {\n // the nested arrays need the ID for the parentID foreign key\n let insertedRows: Args['parentRows']\n if (row.rows.length > 0) {\n insertedRows = await db.insert(adapter.tables[tableName]).values(row.rows).returning()\n }\n\n // Insert locale rows\n if (adapter.tables[`${tableName}_locales`] && row.locales.length > 0) {\n if (!row.locales[0]._parentID) {\n row.locales = row.locales.map((localeRow, i) => {\n if (typeof localeRow._getParentID === 'function') {\n localeRow._parentID = localeRow._getParentID(insertedRows)\n delete localeRow._getParentID\n }\n return localeRow\n })\n }\n await db.insert(adapter.tables[`${tableName}_locales`]).values(row.locales).returning()\n }\n\n // If there are sub arrays, call this function recursively\n if (row.arrays.length > 0) {\n await insertArrays({\n adapter,\n arrays: row.arrays,\n db,\n parentRows: insertedRows,\n })\n }\n }\n}\n"],"names":["insertArrays","adapter","arrays","db","parentRows","rowsByTable","forEach","arraysByTable","parentRowIndex","Object","entries","tableName","arrayRows","locales","rows","parentID","id","arrayRow","i","keys","length","push","row","_parentID","arrayRowLocale","arrayRowLocaleData","_locale","_getParentID","insertedRows","insert","tables","values","returning","map","localeRow"],"mappings":"AAAA,oCAAoC,GAuBpC,OAAO,MAAMA,eAAe,OAAO,EAAEC,OAAO,EAAEC,MAAM,EAAEC,EAAE,EAAEC,UAAU,EAAQ;IAC1E,4CAA4C;IAC5C,MAAMC,cAA2B,CAAC;IAElCH,OAAOI,OAAO,CAAC,CAACC,eAAeC;QAC7BC,OAAOC,OAAO,CAACH,eAAeD,OAAO,CAAC,CAAC,CAACK,WAAWC,UAAU;YAC3D,mDAAmD;YACnD,IAAI,CAACP,WAAW,CAACM,UAAU,EAAE;gBAC3BN,WAAW,CAACM,UAAU,GAAG;oBACvBT,QAAQ,EAAE;oBACVW,SAAS,EAAE;oBACXC,MAAM,EAAE;gBACV;YACF;YAEA,MAAMC,WAAWX,UAAU,CAACI,eAAe,CAACQ,EAAE;YAE9C,6CAA6C;YAC7C,sCAAsC;YACtCJ,UAAUN,OAAO,CAAC,CAACW,UAAUC;gBAC3B,IAAIT,OAAOU,IAAI,CAACF,SAASf,MAAM,EAAEkB,MAAM,GAAG,GAAG;oBAC3Cf,WAAW,CAACM,UAAU,CAACT,MAAM,CAACmB,IAAI,CAACJ,SAASf,MAAM;gBACpD;gBAEA,gDAAgD;gBAChDe,SAASK,GAAG,CAACC,SAAS,GAAGR;gBACzBV,WAAW,CAACM,UAAU,CAACG,IAAI,CAACO,IAAI,CAACJ,SAASK,GAAG;gBAE7Cb,OAAOC,OAAO,CAACO,SAASJ,OAAO,EAAEP,OAAO,CAAC,CAAC,CAACkB,gBAAgBC,mBAAmB;oBAC5EA,m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U1FMPHVua25vd24+XG59XG5cbmV4cG9ydCB0eXBlIEFyZ3MgPSBDcmVhdGVBcmdzIHwgVXBkYXRlQXJnc1xuIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQTZCQSxXQUEwQyJ9
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/upsertRow/types.ts"],"sourcesContent":["import type { SQL } from 'drizzle-orm'\nimport type { Field, PayloadRequest } from 'payload/types'\n\nimport type { DrizzleDB, GenericColumn, PostgresAdapter } from '../types.js'\n\ntype BaseArgs = {\n adapter: PostgresAdapter\n data: Record<string, unknown>\n db: DrizzleDB\n fields: Field[]\n path?: string\n tableName: string\n req: PayloadRequest\n}\n\ntype CreateArgs = BaseArgs & {\n id?: never\n operation: 'create'\n upsertTarget?: never\n where?: never\n}\n\ntype UpdateArgs = BaseArgs & {\n id?: number | string\n operation: 'update'\n upsertTarget?: GenericColumn\n where?: SQL<unknown>\n}\n\nexport type Args = CreateArgs | UpdateArgs\n"],"names":[],"mappings":"AA6BA,WAA0C"}
@@ -3,4 +3,4 @@ export const appendPrefixToObjectKeys = (obj, prefix)=>Object.entries(obj).reduc
3
3
  return res;
4
4
  }, {});
5
5
 
6
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlsaXRpZXMvYXBwZW5kUHJlZml4VG9LZXlzLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBjb25zdCBhcHBlbmRQcmVmaXhUb09iamVjdEtleXMgPSA8VD4ob2JqOiBSZWNvcmQ8c3RyaW5nLCB1bmtub3duPiwgcHJlZml4OiBzdHJpbmcpOiBUID0+XG4gIE9iamVjdC5lbnRyaWVzKG9iaikucmVkdWNlKChyZXMsIFtrZXksIHZhbF0pID0+IHtcbiAgICByZXNbYCR7cHJlZml4fV8ke2tleX1gXSA9IHZhbFxuICAgIHJldHVybiByZXNcbiAgfSwge30gYXMgVClcbiJdLCJuYW1lcyI6WyJhcHBlbmRQcmVmaXhUb09iamVjdEtleXMiLCJvYmoiLCJwcmVmaXgiLCJPYmplY3QiLCJlbnRyaWVzIiwicmVkdWNlIiwicmVzIiwia2V5IiwidmFsIl0sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLE1BQU1BLDJCQUEyQixDQUFJQyxLQUE4QkMsU0FDeEVDLE9BQU9DLE9BQU8sQ0FBQ0gsS0FBS0ksTUFBTSxDQUFDLENBQUNDLEtBQUssQ0FBQ0MsS0FBS0MsSUFBSTtRQUN6Q0YsR0FBRyxDQUFDLENBQUMsRUFBRUosT0FBTyxDQUFDLEVBQUVLLElBQUksQ0FBQyxDQUFDLEdBQUdDO1FBQzFCLE9BQU9GO0lBQ1QsR0FBRyxDQUFDLEdBQU8ifQ==
6
+ //# sourceMappingURL=appendPrefixToKeys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/appendPrefixToKeys.ts"],"sourcesContent":["export const appendPrefixToObjectKeys = <T>(obj: Record<string, unknown>, prefix: string): T =>\n Object.entries(obj).reduce((res, [key, val]) => {\n res[`${prefix}_${key}`] = val\n return res\n }, {} as T)\n"],"names":["appendPrefixToObjectKeys","obj","prefix","Object","entries","reduce","res","key","val"],"mappings":"AAAA,OAAO,MAAMA,2BAA2B,CAAIC,KAA8BC,SACxEC,OAAOC,OAAO,CAACH,KAAKI,MAAM,CAAC,CAACC,KAAK,CAACC,KAAKC,IAAI;QACzCF,GAAG,CAAC,CAAC,EAAEJ,OAAO,CAAC,EAAEK,IAAI,CAAC,CAAC,GAAGC;QAC1B,OAAOF;IACT,GAAG,CAAC,GAAO"}
@@ -26,4 +26,4 @@
26
26
  return blocksMap;
27
27
  };
28
28
 
29
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlsaXRpZXMvY3JlYXRlQmxvY2tzTWFwLnRzIl0sInN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RLEdBQUlBLFNBQVMsQ0FBQ1csSUFBSUMsS0FBSyxDQUFDLEdBQUcsRUFBRTtvQkFFeERELElBQUlGLFNBQVMsR0FBR0E7b0JBQ2hCVCxTQUFTLENBQUNXLElBQUlDLEtBQUssQ0FBQyxDQUFDQyxJQUFJLENBQUNGO29CQUUxQixPQUFPQSxJQUFJQyxLQUFLO2dCQUNsQjtZQUNGO1lBRUEsT0FBT2IsSUFBSSxDQUFDSyxJQUFJO1FBQ2xCO0lBQ0Y7SUFFQUgsT0FBT0MsT0FBTyxDQUFDRixXQUFXYyxNQUFNLENBQUMsQ0FBQ0MsaUJBQWlCLENBQUNDLE1BQU1DLE9BQU87UUFDL0RGLGVBQWUsQ0FBQ0MsS0FBSyxHQUFHQyxPQUFPQyxJQUFJLENBQUMsQ0FBQ0MsR0FBR0M7WUFDdEMsSUFBSSxPQUFPRCxFQUFFRSxNQUFNLEtBQUssWUFBWSxPQUFPRCxFQUFFQyxNQUFNLEtBQUssVUFBVTtnQkFDaEUsT0FBT0YsRUFBRUUsTUFBTSxHQUFHRCxFQUFFQyxNQUFNO1lBQzVCO1lBRUEsT0FBTztRQUNUO1FBRUEsT0FBT047SUFDVCxHQUFHLENBQUM7SUFFSixPQUFPZjtBQUNULEVBQUMifQ==
29
+ //# sourceMappingURL=createBlocksMap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/createBlocksMap.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nexport type BlocksMap = {\n [path: string]: Record<string, unknown>[]\n}\n\nexport const createBlocksMap = (data: Record<string, unknown>): BlocksMap => {\n const blocksMap: BlocksMap = {}\n\n Object.entries(data).forEach(([key, rows]) => {\n if (key.startsWith('_blocks_') && Array.isArray(rows)) {\n const blockType = key.replace('_blocks_', '')\n\n rows.forEach((row) => {\n if ('_path' in row) {\n if (!(row._path in blocksMap)) blocksMap[row._path] = []\n\n row.blockType = blockType\n blocksMap[row._path].push(row)\n\n delete row._path\n }\n })\n\n delete data[key]\n }\n })\n\n Object.entries(blocksMap).reduce((sortedBlocksMap, [path, blocks]) => {\n sortedBlocksMap[path] = blocks.sort((a, b) => {\n if (typeof a._order === 'number' && typeof b._order === 'number') {\n return a._order - b._order\n }\n\n return 0\n })\n\n return sortedBlocksMap\n }, {})\n\n return blocksMap\n}\n"],"names":["createBlocksMap","data","blocksMap","Object","entries","forEach","key","rows","startsWith","Array","isArray","blockType","replace","row","_path","push","reduce","sortedBlocksMap","path","blocks","sort","a","b","_order"],"mappings":"AAAA,oCAAoC,GAKpC,OAAO,MAAMA,kBAAkB,CAACC;IAC9B,MAAMC,YAAuB,CAAC;IAE9BC,OAAOC,OAAO,CAACH,MAAMI,OAAO,CAAC,CAAC,CAACC,KAAKC,KAAK;QACvC,IAAID,IAAIE,UAAU,CAAC,eAAeC,MAAMC,OAAO,CAACH,OAAO;YACrD,MAAMI,YAAYL,IAAIM,OAAO,CAAC,YAAY;YAE1CL,KAAKF,OAAO,CAAC,CAACQ;gBACZ,IAAI,WAAWA,KAAK;oBAClB,IAAI,CAAEA,CAAAA,IAAIC,KAAK,IAAIZ,SAAQ,GAAIA,SAAS,CAACW,IAAIC,KAAK,CAAC,GAAG,EAAE;oBAExDD,IAAIF,SAAS,GAAGA;oBAChBT,SAAS,CAACW,IAAIC,KAAK,CAAC,CAACC,IAAI,CAACF;oBAE1B,OAAOA,IAAIC,KAAK;gBAClB;YACF;YAEA,OAAOb,IAAI,CAACK,IAAI;QAClB;IACF;IAEAH,OAAOC,OAAO,CAACF,WAAWc,MAAM,CAAC,CAACC,iBAAiB,CAACC,MAAMC,OAAO;QAC/DF,eAAe,CAACC,KAAK,GAAGC,OAAOC,IAAI,CAAC,CAACC,GAAGC;YACtC,IAAI,OAAOD,EAAEE,MAAM,KAAK,YAAY,OAAOD,EAAEC,MAAM,KAAK,UAAU;gBAChE,OAAOF,EAAEE,MAAM,GAAGD,EAAEC,MAAM;YAC5B;YAEA,OAAO;QACT;QAEA,OAAON;IACT,GAAG,CAAC;IAEJ,OAAOf;AACT,EAAC"}
@@ -10,4 +10,4 @@ export const createMigrationTable = async (adapter)=>{
10
10
  );`));
11
11
  };
12
12
 
13
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlsaXRpZXMvY3JlYXRlTWlncmF0aW9uVGFibGUudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgc3FsIH0gZnJvbSAnZHJpenpsZS1vcm0nXG5cbmltcG9ydCB0eXBlIHsgUG9zdGdyZXNBZGFwdGVyIH0gZnJvbSAnLi4vdHlwZXMuanMnXG5cbmV4cG9ydCBjb25zdCBjcmVhdGVNaWdyYXRpb25UYWJsZSA9IGFzeW5jIChhZGFwdGVyOiBQb3N0Z3Jlc0FkYXB0ZXIpOiBQcm9taXNlPHZvaWQ+ID0+IHtcbiAgY29uc3QgcHJlcGVuZFNjaGVtYSA9IGFkYXB0ZXIuc2NoZW1hTmFtZSA/IGBcIiR7YWRhcHRlci5zY2hlbWFOYW1lfVwiLmAgOiAnJ1xuXG4gIGF3YWl0IGFkYXB0ZXIuZHJpenpsZS5leGVjdXRlKFxuICAgIHNxbC5yYXcoYENSRUFURSBUQUJMRSBJRiBOT1QgRVhJU1RTICR7cHJlcGVuZFNjaGVtYX1cInBheWxvYWRfbWlncmF0aW9uc1wiIChcbiAgXCJpZFwiIHNlcmlhbCBQUklNQVJZIEtFWSBOT1QgTlVMTCxcbiAgXCJuYW1lXCIgdmFyY2hhcixcbiAgXCJiYXRjaFwiIG51bWVyaWMsXG4gIFwidXBkYXRlZF9hdFwiIHRpbWVzdGFtcCgzKSB3aXRoIHRpbWUgem9uZSBERUZBVUxUIG5vdygpIE5PVCBOVUxMLFxuICBcImNyZWF0ZWRfYXRcIiB0aW1lc3RhbXAoMykgd2l0aCB0aW1lIHpvbmUgREVGQVVMVCBub3coKSBOT1QgTlVMTFxuKTtgKSxcbiAgKVxufVxuIl0sIm5hbWVzIjpbInNxbCIsImNyZWF0ZU1pZ3JhdGlvblRhYmxlIiwiYWRhcHRlciIsInByZXBlbmRTY2hlbWEiLCJzY2hlbWFOYW1lIiwiZHJpenpsZSIsImV4ZWN1dGUiLCJyYXciXSwibWFwcGluZ3MiOiJBQUFBLFNBQVNBLEdBQUcsUUFBUSxjQUFhO0FBSWpDLE9BQU8sTUFBTUMsdUJBQXVCLE9BQU9DO0lBQ3pDLE1BQU1DLGdCQUFnQkQsUUFBUUUsVUFBVSxHQUFHLENBQUMsQ0FBQyxFQUFFRixRQUFRRSxVQUFVLENBQUMsRUFBRSxDQUFDLEdBQUc7SUFFeEUsTUFBTUYsUUFBUUcsT0FBTyxDQUFDQyxPQUFPLENBQzNCTixJQUFJTyxHQUFHLENBQUMsQ0FBQywyQkFBMkIsRUFBRUosY0FBYzs7Ozs7O0VBTXRELENBQUM7QUFFSCxFQUFDIn0=
13
+ //# sourceMappingURL=createMigrationTable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/createMigrationTable.ts"],"sourcesContent":["import { sql } from 'drizzle-orm'\n\nimport type { PostgresAdapter } from '../types.js'\n\nexport const createMigrationTable = async (adapter: PostgresAdapter): Promise<void> => {\n const prependSchema = adapter.schemaName ? `\"${adapter.schemaName}\".` : ''\n\n await adapter.drizzle.execute(\n sql.raw(`CREATE TABLE IF NOT EXISTS ${prependSchema}\"payload_migrations\" (\n \"id\" serial PRIMARY KEY NOT NULL,\n \"name\" varchar,\n \"batch\" numeric,\n \"updated_at\" timestamp(3) with time zone DEFAULT now() NOT NULL,\n \"created_at\" timestamp(3) with time zone DEFAULT now() NOT NULL\n);`),\n )\n}\n"],"names":["sql","createMigrationTable","adapter","prependSchema","schemaName","drizzle","execute","raw"],"mappings":"AAAA,SAASA,GAAG,QAAQ,cAAa;AAIjC,OAAO,MAAMC,uBAAuB,OAAOC;IACzC,MAAMC,gBAAgBD,QAAQE,UAAU,GAAG,CAAC,CAAC,EAAEF,QAAQE,UAAU,CAAC,EAAE,CAAC,GAAG;IAExE,MAAMF,QAAQG,OAAO,CAACC,OAAO,CAC3BN,IAAIO,GAAG,CAAC,CAAC,2BAA2B,EAAEJ,cAAc;;;;;;EAMtD,CAAC;AAEH,EAAC"}
@@ -16,4 +16,4 @@ export const createPathMap = (rows)=>{
16
16
  return rowsByPath;
17
17
  };
18
18
 
19
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlsaXRpZXMvY3JlYXRlUmVsYXRpb25zaGlwTWFwLnRzIl0sInNvdXJjZXNDb250ZW50IjpbIi8vIEZsYXR0ZW4gcm93cyB0byBvYmplY3Qgd2l0aCBwYXRoIGtleXNcbi8vIGZvciBlYXNpZXIgcmV0cmlldmFsXG5leHBvcnQgY29uc3QgY3JlYXRlUGF0aE1hcCA9IChyb3dzOiB1bmtub3duKTogUmVjb3JkPHN0cmluZywgUmVjb3JkPHN0cmluZywgdW5rbm93bj5bXT4gPT4ge1xuICBsZXQgcm93c0J5UGF0aCA9IHt9XG5cbiAgaWYgKEFycmF5LmlzQXJyYXkocm93cykpIHtcbiAgICByb3dzQnlQYXRoID0gcm93cy5yZWR1Y2UoKHJlcywgcm93KSA9PiB7XG4gICAgICBjb25zdCBmb3JtYXR0ZWRSb3cgPSB7XG4gICAgICAgIC4uLnJvdyxcbiAgICAgIH1cblxuICAgICAgZGVsZXRlIGZvcm1hdHRlZFJvdy5wYXRoXG5cbiAgICAgIGlmICghcmVzW3Jvdy5wYXRoXSkgcmVzW3Jvdy5wYXRoXSA9IFtdXG4gICAgICByZXNbcm93LnBhdGhdLnB1c2gocm93KVxuXG4gICAgICByZXR1cm4gcmVzXG4gICAgfSwge30pXG4gIH1cblxuICByZXR1cm4gcm93c0J5UGF0aFxufVxuIl0sIm5hbWVzIjpbImNyZWF0ZVBhdGhNYXAiLCJyb3dzIiwicm93c0J5UGF0aCIsIkFycmF5IiwiaXNBcnJheSIsInJlZHVjZSIsInJlcyIsInJvdyIsImZvcm1hdHRlZFJvdyIsInBhdGgiLCJwdXNoIl0sIm1hcHBpbmdzIjoiQUFBQSx3Q0FBd0M7QUFDeEMsdUJBQXVCO0FBQ3ZCLE9BQU8sTUFBTUEsZ0JBQWdCLENBQUNDO0lBQzVCLElBQUlDLGFBQWEsQ0FBQztJQUVsQixJQUFJQyxNQUFNQyxPQUFPLENBQUNILE9BQU87UUFDdkJDLGFBQWFELEtBQUtJLE1BQU0sQ0FBQyxDQUFDQyxLQUFLQztZQUM3QixNQUFNQyxlQUFlO2dCQUNuQixHQUFHRCxHQUFHO1lBQ1I7WUFFQSxPQUFPQyxhQUFhQyxJQUFJO1lBRXhCLElBQUksQ0FBQ0gsR0FBRyxDQUFDQyxJQUFJRSxJQUFJLENBQUMsRUFBRUgsR0FBRyxDQUFDQyxJQUFJRSxJQUFJLENBQUMsR0FBRyxFQUFFO1lBQ3RDSCxHQUFHLENBQUNDLElBQUlFLElBQUksQ0FBQyxDQUFDQyxJQUFJLENBQUNIO1lBRW5CLE9BQU9EO1FBQ1QsR0FBRyxDQUFDO0lBQ047SUFFQSxPQUFPSjtBQUNULEVBQUMifQ==
19
+ //# sourceMappingURL=createRelationshipMap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/createRelationshipMap.ts"],"sourcesContent":["// Flatten rows to object with path keys\n// for easier retrieval\nexport const createPathMap = (rows: unknown): Record<string, Record<string, unknown>[]> => {\n let rowsByPath = {}\n\n if (Array.isArray(rows)) {\n rowsByPath = rows.reduce((res, row) => {\n const formattedRow = {\n ...row,\n }\n\n delete formattedRow.path\n\n if (!res[row.path]) res[row.path] = []\n res[row.path].push(row)\n\n return res\n }, {})\n }\n\n return rowsByPath\n}\n"],"names":["createPathMap","rows","rowsByPath","Array","isArray","reduce","res","row","formattedRow","path","push"],"mappings":"AAAA,wCAAwC;AACxC,uBAAuB;AACvB,OAAO,MAAMA,gBAAgB,CAACC;IAC5B,IAAIC,aAAa,CAAC;IAElB,IAAIC,MAAMC,OAAO,CAACH,OAAO;QACvBC,aAAaD,KAAKI,MAAM,CAAC,CAACC,KAAKC;YAC7B,MAAMC,eAAe;gBACnB,GAAGD,GAAG;YACR;YAEA,OAAOC,aAAaC,IAAI;YAExB,IAAI,CAACH,GAAG,CAACC,IAAIE,IAAI,CAAC,EAAEH,GAAG,CAACC,IAAIE,IAAI,CAAC,GAAG,EAAE;YACtCH,GAAG,CAACC,IAAIE,IAAI,CAAC,CAACC,IAAI,CAACH;YAEnB,OAAOD;QACT,GAAG,CAAC;IACN;IAEA,OAAOJ;AACT,EAAC"}
@@ -8,4 +8,4 @@ export const hasLocalesTable = (fields)=>{
8
8
  });
9
9
  };
10
10
 
11
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlsaXRpZXMvaGFzTG9jYWxlc1RhYmxlLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB0eXBlIHsgRmllbGQgfSBmcm9tICdwYXlsb2FkL3R5cGVzJ1xuXG5pbXBvcnQgeyBmaWVsZEFmZmVjdHNEYXRhLCBmaWVsZEhhc1N1YkZpZWxkcyB9IGZyb20gJ3BheWxvYWQvdHlwZXMnXG5cbmV4cG9ydCBjb25zdCBoYXNMb2NhbGVzVGFibGUgPSAoZmllbGRzOiBGaWVsZFtdKTogYm9vbGVhbiA9PiB7XG4gIHJldHVybiBmaWVsZHMuc29tZSgoZmllbGQpID0+IHtcbiAgICBpZiAoZmllbGRBZmZlY3RzRGF0YShmaWVsZCkgJiYgZmllbGQubG9jYWxpemVkKSByZXR1cm4gdHJ1ZVxuICAgIGlmIChmaWVsZEhhc1N1YkZpZWxkcyhmaWVsZCkgJiYgZmllbGQudHlwZSAhPT0gJ2FycmF5JykgcmV0dXJuIGhhc0xvY2FsZXNUYWJsZShmaWVsZC5maWVsZHMpXG4gICAgaWYgKGZpZWxkLnR5cGUgPT09ICd0YWJzJykgcmV0dXJuIGZpZWxkLnRhYnMuc29tZSgodGFiKSA9PiBoYXNMb2NhbGVzVGFibGUodGFiLmZpZWxkcykpXG4gICAgcmV0dXJuIGZhbHNlXG4gIH0pXG59XG4iXSwibmFtZXMiOlsiZmllbGRBZmZlY3RzRGF0YSIsImZpZWxkSGFzU3ViRmllbGRzIiwiaGFzTG9jYWxlc1RhYmxlIiwiZmllbGRzIiwic29tZSIsImZpZWxkIiwibG9jYWxpemVkIiwidHlwZSIsInRhYnMiLCJ0YWIiXSwibWFwcGluZ3MiOiJBQUVBLFNBQVNBLGdCQUFnQixFQUFFQyxpQkFBaUIsUUFBUSxnQkFBZTtBQUVuRSxPQUFPLE1BQU1DLGtCQUFrQixDQUFDQztJQUM5QixPQUFPQSxPQUFPQyxJQUFJLENBQUMsQ0FBQ0M7UUFDbEIsSUFBSUwsaUJBQWlCSyxVQUFVQSxNQUFNQyxTQUFTLEVBQUUsT0FBTztRQUN2RCxJQUFJTCxrQkFBa0JJLFVBQVVBLE1BQU1FLElBQUksS0FBSyxTQUFTLE9BQU9MLGdCQUFnQkcsTUFBTUYsTUFBTTtRQUMzRixJQUFJRSxNQUFNRSxJQUFJLEtBQUssUUFBUSxPQUFPRixNQUFNRyxJQUFJLENBQUNKLElBQUksQ0FBQyxDQUFDSyxNQUFRUCxnQkFBZ0JPLElBQUlOLE1BQU07UUFDckYsT0FBTztJQUNUO0FBQ0YsRUFBQyJ9
11
+ //# sourceMappingURL=hasLocalesTable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/hasLocalesTable.ts"],"sourcesContent":["import type { Field } from 'payload/types'\n\nimport { fieldAffectsData, fieldHasSubFields } from 'payload/types'\n\nexport const hasLocalesTable = (fields: Field[]): boolean => {\n return fields.some((field) => {\n if (fieldAffectsData(field) && field.localized) return true\n if (fieldHasSubFields(field) && field.type !== 'array') return hasLocalesTable(field.fields)\n if (field.type === 'tabs') return field.tabs.some((tab) => hasLocalesTable(tab.fields))\n return false\n })\n}\n"],"names":["fieldAffectsData","fieldHasSubFields","hasLocalesTable","fields","some","field","localized","type","tabs","tab"],"mappings":"AAEA,SAASA,gBAAgB,EAAEC,iBAAiB,QAAQ,gBAAe;AAEnE,OAAO,MAAMC,kBAAkB,CAACC;IAC9B,OAAOA,OAAOC,IAAI,CAAC,CAACC;QAClB,IAAIL,iBAAiBK,UAAUA,MAAMC,SAAS,EAAE,OAAO;QACvD,IAAIL,kBAAkBI,UAAUA,MAAME,IAAI,KAAK,SAAS,OAAOL,gBAAgBG,MAAMF,MAAM;QAC3F,IAAIE,MAAME,IAAI,KAAK,QAAQ,OAAOF,MAAMG,IAAI,CAACJ,IAAI,CAAC,CAACK,MAAQP,gBAAgBO,IAAIN,MAAM;QACrF,OAAO;IACT;AACF,EAAC"}
@@ -2,4 +2,4 @@ export function isArrayOfRows(data) {
2
2
  return Array.isArray(data);
3
3
  }
4
4
 
5
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlsaXRpZXMvaXNBcnJheU9mUm93cy50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgZnVuY3Rpb24gaXNBcnJheU9mUm93cyhkYXRhOiB1bmtub3duKTogZGF0YSBpcyBSZWNvcmQ8c3RyaW5nLCB1bmtub3duPltdIHtcbiAgcmV0dXJuIEFycmF5LmlzQXJyYXkoZGF0YSlcbn1cbiJdLCJuYW1lcyI6WyJpc0FycmF5T2ZSb3dzIiwiZGF0YSIsIkFycmF5IiwiaXNBcnJheSJdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxTQUFTQSxjQUFjQyxJQUFhO0lBQ3pDLE9BQU9DLE1BQU1DLE9BQU8sQ0FBQ0Y7QUFDdkIifQ==
5
+ //# sourceMappingURL=isArrayOfRows.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/isArrayOfRows.ts"],"sourcesContent":["export function isArrayOfRows(data: unknown): data is Record<string, unknown>[] {\n return Array.isArray(data)\n}\n"],"names":["isArrayOfRows","data","Array","isArray"],"mappings":"AAAA,OAAO,SAASA,cAAcC,IAAa;IACzC,OAAOC,MAAMC,OAAO,CAACF;AACvB"}
@@ -6,4 +6,4 @@ export const migrationTableExists = async (db)=>{
6
6
  return exists;
7
7
  };
8
8
 
9
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlsaXRpZXMvbWlncmF0aW9uVGFibGVFeGlzdHMudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgc3FsIH0gZnJvbSAnZHJpenpsZS1vcm0nXG5cbmltcG9ydCB0eXBlIHsgRHJpenpsZURCIH0gZnJvbSAnLi4vdHlwZXMuanMnXG5cbmV4cG9ydCBjb25zdCBtaWdyYXRpb25UYWJsZUV4aXN0cyA9IGFzeW5jIChkYjogRHJpenpsZURCKTogUHJvbWlzZTxib29sZWFuPiA9PiB7XG4gIGNvbnN0IHF1ZXJ5UmVzID0gYXdhaXQgZGIuZXhlY3V0ZShzcWxgU0VMRUNUIHRvX3JlZ2NsYXNzKCdwdWJsaWMucGF5bG9hZF9taWdyYXRpb25zJyk7YClcblxuICAvLyBSZXR1cm5zIHRhYmxlIG5hbWUgJ3BheWxvYWRfbWlncmF0aW9ucycgb3IgbnVsbFxuICBjb25zdCBleGlzdHMgPSBxdWVyeVJlcy5yb3dzPy5bMF0/LnRvX3JlZ2NsYXNzID09PSAncGF5bG9hZF9taWdyYXRpb25zJ1xuICByZXR1cm4gZXhpc3RzXG59XG4iXSwibmFtZXMiOlsic3FsIiwibWlncmF0aW9uVGFibGVFeGlzdHMiLCJkYiIsInF1ZXJ5UmVzIiwiZXhlY3V0ZSIsImV4aXN0cyIsInJvd3MiLCJ0b19yZWdjbGFzcyJdLCJtYXBwaW5ncyI6IkFBQUEsU0FBU0EsR0FBRyxRQUFRLGNBQWE7QUFJakMsT0FBTyxNQUFNQyx1QkFBdUIsT0FBT0M7SUFDekMsTUFBTUMsV0FBVyxNQUFNRCxHQUFHRSxPQUFPLENBQUNKLEdBQUcsQ0FBQyxnREFBZ0QsQ0FBQztJQUV2RixrREFBa0Q7SUFDbEQsTUFBTUssU0FBU0YsU0FBU0csSUFBSSxFQUFFLENBQUMsRUFBRSxFQUFFQyxnQkFBZ0I7SUFDbkQsT0FBT0Y7QUFDVCxFQUFDIn0=
9
+ //# sourceMappingURL=migrationTableExists.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/migrationTableExists.ts"],"sourcesContent":["import { sql } from 'drizzle-orm'\n\nimport type { DrizzleDB } from '../types.js'\n\nexport const migrationTableExists = async (db: DrizzleDB): Promise<boolean> => {\n const queryRes = await db.execute(sql`SELECT to_regclass('public.payload_migrations');`)\n\n // Returns table name 'payload_migrations' or null\n const exists = queryRes.rows?.[0]?.to_regclass === 'payload_migrations'\n return exists\n}\n"],"names":["sql","migrationTableExists","db","queryRes","execute","exists","rows","to_regclass"],"mappings":"AAAA,SAASA,GAAG,QAAQ,cAAa;AAIjC,OAAO,MAAMC,uBAAuB,OAAOC;IACzC,MAAMC,WAAW,MAAMD,GAAGE,OAAO,CAACJ,GAAG,CAAC,gDAAgD,CAAC;IAEvF,kDAAkD;IAClD,MAAMK,SAASF,SAASG,IAAI,EAAE,CAAC,EAAE,EAAEC,gBAAgB;IACnD,OAAOF;AACT,EAAC"}
@@ -14,4 +14,4 @@ const { DatabaseError } = pg;
14
14
  return formattedMsg;
15
15
  };
16
16
 
17
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlsaXRpZXMvcGFyc2VFcnJvci50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgcGcgZnJvbSAncGcnXG5jb25zdCB7IERhdGFiYXNlRXJyb3IgfSA9IHBnXG5cbi8qKlxuICogR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FBRUosT0FBTyxDQUFDLENBQUMsRUFBRUQsSUFBSUssSUFBSSxDQUFDLENBQUMsQ0FBQztRQUN0QztJQUNGO0lBQ0EsT0FBT0g7QUFDVCxFQUFDIn0=
17
+ //# sourceMappingURL=parseError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/parseError.ts"],"sourcesContent":["import pg from 'pg'\nconst { DatabaseError } = pg\n\n/**\n * Format error message with hint if available\n */\nexport const parseError = (err: unknown, msg: string): string => {\n let formattedMsg = `${msg}`\n if (err instanceof Error) {\n formattedMsg += ` ${err.message}.`\n if (err instanceof DatabaseError) {\n msg += `: ${err.message}`\n if (err.hint) msg += ` ${err.hint}.`\n }\n }\n return formattedMsg\n}\n"],"names":["pg","DatabaseError","parseError","err","msg","formattedMsg","Error","message","hint"],"mappings":"AAAA,OAAOA,QAAQ,KAAI;AACnB,MAAM,EAAEC,aAAa,EAAE,GAAGD;AAE1B;;CAEC,GACD,OAAO,MAAME,aAAa,CAACC,KAAcC;IACvC,IAAIC,eAAe,CAAC,EAAED,IAAI,CAAC;IAC3B,IAAID,eAAeG,OAAO;QACxBD,gBAAgB,CAAC,CAAC,EAAEF,IAAII,OAAO,CAAC,CAAC,CAAC;QAClC,IAAIJ,eAAeF,eAAe;YAChCG,OAAO,CAAC,EAAE,EAAED,IAAII,OAAO,CAAC,CAAC;YACzB,IAAIJ,IAAIK,IAAI,EAAEJ,OAAO,CAAC,CAAC,EAAED,IAAIK,IAAI,CAAC,CAAC,CAAC;QACtC;IACF;IACA,OAAOH;AACT,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"pushDevSchema.d.ts","sourceRoot":"","sources":["../../src/utilities/pushDevSchema.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAIlD;;;;;GAKG;AACH,eAAO,MAAM,aAAa,OAAc,eAAe,kBAiEtD,CAAA"}
1
+ {"version":3,"file":"pushDevSchema.d.ts","sourceRoot":"","sources":["../../src/utilities/pushDevSchema.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAMlD;;;;;GAKG;AACH,eAAO,MAAM,aAAa,OAAc,eAAe,kBAiEtD,CAAA"}