@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
@@ -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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlsaXRpZXMvcGFyc2VFcnJvci50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgcGcgZnJvbSAncGcnXG5jb25zdCB7IERhdGFiYXNlRXJyb3IgfSA9IHBnXG5cbi8qKlxuICogRm9ybWF0IGVycm9yIG1lc3NhZ2Ugd2l0aCBoaW50IGlmIGF2YWlsYWJsZVxuICovXG5leHBvcnQgY29uc3QgcGFyc2VFcnJvciA9IChlcnI6IHVua25vd24sIG1zZzogc3RyaW5nKTogc3RyaW5nID0+IHtcbiAgbGV0IGZvcm1hdHRlZE1zZyA9IGAke21zZ31gXG4gIGlmIChlcnIgaW5zdGFuY2VvZiBFcnJvcikge1xuICAgIGZvcm1hdHRlZE1zZyArPSBgICR7ZXJyLm1lc3NhZ2V9LmBcbiAgICBpZiAoZXJyIGluc3RhbmNlb2YgRGF0YWJhc2VFcnJvcikge1xuICAgICAgbXNnICs9IGA6ICR7ZXJyLm1lc3NhZ2V9YFxuICAgICAgaWYgKGVyci5oaW50KSBtc2cgKz0gYCAke2Vyci5oaW50fS5gXG4gICAgfVxuICB9XG4gIHJldHVybiBmb3JtYXR0ZWRNc2dcbn1cbiJdLCJuYW1lcyI6WyJwZyIsIkRhdGFiYXNlRXJyb3IiLCJwYXJzZUVycm9yIiwiZXJyIiwibXNnIiwiZm9ybWF0dGVkTXNnIiwiRXJyb3IiLCJtZXNzYWdlIiwiaGludCJdLCJtYXBwaW5ncyI6IkFBQUEsT0FBT0EsUUFBUSxLQUFJO0FBQ25CLE1BQU0sRUFBRUMsYUFBYSxFQUFFLEdBQUdEO0FBRTFCOztDQUVDLEdBQ0QsT0FBTyxNQUFNRSxhQUFhLENBQUNDLEtBQWNDO0lBQ3ZDLElBQUlDLGVBQWUsQ0FBQyxFQUFFRCxJQUFJLENBQUM7SUFDM0IsSUFBSUQsZUFBZUcsT0FBTztRQUN4QkQsZ0JBQWdCLENBQUMsQ0FBQyxFQUFFRixJQUFJSSxPQUFPLENBQUMsQ0FBQyxDQUFDO1FBQ2xDLElBQUlKLGVBQWVGLGVBQWU7WUFDaENHLE9BQU8sQ0FBQyxFQUFFLEVBQUVELElBQUlJLE9BQU8sQ0FBQyxDQUFDO1lBQ3pCLElBQUlKLElBQUlLLElBQUksRUFBRUosT0FBTyxDQUFDLENBQUMsRUFBRUQsSUFBSUssSUFBSSxDQUFDLENBQUMsQ0FBQztRQUN0QztJQUNGO0lBQ0EsT0FBT0g7QUFDVCxFQUFDIn0=
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"}
@@ -0,0 +1,9 @@
1
+ import type { PostgresAdapter } from '../types.js';
2
+ /**
3
+ * Pushes the development schema to the database using Drizzle.
4
+ *
5
+ * @param {PostgresAdapter} db - The PostgresAdapter instance connected to the database.
6
+ * @returns {Promise<void>} - A promise that resolves once the schema push is complete.
7
+ */
8
+ export declare const pushDevSchema: (db: PostgresAdapter) => Promise<void>;
9
+ //# sourceMappingURL=pushDevSchema.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,56 @@
1
+ import { eq } from 'drizzle-orm';
2
+ import { numeric, timestamp, varchar } from 'drizzle-orm/pg-core';
3
+ import prompts from 'prompts';
4
+ const { pushSchema } = await import('drizzle-kit/payload');
5
+ /**
6
+ * Pushes the development schema to the database using Drizzle.
7
+ *
8
+ * @param {PostgresAdapter} db - The PostgresAdapter instance connected to the database.
9
+ * @returns {Promise<void>} - A promise that resolves once the schema push is complete.
10
+ */ export const pushDevSchema = async (db)=>{
11
+ // This will prompt if clarifications are needed for Drizzle to push new schema
12
+ const { apply, hasDataLoss, statementsToExecute, warnings } = await pushSchema(db.schema, db.drizzle);
13
+ if (warnings.length) {
14
+ let message = `Warnings detected during schema push: \n\n${warnings.join('\n')}\n\n`;
15
+ if (hasDataLoss) {
16
+ message += `DATA LOSS WARNING: Possible data loss detected if schema is pushed.\n\n`;
17
+ }
18
+ message += `Accept warnings and push schema to database?`;
19
+ const { confirm: acceptWarnings } = await prompts({
20
+ name: 'confirm',
21
+ type: 'confirm',
22
+ initial: false,
23
+ message
24
+ }, {
25
+ onCancel: ()=>{
26
+ process.exit(0);
27
+ }
28
+ });
29
+ // Exit if user does not accept warnings.
30
+ // Q: Is this the right type of exit for this interaction?
31
+ if (!acceptWarnings) {
32
+ process.exit(0);
33
+ }
34
+ }
35
+ await apply();
36
+ // Migration table def in order to use query using drizzle
37
+ const migrationsSchema = db.pgSchema.table('payload_migrations', {
38
+ name: varchar('name'),
39
+ batch: numeric('batch'),
40
+ created_at: timestamp('created_at'),
41
+ updated_at: timestamp('updated_at')
42
+ });
43
+ const devPush = await db.drizzle.select().from(migrationsSchema).where(eq(migrationsSchema.batch, '-1'));
44
+ if (!devPush.length) {
45
+ await db.drizzle.insert(migrationsSchema).values({
46
+ name: 'dev',
47
+ batch: '-1'
48
+ });
49
+ } else {
50
+ await db.drizzle.update(migrationsSchema).set({
51
+ updated_at: new Date()
52
+ }).where(eq(migrationsSchema.batch, '-1'));
53
+ }
54
+ };
55
+
56
+ //# sourceMappingURL=pushDevSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/pushDevSchema.ts"],"sourcesContent":["import { eq } from 'drizzle-orm'\nimport { numeric, timestamp, varchar } from 'drizzle-orm/pg-core'\nimport prompts from 'prompts'\n\nimport type { PostgresAdapter } from '../types.js'\n\nconst { pushSchema } = await import('drizzle-kit/payload')\n\n/**\n * Pushes the development schema to the database using Drizzle.\n *\n * @param {PostgresAdapter} db - The PostgresAdapter instance connected to the database.\n * @returns {Promise<void>} - A promise that resolves once the schema push is complete.\n */\nexport const pushDevSchema = async (db: PostgresAdapter) => {\n // This will prompt if clarifications are needed for Drizzle to push new schema\n const { apply, hasDataLoss, statementsToExecute, warnings } = await pushSchema(\n db.schema,\n db.drizzle,\n )\n\n if (warnings.length) {\n let message = `Warnings detected during schema push: \\n\\n${warnings.join('\\n')}\\n\\n`\n\n if (hasDataLoss) {\n message += `DATA LOSS WARNING: Possible data loss detected if schema is pushed.\\n\\n`\n }\n\n message += `Accept warnings and push schema to database?`\n\n const { confirm: acceptWarnings } = await prompts(\n {\n name: 'confirm',\n type: 'confirm',\n initial: false,\n message,\n },\n {\n onCancel: () => {\n process.exit(0)\n },\n },\n )\n\n // Exit if user does not accept warnings.\n // Q: Is this the right type of exit for this interaction?\n if (!acceptWarnings) {\n process.exit(0)\n }\n }\n\n await apply()\n\n // Migration table def in order to use query using drizzle\n const migrationsSchema = db.pgSchema.table('payload_migrations', {\n name: varchar('name'),\n batch: numeric('batch'),\n created_at: timestamp('created_at'),\n updated_at: timestamp('updated_at'),\n })\n\n const devPush = await db.drizzle\n .select()\n .from(migrationsSchema)\n .where(eq(migrationsSchema.batch, '-1'))\n\n if (!devPush.length) {\n await db.drizzle.insert(migrationsSchema).values({\n name: 'dev',\n batch: '-1',\n })\n } else {\n await db.drizzle\n .update(migrationsSchema)\n .set({\n updated_at: new Date(),\n })\n .where(eq(migrationsSchema.batch, '-1'))\n }\n}\n"],"names":["eq","numeric","timestamp","varchar","prompts","pushSchema","pushDevSchema","db","apply","hasDataLoss","statementsToExecute","warnings","schema","drizzle","length","message","join","confirm","acceptWarnings","name","type","initial","onCancel","process","exit","migrationsSchema","pgSchema","table","batch","created_at","updated_at","devPush","select","from","where","insert","values","update","set","Date"],"mappings":"AAAA,SAASA,EAAE,QAAQ,cAAa;AAChC,SAASC,OAAO,EAAEC,SAAS,EAAEC,OAAO,QAAQ,sBAAqB;AACjE,OAAOC,aAAa,UAAS;AAI7B,MAAM,EAAEC,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC;AAEpC;;;;;CAKC,GACD,OAAO,MAAMC,gBAAgB,OAAOC;IAClC,+EAA+E;IAC/E,MAAM,EAAEC,KAAK,EAAEC,WAAW,EAAEC,mBAAmB,EAAEC,QAAQ,EAAE,GAAG,MAAMN,WAClEE,GAAGK,MAAM,EACTL,GAAGM,OAAO;IAGZ,IAAIF,SAASG,MAAM,EAAE;QACnB,IAAIC,UAAU,CAAC,0CAA0C,EAAEJ,SAASK,IAAI,CAAC,MAAM,IAAI,CAAC;QAEpF,IAAIP,aAAa;YACfM,WAAW,CAAC,uEAAuE,CAAC;QACtF;QAEAA,WAAW,CAAC,4CAA4C,CAAC;QAEzD,MAAM,EAAEE,SAASC,cAAc,EAAE,GAAG,MAAMd,QACxC;YACEe,MAAM;YACNC,MAAM;YACNC,SAAS;YACTN;QACF,GACA;YACEO,UAAU;gBACRC,QAAQC,IAAI,CAAC;YACf;QACF;QAGF,yCAAyC;QACzC,0DAA0D;QAC1D,IAAI,CAACN,gBAAgB;YACnBK,QAAQC,IAAI,CAAC;QACf;IACF;IAEA,MAAMhB;IAEN,0DAA0D;IAC1D,MAAMiB,mBAAmBlB,GAAGmB,QAAQ,CAACC,KAAK,CAAC,sBAAsB;QAC/DR,MAAMhB,QAAQ;QACdyB,OAAO3B,QAAQ;QACf4B,YAAY3B,UAAU;QACtB4B,YAAY5B,UAAU;IACxB;IAEA,MAAM6B,UAAU,MAAMxB,GAAGM,OAAO,CAC7BmB,MAAM,GACNC,IAAI,CAACR,kBACLS,KAAK,CAAClC,GAAGyB,iBAAiBG,KAAK,EAAE;IAEpC,IAAI,CAACG,QAAQjB,MAAM,EAAE;QACnB,MAAMP,GAAGM,OAAO,CAACsB,MAAM,CAACV,kBAAkBW,MAAM,CAAC;YAC/CjB,MAAM;YACNS,OAAO;QACT;IACF,OAAO;QACL,MAAMrB,GAAGM,OAAO,CACbwB,MAAM,CAACZ,kBACPa,GAAG,CAAC;YACHR,YAAY,IAAIS;QAClB,GACCL,KAAK,CAAClC,GAAGyB,iBAAiBG,KAAK,EAAE;IACtC;AACF,EAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/db-postgres",
3
- "version": "3.0.0-alpha.40",
3
+ "version": "3.0.0-alpha.42",
4
4
  "description": "The officially supported Postgres database adapter for Payload",
5
5
  "repository": "https://github.com/payloadcms/payload",
6
6
  "license": "MIT",
@@ -27,10 +27,10 @@
27
27
  "@types/pg": "8.10.2",
28
28
  "@types/to-snake-case": "1.0.0",
29
29
  "@payloadcms/eslint-config": "1.1.1",
30
- "payload": "3.0.0-alpha.40"
30
+ "payload": "3.0.0-alpha.42"
31
31
  },
32
32
  "peerDependencies": {
33
- "payload": "3.0.0-alpha.40"
33
+ "payload": "3.0.0-alpha.42"
34
34
  },
35
35
  "publishConfig": {
36
36
  "registry": "https://registry.npmjs.org/"