@payloadcms/db-mongodb 3.0.0-canary.f6e77b8 → 3.0.0-canary.fb04843

Sign up to get free protection for your applications and to get access to all the features.
Files changed (220) hide show
  1. package/README.md +1 -1
  2. package/dist/connect.d.ts +1 -1
  3. package/dist/connect.d.ts.map +1 -1
  4. package/dist/connect.js +18 -4
  5. package/dist/connect.js.map +1 -1
  6. package/dist/count.d.ts +1 -1
  7. package/dist/count.d.ts.map +1 -1
  8. package/dist/count.js +10 -3
  9. package/dist/count.js.map +1 -1
  10. package/dist/countGlobalVersions.d.ts +3 -0
  11. package/dist/countGlobalVersions.d.ts.map +1 -0
  12. package/dist/countGlobalVersions.js +40 -0
  13. package/dist/countGlobalVersions.js.map +1 -0
  14. package/dist/countVersions.d.ts +3 -0
  15. package/dist/countVersions.d.ts.map +1 -0
  16. package/dist/countVersions.js +40 -0
  17. package/dist/countVersions.js.map +1 -0
  18. package/dist/create.d.ts +1 -1
  19. package/dist/create.d.ts.map +1 -1
  20. package/dist/create.js +17 -4
  21. package/dist/create.js.map +1 -1
  22. package/dist/createGlobal.d.ts +1 -1
  23. package/dist/createGlobal.d.ts.map +1 -1
  24. package/dist/createGlobal.js +11 -6
  25. package/dist/createGlobal.js.map +1 -1
  26. package/dist/createGlobalVersion.d.ts +1 -1
  27. package/dist/createGlobalVersion.d.ts.map +1 -1
  28. package/dist/createGlobalVersion.js +14 -5
  29. package/dist/createGlobalVersion.js.map +1 -1
  30. package/dist/createMigration.d.ts +1 -1
  31. package/dist/createMigration.d.ts.map +1 -1
  32. package/dist/createMigration.js +20 -32
  33. package/dist/createMigration.js.map +1 -1
  34. package/dist/createVersion.d.ts +1 -1
  35. package/dist/createVersion.d.ts.map +1 -1
  36. package/dist/createVersion.js +32 -10
  37. package/dist/createVersion.js.map +1 -1
  38. package/dist/deleteMany.d.ts +1 -1
  39. package/dist/deleteMany.d.ts.map +1 -1
  40. package/dist/deleteMany.js +1 -1
  41. package/dist/deleteMany.js.map +1 -1
  42. package/dist/deleteOne.d.ts +1 -1
  43. package/dist/deleteOne.d.ts.map +1 -1
  44. package/dist/deleteOne.js +12 -4
  45. package/dist/deleteOne.js.map +1 -1
  46. package/dist/deleteVersions.d.ts +1 -1
  47. package/dist/deleteVersions.d.ts.map +1 -1
  48. package/dist/deleteVersions.js +1 -1
  49. package/dist/deleteVersions.js.map +1 -1
  50. package/dist/destroy.d.ts +1 -1
  51. package/dist/destroy.d.ts.map +1 -1
  52. package/dist/destroy.js.map +1 -1
  53. package/dist/exports/migration-utils.d.ts +3 -0
  54. package/dist/exports/migration-utils.d.ts.map +1 -0
  55. package/dist/exports/migration-utils.js +4 -0
  56. package/dist/exports/migration-utils.js.map +1 -0
  57. package/dist/find.d.ts +1 -1
  58. package/dist/find.d.ts.map +1 -1
  59. package/dist/find.js +36 -7
  60. package/dist/find.js.map +1 -1
  61. package/dist/findGlobal.d.ts +1 -1
  62. package/dist/findGlobal.d.ts.map +1 -1
  63. package/dist/findGlobal.js +11 -5
  64. package/dist/findGlobal.js.map +1 -1
  65. package/dist/findGlobalVersions.d.ts +1 -1
  66. package/dist/findGlobalVersions.d.ts.map +1 -1
  67. package/dist/findGlobalVersions.js +19 -9
  68. package/dist/findGlobalVersions.js.map +1 -1
  69. package/dist/findOne.d.ts +1 -1
  70. package/dist/findOne.d.ts.map +1 -1
  71. package/dist/findOne.js +28 -4
  72. package/dist/findOne.js.map +1 -1
  73. package/dist/findVersions.d.ts +1 -1
  74. package/dist/findVersions.d.ts.map +1 -1
  75. package/dist/findVersions.js +17 -6
  76. package/dist/findVersions.js.map +1 -1
  77. package/dist/index.d.ts +59 -35
  78. package/dist/index.d.ts.map +1 -1
  79. package/dist/index.js +18 -7
  80. package/dist/index.js.map +1 -1
  81. package/dist/init.d.ts +1 -1
  82. package/dist/init.d.ts.map +1 -1
  83. package/dist/init.js +19 -17
  84. package/dist/init.js.map +1 -1
  85. package/dist/migrateFresh.d.ts.map +1 -1
  86. package/dist/migrateFresh.js +1 -1
  87. package/dist/migrateFresh.js.map +1 -1
  88. package/dist/models/buildCollectionSchema.d.ts +2 -29
  89. package/dist/models/buildCollectionSchema.d.ts.map +1 -1
  90. package/dist/models/buildCollectionSchema.js +16 -4
  91. package/dist/models/buildCollectionSchema.js.map +1 -1
  92. package/dist/models/buildGlobalModel.d.ts +1 -1
  93. package/dist/models/buildGlobalModel.d.ts.map +1 -1
  94. package/dist/models/buildGlobalModel.js +2 -2
  95. package/dist/models/buildGlobalModel.js.map +1 -1
  96. package/dist/models/buildSchema.d.ts +2 -29
  97. package/dist/models/buildSchema.d.ts.map +1 -1
  98. package/dist/models/buildSchema.js +116 -23
  99. package/dist/models/buildSchema.js.map +1 -1
  100. package/dist/predefinedMigrations/migrateRelationshipsV2_V3.d.ts +6 -0
  101. package/dist/predefinedMigrations/migrateRelationshipsV2_V3.d.ts.map +1 -0
  102. package/dist/predefinedMigrations/migrateRelationshipsV2_V3.js +141 -0
  103. package/dist/predefinedMigrations/migrateRelationshipsV2_V3.js.map +1 -0
  104. package/dist/predefinedMigrations/migrateVersionsV1_V2.d.ts +5 -0
  105. package/dist/predefinedMigrations/migrateVersionsV1_V2.d.ts.map +1 -0
  106. package/dist/predefinedMigrations/migrateVersionsV1_V2.js +107 -0
  107. package/dist/predefinedMigrations/migrateVersionsV1_V2.js.map +1 -0
  108. package/dist/predefinedMigrations/relationships-v2-v3.d.ts +4 -0
  109. package/dist/predefinedMigrations/relationships-v2-v3.d.ts.map +1 -0
  110. package/dist/predefinedMigrations/relationships-v2-v3.js +9 -0
  111. package/dist/predefinedMigrations/relationships-v2-v3.js.map +1 -0
  112. package/dist/predefinedMigrations/versions-v1-v2.d.ts +4 -0
  113. package/dist/predefinedMigrations/versions-v1-v2.d.ts.map +1 -0
  114. package/dist/predefinedMigrations/versions-v1-v2.js +8 -0
  115. package/dist/predefinedMigrations/versions-v1-v2.js.map +1 -0
  116. package/dist/queries/buildAndOrConditions.d.ts +1 -2
  117. package/dist/queries/buildAndOrConditions.d.ts.map +1 -1
  118. package/dist/queries/buildAndOrConditions.js +0 -2
  119. package/dist/queries/buildAndOrConditions.js.map +1 -1
  120. package/dist/queries/buildQuery.d.ts +3 -4
  121. package/dist/queries/buildQuery.d.ts.map +1 -1
  122. package/dist/queries/buildQuery.js +2 -3
  123. package/dist/queries/buildQuery.js.map +1 -1
  124. package/dist/queries/buildSearchParams.d.ts +1 -2
  125. package/dist/queries/buildSearchParams.d.ts.map +1 -1
  126. package/dist/queries/buildSearchParams.js +34 -22
  127. package/dist/queries/buildSearchParams.js.map +1 -1
  128. package/dist/queries/buildSortParam.d.ts +3 -29
  129. package/dist/queries/buildSortParam.d.ts.map +1 -1
  130. package/dist/queries/buildSortParam.js +26 -17
  131. package/dist/queries/buildSortParam.js.map +1 -1
  132. package/dist/queries/getLocalizedSortProperty.d.ts +1 -2
  133. package/dist/queries/getLocalizedSortProperty.d.ts.map +1 -1
  134. package/dist/queries/getLocalizedSortProperty.js +2 -2
  135. package/dist/queries/getLocalizedSortProperty.js.map +1 -1
  136. package/dist/queries/getLocalizedSortProperty.spec.js +44 -44
  137. package/dist/queries/getLocalizedSortProperty.spec.js.map +1 -1
  138. package/dist/queries/mock.js.map +1 -1
  139. package/dist/queries/operatorMap.js.map +1 -1
  140. package/dist/queries/parseParams.d.ts +1 -3
  141. package/dist/queries/parseParams.d.ts.map +1 -1
  142. package/dist/queries/parseParams.js +8 -6
  143. package/dist/queries/parseParams.js.map +1 -1
  144. package/dist/queries/sanitizeQueryValue.d.ts +1 -1
  145. package/dist/queries/sanitizeQueryValue.d.ts.map +1 -1
  146. package/dist/queries/sanitizeQueryValue.js +145 -28
  147. package/dist/queries/sanitizeQueryValue.js.map +1 -1
  148. package/dist/queryDrafts.d.ts +1 -1
  149. package/dist/queryDrafts.d.ts.map +1 -1
  150. package/dist/queryDrafts.js +37 -10
  151. package/dist/queryDrafts.js.map +1 -1
  152. package/dist/testCredentials.js.map +1 -1
  153. package/dist/transactions/beginTransaction.d.ts +1 -1
  154. package/dist/transactions/beginTransaction.d.ts.map +1 -1
  155. package/dist/transactions/beginTransaction.js +3 -1
  156. package/dist/transactions/beginTransaction.js.map +1 -1
  157. package/dist/transactions/commitTransaction.d.ts +1 -1
  158. package/dist/transactions/commitTransaction.d.ts.map +1 -1
  159. package/dist/transactions/commitTransaction.js +3 -0
  160. package/dist/transactions/commitTransaction.js.map +1 -1
  161. package/dist/transactions/rollbackTransaction.d.ts +1 -1
  162. package/dist/transactions/rollbackTransaction.d.ts.map +1 -1
  163. package/dist/transactions/rollbackTransaction.js +13 -7
  164. package/dist/transactions/rollbackTransaction.js.map +1 -1
  165. package/dist/types.d.ts +7 -31
  166. package/dist/types.d.ts.map +1 -1
  167. package/dist/types.js.map +1 -1
  168. package/dist/updateGlobal.d.ts +1 -1
  169. package/dist/updateGlobal.d.ts.map +1 -1
  170. package/dist/updateGlobal.js +18 -5
  171. package/dist/updateGlobal.js.map +1 -1
  172. package/dist/updateGlobalVersion.d.ts +2 -3
  173. package/dist/updateGlobalVersion.d.ts.map +1 -1
  174. package/dist/updateGlobalVersion.js +19 -5
  175. package/dist/updateGlobalVersion.js.map +1 -1
  176. package/dist/updateOne.d.ts +1 -1
  177. package/dist/updateOne.d.ts.map +1 -1
  178. package/dist/updateOne.js +25 -7
  179. package/dist/updateOne.js.map +1 -1
  180. package/dist/updateVersion.d.ts +1 -1
  181. package/dist/updateVersion.d.ts.map +1 -1
  182. package/dist/updateVersion.js +18 -4
  183. package/dist/updateVersion.js.map +1 -1
  184. package/dist/upsert.d.ts +3 -0
  185. package/dist/upsert.d.ts.map +1 -0
  186. package/dist/upsert.js +15 -0
  187. package/dist/upsert.js.map +1 -0
  188. package/dist/utilities/buildJoinAggregation.d.ts +18 -0
  189. package/dist/utilities/buildJoinAggregation.d.ts.map +1 -0
  190. package/dist/utilities/buildJoinAggregation.js +159 -0
  191. package/dist/utilities/buildJoinAggregation.js.map +1 -0
  192. package/dist/utilities/buildProjectionFromSelect.d.ts +8 -0
  193. package/dist/utilities/buildProjectionFromSelect.d.ts.map +1 -0
  194. package/dist/utilities/buildProjectionFromSelect.js +171 -0
  195. package/dist/utilities/buildProjectionFromSelect.js.map +1 -0
  196. package/dist/utilities/getDBName.d.ts +1 -1
  197. package/dist/utilities/getDBName.d.ts.map +1 -1
  198. package/dist/utilities/getDBName.js +3 -1
  199. package/dist/utilities/getDBName.js.map +1 -1
  200. package/dist/utilities/handleError.d.ts +6 -2
  201. package/dist/utilities/handleError.d.ts.map +1 -1
  202. package/dist/utilities/handleError.js +12 -9
  203. package/dist/utilities/handleError.js.map +1 -1
  204. package/dist/utilities/sanitizeInternalFields.d.ts +1 -2
  205. package/dist/utilities/sanitizeInternalFields.d.ts.map +1 -1
  206. package/dist/utilities/sanitizeInternalFields.js +1 -2
  207. package/dist/utilities/sanitizeInternalFields.js.map +1 -1
  208. package/dist/utilities/sanitizeRelationshipIDs.d.ts +9 -0
  209. package/dist/utilities/sanitizeRelationshipIDs.d.ts.map +1 -0
  210. package/dist/utilities/sanitizeRelationshipIDs.js +115 -0
  211. package/dist/utilities/sanitizeRelationshipIDs.js.map +1 -0
  212. package/dist/utilities/sanitizeRelationshipIDs.spec.js +383 -0
  213. package/dist/utilities/sanitizeRelationshipIDs.spec.js.map +1 -0
  214. package/dist/withSession.d.ts +3 -27
  215. package/dist/withSession.d.ts.map +1 -1
  216. package/dist/withSession.js +10 -4
  217. package/dist/withSession.js.map +1 -1
  218. package/license.md +22 -0
  219. package/package.json +29 -17
  220. package/predefinedMigrations/versions-v1-v2.js +0 -96
@@ -0,0 +1,141 @@
1
+ import { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload';
2
+ import { sanitizeRelationshipIDs } from '../utilities/sanitizeRelationshipIDs.js';
3
+ import { withSession } from '../withSession.js';
4
+ const migrateModelWithBatching = async ({ batchSize, config, fields, Model, session })=>{
5
+ let hasNext = true;
6
+ let skip = 0;
7
+ while(hasNext){
8
+ const docs = await Model.find({}, {}, {
9
+ lean: true,
10
+ limit: batchSize + 1,
11
+ session,
12
+ skip
13
+ });
14
+ if (docs.length === 0) {
15
+ break;
16
+ }
17
+ hasNext = docs.length > batchSize;
18
+ if (hasNext) {
19
+ docs.pop();
20
+ }
21
+ for (const doc of docs){
22
+ sanitizeRelationshipIDs({
23
+ config,
24
+ data: doc,
25
+ fields
26
+ });
27
+ }
28
+ await Model.collection.bulkWrite(docs.map((doc)=>({
29
+ updateOne: {
30
+ filter: {
31
+ _id: doc._id
32
+ },
33
+ update: {
34
+ $set: doc
35
+ }
36
+ }
37
+ })), {
38
+ session
39
+ });
40
+ skip += batchSize;
41
+ }
42
+ };
43
+ const hasRelationshipOrUploadField = ({ fields })=>{
44
+ for (const field of fields){
45
+ if (field.type === 'relationship' || field.type === 'upload') {
46
+ return true;
47
+ }
48
+ if ('fields' in field) {
49
+ if (hasRelationshipOrUploadField({
50
+ fields: field.fields
51
+ })) {
52
+ return true;
53
+ }
54
+ }
55
+ if ('blocks' in field) {
56
+ for (const block of field.blocks){
57
+ if (hasRelationshipOrUploadField({
58
+ fields: block.fields
59
+ })) {
60
+ return true;
61
+ }
62
+ }
63
+ }
64
+ if ('tabs' in field) {
65
+ for (const tab of field.tabs){
66
+ if (hasRelationshipOrUploadField({
67
+ fields: tab.fields
68
+ })) {
69
+ return true;
70
+ }
71
+ }
72
+ }
73
+ }
74
+ return false;
75
+ };
76
+ export async function migrateRelationshipsV2_V3({ batchSize, req }) {
77
+ const { payload } = req;
78
+ const db = payload.db;
79
+ const config = payload.config;
80
+ const { session } = await withSession(db, req);
81
+ for (const collection of payload.config.collections.filter(hasRelationshipOrUploadField)){
82
+ payload.logger.info(`Migrating collection "${collection.slug}"`);
83
+ await migrateModelWithBatching({
84
+ batchSize,
85
+ config,
86
+ fields: collection.fields,
87
+ Model: db.collections[collection.slug],
88
+ session
89
+ });
90
+ payload.logger.info(`Migrated collection "${collection.slug}"`);
91
+ if (collection.versions) {
92
+ payload.logger.info(`Migrating collection versions "${collection.slug}"`);
93
+ await migrateModelWithBatching({
94
+ batchSize,
95
+ config,
96
+ fields: buildVersionCollectionFields(config, collection),
97
+ Model: db.versions[collection.slug],
98
+ session
99
+ });
100
+ payload.logger.info(`Migrated collection versions "${collection.slug}"`);
101
+ }
102
+ }
103
+ const { globals: GlobalsModel } = db;
104
+ for (const global of payload.config.globals.filter(hasRelationshipOrUploadField)){
105
+ payload.logger.info(`Migrating global "${global.slug}"`);
106
+ const doc = await GlobalsModel.findOne({
107
+ globalType: {
108
+ $eq: global.slug
109
+ }
110
+ }, {}, {
111
+ lean: true,
112
+ session
113
+ });
114
+ sanitizeRelationshipIDs({
115
+ config,
116
+ data: doc,
117
+ fields: global.fields
118
+ });
119
+ await GlobalsModel.collection.updateOne({
120
+ globalType: global.slug
121
+ }, {
122
+ $set: doc
123
+ }, {
124
+ session
125
+ });
126
+ payload.logger.info(`Migrated global "${global.slug}"`);
127
+ if (global.versions) {
128
+ payload.logger.info(`Migrating global versions "${global.slug}"`);
129
+ await migrateModelWithBatching({
130
+ batchSize,
131
+ config,
132
+ fields: buildVersionGlobalFields(config, global),
133
+ Model: db.versions[global.slug],
134
+ session
135
+ });
136
+ payload.logger.info(`Migrated global versions "${global.slug}"`);
137
+ }
138
+ }
139
+ }
140
+
141
+ //# sourceMappingURL=migrateRelationshipsV2_V3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/predefinedMigrations/migrateRelationshipsV2_V3.ts"],"sourcesContent":["import type { ClientSession, Model } from 'mongoose'\nimport type { Field, PayloadRequest, SanitizedConfig } from 'payload'\n\nimport { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload'\n\nimport type { MongooseAdapter } from '../index.js'\n\nimport { sanitizeRelationshipIDs } from '../utilities/sanitizeRelationshipIDs.js'\nimport { withSession } from '../withSession.js'\n\nconst migrateModelWithBatching = async ({\n batchSize,\n config,\n fields,\n Model,\n session,\n}: {\n batchSize: number\n config: SanitizedConfig\n fields: Field[]\n Model: Model<any>\n session: ClientSession\n}): Promise<void> => {\n let hasNext = true\n let skip = 0\n\n while (hasNext) {\n const docs = await Model.find(\n {},\n {},\n {\n lean: true,\n limit: batchSize + 1,\n session,\n skip,\n },\n )\n\n if (docs.length === 0) {\n break\n }\n\n hasNext = docs.length > batchSize\n\n if (hasNext) {\n docs.pop()\n }\n\n for (const doc of docs) {\n sanitizeRelationshipIDs({ config, data: doc, fields })\n }\n\n await Model.collection.bulkWrite(\n docs.map((doc) => ({\n updateOne: {\n filter: { _id: doc._id },\n update: {\n $set: doc,\n },\n },\n })),\n { session },\n )\n\n skip += batchSize\n }\n}\n\nconst hasRelationshipOrUploadField = ({ fields }: { fields: Field[] }): boolean => {\n for (const field of fields) {\n if (field.type === 'relationship' || field.type === 'upload') {\n return true\n }\n\n if ('fields' in field) {\n if (hasRelationshipOrUploadField({ fields: field.fields })) {\n return true\n }\n }\n\n if ('blocks' in field) {\n for (const block of field.blocks) {\n if (hasRelationshipOrUploadField({ fields: block.fields })) {\n return true\n }\n }\n }\n\n if ('tabs' in field) {\n for (const tab of field.tabs) {\n if (hasRelationshipOrUploadField({ fields: tab.fields })) {\n return true\n }\n }\n }\n }\n\n return false\n}\n\nexport async function migrateRelationshipsV2_V3({\n batchSize,\n req,\n}: {\n batchSize: number\n req: PayloadRequest\n}): Promise<void> {\n const { payload } = req\n const db = payload.db as MongooseAdapter\n const config = payload.config\n\n const { session } = await withSession(db, req)\n\n for (const collection of payload.config.collections.filter(hasRelationshipOrUploadField)) {\n payload.logger.info(`Migrating collection \"${collection.slug}\"`)\n\n await migrateModelWithBatching({\n batchSize,\n config,\n fields: collection.fields,\n Model: db.collections[collection.slug],\n session,\n })\n\n payload.logger.info(`Migrated collection \"${collection.slug}\"`)\n\n if (collection.versions) {\n payload.logger.info(`Migrating collection versions \"${collection.slug}\"`)\n\n await migrateModelWithBatching({\n batchSize,\n config,\n fields: buildVersionCollectionFields(config, collection),\n Model: db.versions[collection.slug],\n session,\n })\n\n payload.logger.info(`Migrated collection versions \"${collection.slug}\"`)\n }\n }\n\n const { globals: GlobalsModel } = db\n\n for (const global of payload.config.globals.filter(hasRelationshipOrUploadField)) {\n payload.logger.info(`Migrating global \"${global.slug}\"`)\n\n const doc = await GlobalsModel.findOne<Record<string, unknown>>(\n {\n globalType: {\n $eq: global.slug,\n },\n },\n {},\n { lean: true, session },\n )\n\n sanitizeRelationshipIDs({ config, data: doc, fields: global.fields })\n\n await GlobalsModel.collection.updateOne(\n {\n globalType: global.slug,\n },\n { $set: doc },\n { session },\n )\n\n payload.logger.info(`Migrated global \"${global.slug}\"`)\n\n if (global.versions) {\n payload.logger.info(`Migrating global versions \"${global.slug}\"`)\n\n await migrateModelWithBatching({\n batchSize,\n config,\n fields: buildVersionGlobalFields(config, global),\n Model: db.versions[global.slug],\n session,\n })\n\n payload.logger.info(`Migrated global versions \"${global.slug}\"`)\n }\n }\n}\n"],"names":["buildVersionCollectionFields","buildVersionGlobalFields","sanitizeRelationshipIDs","withSession","migrateModelWithBatching","batchSize","config","fields","Model","session","hasNext","skip","docs","find","lean","limit","length","pop","doc","data","collection","bulkWrite","map","updateOne","filter","_id","update","$set","hasRelationshipOrUploadField","field","type","block","blocks","tab","tabs","migrateRelationshipsV2_V3","req","payload","db","collections","logger","info","slug","versions","globals","GlobalsModel","global","findOne","globalType","$eq"],"mappings":"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"}
@@ -0,0 +1,5 @@
1
+ import type { PayloadRequest } from 'payload';
2
+ export declare function migrateVersionsV1_V2({ req }: {
3
+ req: PayloadRequest;
4
+ }): Promise<void>;
5
+ //# sourceMappingURL=migrateVersionsV1_V2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrateVersionsV1_V2.d.ts","sourceRoot":"","sources":["../../src/predefinedMigrations/migrateVersionsV1_V2.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAW,cAAc,EAAE,MAAM,SAAS,CAAA;AAMtD,wBAAsB,oBAAoB,CAAC,EAAE,GAAG,EAAE,EAAE;IAAE,GAAG,EAAE,cAAc,CAAA;CAAE,iBAgC1E"}
@@ -0,0 +1,107 @@
1
+ import { withSession } from '../withSession.js';
2
+ export async function migrateVersionsV1_V2({ req }) {
3
+ const { payload } = req;
4
+ const { session } = await withSession(payload.db, req);
5
+ // For each collection
6
+ for (const { slug, versions } of payload.config.collections){
7
+ if (versions?.drafts) {
8
+ await migrateCollectionDocs({
9
+ slug,
10
+ payload,
11
+ session
12
+ });
13
+ payload.logger.info(`Migrated the "${slug}" collection.`);
14
+ }
15
+ }
16
+ // For each global
17
+ for (const { slug, versions } of payload.config.globals){
18
+ if (versions) {
19
+ const VersionsModel = payload.db.versions[slug];
20
+ await VersionsModel.findOneAndUpdate({}, {
21
+ latest: true
22
+ }, {
23
+ session,
24
+ sort: {
25
+ updatedAt: -1
26
+ }
27
+ }).exec();
28
+ payload.logger.info(`Migrated the "${slug}" global.`);
29
+ }
30
+ }
31
+ }
32
+ async function migrateCollectionDocs({ slug, docsAtATime = 100, payload, session }) {
33
+ const VersionsModel = payload.db.versions[slug];
34
+ const remainingDocs = await VersionsModel.aggregate([
35
+ // Sort so that newest are first
36
+ {
37
+ $sort: {
38
+ updatedAt: -1
39
+ }
40
+ },
41
+ // Group by parent ID
42
+ // take the $first of each
43
+ {
44
+ $group: {
45
+ _id: '$parent',
46
+ _versionID: {
47
+ $first: '$_id'
48
+ },
49
+ createdAt: {
50
+ $first: '$createdAt'
51
+ },
52
+ latest: {
53
+ $first: '$latest'
54
+ },
55
+ updatedAt: {
56
+ $first: '$updatedAt'
57
+ },
58
+ version: {
59
+ $first: '$version'
60
+ }
61
+ }
62
+ },
63
+ {
64
+ $match: {
65
+ latest: {
66
+ $eq: null
67
+ }
68
+ }
69
+ },
70
+ {
71
+ $limit: docsAtATime
72
+ }
73
+ ], {
74
+ allowDiskUse: true,
75
+ session
76
+ }).exec();
77
+ if (!remainingDocs || remainingDocs.length === 0) {
78
+ const newVersions = await VersionsModel.find({
79
+ latest: {
80
+ $eq: true
81
+ }
82
+ }, undefined, {
83
+ session
84
+ });
85
+ if (newVersions?.length) {
86
+ payload.logger.info(`Migrated ${newVersions.length} documents in the "${slug}" versions collection.`);
87
+ }
88
+ return;
89
+ }
90
+ const remainingDocIds = remainingDocs.map((doc)=>doc._versionID);
91
+ await VersionsModel.updateMany({
92
+ _id: {
93
+ $in: remainingDocIds
94
+ }
95
+ }, {
96
+ latest: true
97
+ }, {
98
+ session
99
+ });
100
+ await migrateCollectionDocs({
101
+ slug,
102
+ payload,
103
+ session
104
+ });
105
+ }
106
+
107
+ //# sourceMappingURL=migrateVersionsV1_V2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/predefinedMigrations/migrateVersionsV1_V2.ts"],"sourcesContent":["import type { ClientSession } from 'mongoose'\nimport type { Payload, PayloadRequest } from 'payload'\n\nimport type { MongooseAdapter } from '../index.js'\n\nimport { withSession } from '../withSession.js'\n\nexport async function migrateVersionsV1_V2({ req }: { req: PayloadRequest }) {\n const { payload } = req\n\n const { session } = await withSession(payload.db as MongooseAdapter, req)\n\n // For each collection\n\n for (const { slug, versions } of payload.config.collections) {\n if (versions?.drafts) {\n await migrateCollectionDocs({ slug, payload, session })\n\n payload.logger.info(`Migrated the \"${slug}\" collection.`)\n }\n }\n\n // For each global\n for (const { slug, versions } of payload.config.globals) {\n if (versions) {\n const VersionsModel = payload.db.versions[slug]\n\n await VersionsModel.findOneAndUpdate(\n {},\n { latest: true },\n {\n session,\n sort: { updatedAt: -1 },\n },\n ).exec()\n\n payload.logger.info(`Migrated the \"${slug}\" global.`)\n }\n }\n}\n\nasync function migrateCollectionDocs({\n slug,\n docsAtATime = 100,\n payload,\n session,\n}: {\n docsAtATime?: number\n payload: Payload\n session: ClientSession\n slug: string\n}) {\n const VersionsModel = payload.db.versions[slug]\n const remainingDocs = await VersionsModel.aggregate(\n [\n // Sort so that newest are first\n {\n $sort: {\n updatedAt: -1,\n },\n },\n // Group by parent ID\n // take the $first of each\n {\n $group: {\n _id: '$parent',\n _versionID: { $first: '$_id' },\n createdAt: { $first: '$createdAt' },\n latest: { $first: '$latest' },\n updatedAt: { $first: '$updatedAt' },\n version: { $first: '$version' },\n },\n },\n {\n $match: {\n latest: { $eq: null },\n },\n },\n {\n $limit: docsAtATime,\n },\n ],\n {\n allowDiskUse: true,\n session,\n },\n ).exec()\n\n if (!remainingDocs || remainingDocs.length === 0) {\n const newVersions = await VersionsModel.find(\n {\n latest: {\n $eq: true,\n },\n },\n undefined,\n { session },\n )\n\n if (newVersions?.length) {\n payload.logger.info(\n `Migrated ${newVersions.length} documents in the \"${slug}\" versions collection.`,\n )\n }\n\n return\n }\n\n const remainingDocIds = remainingDocs.map((doc) => doc._versionID)\n\n await VersionsModel.updateMany(\n {\n _id: {\n $in: remainingDocIds,\n },\n },\n {\n latest: true,\n },\n {\n session,\n },\n )\n\n await migrateCollectionDocs({ slug, payload, session })\n}\n"],"names":["withSession","migrateVersionsV1_V2","req","payload","session","db","slug","versions","config","collections","drafts","migrateCollectionDocs","logger","info","globals","VersionsModel","findOneAndUpdate","latest","sort","updatedAt","exec","docsAtATime","remainingDocs","aggregate","$sort","$group","_id","_versionID","$first","createdAt","version","$match","$eq","$limit","allowDiskUse","length","newVersions","find","undefined","remainingDocIds","map","doc","updateMany","$in"],"mappings":"AAKA,SAASA,WAAW,QAAQ,oBAAmB;AAE/C,OAAO,eAAeC,qBAAqB,EAAEC,GAAG,EAA2B;IACzE,MAAM,EAAEC,OAAO,EAAE,GAAGD;IAEpB,MAAM,EAAEE,OAAO,EAAE,GAAG,MAAMJ,YAAYG,QAAQE,EAAE,EAAqBH;IAErE,sBAAsB;IAEtB,KAAK,MAAM,EAAEI,IAAI,EAAEC,QAAQ,EAAE,IAAIJ,QAAQK,MAAM,CAACC,WAAW,CAAE;QAC3D,IAAIF,UAAUG,QAAQ;YACpB,MAAMC,sBAAsB;gBAAEL;gBAAMH;gBAASC;YAAQ;YAErDD,QAAQS,MAAM,CAACC,IAAI,CAAC,CAAC,cAAc,EAAEP,KAAK,aAAa,CAAC;QAC1D;IACF;IAEA,kBAAkB;IAClB,KAAK,MAAM,EAAEA,IAAI,EAAEC,QAAQ,EAAE,IAAIJ,QAAQK,MAAM,CAACM,OAAO,CAAE;QACvD,IAAIP,UAAU;YACZ,MAAMQ,gBAAgBZ,QAAQE,EAAE,CAACE,QAAQ,CAACD,KAAK;YAE/C,MAAMS,cAAcC,gBAAgB,CAClC,CAAC,GACD;gBAAEC,QAAQ;YAAK,GACf;gBACEb;gBACAc,MAAM;oBAAEC,WAAW,CAAC;gBAAE;YACxB,GACAC,IAAI;YAENjB,QAAQS,MAAM,CAACC,IAAI,CAAC,CAAC,cAAc,EAAEP,KAAK,SAAS,CAAC;QACtD;IACF;AACF;AAEA,eAAeK,sBAAsB,EACnCL,IAAI,EACJe,cAAc,GAAG,EACjBlB,OAAO,EACPC,OAAO,EAMR;IACC,MAAMW,gBAAgBZ,QAAQE,EAAE,CAACE,QAAQ,CAACD,KAAK;IAC/C,MAAMgB,gBAAgB,MAAMP,cAAcQ,SAAS,CACjD;QACE,gCAAgC;QAChC;YACEC,OAAO;gBACLL,WAAW,CAAC;YACd;QACF;QACA,qBAAqB;QACrB,0BAA0B;QAC1B;YACEM,QAAQ;gBACNC,KAAK;gBACLC,YAAY;oBAAEC,QAAQ;gBAAO;gBAC7BC,WAAW;oBAAED,QAAQ;gBAAa;gBAClCX,QAAQ;oBAAEW,QAAQ;gBAAU;gBAC5BT,WAAW;oBAAES,QAAQ;gBAAa;gBAClCE,SAAS;oBAAEF,QAAQ;gBAAW;YAChC;QACF;QACA;YACEG,QAAQ;gBACNd,QAAQ;oBAAEe,KAAK;gBAAK;YACtB;QACF;QACA;YACEC,QAAQZ;QACV;KACD,EACD;QACEa,cAAc;QACd9B;IACF,GACAgB,IAAI;IAEN,IAAI,CAACE,iBAAiBA,cAAca,MAAM,KAAK,GAAG;QAChD,MAAMC,cAAc,MAAMrB,cAAcsB,IAAI,CAC1C;YACEpB,QAAQ;gBACNe,KAAK;YACP;QACF,GACAM,WACA;YAAElC;QAAQ;QAGZ,IAAIgC,aAAaD,QAAQ;YACvBhC,QAAQS,MAAM,CAACC,IAAI,CACjB,CAAC,SAAS,EAAEuB,YAAYD,MAAM,CAAC,mBAAmB,EAAE7B,KAAK,sBAAsB,CAAC;QAEpF;QAEA;IACF;IAEA,MAAMiC,kBAAkBjB,cAAckB,GAAG,CAAC,CAACC,MAAQA,IAAId,UAAU;IAEjE,MAAMZ,cAAc2B,UAAU,CAC5B;QACEhB,KAAK;YACHiB,KAAKJ;QACP;IACF,GACA;QACEtB,QAAQ;IACV,GACA;QACEb;IACF;IAGF,MAAMO,sBAAsB;QAAEL;QAAMH;QAASC;IAAQ;AACvD"}
@@ -0,0 +1,4 @@
1
+ declare const imports = "import { migrateRelationshipsV2_V3 } from '@payloadcms/db-mongodb/migration-utils'";
2
+ declare const upSQL = " await migrateRelationshipsV2_V3({\n batchSize: 100,\n req,\n })\n";
3
+ export { imports, upSQL };
4
+ //# sourceMappingURL=relationships-v2-v3.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relationships-v2-v3.d.ts","sourceRoot":"","sources":["../../src/predefinedMigrations/relationships-v2-v3.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,OAAO,uFAAuF,CAAA;AACpG,QAAA,MAAM,KAAK,8FAIV,CAAA;AACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAA"}
@@ -0,0 +1,9 @@
1
+ const imports = `import { migrateRelationshipsV2_V3 } from '@payloadcms/db-mongodb/migration-utils'`;
2
+ const upSQL = ` await migrateRelationshipsV2_V3({
3
+ batchSize: 100,
4
+ req,
5
+ })
6
+ `;
7
+ export { imports, upSQL };
8
+
9
+ //# sourceMappingURL=relationships-v2-v3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/predefinedMigrations/relationships-v2-v3.ts"],"sourcesContent":["const imports = `import { migrateRelationshipsV2_V3 } from '@payloadcms/db-mongodb/migration-utils'`\nconst upSQL = ` await migrateRelationshipsV2_V3({\n batchSize: 100,\n req,\n })\n`\nexport { imports, upSQL }\n"],"names":["imports","upSQL"],"mappings":"AAAA,MAAMA,UAAU,CAAC,kFAAkF,CAAC;AACpG,MAAMC,QAAQ,CAAC;;;;AAIf,CAAC;AACD,SAASD,OAAO,EAAEC,KAAK,GAAE"}
@@ -0,0 +1,4 @@
1
+ declare const imports = "import { migrateVersionsV1_V2 } from '@payloadcms/db-mongodb/migration-utils'";
2
+ declare const upSQL = " await migrateVersionsV1_V2({\n req,\n })\n";
3
+ export { imports, upSQL };
4
+ //# sourceMappingURL=versions-v1-v2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"versions-v1-v2.d.ts","sourceRoot":"","sources":["../../src/predefinedMigrations/versions-v1-v2.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,OAAO,kFAAkF,CAAA;AAC/F,QAAA,MAAM,KAAK,gEAGV,CAAA;AACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAA"}
@@ -0,0 +1,8 @@
1
+ const imports = `import { migrateVersionsV1_V2 } from '@payloadcms/db-mongodb/migration-utils'`;
2
+ const upSQL = ` await migrateVersionsV1_V2({
3
+ req,
4
+ })
5
+ `;
6
+ export { imports, upSQL };
7
+
8
+ //# sourceMappingURL=versions-v1-v2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/predefinedMigrations/versions-v1-v2.ts"],"sourcesContent":["const imports = `import { migrateVersionsV1_V2 } from '@payloadcms/db-mongodb/migration-utils'`\nconst upSQL = ` await migrateVersionsV1_V2({\n req,\n })\n`\nexport { imports, upSQL }\n"],"names":["imports","upSQL"],"mappings":"AAAA,MAAMA,UAAU,CAAC,6EAA6E,CAAC;AAC/F,MAAMC,QAAQ,CAAC;;;AAGf,CAAC;AACD,SAASD,OAAO,EAAEC,KAAK,GAAE"}
@@ -1,5 +1,4 @@
1
- import type { Payload } from 'payload';
2
- import type { Field, Where } from 'payload/types';
1
+ import type { Field, Payload, Where } from 'payload';
3
2
  export declare function buildAndOrConditions({ collectionSlug, fields, globalSlug, locale, payload, where, }: {
4
3
  collectionSlug?: string;
5
4
  fields: Field[];
@@ -1 +1 @@
1
- {"version":3,"file":"buildAndOrConditions.d.ts","sourceRoot":"","sources":["../../src/queries/buildAndOrConditions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAIjD,wBAAsB,oBAAoB,CAAC,EACzC,cAAc,EACd,MAAM,EACN,UAAU,EACV,MAAM,EACN,OAAO,EACP,KAAK,GACN,EAAE;IACD,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,KAAK,EAAE,CAAA;CACf,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAuBrC"}
1
+ {"version":3,"file":"buildAndOrConditions.d.ts","sourceRoot":"","sources":["../../src/queries/buildAndOrConditions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAIpD,wBAAsB,oBAAoB,CAAC,EACzC,cAAc,EACd,MAAM,EACN,UAAU,EACV,MAAM,EACN,OAAO,EACP,KAAK,GACN,EAAE;IACD,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,KAAK,EAAE,CAAA;CACf,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAsBrC"}
@@ -3,11 +3,9 @@ export async function buildAndOrConditions({ collectionSlug, fields, globalSlug,
3
3
  const completedConditions = [];
4
4
  // Loop over all AND / OR operations and add them to the AND / OR query param
5
5
  // Operations should come through as an array
6
- // eslint-disable-next-line no-restricted-syntax
7
6
  for (const condition of where){
8
7
  // If the operation is properly formatted as an object
9
8
  if (typeof condition === 'object') {
10
- // eslint-disable-next-line no-await-in-loop
11
9
  const result = await parseParams({
12
10
  collectionSlug,
13
11
  fields,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/queries/buildAndOrConditions.ts"],"sourcesContent":["import type { Payload } from 'payload'\nimport type { Field, Where } from 'payload/types'\n\nimport { parseParams } from './parseParams.js'\n\nexport async function buildAndOrConditions({\n collectionSlug,\n fields,\n globalSlug,\n locale,\n payload,\n where,\n}: {\n collectionSlug?: string\n fields: Field[]\n globalSlug?: string\n locale?: string\n payload: Payload\n where: Where[]\n}): Promise<Record<string, unknown>[]> {\n const completedConditions = []\n // Loop over all AND / OR operations and add them to the AND / OR query param\n // Operations should come through as an array\n // eslint-disable-next-line no-restricted-syntax\n for (const condition of where) {\n // If the operation is properly formatted as an object\n if (typeof condition === 'object') {\n // eslint-disable-next-line no-await-in-loop\n const result = await parseParams({\n collectionSlug,\n fields,\n globalSlug,\n locale,\n payload,\n where: condition,\n })\n if (Object.keys(result).length > 0) {\n completedConditions.push(result)\n }\n }\n }\n return completedConditions\n}\n"],"names":["parseParams","buildAndOrConditions","collectionSlug","fields","globalSlug","locale","payload","where","completedConditions","condition","result","Object","keys","length","push"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,eAAeC,qBAAqB,EACzCC,cAAc,EACdC,MAAM,EACNC,UAAU,EACVC,MAAM,EACNC,OAAO,EACPC,KAAK,EAQN;IACC,MAAMC,sBAAsB,EAAE;IAC9B,6EAA6E;IAC7E,6CAA6C;IAC7C,gDAAgD;IAChD,KAAK,MAAMC,aAAaF,MAAO;QAC7B,sDAAsD;QACtD,IAAI,OAAOE,cAAc,UAAU;YACjC,4CAA4C;YAC5C,MAAMC,SAAS,MAAMV,YAAY;gBAC/BE;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC,OAAOE;YACT;YACA,IAAIE,OAAOC,IAAI,CAACF,QAAQG,MAAM,GAAG,GAAG;gBAClCL,oBAAoBM,IAAI,CAACJ;YAC3B;QACF;IACF;IACA,OAAOF;AACT"}
1
+ {"version":3,"sources":["../../src/queries/buildAndOrConditions.ts"],"sourcesContent":["import type { Field, Payload, Where } from 'payload'\n\nimport { parseParams } from './parseParams.js'\n\nexport async function buildAndOrConditions({\n collectionSlug,\n fields,\n globalSlug,\n locale,\n payload,\n where,\n}: {\n collectionSlug?: string\n fields: Field[]\n globalSlug?: string\n locale?: string\n payload: Payload\n where: Where[]\n}): Promise<Record<string, unknown>[]> {\n const completedConditions = []\n // Loop over all AND / OR operations and add them to the AND / OR query param\n // Operations should come through as an array\n\n for (const condition of where) {\n // If the operation is properly formatted as an object\n if (typeof condition === 'object') {\n const result = await parseParams({\n collectionSlug,\n fields,\n globalSlug,\n locale,\n payload,\n where: condition,\n })\n if (Object.keys(result).length > 0) {\n completedConditions.push(result)\n }\n }\n }\n return completedConditions\n}\n"],"names":["parseParams","buildAndOrConditions","collectionSlug","fields","globalSlug","locale","payload","where","completedConditions","condition","result","Object","keys","length","push"],"mappings":"AAEA,SAASA,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,eAAeC,qBAAqB,EACzCC,cAAc,EACdC,MAAM,EACNC,UAAU,EACVC,MAAM,EACNC,OAAO,EACPC,KAAK,EAQN;IACC,MAAMC,sBAAsB,EAAE;IAC9B,6EAA6E;IAC7E,6CAA6C;IAE7C,KAAK,MAAMC,aAAaF,MAAO;QAC7B,sDAAsD;QACtD,IAAI,OAAOE,cAAc,UAAU;YACjC,MAAMC,SAAS,MAAMV,YAAY;gBAC/BE;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC,OAAOE;YACT;YACA,IAAIE,OAAOC,IAAI,CAACF,QAAQG,MAAM,GAAG,GAAG;gBAClCL,oBAAoBM,IAAI,CAACJ;YAC3B;QACF;IACF;IACA,OAAOF;AACT"}
@@ -1,5 +1,4 @@
1
- import type { Payload } from 'payload';
2
- import type { Field, Where } from 'payload/types';
1
+ import type { Field, Payload, Where } from 'payload';
3
2
  type GetBuildQueryPluginArgs = {
4
3
  collectionSlug?: string;
5
4
  versionsFields?: Field[];
@@ -10,6 +9,6 @@ export type BuildQueryArgs = {
10
9
  payload: Payload;
11
10
  where: Where;
12
11
  };
13
- declare const getBuildQueryPlugin: ({ collectionSlug, versionsFields }?: GetBuildQueryPluginArgs) => (schema: any) => void;
14
- export default getBuildQueryPlugin;
12
+ export declare const getBuildQueryPlugin: ({ collectionSlug, versionsFields, }?: GetBuildQueryPluginArgs) => (schema: any) => void;
13
+ export {};
15
14
  //# sourceMappingURL=buildQuery.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"buildQuery.d.ts","sourceRoot":"","sources":["../../src/queries/buildQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAMjD,KAAK,uBAAuB,GAAG;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,cAAc,CAAC,EAAE,KAAK,EAAE,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,KAAK,CAAA;CACb,CAAA;AAID,QAAA,MAAM,mBAAmB,wCAAwC,uBAAuB,0BAsCvF,CAAA;AAED,eAAe,mBAAmB,CAAA"}
1
+ {"version":3,"file":"buildQuery.d.ts","sourceRoot":"","sources":["../../src/queries/buildQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAMpD,KAAK,uBAAuB,GAAG;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,cAAc,CAAC,EAAE,KAAK,EAAE,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,KAAK,CAAA;CACb,CAAA;AAID,eAAO,MAAM,mBAAmB,yCAG7B,uBAAuB,0BAsCzB,CAAA"}
@@ -1,8 +1,8 @@
1
- import { QueryError } from 'payload/errors';
1
+ import { QueryError } from 'payload';
2
2
  import { parseParams } from './parseParams.js';
3
3
  // This plugin asynchronously builds a list of Mongoose query constraints
4
4
  // which can then be used in subsequent Mongoose queries.
5
- const getBuildQueryPlugin = ({ collectionSlug, versionsFields } = {})=>{
5
+ export const getBuildQueryPlugin = ({ collectionSlug, versionsFields } = {})=>{
6
6
  return function buildQueryPlugin(schema) {
7
7
  const modifiedSchema = schema;
8
8
  async function buildQuery({ globalSlug, locale, payload, where }) {
@@ -34,6 +34,5 @@ const getBuildQueryPlugin = ({ collectionSlug, versionsFields } = {})=>{
34
34
  modifiedSchema.statics.buildQuery = buildQuery;
35
35
  };
36
36
  };
37
- export default getBuildQueryPlugin;
38
37
 
39
38
  //# sourceMappingURL=buildQuery.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/queries/buildQuery.ts"],"sourcesContent":["import type { Payload } from 'payload'\nimport type { Field, Where } from 'payload/types'\n\nimport { QueryError } from 'payload/errors'\n\nimport { parseParams } from './parseParams.js'\n\ntype GetBuildQueryPluginArgs = {\n collectionSlug?: string\n versionsFields?: Field[]\n}\n\nexport type BuildQueryArgs = {\n globalSlug?: string\n locale?: string\n payload: Payload\n where: Where\n}\n\n// This plugin asynchronously builds a list of Mongoose query constraints\n// which can then be used in subsequent Mongoose queries.\nconst getBuildQueryPlugin = ({ collectionSlug, versionsFields }: GetBuildQueryPluginArgs = {}) => {\n return function buildQueryPlugin(schema) {\n const modifiedSchema = schema\n async function buildQuery({\n globalSlug,\n locale,\n payload,\n where,\n }: BuildQueryArgs): Promise<Record<string, unknown>> {\n let fields = versionsFields\n if (!fields) {\n if (globalSlug) {\n const globalConfig = payload.globals.config.find(({ slug }) => slug === globalSlug)\n fields = globalConfig.fields\n }\n if (collectionSlug) {\n const collectionConfig = payload.collections[collectionSlug].config\n fields = collectionConfig.fields\n }\n }\n const errors = []\n const result = await parseParams({\n collectionSlug,\n fields,\n globalSlug,\n locale,\n payload,\n where,\n })\n\n if (errors.length > 0) {\n throw new QueryError(errors)\n }\n\n return result\n }\n modifiedSchema.statics.buildQuery = buildQuery\n }\n}\n\nexport default getBuildQueryPlugin\n"],"names":["QueryError","parseParams","getBuildQueryPlugin","collectionSlug","versionsFields","buildQueryPlugin","schema","modifiedSchema","buildQuery","globalSlug","locale","payload","where","fields","globalConfig","globals","config","find","slug","collectionConfig","collections","errors","result","length","statics"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,UAAU,QAAQ,iBAAgB;AAE3C,SAASC,WAAW,QAAQ,mBAAkB;AAc9C,yEAAyE;AACzE,yDAAyD;AACzD,MAAMC,sBAAsB,CAAC,EAAEC,cAAc,EAAEC,cAAc,EAA2B,GAAG,CAAC,CAAC;IAC3F,OAAO,SAASC,iBAAiBC,MAAM;QACrC,MAAMC,iBAAiBD;QACvB,eAAeE,WAAW,EACxBC,UAAU,EACVC,MAAM,EACNC,OAAO,EACPC,KAAK,EACU;YACf,IAAIC,SAAST;YACb,IAAI,CAACS,QAAQ;gBACX,IAAIJ,YAAY;oBACd,MAAMK,eAAeH,QAAQI,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKA,SAAST;oBACxEI,SAASC,aAAaD,MAAM;gBAC9B;gBACA,IAAIV,gBAAgB;oBAClB,MAAMgB,mBAAmBR,QAAQS,WAAW,CAACjB,eAAe,CAACa,MAAM;oBACnEH,SAASM,iBAAiBN,MAAM;gBAClC;YACF;YACA,MAAMQ,SAAS,EAAE;YACjB,MAAMC,SAAS,MAAMrB,YAAY;gBAC/BE;gBACAU;gBACAJ;gBACAC;gBACAC;gBACAC;YACF;YAEA,IAAIS,OAAOE,MAAM,GAAG,GAAG;gBACrB,MAAM,IAAIvB,WAAWqB;YACvB;YAEA,OAAOC;QACT;QACAf,eAAeiB,OAAO,CAAChB,UAAU,GAAGA;IACtC;AACF;AAEA,eAAeN,oBAAmB"}
1
+ {"version":3,"sources":["../../src/queries/buildQuery.ts"],"sourcesContent":["import type { Field, Payload, Where } from 'payload'\n\nimport { QueryError } from 'payload'\n\nimport { parseParams } from './parseParams.js'\n\ntype GetBuildQueryPluginArgs = {\n collectionSlug?: string\n versionsFields?: Field[]\n}\n\nexport type BuildQueryArgs = {\n globalSlug?: string\n locale?: string\n payload: Payload\n where: Where\n}\n\n// This plugin asynchronously builds a list of Mongoose query constraints\n// which can then be used in subsequent Mongoose queries.\nexport const getBuildQueryPlugin = ({\n collectionSlug,\n versionsFields,\n}: GetBuildQueryPluginArgs = {}) => {\n return function buildQueryPlugin(schema) {\n const modifiedSchema = schema\n async function buildQuery({\n globalSlug,\n locale,\n payload,\n where,\n }: BuildQueryArgs): Promise<Record<string, unknown>> {\n let fields = versionsFields\n if (!fields) {\n if (globalSlug) {\n const globalConfig = payload.globals.config.find(({ slug }) => slug === globalSlug)\n fields = globalConfig.fields\n }\n if (collectionSlug) {\n const collectionConfig = payload.collections[collectionSlug].config\n fields = collectionConfig.fields\n }\n }\n const errors = []\n const result = await parseParams({\n collectionSlug,\n fields,\n globalSlug,\n locale,\n payload,\n where,\n })\n\n if (errors.length > 0) {\n throw new QueryError(errors)\n }\n\n return result\n }\n modifiedSchema.statics.buildQuery = buildQuery\n }\n}\n"],"names":["QueryError","parseParams","getBuildQueryPlugin","collectionSlug","versionsFields","buildQueryPlugin","schema","modifiedSchema","buildQuery","globalSlug","locale","payload","where","fields","globalConfig","globals","config","find","slug","collectionConfig","collections","errors","result","length","statics"],"mappings":"AAEA,SAASA,UAAU,QAAQ,UAAS;AAEpC,SAASC,WAAW,QAAQ,mBAAkB;AAc9C,yEAAyE;AACzE,yDAAyD;AACzD,OAAO,MAAMC,sBAAsB,CAAC,EAClCC,cAAc,EACdC,cAAc,EACU,GAAG,CAAC,CAAC;IAC7B,OAAO,SAASC,iBAAiBC,MAAM;QACrC,MAAMC,iBAAiBD;QACvB,eAAeE,WAAW,EACxBC,UAAU,EACVC,MAAM,EACNC,OAAO,EACPC,KAAK,EACU;YACf,IAAIC,SAAST;YACb,IAAI,CAACS,QAAQ;gBACX,IAAIJ,YAAY;oBACd,MAAMK,eAAeH,QAAQI,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKA,SAAST;oBACxEI,SAASC,aAAaD,MAAM;gBAC9B;gBACA,IAAIV,gBAAgB;oBAClB,MAAMgB,mBAAmBR,QAAQS,WAAW,CAACjB,eAAe,CAACa,MAAM;oBACnEH,SAASM,iBAAiBN,MAAM;gBAClC;YACF;YACA,MAAMQ,SAAS,EAAE;YACjB,MAAMC,SAAS,MAAMrB,YAAY;gBAC/BE;gBACAU;gBACAJ;gBACAC;gBACAC;gBACAC;YACF;YAEA,IAAIS,OAAOE,MAAM,GAAG,GAAG;gBACrB,MAAM,IAAIvB,WAAWqB;YACvB;YAEA,OAAOC;QACT;QACAf,eAAeiB,OAAO,CAAChB,UAAU,GAAGA;IACtC;AACF,EAAC"}
@@ -1,5 +1,4 @@
1
- import type { Payload } from 'payload';
2
- import type { Field } from 'payload/types';
1
+ import type { Field, Payload } from 'payload';
3
2
  type SearchParam = {
4
3
  path?: string;
5
4
  rawQuery?: unknown;
@@ -1 +1 @@
1
- {"version":3,"file":"buildSearchParams.d.ts","sourceRoot":"","sources":["../../src/queries/buildSearchParams.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEtC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAiB1C,KAAK,WAAW,GAAG;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,CAAA;AAOD;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,EACrC,cAAc,EACd,MAAM,EACN,UAAU,EACV,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,OAAO,EACP,GAAG,GACJ,EAAE;IACD,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,GAAG,EAAE,OAAO,CAAA;CACb,GAAG,OAAO,CAAC,WAAW,CAAC,CAmNvB"}
1
+ {"version":3,"file":"buildSearchParams.d.ts","sourceRoot":"","sources":["../../src/queries/buildSearchParams.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAyB,OAAO,EAAE,MAAM,SAAS,CAAA;AAWpE,KAAK,WAAW,GAAG;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,CAAA;AAOD;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,EACrC,cAAc,EACd,MAAM,EACN,UAAU,EACV,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,OAAO,EACP,GAAG,GACJ,EAAE;IACD,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,GAAG,EAAE,OAAO,CAAA;CACb,GAAG,OAAO,CAAC,WAAW,CAAC,CAgOvB"}
@@ -1,10 +1,8 @@
1
- import ObjectIdImport from 'bson-objectid';
2
- import mongoose from 'mongoose';
3
- import { getLocalizedPaths } from 'payload/database';
4
- import { validOperators } from 'payload/types';
1
+ import { Types } from 'mongoose';
2
+ import { getLocalizedPaths } from 'payload';
3
+ import { validOperators } from 'payload/shared';
5
4
  import { operatorMap } from './operatorMap.js';
6
5
  import { sanitizeQueryValue } from './sanitizeQueryValue.js';
7
- const ObjectId = ObjectIdImport.default || ObjectIdImport;
8
6
  const subQueryOptions = {
9
7
  lean: true,
10
8
  limit: 50
@@ -14,7 +12,9 @@ const subQueryOptions = {
14
12
  */ export async function buildSearchParam({ collectionSlug, fields, globalSlug, incomingPath, locale, operator, payload, val }) {
15
13
  // Replace GraphQL nested field double underscore formatting
16
14
  let sanitizedPath = incomingPath.replace(/__/g, '.');
17
- if (sanitizedPath === 'id') sanitizedPath = '_id';
15
+ if (sanitizedPath === 'id') {
16
+ sanitizedPath = '_id';
17
+ }
18
18
  let paths = [];
19
19
  let hasCustomID = false;
20
20
  if (sanitizedPath === '_id') {
@@ -45,16 +45,22 @@ const subQueryOptions = {
45
45
  }
46
46
  const [{ field, path }] = paths;
47
47
  if (path) {
48
- const { operator: formattedOperator, rawQuery, val: formattedValue } = sanitizeQueryValue({
48
+ const sanitizedQueryValue = sanitizeQueryValue({
49
49
  field,
50
50
  hasCustomID,
51
51
  operator,
52
52
  path,
53
53
  val
54
54
  });
55
- if (rawQuery) return {
56
- value: rawQuery
57
- };
55
+ if (!sanitizedQueryValue) {
56
+ return undefined;
57
+ }
58
+ const { operator: formattedOperator, rawQuery, val: formattedValue } = sanitizedQueryValue;
59
+ if (rawQuery) {
60
+ return {
61
+ value: rawQuery
62
+ };
63
+ }
58
64
  // If there are multiple collections to search through,
59
65
  // Recursively build up a list of query constraints
60
66
  if (paths.length > 1) {
@@ -84,7 +90,7 @@ const subQueryOptions = {
84
90
  result.forEach((doc)=>{
85
91
  const stringID = doc._id.toString();
86
92
  $in.push(stringID);
87
- if (mongoose.Types.ObjectId.isValid(stringID)) {
93
+ if (Types.ObjectId.isValid(stringID)) {
88
94
  $in.push(doc._id);
89
95
  }
90
96
  });
@@ -107,7 +113,7 @@ const subQueryOptions = {
107
113
  }
108
114
  const subQuery = priorQueryResult.value;
109
115
  const result = await SubModel.find(subQuery, subQueryOptions);
110
- const $in = result.map((doc)=>doc._id.toString());
116
+ const $in = result.map((doc)=>doc._id);
111
117
  // If it is the last recursion
112
118
  // then pass through the search param
113
119
  if (i + 1 === pathsToQuery.length) {
@@ -132,9 +138,13 @@ const subQueryOptions = {
132
138
  const operatorKey = operatorMap[formattedOperator];
133
139
  if (field.type === 'relationship' || field.type === 'upload') {
134
140
  let hasNumberIDRelation;
141
+ let multiIDCondition = '$or';
142
+ if (operatorKey === '$ne') {
143
+ multiIDCondition = '$and';
144
+ }
135
145
  const result = {
136
146
  value: {
137
- $or: [
147
+ [multiIDCondition]: [
138
148
  {
139
149
  [path]: {
140
150
  [operatorKey]: formattedValue
@@ -144,10 +154,10 @@ const subQueryOptions = {
144
154
  }
145
155
  };
146
156
  if (typeof formattedValue === 'string') {
147
- if (mongoose.Types.ObjectId.isValid(formattedValue)) {
148
- result.value.$or.push({
157
+ if (Types.ObjectId.isValid(formattedValue)) {
158
+ result.value[multiIDCondition].push({
149
159
  [path]: {
150
- [operatorKey]: new ObjectId(formattedValue)
160
+ [operatorKey]: new Types.ObjectId(formattedValue)
151
161
  }
152
162
  });
153
163
  } else {
@@ -159,14 +169,16 @@ const subQueryOptions = {
159
169
  hasNumberIDRelation = true;
160
170
  }
161
171
  });
162
- if (hasNumberIDRelation) result.value.$or.push({
163
- [path]: {
164
- [operatorKey]: parseFloat(formattedValue)
165
- }
166
- });
172
+ if (hasNumberIDRelation) {
173
+ result.value[multiIDCondition].push({
174
+ [path]: {
175
+ [operatorKey]: parseFloat(formattedValue)
176
+ }
177
+ });
178
+ }
167
179
  }
168
180
  }
169
- if (result.value.$or.length > 1) {
181
+ if (result.value[multiIDCondition].length > 1) {
170
182
  return result;
171
183
  }
172
184
  }