@payloadcms/db-mongodb 3.65.0-internal.ef3958a → 3.66.0-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/count.js +3 -3
  2. package/dist/count.js.map +1 -1
  3. package/dist/countGlobalVersions.js +3 -3
  4. package/dist/countGlobalVersions.js.map +1 -1
  5. package/dist/countVersions.js +3 -3
  6. package/dist/countVersions.js.map +1 -1
  7. package/dist/create.js +5 -5
  8. package/dist/create.js.map +1 -1
  9. package/dist/createGlobalVersion.js +5 -5
  10. package/dist/createGlobalVersion.js.map +1 -1
  11. package/dist/createVersion.js +5 -5
  12. package/dist/createVersion.js.map +1 -1
  13. package/dist/deleteMany.js +3 -3
  14. package/dist/deleteMany.js.map +1 -1
  15. package/dist/deleteOne.js +6 -6
  16. package/dist/deleteOne.js.map +1 -1
  17. package/dist/deleteVersions.js +1 -1
  18. package/dist/deleteVersions.js.map +1 -1
  19. package/dist/exports/internal.d.ts +2 -0
  20. package/dist/exports/internal.d.ts.map +1 -0
  21. package/dist/exports/internal.js +3 -0
  22. package/dist/exports/internal.js.map +1 -0
  23. package/dist/find.js +1 -1
  24. package/dist/find.js.map +1 -1
  25. package/dist/findDistinct.js +1 -1
  26. package/dist/findDistinct.js.map +1 -1
  27. package/dist/findGlobal.d.ts.map +1 -1
  28. package/dist/findGlobal.js +9 -9
  29. package/dist/findGlobal.js.map +1 -1
  30. package/dist/findGlobalVersions.js +6 -6
  31. package/dist/findGlobalVersions.js.map +1 -1
  32. package/dist/findOne.js +5 -5
  33. package/dist/findOne.js.map +1 -1
  34. package/dist/findVersions.js +6 -6
  35. package/dist/findVersions.js.map +1 -1
  36. package/dist/queryDrafts.d.ts.map +1 -1
  37. package/dist/queryDrafts.js +4 -3
  38. package/dist/queryDrafts.js.map +1 -1
  39. package/dist/transactions/commitTransaction.d.ts.map +1 -1
  40. package/dist/transactions/commitTransaction.js +12 -6
  41. package/dist/transactions/commitTransaction.js.map +1 -1
  42. package/dist/transactions/rollbackTransaction.d.ts.map +1 -1
  43. package/dist/transactions/rollbackTransaction.js +8 -10
  44. package/dist/transactions/rollbackTransaction.js.map +1 -1
  45. package/dist/updateGlobal.js +7 -7
  46. package/dist/updateGlobal.js.map +1 -1
  47. package/dist/updateGlobalVersion.d.ts.map +1 -1
  48. package/dist/updateGlobalVersion.js +12 -12
  49. package/dist/updateGlobalVersion.js.map +1 -1
  50. package/dist/updateJobs.js +7 -7
  51. package/dist/updateJobs.js.map +1 -1
  52. package/dist/updateMany.js +13 -13
  53. package/dist/updateMany.js.map +1 -1
  54. package/dist/updateOne.js +13 -13
  55. package/dist/updateOne.js.map +1 -1
  56. package/dist/updateVersion.js +12 -12
  57. package/dist/updateVersion.js.map +1 -1
  58. package/dist/utilities/getSession.d.ts.map +1 -1
  59. package/dist/utilities/getSession.js +14 -1
  60. package/dist/utilities/getSession.js.map +1 -1
  61. package/dist/utilities/transform.d.ts +4 -0
  62. package/dist/utilities/transform.d.ts.map +1 -1
  63. package/dist/utilities/transform.js +4 -1
  64. package/dist/utilities/transform.js.map +1 -1
  65. package/package.json +8 -3
@@ -27,19 +27,6 @@ export const updateMany = async function updateMany({ collection: collectionSlug
27
27
  timestamps: true
28
28
  });
29
29
  }
30
- const options = {
31
- ...optionsArgs,
32
- lean: true,
33
- new: true,
34
- projection: buildProjectionFromSelect({
35
- adapter: this,
36
- fields: collectionConfig.flattenedFields,
37
- select
38
- }),
39
- session: await getSession(this, req),
40
- // Timestamps are manually added by the write transform
41
- timestamps: false
42
- };
43
30
  let query = await buildQuery({
44
31
  adapter: this,
45
32
  collectionSlug,
@@ -78,6 +65,19 @@ export const updateMany = async function updateMany({ collection: collectionSlug
78
65
  updateOps.$set = data;
79
66
  data = updateOps;
80
67
  }
68
+ const options = {
69
+ ...optionsArgs,
70
+ lean: true,
71
+ new: true,
72
+ projection: buildProjectionFromSelect({
73
+ adapter: this,
74
+ fields: collectionConfig.flattenedFields,
75
+ select
76
+ }),
77
+ session: await getSession(this, req),
78
+ // Timestamps are manually added by the write transform
79
+ timestamps: false
80
+ };
81
81
  try {
82
82
  if (typeof limit === 'number' && limit > 0) {
83
83
  const documentsToUpdate = await Model.find(query, {}, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/updateMany.ts"],"sourcesContent":["import type { MongooseUpdateQueryOptions, UpdateQuery } from 'mongoose'\n\nimport { flattenWhereToOperators, type UpdateMany } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildSortParam } from './queries/buildSortParam.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getCollection } from './utilities/getEntity.js'\nimport { getSession } from './utilities/getSession.js'\nimport { handleError } from './utilities/handleError.js'\nimport { transform } from './utilities/transform.js'\n\nexport const updateMany: UpdateMany = async function updateMany(\n this: MongooseAdapter,\n {\n collection: collectionSlug,\n data,\n limit,\n locale,\n options: optionsArgs = {},\n req,\n returning,\n select,\n sort: sortArg,\n where,\n },\n) {\n let hasNearConstraint = false\n\n if (where) {\n const constraints = flattenWhereToOperators(where)\n hasNearConstraint = constraints.some((prop) => Object.keys(prop).some((key) => key === 'near'))\n }\n\n const { collectionConfig, Model } = getCollection({ adapter: this, collectionSlug })\n\n let sort: Record<string, unknown> | undefined\n if (!hasNearConstraint) {\n sort = buildSortParam({\n adapter: this,\n config: this.payload.config,\n fields: collectionConfig.flattenedFields,\n locale,\n sort: sortArg || collectionConfig.defaultSort,\n timestamps: true,\n })\n }\n\n const options: MongooseUpdateQueryOptions = {\n ...optionsArgs,\n lean: true,\n new: true,\n projection: buildProjectionFromSelect({\n adapter: this,\n fields: collectionConfig.flattenedFields,\n select,\n }),\n session: await getSession(this, req),\n // Timestamps are manually added by the write transform\n timestamps: false,\n }\n\n let query = await buildQuery({\n adapter: this,\n collectionSlug,\n fields: collectionConfig.flattenedFields,\n locale,\n where,\n })\n\n const $inc: Record<string, number> = {}\n const $push: Record<string, { $each: any[] } | any> = {}\n const $addToSet: Record<string, { $each: any[] } | any> = {}\n const $pull: Record<string, { $in: any[] } | any> = {}\n\n transform({\n $addToSet,\n $inc,\n $pull,\n $push,\n adapter: this,\n data,\n fields: collectionConfig.fields,\n operation: 'write',\n })\n\n const updateOps: UpdateQuery<any> = {}\n\n if (Object.keys($inc).length) {\n updateOps.$inc = $inc\n }\n if (Object.keys($push).length) {\n updateOps.$push = $push\n }\n if (Object.keys($addToSet).length) {\n updateOps.$addToSet = $addToSet\n }\n if (Object.keys($pull).length) {\n updateOps.$pull = $pull\n }\n if (Object.keys(updateOps).length) {\n updateOps.$set = data\n data = updateOps\n }\n\n try {\n if (typeof limit === 'number' && limit > 0) {\n const documentsToUpdate = await Model.find(\n query,\n {},\n { ...options, limit, projection: { _id: 1 }, sort },\n )\n if (documentsToUpdate.length === 0) {\n return null\n }\n\n query = { _id: { $in: documentsToUpdate.map((doc) => doc._id) } }\n }\n\n await Model.updateMany(query, data, options)\n } catch (error) {\n handleError({ collection: collectionSlug, error, req })\n }\n\n if (returning === false) {\n return null\n }\n\n const result = await Model.find(\n query,\n {},\n {\n ...options,\n sort,\n },\n )\n\n transform({\n adapter: this,\n data: result,\n fields: collectionConfig.fields,\n operation: 'read',\n })\n\n return result\n}\n"],"names":["flattenWhereToOperators","buildQuery","buildSortParam","buildProjectionFromSelect","getCollection","getSession","handleError","transform","updateMany","collection","collectionSlug","data","limit","locale","options","optionsArgs","req","returning","select","sort","sortArg","where","hasNearConstraint","constraints","some","prop","Object","keys","key","collectionConfig","Model","adapter","config","payload","fields","flattenedFields","defaultSort","timestamps","lean","new","projection","session","query","$inc","$push","$addToSet","$pull","operation","updateOps","length","$set","documentsToUpdate","find","_id","$in","map","doc","error","result"],"mappings":"AAEA,SAASA,uBAAuB,QAAyB,UAAS;AAIlE,SAASC,UAAU,QAAQ,0BAAyB;AACpD,SAASC,cAAc,QAAQ,8BAA6B;AAC5D,SAASC,yBAAyB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AEA,MAAMyC,SAAS,MAAM5B,MAAMsB,IAAI,CAC7BV,OACA,CAAC,GACD;QACE,GAAG5B,OAAO;QACVK;IACF;IAGFZ,UAAU;QACRwB,SAAS,IAAI;QACbpB,MAAM+C;QACNxB,QAAQL,iBAAiBK,MAAM;QAC/Ba,WAAW;IACb;IAEA,OAAOW;AACT,EAAC"}
1
+ {"version":3,"sources":["../src/updateMany.ts"],"sourcesContent":["import type { MongooseUpdateQueryOptions, UpdateQuery } from 'mongoose'\n\nimport { flattenWhereToOperators, type UpdateMany } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildSortParam } from './queries/buildSortParam.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getCollection } from './utilities/getEntity.js'\nimport { getSession } from './utilities/getSession.js'\nimport { handleError } from './utilities/handleError.js'\nimport { transform } from './utilities/transform.js'\n\nexport const updateMany: UpdateMany = async function updateMany(\n this: MongooseAdapter,\n {\n collection: collectionSlug,\n data,\n limit,\n locale,\n options: optionsArgs = {},\n req,\n returning,\n select,\n sort: sortArg,\n where,\n },\n) {\n let hasNearConstraint = false\n\n if (where) {\n const constraints = flattenWhereToOperators(where)\n hasNearConstraint = constraints.some((prop) => Object.keys(prop).some((key) => key === 'near'))\n }\n\n const { collectionConfig, Model } = getCollection({ adapter: this, collectionSlug })\n\n let sort: Record<string, unknown> | undefined\n if (!hasNearConstraint) {\n sort = buildSortParam({\n adapter: this,\n config: this.payload.config,\n fields: collectionConfig.flattenedFields,\n locale,\n sort: sortArg || collectionConfig.defaultSort,\n timestamps: true,\n })\n }\n\n let query = await buildQuery({\n adapter: this,\n collectionSlug,\n fields: collectionConfig.flattenedFields,\n locale,\n where,\n })\n\n const $inc: Record<string, number> = {}\n const $push: Record<string, { $each: any[] } | any> = {}\n const $addToSet: Record<string, { $each: any[] } | any> = {}\n const $pull: Record<string, { $in: any[] } | any> = {}\n\n transform({\n $addToSet,\n $inc,\n $pull,\n $push,\n adapter: this,\n data,\n fields: collectionConfig.fields,\n operation: 'write',\n })\n\n const updateOps: UpdateQuery<any> = {}\n\n if (Object.keys($inc).length) {\n updateOps.$inc = $inc\n }\n if (Object.keys($push).length) {\n updateOps.$push = $push\n }\n if (Object.keys($addToSet).length) {\n updateOps.$addToSet = $addToSet\n }\n if (Object.keys($pull).length) {\n updateOps.$pull = $pull\n }\n if (Object.keys(updateOps).length) {\n updateOps.$set = data\n data = updateOps\n }\n\n const options: MongooseUpdateQueryOptions = {\n ...optionsArgs,\n lean: true,\n new: true,\n projection: buildProjectionFromSelect({\n adapter: this,\n fields: collectionConfig.flattenedFields,\n select,\n }),\n session: await getSession(this, req),\n // Timestamps are manually added by the write transform\n timestamps: false,\n }\n\n try {\n if (typeof limit === 'number' && limit > 0) {\n const documentsToUpdate = await Model.find(\n query,\n {},\n { ...options, limit, projection: { _id: 1 }, sort },\n )\n if (documentsToUpdate.length === 0) {\n return null\n }\n\n query = { _id: { $in: documentsToUpdate.map((doc) => doc._id) } }\n }\n\n await Model.updateMany(query, data, options)\n } catch (error) {\n handleError({ collection: collectionSlug, error, req })\n }\n\n if (returning === false) {\n return null\n }\n\n const result = await Model.find(\n query,\n {},\n {\n ...options,\n sort,\n },\n )\n\n transform({\n adapter: this,\n data: result,\n fields: collectionConfig.fields,\n operation: 'read',\n })\n\n return result\n}\n"],"names":["flattenWhereToOperators","buildQuery","buildSortParam","buildProjectionFromSelect","getCollection","getSession","handleError","transform","updateMany","collection","collectionSlug","data","limit","locale","options","optionsArgs","req","returning","select","sort","sortArg","where","hasNearConstraint","constraints","some","prop","Object","keys","key","collectionConfig","Model","adapter","config","payload","fields","flattenedFields","defaultSort","timestamps","query","$inc","$push","$addToSet","$pull","operation","updateOps","length","$set","lean","new","projection","session","documentsToUpdate","find","_id","$in","map","doc","error","result"],"mappings":"AAEA,SAASA,uBAAuB,QAAyB,UAAS;AAIlE,SAASC,UAAU,QAAQ,0BAAyB;AACp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;IAEA,IAAIC,cAAc,OAAO;QACvB,OAAO;IACT;IAEA,MAAMyC,SAAS,MAAM5B,MAAMsB,IAAI,CAC7Bd,OACA,CAAC,GACD;QACE,GAAGxB,OAAO;QACVK;IACF;IAGFZ,UAAU;QACRwB,SAAS,IAAI;QACbpB,MAAM+C;QACNxB,QAAQL,iBAAiBK,MAAM;QAC/BS,WAAW;IACb;IAEA,OAAOe;AACT,EAAC"}
package/dist/updateOne.js CHANGED
@@ -15,19 +15,6 @@ export const updateOne = async function updateOne({ id, collection: collectionSl
15
15
  }
16
16
  } : whereArg;
17
17
  const fields = collectionConfig.fields;
18
- const options = {
19
- ...optionsArgs,
20
- lean: true,
21
- new: true,
22
- projection: buildProjectionFromSelect({
23
- adapter: this,
24
- fields: collectionConfig.flattenedFields,
25
- select
26
- }),
27
- session: await getSession(this, req),
28
- // Timestamps are manually added by the write transform
29
- timestamps: false
30
- };
31
18
  const query = await buildQuery({
32
19
  adapter: this,
33
20
  collectionSlug,
@@ -68,6 +55,19 @@ export const updateOne = async function updateOne({ id, collection: collectionSl
68
55
  updateOps.$set = updateData;
69
56
  updateData = updateOps;
70
57
  }
58
+ const options = {
59
+ ...optionsArgs,
60
+ lean: true,
61
+ new: true,
62
+ projection: buildProjectionFromSelect({
63
+ adapter: this,
64
+ fields: collectionConfig.flattenedFields,
65
+ select
66
+ }),
67
+ session: await getSession(this, req),
68
+ // Timestamps are manually added by the write transform
69
+ timestamps: false
70
+ };
71
71
  try {
72
72
  if (returning === false) {
73
73
  await Model.updateOne(query, updateData, options);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/updateOne.ts"],"sourcesContent":["import type { MongooseUpdateQueryOptions, UpdateQuery } from 'mongoose'\nimport type { UpdateOne } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getCollection } from './utilities/getEntity.js'\nimport { getSession } from './utilities/getSession.js'\nimport { handleError } from './utilities/handleError.js'\nimport { transform } from './utilities/transform.js'\n\nexport const updateOne: UpdateOne = async function updateOne(\n this: MongooseAdapter,\n {\n id,\n collection: collectionSlug,\n data,\n locale,\n options: optionsArgs = {},\n req,\n returning,\n select,\n where: whereArg = {},\n },\n) {\n const { collectionConfig, Model } = getCollection({ adapter: this, collectionSlug })\n const where = id ? { id: { equals: id } } : whereArg\n const fields = collectionConfig.fields\n\n const options: MongooseUpdateQueryOptions = {\n ...optionsArgs,\n lean: true,\n new: true,\n projection: buildProjectionFromSelect({\n adapter: this,\n fields: collectionConfig.flattenedFields,\n select,\n }),\n session: await getSession(this, req),\n // Timestamps are manually added by the write transform\n timestamps: false,\n }\n\n const query = await buildQuery({\n adapter: this,\n collectionSlug,\n fields: collectionConfig.flattenedFields,\n locale,\n where,\n })\n\n let result\n\n let updateData: UpdateQuery<any> = data\n\n const $inc: Record<string, number> = {}\n const $push: Record<string, { $each: any[] } | any> = {}\n const $addToSet: Record<string, { $each: any[] } | any> = {}\n const $pull: Record<string, { $in: any[] } | any> = {}\n\n transform({\n $addToSet,\n $inc,\n $pull,\n $push,\n adapter: this,\n data,\n fields,\n operation: 'write',\n })\n\n const updateOps: UpdateQuery<any> = {}\n\n if (Object.keys($inc).length) {\n updateOps.$inc = $inc\n }\n if (Object.keys($push).length) {\n updateOps.$push = $push\n }\n if (Object.keys($addToSet).length) {\n updateOps.$addToSet = $addToSet\n }\n if (Object.keys($pull).length) {\n updateOps.$pull = $pull\n }\n if (Object.keys(updateOps).length) {\n updateOps.$set = updateData\n updateData = updateOps\n }\n\n try {\n if (returning === false) {\n await Model.updateOne(query, updateData, options)\n transform({ adapter: this, data, fields, operation: 'read' })\n return null\n } else {\n result = await Model.findOneAndUpdate(query, updateData, options)\n }\n } catch (error) {\n handleError({ collection: collectionSlug, error, req })\n }\n\n if (!result) {\n return null\n }\n\n transform({ adapter: this, data: result, fields, operation: 'read' })\n\n return result\n}\n"],"names":["buildQuery","buildProjectionFromSelect","getCollection","getSession","handleError","transform","updateOne","id","collection","collectionSlug","data","locale","options","optionsArgs","req","returning","select","where","whereArg","collectionConfig","Model","adapter","equals","fields","lean","new","projection","flattenedFields","session","timestamps","query","result","updateData","$inc","$push","$addToSet","$pull","operation","updateOps","Object","keys","length","$set","findOneAndUpdate","error"],"mappings":"AAKA,SAASA,UAAU,QAAQ,0BAAyB;AACpD,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,aAAa,QAAQ,2BAA0B;AACxD,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,WAAW,QAAQ,6BAA4B;AACxD,SAASC,SAAS,QAAQ,2BAA0B;AAEpD,OAAO,MAAMC,YAAuB,eAAeA,UAEjD,EACEC,EAAE,EACFC,YAAYC,cAAc,EAC1BC,IAAI,EACJC,MAAM,EACNC,SAASC,cAAc,CAAC,CAAC,EACzBC,GAAG,EACHC,SAAS,EACTC,MAAM,EACNC,OAAOC,WAAW,CAAC,CAAC,EACrB;IAED,MAAM,EAAEC,gBAAgB,EAAEC,KAAK,EAAE,GAAGlB,cAAc;QAAEmB,SAAS,IAAI;QAAEZ;IAAe;IAClF,MAAMQ,QAAQV,KAAK;QAAEA,IAAI;YAAEe,QAAQf;QAAG;IAAE,IAAIW;IAC5C,MAAMK,SAASJ,iBAAiBI,MAAM;IAEtC,MAAMX,UAAsC;QAC1C,GAAGC,WAAW;QACdW,MAAM;QACNC,KAAK;QACLC,YAAYzB,0BAA0B;YACpCoB,SAAS,IAAI;YACbE,QAAQJ,iBAAiBQ,eAAe;YACxCX;QACF;QACAY,SAAS,MAAMzB,WAAW,IAAI,EAAEW;QAChC,uDAAuD;QACvDe,YAAY;IACd;IAEA,MAAMC,QAAQ,MAAM9B,WAAW;QAC7BqB,SAAS,IAAI;QACbZ;QACAc,QAAQJ,iBAAiBQ,eAAe;QACxChB;QACAM;IACF;IAEA,IAAIc;IAEJ,IAAIC,aAA+BtB;IAEnC,MAAMuB,OAA+B,CAAC;IACtC,MAAMC,QAAgD,CAAC;IACvD,MAAMC,YAAoD,CAAC;IAC3D,MAAMC,QAA8C,CAAC;IAErD/B,UAAU;QACR8B;QACAF;QACAG;QACAF;QACAb,SAAS,IAAI;QACbX;QACAa;QACAc,WAAW;IACb;IAEA,MAAMC,YAA8B,CAAC;IAErC,IAAIC,OAAOC,IAAI,CAACP,MAAMQ,MAAM,EAAE;QAC5BH,UAAUL,IAAI,GAAGA;IACnB;IACA,IAAIM,OAAOC,IAAI,CAACN,OAAOO,MAAM,EAAE;QAC7BH,UAAUJ,KAAK,GAAGA;IACpB;IACA,IAAIK,OAAOC,IAAI,CAACL,WAAWM,MAAM,EAAE;QACjCH,UAAUH,SAAS,GAAGA;IACxB;IACA,IAAII,OAAOC,IAAI,CAACJ,OAAOK,MAAM,EAAE;QAC7BH,UAAUF,KAAK,GAAGA;IACpB;IACA,IAAIG,OAAOC,IAAI,CAACF,WAAWG,MAAM,EAAE;QACjCH,UAAUI,IAAI,GAAGV;QACjBA,aAAaM;IACf;IAEA,IAAI;QACF,IAAIvB,cAAc,OAAO;YACvB,MAAMK,MAAMd,SAAS,CAACwB,OAAOE,YAAYpB;YACzCP,UAAU;gBAAEgB,SAAS,IAAI;gBAAEX;gBAAMa;gBAAQc,WAAW;YAAO;YAC3D,OAAO;QACT,OAAO;YACLN,SAAS,MAAMX,MAAMuB,gBAAgB,CAACb,OAAOE,YAAYpB;QAC3D;IACF,EAAE,OAAOgC,OAAO;QACdxC,YAAY;YAAEI,YAAYC;YAAgBmC;YAAO9B;QAAI;IACvD;IAEA,IAAI,CAACiB,QAAQ;QACX,OAAO;IACT;IAEA1B,UAAU;QAAEgB,SAAS,IAAI;QAAEX,MAAMqB;QAAQR;QAAQc,WAAW;IAAO;IAEnE,OAAON;AACT,EAAC"}
1
+ {"version":3,"sources":["../src/updateOne.ts"],"sourcesContent":["import type { MongooseUpdateQueryOptions, UpdateQuery } from 'mongoose'\nimport type { UpdateOne } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getCollection } from './utilities/getEntity.js'\nimport { getSession } from './utilities/getSession.js'\nimport { handleError } from './utilities/handleError.js'\nimport { transform } from './utilities/transform.js'\n\nexport const updateOne: UpdateOne = async function updateOne(\n this: MongooseAdapter,\n {\n id,\n collection: collectionSlug,\n data,\n locale,\n options: optionsArgs = {},\n req,\n returning,\n select,\n where: whereArg = {},\n },\n) {\n const { collectionConfig, Model } = getCollection({ adapter: this, collectionSlug })\n const where = id ? { id: { equals: id } } : whereArg\n const fields = collectionConfig.fields\n\n const query = await buildQuery({\n adapter: this,\n collectionSlug,\n fields: collectionConfig.flattenedFields,\n locale,\n where,\n })\n\n let result\n\n let updateData: UpdateQuery<any> = data\n\n const $inc: Record<string, number> = {}\n const $push: Record<string, { $each: any[] } | any> = {}\n const $addToSet: Record<string, { $each: any[] } | any> = {}\n const $pull: Record<string, { $in: any[] } | any> = {}\n\n transform({\n $addToSet,\n $inc,\n $pull,\n $push,\n adapter: this,\n data,\n fields,\n operation: 'write',\n })\n\n const updateOps: UpdateQuery<any> = {}\n\n if (Object.keys($inc).length) {\n updateOps.$inc = $inc\n }\n if (Object.keys($push).length) {\n updateOps.$push = $push\n }\n if (Object.keys($addToSet).length) {\n updateOps.$addToSet = $addToSet\n }\n if (Object.keys($pull).length) {\n updateOps.$pull = $pull\n }\n if (Object.keys(updateOps).length) {\n updateOps.$set = updateData\n updateData = updateOps\n }\n\n const options: MongooseUpdateQueryOptions = {\n ...optionsArgs,\n lean: true,\n new: true,\n projection: buildProjectionFromSelect({\n adapter: this,\n fields: collectionConfig.flattenedFields,\n select,\n }),\n session: await getSession(this, req),\n // Timestamps are manually added by the write transform\n timestamps: false,\n }\n\n try {\n if (returning === false) {\n await Model.updateOne(query, updateData, options)\n transform({ adapter: this, data, fields, operation: 'read' })\n return null\n } else {\n result = await Model.findOneAndUpdate(query, updateData, options)\n }\n } catch (error) {\n handleError({ collection: collectionSlug, error, req })\n }\n\n if (!result) {\n return null\n }\n\n transform({ adapter: this, data: result, fields, operation: 'read' })\n\n return result\n}\n"],"names":["buildQuery","buildProjectionFromSelect","getCollection","getSession","handleError","transform","updateOne","id","collection","collectionSlug","data","locale","options","optionsArgs","req","returning","select","where","whereArg","collectionConfig","Model","adapter","equals","fields","query","flattenedFields","result","updateData","$inc","$push","$addToSet","$pull","operation","updateOps","Object","keys","length","$set","lean","new","projection","session","timestamps","findOneAndUpdate","error"],"mappings":"AAKA,SAASA,UAAU,QAAQ,0BAAyB;AACpD,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,aAAa,QAAQ,2BAA0B;AACxD,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,WAAW,QAAQ,6BAA4B;AACxD,SAASC,SAAS,QAAQ,2BAA0B;AAEpD,OAAO,MAAMC,YAAuB,eAAeA,UAEjD,EACEC,EAAE,EACFC,YAAYC,cAAc,EAC1BC,IAAI,EACJC,MAAM,EACNC,SAASC,cAAc,CAAC,CAAC,EACzBC,GAAG,EACHC,SAAS,EACTC,MAAM,EACNC,OAAOC,WAAW,CAAC,CAAC,EACrB;IAED,MAAM,EAAEC,gBAAgB,EAAEC,KAAK,EAAE,GAAGlB,cAAc;QAAEmB,SAAS,IAAI;QAAEZ;IAAe;IAClF,MAAMQ,QAAQV,KAAK;QAAEA,IAAI;YAAEe,QAAQf;QAAG;IAAE,IAAIW;IAC5C,MAAMK,SAASJ,iBAAiBI,MAAM;IAEtC,MAAMC,QAAQ,MAAMxB,WAAW;QAC7BqB,SAAS,IAAI;QACbZ;QACAc,QAAQJ,iBAAiBM,eAAe;QACxCd;QACAM;IACF;IAEA,IAAIS;IAEJ,IAAIC,aAA+BjB;IAEnC,MAAMkB,OAA+B,CAAC;IACtC,MAAMC,QAAgD,CAAC;IACvD,MAAMC,YAAoD,CAAC;IAC3D,MAAMC,QAA8C,CAAC;IAErD1B,UA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ACT,EAAC"}
@@ -17,6 +17,18 @@ export const updateVersion = async function updateVersion({ id, collection: coll
17
17
  };
18
18
  const fields = buildVersionCollectionFields(this.payload.config, collectionConfig);
19
19
  const flattenedFields = buildVersionCollectionFields(this.payload.config, collectionConfig, true);
20
+ const query = await buildQuery({
21
+ adapter: this,
22
+ fields: flattenedFields,
23
+ locale,
24
+ where: whereToUse
25
+ });
26
+ transform({
27
+ adapter: this,
28
+ data: versionData,
29
+ fields,
30
+ operation: 'write'
31
+ });
20
32
  const options = {
21
33
  ...optionsArgs,
22
34
  lean: true,
@@ -30,18 +42,6 @@ export const updateVersion = async function updateVersion({ id, collection: coll
30
42
  // Timestamps are manually added by the write transform
31
43
  timestamps: false
32
44
  };
33
- const query = await buildQuery({
34
- adapter: this,
35
- fields: flattenedFields,
36
- locale,
37
- where: whereToUse
38
- });
39
- transform({
40
- adapter: this,
41
- data: versionData,
42
- fields,
43
- operation: 'write'
44
- });
45
45
  if (returning === false) {
46
46
  await Model.updateOne(query, versionData, options);
47
47
  return null;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/updateVersion.ts"],"sourcesContent":["import type { MongooseUpdateQueryOptions } from 'mongoose'\n\nimport { buildVersionCollectionFields, type UpdateVersion } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getCollection } from './utilities/getEntity.js'\nimport { getSession } from './utilities/getSession.js'\nimport { transform } from './utilities/transform.js'\n\nexport const updateVersion: UpdateVersion = async function updateVersion(\n this: MongooseAdapter,\n {\n id,\n collection: collectionSlug,\n locale,\n options: optionsArgs = {},\n req,\n returning,\n select,\n versionData,\n where,\n },\n) {\n const { collectionConfig, Model } = getCollection({\n adapter: this,\n collectionSlug,\n versions: true,\n })\n\n const whereToUse = where || { id: { equals: id } }\n const fields = buildVersionCollectionFields(this.payload.config, collectionConfig)\n\n const flattenedFields = buildVersionCollectionFields(this.payload.config, collectionConfig, true)\n\n const options: MongooseUpdateQueryOptions = {\n ...optionsArgs,\n lean: true,\n new: true,\n projection: buildProjectionFromSelect({\n adapter: this,\n fields: flattenedFields,\n select,\n }),\n session: await getSession(this, req),\n // Timestamps are manually added by the write transform\n timestamps: false,\n }\n\n const query = await buildQuery({\n adapter: this,\n fields: flattenedFields,\n locale,\n where: whereToUse,\n })\n\n transform({ adapter: this, data: versionData, fields, operation: 'write' })\n\n if (returning === false) {\n await Model.updateOne(query, versionData, options)\n return null\n }\n\n const doc = await Model.findOneAndUpdate(query, versionData, options)\n\n if (!doc) {\n return null\n }\n\n transform({ adapter: this, data: doc, fields, operation: 'read' })\n\n return doc\n}\n"],"names":["buildVersionCollectionFields","buildQuery","buildProjectionFromSelect","getCollection","getSession","transform","updateVersion","id","collection","collectionSlug","locale","options","optionsArgs","req","returning","select","versionData","where","collectionConfig","Model","adapter","versions","whereToUse","equals","fields","payload","config","flattenedFields","lean","new","projection","session","timestamps","query","data","operation","updateOne","doc","findOneAndUpdate"],"mappings":"AAEA,SAASA,4BAA4B,QAA4B,UAAS;AAI1E,SAASC,UAAU,QAAQ,0BAAyB;AACpD,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,aAAa,QAAQ,2BAA0B;AACxD,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,SAAS,QAAQ,2BAA0B;AAEpD,OAAO,MAAMC,gBAA+B,eAAeA,cAEzD,EACEC,EAAE,EACFC,YAAYC,cAAc,EAC1BC,MAAM,EACNC,SAASC,cAAc,CAAC,CAAC,EACzBC,GAAG,EACHC,SAAS,EACTC,MAAM,EACNC,WAAW,EACXC,KAAK,EACN;IAED,MAAM,EAAEC,gBAAgB,EAAEC,KAAK,EAAE,GAAGhB,cAAc;QAChDiB,SAAS,IAAI;QACbX;QACAY,UAAU;IACZ;IAEA,MAAMC,aAAaL,SAAS;QAAEV,IAAI;YAAEgB,QAAQhB;QAAG;IAAE;IACjD,MAAMiB,SAASxB,6BAA6B,IAAI,CAACyB,OAAO,CAACC,MAAM,EAAER;IAEjE,MAAMS,kBAAkB3B,6BAA6B,IAAI,CAACyB,OAAO,CAACC,MAAM,EAAER,kBAAkB;IAE5F,MAAMP,UAAsC;QAC1C,GAAGC,WAAW;QACdgB,MAAM;QACNC,KAAK;QACLC,YAAY5B,0BAA0B;YACpCkB,SAAS,IAAI;YACbI,QAAQG;YACRZ;QACF;QACAgB,SAAS,MAAM3B,WAAW,IAAI,EAAES;QAChC,uDAAuD;QACvDmB,YAAY;IACd;IAEA,MAAMC,QAAQ,MAAMhC,WAAW;QAC7BmB,SAAS,IAAI;QACbI,QAAQG;QACRjB;QACAO,OAAOK;IACT;IAEAjB,UAAU;QAAEe,SAAS,IAAI;QAAEc,MAAMlB;QAAaQ;QAAQW,WAAW;IAAQ;IAEzE,IAAIrB,cAAc,OAAO;QACvB,MAAMK,MAAMiB,SAAS,CAACH,OAAOjB,aAAaL;QAC1C,OAAO;IACT;IAEA,MAAM0B,MAAM,MAAMlB,MAAMmB,gBAAgB,CAACL,OAAOjB,aAAaL;IAE7D,IAAI,CAAC0B,KAAK;QACR,OAAO;IACT;IAEAhC,UAAU;QAAEe,SAAS,IAAI;QAAEc,MAAMG;QAAKb;QAAQW,WAAW;IAAO;IAEhE,OAAOE;AACT,EAAC"}
1
+ {"version":3,"sources":["../src/updateVersion.ts"],"sourcesContent":["import type { MongooseUpdateQueryOptions } from 'mongoose'\n\nimport { buildVersionCollectionFields, type UpdateVersion } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getCollection } from './utilities/getEntity.js'\nimport { getSession } from './utilities/getSession.js'\nimport { transform } from './utilities/transform.js'\n\nexport const updateVersion: UpdateVersion = async function updateVersion(\n this: MongooseAdapter,\n {\n id,\n collection: collectionSlug,\n locale,\n options: optionsArgs = {},\n req,\n returning,\n select,\n versionData,\n where,\n },\n) {\n const { collectionConfig, Model } = getCollection({\n adapter: this,\n collectionSlug,\n versions: true,\n })\n\n const whereToUse = where || { id: { equals: id } }\n const fields = buildVersionCollectionFields(this.payload.config, collectionConfig)\n\n const flattenedFields = buildVersionCollectionFields(this.payload.config, collectionConfig, true)\n\n const query = await buildQuery({\n adapter: this,\n fields: flattenedFields,\n locale,\n where: whereToUse,\n })\n\n transform({ adapter: this, data: versionData, fields, operation: 'write' })\n\n const options: MongooseUpdateQueryOptions = {\n ...optionsArgs,\n lean: true,\n new: true,\n projection: buildProjectionFromSelect({\n adapter: this,\n fields: flattenedFields,\n select,\n }),\n session: await getSession(this, req),\n // Timestamps are manually added by the write transform\n timestamps: false,\n }\n\n if (returning === false) {\n await Model.updateOne(query, versionData, options)\n return null\n }\n\n const doc = await Model.findOneAndUpdate(query, versionData, options)\n\n if (!doc) {\n return null\n }\n\n transform({ adapter: this, data: doc, fields, operation: 'read' })\n\n return doc\n}\n"],"names":["buildVersionCollectionFields","buildQuery","buildProjectionFromSelect","getCollection","getSession","transform","updateVersion","id","collection","collectionSlug","locale","options","optionsArgs","req","returning","select","versionData","where","collectionConfig","Model","adapter","versions","whereToUse","equals","fields","payload","config","flattenedFields","query","data","operation","lean","new","projection","session","timestamps","updateOne","doc","findOneAndUpdate"],"mappings":"AAEA,SAASA,4BAA4B,QAA4B,UAAS;AAI1E,SAASC,UAAU,QAAQ,0BAAyB;AACpD,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,aAAa,QAAQ,2BAA0B;AACxD,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,SAAS,QAAQ,2BAA0B;AAEpD,OAAO,MAAMC,gBAA+B,eAAeA,cAEzD,EACEC,EAAE,EACFC,YAAYC,cAAc,EAC1BC,MAAM,EACNC,SAASC,cAAc,CAAC,CAAC,EACzBC,GAAG,EACHC,SAAS,EACTC,MAAM,EACNC,WAAW,EACXC,KAAK,EACN;IAED,MAAM,EAAEC,gBAAg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,CAAA;AAElD;;;GAGG;AACH,wBAAsB,UAAU,CAC9B,EAAE,EAAE,eAAe,EACnB,GAAG,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAC5B,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAcpC"}
1
+ {"version":3,"file":"getSession.d.ts","sourceRoot":"","sources":["../../src/utilities/getSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAElD;;;GAGG;AACH,wBAAsB,UAAU,CAC9B,EAAE,EAAE,eAAe,EACnB,GAAG,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAC5B,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CA6BpC"}
@@ -10,7 +10,20 @@
10
10
  transactionID = await req.transactionID;
11
11
  }
12
12
  if (transactionID) {
13
- return db.sessions[transactionID];
13
+ const session = db.sessions[transactionID];
14
+ // Defensive check for race conditions where:
15
+ // 1. Session was retrieved from db.sessions
16
+ // 2. Another operation committed/rolled back and ended the session
17
+ // 3. This operation tries to use the now-ended session
18
+ // Note: This shouldn't normally happen as sessions are deleted from db.sessions
19
+ // after commit/rollback, but can occur due to async timing where we hold
20
+ // a reference to a session object that gets ended before we use it.
21
+ if (session && !session.inTransaction()) {
22
+ // Clean up the orphaned session reference
23
+ delete db.sessions[transactionID];
24
+ return undefined;
25
+ }
26
+ return session;
14
27
  }
15
28
  }
16
29
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/getSession.ts"],"sourcesContent":["import type { ClientSession } from 'mongoose'\nimport type { PayloadRequest } from 'payload'\n\nimport type { MongooseAdapter } from '../index.js'\n\n/**\n * returns the session belonging to the transaction of the req.session if exists\n * @returns ClientSession\n */\nexport async function getSession(\n db: MongooseAdapter,\n req?: Partial<PayloadRequest>,\n): Promise<ClientSession | undefined> {\n if (!req) {\n return\n }\n\n let transactionID = req.transactionID\n\n if (transactionID instanceof Promise) {\n transactionID = await req.transactionID\n }\n\n if (transactionID) {\n return db.sessions[transactionID]\n }\n}\n"],"names":["getSession","db","req","transactionID","Promise","sessions"],"mappings":"AAKA;;;CAGC,GACD,OAAO,eAAeA,WACpBC,EAAmB,EACnBC,GAA6B;IAE7B,IAAI,CAACA,KAAK;QACR;IACF;IAEA,IAAIC,gBAAgBD,IAAIC,aAAa;IAErC,IAAIA,yBAAyBC,SAAS;QACpCD,gBAAgB,MAAMD,IAAIC,aAAa;IACzC;IAEA,IAAIA,eAAe;QACjB,OAAOF,GAAGI,QAAQ,CAACF,cAAc;IACnC;AACF"}
1
+ {"version":3,"sources":["../../src/utilities/getSession.ts"],"sourcesContent":["import type { ClientSession } from 'mongoose'\nimport type { PayloadRequest } from 'payload'\n\nimport type { MongooseAdapter } from '../index.js'\n\n/**\n * returns the session belonging to the transaction of the req.session if exists\n * @returns ClientSession\n */\nexport async function getSession(\n db: MongooseAdapter,\n req?: Partial<PayloadRequest>,\n): Promise<ClientSession | undefined> {\n if (!req) {\n return\n }\n\n let transactionID = req.transactionID\n\n if (transactionID instanceof Promise) {\n transactionID = await req.transactionID\n }\n\n if (transactionID) {\n const session = db.sessions[transactionID]\n\n // Defensive check for race conditions where:\n // 1. Session was retrieved from db.sessions\n // 2. Another operation committed/rolled back and ended the session\n // 3. This operation tries to use the now-ended session\n // Note: This shouldn't normally happen as sessions are deleted from db.sessions\n // after commit/rollback, but can occur due to async timing where we hold\n // a reference to a session object that gets ended before we use it.\n if (session && !session.inTransaction()) {\n // Clean up the orphaned session reference\n delete db.sessions[transactionID]\n return undefined\n }\n\n return session\n }\n}\n"],"names":["getSession","db","req","transactionID","Promise","session","sessions","inTransaction","undefined"],"mappings":"AAKA;;;CAGC,GACD,OAAO,eAAeA,WACpBC,EAAmB,EACnBC,GAA6B;IAE7B,IAAI,CAACA,KAAK;QACR;IACF;IAEA,IAAIC,gBAAgBD,IAAIC,aAAa;IAErC,IAAIA,yBAAyBC,SAAS;QACpCD,gBAAgB,MAAMD,IAAIC,aAAa;IACzC;IAEA,IAAIA,eAAe;QACjB,MAAME,UAAUJ,GAAGK,QAAQ,CAACH,cAAc;QAE1C,6CAA6C;QAC7C,4CAA4C;QAC5C,mEAAmE;QACnE,uDAAuD;QACvD,gFAAgF;QAChF,yEAAyE;QACzE,oEAAoE;QACpE,IAAIE,WAAW,CAACA,QAAQE,aAAa,IAAI;YACvC,0CAA0C;YAC1C,OAAON,GAAGK,QAAQ,CAACH,cAAc;YACjC,OAAOK;QACT;QAEA,OAAOH;IACT;AACF"}
@@ -32,6 +32,10 @@ type Args = {
32
32
  */
33
33
  validateRelationships?: boolean;
34
34
  };
35
+ /**
36
+ * A function that transforms Payload <-> MongoDB data.
37
+ * @internal - this function may be removed or receive breaking changes in minor releases.
38
+ */
35
39
  export declare const transform: ({ $addToSet, $inc, $pull, $push, adapter, data, fields, globalSlug, operation, parentIsLocalized, validateRelationships, }: Args) => null | undefined;
36
40
  export {};
37
41
  //# sourceMappingURL=transform.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../src/utilities/transform.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,KAAK,EAQN,MAAM,SAAS,CAAA;AAMhB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAmQlD,KAAK,IAAI,GAAG;IACV,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,GAAG,EAAE,CAAA;KAAE,GAAG,GAAG,CAAC,CAAA;IAClD,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,GAAG,EAAE,CAAA;KAAE,GAAG,GAAG,CAAC,CAAA;IA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A8B;IAC9B,OAAO,EAAE,eAAe,CAAA;IACxB,2EAA2E;IAC3E,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IACzD,uCAAuC;IACvC,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;;OAIG;IACH,SAAS,EAAE,MAAM,GAAG,OAAO,CAAA;IAC3B,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B;;;OAGG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC,CAAA;AAmMD;;;GAGG;AACH,eAAO,MAAM,SAAS,+HAYnB,IAAI,qBA6XN,CAAA"}
@@ -315,7 +315,10 @@ const stripFields = ({ config, data, fields, parentIsLocalized = false, reserved
315
315
  }
316
316
  }
317
317
  };
318
- export const transform = ({ $addToSet, $inc, $pull, $push, adapter, data, fields, globalSlug, operation, parentIsLocalized = false, validateRelationships = true })=>{
318
+ /**
319
+ * A function that transforms Payload <-> MongoDB data.
320
+ * @internal - this function may be removed or receive breaking changes in minor releases.
321
+ */ export const transform = ({ $addToSet, $inc, $pull, $push, adapter, data, fields, globalSlug, operation, parentIsLocalized = false, validateRelationships = true })=>{
319
322
  if (!data) {
320
323
  return null;
321
324
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/transform.ts"],"sourcesContent":["import type {\n CollectionConfig,\n DateField,\n Field,\n FlattenedBlock,\n FlattenedField,\n JoinField,\n RelationshipField,\n SanitizedConfig,\n TraverseFieldsCallback,\n UploadField,\n} from 'payload'\n\nimport { Types } from 'mongoose'\nimport { flattenAllFields, traverseFields } from 'payload'\nimport { fieldAffectsData, fieldShouldBeLocalized } from 'payload/shared'\n\nimport type { MongooseAdapter } from '../index.js'\n\nimport { isObjectID } from './isObjectID.js'\n\ninterface RelationObject {\n relationTo: string\n value: number | string\n}\n\nfunction isValidRelationObject(value: unknown): value is RelationObject {\n return typeof value === 'object' && value !== null && 'relationTo' in value && 'value' in value\n}\n\n/**\n * Process relationship values for polymorphic and simple relationships\n * Used by both $push and $remove operations\n */\nconst processRelationshipValues = (\n items: unknown[],\n field: RelationshipField | UploadField,\n config: SanitizedConfig,\n operation: 'read' | 'write',\n validateRelationships: boolean,\n adapter: MongooseAdapter,\n) => {\n return items.map((item) => {\n // Handle polymorphic relationships\n if (Array.isArray(field.relationTo) && isValidRelationObject(item)) {\n const relatedCollection = config.collections?.find(({ slug }) => slug === item.relationTo)\n if (relatedCollection) {\n return {\n relationTo: item.relationTo,\n value: convertRelationshipValue({\n adapter,\n operation,\n relatedCollection,\n validateRelationships,\n value: item.value,\n }),\n }\n }\n return item\n }\n\n // Handle simple relationships\n if (typeof field.relationTo === 'string') {\n const relatedCollection = config.collections?.find(({ slug }) => slug === field.relationTo)\n if (relatedCollection) {\n return convertRelationshipValue({\n adapter,\n operation,\n relatedCollection,\n validateRelationships,\n value: item,\n })\n }\n }\n\n return item\n })\n}\n\nconst convertRelationshipValue = ({\n adapter,\n operation,\n relatedCollection,\n validateRelationships,\n value,\n}: {\n adapter: MongooseAdapter\n operation: Args['operation']\n relatedCollection: CollectionConfig\n validateRelationships?: boolean\n value: unknown\n}) => {\n const customIDField = relatedCollection.fields.find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n )\n\n if (operation === 'read') {\n if (isObjectID(value)) {\n return value.toHexString()\n }\n\n if (\n customIDField?.type === 'number' &&\n typeof value === 'bigint' &&\n adapter.useBigIntForNumberIDs\n ) {\n return Number(value)\n }\n\n return value\n }\n\n if (customIDField) {\n return value\n }\n\n if (typeof value === 'string') {\n try {\n return new Types.ObjectId(value)\n } catch (e) {\n if (validateRelationships) {\n throw e\n }\n return value\n }\n }\n\n return value\n}\n\nconst sanitizeRelationship = ({\n adapter,\n config,\n field,\n locale,\n operation,\n ref,\n validateRelationships,\n value,\n}: {\n adapter: MongooseAdapter\n config: SanitizedConfig\n field: JoinField | RelationshipField | UploadField\n locale?: string\n operation: Args['operation']\n ref: Record<string, unknown>\n validateRelationships?: boolean\n value?: unknown\n}) => {\n if (field.type === 'join') {\n if (\n operation === 'read' &&\n value &&\n typeof value === 'object' &&\n 'docs' in value &&\n Array.isArray(value.docs)\n ) {\n for (let i = 0; i < value.docs.length; i++) {\n const item = value.docs[i]\n\n if (isObjectID(item)) {\n value.docs[i] = item.toHexString()\n } else if (Array.isArray(field.collection) && item) {\n // Fields here for polymorphic joins cannot be determinted, JSON.parse needed\n value.docs[i] = JSON.parse(JSON.stringify(value.docs[i]))\n }\n }\n }\n\n return value\n }\n let relatedCollection: CollectionConfig | undefined\n let result = value\n\n const hasManyRelations = typeof field.relationTo !== 'string'\n\n if (!hasManyRelations) {\n relatedCollection = config.collections?.find(({ slug }) => slug === field.relationTo)\n }\n\n if (Array.isArray(value)) {\n result = value.map((val) => {\n // Handle has many - polymorphic\n if (isValidRelationObject(val)) {\n const relatedCollectionForSingleValue = config.collections?.find(\n ({ slug }) => slug === val.relationTo,\n )\n\n if (relatedCollectionForSingleValue) {\n return {\n relationTo: val.relationTo,\n value: convertRelationshipValue({\n adapter,\n operation,\n relatedCollection: relatedCollectionForSingleValue,\n validateRelationships,\n value: val.value,\n }),\n }\n }\n }\n\n if (relatedCollection) {\n return convertRelationshipValue({\n adapter,\n operation,\n relatedCollection,\n validateRelationships,\n value: val,\n })\n }\n\n return val\n })\n }\n // Handle has one - polymorphic\n else if (isValidRelationObject(value)) {\n relatedCollection = config.collections?.find(({ slug }) => slug === value.relationTo)\n\n if (relatedCollection) {\n result = {\n relationTo: value.relationTo,\n value: convertRelationshipValue({\n adapter,\n operation,\n relatedCollection,\n validateRelationships,\n value: value.value,\n }),\n }\n }\n }\n // Handle has one\n else if (relatedCollection) {\n result = convertRelationshipValue({\n adapter,\n operation,\n relatedCollection,\n validateRelationships,\n value,\n })\n }\n\n if (locale) {\n ref[locale] = result\n } else {\n ref[field.name] = result\n }\n}\n\nconst sanitizeDate = ({\n field,\n locale,\n ref,\n value,\n}: {\n field: DateField\n locale?: string\n ref: Record<string, unknown>\n value: unknown\n}) => {\n if (!value) {\n return\n }\n\n if (value instanceof Date) {\n value = value.toISOString()\n }\n\n if (locale) {\n ref[locale] = value\n } else {\n ref[field.name] = value\n }\n}\n\ntype Args = {\n $addToSet?: Record<string, { $each: any[] } | any>\n $inc?: Record<string, number>\n $pull?: Record<string, { $in: any[] } | any>\n $push?: Record<string, { $each: any[] } | any>\n /** instance of the adapter */\n adapter: MongooseAdapter\n /** data to transform, can be an array of documents or a single document */\n data: Record<string, unknown> | Record<string, unknown>[]\n /** fields accossiated with the data */\n fields: Field[]\n /** slug of the global, pass only when the operation is `write` */\n globalSlug?: string\n /**\n * Type of the operation\n * read - sanitizes ObjectIDs, Date to strings.\n * write - sanitizes string relationships to ObjectIDs.\n */\n operation: 'read' | 'write'\n parentIsLocalized?: boolean\n /**\n * Throw errors on invalid relationships\n * @default true\n */\n validateRelationships?: boolean\n}\n\nconst stripFields = ({\n config,\n data,\n fields,\n parentIsLocalized = false,\n reservedKeys = [],\n}: {\n config: SanitizedConfig\n data: any\n fields: FlattenedField[]\n parentIsLocalized?: boolean\n reservedKeys?: string[]\n}) => {\n for (const k in data) {\n if (!fields.some((field) => field.name === k) && !reservedKeys.includes(k)) {\n delete data[k]\n }\n }\n\n for (const field of fields) {\n reservedKeys = []\n const fieldData = data[field.name]\n if (!fieldData || typeof fieldData !== 'object') {\n continue\n }\n\n const shouldLocalizeField = fieldShouldBeLocalized({ field, parentIsLocalized })\n\n if (field.type === 'blocks') {\n reservedKeys.push('blockType')\n }\n\n if ('flattenedFields' in field || 'blocks' in field) {\n if (shouldLocalizeField && config.localization) {\n for (const localeKey in fieldData) {\n if (!config.localization.localeCodes.some((code) => code === localeKey)) {\n delete fieldData[localeKey]\n continue\n }\n\n const localeData = fieldData[localeKey]\n\n if (!localeData || typeof localeData !== 'object') {\n continue\n }\n\n if (field.type === 'array' || field.type === 'blocks') {\n if (!Array.isArray(localeData)) {\n continue\n }\n\n let hasNull = false\n for (let i = 0; i < localeData.length; i++) {\n const data = localeData[i]\n let fields: FlattenedField[] | null = null\n\n if (field.type === 'array') {\n fields = field.flattenedFields\n } else {\n let maybeBlock: FlattenedBlock | undefined = undefined\n\n if (field.blockReferences) {\n const maybeBlockReference = field.blockReferences.find((each) => {\n const slug = typeof each === 'string' ? each : each.slug\n return slug === data.blockType\n })\n\n if (maybeBlockReference) {\n if (typeof maybeBlockReference === 'object') {\n maybeBlock = maybeBlockReference\n } else {\n maybeBlock = config.blocks?.find((each) => each.slug === maybeBlockReference)\n }\n }\n }\n\n if (!maybeBlock) {\n maybeBlock = field.blocks.find((each) => each.slug === data.blockType)\n }\n\n if (maybeBlock) {\n fields = maybeBlock.flattenedFields\n } else {\n localeData[i] = null\n hasNull = true\n }\n }\n\n if (!fields) {\n continue\n }\n\n stripFields({\n config,\n data,\n fields,\n parentIsLocalized: parentIsLocalized || field.localized,\n reservedKeys,\n })\n }\n\n if (hasNull) {\n fieldData[localeKey] = localeData.filter(Boolean)\n }\n\n continue\n } else {\n stripFields({\n config,\n data: localeData,\n fields: field.flattenedFields,\n parentIsLocalized: parentIsLocalized || field.localized,\n reservedKeys,\n })\n }\n }\n continue\n }\n\n if (field.type === 'array' || field.type === 'blocks') {\n if (!Array.isArray(fieldData)) {\n continue\n }\n\n let hasNull = false\n\n for (let i = 0; i < fieldData.length; i++) {\n const data = fieldData[i]\n let fields: FlattenedField[] | null = null\n\n if (field.type === 'array') {\n fields = field.flattenedFields\n } else {\n let maybeBlock: FlattenedBlock | undefined = undefined\n\n if (field.blockReferences) {\n const maybeBlockReference = field.blockReferences.find((each) => {\n const slug = typeof each === 'string' ? each : each.slug\n return slug === data.blockType\n })\n\n if (maybeBlockReference) {\n if (typeof maybeBlockReference === 'object') {\n maybeBlock = maybeBlockReference\n } else {\n maybeBlock = config.blocks?.find((each) => each.slug === maybeBlockReference)\n }\n }\n }\n\n if (!maybeBlock) {\n maybeBlock = field.blocks.find((each) => each.slug === data.blockType)\n }\n\n if (maybeBlock) {\n fields = maybeBlock.flattenedFields\n } else {\n fieldData[i] = null\n hasNull = true\n }\n }\n\n if (!fields) {\n continue\n }\n\n stripFields({\n config,\n data,\n fields,\n parentIsLocalized: parentIsLocalized || field.localized,\n reservedKeys,\n })\n }\n\n if (hasNull) {\n data[field.name] = fieldData.filter(Boolean)\n }\n\n continue\n } else {\n stripFields({\n config,\n data: fieldData,\n fields: field.flattenedFields,\n parentIsLocalized: parentIsLocalized || field.localized,\n reservedKeys,\n })\n }\n }\n }\n}\n\nexport const transform = ({\n $addToSet,\n $inc,\n $pull,\n $push,\n adapter,\n data,\n fields,\n globalSlug,\n operation,\n parentIsLocalized = false,\n validateRelationships = true,\n}: Args) => {\n if (!data) {\n return null\n }\n\n if (Array.isArray(data)) {\n for (const item of data) {\n transform({\n $addToSet,\n $inc,\n $pull,\n $push,\n adapter,\n data: item,\n fields,\n globalSlug,\n operation,\n validateRelationships,\n })\n }\n return\n }\n\n const {\n payload: { config },\n } = adapter\n\n if (operation === 'read') {\n delete data['__v']\n data.id = data._id || data.id\n delete data['_id']\n\n if (isObjectID(data.id)) {\n data.id = data.id.toHexString()\n }\n\n // Handle BigInt conversion for custom ID fields of type 'number'\n if (adapter.useBigIntForNumberIDs && typeof data.id === 'bigint') {\n data.id = Number(data.id)\n }\n\n if (!adapter.allowAdditionalKeys) {\n stripFields({\n config,\n data,\n fields: flattenAllFields({ cache: true, fields }),\n parentIsLocalized: false,\n reservedKeys: ['id', 'globalType'],\n })\n }\n }\n\n if (operation === 'write' && globalSlug) {\n data.globalType = globalSlug\n }\n\n const sanitize: TraverseFieldsCallback = ({\n field,\n parentIsLocalized,\n parentPath,\n parentRef: incomingParentRef,\n ref: incomingRef,\n }) => {\n if (!incomingRef || typeof incomingRef !== 'object') {\n return\n }\n\n const ref = incomingRef as Record<string, unknown>\n const parentRef = (incomingParentRef || {}) as Record<string, unknown>\n\n // Clear empty parent containers by setting them to undefined.\n const clearEmptyContainer = () => {\n if (!parentRef || typeof parentRef !== 'object') {\n return\n }\n if (!ref || typeof ref !== 'object') {\n return\n }\n if (Object.keys(ref).length > 0) {\n return\n }\n const containerKey = Object.keys(parentRef).find((k) => parentRef[k] === ref)\n if (containerKey) {\n parentRef[containerKey] = undefined\n }\n }\n\n if (\n $inc &&\n field.type === 'number' &&\n operation === 'write' &&\n field.name in ref &&\n ref[field.name]\n ) {\n const value = ref[field.name]\n if (value && typeof value === 'object' && '$inc' in value && typeof value.$inc === 'number') {\n $inc[`${parentPath}${field.name}`] = value.$inc\n delete ref[field.name]\n clearEmptyContainer()\n }\n }\n\n if (\n $push &&\n field.type === 'array' &&\n operation === 'write' &&\n field.name in ref &&\n ref[field.name]\n ) {\n const value = ref[field.name]\n\n if (\n value &&\n typeof value === 'object' &&\n ('$push' in value ||\n (config.localization &&\n fieldShouldBeLocalized({ field, parentIsLocalized }) &&\n Object.values(value).some(\n (localeValue) =>\n localeValue && typeof localeValue === 'object' && '$push' in localeValue,\n )))\n ) {\n if (config.localization && fieldShouldBeLocalized({ field, parentIsLocalized })) {\n // Handle localized fields: { field: { locale: { $push: data } } }\n let hasLocaleOperations = false\n Object.entries(value).forEach(([localeKey, localeValue]) => {\n if (localeValue && typeof localeValue === 'object' && '$push' in localeValue) {\n hasLocaleOperations = true\n const push = localeValue.$push\n if (Array.isArray(push)) {\n $push[`${parentPath}${field.name}.${localeKey}`] = { $each: push }\n } else if (typeof push === 'object') {\n $push[`${parentPath}${field.name}.${localeKey}`] = push\n }\n }\n })\n\n if (hasLocaleOperations) {\n delete ref[field.name]\n clearEmptyContainer()\n }\n } else if (value && typeof value === 'object' && '$push' in value) {\n // Handle non-localized fields: { field: { $push: data } }\n const push = value.$push\n if (Array.isArray(push)) {\n $push[`${parentPath}${field.name}`] = { $each: push }\n } else if (typeof push === 'object') {\n $push[`${parentPath}${field.name}`] = push\n }\n delete ref[field.name]\n clearEmptyContainer()\n }\n }\n }\n\n // Handle $push operation for relationship fields (converts to $addToSet)\n\n // Handle $push operation for relationship fields (converts to $addToSet) - unified approach\n if (\n $addToSet &&\n (field.type === 'relationship' || field.type === 'upload') &&\n 'hasMany' in field &&\n field.hasMany &&\n operation === 'write' &&\n field.name in ref &&\n ref[field.name]\n ) {\n const value = ref[field.name]\n\n if (\n value &&\n typeof value === 'object' &&\n ('$push' in value ||\n (config.localization &&\n fieldShouldBeLocalized({ field, parentIsLocalized }) &&\n Object.values(value).some(\n (localeValue) =>\n localeValue &&\n typeof localeValue === 'object' &&\n '$push' in (localeValue as Record<string, unknown>),\n )))\n ) {\n if (config.localization && fieldShouldBeLocalized({ field, parentIsLocalized })) {\n // Handle localized fields: { field: { locale: { $push: data } } }\n let hasLocaleOperations = false\n Object.entries(value).forEach(([localeKey, localeValue]) => {\n if (localeValue && typeof localeValue === 'object' && '$push' in localeValue) {\n hasLocaleOperations = true\n const push = localeValue.$push\n const localeItems = Array.isArray(push) ? push : [push]\n const processedLocaleItems = processRelationshipValues(\n localeItems,\n field,\n config,\n operation,\n validateRelationships,\n adapter,\n )\n $addToSet[`${parentPath}${field.name}.${localeKey}`] = { $each: processedLocaleItems }\n }\n })\n\n if (hasLocaleOperations) {\n delete ref[field.name]\n clearEmptyContainer()\n }\n } else if (value && typeof value === 'object' && '$push' in value) {\n // Handle non-localized fields: { field: { $push: data } }\n const itemsToAppend = Array.isArray(value.$push) ? value.$push : [value.$push]\n const processedItems = processRelationshipValues(\n itemsToAppend,\n field,\n config,\n operation,\n validateRelationships,\n adapter,\n )\n $addToSet[`${parentPath}${field.name}`] = { $each: processedItems }\n delete ref[field.name]\n clearEmptyContainer()\n }\n }\n }\n\n // Handle $remove operation for relationship fields (converts to $pull)\n if (\n $pull &&\n (field.type === 'relationship' || field.type === 'upload') &&\n 'hasMany' in field &&\n field.hasMany &&\n operation === 'write' &&\n field.name in ref &&\n ref[field.name]\n ) {\n const value = ref[field.name]\n if (\n value &&\n typeof value === 'object' &&\n ('$remove' in value ||\n (config.localization &&\n fieldShouldBeLocalized({ field, parentIsLocalized }) &&\n Object.values(value).some(\n (localeValue) =>\n localeValue &&\n typeof localeValue === 'object' &&\n '$remove' in (localeValue as Record<string, unknown>),\n )))\n ) {\n if (config.localization && fieldShouldBeLocalized({ field, parentIsLocalized })) {\n // Handle localized fields: { field: { locale: { $remove: data } } }\n let hasLocaleOperations = false\n Object.entries(value).forEach(([localeKey, localeValue]) => {\n if (localeValue && typeof localeValue === 'object' && '$remove' in localeValue) {\n hasLocaleOperations = true\n const remove = localeValue.$remove\n const localeItems = Array.isArray(remove) ? remove : [remove]\n const processedLocaleItems = processRelationshipValues(\n localeItems,\n field,\n config,\n operation,\n validateRelationships,\n adapter,\n )\n $pull[`${parentPath}${field.name}.${localeKey}`] = { $in: processedLocaleItems }\n }\n })\n\n if (hasLocaleOperations) {\n delete ref[field.name]\n clearEmptyContainer()\n }\n } else if (value && typeof value === 'object' && '$remove' in value) {\n // Handle non-localized fields: { field: { $remove: data } }\n const itemsToRemove = Array.isArray(value.$remove) ? value.$remove : [value.$remove]\n const processedItems = processRelationshipValues(\n itemsToRemove,\n field,\n config,\n operation,\n validateRelationships,\n adapter,\n )\n $pull[`${parentPath}${field.name}`] = { $in: processedItems }\n delete ref[field.name]\n clearEmptyContainer()\n }\n }\n }\n\n if (field.type === 'date' && operation === 'read' && field.name in ref && ref[field.name]) {\n if (config.localization && fieldShouldBeLocalized({ field, parentIsLocalized })) {\n const fieldRef = ref[field.name] as Record<string, unknown>\n if (!fieldRef || typeof fieldRef !== 'object') {\n return\n }\n\n for (const locale of config.localization.localeCodes) {\n sanitizeDate({\n field,\n locale,\n ref: fieldRef,\n value: fieldRef[locale],\n })\n }\n } else {\n sanitizeDate({\n field,\n ref,\n value: ref[field.name],\n })\n }\n }\n\n if (\n field.type === 'relationship' ||\n field.type === 'upload' ||\n (operation === 'read' && field.type === 'join')\n ) {\n if (!ref[field.name]) {\n return\n }\n\n // handle localized relationships\n if (config.localization && fieldShouldBeLocalized({ field, parentIsLocalized })) {\n const locales = config.localization.locales\n const fieldRef = ref[field.name] as Record<string, unknown>\n if (typeof fieldRef !== 'object') {\n return\n }\n\n for (const { code } of locales) {\n const value = fieldRef[code]\n if (value) {\n sanitizeRelationship({\n adapter,\n config,\n field,\n locale: code,\n operation,\n ref: fieldRef,\n validateRelationships,\n value,\n })\n }\n }\n } else {\n // handle non-localized relationships\n sanitizeRelationship({\n adapter,\n config,\n field,\n locale: undefined,\n operation,\n ref,\n validateRelationships,\n value: ref[field.name],\n })\n }\n }\n }\n\n traverseFields({\n callback: sanitize,\n config,\n fields,\n fillEmpty: false,\n parentIsLocalized,\n ref: data,\n })\n\n if (operation === 'write') {\n if (typeof data.updatedAt === 'undefined') {\n // If data.updatedAt is explicitly set to `null` we should not set it - this means we don't want to change the value of updatedAt.\n data.updatedAt = new Date().toISOString()\n } else if (data.updatedAt === null) {\n // `updatedAt` may be explicitly set to null to disable updating it - if that is the case, we need to delete the property. Keeping it as null will\n // cause the database to think we want to set it to null, which we don't.\n delete data.updatedAt\n }\n }\n}\n"],"names":["Types","flattenAllFields","traverseFields","fieldAffectsData","fieldShouldBeLocalized","isObjectID","isValidRelationObject","value","processRelationshipValues","items","field","config","operation","validateRelationships","adapter","map","item","Array","isArray","relationTo","relatedCollection","collections","find","slug","convertRelationshipValue","customIDField","fields","name","toHexString","type","useBigIntForNumberIDs","Number","ObjectId","e","sanitizeRelationship","locale","ref","docs","i","length","collection","JSON","parse","stringify","result","hasManyRelations","val","relatedCollectionForSingleValue","sanitizeDate","Date","toISOString","stripFields","data","parentIsLocalized","reservedKeys","k","some","includes","fieldData","shouldLocalizeField","push","localization","localeKey","localeCodes","code","localeData","hasNull","flattenedFields","maybeBlock","undefined","blockReferences","maybeBlockReference","each","blockType","blocks","localized","filter","Boolean","transform","$addToSet","$inc","$pull","$push","globalSlug","payload","id","_id","allowAdditionalKeys","cache","globalType","sanitize","parentPath","parentRef","incomingParentRef","incomingRef","clearEmptyContainer","Object","keys","containerKey","values","localeValue","hasLocaleOperations","entries","forEach","$each","hasMany","localeItems","processedLocaleItems","itemsToAppend","processedItems","remove","$remove","$in","itemsToRemove","fieldRef","locales","callback","fillEmpty","updatedAt"],"mappings":"AAaA,SAASA,KAAK,QAAQ,WAAU;AAChC,SAASC,gBAAgB,EAAEC,cAAc,QAAQ,UAAS;AAC1D,SAASC,gBAAgB,EAAEC,sBAAsB,QAAQ,iBAAgB;AAIzE,SAASC,UAAU,QAAQ,kBAAiB;AAO5C,SAASC,sBAAsBC,KAAc;IAC3C,OAAO,OAAOA,UAAU,YAAYA,UAAU,QAAQ,gBAAgBA,SAAS,WAAWA;AAC5F;AAEA;;;CAGC,GACD,MAAMC,4BAA4B,CAChCC,OACAC,OACAC,QACAC,WACAC,uBACAC;IAEA,OAAOL,MAAMM,GAAG,CAAC,CAACC;QAChB,mCAAmC;QACnC,IAAIC,MAAMC,OAAO,CAACR,MAAMS,UAAU,KAAKb,sBAAsBU,OAAO;YAClE,MAAMI,oBAAoBT,OAAOU,WAAW,EAAEC,KAAK,CAAC,EAAEC,IAAI,EAAE,GAAKA,SAASP,KAAKG,UAAU;YACzF,IAAIC,mBAAmB;gBACrB,OAAO;oBACLD,YAAYH,KAAKG,UAAU;oBAC3BZ,OAAOiB,yBAAyB;wBAC9BV;wBACAF;wBACAQ;wBACAP;wBACAN,OAAOS,KAAKT,KAAK;oBACnB;gBACF;YACF;YACA,OAAOS;QACT;QAEA,8BAA8B;QAC9B,IAAI,OAAON,MAAMS,UAAU,KAAK,UAAU;YACxC,MAAMC,oBAAoBT,OAAOU,WAAW,EAAEC,KAAK,CAAC,EAAEC,IAAI,EAAE,GAAKA,SAASb,MAAMS,UAAU;YAC1F,IAAIC,mBAAmB;gBACrB,OAAOI,yBAAyB;oBAC9BV;oBACAF;oBACAQ;oBACAP;oBACAN,OAAOS;gBACT;YACF;QACF;QAEA,OAAOA;IACT;AACF;AAEA,MAAMQ,2BAA2B,CAAC,EACh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OAAO;gBAC3C,MAAMD,WAAW9E,GAAG,CAAC1B,MAAMiB,IAAI,CAAC;gBAChC,IAAI,OAAOuF,aAAa,UAAU;oBAChC;gBACF;gBAEA,KAAK,MAAM,EAAElD,IAAI,EAAE,IAAImD,QAAS;oBAC9B,MAAM5G,QAAQ2G,QAAQ,CAAClD,KAAK;oBAC5B,IAAIzD,OAAO;wBACT2B,qBAAqB;4BACnBpB;4BACAH;4BACAD;4BACAyB,QAAQ6B;4BACRpD;4BACAwB,KAAK8E;4BACLrG;4BACAN;wBACF;oBACF;gBACF;YACF,OAAO;gBACL,qCAAqC;gBACrC2B,qBAAqB;oBACnBpB;oBACAH;oBACAD;oBACAyB,QAAQkC;oBACRzD;oBACAwB;oBACAvB;oBACAN,OAAO6B,GAAG,CAAC1B,MAAMiB,IAAI,CAAC;gBACxB;YACF;QACF;IACF;IAEAzB,eAAe;QACbkH,UAAU1B;QACV/E;QACAe;QACA2F,WAAW;QACXhE;QACAjB,KAAKgB;IACP;IAEA,IAAIxC,cAAc,SAAS;QACzB,IAAI,OAAOwC,KAAKkE,SAAS,KAAK,aAAa;YACzC,kIAAkI;YAClIlE,KAAKkE,SAAS,GAAG,IAAIrE,OAAOC,WAAW;QACzC,OAAO,IAAIE,KAAKkE,SAAS,KAAK,MAAM;YAClC,kJAAkJ;YAClJ,yEAAyE;YACzE,OAAOlE,KAAKkE,SAAS;QACvB;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../src/utilities/transform.ts"],"sourcesContent":["import type {\n CollectionConfig,\n DateField,\n Field,\n FlattenedBlock,\n FlattenedField,\n JoinField,\n RelationshipField,\n SanitizedConfig,\n TraverseFieldsCallback,\n UploadField,\n} from 'payload'\n\nimport { Types } from 'mongoose'\nimport { flattenAllFields, traverseFields } from 'payload'\nimport { fieldAffectsData, fieldShouldBeLocalized } from 'payload/shared'\n\nimport type { MongooseAdapter } from '../index.js'\n\nimport { isObjectID } from './isObjectID.js'\n\ninterface RelationObject {\n relationTo: string\n value: number | string\n}\n\nfunction isValidRelationObject(value: unknown): value is RelationObject {\n return typeof value === 'object' && value !== null && 'relationTo' in value && 'value' in value\n}\n\n/**\n * Process relationship values for polymorphic and simple relationships\n * Used by both $push and $remove operations\n */\nconst processRelationshipValues = (\n items: unknown[],\n field: RelationshipField | UploadField,\n config: SanitizedConfig,\n operation: 'read' | 'write',\n validateRelationships: boolean,\n adapter: MongooseAdapter,\n) => {\n return items.map((item) => {\n // Handle polymorphic relationships\n if (Array.isArray(field.relationTo) && isValidRelationObject(item)) {\n const relatedCollection = config.collections?.find(({ slug }) => slug === item.relationTo)\n if (relatedCollection) {\n return {\n relationTo: item.relationTo,\n value: convertRelationshipValue({\n adapter,\n operation,\n relatedCollection,\n validateRelationships,\n value: item.value,\n }),\n }\n }\n return item\n }\n\n // Handle simple relationships\n if (typeof field.relationTo === 'string') {\n const relatedCollection = config.collections?.find(({ slug }) => slug === field.relationTo)\n if (relatedCollection) {\n return convertRelationshipValue({\n adapter,\n operation,\n relatedCollection,\n validateRelationships,\n value: item,\n })\n }\n }\n\n return item\n })\n}\n\nconst convertRelationshipValue = ({\n adapter,\n operation,\n relatedCollection,\n validateRelationships,\n value,\n}: {\n adapter: MongooseAdapter\n operation: Args['operation']\n relatedCollection: CollectionConfig\n validateRelationships?: boolean\n value: unknown\n}) => {\n const customIDField = relatedCollection.fields.find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n )\n\n if (operation === 'read') {\n if (isObjectID(value)) {\n return value.toHexString()\n }\n\n if (\n customIDField?.type === 'number' &&\n typeof value === 'bigint' &&\n adapter.useBigIntForNumberIDs\n ) {\n return Number(value)\n }\n\n return value\n }\n\n if (customIDField) {\n return value\n }\n\n if (typeof value === 'string') {\n try {\n return new Types.ObjectId(value)\n } catch (e) {\n if (validateRelationships) {\n throw e\n }\n return value\n }\n }\n\n return value\n}\n\nconst sanitizeRelationship = ({\n adapter,\n config,\n field,\n locale,\n operation,\n ref,\n validateRelationships,\n value,\n}: {\n adapter: MongooseAdapter\n config: SanitizedConfig\n field: JoinField | RelationshipField | UploadField\n locale?: string\n operation: Args['operation']\n ref: Record<string, unknown>\n validateRelationships?: boolean\n value?: unknown\n}) => {\n if (field.type === 'join') {\n if (\n operation === 'read' &&\n value &&\n typeof value === 'object' &&\n 'docs' in value &&\n Array.isArray(value.docs)\n ) {\n for (let i = 0; i < value.docs.length; i++) {\n const item = value.docs[i]\n\n if (isObjectID(item)) {\n value.docs[i] = item.toHexString()\n } else if (Array.isArray(field.collection) && item) {\n // Fields here for polymorphic joins cannot be determinted, JSON.parse needed\n value.docs[i] = JSON.parse(JSON.stringify(value.docs[i]))\n }\n }\n }\n\n return value\n }\n let relatedCollection: CollectionConfig | undefined\n let result = value\n\n const hasManyRelations = typeof field.relationTo !== 'string'\n\n if (!hasManyRelations) {\n relatedCollection = config.collections?.find(({ slug }) => slug === field.relationTo)\n }\n\n if (Array.isArray(value)) {\n result = value.map((val) => {\n // Handle has many - polymorphic\n if (isValidRelationObject(val)) {\n const relatedCollectionForSingleValue = config.collections?.find(\n ({ slug }) => slug === val.relationTo,\n )\n\n if (relatedCollectionForSingleValue) {\n return {\n relationTo: val.relationTo,\n value: convertRelationshipValue({\n adapter,\n operation,\n relatedCollection: relatedCollectionForSingleValue,\n validateRelationships,\n value: val.value,\n }),\n }\n }\n }\n\n if (relatedCollection) {\n return convertRelationshipValue({\n adapter,\n operation,\n relatedCollection,\n validateRelationships,\n value: val,\n })\n }\n\n return val\n })\n }\n // Handle has one - polymorphic\n else if (isValidRelationObject(value)) {\n relatedCollection = config.collections?.find(({ slug }) => slug === value.relationTo)\n\n if (relatedCollection) {\n result = {\n relationTo: value.relationTo,\n value: convertRelationshipValue({\n adapter,\n operation,\n relatedCollection,\n validateRelationships,\n value: value.value,\n }),\n }\n }\n }\n // Handle has one\n else if (relatedCollection) {\n result = convertRelationshipValue({\n adapter,\n operation,\n relatedCollection,\n validateRelationships,\n value,\n })\n }\n\n if (locale) {\n ref[locale] = result\n } else {\n ref[field.name] = result\n }\n}\n\nconst sanitizeDate = ({\n field,\n locale,\n ref,\n value,\n}: {\n field: DateField\n locale?: string\n ref: Record<string, unknown>\n value: unknown\n}) => {\n if (!value) {\n return\n }\n\n if (value instanceof Date) {\n value = value.toISOString()\n }\n\n if (locale) {\n ref[locale] = value\n } else {\n ref[field.name] = value\n }\n}\n\ntype Args = {\n $addToSet?: Record<string, { $each: any[] } | any>\n $inc?: Record<string, number>\n $pull?: Record<string, { $in: any[] } | any>\n $push?: Record<string, { $each: any[] } | any>\n /** instance of the adapter */\n adapter: MongooseAdapter\n /** data to transform, can be an array of documents or a single document */\n data: Record<string, unknown> | Record<string, unknown>[]\n /** fields accossiated with the data */\n fields: Field[]\n /** slug of the global, pass only when the operation is `write` */\n globalSlug?: string\n /**\n * Type of the operation\n * read - sanitizes ObjectIDs, Date to strings.\n * write - sanitizes string relationships to ObjectIDs.\n */\n operation: 'read' | 'write'\n parentIsLocalized?: boolean\n /**\n * Throw errors on invalid relationships\n * @default true\n */\n validateRelationships?: boolean\n}\n\nconst stripFields = ({\n config,\n data,\n fields,\n parentIsLocalized = false,\n reservedKeys = [],\n}: {\n config: SanitizedConfig\n data: any\n fields: FlattenedField[]\n parentIsLocalized?: boolean\n reservedKeys?: string[]\n}) => {\n for (const k in data) {\n if (!fields.some((field) => field.name === k) && !reservedKeys.includes(k)) {\n delete data[k]\n }\n }\n\n for (const field of fields) {\n reservedKeys = []\n const fieldData = data[field.name]\n if (!fieldData || typeof fieldData !== 'object') {\n continue\n }\n\n const shouldLocalizeField = fieldShouldBeLocalized({ field, parentIsLocalized })\n\n if (field.type === 'blocks') {\n reservedKeys.push('blockType')\n }\n\n if ('flattenedFields' in field || 'blocks' in field) {\n if (shouldLocalizeField && config.localization) {\n for (const localeKey in fieldData) {\n if (!config.localization.localeCodes.some((code) => code === localeKey)) {\n delete fieldData[localeKey]\n continue\n }\n\n const localeData = fieldData[localeKey]\n\n if (!localeData || typeof localeData !== 'object') {\n continue\n }\n\n if (field.type === 'array' || field.type === 'blocks') {\n if (!Array.isArray(localeData)) {\n continue\n }\n\n let hasNull = false\n for (let i = 0; i < localeData.length; i++) {\n const data = localeData[i]\n let fields: FlattenedField[] | null = null\n\n if (field.type === 'array') {\n fields = field.flattenedFields\n } else {\n let maybeBlock: FlattenedBlock | undefined = undefined\n\n if (field.blockReferences) {\n const maybeBlockReference = field.blockReferences.find((each) => {\n const slug = typeof each === 'string' ? each : each.slug\n return slug === data.blockType\n })\n\n if (maybeBlockReference) {\n if (typeof maybeBlockReference === 'object') {\n maybeBlock = maybeBlockReference\n } else {\n maybeBlock = config.blocks?.find((each) => each.slug === maybeBlockReference)\n }\n }\n }\n\n if (!maybeBlock) {\n maybeBlock = field.blocks.find((each) => each.slug === data.blockType)\n }\n\n if (maybeBlock) {\n fields = maybeBlock.flattenedFields\n } else {\n localeData[i] = null\n hasNull = true\n }\n }\n\n if (!fields) {\n continue\n }\n\n stripFields({\n config,\n data,\n fields,\n parentIsLocalized: parentIsLocalized || field.localized,\n reservedKeys,\n })\n }\n\n if (hasNull) {\n fieldData[localeKey] = localeData.filter(Boolean)\n }\n\n continue\n } else {\n stripFields({\n config,\n data: localeData,\n fields: field.flattenedFields,\n parentIsLocalized: parentIsLocalized || field.localized,\n reservedKeys,\n })\n }\n }\n continue\n }\n\n if (field.type === 'array' || field.type === 'blocks') {\n if (!Array.isArray(fieldData)) {\n continue\n }\n\n let hasNull = false\n\n for (let i = 0; i < fieldData.length; i++) {\n const data = fieldData[i]\n let fields: FlattenedField[] | null = null\n\n if (field.type === 'array') {\n fields = field.flattenedFields\n } else {\n let maybeBlock: FlattenedBlock | undefined = undefined\n\n if (field.blockReferences) {\n const maybeBlockReference = field.blockReferences.find((each) => {\n const slug = typeof each === 'string' ? each : each.slug\n return slug === data.blockType\n })\n\n if (maybeBlockReference) {\n if (typeof maybeBlockReference === 'object') {\n maybeBlock = maybeBlockReference\n } else {\n maybeBlock = config.blocks?.find((each) => each.slug === maybeBlockReference)\n }\n }\n }\n\n if (!maybeBlock) {\n maybeBlock = field.blocks.find((each) => each.slug === data.blockType)\n }\n\n if (maybeBlock) {\n fields = maybeBlock.flattenedFields\n } else {\n fieldData[i] = null\n hasNull = true\n }\n }\n\n if (!fields) {\n continue\n }\n\n stripFields({\n config,\n data,\n fields,\n parentIsLocalized: parentIsLocalized || field.localized,\n reservedKeys,\n })\n }\n\n if (hasNull) {\n data[field.name] = fieldData.filter(Boolean)\n }\n\n continue\n } else {\n stripFields({\n config,\n data: fieldData,\n fields: field.flattenedFields,\n parentIsLocalized: parentIsLocalized || field.localized,\n reservedKeys,\n })\n }\n }\n }\n}\n\n/**\n * A function that transforms Payload <-> MongoDB data.\n * @internal - this function may be removed or receive breaking changes in minor releases.\n */\nexport const transform = ({\n $addToSet,\n $inc,\n $pull,\n $push,\n adapter,\n data,\n fields,\n globalSlug,\n operation,\n parentIsLocalized = false,\n validateRelationships = true,\n}: Args) => {\n if (!data) {\n return null\n }\n\n if (Array.isArray(data)) {\n for (const item of data) {\n transform({\n $addToSet,\n $inc,\n $pull,\n $push,\n adapter,\n data: item,\n fields,\n globalSlug,\n operation,\n validateRelationships,\n })\n }\n return\n }\n\n const {\n payload: { config },\n } = adapter\n\n if (operation === 'read') {\n delete data['__v']\n data.id = data._id || data.id\n delete data['_id']\n\n if (isObjectID(data.id)) {\n data.id = data.id.toHexString()\n }\n\n // Handle BigInt conversion for custom ID fields of type 'number'\n if (adapter.useBigIntForNumberIDs && typeof data.id === 'bigint') {\n data.id = Number(data.id)\n }\n\n if (!adapter.allowAdditionalKeys) {\n stripFields({\n config,\n data,\n fields: flattenAllFields({ cache: true, fields }),\n parentIsLocalized: false,\n reservedKeys: ['id', 'globalType'],\n })\n }\n }\n\n if (operation === 'write' && globalSlug) {\n data.globalType = globalSlug\n }\n\n const sanitize: TraverseFieldsCallback = ({\n field,\n parentIsLocalized,\n parentPath,\n parentRef: incomingParentRef,\n ref: incomingRef,\n }) => {\n if (!incomingRef || typeof incomingRef !== 'object') {\n return\n }\n\n const ref = incomingRef as Record<string, unknown>\n const parentRef = (incomingParentRef || {}) as Record<string, unknown>\n\n // Clear empty parent containers by setting them to undefined.\n const clearEmptyContainer = () => {\n if (!parentRef || typeof parentRef !== 'object') {\n return\n }\n if (!ref || typeof ref !== 'object') {\n return\n }\n if (Object.keys(ref).length > 0) {\n return\n }\n const containerKey = Object.keys(parentRef).find((k) => parentRef[k] === ref)\n if (containerKey) {\n parentRef[containerKey] = undefined\n }\n }\n\n if (\n $inc &&\n field.type === 'number' &&\n operation === 'write' &&\n field.name in ref &&\n ref[field.name]\n ) {\n const value = ref[field.name]\n if (value && typeof value === 'object' && '$inc' in value && typeof value.$inc === 'number') {\n $inc[`${parentPath}${field.name}`] = value.$inc\n delete ref[field.name]\n clearEmptyContainer()\n }\n }\n\n if (\n $push &&\n field.type === 'array' &&\n operation === 'write' &&\n field.name in ref &&\n ref[field.name]\n ) {\n const value = ref[field.name]\n\n if (\n value &&\n typeof value === 'object' &&\n ('$push' in value ||\n (config.localization &&\n fieldShouldBeLocalized({ field, parentIsLocalized }) &&\n Object.values(value).some(\n (localeValue) =>\n localeValue && typeof localeValue === 'object' && '$push' in localeValue,\n )))\n ) {\n if (config.localization && fieldShouldBeLocalized({ field, parentIsLocalized })) {\n // Handle localized fields: { field: { locale: { $push: data } } }\n let hasLocaleOperations = false\n Object.entries(value).forEach(([localeKey, localeValue]) => {\n if (localeValue && typeof localeValue === 'object' && '$push' in localeValue) {\n hasLocaleOperations = true\n const push = localeValue.$push\n if (Array.isArray(push)) {\n $push[`${parentPath}${field.name}.${localeKey}`] = { $each: push }\n } else if (typeof push === 'object') {\n $push[`${parentPath}${field.name}.${localeKey}`] = push\n }\n }\n })\n\n if (hasLocaleOperations) {\n delete ref[field.name]\n clearEmptyContainer()\n }\n } else if (value && typeof value === 'object' && '$push' in value) {\n // Handle non-localized fields: { field: { $push: data } }\n const push = value.$push\n if (Array.isArray(push)) {\n $push[`${parentPath}${field.name}`] = { $each: push }\n } else if (typeof push === 'object') {\n $push[`${parentPath}${field.name}`] = push\n }\n delete ref[field.name]\n clearEmptyContainer()\n }\n }\n }\n\n // Handle $push operation for relationship fields (converts to $addToSet)\n\n // Handle $push operation for relationship fields (converts to $addToSet) - unified approach\n if (\n $addToSet &&\n (field.type === 'relationship' || field.type === 'upload') &&\n 'hasMany' in field &&\n field.hasMany &&\n operation === 'write' &&\n field.name in ref &&\n ref[field.name]\n ) {\n const value = ref[field.name]\n\n if (\n value &&\n typeof value === 'object' &&\n ('$push' in value ||\n (config.localization &&\n fieldShouldBeLocalized({ field, parentIsLocalized }) &&\n Object.values(value).some(\n (localeValue) =>\n localeValue &&\n typeof localeValue === 'object' &&\n '$push' in (localeValue as Record<string, unknown>),\n )))\n ) {\n if (config.localization && fieldShouldBeLocalized({ field, parentIsLocalized })) {\n // Handle localized fields: { field: { locale: { $push: data } } }\n let hasLocaleOperations = false\n Object.entries(value).forEach(([localeKey, localeValue]) => {\n if (localeValue && typeof localeValue === 'object' && '$push' in localeValue) {\n hasLocaleOperations = true\n const push = localeValue.$push\n const localeItems = Array.isArray(push) ? push : [push]\n const processedLocaleItems = processRelationshipValues(\n localeItems,\n field,\n config,\n operation,\n validateRelationships,\n adapter,\n )\n $addToSet[`${parentPath}${field.name}.${localeKey}`] = { $each: processedLocaleItems }\n }\n })\n\n if (hasLocaleOperations) {\n delete ref[field.name]\n clearEmptyContainer()\n }\n } else if (value && typeof value === 'object' && '$push' in value) {\n // Handle non-localized fields: { field: { $push: data } }\n const itemsToAppend = Array.isArray(value.$push) ? value.$push : [value.$push]\n const processedItems = processRelationshipValues(\n itemsToAppend,\n field,\n config,\n operation,\n validateRelationships,\n adapter,\n )\n $addToSet[`${parentPath}${field.name}`] = { $each: processedItems }\n delete ref[field.name]\n clearEmptyContainer()\n }\n }\n }\n\n // Handle $remove operation for relationship fields (converts to $pull)\n if (\n $pull &&\n (field.type === 'relationship' || field.type === 'upload') &&\n 'hasMany' in field &&\n field.hasMany &&\n operation === 'write' &&\n field.name in ref &&\n ref[field.name]\n ) {\n const value = ref[field.name]\n if (\n value &&\n typeof value === 'object' &&\n ('$remove' in value ||\n (config.localization &&\n fieldShouldBeLocalized({ field, parentIsLocalized }) &&\n Object.values(value).some(\n (localeValue) =>\n localeValue &&\n typeof localeValue === 'object' &&\n '$remove' in (localeValue as Record<string, unknown>),\n )))\n ) {\n if (config.localization && fieldShouldBeLocalized({ field, parentIsLocalized })) {\n // Handle localized fields: { field: { locale: { $remove: data } } }\n let hasLocaleOperations = false\n Object.entries(value).forEach(([localeKey, localeValue]) => {\n if (localeValue && typeof localeValue === 'object' && '$remove' in localeValue) {\n hasLocaleOperations = true\n const remove = localeValue.$remove\n const localeItems = Array.isArray(remove) ? remove : [remove]\n const processedLocaleItems = processRelationshipValues(\n localeItems,\n field,\n config,\n operation,\n validateRelationships,\n adapter,\n )\n $pull[`${parentPath}${field.name}.${localeKey}`] = { $in: processedLocaleItems }\n }\n })\n\n if (hasLocaleOperations) {\n delete ref[field.name]\n clearEmptyContainer()\n }\n } else if (value && typeof value === 'object' && '$remove' in value) {\n // Handle non-localized fields: { field: { $remove: data } }\n const itemsToRemove = Array.isArray(value.$remove) ? value.$remove : [value.$remove]\n const processedItems = processRelationshipValues(\n itemsToRemove,\n field,\n config,\n operation,\n validateRelationships,\n adapter,\n )\n $pull[`${parentPath}${field.name}`] = { $in: processedItems }\n delete ref[field.name]\n clearEmptyContainer()\n }\n }\n }\n\n if (field.type === 'date' && operation === 'read' && field.name in ref && ref[field.name]) {\n if (config.localization && fieldShouldBeLocalized({ field, parentIsLocalized })) {\n const fieldRef = ref[field.name] as Record<string, unknown>\n if (!fieldRef || typeof fieldRef !== 'object') {\n return\n }\n\n for (const locale of config.localization.localeCodes) {\n sanitizeDate({\n field,\n locale,\n ref: fieldRef,\n value: fieldRef[locale],\n })\n }\n } else {\n sanitizeDate({\n field,\n ref,\n value: ref[field.name],\n })\n }\n }\n\n if (\n field.type === 'relationship' ||\n field.type === 'upload' ||\n (operation === 'read' && field.type === 'join')\n ) {\n if (!ref[field.name]) {\n return\n }\n\n // handle localized relationships\n if (config.localization && fieldShouldBeLocalized({ field, parentIsLocalized })) {\n const locales = config.localization.locales\n const fieldRef = ref[field.name] as Record<string, unknown>\n if (typeof fieldRef !== 'object') {\n return\n }\n\n for (const { code } of locales) {\n const value = fieldRef[code]\n if (value) {\n sanitizeRelationship({\n adapter,\n config,\n field,\n locale: code,\n operation,\n ref: fieldRef,\n validateRelationships,\n value,\n })\n }\n }\n } else {\n // handle non-localized relationships\n sanitizeRelationship({\n adapter,\n config,\n field,\n locale: undefined,\n operation,\n ref,\n validateRelationships,\n value: ref[field.name],\n })\n }\n }\n }\n\n traverseFields({\n callback: sanitize,\n config,\n fields,\n fillEmpty: false,\n parentIsLocalized,\n ref: data,\n })\n\n if (operation === 'write') {\n if (typeof data.updatedAt === 'undefined') {\n // If data.updatedAt is explicitly set to `null` we should not set it - this means we don't want to change the value of updatedAt.\n data.updatedAt = new Date().toISOString()\n } else if (data.updatedAt === null) {\n // `updatedAt` may be explicitly set to null to disable updating it - if that is the case, we need to delete the property. Keeping it as null will\n // cause the database to think we want to set it to null, which we don't.\n delete data.updatedAt\n }\n }\n}\n"],"names":["Types","flattenAllFields","traverseFields","fieldAffectsData","fieldShouldBeLocalized","isObjectID","isValidRelationObject","value","processRelationshipValues","items","field","config","operation","validateRelationships","adapter","map","item","Array","isArray","relationTo","relatedCollection","collections","find","slug","convertRelationshipValue","customIDField","fields","name","toHexString","type","useBigIntForNumberIDs","Number","ObjectId","e","sanitizeRelationship","locale","ref","docs","i","length","collection","JSON","parse","stringify","result","hasManyRelations","val","relatedCollectionForSingleValue","sanitizeDate","Date","toISOString","stripFields","data","parentIsLocalized","reservedKeys","k","some","includes","fieldData","shouldLocalizeField","push","localization","localeKey","localeCodes","code","localeData","hasNull","flattenedFields","maybeBlock","undefined","blockReferences","maybeBlockReference","each","blockType","blocks","localized","filter","Boolean","transform","$addToSet","$inc","$pull","$push","globalSlug","payload","id","_id","allowAdditionalKeys","cache","globalType","sanitize","parentPath","parentRef","incomingParentRef","incomingRef","clearEmptyContainer","Object","keys","containerKey","values","localeValue","hasLocaleOperations","entries","forEach","$each","hasMany","localeItems","processedLocaleItems","itemsToAppend","processedItems","remove","$remove","$in","itemsToRemove","fieldRef","locales","callback","fillEmpty","updatedAt"],"mappings":"AAaA,SAASA,KAAK,QAAQ,WAAU;AAChC,SAASC,gBAAgB,EAAEC,cAAc,QAAQ,UAAS;AAC1D,SAASC,gBAAgB,EAAEC,sBAAsB,QAAQ,iBAAgB;AAIzE,SAASC,UAAU,QAAQ,kBAAiB;AAO5C,SAASC,sBAAsBC,KAAc;IAC3C,OAAO,OAAOA,UAAU,YAAYA,UAAU,QAAQ,gBAAgBA,SAAS,WAAWA;AAC5F;AAEA;;;CAGC,GACD,MAAMC,4BAA4B,CAChCC,OACAC,OACAC,QACAC,WACAC,uBACAC;IAEA,OAAOL,MAAMM,GAAG,CAAC,CAACC;QAChB,mCAAmC;QACnC,IAAIC,MAAMC,OAAO,CAACR,MAAMS,UAAU,KAAKb,sBAAsBU,OAAO;YAClE,MAAMI,oBAAoBT,OAAOU,WAAW,EAAEC,KAAK,CAAC,EAAEC,IAAI,EAAE,GAAKA,SAASP,KAAKG,UAAU;YACzF,IAAIC,mBAAmB;gBACrB,OAAO;oBACLD,YAAYH,KAAKG,UAAU;oBAC3BZ,OAAOiB,yBAAyB;wBAC9BV;wBACAF;wBACAQ;wBACAP;wBACAN,OAAOS,KAAKT,KAAK;oBACnB;gBACF;YACF;YACA,OAAOS;QACT;QAEA,8BAA8B;QAC9B,IAAI,OAAON,MAAMS,UAAU,KAAK,UAAU;YACxC,MAAMC,oBAAoBT,OAAOU,WAAW,EAAEC,KAAK,CAAC,EAAEC,IAAI,EAAE,GAAKA,SAASb,MAAMS,UAAU;YAC1F,IAAIC,mBAAmB;gBACrB,OAAOI,yBAAyB;oBAC9BV;oBACAF;oBACAQ;oBACAP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AAY,IAAIzD,uBAAuB;gBAAEM;gBAAO2C;YAAkB,IAAI;gBAC/E,MAAM8D,UAAUxG,OAAOkD,YAAY,CAACsD,OAAO;gBAC3C,MAAMD,WAAW9E,GAAG,CAAC1B,MAAMiB,IAAI,CAAC;gBAChC,IAAI,OAAOuF,aAAa,UAAU;oBAChC;gBACF;gBAEA,KAAK,MAAM,EAAElD,IAAI,EAAE,IAAImD,QAAS;oBAC9B,MAAM5G,QAAQ2G,QAAQ,CAAClD,KAAK;oBAC5B,IAAIzD,OAAO;wBACT2B,qBAAqB;4BACnBpB;4BACAH;4BACAD;4BACAyB,QAAQ6B;4BACRpD;4BACAwB,KAAK8E;4BACLrG;4BACAN;wBACF;oBACF;gBACF;YACF,OAAO;gBACL,qCAAqC;gBACrC2B,qBAAqB;oBACnBpB;oBACAH;oBACAD;oBACAyB,QAAQkC;oBACRzD;oBACAwB;oBACAvB;oBACAN,OAAO6B,GAAG,CAAC1B,MAAMiB,IAAI,CAAC;gBACxB;YACF;QACF;IACF;IAEAzB,eAAe;QACbkH,UAAU1B;QACV/E;QACAe;QACA2F,WAAW;QACXhE;QACAjB,KAAKgB;IACP;IAEA,IAAIxC,cAAc,SAAS;QACzB,IAAI,OAAOwC,KAAKkE,SAAS,KAAK,aAAa;YACzC,kIAAkI;YAClIlE,KAAKkE,SAAS,GAAG,IAAIrE,OAAOC,WAAW;QACzC,OAAO,IAAIE,KAAKkE,SAAS,KAAK,MAAM;YAClC,kJAAkJ;YAClJ,yEAAyE;YACzE,OAAOlE,KAAKkE,SAAS;QACvB;IACF;AACF,EAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/db-mongodb",
3
- "version": "3.65.0-internal.ef3958a",
3
+ "version": "3.66.0-canary.0",
4
4
  "description": "The officially supported MongoDB database adapter for Payload",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -29,6 +29,11 @@
29
29
  "import": "./dist/exports/migration-utils.js",
30
30
  "types": "./dist/exports/migration-utils.d.ts",
31
31
  "default": "./dist/exports/migration-utils.js"
32
+ },
33
+ "./internal": {
34
+ "import": "./dist/exports/internal.js",
35
+ "types": "./dist/exports/internal.d.ts",
36
+ "default": "./dist/exports/internal.js"
32
37
  }
33
38
  },
34
39
  "main": "./dist/index.js",
@@ -50,10 +55,10 @@
50
55
  "mongodb": "6.16.0",
51
56
  "mongodb-memory-server": "10.1.4",
52
57
  "@payloadcms/eslint-config": "3.28.0",
53
- "payload": "3.65.0-internal.ef3958a"
58
+ "payload": "3.66.0-canary.0"
54
59
  },
55
60
  "peerDependencies": {
56
- "payload": "3.65.0-internal.ef3958a"
61
+ "payload": "3.66.0-canary.0"
57
62
  },
58
63
  "scripts": {
59
64
  "build": "pnpm build:types && pnpm build:swc",