@payloadcms/next 3.80.0-internal.52ab774 → 3.80.0-internal.82dcece

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 (114) hide show
  1. package/dist/cjs/withPayload.cjs +3 -0
  2. package/dist/cjs/withPayload.cjs.map +3 -3
  3. package/dist/elements/Nav/getNavPrefs.d.ts.map +1 -1
  4. package/dist/elements/Nav/getNavPrefs.js +2 -36
  5. package/dist/elements/Nav/getNavPrefs.js.map +1 -1
  6. package/dist/elements/Nav/index.client.d.ts.map +1 -1
  7. package/dist/elements/Nav/index.client.js +44 -27
  8. package/dist/elements/Nav/index.client.js.map +1 -1
  9. package/dist/elements/Nav/index.d.ts.map +1 -1
  10. package/dist/elements/Nav/index.js +7 -35
  11. package/dist/elements/Nav/index.js.map +1 -1
  12. package/dist/exports/client.d.ts +1 -2
  13. package/dist/exports/client.d.ts.map +1 -1
  14. package/dist/exports/client.js +1 -2
  15. package/dist/exports/client.js.map +1 -1
  16. package/dist/exports/rsc.d.ts +1 -2
  17. package/dist/exports/rsc.d.ts.map +1 -1
  18. package/dist/exports/rsc.js +1 -2
  19. package/dist/exports/rsc.js.map +1 -1
  20. package/dist/exports/utilities.d.ts +0 -2
  21. package/dist/exports/utilities.d.ts.map +1 -1
  22. package/dist/exports/utilities.js +0 -1
  23. package/dist/exports/utilities.js.map +1 -1
  24. package/dist/layouts/Root/index.d.ts +4 -2
  25. package/dist/layouts/Root/index.d.ts.map +1 -1
  26. package/dist/layouts/Root/index.js +25 -3
  27. package/dist/layouts/Root/index.js.map +1 -1
  28. package/dist/prod/styles.css +1 -1
  29. package/dist/utilities/handleServerFunctions.js +2 -2
  30. package/dist/utilities/handleServerFunctions.js.map +1 -1
  31. package/dist/views/BrowseByFolder/buildView.d.ts +13 -0
  32. package/dist/views/BrowseByFolder/buildView.d.ts.map +1 -0
  33. package/dist/views/BrowseByFolder/buildView.js +170 -0
  34. package/dist/views/BrowseByFolder/buildView.js.map +1 -0
  35. package/dist/views/BrowseByFolder/index.d.ts +4 -0
  36. package/dist/views/BrowseByFolder/index.d.ts.map +1 -0
  37. package/dist/views/BrowseByFolder/index.js +20 -0
  38. package/dist/views/BrowseByFolder/index.js.map +1 -0
  39. package/dist/views/BrowseByFolder/metadata.d.ts +4 -0
  40. package/dist/views/BrowseByFolder/metadata.d.ts.map +1 -0
  41. package/dist/views/BrowseByFolder/metadata.js +18 -0
  42. package/dist/views/BrowseByFolder/metadata.js.map +1 -0
  43. package/dist/views/CollectionFolders/buildView.d.ts +15 -0
  44. package/dist/views/CollectionFolders/buildView.d.ts.map +1 -0
  45. package/dist/views/CollectionFolders/buildView.js +156 -0
  46. package/dist/views/CollectionFolders/buildView.js.map +1 -0
  47. package/dist/views/CollectionFolders/index.d.ts +4 -0
  48. package/dist/views/CollectionFolders/index.d.ts.map +1 -0
  49. package/dist/views/CollectionFolders/index.js +20 -0
  50. package/dist/views/CollectionFolders/index.js.map +1 -0
  51. package/dist/views/CollectionFolders/metadata.d.ts +7 -0
  52. package/dist/views/CollectionFolders/metadata.d.ts.map +1 -0
  53. package/dist/views/CollectionFolders/metadata.js +25 -0
  54. package/dist/views/CollectionFolders/metadata.js.map +1 -0
  55. package/dist/views/CollectionFolders/renderFolderViewSlots.d.ts +11 -0
  56. package/dist/views/CollectionFolders/renderFolderViewSlots.d.ts.map +1 -0
  57. package/dist/views/CollectionFolders/renderFolderViewSlots.js +64 -0
  58. package/dist/views/CollectionFolders/renderFolderViewSlots.js.map +1 -0
  59. package/dist/views/Document/renderDocumentSlots.d.ts.map +1 -1
  60. package/dist/views/Document/renderDocumentSlots.js +0 -8
  61. package/dist/views/Document/renderDocumentSlots.js.map +1 -1
  62. package/dist/views/List/index.d.ts.map +1 -1
  63. package/dist/views/List/index.js +28 -84
  64. package/dist/views/List/index.js.map +1 -1
  65. package/dist/views/Root/getRouteData.d.ts +4 -1
  66. package/dist/views/Root/getRouteData.d.ts.map +1 -1
  67. package/dist/views/Root/getRouteData.js +91 -27
  68. package/dist/views/Root/getRouteData.js.map +1 -1
  69. package/dist/views/Root/index.d.ts.map +1 -1
  70. package/dist/views/Root/index.js +11 -5
  71. package/dist/views/Root/index.js.map +1 -1
  72. package/dist/views/Root/metadata.d.ts.map +1 -1
  73. package/dist/views/Root/metadata.js +37 -1
  74. package/dist/views/Root/metadata.js.map +1 -1
  75. package/dist/withPayload/withPayload.d.ts.map +1 -1
  76. package/dist/withPayload/withPayload.js +3 -0
  77. package/dist/withPayload/withPayload.js.map +1 -1
  78. package/package.json +7 -7
  79. package/dist/elements/HierarchyTypeField/index.d.ts +0 -9
  80. package/dist/elements/HierarchyTypeField/index.d.ts.map +0 -1
  81. package/dist/elements/HierarchyTypeField/index.js +0 -114
  82. package/dist/elements/HierarchyTypeField/index.js.map +0 -1
  83. package/dist/elements/HierarchyTypeField/index.server.d.ts +0 -9
  84. package/dist/elements/HierarchyTypeField/index.server.d.ts.map +0 -1
  85. package/dist/elements/HierarchyTypeField/index.server.js +0 -32
  86. package/dist/elements/HierarchyTypeField/index.server.js.map +0 -1
  87. package/dist/elements/Nav/SidebarTabs/TabError/index.d.ts +0 -8
  88. package/dist/elements/Nav/SidebarTabs/TabError/index.d.ts.map +0 -1
  89. package/dist/elements/Nav/SidebarTabs/TabError/index.js +0 -42
  90. package/dist/elements/Nav/SidebarTabs/TabError/index.js.map +0 -1
  91. package/dist/elements/Nav/SidebarTabs/constants.d.ts +0 -2
  92. package/dist/elements/Nav/SidebarTabs/constants.d.ts.map +0 -1
  93. package/dist/elements/Nav/SidebarTabs/constants.js +0 -2
  94. package/dist/elements/Nav/SidebarTabs/constants.js.map +0 -1
  95. package/dist/elements/Nav/SidebarTabs/index.client.d.ts +0 -22
  96. package/dist/elements/Nav/SidebarTabs/index.client.d.ts.map +0 -1
  97. package/dist/elements/Nav/SidebarTabs/index.client.js +0 -194
  98. package/dist/elements/Nav/SidebarTabs/index.client.js.map +0 -1
  99. package/dist/elements/Nav/SidebarTabs/index.d.ts +0 -17
  100. package/dist/elements/Nav/SidebarTabs/index.d.ts.map +0 -1
  101. package/dist/elements/Nav/SidebarTabs/index.js +0 -85
  102. package/dist/elements/Nav/SidebarTabs/index.js.map +0 -1
  103. package/dist/elements/Nav/SidebarTabs/renderTabServerFn.d.ts +0 -10
  104. package/dist/elements/Nav/SidebarTabs/renderTabServerFn.d.ts.map +0 -1
  105. package/dist/elements/Nav/SidebarTabs/renderTabServerFn.js +0 -54
  106. package/dist/elements/Nav/SidebarTabs/renderTabServerFn.js.map +0 -1
  107. package/dist/utilities/getHierarchyAncestry.d.ts +0 -24
  108. package/dist/utilities/getHierarchyAncestry.d.ts.map +0 -1
  109. package/dist/utilities/getHierarchyAncestry.js +0 -103
  110. package/dist/utilities/getHierarchyAncestry.js.map +0 -1
  111. package/dist/views/List/handleHierarchy.d.ts +0 -18
  112. package/dist/views/List/handleHierarchy.d.ts.map +0 -1
  113. package/dist/views/List/handleHierarchy.js +0 -258
  114. package/dist/views/List/handleHierarchy.js.map +0 -1
@@ -1,258 +0,0 @@
1
- import { getTranslation } from '@payloadcms/translations';
2
- import { getAncestors } from 'payload';
3
- import { combineWhereConstraints, DEFAULT_HIERARCHY_LIST_LIMIT } from 'payload/shared';
4
- /**
5
- * Fetches hierarchy data for a collection with a selected parent.
6
- * Returns data that can be rendered client-side by HierarchyTable.
7
- */
8
- export const handleHierarchy = async ({
9
- baseFilter,
10
- collectionConfig,
11
- collectionSlug,
12
- parentId,
13
- permissions,
14
- req,
15
- search,
16
- typeFilter,
17
- user
18
- }) => {
19
- const hierarchyConfig = collectionConfig.hierarchy && typeof collectionConfig.hierarchy === 'object' ? collectionConfig.hierarchy : undefined;
20
- if (!hierarchyConfig) {
21
- throw new Error('Collection is not a hierarchy');
22
- }
23
- const parentFieldName = hierarchyConfig.parentFieldName;
24
- const useAsTitle = collectionConfig.admin?.useAsTitle || 'id';
25
- // Fetch the parent item and breadcrumbs (skip for root level)
26
- let parent = null;
27
- let breadcrumbs = [];
28
- if (parentId !== null) {
29
- try {
30
- const [item, ancestors] = await Promise.all([req.payload.findByID({
31
- id: parentId,
32
- collection: collectionSlug,
33
- depth: 0,
34
- overrideAccess: false,
35
- req,
36
- user
37
- }), getAncestors({
38
- id: parentId,
39
- collectionSlug,
40
- req
41
- })]);
42
- parent = item;
43
- breadcrumbs = ancestors;
44
- } catch (_error) {
45
- req.payload.logger.warn({
46
- msg: `Hierarchy item not found: ${parentId}`
47
- });
48
- }
49
- }
50
- // Build children where clause
51
- // For root level (parentId is null), find items without a parent
52
- // For nested level, find items with this specific parent
53
- const parentCondition = parentId === null ? {
54
- or: [{
55
- [parentFieldName]: {
56
- exists: false
57
- }
58
- }, {
59
- [parentFieldName]: {
60
- equals: null
61
- }
62
- }]
63
- } : {
64
- [parentFieldName]: {
65
- equals: parentId
66
- }
67
- };
68
- // Build type filter condition if typeFilter is provided and collectionSpecific is configured
69
- // Filter to folders that allow ANY of the selected types OR are unrestricted
70
- let typeCondition;
71
- if (typeFilter && typeFilter.length > 0 && hierarchyConfig.collectionSpecific && typeof hierarchyConfig.collectionSpecific === 'object') {
72
- const typeFieldName = hierarchyConfig.collectionSpecific.fieldName;
73
- // Exclude the hierarchy collection itself from the filter (folders always show folders)
74
- const filteredTypes = typeFilter.filter(t => t !== collectionSlug);
75
- if (filteredTypes.length > 0) {
76
- typeCondition = {
77
- or: [{
78
- [typeFieldName]: {
79
- in: filteredTypes
80
- }
81
- }, {
82
- [typeFieldName]: {
83
- exists: false
84
- }
85
- }]
86
- };
87
- }
88
- }
89
- // Combine conditions: parent + search + typeFilter
90
- const conditions = [parentCondition];
91
- if (search) {
92
- conditions.push({
93
- [useAsTitle]: {
94
- like: search
95
- }
96
- });
97
- }
98
- if (typeCondition) {
99
- conditions.push(typeCondition);
100
- }
101
- const childrenWhere = conditions.length > 1 ? {
102
- and: conditions
103
- } : parentCondition;
104
- // Fetch children (hierarchy items with this parent, or root items if parentId is null)
105
- const childrenData = await req.payload.find({
106
- collection: collectionSlug,
107
- depth: 0,
108
- draft: true,
109
- fallbackLocale: false,
110
- includeLockStatus: true,
111
- limit: DEFAULT_HIERARCHY_LIST_LIMIT,
112
- locale: req.locale,
113
- overrideAccess: false,
114
- page: 1,
115
- req,
116
- user,
117
- where: combineWhereConstraints([childrenWhere, baseFilter])
118
- });
119
- // Fetch related documents from other collections
120
- // At root level: show unassigned documents (where hierarchy field doesn't exist)
121
- // At nested level: show documents assigned to the selected hierarchy item
122
- const relatedDocumentsByCollection = {};
123
- const relatedBaseFilters = {};
124
- // Use pre-computed relatedCollections from sanitized hierarchy config
125
- const relatedCollectionsConfig = hierarchyConfig.relatedCollections || {};
126
- for (const [relatedSlug, fieldInfo] of Object.entries(relatedCollectionsConfig)) {
127
- if (relatedSlug === collectionSlug) {
128
- continue;
129
- }
130
- const relatedCollectionConfig = req.payload.collections[relatedSlug]?.config;
131
- if (!relatedCollectionConfig) {
132
- continue;
133
- }
134
- // Check if user has read permission for this collection
135
- if (!permissions?.collections?.[relatedSlug]?.read) {
136
- continue;
137
- }
138
- const {
139
- fieldName,
140
- hasMany
141
- } = fieldInfo;
142
- // Get baseFilter for this related collection
143
- const relatedBaseFilter = await (relatedCollectionConfig.admin?.baseFilter ?? relatedCollectionConfig.admin?.baseListFilter)?.({
144
- limit: DEFAULT_HIERARCHY_LIST_LIMIT,
145
- page: 1,
146
- req,
147
- sort: undefined
148
- });
149
- if (relatedBaseFilter) {
150
- relatedBaseFilters[relatedSlug] = relatedBaseFilter;
151
- }
152
- // Build where clause based on whether we're at root or nested level
153
- let relationshipWhere;
154
- if (parentId === null) {
155
- // Root level: find documents where hierarchy field doesn't exist, is null, or is empty array
156
- const conditions = [{
157
- [fieldName]: {
158
- exists: false
159
- }
160
- }, {
161
- [fieldName]: {
162
- equals: null
163
- }
164
- }];
165
- if (hasMany) {
166
- // hasMany fields store cleared values as empty arrays
167
- conditions.push({
168
- [fieldName]: {
169
- equals: []
170
- }
171
- });
172
- }
173
- relationshipWhere = {
174
- or: conditions
175
- };
176
- } else {
177
- // Nested level: find documents assigned to this hierarchy item
178
- // "in" operator works for both hasMany and single relationship fields
179
- relationshipWhere = {
180
- [fieldName]: {
181
- in: [parentId]
182
- }
183
- };
184
- }
185
- // Add search filter if provided
186
- const relatedUseAsTitle = relatedCollectionConfig.admin?.useAsTitle || 'id';
187
- const whereWithSearch = search ? {
188
- and: [relationshipWhere, {
189
- [relatedUseAsTitle]: {
190
- like: search
191
- }
192
- }]
193
- } : relationshipWhere;
194
- // Combine relationship where with related collection's baseFilter
195
- const where = combineWhereConstraints([whereWithSearch, relatedBaseFilter]);
196
- try {
197
- const data = await req.payload.find({
198
- collection: relatedSlug,
199
- depth: 0,
200
- draft: true,
201
- fallbackLocale: false,
202
- includeLockStatus: true,
203
- limit: DEFAULT_HIERARCHY_LIST_LIMIT,
204
- locale: req.locale,
205
- overrideAccess: false,
206
- page: 1,
207
- req,
208
- user,
209
- where
210
- });
211
- if (data.totalDocs > 0) {
212
- relatedDocumentsByCollection[relatedSlug] = {
213
- hasMany,
214
- label: getTranslation(relatedCollectionConfig.labels?.plural, req.i18n),
215
- result: data
216
- };
217
- }
218
- } catch (error) {
219
- req.payload.logger.warn({
220
- err: error,
221
- msg: `Failed to query related collection ${relatedSlug}`
222
- });
223
- }
224
- }
225
- // Extract allowed collections from parent's collectionSpecific field
226
- // - undefined: collectionSpecific not configured, no filtering needed
227
- // - []: parent folder accepts everything, can only move to unrestricted destinations
228
- // - [{ slug, label }, ...]: parent folder has restrictions
229
- let allowedCollections;
230
- if (hierarchyConfig.collectionSpecific && parent) {
231
- const typeFieldName = hierarchyConfig.collectionSpecific.fieldName;
232
- const typeValues = parent[typeFieldName];
233
- if (typeValues && typeValues.length > 0) {
234
- allowedCollections = typeValues.map(slug => {
235
- const config = req.payload.collections[slug]?.config;
236
- const label = config ? getTranslation(config.labels?.plural, req.i18n) : slug;
237
- return {
238
- slug,
239
- label
240
- };
241
- });
242
- } else {
243
- // Parent folder accepts everything (type is null or empty)
244
- allowedCollections = [];
245
- }
246
- }
247
- return {
248
- allowedCollections,
249
- breadcrumbs,
250
- childrenData,
251
- parent,
252
- parentFieldName,
253
- parentId,
254
- relatedBaseFilters: Object.keys(relatedBaseFilters).length > 0 ? relatedBaseFilters : undefined,
255
- relatedDocumentsByCollection
256
- };
257
- };
258
- //# sourceMappingURL=handleHierarchy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"handleHierarchy.js","names":["getTranslation","getAncestors","combineWhereConstraints","DEFAULT_HIERARCHY_LIST_LIMIT","handleHierarchy","baseFilter","collectionConfig","collectionSlug","parentId","permissions","req","search","typeFilter","user","hierarchyConfig","hierarchy","undefined","Error","parentFieldName","useAsTitle","admin","parent","breadcrumbs","item","ancestors","Promise","all","payload","findByID","id","collection","depth","overrideAccess","_error","logger","warn","msg","parentCondition","or","exists","equals","typeCondition","length","collectionSpecific","typeFieldName","fieldName","filteredTypes","filter","t","in","conditions","push","like","childrenWhere","and","childrenData","find","draft","fallbackLocale","includeLockStatus","limit","locale","page","where","relatedDocumentsByCollection","relatedBaseFilters","relatedCollectionsConfig","relatedCollections","relatedSlug","fieldInfo","Object","entries","relatedCollectionConfig","collections","config","read","hasMany","relatedBaseFilter","baseListFilter","sort","relationshipWhere","relatedUseAsTitle","whereWithSearch","data","totalDocs","label","labels","plural","i18n","result","error","err","allowedCollections","typeValues","map","slug","keys"],"sources":["../../../src/views/List/handleHierarchy.ts"],"sourcesContent":["import type {\n HierarchyViewData,\n PayloadRequest,\n RelatedDocumentsGrouped,\n SanitizedCollectionConfig,\n SanitizedPermissions,\n TypeWithID,\n Where,\n} from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { getAncestors } from 'payload'\nimport { combineWhereConstraints, DEFAULT_HIERARCHY_LIST_LIMIT } from 'payload/shared'\n\n/**\n * Fetches hierarchy data for a collection with a selected parent.\n * Returns data that can be rendered client-side by HierarchyTable.\n */\nexport const handleHierarchy = async ({\n baseFilter,\n collectionConfig,\n collectionSlug,\n parentId,\n permissions,\n req,\n search,\n typeFilter,\n user,\n}: {\n baseFilter?: null | Where\n collectionConfig: SanitizedCollectionConfig\n collectionSlug: string\n parentId: null | number | string\n permissions?: SanitizedPermissions\n req: PayloadRequest\n search?: string\n /** Filter hierarchy items by their collectionSpecific type field */\n typeFilter?: string[]\n user: PayloadRequest['user']\n}): Promise<HierarchyViewData> => {\n const hierarchyConfig =\n collectionConfig.hierarchy && typeof collectionConfig.hierarchy === 'object'\n ? collectionConfig.hierarchy\n : undefined\n\n if (!hierarchyConfig) {\n throw new Error('Collection is not a hierarchy')\n }\n\n const parentFieldName = hierarchyConfig.parentFieldName\n\n const useAsTitle = collectionConfig.admin?.useAsTitle || 'id'\n\n // Fetch the parent item and breadcrumbs (skip for root level)\n let parent: null | (Record<string, unknown> & TypeWithID) = null\n let breadcrumbs: Array<{ id: number | string; title: string }> = []\n\n if (parentId !== null) {\n try {\n const [item, ancestors] = await Promise.all([\n req.payload.findByID({\n id: parentId,\n collection: collectionSlug,\n depth: 0,\n overrideAccess: false,\n req,\n user,\n }),\n getAncestors({\n id: parentId,\n collectionSlug,\n req,\n }),\n ])\n\n parent = item\n breadcrumbs = ancestors\n } catch (_error) {\n req.payload.logger.warn({\n msg: `Hierarchy item not found: ${parentId}`,\n })\n }\n }\n\n // Build children where clause\n // For root level (parentId is null), find items without a parent\n // For nested level, find items with this specific parent\n const parentCondition =\n parentId === null\n ? {\n or: [{ [parentFieldName]: { exists: false } }, { [parentFieldName]: { equals: null } }],\n }\n : { [parentFieldName]: { equals: parentId } }\n\n // Build type filter condition if typeFilter is provided and collectionSpecific is configured\n // Filter to folders that allow ANY of the selected types OR are unrestricted\n let typeCondition: Record<string, unknown> | undefined\n\n if (\n typeFilter &&\n typeFilter.length > 0 &&\n hierarchyConfig.collectionSpecific &&\n typeof hierarchyConfig.collectionSpecific === 'object'\n ) {\n const typeFieldName = hierarchyConfig.collectionSpecific.fieldName\n // Exclude the hierarchy collection itself from the filter (folders always show folders)\n const filteredTypes = typeFilter.filter((t) => t !== collectionSlug)\n\n if (filteredTypes.length > 0) {\n typeCondition = {\n or: [\n { [typeFieldName]: { in: filteredTypes } },\n { [typeFieldName]: { exists: false } }, // Include unrestricted folders\n ],\n }\n }\n }\n\n // Combine conditions: parent + search + typeFilter\n const conditions: Record<string, unknown>[] = [parentCondition]\n\n if (search) {\n conditions.push({ [useAsTitle]: { like: search } })\n }\n\n if (typeCondition) {\n conditions.push(typeCondition)\n }\n\n const childrenWhere = conditions.length > 1 ? { and: conditions } : parentCondition\n\n // Fetch children (hierarchy items with this parent, or root items if parentId is null)\n const childrenData = await req.payload.find({\n collection: collectionSlug,\n depth: 0,\n draft: true,\n fallbackLocale: false,\n includeLockStatus: true,\n limit: DEFAULT_HIERARCHY_LIST_LIMIT,\n locale: req.locale,\n overrideAccess: false,\n page: 1,\n req,\n user,\n where: combineWhereConstraints([childrenWhere, baseFilter]),\n })\n\n // Fetch related documents from other collections\n // At root level: show unassigned documents (where hierarchy field doesn't exist)\n // At nested level: show documents assigned to the selected hierarchy item\n const relatedDocumentsByCollection: RelatedDocumentsGrouped = {}\n const relatedBaseFilters: Record<string, Where> = {}\n\n // Use pre-computed relatedCollections from sanitized hierarchy config\n const relatedCollectionsConfig = hierarchyConfig.relatedCollections || {}\n\n for (const [relatedSlug, fieldInfo] of Object.entries(relatedCollectionsConfig)) {\n if (relatedSlug === collectionSlug) {\n continue\n }\n\n const relatedCollectionConfig = req.payload.collections[relatedSlug]?.config\n if (!relatedCollectionConfig) {\n continue\n }\n\n // Check if user has read permission for this collection\n if (!permissions?.collections?.[relatedSlug]?.read) {\n continue\n }\n\n const { fieldName, hasMany } = fieldInfo\n\n // Get baseFilter for this related collection\n const relatedBaseFilter = await (\n relatedCollectionConfig.admin?.baseFilter ?? relatedCollectionConfig.admin?.baseListFilter\n )?.({\n limit: DEFAULT_HIERARCHY_LIST_LIMIT,\n page: 1,\n req,\n sort: undefined,\n })\n\n if (relatedBaseFilter) {\n relatedBaseFilters[relatedSlug] = relatedBaseFilter\n }\n\n // Build where clause based on whether we're at root or nested level\n let relationshipWhere: Record<string, unknown>\n\n if (parentId === null) {\n // Root level: find documents where hierarchy field doesn't exist, is null, or is empty array\n const conditions: Record<string, unknown>[] = [\n { [fieldName]: { exists: false } },\n { [fieldName]: { equals: null } },\n ]\n if (hasMany) {\n // hasMany fields store cleared values as empty arrays\n conditions.push({ [fieldName]: { equals: [] } })\n }\n relationshipWhere = { or: conditions }\n } else {\n // Nested level: find documents assigned to this hierarchy item\n // \"in\" operator works for both hasMany and single relationship fields\n relationshipWhere = {\n [fieldName]: { in: [parentId] },\n }\n }\n\n // Add search filter if provided\n const relatedUseAsTitle = relatedCollectionConfig.admin?.useAsTitle || 'id'\n const whereWithSearch = search\n ? { and: [relationshipWhere, { [relatedUseAsTitle]: { like: search } }] }\n : relationshipWhere\n\n // Combine relationship where with related collection's baseFilter\n const where = combineWhereConstraints([whereWithSearch, relatedBaseFilter])\n\n try {\n const data = await req.payload.find({\n collection: relatedSlug,\n depth: 0,\n draft: true,\n fallbackLocale: false,\n includeLockStatus: true,\n limit: DEFAULT_HIERARCHY_LIST_LIMIT,\n locale: req.locale,\n overrideAccess: false,\n page: 1,\n req,\n user,\n where,\n })\n\n if (data.totalDocs > 0) {\n relatedDocumentsByCollection[relatedSlug] = {\n hasMany,\n label: getTranslation(relatedCollectionConfig.labels?.plural, req.i18n),\n result: data,\n }\n }\n } catch (error) {\n req.payload.logger.warn({\n err: error,\n msg: `Failed to query related collection ${relatedSlug}`,\n })\n }\n }\n\n // Extract allowed collections from parent's collectionSpecific field\n // - undefined: collectionSpecific not configured, no filtering needed\n // - []: parent folder accepts everything, can only move to unrestricted destinations\n // - [{ slug, label }, ...]: parent folder has restrictions\n let allowedCollections: Array<{ label: string; slug: string }> | undefined\n\n if (hierarchyConfig.collectionSpecific && parent) {\n const typeFieldName = hierarchyConfig.collectionSpecific.fieldName\n const typeValues = parent[typeFieldName] as null | string[] | undefined\n\n if (typeValues && typeValues.length > 0) {\n allowedCollections = typeValues.map((slug) => {\n const config = req.payload.collections[slug]?.config\n const label = config ? getTranslation(config.labels?.plural, req.i18n) : slug\n return { slug, label }\n })\n } else {\n // Parent folder accepts everything (type is null or empty)\n allowedCollections = []\n }\n }\n\n return {\n allowedCollections,\n breadcrumbs,\n childrenData,\n parent,\n parentFieldName,\n parentId,\n relatedBaseFilters: Object.keys(relatedBaseFilters).length > 0 ? relatedBaseFilters : undefined,\n relatedDocumentsByCollection,\n }\n}\n"],"mappings":"AAUA,SAASA,cAAc,QAAQ;AAC/B,SAASC,YAAY,QAAQ;AAC7B,SAASC,uBAAuB,EAAEC,4BAA4B,QAAQ;AAEtE;;;;AAIA,OAAO,MAAMC,eAAA,GAAkB,MAAAA,CAAO;EACpCC,UAAU;EACVC,gBAAgB;EAChBC,cAAc;EACdC,QAAQ;EACRC,WAAW;EACXC,GAAG;EACHC,MAAM;EACNC,UAAU;EACVC;AAAI,CAYL;EACC,MAAMC,eAAA,GACJR,gBAAA,CAAiBS,SAAS,IAAI,OAAOT,gBAAA,CAAiBS,SAAS,KAAK,WAChET,gBAAA,CAAiBS,SAAS,GAC1BC,SAAA;EAEN,IAAI,CAACF,eAAA,EAAiB;IACpB,MAAM,IAAIG,KAAA,CAAM;EAClB;EAEA,MAAMC,eAAA,GAAkBJ,eAAA,CAAgBI,eAAe;EAEvD,MAAMC,UAAA,GAAab,gBAAA,CAAiBc,KAAK,EAAED,UAAA,IAAc;EAEzD;EACA,IAAIE,MAAA,GAAwD;EAC5D,IAAIC,WAAA,GAA6D,EAAE;EAEnE,IAAId,QAAA,KAAa,MAAM;IACrB,IAAI;MACF,MAAM,CAACe,IAAA,EAAMC,SAAA,CAAU,GAAG,MAAMC,OAAA,CAAQC,GAAG,CAAC,CAC1ChB,GAAA,CAAIiB,OAAO,CAACC,QAAQ,CAAC;QACnBC,EAAA,EAAIrB,QAAA;QACJsB,UAAA,EAAYvB,cAAA;QACZwB,KAAA,EAAO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