payload 3.0.0-beta.125 → 3.0.0-beta.126

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 (158) hide show
  1. package/dist/admin/RichText.d.ts +3 -1
  2. package/dist/admin/RichText.d.ts.map +1 -1
  3. package/dist/admin/RichText.js.map +1 -1
  4. package/dist/collections/operations/create.d.ts +2 -1
  5. package/dist/collections/operations/create.d.ts.map +1 -1
  6. package/dist/collections/operations/create.js +2 -1
  7. package/dist/collections/operations/create.js.map +1 -1
  8. package/dist/collections/operations/delete.d.ts +2 -1
  9. package/dist/collections/operations/delete.d.ts.map +1 -1
  10. package/dist/collections/operations/delete.js +2 -1
  11. package/dist/collections/operations/delete.js.map +1 -1
  12. package/dist/collections/operations/deleteByID.d.ts +2 -1
  13. package/dist/collections/operations/deleteByID.d.ts.map +1 -1
  14. package/dist/collections/operations/deleteByID.js +2 -1
  15. package/dist/collections/operations/deleteByID.js.map +1 -1
  16. package/dist/collections/operations/duplicate.d.ts +2 -1
  17. package/dist/collections/operations/duplicate.d.ts.map +1 -1
  18. package/dist/collections/operations/duplicate.js +2 -1
  19. package/dist/collections/operations/duplicate.js.map +1 -1
  20. package/dist/collections/operations/find.d.ts +2 -1
  21. package/dist/collections/operations/find.d.ts.map +1 -1
  22. package/dist/collections/operations/find.js +2 -1
  23. package/dist/collections/operations/find.js.map +1 -1
  24. package/dist/collections/operations/findByID.d.ts +2 -1
  25. package/dist/collections/operations/findByID.d.ts.map +1 -1
  26. package/dist/collections/operations/findByID.js +2 -1
  27. package/dist/collections/operations/findByID.js.map +1 -1
  28. package/dist/collections/operations/findVersionByID.d.ts +2 -1
  29. package/dist/collections/operations/findVersionByID.d.ts.map +1 -1
  30. package/dist/collections/operations/findVersionByID.js +2 -1
  31. package/dist/collections/operations/findVersionByID.js.map +1 -1
  32. package/dist/collections/operations/findVersions.d.ts +2 -1
  33. package/dist/collections/operations/findVersions.d.ts.map +1 -1
  34. package/dist/collections/operations/findVersions.js +2 -1
  35. package/dist/collections/operations/findVersions.js.map +1 -1
  36. package/dist/collections/operations/local/create.d.ts +2 -1
  37. package/dist/collections/operations/local/create.d.ts.map +1 -1
  38. package/dist/collections/operations/local/create.js +2 -1
  39. package/dist/collections/operations/local/create.js.map +1 -1
  40. package/dist/collections/operations/local/delete.d.ts +2 -1
  41. package/dist/collections/operations/local/delete.d.ts.map +1 -1
  42. package/dist/collections/operations/local/delete.js +2 -1
  43. package/dist/collections/operations/local/delete.js.map +1 -1
  44. package/dist/collections/operations/local/duplicate.d.ts +2 -1
  45. package/dist/collections/operations/local/duplicate.d.ts.map +1 -1
  46. package/dist/collections/operations/local/duplicate.js +2 -1
  47. package/dist/collections/operations/local/duplicate.js.map +1 -1
  48. package/dist/collections/operations/local/find.d.ts +3 -2
  49. package/dist/collections/operations/local/find.d.ts.map +1 -1
  50. package/dist/collections/operations/local/find.js.map +1 -1
  51. package/dist/collections/operations/local/findByID.d.ts +3 -2
  52. package/dist/collections/operations/local/findByID.d.ts.map +1 -1
  53. package/dist/collections/operations/local/findByID.js +2 -1
  54. package/dist/collections/operations/local/findByID.js.map +1 -1
  55. package/dist/collections/operations/local/findVersionByID.d.ts +2 -1
  56. package/dist/collections/operations/local/findVersionByID.d.ts.map +1 -1
  57. package/dist/collections/operations/local/findVersionByID.js +2 -1
  58. package/dist/collections/operations/local/findVersionByID.js.map +1 -1
  59. package/dist/collections/operations/local/findVersions.d.ts +2 -1
  60. package/dist/collections/operations/local/findVersions.d.ts.map +1 -1
  61. package/dist/collections/operations/local/findVersions.js +2 -1
  62. package/dist/collections/operations/local/findVersions.js.map +1 -1
  63. package/dist/collections/operations/local/restoreVersion.d.ts +2 -1
  64. package/dist/collections/operations/local/restoreVersion.d.ts.map +1 -1
  65. package/dist/collections/operations/local/restoreVersion.js +2 -1
  66. package/dist/collections/operations/local/restoreVersion.js.map +1 -1
  67. package/dist/collections/operations/local/update.d.ts +2 -1
  68. package/dist/collections/operations/local/update.d.ts.map +1 -1
  69. package/dist/collections/operations/local/update.js +2 -1
  70. package/dist/collections/operations/local/update.js.map +1 -1
  71. package/dist/collections/operations/restoreVersion.d.ts +2 -1
  72. package/dist/collections/operations/restoreVersion.d.ts.map +1 -1
  73. package/dist/collections/operations/restoreVersion.js +2 -1
  74. package/dist/collections/operations/restoreVersion.js.map +1 -1
  75. package/dist/collections/operations/update.d.ts +2 -1
  76. package/dist/collections/operations/update.d.ts.map +1 -1
  77. package/dist/collections/operations/update.js +2 -1
  78. package/dist/collections/operations/update.js.map +1 -1
  79. package/dist/collections/operations/updateByID.d.ts +2 -1
  80. package/dist/collections/operations/updateByID.d.ts.map +1 -1
  81. package/dist/collections/operations/updateByID.js +8 -6
  82. package/dist/collections/operations/updateByID.js.map +1 -1
  83. package/dist/database/sanitizeJoinQuery.d.ts +3 -3
  84. package/dist/database/sanitizeJoinQuery.d.ts.map +1 -1
  85. package/dist/fields/hooks/afterRead/index.d.ts +2 -1
  86. package/dist/fields/hooks/afterRead/index.d.ts.map +1 -1
  87. package/dist/fields/hooks/afterRead/index.js +2 -1
  88. package/dist/fields/hooks/afterRead/index.js.map +1 -1
  89. package/dist/fields/hooks/afterRead/promise.d.ts +3 -2
  90. package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
  91. package/dist/fields/hooks/afterRead/promise.js +12 -1
  92. package/dist/fields/hooks/afterRead/promise.js.map +1 -1
  93. package/dist/fields/hooks/afterRead/relationshipPopulationPromise.d.ts +3 -2
  94. package/dist/fields/hooks/afterRead/relationshipPopulationPromise.d.ts.map +1 -1
  95. package/dist/fields/hooks/afterRead/relationshipPopulationPromise.js +7 -3
  96. package/dist/fields/hooks/afterRead/relationshipPopulationPromise.js.map +1 -1
  97. package/dist/fields/hooks/afterRead/traverseFields.d.ts +3 -2
  98. package/dist/fields/hooks/afterRead/traverseFields.d.ts.map +1 -1
  99. package/dist/fields/hooks/afterRead/traverseFields.js +2 -1
  100. package/dist/fields/hooks/afterRead/traverseFields.js.map +1 -1
  101. package/dist/globals/operations/findOne.d.ts +2 -1
  102. package/dist/globals/operations/findOne.d.ts.map +1 -1
  103. package/dist/globals/operations/findOne.js +2 -1
  104. package/dist/globals/operations/findOne.js.map +1 -1
  105. package/dist/globals/operations/findVersionByID.d.ts +2 -1
  106. package/dist/globals/operations/findVersionByID.d.ts.map +1 -1
  107. package/dist/globals/operations/findVersionByID.js +2 -1
  108. package/dist/globals/operations/findVersionByID.js.map +1 -1
  109. package/dist/globals/operations/findVersions.d.ts +2 -1
  110. package/dist/globals/operations/findVersions.d.ts.map +1 -1
  111. package/dist/globals/operations/findVersions.js +2 -1
  112. package/dist/globals/operations/findVersions.js.map +1 -1
  113. package/dist/globals/operations/local/findOne.d.ts +2 -1
  114. package/dist/globals/operations/local/findOne.d.ts.map +1 -1
  115. package/dist/globals/operations/local/findOne.js +2 -1
  116. package/dist/globals/operations/local/findOne.js.map +1 -1
  117. package/dist/globals/operations/local/findVersionByID.d.ts +2 -1
  118. package/dist/globals/operations/local/findVersionByID.d.ts.map +1 -1
  119. package/dist/globals/operations/local/findVersionByID.js +2 -1
  120. package/dist/globals/operations/local/findVersionByID.js.map +1 -1
  121. package/dist/globals/operations/local/findVersions.d.ts +2 -1
  122. package/dist/globals/operations/local/findVersions.d.ts.map +1 -1
  123. package/dist/globals/operations/local/findVersions.js +2 -1
  124. package/dist/globals/operations/local/findVersions.js.map +1 -1
  125. package/dist/globals/operations/local/restoreVersion.d.ts +2 -1
  126. package/dist/globals/operations/local/restoreVersion.d.ts.map +1 -1
  127. package/dist/globals/operations/local/restoreVersion.js +2 -1
  128. package/dist/globals/operations/local/restoreVersion.js.map +1 -1
  129. package/dist/globals/operations/local/update.d.ts +2 -1
  130. package/dist/globals/operations/local/update.d.ts.map +1 -1
  131. package/dist/globals/operations/local/update.js +2 -1
  132. package/dist/globals/operations/local/update.js.map +1 -1
  133. package/dist/globals/operations/restoreVersion.d.ts +2 -1
  134. package/dist/globals/operations/restoreVersion.d.ts.map +1 -1
  135. package/dist/globals/operations/restoreVersion.js +2 -1
  136. package/dist/globals/operations/restoreVersion.js.map +1 -1
  137. package/dist/globals/operations/update.d.ts +2 -1
  138. package/dist/globals/operations/update.d.ts.map +1 -1
  139. package/dist/globals/operations/update.js +2 -1
  140. package/dist/globals/operations/update.js.map +1 -1
  141. package/dist/index.d.ts +7 -0
  142. package/dist/index.d.ts.map +1 -1
  143. package/dist/index.js.map +1 -1
  144. package/dist/queues/config/jobsCollection.d.ts.map +1 -1
  145. package/dist/queues/config/jobsCollection.js +15 -13
  146. package/dist/queues/config/jobsCollection.js.map +1 -1
  147. package/dist/queues/config/types/index.d.ts +1 -1
  148. package/dist/queues/config/types/index.d.ts.map +1 -1
  149. package/dist/queues/config/types/index.js.map +1 -1
  150. package/dist/queues/operations/runJobs/index.js +1 -1
  151. package/dist/queues/operations/runJobs/index.js.map +1 -1
  152. package/dist/types/index.d.ts +5 -4
  153. package/dist/types/index.d.ts.map +1 -1
  154. package/dist/types/index.js.map +1 -1
  155. package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
  156. package/dist/utilities/configToJSONSchema.js +35 -0
  157. package/dist/utilities/configToJSONSchema.js.map +1 -1
  158. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  import { createDataloaderCacheKey } from '../../../collections/dataloader.js';
2
2
  import { fieldHasMaxDepth, fieldSupportsMany } from '../../config/types.js';
3
- const populate = async ({ currentDepth, data, dataReference, depth, draft, fallbackLocale, field, index, key, locale, overrideAccess, req, showHiddenFields })=>{
3
+ const populate = async ({ currentDepth, data, dataReference, depth, draft, fallbackLocale, field, index, key, locale, overrideAccess, populateArg, req, showHiddenFields })=>{
4
4
  const dataToUpdate = dataReference;
5
5
  let relation;
6
6
  if (field.type === 'join') {
@@ -26,7 +26,7 @@ const populate = async ({ currentDepth, data, dataReference, depth, draft, fallb
26
26
  fallbackLocale,
27
27
  locale,
28
28
  overrideAccess,
29
- select: relatedCollection.config.defaultPopulate,
29
+ select: populateArg?.[relatedCollection.config.slug] ?? relatedCollection.config.defaultPopulate,
30
30
  showHiddenFields,
31
31
  transactionID: req.transactionID
32
32
  }));
@@ -56,7 +56,7 @@ const populate = async ({ currentDepth, data, dataReference, depth, draft, fallb
56
56
  }
57
57
  }
58
58
  };
59
- export const relationshipPopulationPromise = async ({ currentDepth, depth, draft, fallbackLocale, field, locale, overrideAccess, req, showHiddenFields, siblingDoc })=>{
59
+ export const relationshipPopulationPromise = async ({ currentDepth, depth, draft, fallbackLocale, field, locale, overrideAccess, populate: populateArg, req, showHiddenFields, siblingDoc })=>{
60
60
  const resultingDoc = siblingDoc;
61
61
  const populateDepth = fieldHasMaxDepth(field) && field.maxDepth < depth ? field.maxDepth : depth;
62
62
  const rowPromises = [];
@@ -78,6 +78,7 @@ export const relationshipPopulationPromise = async ({ currentDepth, depth, draft
78
78
  key: localeKey,
79
79
  locale,
80
80
  overrideAccess,
81
+ populateArg,
81
82
  req,
82
83
  showHiddenFields
83
84
  });
@@ -101,6 +102,7 @@ export const relationshipPopulationPromise = async ({ currentDepth, depth, draft
101
102
  index,
102
103
  locale,
103
104
  overrideAccess,
105
+ populateArg,
104
106
  req,
105
107
  showHiddenFields
106
108
  });
@@ -123,6 +125,7 @@ export const relationshipPopulationPromise = async ({ currentDepth, depth, draft
123
125
  key: localeKey,
124
126
  locale,
125
127
  overrideAccess,
128
+ populateArg,
126
129
  req,
127
130
  showHiddenFields
128
131
  });
@@ -141,6 +144,7 @@ export const relationshipPopulationPromise = async ({ currentDepth, depth, draft
141
144
  field,
142
145
  locale,
143
146
  overrideAccess,
147
+ populateArg,
144
148
  req,
145
149
  showHiddenFields
146
150
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/fields/hooks/afterRead/relationshipPopulationPromise.ts"],"sourcesContent":["import type { PayloadRequest } from '../../../types/index.js'\nimport type { JoinField, RelationshipField, UploadField } from '../../config/types.js'\n\nimport { createDataloaderCacheKey } from '../../../collections/dataloader.js'\nimport { fieldHasMaxDepth, fieldSupportsMany } from '../../config/types.js'\n\ntype PopulateArgs = {\n currentDepth: number\n data: Record<string, unknown>\n dataReference: Record<string, any>\n depth: number\n draft: boolean\n fallbackLocale: null | string\n field: JoinField | RelationshipField | UploadField\n index?: number\n key?: string\n locale: null | string\n overrideAccess: boolean\n req: PayloadRequest\n showHiddenFields: boolean\n}\n\nconst populate = async ({\n currentDepth,\n data,\n dataReference,\n depth,\n draft,\n fallbackLocale,\n field,\n index,\n key,\n locale,\n overrideAccess,\n req,\n showHiddenFields,\n}: PopulateArgs) => {\n const dataToUpdate = dataReference\n let relation\n if (field.type === 'join') {\n relation = field.collection\n } else {\n relation = Array.isArray(field.relationTo) ? (data.relationTo as string) : field.relationTo\n }\n const relatedCollection = req.payload.collections[relation]\n\n if (relatedCollection) {\n let id = field.type !== 'join' && Array.isArray(field.relationTo) ? data.value : data\n let relationshipValue\n const shouldPopulate = depth && currentDepth <= depth\n\n if (\n typeof id !== 'string' &&\n typeof id !== 'number' &&\n typeof id?.toString === 'function' &&\n typeof id !== 'object'\n ) {\n id = id.toString()\n }\n\n if (shouldPopulate) {\n relationshipValue = await req.payloadDataLoader.load(\n createDataloaderCacheKey({\n collectionSlug: relatedCollection.config.slug,\n currentDepth: currentDepth + 1,\n depth,\n docID: id as string,\n draft,\n fallbackLocale,\n locale,\n overrideAccess,\n select: relatedCollection.config.defaultPopulate,\n showHiddenFields,\n transactionID: req.transactionID,\n }),\n )\n }\n\n if (!relationshipValue) {\n // ids are visible regardless of access controls\n relationshipValue = id\n }\n if (typeof index === 'number' && typeof key === 'string') {\n if (field.type !== 'join' && Array.isArray(field.relationTo)) {\n dataToUpdate[field.name][key][index].value = relationshipValue\n } else {\n dataToUpdate[field.name][key][index] = relationshipValue\n }\n } else if (typeof index === 'number' || typeof key === 'string') {\n if (field.type === 'join') {\n dataToUpdate[field.name].docs[index ?? key] = relationshipValue\n } else if (Array.isArray(field.relationTo)) {\n dataToUpdate[field.name][index ?? key].value = relationshipValue\n } else {\n dataToUpdate[field.name][index ?? key] = relationshipValue\n }\n } else if (field.type !== 'join' && Array.isArray(field.relationTo)) {\n dataToUpdate[field.name].value = relationshipValue\n } else {\n dataToUpdate[field.name] = relationshipValue\n }\n }\n}\n\ntype PromiseArgs = {\n currentDepth: number\n depth: number\n draft: boolean\n fallbackLocale: null | string\n field: JoinField | RelationshipField | UploadField\n locale: null | string\n overrideAccess: boolean\n req: PayloadRequest\n showHiddenFields: boolean\n siblingDoc: Record<string, any>\n}\n\nexport const relationshipPopulationPromise = async ({\n currentDepth,\n depth,\n draft,\n fallbackLocale,\n field,\n locale,\n overrideAccess,\n req,\n showHiddenFields,\n siblingDoc,\n}: PromiseArgs): Promise<void> => {\n const resultingDoc = siblingDoc\n const populateDepth = fieldHasMaxDepth(field) && field.maxDepth < depth ? field.maxDepth : depth\n const rowPromises = []\n\n if (field.type === 'join' || (fieldSupportsMany(field) && field.hasMany)) {\n if (\n field.localized &&\n locale === 'all' &&\n typeof siblingDoc[field.name] === 'object' &&\n siblingDoc[field.name] !== null\n ) {\n Object.keys(siblingDoc[field.name]).forEach((localeKey) => {\n if (Array.isArray(siblingDoc[field.name][localeKey])) {\n siblingDoc[field.name][localeKey].forEach((relatedDoc, index) => {\n const rowPromise = async () => {\n await populate({\n currentDepth,\n data: siblingDoc[field.name][localeKey][index],\n dataReference: resultingDoc,\n depth: populateDepth,\n draft,\n fallbackLocale,\n field,\n index,\n key: localeKey,\n locale,\n overrideAccess,\n req,\n showHiddenFields,\n })\n }\n rowPromises.push(rowPromise())\n })\n }\n })\n } else if (\n Array.isArray(siblingDoc[field.name]) ||\n Array.isArray(siblingDoc[field.name]?.docs)\n ) {\n ;(Array.isArray(siblingDoc[field.name])\n ? siblingDoc[field.name]\n : siblingDoc[field.name].docs\n ).forEach((relatedDoc, index) => {\n const rowPromise = async () => {\n if (relatedDoc) {\n await populate({\n currentDepth,\n data: relatedDoc?.id ? relatedDoc.id : relatedDoc,\n dataReference: resultingDoc,\n depth: populateDepth,\n draft,\n fallbackLocale,\n field,\n index,\n locale,\n overrideAccess,\n req,\n showHiddenFields,\n })\n }\n }\n\n rowPromises.push(rowPromise())\n })\n }\n } else if (\n field.localized &&\n locale === 'all' &&\n typeof siblingDoc[field.name] === 'object' &&\n siblingDoc[field.name] !== null\n ) {\n Object.keys(siblingDoc[field.name]).forEach((localeKey) => {\n const rowPromise = async () => {\n await populate({\n currentDepth,\n data: siblingDoc[field.name][localeKey],\n dataReference: resultingDoc,\n depth: populateDepth,\n draft,\n fallbackLocale,\n field,\n key: localeKey,\n locale,\n overrideAccess,\n req,\n showHiddenFields,\n })\n }\n rowPromises.push(rowPromise())\n })\n\n await Promise.all(rowPromises)\n } else if (siblingDoc[field.name]) {\n await populate({\n currentDepth,\n data: siblingDoc[field.name],\n dataReference: resultingDoc,\n depth: populateDepth,\n draft,\n fallbackLocale,\n field,\n locale,\n overrideAccess,\n req,\n showHiddenFields,\n })\n }\n await Promise.all(rowPromises)\n}\n"],"names":["createDataloaderCacheKey","fieldHasMaxDepth","fieldSupportsMany","populate","currentDepth","data","dataReference","depth","draft","fallbackLocale","field","index","key","locale","overrideAccess","req","showHiddenFields","dataToUpdate","relation","type","collection","Array","isArray","relationTo","relatedCollection","payload","collections","id","value","relationshipValue","shouldPopulate","toString","payloadDataLoader","load","collectionSlug","config","slug","docID","select","defaultPopulate","transactionID","name","docs","relationshipPopulationPromise","siblingDoc","resultingDoc","populateDepth","maxDepth","rowPromises","hasMany","localized","Object","keys","forEach","localeKey","relatedDoc","rowPromise","push","Promise","all"],"mappings":"AAGA,SAASA,wBAAwB,QAAQ,qCAAoC;AAC7E,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,wBAAuB;AAkB3E,MAAMC,WAAW,OAAO,EACtBC,YAAY,EACZC,IAAI,EACJC,aAAa,EACbC,KAAK,EACLC,KAAK,EACLC,cAAc,EACdC,KAAK,EACLC,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,cAAc,EACdC,GAAG,EACHC,g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UAAU,CAAClC,MAAM+B,IAAI,CAAC,KAAK,YAClCG,UAAU,CAAClC,MAAM+B,IAAI,CAAC,KAAK,MAC3B;QACAU,OAAOC,IAAI,CAACR,UAAU,CAAClC,MAAM+B,IAAI,CAAC,EAAEY,OAAO,CAAC,CAACC;YAC3C,MAAME,aAAa;gBACjB,MAAMrD,SAAS;oBACbC;oBACAC,MAAMuC,UAAU,CAAClC,MAAM+B,IAAI,CAAC,CAACa,UAAU;oBACvChD,eAAeuC;oBACftC,OAAOuC;oBACPtC;oBACAC;oBACAC;oBACAE,KAAK0C;oBACLzC;oBACAC;oBACAC;oBACAC;gBACF;YACF;YACAgC,YAAYS,IAAI,CAACD;QACnB;QAEA,MAAME,QAAQC,GAAG,CAACX;IACpB,OAAO,IAAIJ,UAAU,CAAClC,MAAM+B,IAAI,CAAC,EAAE;QACjC,MAAMtC,SAAS;YACbC;YACAC,MAAMuC,UAAU,CAAClC,MAAM+B,IAAI,CAAC;YAC5BnC,eAAeuC;YACftC,OAAOuC;YACPtC;YACAC;YACAC;YACAG;YACAC;YACAC;YACAC;QACF;IACF;IACA,MAAM0C,QAAQC,GAAG,CAACX;AACpB,EAAC"}
1
+ {"version":3,"sources":["../../../../src/fields/hooks/afterRead/relationshipPopulationPromise.ts"],"sourcesContent":["import type { PayloadRequest, PopulateType } from '../../../types/index.js'\nimport type { JoinField, RelationshipField, UploadField } from '../../config/types.js'\n\nimport { createDataloaderCacheKey } from '../../../collections/dataloader.js'\nimport { fieldHasMaxDepth, fieldSupportsMany } from '../../config/types.js'\n\ntype PopulateArgs = {\n currentDepth: number\n data: Record<string, unknown>\n dataReference: Record<string, any>\n depth: number\n draft: boolean\n fallbackLocale: null | string\n field: JoinField | RelationshipField | UploadField\n index?: number\n key?: string\n locale: null | string\n overrideAccess: boolean\n populateArg?: PopulateType\n req: PayloadRequest\n showHiddenFields: boolean\n}\n\nconst populate = async ({\n currentDepth,\n data,\n dataReference,\n depth,\n draft,\n fallbackLocale,\n field,\n index,\n key,\n locale,\n overrideAccess,\n populateArg,\n req,\n showHiddenFields,\n}: PopulateArgs) => {\n const dataToUpdate = dataReference\n let relation\n if (field.type === 'join') {\n relation = field.collection\n } else {\n relation = Array.isArray(field.relationTo) ? (data.relationTo as string) : field.relationTo\n }\n const relatedCollection = req.payload.collections[relation]\n\n if (relatedCollection) {\n let id = field.type !== 'join' && Array.isArray(field.relationTo) ? data.value : data\n let relationshipValue\n const shouldPopulate = depth && currentDepth <= depth\n\n if (\n typeof id !== 'string' &&\n typeof id !== 'number' &&\n typeof id?.toString === 'function' &&\n typeof id !== 'object'\n ) {\n id = id.toString()\n }\n\n if (shouldPopulate) {\n relationshipValue = await req.payloadDataLoader.load(\n createDataloaderCacheKey({\n collectionSlug: relatedCollection.config.slug,\n currentDepth: currentDepth + 1,\n depth,\n docID: id as string,\n draft,\n fallbackLocale,\n locale,\n overrideAccess,\n select:\n populateArg?.[relatedCollection.config.slug] ??\n relatedCollection.config.defaultPopulate,\n showHiddenFields,\n transactionID: req.transactionID,\n }),\n )\n }\n\n if (!relationshipValue) {\n // ids are visible regardless of access controls\n relationshipValue = id\n }\n if (typeof index === 'number' && typeof key === 'string') {\n if (field.type !== 'join' && Array.isArray(field.relationTo)) {\n dataToUpdate[field.name][key][index].value = relationshipValue\n } else {\n dataToUpdate[field.name][key][index] = relationshipValue\n }\n } else if (typeof index === 'number' || typeof key === 'string') {\n if (field.type === 'join') {\n dataToUpdate[field.name].docs[index ?? key] = relationshipValue\n } else if (Array.isArray(field.relationTo)) {\n dataToUpdate[field.name][index ?? key].value = relationshipValue\n } else {\n dataToUpdate[field.name][index ?? key] = relationshipValue\n }\n } else if (field.type !== 'join' && Array.isArray(field.relationTo)) {\n dataToUpdate[field.name].value = relationshipValue\n } else {\n dataToUpdate[field.name] = relationshipValue\n }\n }\n}\n\ntype PromiseArgs = {\n currentDepth: number\n depth: number\n draft: boolean\n fallbackLocale: null | string\n field: JoinField | RelationshipField | UploadField\n locale: null | string\n overrideAccess: boolean\n populate?: PopulateType\n req: PayloadRequest\n showHiddenFields: boolean\n siblingDoc: Record<string, any>\n}\n\nexport const relationshipPopulationPromise = async ({\n currentDepth,\n depth,\n draft,\n fallbackLocale,\n field,\n locale,\n overrideAccess,\n populate: populateArg,\n req,\n showHiddenFields,\n siblingDoc,\n}: PromiseArgs): Promise<void> => {\n const resultingDoc = siblingDoc\n const populateDepth = fieldHasMaxDepth(field) && field.maxDepth < depth ? field.maxDepth : depth\n const rowPromises = []\n\n if (field.type === 'join' || (fieldSupportsMany(field) && field.hasMany)) {\n if (\n field.localized &&\n locale === 'all' &&\n typeof siblingDoc[field.name] === 'object' &&\n siblingDoc[field.name] !== null\n ) {\n Object.keys(siblingDoc[field.name]).forEach((localeKey) => {\n if (Array.isArray(siblingDoc[field.name][localeKey])) {\n siblingDoc[field.name][localeKey].forEach((relatedDoc, index) => {\n const rowPromise = async () => {\n await populate({\n currentDepth,\n data: siblingDoc[field.name][localeKey][index],\n dataReference: resultingDoc,\n depth: populateDepth,\n draft,\n fallbackLocale,\n field,\n index,\n key: localeKey,\n locale,\n overrideAccess,\n populateArg,\n req,\n showHiddenFields,\n })\n }\n rowPromises.push(rowPromise())\n })\n }\n })\n } else if (\n Array.isArray(siblingDoc[field.name]) ||\n Array.isArray(siblingDoc[field.name]?.docs)\n ) {\n ;(Array.isArray(siblingDoc[field.name])\n ? siblingDoc[field.name]\n : siblingDoc[field.name].docs\n ).forEach((relatedDoc, index) => {\n const rowPromise = async () => {\n if (relatedDoc) {\n await populate({\n currentDepth,\n data: relatedDoc?.id ? relatedDoc.id : relatedDoc,\n dataReference: resultingDoc,\n depth: populateDepth,\n draft,\n fallbackLocale,\n field,\n index,\n locale,\n overrideAccess,\n populateArg,\n req,\n showHiddenFields,\n })\n }\n }\n\n rowPromises.push(rowPromise())\n })\n }\n } else if (\n field.localized &&\n locale === 'all' &&\n typeof siblingDoc[field.name] === 'object' &&\n siblingDoc[field.name] !== null\n ) {\n Object.keys(siblingDoc[field.name]).forEach((localeKey) => {\n const rowPromise = async () => {\n await populate({\n currentDepth,\n data: siblingDoc[field.name][localeKey],\n dataReference: resultingDoc,\n depth: populateDepth,\n draft,\n fallbackLocale,\n field,\n key: localeKey,\n locale,\n overrideAccess,\n populateArg,\n req,\n showHiddenFields,\n })\n }\n rowPromises.push(rowPromise())\n })\n\n await Promise.all(rowPromises)\n } else if (siblingDoc[field.name]) {\n await populate({\n currentDepth,\n data: siblingDoc[field.name],\n dataReference: resultingDoc,\n depth: populateDepth,\n draft,\n fallbackLocale,\n field,\n locale,\n overrideAccess,\n populateArg,\n req,\n showHiddenFields,\n })\n }\n await Promise.all(rowPromises)\n}\n"],"names":["createDataloaderCacheKey","fieldHasMaxDepth","fieldSupportsMany","populate","currentDepth","data","dataReference","depth","draft","fallbackLocale","field","index","key","locale","overrideAccess","populateArg","req","showHiddenFields","dataToUpdate","relation","type","collection","Array","isArray","relationTo","relatedCollection","payload","collections","id","value","relationshipValue","shouldPopulate","toString","payloadDataLoader","load","collectionSlug","config","slug","docID","select","defaultPopulate","transactionID","name","docs","relationshipPopulationPromise","siblingDoc","resultingDoc","populateDepth","maxDepth","rowPromises","hasMany","localized","Object","keys","forEach","localeKey","relatedDoc","rowPromise","push","Promise","all"],"mappings":"AAGA,SAASA,wBAAwB,QAAQ,qCAAoC;AAC7E,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,wBAAuB;AAmB3E,MAAMC,WAAW,OAAO,EACtBC,YAAY,EACZC,IAAI,EACJC,aAAa,EACbC,KAAK,EACLC,KAAK,EACLC,cAAc,EACdC,KAAK,EACLC,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,cAAc,EACdC,WAAW,EACXC,GAAG,EACHC,gBAAgB,EACH;IACb,MAAMC,eAAeZ;IACrB,IAAIa;IACJ,IAAIT,MAAMU,IAAI,KAAK,QAAQ;QACzBD,WAAWT,MAAMW,UAAU;IAC7B,OAAO;QACLF,WAAWG,MAAMC,OAAO,CAACb,MAAMc,U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,MAC3B;QACAU,OAAOC,IAAI,CAACR,UAAU,CAACnC,MAAMgC,IAAI,CAAC,EAAEY,OAAO,CAAC,CAACC;YAC3C,MAAME,aAAa;gBACjB,MAAMtD,SAAS;oBACbC;oBACAC,MAAMwC,UAAU,CAACnC,MAAMgC,IAAI,CAAC,CAACa,UAAU;oBACvCjD,eAAewC;oBACfvC,OAAOwC;oBACPvC;oBACAC;oBACAC;oBACAE,KAAK2C;oBACL1C;oBACAC;oBACAC;oBACAC;oBACAC;gBACF;YACF;YACAgC,YAAYS,IAAI,CAACD;QACnB;QAEA,MAAME,QAAQC,GAAG,CAACX;IACpB,OAAO,IAAIJ,UAAU,CAACnC,MAAMgC,IAAI,CAAC,EAAE;QACjC,MAAMvC,SAAS;YACbC;YACAC,MAAMwC,UAAU,CAACnC,MAAMgC,IAAI,CAAC;YAC5BpC,eAAewC;YACfvC,OAAOwC;YACPvC;YACAC;YACAC;YACAG;YACAC;YACAC;YACAC;YACAC;QACF;IACF;IACA,MAAM0C,QAAQC,GAAG,CAACX;AACpB,EAAC"}
@@ -1,7 +1,7 @@
1
1
  import type { SanitizedCollectionConfig } from '../../../collections/config/types.js';
2
2
  import type { SanitizedGlobalConfig } from '../../../globals/config/types.js';
3
3
  import type { RequestContext } from '../../../index.js';
4
- import type { JsonObject, PayloadRequest, SelectMode, SelectType } from '../../../types/index.js';
4
+ import type { JsonObject, PayloadRequest, PopulateType, SelectMode, SelectType } from '../../../types/index.js';
5
5
  import type { Field, TabAsField } from '../../config/types.js';
6
6
  type Args = {
7
7
  collection: null | SanitizedCollectionConfig;
@@ -22,6 +22,7 @@ type Args = {
22
22
  locale: null | string;
23
23
  overrideAccess: boolean;
24
24
  path: (number | string)[];
25
+ populate?: PopulateType;
25
26
  populationPromises: Promise<void>[];
26
27
  req: PayloadRequest;
27
28
  schemaPath: string[];
@@ -32,6 +33,6 @@ type Args = {
32
33
  triggerAccessControl?: boolean;
33
34
  triggerHooks?: boolean;
34
35
  };
35
- export declare const traverseFields: ({ collection, context, currentDepth, depth, doc, draft, fallbackLocale, fieldPromises, fields, findMany, flattenLocales, global, locale, overrideAccess, path, populationPromises, req, schemaPath, select, selectMode, showHiddenFields, siblingDoc, triggerAccessControl, triggerHooks, }: Args) => void;
36
+ export declare const traverseFields: ({ collection, context, currentDepth, depth, doc, draft, fallbackLocale, fieldPromises, fields, findMany, flattenLocales, global, locale, overrideAccess, path, populate, populationPromises, req, schemaPath, select, selectMode, showHiddenFields, siblingDoc, triggerAccessControl, triggerHooks, }: Args) => void;
36
37
  export {};
37
38
  //# sourceMappingURL=traverseFields.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/afterRead/traverseFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACjG,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAI9D,KAAK,IAAI,GAAG;IACV,UAAU,EAAE,IAAI,GAAG,yBAAyB,CAAA;IAC5C,OAAO,EAAE,cAAc,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,UAAU,CAAA;IACf,KAAK,EAAE,OAAO,CAAA;IACd,cAAc,EAAE,IAAI,GAAG,MAAM,CAAA;IAC7B;;OAEG;IACH,aAAa,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAA;IAC9B,MAAM,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,EAAE,CAAA;IAC9B,QAAQ,EAAE,OAAO,CAAA;IACjB,cAAc,EAAE,OAAO,CAAA;IACvB,MAAM,EAAE,IAAI,GAAG,qBAAqB,CAAA;IACpC,MAAM,EAAE,IAAI,GAAG,MAAM,CAAA;IACrB,cAAc,EAAE,OAAO,CAAA;IACvB,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;IACzB,kBAAkB,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAA;IACnC,GAAG,EAAE,cAAc,CAAA;IACnB,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,gBAAgB,EAAE,OAAO,CAAA;IACzB,UAAU,EAAE,UAAU,CAAA;IACtB,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,cAAc,gSAyBxB,IAAI,KAAG,IA+BT,CAAA"}
1
+ {"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/afterRead/traverseFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,YAAY,EACZ,UAAU,EACV,UAAU,EACX,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAI9D,KAAK,IAAI,GAAG;IACV,UAAU,EAAE,IAAI,GAAG,yBAAyB,CAAA;IAC5C,OAAO,EAAE,cAAc,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,UAAU,CAAA;IACf,KAAK,EAAE,OAAO,CAAA;IACd,cAAc,EAAE,IAAI,GAAG,MAAM,CAAA;IAC7B;;OAEG;IACH,aAAa,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAA;IAC9B,MAAM,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,EAAE,CAAA;IAC9B,QAAQ,EAAE,OAAO,CAAA;IACjB,cAAc,EAAE,OAAO,CAAA;IACvB,MAAM,EAAE,IAAI,GAAG,qBAAqB,CAAA;IACpC,MAAM,EAAE,IAAI,GAAG,MAAM,CAAA;IACrB,cAAc,EAAE,OAAO,CAAA;IACvB,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;IACzB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,kBAAkB,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAA;IACnC,GAAG,EAAE,cAAc,CAAA;IACnB,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,gBAAgB,EAAE,OAAO,CAAA;IACzB,UAAU,EAAE,UAAU,CAAA;IACtB,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,cAAc,0SA0BxB,IAAI,KAAG,IAgCT,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { promise } from './promise.js';
2
- export const traverseFields = ({ collection, context, currentDepth, depth, doc, draft, fallbackLocale, fieldPromises, fields, findMany, flattenLocales, global, locale, overrideAccess, path, populationPromises, req, schemaPath, select, selectMode, showHiddenFields, siblingDoc, triggerAccessControl = true, triggerHooks = true })=>{
2
+ export const traverseFields = ({ collection, context, currentDepth, depth, doc, draft, fallbackLocale, fieldPromises, fields, findMany, flattenLocales, global, locale, overrideAccess, path, populate, populationPromises, req, schemaPath, select, selectMode, showHiddenFields, siblingDoc, triggerAccessControl = true, triggerHooks = true })=>{
3
3
  fields.forEach((field)=>{
4
4
  fieldPromises.push(promise({
5
5
  collection,
@@ -18,6 +18,7 @@ export const traverseFields = ({ collection, context, currentDepth, depth, doc,
18
18
  overrideAccess,
19
19
  parentPath: path,
20
20
  parentSchemaPath: schemaPath,
21
+ populate,
21
22
  populationPromises,
22
23
  req,
23
24
  select,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/fields/hooks/afterRead/traverseFields.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { RequestContext } from '../../../index.js'\nimport type { JsonObject, PayloadRequest, SelectMode, SelectType } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { promise } from './promise.js'\n\ntype Args = {\n collection: null | SanitizedCollectionConfig\n context: RequestContext\n currentDepth: number\n depth: number\n doc: JsonObject\n draft: boolean\n fallbackLocale: null | string\n /**\n * fieldPromises are used for things like field hooks. They should be awaited before awaiting populationPromises\n */\n fieldPromises: Promise<void>[]\n fields: (Field | TabAsField)[]\n findMany: boolean\n flattenLocales: boolean\n global: null | SanitizedGlobalConfig\n locale: null | string\n overrideAccess: boolean\n path: (number | string)[]\n populationPromises: Promise<void>[]\n req: PayloadRequest\n schemaPath: string[]\n select?: SelectType\n selectMode?: SelectMode\n showHiddenFields: boolean\n siblingDoc: JsonObject\n triggerAccessControl?: boolean\n triggerHooks?: boolean\n}\n\nexport const traverseFields = ({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path,\n populationPromises,\n req,\n schemaPath,\n select,\n selectMode,\n showHiddenFields,\n siblingDoc,\n triggerAccessControl = true,\n triggerHooks = true,\n}: Args): void => {\n fields.forEach((field) => {\n fieldPromises.push(\n promise({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n parentPath: path,\n parentSchemaPath: schemaPath,\n populationPromises,\n req,\n select,\n selectMode,\n showHiddenFields,\n siblingDoc,\n triggerAccessControl,\n triggerHooks,\n }),\n )\n })\n}\n"],"names":["promise","traverseFields","collection","context","currentDepth","depth","doc","draft","fallbackLocale","fieldPromises","fields","findMany","flattenLocales","global","locale","overrideAccess","path","populationPromises","req","schemaPath","select","selectMode","showHiddenFields","siblingDoc","triggerAccessControl","triggerHooks","forEach","field","push","parentPath","parentSchemaPath"],"mappings":"AAMA,SAASA,OAAO,QAAQ,eAAc;AAgCtC,OAAO,MAAMC,iBAAiB,CAAC,EAC7BC,UAAU,EACVC,OAAO,EACPC,YAAY,EACZC,KAAK,EACLC,GAAG,EACHC,KAAK,EACLC,cAAc,EACdC,aAAa,EACbC,MAAM,EACNC,QAAQ,EACRC,cAAc,EACdC,MAAM,EACNC,MAAM,EACNC,cAAc,EACdC,IAAI,EACJC,kBAAkB,EAClBC,GAAG,EACHC,UAAU,EACVC,MAAM,EACNC,UAAU,EACVC,gBAAgB,EAChBC,UAAU,EACVC,uBAAuB,IAAI,EAC3BC,eAAe,IAAI,EACd;IACLf,OAAOgB,OAAO,CAAC,CAACC;QACdlB,cAAcmB,IAAI,CAChB5B,QAAQ;YACNE;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAmB;YACAlB;YACAE;YACAC;YACAC;YACAC;YACAC;YACAc,YAAYb;YACZc,kBAAkBX;YAClBF;YACAC;YACAE;YACAC;YACAC;YACAC;YACAC;YACAC;QACF;IAEJ;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/fields/hooks/afterRead/traverseFields.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { RequestContext } from '../../../index.js'\nimport type {\n JsonObject,\n PayloadRequest,\n PopulateType,\n SelectMode,\n SelectType,\n} from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { promise } from './promise.js'\n\ntype Args = {\n collection: null | SanitizedCollectionConfig\n context: RequestContext\n currentDepth: number\n depth: number\n doc: JsonObject\n draft: boolean\n fallbackLocale: null | string\n /**\n * fieldPromises are used for things like field hooks. They should be awaited before awaiting populationPromises\n */\n fieldPromises: Promise<void>[]\n fields: (Field | TabAsField)[]\n findMany: boolean\n flattenLocales: boolean\n global: null | SanitizedGlobalConfig\n locale: null | string\n overrideAccess: boolean\n path: (number | string)[]\n populate?: PopulateType\n populationPromises: Promise<void>[]\n req: PayloadRequest\n schemaPath: string[]\n select?: SelectType\n selectMode?: SelectMode\n showHiddenFields: boolean\n siblingDoc: JsonObject\n triggerAccessControl?: boolean\n triggerHooks?: boolean\n}\n\nexport const traverseFields = ({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path,\n populate,\n populationPromises,\n req,\n schemaPath,\n select,\n selectMode,\n showHiddenFields,\n siblingDoc,\n triggerAccessControl = true,\n triggerHooks = true,\n}: Args): void => {\n fields.forEach((field) => {\n fieldPromises.push(\n promise({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n parentPath: path,\n parentSchemaPath: schemaPath,\n populate,\n populationPromises,\n req,\n select,\n selectMode,\n showHiddenFields,\n siblingDoc,\n triggerAccessControl,\n triggerHooks,\n }),\n )\n })\n}\n"],"names":["promise","traverseFields","collection","context","currentDepth","depth","doc","draft","fallbackLocale","fieldPromises","fields","findMany","flattenLocales","global","locale","overrideAccess","path","populate","populationPromises","req","schemaPath","select","selectMode","showHiddenFields","siblingDoc","triggerAccessControl","triggerHooks","forEach","field","push","parentPath","parentSchemaPath"],"mappings":"AAYA,SAASA,OAAO,QAAQ,eAAc;AAiCtC,OAAO,MAAMC,iBAAiB,CAAC,EAC7BC,UAAU,EACVC,OAAO,EACPC,YAAY,EACZC,KAAK,EACLC,GAAG,EACHC,KAAK,EACLC,cAAc,EACdC,aAAa,EACbC,MAAM,EACNC,QAAQ,EACRC,cAAc,EACdC,MAAM,EACNC,MAAM,EACNC,cAAc,EACdC,IAAI,EACJC,QAAQ,EACRC,kBAAkB,EAClBC,GAAG,EACHC,UAAU,EACVC,MAAM,EACNC,UAAU,EACVC,gBAAgB,EAChBC,UAAU,EACVC,uBAAuB,IAAI,EAC3BC,eAAe,IAAI,EACd;IACLhB,OAAOiB,OAAO,CAAC,CAACC;QACdnB,cAAcoB,IAAI,CAChB7B,QAAQ;YACNE;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAoB;YACAnB;YACAE;YACAC;YACAC;YACAC;YACAC;YACAe,YAAYd;YACZe,kBAAkBX;YAClBH;YACAC;YACAC;YACAE;YACAC;YACAC;YACAC;YACAC;YACAC;QACF;IAEJ;AACF,EAAC"}
@@ -1,4 +1,4 @@
1
- import type { PayloadRequest, SelectType } from '../../types/index.js';
1
+ import type { PayloadRequest, PopulateType, SelectType } from '../../types/index.js';
2
2
  import type { SanitizedGlobalConfig } from '../config/types.js';
3
3
  type Args = {
4
4
  depth?: number;
@@ -6,6 +6,7 @@ type Args = {
6
6
  globalConfig: SanitizedGlobalConfig;
7
7
  includeLockStatus?: boolean;
8
8
  overrideAccess?: boolean;
9
+ populate?: PopulateType;
9
10
  req: PayloadRequest;
10
11
  select?: SelectType;
11
12
  showHiddenFields?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"findOne.d.ts","sourceRoot":"","sources":["../../../src/globals/operations/findOne.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAS,MAAM,sBAAsB,CAAA;AAC7E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CA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,7 @@ import { getSelectMode } from '../../utilities/getSelectMode.js';
4
4
  import { killTransaction } from '../../utilities/killTransaction.js';
5
5
  import replaceWithDraftIfAvailable from '../../versions/drafts/replaceWithDraftIfAvailable.js';
6
6
  export const findOneOperation = async (args)=>{
7
- const { slug, depth, draft: draftEnabled = false, globalConfig, includeLockStatus, overrideAccess = false, req: { fallbackLocale, locale }, req, select, showHiddenFields } = args;
7
+ const { slug, depth, draft: draftEnabled = false, globalConfig, includeLockStatus, overrideAccess = false, populate, req: { fallbackLocale, locale }, req, select, showHiddenFields } = args;
8
8
  try {
9
9
  // /////////////////////////////////////
10
10
  // Retrieve and execute access
@@ -118,6 +118,7 @@ export const findOneOperation = async (args)=>{
118
118
  global: globalConfig,
119
119
  locale,
120
120
  overrideAccess,
121
+ populate,
121
122
  req,
122
123
  select,
123
124
  showHiddenFields
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/globals/operations/findOne.ts"],"sourcesContent":["import type { AccessResult } from '../../config/types.js'\nimport type { PayloadRequest, SelectType, Where } from '../../types/index.js'\nimport type { SanitizedGlobalConfig } from '../config/types.js'\n\nimport executeAccess from '../../auth/executeAccess.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { getSelectMode } from '../../utilities/getSelectMode.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport replaceWithDraftIfAvailable from '../../versions/drafts/replaceWithDraftIfAvailable.js'\n\ntype Args = {\n depth?: number\n draft?: boolean\n globalConfig: SanitizedGlobalConfig\n includeLockStatus?: boolean\n overrideAccess?: boolean\n req: PayloadRequest\n select?: SelectType\n showHiddenFields?: boolean\n slug: string\n}\n\nexport const findOneOperation = async <T extends Record<string, unknown>>(\n args: Args,\n): Promise<T> => {\n const {\n slug,\n depth,\n draft: draftEnabled = false,\n globalConfig,\n includeLockStatus,\n overrideAccess = false,\n req: { fallbackLocale, locale },\n req,\n select,\n showHiddenFields,\n } = args\n\n try {\n // /////////////////////////////////////\n // Retrieve and execute access\n // /////////////////////////////////////\n\n let accessResult: AccessResult\n\n if (!overrideAccess) {\n accessResult = await executeAccess({ req }, globalConfig.access.read)\n }\n\n // /////////////////////////////////////\n // Perform database operation\n // /////////////////////////////////////\n\n let doc = await req.payload.db.findGlobal({\n slug,\n locale,\n req,\n select,\n where: overrideAccess ? undefined : (accessResult as Where),\n })\n if (!doc) {\n doc = {}\n }\n\n // /////////////////////////////////////\n // Include Lock Status if required\n // /////////////////////////////////////\n if (includeLockStatus && slug) {\n let lockStatus = null\n\n try {\n const lockDocumentsProp = globalConfig?.lockDocuments\n\n const lockDurationDefault = 300 // Default 5 minutes in seconds\n const lockDuration =\n typeof lockDocumentsProp === 'object' ? lockDocumentsProp.duration : lockDurationDefault\n const lockDurationInMilliseconds = lockDuration * 1000\n\n const lockedDocument = await req.payload.find({\n collection: 'payload-locked-documents',\n depth: 1,\n limit: 1,\n overrideAccess: false,\n pagination: false,\n req,\n where: {\n and: [\n {\n globalSlug: {\n equals: slug,\n },\n },\n {\n updatedAt: {\n greater_than: new Date(new Date().getTime() - lockDurationInMilliseconds),\n },\n },\n ],\n },\n })\n\n if (lockedDocument && lockedDocument.docs.length > 0) {\n lockStatus = lockedDocument.docs[0]\n }\n } catch {\n // swallow error\n }\n\n doc._isLocked = !!lockStatus\n doc._userEditing = lockStatus?.user?.value ?? null\n }\n\n // /////////////////////////////////////\n // Replace document with draft if available\n // /////////////////////////////////////\n\n if (globalConfig.versions?.drafts && draftEnabled) {\n doc = await replaceWithDraftIfAvailable({\n accessResult,\n doc,\n entity: globalConfig,\n entityType: 'global',\n overrideAccess,\n req,\n select,\n })\n }\n\n // /////////////////////////////////////\n // Execute before global hook\n // /////////////////////////////////////\n\n await globalConfig.hooks.beforeRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n doc =\n (await hook({\n context: req.context,\n doc,\n global: globalConfig,\n req,\n })) || doc\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // Execute globalType field if not selected\n // /////////////////////////////////////\n if (select && doc.globalType) {\n const selectMode = getSelectMode(select)\n if (\n (selectMode === 'include' && !select['globalType']) ||\n (selectMode === 'exclude' && select['globalType'] === false)\n ) {\n delete doc['globalType']\n }\n }\n\n // /////////////////////////////////////\n // Execute field-level hooks and access\n // /////////////////////////////////////\n\n doc = await afterRead({\n collection: null,\n context: req.context,\n depth,\n doc,\n draft: draftEnabled,\n fallbackLocale,\n global: globalConfig,\n locale,\n overrideAccess,\n req,\n select,\n showHiddenFields,\n })\n\n // /////////////////////////////////////\n // Execute after global hook\n // /////////////////////////////////////\n\n await globalConfig.hooks.afterRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n doc =\n (await hook({\n context: req.context,\n doc,\n global: globalConfig,\n req,\n })) || doc\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n return doc\n } catch (error: unknown) {\n await killTransaction(req)\n throw error\n }\n}\n"],"names":["executeAccess","afterRead","getSelectMode","killTransaction","replaceWithDraftIfAvailable","findOneOperation","args","slug","depth","draft","draftEnabled","globalConfig","includeLockStatus","overrideAccess","req","fallbackLocale","locale","select","showHiddenFields","accessResult","access","read","doc","payload","db","findGlobal","where","undefined","lockStatus","lockDocumentsProp","lockDocuments","lockDurationDefault","lockDuration","duration","lockDurationInMilliseconds","lockedDocument","find","collection","limit","pagination","and","globalSlug","equals","updatedAt","greater_than","Date","getTime","docs","length","_isLocked","_userEditing","user","value","versions","drafts","entity","entityType","hooks","beforeRead","reduce","priorHook","hook","context","global","Promise","resolve","globalType","selectMode","error"],"mappings":"AAIA,OAAOA,mBAAmB,8BAA6B;AACvD,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,aAAa,QAAQ,mCAAkC;AAChE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,OAAOC,iCAAiC,uDAAsD;AAc9F,OAAO,MAAMC,mBAAmB,OAC9BC;IAEA,MAAM,EACJC,IAAI,EACJC,KAAK,EACLC,OAAOC,eAAe,KAAK,EAC3BC,YAAY,EAC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C,MACE,AAAC,MAAMuC,KAAK;gBACVC,SAAShD,IAAIgD,OAAO;gBACpBxC;gBACAyC,QAAQpD;gBACRG;YACF,MAAOQ;QACX,GAAG0C,QAAQC,OAAO;QAElB,wCAAwC;QACxC,iBAAiB;QACjB,wCAAwC;QAExC,OAAO3C;IACT,EAAE,OAAO8C,OAAgB;QACvB,MAAMjE,gBAAgBW;QACtB,MAAMsD;IACR;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/globals/operations/findOne.ts"],"sourcesContent":["import type { AccessResult } from '../../config/types.js'\nimport type { PayloadRequest, PopulateType, SelectType, Where } from '../../types/index.js'\nimport type { SanitizedGlobalConfig } from '../config/types.js'\n\nimport executeAccess from '../../auth/executeAccess.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { getSelectMode } from '../../utilities/getSelectMode.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport replaceWithDraftIfAvailable from '../../versions/drafts/replaceWithDraftIfAvailable.js'\n\ntype Args = {\n depth?: number\n draft?: boolean\n globalConfig: SanitizedGlobalConfig\n includeLockStatus?: boolean\n overrideAccess?: boolean\n populate?: PopulateType\n req: PayloadRequest\n select?: SelectType\n showHiddenFields?: boolean\n slug: string\n}\n\nexport const findOneOperation = async <T extends Record<string, unknown>>(\n args: Args,\n): Promise<T> => {\n const {\n slug,\n depth,\n draft: draftEnabled = false,\n globalConfig,\n includeLockStatus,\n overrideAccess = false,\n populate,\n req: { fallbackLocale, locale },\n req,\n select,\n showHiddenFields,\n } = args\n\n try {\n // /////////////////////////////////////\n // Retrieve and execute access\n // /////////////////////////////////////\n\n let accessResult: AccessResult\n\n if (!overrideAccess) {\n accessResult = await executeAccess({ req }, globalConfig.access.read)\n }\n\n // /////////////////////////////////////\n // Perform database operation\n // /////////////////////////////////////\n\n let doc = await req.payload.db.findGlobal({\n slug,\n locale,\n req,\n select,\n where: overrideAccess ? undefined : (accessResult as Where),\n })\n if (!doc) {\n doc = {}\n }\n\n // /////////////////////////////////////\n // Include Lock Status if required\n // /////////////////////////////////////\n if (includeLockStatus && slug) {\n let lockStatus = null\n\n try {\n const lockDocumentsProp = globalConfig?.lockDocuments\n\n const lockDurationDefault = 300 // Default 5 minutes in seconds\n const lockDuration =\n typeof lockDocumentsProp === 'object' ? lockDocumentsProp.duration : lockDurationDefault\n const lockDurationInMilliseconds = lockDuration * 1000\n\n const lockedDocument = await req.payload.find({\n collection: 'payload-locked-documents',\n depth: 1,\n limit: 1,\n overrideAccess: false,\n pagination: false,\n req,\n where: {\n and: [\n {\n globalSlug: {\n equals: slug,\n },\n },\n {\n updatedAt: {\n greater_than: new Date(new Date().getTime() - lockDurationInMilliseconds),\n },\n },\n ],\n },\n })\n\n if (lockedDocument && lockedDocument.docs.length > 0) {\n lockStatus = lockedDocument.docs[0]\n }\n } catch {\n // swallow error\n }\n\n doc._isLocked = !!lockStatus\n doc._userEditing = lockStatus?.user?.value ?? null\n }\n\n // /////////////////////////////////////\n // Replace document with draft if available\n // /////////////////////////////////////\n\n if (globalConfig.versions?.drafts && draftEnabled) {\n doc = await replaceWithDraftIfAvailable({\n accessResult,\n doc,\n entity: globalConfig,\n entityType: 'global',\n overrideAccess,\n req,\n select,\n })\n }\n\n // /////////////////////////////////////\n // Execute before global hook\n // /////////////////////////////////////\n\n await globalConfig.hooks.beforeRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n doc =\n (await hook({\n context: req.context,\n doc,\n global: globalConfig,\n req,\n })) || doc\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // Execute globalType field if not selected\n // /////////////////////////////////////\n if (select && doc.globalType) {\n const selectMode = getSelectMode(select)\n if (\n (selectMode === 'include' && !select['globalType']) ||\n (selectMode === 'exclude' && select['globalType'] === false)\n ) {\n delete doc['globalType']\n }\n }\n\n // /////////////////////////////////////\n // Execute field-level hooks and access\n // /////////////////////////////////////\n\n doc = await afterRead({\n collection: null,\n context: req.context,\n depth,\n doc,\n draft: draftEnabled,\n fallbackLocale,\n global: globalConfig,\n locale,\n overrideAccess,\n populate,\n req,\n select,\n showHiddenFields,\n })\n\n // /////////////////////////////////////\n // Execute after global hook\n // /////////////////////////////////////\n\n await globalConfig.hooks.afterRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n doc =\n (await hook({\n context: req.context,\n doc,\n global: globalConfig,\n req,\n })) || doc\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n return doc\n } catch (error: unknown) {\n await killTransaction(req)\n throw error\n }\n}\n"],"names":["executeAccess","afterRead","getSelectMode","killTransaction","replaceWithDraftIfAvailable","findOneOperation","args","slug","depth","draft","draftEnabled","globalConfig","includeLockStatus","overrideAccess","populate","req","fallbackLocale","locale","select","showHiddenFields","accessResult","access","read","doc","payload","db","findGlobal","where","undefined","lockStatus","lockDocumentsProp","lockDocuments","lockDurationDefault","lockDuration","duration","lockDurationInMilliseconds","lockedDocument","find","collection","limit","pagination","and","globalSlug","equals","updatedAt","greater_than","Date","getTime","docs","length","_isLocked","_userEditing","user","value","versions","drafts","entity","entityType","hooks","beforeRead","reduce","priorHook","hook","context","global","Promise","resolve","globalType","selectMode","error"],"mappings":"AAIA,OAAOA,mBAAmB,8BAA6B;AACvD,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,aAAa,QAAQ,mCAAkC;AAChE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,OAAOC,iCAAiC,uDAAsD;AAe9F,OAAO,MAAMC,mBAAmB,OAC9BC;IAEA,MAAM,EACJC,IAAI,EACJC,KAAK,EACLC,OAAOC,eAAe,KAAK,EAC3BC,YAAY,EACZC,iBAAiB,EACjBC,iBAAiB,KAAK,EACtBC,QAAQ,EACRC,KAAK,EAAEC,cAAc,EAAEC,MAAM,EAAE,EAC/BF,GAAG,EACHG,MAAM,EACNC,gBAAgB,EACjB,GAAGb;IAEJ,IAAI;QACF,wCAAwC;QACxC,8BAA8B;QAC9B,wCAAwC;QAExC,IAAIc;QAEJ,IAAI,CAACP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AgB;QACvB,MAAMlE,gBAAgBY;QACtB,MAAMsD;IACR;AACF,EAAC"}
@@ -1,4 +1,4 @@
1
- import type { PayloadRequest, SelectType } from '../../types/index.js';
1
+ import type { PayloadRequest, PopulateType, SelectType } from '../../types/index.js';
2
2
  import type { TypeWithVersion } from '../../versions/types.js';
3
3
  import type { SanitizedGlobalConfig } from '../config/types.js';
4
4
  export type Arguments = {
@@ -8,6 +8,7 @@ export type Arguments = {
8
8
  globalConfig: SanitizedGlobalConfig;
9
9
  id: number | string;
10
10
  overrideAccess?: boolean;
11
+ populate?: PopulateType;
11
12
  req: PayloadRequest;
12
13
  select?: SelectType;
13
14
  showHiddenFields?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"findVersionByID.d.ts","sourceRoot":"","sources":["../../../src/globals/operations/findVersionByID.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAU/D,MAAM,MAAM,SAAS,GAAG;IACtB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,YAAY,EAAE,qBAAqB,CAAA;IACnC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,GAAG,EAAE,cAAc,CAAA;IACnB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,CAAA;AAED,eAAO,MAAM,wBAAwB,GAAU,CAAC,SAAS,eAAe,CAAC,CAAC,CAAC,cACnE,SAAS,KACd,OAAO,CAAC,CAAC,CA6HX,CAAA"}
1
+ {"version":3,"file":"findVersionByID.d.ts","sourceRoot":"","sources":["../../../src/globals/operations/findVersionByID.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACpF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAS/D,MAAM,MAAM,SAAS,GAAG;IACtB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,YAAY,EAAE,qBAAqB,CAAA;IACnC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,GAAG,EAAE,cAAc,CAAA;IACnB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,CAAA;AAED,eAAO,MAAM,wBAAwB,GAAU,CAAC,SAAS,eAAe,CAAC,CAAC,CAAC,cACnE,SAAS,KACd,OAAO,CAAC,CAAC,CA+HX,CAAA"}
@@ -5,7 +5,7 @@ import { afterRead } from '../../fields/hooks/afterRead/index.js';
5
5
  import { deepCopyObjectSimple } from '../../utilities/deepCopyObject.js';
6
6
  import { killTransaction } from '../../utilities/killTransaction.js';
7
7
  export const findVersionByIDOperation = async (args)=>{
8
- const { id, currentDepth, depth, disableErrors, globalConfig, overrideAccess, req: { fallbackLocale, locale, payload }, req, select, showHiddenFields } = args;
8
+ const { id, currentDepth, depth, disableErrors, globalConfig, overrideAccess, populate, req: { fallbackLocale, locale, payload }, req, select, showHiddenFields } = args;
9
9
  try {
10
10
  // /////////////////////////////////////
11
11
  // Access
@@ -80,6 +80,7 @@ export const findVersionByIDOperation = async (args)=>{
80
80
  global: globalConfig,
81
81
  locale,
82
82
  overrideAccess,
83
+ populate,
83
84
  req,
84
85
  select: typeof select?.version === 'object' ? select.version : undefined,
85
86
  showHiddenFields
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/globals/operations/findVersionByID.ts"],"sourcesContent":["import type { FindGlobalVersionsArgs } from '../../database/types.js'\nimport type { PayloadRequest, SelectType } from '../../types/index.js'\nimport type { TypeWithVersion } from '../../versions/types.js'\nimport type { SanitizedGlobalConfig } from '../config/types.js'\n\nimport executeAccess from '../../auth/executeAccess.js'\nimport { combineQueries } from '../../database/combineQueries.js'\nimport { Forbidden, NotFound } from '../../errors/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { deepCopyObjectSimple } from '../../utilities/deepCopyObject.js'\nimport { getSelectMode } from '../../utilities/getSelectMode.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\n\nexport type Arguments = {\n currentDepth?: number\n depth?: number\n disableErrors?: boolean\n globalConfig: SanitizedGlobalConfig\n id: number | string\n overrideAccess?: boolean\n req: PayloadRequest\n select?: SelectType\n showHiddenFields?: boolean\n}\n\nexport const findVersionByIDOperation = async <T extends TypeWithVersion<T> = any>(\n args: Arguments,\n): Promise<T> => {\n const {\n id,\n currentDepth,\n depth,\n disableErrors,\n globalConfig,\n overrideAccess,\n req: { fallbackLocale, locale, payload },\n req,\n select,\n showHiddenFields,\n } = args\n\n try {\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n const accessResults = !overrideAccess\n ? await executeAccess({ id, disableErrors, req }, globalConfig.access.readVersions)\n : true\n\n // If errors are disabled, and access returns false, return null\n if (accessResults === false) {\n return null\n }\n\n const hasWhereAccess = typeof accessResults === 'object'\n\n const findGlobalVersionsArgs: FindGlobalVersionsArgs = {\n global: globalConfig.slug,\n limit: 1,\n locale,\n req,\n select,\n where: combineQueries({ id: { equals: id } }, accessResults),\n }\n\n // /////////////////////////////////////\n // Find by ID\n // /////////////////////////////////////\n\n if (!findGlobalVersionsArgs.where.and[0].id) {\n throw new NotFound(req.t)\n }\n\n const { docs: results } = await payload.db.findGlobalVersions(findGlobalVersionsArgs)\n if (!results || results?.length === 0) {\n if (!disableErrors) {\n if (!hasWhereAccess) {\n throw new NotFound(req.t)\n }\n if (hasWhereAccess) {\n throw new Forbidden(req.t)\n }\n }\n\n return null\n }\n\n // Clone the result - it may have come back memoized\n let result: any = deepCopyObjectSimple(results[0])\n\n // Patch globalType onto version doc\n result.version.globalType = globalConfig.slug\n\n // /////////////////////////////////////\n // beforeRead - Collection\n // /////////////////////////////////////\n\n await globalConfig.hooks.beforeRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n result =\n (await hook({\n context: req.context,\n doc: result.version,\n global: globalConfig,\n req,\n })) || result.version\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result.version = await afterRead({\n collection: null,\n context: req.context,\n currentDepth,\n depth,\n doc: result.version,\n draft: undefined,\n fallbackLocale,\n global: globalConfig,\n locale,\n overrideAccess,\n req,\n select: typeof select?.version === 'object' ? select.version : undefined,\n showHiddenFields,\n })\n\n // /////////////////////////////////////\n // afterRead - Global\n // /////////////////////////////////////\n\n await globalConfig.hooks.afterRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n result.version =\n (await hook({\n context: req.context,\n doc: result.version,\n global: globalConfig,\n query: findGlobalVersionsArgs.where,\n req,\n })) || result.version\n }, Promise.resolve())\n\n return result\n } catch (error: unknown) {\n await killTransaction(req)\n throw error\n }\n}\n"],"names":["executeAccess","combineQueries","Forbidden","NotFound","afterRead","deepCopyObjectSimple","killTransaction","findVersionByIDOperation","args","id","currentDepth","depth","disableErrors","globalConfig","overrideAccess","req","fallbackLocale","locale","payload","select","showHiddenFields","accessResults","access","readVersions","hasWhereAccess","findGlobalVersionsArgs","global","slug","limit","where","equals","and","t","docs","results","db","findGlobalVersions","length","result","version","globalType","hooks","beforeRead","reduce","priorHook","hook","context","doc","Promise","resolve","collection","draft","undefined","query","error"],"mappings":"AAKA,OAAOA,mBA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OAAgB;QACvB,MAAMhD,gBAAgBS;QACtB,MAAMuC;IACR;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/globals/operations/findVersionByID.ts"],"sourcesContent":["import type { FindGlobalVersionsArgs } from '../../database/types.js'\nimport type { PayloadRequest, PopulateType, SelectType } from '../../types/index.js'\nimport type { TypeWithVersion } from '../../versions/types.js'\nimport type { SanitizedGlobalConfig } from '../config/types.js'\n\nimport executeAccess from '../../auth/executeAccess.js'\nimport { combineQueries } from '../../database/combineQueries.js'\nimport { Forbidden, NotFound } from '../../errors/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { deepCopyObjectSimple } from '../../utilities/deepCopyObject.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\n\nexport type Arguments = {\n currentDepth?: number\n depth?: number\n disableErrors?: boolean\n globalConfig: SanitizedGlobalConfig\n id: number | string\n overrideAccess?: boolean\n populate?: PopulateType\n req: PayloadRequest\n select?: SelectType\n showHiddenFields?: boolean\n}\n\nexport const findVersionByIDOperation = async <T extends TypeWithVersion<T> = any>(\n args: Arguments,\n): Promise<T> => {\n const {\n id,\n currentDepth,\n depth,\n disableErrors,\n globalConfig,\n overrideAccess,\n populate,\n req: { fallbackLocale, locale, payload },\n req,\n select,\n showHiddenFields,\n } = args\n\n try {\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n const accessResults = !overrideAccess\n ? await executeAccess({ id, disableErrors, req }, globalConfig.access.readVersions)\n : true\n\n // If errors are disabled, and access returns false, return null\n if (accessResults === false) {\n return null\n }\n\n const hasWhereAccess = typeof accessResults === 'object'\n\n const findGlobalVersionsArgs: FindGlobalVersionsArgs = {\n global: globalConfig.slug,\n limit: 1,\n locale,\n req,\n select,\n where: combineQueries({ id: { equals: id } }, accessResults),\n }\n\n // /////////////////////////////////////\n // Find by ID\n // /////////////////////////////////////\n\n if (!findGlobalVersionsArgs.where.and[0].id) {\n throw new NotFound(req.t)\n }\n\n const { docs: results } = await payload.db.findGlobalVersions(findGlobalVersionsArgs)\n if (!results || results?.length === 0) {\n if (!disableErrors) {\n if (!hasWhereAccess) {\n throw new NotFound(req.t)\n }\n if (hasWhereAccess) {\n throw new Forbidden(req.t)\n }\n }\n\n return null\n }\n\n // Clone the result - it may have come back memoized\n let result: any = deepCopyObjectSimple(results[0])\n\n // Patch globalType onto version doc\n result.version.globalType = globalConfig.slug\n\n // /////////////////////////////////////\n // beforeRead - Collection\n // /////////////////////////////////////\n\n await globalConfig.hooks.beforeRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n result =\n (await hook({\n context: req.context,\n doc: result.version,\n global: globalConfig,\n req,\n })) || result.version\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result.version = await afterRead({\n collection: null,\n context: req.context,\n currentDepth,\n depth,\n doc: result.version,\n draft: undefined,\n fallbackLocale,\n global: globalConfig,\n locale,\n overrideAccess,\n populate,\n req,\n select: typeof select?.version === 'object' ? select.version : undefined,\n showHiddenFields,\n })\n\n // /////////////////////////////////////\n // afterRead - Global\n // /////////////////////////////////////\n\n await globalConfig.hooks.afterRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n result.version =\n (await hook({\n context: req.context,\n doc: result.version,\n global: globalConfig,\n query: findGlobalVersionsArgs.where,\n req,\n })) || result.version\n }, Promise.resolve())\n\n return result\n } catch (error: unknown) {\n await killTransaction(req)\n throw error\n }\n}\n"],"names":["executeAccess","combineQueries","Forbidden","NotFound","afterRead","deepCopyObjectSimple","killTransaction","findVersionByIDOperation","args","id","currentDepth","depth","disableErrors","globalConfig","overrideAccess","populate","req","fallbackLocale","locale","payload","select","showHiddenFields","accessResults","access","readVersions","hasWhereAccess","findGlobalVersionsArgs","global","slug","limit","where","equals","and","t","docs","results","db","findGlobalVersions","length","result","version","globalType","hooks","beforeRead","reduce","priorHook","hook","context","doc","Promise","resolve","collection","draft","undefined","query","error"],"mappings":"AAKA,OAAOA,mBAAmB,8BAA6B;AACvD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OAAgB;QACvB,MAAMjD,gBAAgBU;QACtB,MAAMuC;IACR;AACF,EAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { PaginatedDocs } from '../../database/types.js';
2
- import type { PayloadRequest, SelectType, Sort, Where } from '../../types/index.js';
2
+ import type { PayloadRequest, PopulateType, SelectType, Sort, Where } from '../../types/index.js';
3
3
  import type { TypeWithVersion } from '../../versions/types.js';
4
4
  import type { SanitizedGlobalConfig } from '../config/types.js';
5
5
  export type Arguments = {
@@ -9,6 +9,7 @@ export type Arguments = {
9
9
  overrideAccess?: boolean;
10
10
  page?: number;
11
11
  pagination?: boolean;
12
+ populate?: PopulateType;
12
13
  req?: PayloadRequest;
13
14
  select?: SelectType;
14
15
  showHiddenFields?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"findVersions.d.ts","sourceRoot":"","sources":["../../../src/globals/operations/findVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AACnF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAU/D,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,qBAAqB,CAAA;IACnC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,GAAG,CAAC,EAAE,cAAc,CAAA;IACpB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;AAED,eAAO,MAAM,qBAAqB,GAAU,CAAC,SAAS,eAAe,CAAC,CAAC,CAAC,QAChE,SAAS,KACd,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAkI1B,CAAA"}
1
+ {"version":3,"file":"findVersions.d.ts","sourceRoot":"","sources":["../../../src/globals/operations/findVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AACjG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAU/D,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,qBAAqB,CAAA;IACnC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,GAAG,CAAC,EAAE,cAAc,CAAA;IACpB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;AAED,eAAO,MAAM,qBAAqB,GAAU,CAAC,SAAS,eAAe,CAAC,CAAC,CAAC,QAChE,SAAS,KACd,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAoI1B,CAAA"}
@@ -6,7 +6,7 @@ import { killTransaction } from '../../utilities/killTransaction.js';
6
6
  import sanitizeInternalFields from '../../utilities/sanitizeInternalFields.js';
7
7
  import { buildVersionGlobalFields } from '../../versions/buildGlobalFields.js';
8
8
  export const findVersionsOperation = async (args)=>{
9
- const { depth, globalConfig, limit, overrideAccess, page, pagination = true, req: { fallbackLocale, locale, payload }, req, select, showHiddenFields, sort, where } = args;
9
+ const { depth, globalConfig, limit, overrideAccess, page, pagination = true, populate, req: { fallbackLocale, locale, payload }, req, select, showHiddenFields, sort, where } = args;
10
10
  const versionFields = buildVersionGlobalFields(payload.config, globalConfig);
11
11
  try {
12
12
  // /////////////////////////////////////
@@ -60,6 +60,7 @@ export const findVersionsOperation = async (args)=>{
60
60
  global: globalConfig,
61
61
  locale,
62
62
  overrideAccess,
63
+ populate,
63
64
  req,
64
65
  select,
65
66
  showHiddenFields
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/globals/operations/findVersions.ts"],"sourcesContent":["import type { PaginatedDocs } from '../../database/types.js'\nimport type { PayloadRequest, SelectType, Sort, Where } from '../../types/index.js'\nimport type { TypeWithVersion } from '../../versions/types.js'\nimport type { SanitizedGlobalConfig } from '../config/types.js'\n\nimport executeAccess from '../../auth/executeAccess.js'\nimport { combineQueries } from '../../database/combineQueries.js'\nimport { validateQueryPaths } from '../../database/queryValidation/validateQueryPaths.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport sanitizeInternalFields from '../../utilities/sanitizeInternalFields.js'\nimport { buildVersionGlobalFields } from '../../versions/buildGlobalFields.js'\n\nexport type Arguments = {\n depth?: number\n globalConfig: SanitizedGlobalConfig\n limit?: number\n overrideAccess?: boolean\n page?: number\n pagination?: boolean\n req?: PayloadRequest\n select?: SelectType\n showHiddenFields?: boolean\n sort?: Sort\n where?: Where\n}\n\nexport const findVersionsOperation = async <T extends TypeWithVersion<T>>(\n args: Arguments,\n): Promise<PaginatedDocs<T>> => {\n const {\n depth,\n globalConfig,\n limit,\n overrideAccess,\n page,\n pagination = true,\n req: { fallbackLocale, locale, payload },\n req,\n select,\n showHiddenFields,\n sort,\n where,\n } = args\n\n const versionFields = buildVersionGlobalFields(payload.config, globalConfig)\n\n try {\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n const accessResults = !overrideAccess\n ? await executeAccess({ req }, globalConfig.access.readVersions)\n : true\n\n await validateQueryPaths({\n globalConfig,\n overrideAccess,\n req,\n versionFields,\n where,\n })\n\n const fullWhere = combineQueries(where, accessResults)\n\n // /////////////////////////////////////\n // Find\n // /////////////////////////////////////\n\n const paginatedDocs = await payload.db.findGlobalVersions<T>({\n global: globalConfig.slug,\n limit: limit ?? 10,\n locale,\n page: page || 1,\n pagination,\n req,\n select,\n sort,\n where: fullWhere,\n })\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n let result = {\n ...paginatedDocs,\n docs: await Promise.all(\n paginatedDocs.docs.map(async (data) => {\n return {\n ...data,\n version: await afterRead<T>({\n collection: null,\n context: req.context,\n depth,\n doc: {\n ...data.version,\n // Patch globalType onto version doc\n globalType: globalConfig.slug,\n },\n draft: undefined,\n fallbackLocale,\n findMany: true,\n global: globalConfig,\n locale,\n overrideAccess,\n req,\n select,\n showHiddenFields,\n }),\n }\n }),\n ),\n } as PaginatedDocs<T>\n\n // /////////////////////////////////////\n // afterRead - Global\n // /////////////////////////////////////\n\n result = {\n ...result,\n docs: await Promise.all(\n result.docs.map(async (doc) => {\n const docRef = doc\n\n await globalConfig.hooks.afterRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n docRef.version =\n (await hook({\n context: req.context,\n doc: doc.version,\n findMany: true,\n global: globalConfig,\n query: fullWhere,\n req,\n })) || doc.version\n }, Promise.resolve())\n\n return docRef\n }),\n ),\n }\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n result = {\n ...result,\n docs: result.docs.map((doc) => sanitizeInternalFields<T>(doc)),\n }\n\n return result\n } catch (error: unknown) {\n await killTransaction(req)\n throw error\n }\n}\n"],"names":["executeAccess","combineQueries","validateQueryPaths","afterRead","killTransaction","sanitizeInternalFields","buildVersionGlobalFields","findVersionsOperation","args","depth","globalConfig","limit","overrideAccess","page","pagination","req","fallbackLocale","locale","payload","select","showHiddenFields","sort","where","versionFields","config","accessResults","access","readVersions","fullWhere","paginatedDocs","db","findGlobalVersions","global","slug","result","docs","Promise","all","map","data","version","collection","context","doc","globalType","draft","undefined","findMany","docRef","hooks","reduce","priorHook","hook","query","resolve","error"],"mappings":"AAKA,OAAOA,mBAAmB,8BAA6B;AACvD,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,kBAAkB,QAAQ,uDAAsD;AACzF,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,OAAOC,4BAA4B,4CAA2C;AAC9E,SAASC,wBAAwB,QAAQ,sCAAqC;AAgB9E,OAAO,MAAMC,wBAAwB,OACnCC;IAEA,MAAM,EACJC,KAAK,EACLC,YAAY,EACZC,KAAK,EACLC,cAAc,EACdC,IAAI,EACJC,aAAa,IAAI,EACjBC,KAAK,EAAEC,cAAc,EAAEC,MAAM,EAAEC,OAAO,EAAE,EACxCH,GAAG,EACHI,MAAM,EACNC,gBAAgB,EAChBC,IAAI,EACJC,KAAK,EACN,GAAGd;IAEJ,MAAMe,gBAAgBjB,yBAAyBY,QAAQM,MAAM,EAAEd;IAE/D,IAAI;QACF,wCAAwC;QACxC,SAAS;QACT,wCAAwC;QAExC,MAAMe,gBAAgB,CAACb,iBACnB,MAAMZ,cAAc;YAAEe;QAAI,GAAGL,aAAagB,MAAM,CAACC,YAAY,IAC7D;QAEJ,MAAMzB,mBAAmB;YACvBQ;YACAE;YACAG;YACAQ;YACAD;QACF;QAEA,MAAMM,YAAY3B,eAAeqB,OAAOG;QAExC,wCAAwC;QACxC,OAAO;QACP,wCAAwC;QAExC,MAAMI,gBAAgB,MAAMX,QAAQY,EAAE,CAACC,kBAAkB,CAAI;YAC3DC,QAAQtB,aAAauB,IAAI;YACzBtB,OAAOA,SAAS;YACh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EAAE,OAAOqB,OAAgB;QACvB,MAAMnD,gBAAgBW;QACtB,MAAMwC;IACR;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/globals/operations/findVersions.ts"],"sourcesContent":["import type { PaginatedDocs } from '../../database/types.js'\nimport type { PayloadRequest, PopulateType, SelectType, Sort, Where } from '../../types/index.js'\nimport type { TypeWithVersion } from '../../versions/types.js'\nimport type { SanitizedGlobalConfig } from '../config/types.js'\n\nimport executeAccess from '../../auth/executeAccess.js'\nimport { combineQueries } from '../../database/combineQueries.js'\nimport { validateQueryPaths } from '../../database/queryValidation/validateQueryPaths.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport sanitizeInternalFields from '../../utilities/sanitizeInternalFields.js'\nimport { buildVersionGlobalFields } from '../../versions/buildGlobalFields.js'\n\nexport type Arguments = {\n depth?: number\n globalConfig: SanitizedGlobalConfig\n limit?: number\n overrideAccess?: boolean\n page?: number\n pagination?: boolean\n populate?: PopulateType\n req?: PayloadRequest\n select?: SelectType\n showHiddenFields?: boolean\n sort?: Sort\n where?: Where\n}\n\nexport const findVersionsOperation = async <T extends TypeWithVersion<T>>(\n args: Arguments,\n): Promise<PaginatedDocs<T>> => {\n const {\n depth,\n globalConfig,\n limit,\n overrideAccess,\n page,\n pagination = true,\n populate,\n req: { fallbackLocale, locale, payload },\n req,\n select,\n showHiddenFields,\n sort,\n where,\n } = args\n\n const versionFields = buildVersionGlobalFields(payload.config, globalConfig)\n\n try {\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n const accessResults = !overrideAccess\n ? await executeAccess({ req }, globalConfig.access.readVersions)\n : true\n\n await validateQueryPaths({\n globalConfig,\n overrideAccess,\n req,\n versionFields,\n where,\n })\n\n const fullWhere = combineQueries(where, accessResults)\n\n // /////////////////////////////////////\n // Find\n // /////////////////////////////////////\n\n const paginatedDocs = await payload.db.findGlobalVersions<T>({\n global: globalConfig.slug,\n limit: limit ?? 10,\n locale,\n page: page || 1,\n pagination,\n req,\n select,\n sort,\n where: fullWhere,\n })\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n let result = {\n ...paginatedDocs,\n docs: await Promise.all(\n paginatedDocs.docs.map(async (data) => {\n return {\n ...data,\n version: await afterRead<T>({\n collection: null,\n context: req.context,\n depth,\n doc: {\n ...data.version,\n // Patch globalType onto version doc\n globalType: globalConfig.slug,\n },\n draft: undefined,\n fallbackLocale,\n findMany: true,\n global: globalConfig,\n locale,\n overrideAccess,\n populate,\n req,\n select,\n showHiddenFields,\n }),\n }\n }),\n ),\n } as PaginatedDocs<T>\n\n // /////////////////////////////////////\n // afterRead - Global\n // /////////////////////////////////////\n\n result = {\n ...result,\n docs: await Promise.all(\n result.docs.map(async (doc) => {\n const docRef = doc\n\n await globalConfig.hooks.afterRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n docRef.version =\n (await hook({\n context: req.context,\n doc: doc.version,\n findMany: true,\n global: globalConfig,\n query: fullWhere,\n req,\n })) || doc.version\n }, Promise.resolve())\n\n return docRef\n }),\n ),\n }\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n result = {\n ...result,\n docs: result.docs.map((doc) => sanitizeInternalFields<T>(doc)),\n }\n\n return result\n } catch (error: unknown) {\n await killTransaction(req)\n throw error\n }\n}\n"],"names":["executeAccess","combineQueries","validateQueryPaths","afterRead","killTransaction","sanitizeInternalFields","buildVersionGlobalFields","findVersionsOperation","args","depth","globalConfig","limit","overrideAccess","page","pagination","populate","req","fallbackLocale","locale","payload","select","showHiddenFields","sort","where","versionFields","config","accessResults","access","readVersions","fullWhere","paginatedDocs","db","findGlobalVersions","global","slug","result","docs","Promise","all","map","data","version","collection","context","doc","globalType","draft","undefined","findMany","docRef","hooks","reduce","priorHook","hook","query","resolve","error"],"mappings":"AAKA,OAAOA,mBAAmB,8BAA6B;AACvD,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,kBAAkB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;wBACpBlC;wBACAmC,KAAK;4BACH,GAAGJ,KAAKC,OAAO;4BACf,oCAAoC;4BACpCI,YAAYnC,aAAawB,IAAI;wBAC/B;wBACAY,OAAOC;wBACP9B;wBACA+B,UAAU;wBACVf,QAAQvB;wBACRQ;wBACAN;wBACAG;wBACAC;wBACAI;wBACAC;oBACF;gBACF;YACF;QAEJ;QAEA,wCAAwC;QACxC,qBAAqB;QACrB,wCAAwC;QAExCc,SAAS;YACP,GAAGA,MAAM;YACTC,MAAM,MAAMC,QAAQC,GAAG,CACrBH,OAAOC,IAAI,CAACG,GAAG,CAAC,OAAOK;gBACrB,MAAMK,SAASL;gBAEf,MAAMlC,aAAawC,KAAK,CAAC/C,SAAS,CAACgD,MAAM,CAAC,OAAOC,WAAWC;oBAC1D,MAAMD;oBAENH,OAAOR,OAAO,GACZ,AAAC,MAAMY,KAAK;wBACVV,SAAS3B,IAAI2B,OAAO;wBACpBC,KAAKA,IAAIH,OAAO;wBAChBO,UAAU;wBACVf,QAAQvB;wBACR4C,OAAOzB;wBACPb;oBACF,MAAO4B,IAAIH,OAAO;gBACtB,GAAGJ,QAAQkB,OAAO;gBAElB,OAAON;YACT;QAEJ;QAEA,wCAAwC;QACxC,iBAAiB;QACjB,wCAAwC;QAExCd,SAAS;YACP,GAAGA,MAAM;YACTC,MAAMD,OAAOC,IAAI,CAACG,GAAG,CAAC,CAACK,MAAQvC,uBAA0BuC;QAC3D;QAEA,OAAOT;IACT,EAAE,OAAOqB,OAAgB;QACvB,MAAMpD,gBAAgBY;QACtB,MAAMwC;IACR;AACF,EAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { GlobalSlug, Payload, RequestContext, TypedLocale } from '../../../index.js';
2
- import type { Document, PayloadRequest, SelectType, TransformGlobalWithSelect } from '../../../types/index.js';
2
+ import type { Document, PayloadRequest, PopulateType, SelectType, TransformGlobalWithSelect } from '../../../types/index.js';
3
3
  import type { SelectFromGlobalSlug } from '../../config/types.js';
4
4
  export type Options<TSlug extends GlobalSlug, TSelect extends SelectType> = {
5
5
  context?: RequestContext;
@@ -9,6 +9,7 @@ export type Options<TSlug extends GlobalSlug, TSelect extends SelectType> = {
9
9
  includeLockStatus?: boolean;
10
10
  locale?: 'all' | TypedLocale;
11
11
  overrideAccess?: boolean;
12
+ populate?: PopulateType;
12
13
  req?: PayloadRequest;
13
14
  select?: TSelect;
14
15
  showHiddenFields?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"findOne.d.ts","sourceRoot":"","sources":["../../../../src/globals/operations/local/findOne.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACzF,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,UAAU,EACV,yBAAyB,EAC1B,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAMjE,MAAM,MAAM,OAAO,CAAC,KAAK,SAAS,UAAU,EAAE,OAAO,SAAS,UAAU,IAAI;IAC1E,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,cAAc,CAAC,EAAE,WAAW,CAAA;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,MAAM,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,GAAG,CAAC,EAAE,cAAc,CAAA;IACpB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,EAAE,KAAK,CAAA;IACX,IAAI,CAAC,EAAE,QAAQ,CAAA;CAChB,CAAA;AAED,wBAA8B,YAAY,CACxC,KAAK,SAAS,UAAU,EACxB,OAAO,SAAS,oBAAoB,CAAC,KAAK,CAAC,EAE3C,OAA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,OAAO,CAAC,yBAAyB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CA8BpD"}
@@ -2,7 +2,7 @@ import { APIError } from '../../../errors/index.js';
2
2
  import { createLocalReq } from '../../../utilities/createLocalReq.js';
3
3
  import { findOneOperation } from '../findOne.js';
4
4
  export default async function findOneLocal(payload, options) {
5
- const { slug: globalSlug, depth, draft = false, includeLockStatus, overrideAccess = true, select, showHiddenFields } = options;
5
+ const { slug: globalSlug, depth, draft = false, includeLockStatus, overrideAccess = true, populate, select, showHiddenFields } = options;
6
6
  const globalConfig = payload.globals.config.find((config)=>config.slug === globalSlug);
7
7
  if (!globalConfig) {
8
8
  throw new APIError(`The global with slug ${String(globalSlug)} can't be found.`);
@@ -14,6 +14,7 @@ export default async function findOneLocal(payload, options) {
14
14
  globalConfig,
15
15
  includeLockStatus,
16
16
  overrideAccess,
17
+ populate,
17
18
  req: await createLocalReq(options, payload),
18
19
  select,
19
20
  showHiddenFields
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/globals/operations/local/findOne.ts"],"sourcesContent":["import type { GlobalSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'\nimport type {\n Document,\n PayloadRequest,\n SelectType,\n TransformGlobalWithSelect,\n} from '../../../types/index.js'\nimport type { SelectFromGlobalSlug } from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { findOneOperation } from '../findOne.js'\n\nexport type Options<TSlug extends GlobalSlug, TSelect extends SelectType> = {\n context?: RequestContext\n depth?: number\n draft?: boolean\n fallbackLocale?: TypedLocale\n includeLockStatus?: boolean\n locale?: 'all' | TypedLocale\n overrideAccess?: boolean\n req?: PayloadRequest\n select?: TSelect\n showHiddenFields?: boolean\n slug: TSlug\n user?: Document\n}\n\nexport default async function findOneLocal<\n TSlug extends GlobalSlug,\n TSelect extends SelectFromGlobalSlug<TSlug>,\n>(\n payload: Payload,\n options: Options<TSlug, TSelect>,\n): Promise<TransformGlobalWithSelect<TSlug, TSelect>> {\n const {\n slug: globalSlug,\n depth,\n draft = false,\n includeLockStatus,\n overrideAccess = true,\n select,\n showHiddenFields,\n } = options\n\n const globalConfig = payload.globals.config.find((config) => config.slug === globalSlug)\n\n if (!globalConfig) {\n throw new APIError(`The global with slug ${String(globalSlug)} can't be found.`)\n }\n\n return findOneOperation({\n slug: globalSlug as string,\n depth,\n draft,\n globalConfig,\n includeLockStatus,\n overrideAccess,\n req: await createLocalReq(options, payload),\n select,\n showHiddenFields,\n })\n}\n"],"names":["APIError","createLocalReq","findOneOperation","findOneLocal","payload","options","slug","globalSlug","depth","draft","includeLockStatus","overrideAccess","select","showHiddenFields","globalConfig","globals","config","find","String","req"],"mappings":"AASA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,gBAAgB,QAAQ,gBAAe;AAiBhD,eAAe,eAAeC,aAI5BC,OAAgB,EAChBC,OAAgC;IAEhC,MAAM,EACJC,MAAMC,UAAU,EAChBC,KAAK,EACLC,QAAQ,KAAK,EACbC,iBAAiB,EACjBC,iBAAiB,IAAI,EACrBC,MAAM,EACNC,gBAAgB,EACjB,GAAGR;IAEJ,MAAMS,eAAeV,QAAQW,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAACD,SAAWA,OAAOV,IAAI,KAAKC;IAE7E,IAAI,CAACO,cAAc;QACjB,MAAM,IAAId,SAAS,CAAC,qBAAqB,EAAEkB,OAAOX,YAAY,gBAAgB,CAAC;IACjF;IAEA,OAAOL,iBAAiB;QACtBI,MAAMC;QACNC;QACAC;QACAK;QACAJ;QACAC;QACAQ,KAAK,MAAMlB,eAAeI,SAASD;QACnCQ;QACAC;IACF;AACF"}
1
+ {"version":3,"sources":["../../../../src/globals/operations/local/findOne.ts"],"sourcesContent":["import type { GlobalSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'\nimport type {\n Document,\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformGlobalWithSelect,\n} from '../../../types/index.js'\nimport type { SelectFromGlobalSlug } from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { findOneOperation } from '../findOne.js'\n\nexport type Options<TSlug extends GlobalSlug, TSelect extends SelectType> = {\n context?: RequestContext\n depth?: number\n draft?: boolean\n fallbackLocale?: TypedLocale\n includeLockStatus?: boolean\n locale?: 'all' | TypedLocale\n overrideAccess?: boolean\n populate?: PopulateType\n req?: PayloadRequest\n select?: TSelect\n showHiddenFields?: boolean\n slug: TSlug\n user?: Document\n}\n\nexport default async function findOneLocal<\n TSlug extends GlobalSlug,\n TSelect extends SelectFromGlobalSlug<TSlug>,\n>(\n payload: Payload,\n options: Options<TSlug, TSelect>,\n): Promise<TransformGlobalWithSelect<TSlug, TSelect>> {\n const {\n slug: globalSlug,\n depth,\n draft = false,\n includeLockStatus,\n overrideAccess = true,\n populate,\n select,\n showHiddenFields,\n } = options\n\n const globalConfig = payload.globals.config.find((config) => config.slug === globalSlug)\n\n if (!globalConfig) {\n throw new APIError(`The global with slug ${String(globalSlug)} can't be found.`)\n }\n\n return findOneOperation({\n slug: globalSlug as string,\n depth,\n draft,\n globalConfig,\n includeLockStatus,\n overrideAccess,\n populate,\n req: await createLocalReq(options, payload),\n select,\n showHiddenFields,\n })\n}\n"],"names":["APIError","createLocalReq","findOneOperation","findOneLocal","payload","options","slug","globalSlug","depth","draft","includeLockStatus","overrideAccess","populate","select","showHiddenFields","globalConfig","globals","config","find","String","req"],"mappings":"AAUA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,gBAAgB,QAAQ,gBAAe;AAkBhD,eAAe,eAAeC,aAI5BC,OAAgB,EAChBC,OAAgC;IAEhC,MAAM,EACJC,MAAMC,UAAU,EAChBC,KAAK,EACLC,QAAQ,KAAK,EACbC,iBAAiB,EACjBC,iBAAiB,IAAI,EACrBC,QAAQ,EACRC,MAAM,EACNC,gBAAgB,EACjB,GAAGT;IAEJ,MAAMU,eAAeX,QAAQY,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAACD,SAAWA,OAAOX,IAAI,KAAKC;IAE7E,IAAI,CAACQ,cAAc;QACjB,MAAM,IAAIf,SAAS,CAAC,qBAAqB,EAAEmB,OAAOZ,YAAY,gBAAgB,CAAC;IACjF;IAEA,OAAOL,iBAAiB;QACtBI,MAAMC;QACNC;QACAC;QACAM;QACAL;QACAC;QACAC;QACAQ,KAAK,MAAMnB,eAAeI,SAASD;QACnCS;QACAC;IACF;AACF"}
@@ -1,5 +1,5 @@
1
1
  import type { GlobalSlug, Payload, RequestContext, TypedLocale } from '../../../index.js';
2
- import type { Document, PayloadRequest, SelectType } from '../../../types/index.js';
2
+ import type { Document, PayloadRequest, PopulateType, SelectType } from '../../../types/index.js';
3
3
  import type { TypeWithVersion } from '../../../versions/types.js';
4
4
  import type { DataFromGlobalSlug } from '../../config/types.js';
5
5
  export type Options<TSlug extends GlobalSlug> = {
@@ -10,6 +10,7 @@ export type Options<TSlug extends GlobalSlug> = {
10
10
  id: string;
11
11
  locale?: 'all' | TypedLocale;
12
12
  overrideAccess?: boolean;
13
+ populate?: PopulateType;
13
14
  req?: PayloadRequest;
14
15
  select?: SelectType;
15
16
  showHiddenFields?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"findVersionByID.d.ts","sourceRoot":"","sources":["../../../../src/globals/operations/local/findVersionByID.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACzF,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACnF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA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AAC,EAAE,OAAO,CAAA;IACvB,cAAc,CAAC,EAAE,WAAW,CAAA;IAC5B,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,GAAG,CAAC,EAAE,cAAc,CAAA;IACpB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,EAAE,KAAK,CAAA;IACX,IAAI,CAAC,EAAE,QAAQ,CAAA;CAChB,CAAA;AAGD,wBAA8B,oBAAoB,CAAC,KAAK,SAAS,UAAU,EACzE,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,GACtB,OAAO,CAAC,eAAe,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CA6BrD"}
@@ -3,7 +3,7 @@ import { createLocalReq } from '../../../utilities/createLocalReq.js';
3
3
  import { findVersionByIDOperation } from '../findVersionByID.js';
4
4
  // eslint-disable-next-line no-restricted-exports
5
5
  export default async function findVersionByIDLocal(payload, options) {
6
- const { id, slug: globalSlug, depth, disableErrors = false, overrideAccess = true, select, showHiddenFields } = options;
6
+ const { id, slug: globalSlug, depth, disableErrors = false, overrideAccess = true, populate, select, showHiddenFields } = options;
7
7
  const globalConfig = payload.globals.config.find((config)=>config.slug === globalSlug);
8
8
  if (!globalConfig) {
9
9
  throw new APIError(`The global with slug ${String(globalSlug)} can't be found.`);
@@ -14,6 +14,7 @@ export default async function findVersionByIDLocal(payload, options) {
14
14
  disableErrors,
15
15
  globalConfig,
16
16
  overrideAccess,
17
+ populate,
17
18
  req: await createLocalReq(options, payload),
18
19
  select,
19
20
  showHiddenFields