@payloadcms/next 3.43.0-canary.7 → 3.43.0-internal.693bd81
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.
- package/dist/elements/DocumentHeader/Tabs/Tab/index.d.ts.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/Tab/index.js +36 -26
- package/dist/elements/DocumentHeader/Tabs/Tab/index.js.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/getCustomViews.d.ts +6 -0
- package/dist/elements/DocumentHeader/Tabs/getCustomViews.d.ts.map +1 -0
- package/dist/elements/DocumentHeader/Tabs/getCustomViews.js +34 -0
- package/dist/elements/DocumentHeader/Tabs/getCustomViews.js.map +1 -0
- package/dist/elements/DocumentHeader/Tabs/getViewConfig.d.ts +7 -0
- package/dist/elements/DocumentHeader/Tabs/getViewConfig.d.ts.map +1 -0
- package/dist/elements/DocumentHeader/Tabs/getViewConfig.js +17 -0
- package/dist/elements/DocumentHeader/Tabs/getViewConfig.js.map +1 -0
- package/dist/elements/DocumentHeader/Tabs/index.d.ts.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/index.js +81 -35
- package/dist/elements/DocumentHeader/Tabs/index.js.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/tabs/index.d.ts +6 -8
- package/dist/elements/DocumentHeader/Tabs/tabs/index.d.ts.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/tabs/index.js +61 -91
- package/dist/elements/DocumentHeader/Tabs/tabs/index.js.map +1 -1
- package/dist/elements/DocumentHeader/index.d.ts.map +1 -1
- package/dist/elements/DocumentHeader/index.js.map +1 -1
- package/dist/prod/styles.css +1 -1
- package/dist/utilities/handleServerFunctions.d.ts.map +1 -1
- package/dist/utilities/handleServerFunctions.js +0 -2
- package/dist/utilities/handleServerFunctions.js.map +1 -1
- package/dist/views/BrowseByFolder/buildView.d.ts.map +1 -1
- package/dist/views/BrowseByFolder/buildView.js +61 -40
- package/dist/views/BrowseByFolder/buildView.js.map +1 -1
- package/dist/views/CollectionFolders/buildView.d.ts.map +1 -1
- package/dist/views/CollectionFolders/buildView.js +59 -45
- package/dist/views/CollectionFolders/buildView.js.map +1 -1
- package/dist/views/Document/getMetaBySegment.d.ts.map +1 -1
- package/dist/views/Document/getMetaBySegment.js +3 -10
- package/dist/views/Document/getMetaBySegment.js.map +1 -1
- package/dist/views/Document/getViewsFromConfig.d.ts +27 -0
- package/dist/views/Document/getViewsFromConfig.d.ts.map +1 -0
- package/dist/views/Document/getViewsFromConfig.js +330 -0
- package/dist/views/Document/getViewsFromConfig.js.map +1 -0
- package/dist/views/Document/index.d.ts +1 -2
- package/dist/views/Document/index.d.ts.map +1 -1
- package/dist/views/Document/index.js +76 -34
- package/dist/views/Document/index.js.map +1 -1
- package/dist/views/LivePreview/index.client.js +1 -3
- package/dist/views/LivePreview/index.client.js.map +1 -1
- package/dist/views/Unauthorized/index.d.ts +0 -1
- package/dist/views/Unauthorized/index.d.ts.map +1 -1
- package/dist/views/Unauthorized/index.js +1 -9
- package/dist/views/Unauthorized/index.js.map +1 -1
- package/dist/views/Unauthorized/index.scss +0 -4
- package/dist/views/Version/SelectComparison/index.js +0 -1
- package/dist/views/Version/SelectComparison/index.js.map +1 -1
- package/dist/views/Versions/cells/AutosaveCell/index.js +0 -2
- package/dist/views/Versions/cells/AutosaveCell/index.js.map +1 -1
- package/package.json +6 -6
- package/dist/views/Document/getDocumentView.d.ts +0 -18
- package/dist/views/Document/getDocumentView.d.ts.map +0 -1
- package/dist/views/Document/getDocumentView.js +0 -264
- package/dist/views/Document/getDocumentView.js.map +0 -1
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import { APIView as DefaultAPIView } from '../API/index.js';
|
|
2
|
+
import { EditView as DefaultEditView } from '../Edit/index.js';
|
|
3
|
+
import { LivePreviewView as DefaultLivePreviewView } from '../LivePreview/index.js';
|
|
4
|
+
import { UnauthorizedView } from '../Unauthorized/index.js';
|
|
5
|
+
import { VersionView as DefaultVersionView } from '../Version/index.js';
|
|
6
|
+
import { VersionsView as DefaultVersionsView } from '../Versions/index.js';
|
|
7
|
+
import { getCustomViewByKey } from './getCustomViewByKey.js';
|
|
8
|
+
import { getCustomViewByRoute } from './getCustomViewByRoute.js';
|
|
9
|
+
export const getViewsFromConfig = ({
|
|
10
|
+
collectionConfig,
|
|
11
|
+
config,
|
|
12
|
+
docPermissions,
|
|
13
|
+
globalConfig,
|
|
14
|
+
overrideDocPermissions,
|
|
15
|
+
routeSegments
|
|
16
|
+
}) => {
|
|
17
|
+
// Conditionally import and lazy load the default view
|
|
18
|
+
let DefaultView = null;
|
|
19
|
+
let CustomView = null;
|
|
20
|
+
let ErrorView = null;
|
|
21
|
+
let viewKey;
|
|
22
|
+
const {
|
|
23
|
+
routes: {
|
|
24
|
+
admin: adminRoute
|
|
25
|
+
}
|
|
26
|
+
} = config;
|
|
27
|
+
const views = collectionConfig && collectionConfig?.admin?.components?.views || globalConfig && globalConfig?.admin?.components?.views;
|
|
28
|
+
const livePreviewEnabled = collectionConfig && collectionConfig?.admin?.livePreview || config?.admin?.livePreview?.collections?.includes(collectionConfig?.slug) || globalConfig && globalConfig?.admin?.livePreview || config?.admin?.livePreview?.globals?.includes(globalConfig?.slug);
|
|
29
|
+
if (collectionConfig) {
|
|
30
|
+
const [collectionEntity, collectionSlug, segment3, segment4, segment5, ...remainingSegments] = routeSegments;
|
|
31
|
+
if (!overrideDocPermissions && !docPermissions?.read) {
|
|
32
|
+
throw new Error('not-found');
|
|
33
|
+
} else {
|
|
34
|
+
// `../:id`, or `../create`
|
|
35
|
+
switch (routeSegments.length) {
|
|
36
|
+
case 3:
|
|
37
|
+
{
|
|
38
|
+
switch (segment3) {
|
|
39
|
+
case 'create':
|
|
40
|
+
{
|
|
41
|
+
if (!overrideDocPermissions && 'create' in docPermissions && docPermissions.create) {
|
|
42
|
+
CustomView = {
|
|
43
|
+
ComponentConfig: getCustomViewByKey(views, 'default')
|
|
44
|
+
};
|
|
45
|
+
DefaultView = {
|
|
46
|
+
Component: DefaultEditView
|
|
47
|
+
};
|
|
48
|
+
} else {
|
|
49
|
+
ErrorView = {
|
|
50
|
+
Component: UnauthorizedView
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
default:
|
|
56
|
+
{
|
|
57
|
+
const baseRoute = [adminRoute !== '/' && adminRoute, 'collections', collectionSlug, segment3].filter(Boolean).join('/');
|
|
58
|
+
const currentRoute = [baseRoute, segment4, segment5, ...remainingSegments].filter(Boolean).join('/');
|
|
59
|
+
const {
|
|
60
|
+
Component: CustomViewComponent,
|
|
61
|
+
viewKey: customViewKey
|
|
62
|
+
} = getCustomViewByRoute({
|
|
63
|
+
baseRoute,
|
|
64
|
+
currentRoute,
|
|
65
|
+
views
|
|
66
|
+
});
|
|
67
|
+
if (customViewKey) {
|
|
68
|
+
viewKey = customViewKey;
|
|
69
|
+
CustomView = {
|
|
70
|
+
ComponentConfig: CustomViewComponent
|
|
71
|
+
};
|
|
72
|
+
} else {
|
|
73
|
+
CustomView = {
|
|
74
|
+
ComponentConfig: getCustomViewByKey(views, 'default')
|
|
75
|
+
};
|
|
76
|
+
DefaultView = {
|
|
77
|
+
Component: DefaultEditView
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
// `../:id/api`, `../:id/preview`, `../:id/versions`, etc
|
|
86
|
+
case 4:
|
|
87
|
+
{
|
|
88
|
+
switch (segment4) {
|
|
89
|
+
case 'api':
|
|
90
|
+
{
|
|
91
|
+
if (collectionConfig?.admin?.hideAPIURL !== true) {
|
|
92
|
+
CustomView = {
|
|
93
|
+
ComponentConfig: getCustomViewByKey(views, 'api')
|
|
94
|
+
};
|
|
95
|
+
DefaultView = {
|
|
96
|
+
Component: DefaultAPIView
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
case 'preview':
|
|
102
|
+
{
|
|
103
|
+
if (livePreviewEnabled) {
|
|
104
|
+
DefaultView = {
|
|
105
|
+
Component: DefaultLivePreviewView
|
|
106
|
+
};
|
|
107
|
+
CustomView = {
|
|
108
|
+
ComponentConfig: getCustomViewByKey(views, 'livePreview')
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
case 'versions':
|
|
114
|
+
{
|
|
115
|
+
if (!overrideDocPermissions && docPermissions?.readVersions) {
|
|
116
|
+
CustomView = {
|
|
117
|
+
ComponentConfig: getCustomViewByKey(views, 'versions')
|
|
118
|
+
};
|
|
119
|
+
DefaultView = {
|
|
120
|
+
Component: DefaultVersionsView
|
|
121
|
+
};
|
|
122
|
+
} else {
|
|
123
|
+
ErrorView = {
|
|
124
|
+
Component: UnauthorizedView
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
default:
|
|
130
|
+
{
|
|
131
|
+
const baseRoute = [adminRoute !== '/' && adminRoute, 'collections', collectionSlug, segment3].filter(Boolean).join('/');
|
|
132
|
+
const currentRoute = [baseRoute, segment4, segment5, ...remainingSegments].filter(Boolean).join('/');
|
|
133
|
+
const {
|
|
134
|
+
Component: CustomViewComponent,
|
|
135
|
+
viewKey: customViewKey
|
|
136
|
+
} = getCustomViewByRoute({
|
|
137
|
+
baseRoute,
|
|
138
|
+
currentRoute,
|
|
139
|
+
views
|
|
140
|
+
});
|
|
141
|
+
if (customViewKey) {
|
|
142
|
+
viewKey = customViewKey;
|
|
143
|
+
CustomView = {
|
|
144
|
+
ComponentConfig: CustomViewComponent
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
// `../:id/versions/:version`, etc
|
|
153
|
+
default:
|
|
154
|
+
{
|
|
155
|
+
if (segment4 === 'versions') {
|
|
156
|
+
if (!overrideDocPermissions && docPermissions?.readVersions) {
|
|
157
|
+
CustomView = {
|
|
158
|
+
ComponentConfig: getCustomViewByKey(views, 'version')
|
|
159
|
+
};
|
|
160
|
+
DefaultView = {
|
|
161
|
+
Component: DefaultVersionView
|
|
162
|
+
};
|
|
163
|
+
} else {
|
|
164
|
+
ErrorView = {
|
|
165
|
+
Component: UnauthorizedView
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
} else {
|
|
169
|
+
const baseRoute = [adminRoute !== '/' && adminRoute, collectionEntity, collectionSlug, segment3].filter(Boolean).join('/');
|
|
170
|
+
const currentRoute = [baseRoute, segment4, segment5, ...remainingSegments].filter(Boolean).join('/');
|
|
171
|
+
const {
|
|
172
|
+
Component: CustomViewComponent,
|
|
173
|
+
viewKey: customViewKey
|
|
174
|
+
} = getCustomViewByRoute({
|
|
175
|
+
baseRoute,
|
|
176
|
+
currentRoute,
|
|
177
|
+
views
|
|
178
|
+
});
|
|
179
|
+
if (customViewKey) {
|
|
180
|
+
viewKey = customViewKey;
|
|
181
|
+
CustomView = {
|
|
182
|
+
ComponentConfig: CustomViewComponent
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (globalConfig) {
|
|
192
|
+
const [globalEntity, globalSlug, segment3, ...remainingSegments] = routeSegments;
|
|
193
|
+
if (!overrideDocPermissions && !docPermissions?.read) {
|
|
194
|
+
throw new Error('not-found');
|
|
195
|
+
} else {
|
|
196
|
+
switch (routeSegments.length) {
|
|
197
|
+
case 2:
|
|
198
|
+
{
|
|
199
|
+
CustomView = {
|
|
200
|
+
ComponentConfig: getCustomViewByKey(views, 'default')
|
|
201
|
+
};
|
|
202
|
+
DefaultView = {
|
|
203
|
+
Component: DefaultEditView
|
|
204
|
+
};
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
case 3:
|
|
208
|
+
{
|
|
209
|
+
// `../:slug/api`, `../:slug/preview`, `../:slug/versions`, etc
|
|
210
|
+
switch (segment3) {
|
|
211
|
+
case 'api':
|
|
212
|
+
{
|
|
213
|
+
if (globalConfig?.admin?.hideAPIURL !== true) {
|
|
214
|
+
CustomView = {
|
|
215
|
+
ComponentConfig: getCustomViewByKey(views, 'api')
|
|
216
|
+
};
|
|
217
|
+
DefaultView = {
|
|
218
|
+
Component: DefaultAPIView
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
case 'preview':
|
|
224
|
+
{
|
|
225
|
+
if (livePreviewEnabled) {
|
|
226
|
+
DefaultView = {
|
|
227
|
+
Component: DefaultLivePreviewView
|
|
228
|
+
};
|
|
229
|
+
CustomView = {
|
|
230
|
+
ComponentConfig: getCustomViewByKey(views, 'livePreview')
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
break;
|
|
234
|
+
}
|
|
235
|
+
case 'versions':
|
|
236
|
+
{
|
|
237
|
+
if (!overrideDocPermissions && docPermissions?.readVersions) {
|
|
238
|
+
CustomView = {
|
|
239
|
+
ComponentConfig: getCustomViewByKey(views, 'versions')
|
|
240
|
+
};
|
|
241
|
+
DefaultView = {
|
|
242
|
+
Component: DefaultVersionsView
|
|
243
|
+
};
|
|
244
|
+
} else {
|
|
245
|
+
ErrorView = {
|
|
246
|
+
Component: UnauthorizedView
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
break;
|
|
250
|
+
}
|
|
251
|
+
default:
|
|
252
|
+
{
|
|
253
|
+
if (!overrideDocPermissions && docPermissions?.read) {
|
|
254
|
+
const baseRoute = [adminRoute, globalEntity, globalSlug, segment3].filter(Boolean).join('/');
|
|
255
|
+
const currentRoute = [baseRoute, segment3, ...remainingSegments].filter(Boolean).join('/');
|
|
256
|
+
const {
|
|
257
|
+
Component: CustomViewComponent,
|
|
258
|
+
viewKey: customViewKey
|
|
259
|
+
} = getCustomViewByRoute({
|
|
260
|
+
baseRoute,
|
|
261
|
+
currentRoute,
|
|
262
|
+
views
|
|
263
|
+
});
|
|
264
|
+
if (customViewKey) {
|
|
265
|
+
viewKey = customViewKey;
|
|
266
|
+
CustomView = {
|
|
267
|
+
ComponentConfig: CustomViewComponent
|
|
268
|
+
};
|
|
269
|
+
} else {
|
|
270
|
+
DefaultView = {
|
|
271
|
+
Component: DefaultEditView
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
} else {
|
|
275
|
+
ErrorView = {
|
|
276
|
+
Component: UnauthorizedView
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
break;
|
|
283
|
+
}
|
|
284
|
+
default:
|
|
285
|
+
{
|
|
286
|
+
// `../:slug/versions/:version`, etc
|
|
287
|
+
if (segment3 === 'versions') {
|
|
288
|
+
if (!overrideDocPermissions && docPermissions?.readVersions) {
|
|
289
|
+
CustomView = {
|
|
290
|
+
ComponentConfig: getCustomViewByKey(views, 'version')
|
|
291
|
+
};
|
|
292
|
+
DefaultView = {
|
|
293
|
+
Component: DefaultVersionView
|
|
294
|
+
};
|
|
295
|
+
} else {
|
|
296
|
+
ErrorView = {
|
|
297
|
+
Component: UnauthorizedView
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
} else {
|
|
301
|
+
const baseRoute = [adminRoute !== '/' && adminRoute, 'globals', globalSlug].filter(Boolean).join('/');
|
|
302
|
+
const currentRoute = [baseRoute, segment3, ...remainingSegments].filter(Boolean).join('/');
|
|
303
|
+
const {
|
|
304
|
+
Component: CustomViewComponent,
|
|
305
|
+
viewKey: customViewKey
|
|
306
|
+
} = getCustomViewByRoute({
|
|
307
|
+
baseRoute,
|
|
308
|
+
currentRoute,
|
|
309
|
+
views
|
|
310
|
+
});
|
|
311
|
+
if (customViewKey) {
|
|
312
|
+
viewKey = customViewKey;
|
|
313
|
+
CustomView = {
|
|
314
|
+
ComponentConfig: CustomViewComponent
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
break;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
return {
|
|
324
|
+
CustomView,
|
|
325
|
+
DefaultView,
|
|
326
|
+
ErrorView,
|
|
327
|
+
viewKey
|
|
328
|
+
};
|
|
329
|
+
};
|
|
330
|
+
//# sourceMappingURL=getViewsFromConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getViewsFromConfig.js","names":["APIView","DefaultAPIView","EditView","DefaultEditView","LivePreviewView","DefaultLivePreviewView","UnauthorizedView","VersionView","DefaultVersionView","VersionsView","DefaultVersionsView","getCustomViewByKey","getCustomViewByRoute","getViewsFromConfig","collectionConfig","config","docPermissions","globalConfig","overrideDocPermissions","routeSegments","DefaultView","CustomView","ErrorView","viewKey","routes","admin","adminRoute","views","components","livePreviewEnabled","livePreview","collections","includes","slug","globals","collectionEntity","collectionSlug","segment3","segment4","segment5","remainingSegments","read","Error","length","create","ComponentConfig","Component","baseRoute","filter","Boolean","join","currentRoute","CustomViewComponent","customViewKey","hideAPIURL","readVersions","globalEntity","globalSlug"],"sources":["../../../src/views/Document/getViewsFromConfig.tsx"],"sourcesContent":["import type {\n AdminViewServerProps,\n DocumentViewServerProps,\n PayloadComponent,\n SanitizedCollectionConfig,\n SanitizedCollectionPermission,\n SanitizedConfig,\n SanitizedGlobalConfig,\n SanitizedGlobalPermission,\n} from 'payload'\nimport type React from 'react'\n\nimport { APIView as DefaultAPIView } from '../API/index.js'\nimport { EditView as DefaultEditView } from '../Edit/index.js'\nimport { LivePreviewView as DefaultLivePreviewView } from '../LivePreview/index.js'\nimport { UnauthorizedView } from '../Unauthorized/index.js'\nimport { VersionView as DefaultVersionView } from '../Version/index.js'\nimport { VersionsView as DefaultVersionsView } from '../Versions/index.js'\nimport { getCustomViewByKey } from './getCustomViewByKey.js'\nimport { getCustomViewByRoute } from './getCustomViewByRoute.js'\n\nexport type ViewFromConfig<TProps extends object> = {\n Component?: React.FC<TProps>\n ComponentConfig?: PayloadComponent<TProps>\n}\n\nexport const getViewsFromConfig = ({\n collectionConfig,\n config,\n docPermissions,\n globalConfig,\n overrideDocPermissions,\n routeSegments,\n}: {\n collectionConfig?: SanitizedCollectionConfig\n config: SanitizedConfig\n globalConfig?: SanitizedGlobalConfig\n routeSegments: string[]\n} & (\n | {\n docPermissions: SanitizedCollectionPermission | SanitizedGlobalPermission\n overrideDocPermissions?: false | undefined\n }\n | {\n docPermissions?: never\n overrideDocPermissions: true\n }\n)): {\n CustomView: ViewFromConfig<DocumentViewServerProps>\n DefaultView: ViewFromConfig<DocumentViewServerProps>\n /**\n * The error view to display if CustomView or DefaultView do not exist (could be either due to not found, or unauthorized). Can be null\n */\n ErrorView: ViewFromConfig<AdminViewServerProps>\n viewKey: string\n} | null => {\n // Conditionally import and lazy load the default view\n let DefaultView: ViewFromConfig<DocumentViewServerProps> = null\n let CustomView: ViewFromConfig<DocumentViewServerProps> = null\n let ErrorView: ViewFromConfig<AdminViewServerProps> = null\n let viewKey: string\n\n const {\n routes: { admin: adminRoute },\n } = config\n\n const views =\n (collectionConfig && collectionConfig?.admin?.components?.views) ||\n (globalConfig && globalConfig?.admin?.components?.views)\n\n const livePreviewEnabled =\n (collectionConfig && collectionConfig?.admin?.livePreview) ||\n config?.admin?.livePreview?.collections?.includes(collectionConfig?.slug) ||\n (globalConfig && globalConfig?.admin?.livePreview) ||\n config?.admin?.livePreview?.globals?.includes(globalConfig?.slug)\n\n if (collectionConfig) {\n const [collectionEntity, collectionSlug, segment3, segment4, segment5, ...remainingSegments] =\n routeSegments\n\n if (!overrideDocPermissions && !docPermissions?.read) {\n throw new Error('not-found')\n } else {\n // `../:id`, or `../create`\n switch (routeSegments.length) {\n case 3: {\n switch (segment3) {\n case 'create': {\n if (!overrideDocPermissions && 'create' in docPermissions && docPermissions.create) {\n CustomView = {\n ComponentConfig: getCustomViewByKey(views, 'default'),\n }\n DefaultView = {\n Component: DefaultEditView,\n }\n } else {\n ErrorView = {\n Component: UnauthorizedView,\n }\n }\n break\n }\n\n default: {\n const baseRoute = [\n adminRoute !== '/' && adminRoute,\n 'collections',\n collectionSlug,\n segment3,\n ]\n .filter(Boolean)\n .join('/')\n\n const currentRoute = [baseRoute, segment4, segment5, ...remainingSegments]\n .filter(Boolean)\n .join('/')\n\n const { Component: CustomViewComponent, viewKey: customViewKey } =\n getCustomViewByRoute({\n baseRoute,\n currentRoute,\n views,\n })\n\n if (customViewKey) {\n viewKey = customViewKey\n\n CustomView = {\n ComponentConfig: CustomViewComponent,\n }\n } else {\n CustomView = {\n ComponentConfig: getCustomViewByKey(views, 'default'),\n }\n\n DefaultView = {\n Component: DefaultEditView,\n }\n }\n\n break\n }\n }\n break\n }\n\n // `../:id/api`, `../:id/preview`, `../:id/versions`, etc\n case 4: {\n switch (segment4) {\n case 'api': {\n if (collectionConfig?.admin?.hideAPIURL !== true) {\n CustomView = {\n ComponentConfig: getCustomViewByKey(views, 'api'),\n }\n DefaultView = {\n Component: DefaultAPIView,\n }\n }\n break\n }\n\n case 'preview': {\n if (livePreviewEnabled) {\n DefaultView = {\n Component: DefaultLivePreviewView,\n }\n CustomView = {\n ComponentConfig: getCustomViewByKey(views, 'livePreview'),\n }\n }\n break\n }\n\n case 'versions': {\n if (!overrideDocPermissions && docPermissions?.readVersions) {\n CustomView = {\n ComponentConfig: getCustomViewByKey(views, 'versions'),\n }\n DefaultView = {\n Component: DefaultVersionsView,\n }\n } else {\n ErrorView = {\n Component: UnauthorizedView,\n }\n }\n break\n }\n\n default: {\n const baseRoute = [\n adminRoute !== '/' && adminRoute,\n 'collections',\n collectionSlug,\n segment3,\n ]\n .filter(Boolean)\n .join('/')\n\n const currentRoute = [baseRoute, segment4, segment5, ...remainingSegments]\n .filter(Boolean)\n .join('/')\n\n const { Component: CustomViewComponent, viewKey: customViewKey } =\n getCustomViewByRoute({\n baseRoute,\n currentRoute,\n views,\n })\n\n if (customViewKey) {\n viewKey = customViewKey\n\n CustomView = {\n ComponentConfig: CustomViewComponent,\n }\n }\n\n break\n }\n }\n break\n }\n\n // `../:id/versions/:version`, etc\n default: {\n if (segment4 === 'versions') {\n if (!overrideDocPermissions && docPermissions?.readVersions) {\n CustomView = {\n ComponentConfig: getCustomViewByKey(views, 'version'),\n }\n DefaultView = {\n Component: DefaultVersionView,\n }\n } else {\n ErrorView = {\n Component: UnauthorizedView,\n }\n }\n } else {\n const baseRoute = [\n adminRoute !== '/' && adminRoute,\n collectionEntity,\n collectionSlug,\n segment3,\n ]\n .filter(Boolean)\n .join('/')\n\n const currentRoute = [baseRoute, segment4, segment5, ...remainingSegments]\n .filter(Boolean)\n .join('/')\n\n const { Component: CustomViewComponent, viewKey: customViewKey } = getCustomViewByRoute(\n {\n baseRoute,\n currentRoute,\n views,\n },\n )\n\n if (customViewKey) {\n viewKey = customViewKey\n\n CustomView = {\n ComponentConfig: CustomViewComponent,\n }\n }\n }\n\n break\n }\n }\n }\n }\n\n if (globalConfig) {\n const [globalEntity, globalSlug, segment3, ...remainingSegments] = routeSegments\n\n if (!overrideDocPermissions && !docPermissions?.read) {\n throw new Error('not-found')\n } else {\n switch (routeSegments.length) {\n case 2: {\n CustomView = {\n ComponentConfig: getCustomViewByKey(views, 'default'),\n }\n DefaultView = {\n Component: DefaultEditView,\n }\n break\n }\n\n case 3: {\n // `../:slug/api`, `../:slug/preview`, `../:slug/versions`, etc\n switch (segment3) {\n case 'api': {\n if (globalConfig?.admin?.hideAPIURL !== true) {\n CustomView = {\n ComponentConfig: getCustomViewByKey(views, 'api'),\n }\n DefaultView = {\n Component: DefaultAPIView,\n }\n }\n break\n }\n\n case 'preview': {\n if (livePreviewEnabled) {\n DefaultView = {\n Component: DefaultLivePreviewView,\n }\n CustomView = {\n ComponentConfig: getCustomViewByKey(views, 'livePreview'),\n }\n }\n break\n }\n\n case 'versions': {\n if (!overrideDocPermissions && docPermissions?.readVersions) {\n CustomView = {\n ComponentConfig: getCustomViewByKey(views, 'versions'),\n }\n\n DefaultView = {\n Component: DefaultVersionsView,\n }\n } else {\n ErrorView = {\n Component: UnauthorizedView,\n }\n }\n break\n }\n\n default: {\n if (!overrideDocPermissions && docPermissions?.read) {\n const baseRoute = [adminRoute, globalEntity, globalSlug, segment3]\n .filter(Boolean)\n .join('/')\n\n const currentRoute = [baseRoute, segment3, ...remainingSegments]\n .filter(Boolean)\n .join('/')\n\n const { Component: CustomViewComponent, viewKey: customViewKey } =\n getCustomViewByRoute({\n baseRoute,\n currentRoute,\n views,\n })\n\n if (customViewKey) {\n viewKey = customViewKey\n\n CustomView = {\n ComponentConfig: CustomViewComponent,\n }\n } else {\n DefaultView = {\n Component: DefaultEditView,\n }\n }\n } else {\n ErrorView = {\n Component: UnauthorizedView,\n }\n }\n break\n }\n }\n break\n }\n\n default: {\n // `../:slug/versions/:version`, etc\n if (segment3 === 'versions') {\n if (!overrideDocPermissions && docPermissions?.readVersions) {\n CustomView = {\n ComponentConfig: getCustomViewByKey(views, 'version'),\n }\n DefaultView = {\n Component: DefaultVersionView,\n }\n } else {\n ErrorView = {\n Component: UnauthorizedView,\n }\n }\n } else {\n const baseRoute = [adminRoute !== '/' && adminRoute, 'globals', globalSlug]\n .filter(Boolean)\n .join('/')\n\n const currentRoute = [baseRoute, segment3, ...remainingSegments]\n .filter(Boolean)\n .join('/')\n\n const { Component: CustomViewComponent, viewKey: customViewKey } = getCustomViewByRoute(\n {\n baseRoute,\n currentRoute,\n views,\n },\n )\n\n if (customViewKey) {\n viewKey = customViewKey\n\n CustomView = {\n ComponentConfig: CustomViewComponent,\n }\n }\n }\n\n break\n }\n }\n }\n }\n\n return {\n CustomView,\n DefaultView,\n ErrorView,\n viewKey,\n }\n}\n"],"mappings":"AAYA,SAASA,OAAA,IAAWC,cAAc,QAAQ;AAC1C,SAASC,QAAA,IAAYC,eAAe,QAAQ;AAC5C,SAASC,eAAA,IAAmBC,sBA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A;IACAC;EACF;AACF","ignoreList":[]}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { AdminViewServerProps, Data
|
|
1
|
+
import type { AdminViewServerProps, Data } from 'payload';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import type { GenerateEditViewMetadata } from './getMetaBySegment.js';
|
|
4
4
|
export declare const generateMetadata: GenerateEditViewMetadata;
|
|
5
|
-
export type ViewToRender = EditViewComponent | PayloadComponent<DocumentViewServerProps> | React.FC | React.FC<DocumentViewClientProps>;
|
|
6
5
|
/**
|
|
7
6
|
* This function is responsible for rendering
|
|
8
7
|
* an Edit Document view on the server for both:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Document/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Document/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,IAAI,EAKL,MAAM,SAAS,CAAA;AAShB,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAcrE,eAAO,MAAM,gBAAgB,EAAE,wBAAiE,CAAA;AAEhG;;;;;GAKG;AACH,eAAO,MAAM,cAAc,6NAcxB;IACD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAA;IACtC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAA;IACtC,QAAQ,CAAC,sBAAsB,CAAC,EAAE,OAAO,CAAA;CAC1C,GAAG,oBAAoB,KAAG,OAAO,CAAC;IACjC,IAAI,EAAE,IAAI,CAAA;IACV,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,CAsVA,CAAA;AAED,wBAAsB,QAAQ,CAAC,KAAK,EAAE,oBAAoB,+QAezD"}
|
|
@@ -12,10 +12,10 @@ import { NotFoundView } from '../NotFound/index.js';
|
|
|
12
12
|
import { getDocPreferences } from './getDocPreferences.js';
|
|
13
13
|
import { getDocumentData } from './getDocumentData.js';
|
|
14
14
|
import { getDocumentPermissions } from './getDocumentPermissions.js';
|
|
15
|
-
import { getDocumentView } from './getDocumentView.js';
|
|
16
15
|
import { getIsLocked } from './getIsLocked.js';
|
|
17
16
|
import { getMetaBySegment } from './getMetaBySegment.js';
|
|
18
17
|
import { getVersions } from './getVersions.js';
|
|
18
|
+
import { getViewsFromConfig } from './getViewsFromConfig.js';
|
|
19
19
|
import { renderDocumentSlots } from './renderDocumentSlots.js';
|
|
20
20
|
export const generateMetadata = async args => getMetaBySegment(args);
|
|
21
21
|
/**
|
|
@@ -71,6 +71,11 @@ export const renderDocument = async ({
|
|
|
71
71
|
collectionSlug,
|
|
72
72
|
globalSlug
|
|
73
73
|
});
|
|
74
|
+
let RootViewOverride;
|
|
75
|
+
let CustomView;
|
|
76
|
+
let DefaultView;
|
|
77
|
+
let ErrorView;
|
|
78
|
+
let apiURL;
|
|
74
79
|
// Fetch the doc required for the view
|
|
75
80
|
let doc = initialData || (await getDocumentData({
|
|
76
81
|
id: idFromArgs,
|
|
@@ -160,37 +165,69 @@ export const renderDocument = async ({
|
|
|
160
165
|
searchParams,
|
|
161
166
|
user
|
|
162
167
|
};
|
|
163
|
-
if (
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
168
|
+
if (collectionConfig) {
|
|
169
|
+
if (!visibleEntities?.collections?.find(visibleSlug => visibleSlug === collectionSlug) && !overrideEntityVisibility) {
|
|
170
|
+
throw new Error('not-found');
|
|
171
|
+
}
|
|
172
|
+
const params = new URLSearchParams();
|
|
173
|
+
if (collectionConfig.versions?.drafts) {
|
|
174
|
+
params.append('draft', 'true');
|
|
175
|
+
}
|
|
176
|
+
if (locale?.code) {
|
|
177
|
+
params.append('locale', locale.code);
|
|
178
|
+
}
|
|
179
|
+
const apiQueryParams = `?${params.toString()}`;
|
|
180
|
+
apiURL = `${serverURL}${apiRoute}/${collectionSlug}/${idFromArgs}${apiQueryParams}`;
|
|
181
|
+
RootViewOverride = collectionConfig?.admin?.components?.views?.edit?.root && 'Component' in collectionConfig.admin.components.views.edit.root ? collectionConfig?.admin?.components?.views?.edit?.root?.Component : null;
|
|
182
|
+
if (!RootViewOverride) {
|
|
183
|
+
const collectionViews = getViewsFromConfig({
|
|
184
|
+
collectionConfig,
|
|
185
|
+
config,
|
|
186
|
+
docPermissions,
|
|
187
|
+
routeSegments: segments
|
|
188
|
+
});
|
|
189
|
+
CustomView = collectionViews?.CustomView;
|
|
190
|
+
DefaultView = collectionViews?.DefaultView;
|
|
191
|
+
ErrorView = collectionViews?.ErrorView;
|
|
192
|
+
}
|
|
193
|
+
if (!CustomView && !DefaultView && !RootViewOverride && !ErrorView) {
|
|
194
|
+
ErrorView = {
|
|
195
|
+
Component: NotFoundView
|
|
196
|
+
};
|
|
197
|
+
}
|
|
191
198
|
}
|
|
192
|
-
if (
|
|
193
|
-
|
|
199
|
+
if (globalConfig) {
|
|
200
|
+
if (!visibleEntities?.globals?.find(visibleSlug => visibleSlug === globalSlug)) {
|
|
201
|
+
throw new Error('not-found');
|
|
202
|
+
}
|
|
203
|
+
const params = new URLSearchParams({
|
|
204
|
+
locale: locale?.code
|
|
205
|
+
});
|
|
206
|
+
if (globalConfig.versions?.drafts) {
|
|
207
|
+
params.append('draft', 'true');
|
|
208
|
+
}
|
|
209
|
+
if (locale?.code) {
|
|
210
|
+
params.append('locale', locale.code);
|
|
211
|
+
}
|
|
212
|
+
const apiQueryParams = `?${params.toString()}`;
|
|
213
|
+
apiURL = `${serverURL}${apiRoute}/${globalSlug}${apiQueryParams}`;
|
|
214
|
+
RootViewOverride = globalConfig?.admin?.components?.views?.edit?.root && 'Component' in globalConfig.admin.components.views.edit.root ? globalConfig?.admin?.components?.views?.edit?.root?.Component : null;
|
|
215
|
+
if (!RootViewOverride) {
|
|
216
|
+
const globalViews = getViewsFromConfig({
|
|
217
|
+
config,
|
|
218
|
+
docPermissions,
|
|
219
|
+
globalConfig,
|
|
220
|
+
routeSegments: segments
|
|
221
|
+
});
|
|
222
|
+
CustomView = globalViews?.CustomView;
|
|
223
|
+
DefaultView = globalViews?.DefaultView;
|
|
224
|
+
ErrorView = globalViews?.ErrorView;
|
|
225
|
+
if (!CustomView && !DefaultView && !RootViewOverride && !ErrorView) {
|
|
226
|
+
ErrorView = {
|
|
227
|
+
Component: NotFoundView
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
}
|
|
194
231
|
}
|
|
195
232
|
/**
|
|
196
233
|
* Handle case where autoSave is enabled and the document is being created
|
|
@@ -266,7 +303,7 @@ export const renderDocument = async ({
|
|
|
266
303
|
redirectAfterDuplicate: redirectAfterDuplicate,
|
|
267
304
|
unpublishedVersionCount: unpublishedVersionCount,
|
|
268
305
|
versionCount: versionCount,
|
|
269
|
-
children: [
|
|
306
|
+
children: [!RootViewOverride && !drawerSlug && /*#__PURE__*/_jsx(DocumentHeader, {
|
|
270
307
|
collectionConfig: collectionConfig,
|
|
271
308
|
globalConfig: globalConfig,
|
|
272
309
|
i18n: i18n,
|
|
@@ -275,9 +312,14 @@ export const renderDocument = async ({
|
|
|
275
312
|
}), /*#__PURE__*/_jsx(HydrateAuthProvider, {
|
|
276
313
|
permissions: permissions
|
|
277
314
|
}), /*#__PURE__*/_jsx(EditDepthProvider, {
|
|
278
|
-
children: RenderServerComponent({
|
|
315
|
+
children: ErrorView ? RenderServerComponent({
|
|
316
|
+
clientProps,
|
|
317
|
+
Component: ErrorView.ComponentConfig || ErrorView.Component,
|
|
318
|
+
importMap,
|
|
319
|
+
serverProps: documentViewServerProps
|
|
320
|
+
}) : RenderServerComponent({
|
|
279
321
|
clientProps,
|
|
280
|
-
Component:
|
|
322
|
+
Component: RootViewOverride ? RootViewOverride : CustomView?.ComponentConfig || CustomView?.Component ? CustomView?.ComponentConfig || CustomView?.Component : DefaultView?.ComponentConfig || DefaultView?.Component,
|
|
281
323
|
importMap,
|
|
282
324
|
serverProps: documentViewServerProps
|
|
283
325
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["DocumentInfoProvider","EditDepthProvider","HydrateAuthProvider","RenderServerComponent","isEditing","getIsEditing","buildFormState","notFound","redirect","logError","formatAdminURL","React","DocumentHeader","NotFoundView","getDocPreferences","getDocumentData","getDocumentPermissions","getDocumentView","getIsLocked","getMetaBySegment","getVersions","renderDocumentSlots","generateMetadata","args","renderDocument","disableActions","documentSubViewType","drawerSlug","importMap","initialData","initPageResult","overrideEntityVisibility","params","redirectAfterCreate","redirectAfterDelete","redirectAfterDuplicate","searchParams","viewType","collectionConfig","docID","idFromArgs","globalConfig","locale","permissions","req","i18n","payload","config","routes","admin","adminRoute","api","apiRoute","serverURL","user","visibleEntities","segments","Array","isArray","collectionSlug","slug","undefined","globalSlug","id","doc","Error","docPreferences","docPermissions","hasPublishPermission","hasSavePermission","currentEditor","isLocked","lastUpdateTime","Promise","all","data","hasPublishedDoc","mostRecentVersionIsAutosaved","unpublishedVersionCount","versionCount","state","formState","code","fallbackLocale","operation","renderAllFields","schemaPath","skipValidation","documentViewServerProps","routeSegments","collections","find","visibleSlug","globals","formattedParams","URLSearchParams","versions","drafts","append","apiQueryParams","toString","apiURL","View","showHeader","RootViewOverride","components","views","edit","root","Component","shouldAutosave","autosave","validateDraftData","validate","create","collection","depth","draft","redirectURL","path","documentSlots","clientProps","Document","_jsxs","initialState","_jsx","serverProps","props","RenderedDocument","error","message","err"],"sources":["../../../src/views/Document/index.tsx"],"sourcesContent":["import type {\n AdminViewServerProps,\n Data,\n DocumentViewClientProps,\n DocumentViewServerProps,\n DocumentViewServerPropsOnly,\n EditViewComponent,\n PayloadComponent,\n} from 'payload'\n\nimport { DocumentInfoProvider, EditDepthProvider, HydrateAuthProvider } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { isEditing as getIsEditing } from '@payloadcms/ui/shared'\nimport { buildFormState } from '@payloadcms/ui/utilities/buildFormState'\nimport { notFound, redirect } from 'next/navigation.js'\nimport { logError } from 'payload'\nimport { formatAdminURL } from 'payload/shared'\nimport React from 'react'\n\nimport type { GenerateEditViewMetadata } from './getMetaBySegment.js'\n\nimport { DocumentHeader } from '../../elements/DocumentHeader/index.js'\nimport { NotFoundView } from '../NotFound/index.js'\nimport { getDocPreferences } from './getDocPreferences.js'\nimport { getDocumentData } from './getDocumentData.js'\nimport { getDocumentPermissions } from './getDocumentPermissions.js'\nimport { getDocumentView } from './getDocumentView.js'\nimport { getIsLocked } from './getIsLocked.js'\nimport { getMetaBySegment } from './getMetaBySegment.js'\nimport { getVersions } from './getVersions.js'\nimport { renderDocumentSlots } from './renderDocumentSlots.js'\n\nexport const generateMetadata: GenerateEditViewMetadata = async (args) => getMetaBySegment(args)\n\nexport type ViewToRender =\n | EditViewComponent\n | PayloadComponent<DocumentViewServerProps>\n | React.FC\n | React.FC<DocumentViewClientProps>\n\n/**\n * This function is responsible for rendering\n * an Edit Document view on the server for both:\n * - default document edit views\n * - on-demand edit views within drawers\n */\nexport const renderDocument = async ({\n disableActions,\n documentSubViewType,\n drawerSlug,\n importMap,\n initialData,\n initPageResult,\n overrideEntityVisibility,\n params,\n redirectAfterCreate,\n redirectAfterDelete,\n redirectAfterDuplicate,\n searchParams,\n viewType,\n}: {\n drawerSlug?: string\n overrideEntityVisibility?: boolean\n readonly redirectAfterCreate?: boolean\n readonly redirectAfterDelete?: boolean\n readonly redirectAfterDuplicate?: boolean\n} & AdminViewServerProps): Promise<{\n data: Data\n Document: React.ReactNode\n}> => {\n const {\n collectionConfig,\n docID: idFromArgs,\n globalConfig,\n locale,\n permissions,\n req,\n req: {\n i18n,\n payload,\n payload: {\n config,\n config: {\n routes: { admin: adminRoute, api: apiRoute },\n serverURL,\n },\n },\n user,\n },\n visibleEntities,\n } = initPageResult\n\n const segments = Array.isArray(params?.segments) ? params.segments : []\n const collectionSlug = collectionConfig?.slug || undefined\n const globalSlug = globalConfig?.slug || undefined\n let isEditing = getIsEditing({ id: idFromArgs, collectionSlug, globalSlug })\n\n // Fetch the doc required for the view\n let doc =\n initialData ||\n (await getDocumentData({\n id: idFromArgs,\n collectionSlug,\n globalSlug,\n locale,\n payload,\n req,\n user,\n }))\n\n if (isEditing && !doc) {\n throw new Error('not-found')\n }\n\n const [\n docPreferences,\n { docPermissions, hasPublishPermission, hasSavePermission },\n { currentEditor, isLocked, lastUpdateTime },\n ] = await Promise.all([\n // Get document preferences\n getDocPreferences({\n id: idFromArgs,\n collectionSlug,\n globalSlug,\n payload,\n user,\n }),\n\n // Get permissions\n getDocumentPermissions({\n id: idFromArgs,\n collectionConfig,\n data: doc,\n globalConfig,\n req,\n }),\n\n // Fetch document lock state\n getIsLocked({\n id: idFromArgs,\n collectionConfig,\n globalConfig,\n isEditing,\n req,\n }),\n ])\n\n const [\n { hasPublishedDoc, mostRecentVersionIsAutosaved, unpublishedVersionCount, versionCount },\n { state: formState },\n ] = await Promise.all([\n getVersions({\n id: idFromArgs,\n collectionConfig,\n doc,\n docPermissions,\n globalConfig,\n locale: locale?.code,\n payload,\n user,\n }),\n buildFormState({\n id: idFromArgs,\n collectionSlug,\n data: doc,\n docPermissions,\n docPreferences,\n fallbackLocale: false,\n globalSlug,\n locale: locale?.code,\n operation: (collectionSlug && idFromArgs) || globalSlug ? 'update' : 'create',\n renderAllFields: true,\n req,\n schemaPath: collectionSlug || globalSlug,\n skipValidation: true,\n }),\n ])\n\n const documentViewServerProps: DocumentViewServerPropsOnly = {\n doc,\n i18n,\n initPageResult,\n locale,\n params,\n payload,\n permissions,\n routeSegments: segments,\n searchParams,\n user,\n }\n\n if (\n !overrideEntityVisibility &&\n ((collectionSlug &&\n !visibleEntities?.collections?.find((visibleSlug) => visibleSlug === collectionSlug)) ||\n (globalSlug && !visibleEntities?.globals?.find((visibleSlug) => visibleSlug === globalSlug)))\n ) {\n throw new Error('not-found')\n }\n\n const formattedParams = new URLSearchParams()\n\n if (collectionConfig?.versions?.drafts || globalConfig?.versions?.drafts) {\n formattedParams.append('draft', 'true')\n }\n\n if (locale?.code) {\n formattedParams.append('locale', locale.code)\n }\n\n const apiQueryParams = `?${formattedParams.toString()}`\n\n const apiURL = collectionSlug\n ? `${serverURL}${apiRoute}/${collectionSlug}/${idFromArgs}${apiQueryParams}`\n : globalSlug\n ? `${serverURL}${apiRoute}/${globalSlug}${apiQueryParams}`\n : ''\n\n let View: ViewToRender = null\n\n let showHeader = true\n\n const RootViewOverride =\n collectionConfig?.admin?.components?.views?.edit?.root &&\n 'Component' in collectionConfig.admin.components.views.edit.root\n ? collectionConfig?.admin?.components?.views?.edit?.root?.Component\n : globalConfig?.admin?.components?.views?.edit?.root &&\n 'Component' in globalConfig.admin.components.views.edit.root\n ? globalConfig?.admin?.components?.views?.edit?.root?.Component\n : null\n\n if (RootViewOverride) {\n View = RootViewOverride\n showHeader = false\n } else {\n ;({ View } = getDocumentView({\n collectionConfig,\n config,\n docPermissions,\n globalConfig,\n routeSegments: segments,\n }))\n }\n\n if (!View) {\n View = NotFoundView\n }\n\n /**\n * Handle case where autoSave is enabled and the document is being created\n * => create document and redirect\n */\n const shouldAutosave =\n hasSavePermission &&\n ((collectionConfig?.versions?.drafts && collectionConfig?.versions?.drafts?.autosave) ||\n (globalConfig?.versions?.drafts && globalConfig?.versions?.drafts?.autosave))\n\n const validateDraftData =\n collectionConfig?.versions?.drafts && collectionConfig?.versions?.drafts?.validate\n\n let id = idFromArgs\n\n if (shouldAutosave && !validateDraftData && !idFromArgs && collectionSlug) {\n doc = await payload.create({\n collection: collectionSlug,\n data: initialData || {},\n depth: 0,\n draft: true,\n fallbackLocale: false,\n locale: locale?.code,\n req,\n user,\n })\n\n if (doc?.id) {\n id = doc.id\n isEditing = getIsEditing({ id: doc.id, collectionSlug, globalSlug })\n\n if (!drawerSlug && redirectAfterCreate !== false) {\n const redirectURL = formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}/${doc.id}`,\n serverURL,\n })\n\n redirect(redirectURL)\n }\n } else {\n throw new Error('not-found')\n }\n }\n\n const documentSlots = renderDocumentSlots({\n collectionConfig,\n globalConfig,\n hasSavePermission,\n permissions: docPermissions,\n req,\n })\n\n const clientProps: DocumentViewClientProps = {\n formState,\n ...documentSlots,\n documentSubViewType,\n viewType,\n }\n\n return {\n data: doc,\n Document: (\n <DocumentInfoProvider\n apiURL={apiURL}\n collectionSlug={collectionConfig?.slug}\n currentEditor={currentEditor}\n disableActions={disableActions ?? false}\n docPermissions={docPermissions}\n globalSlug={globalConfig?.slug}\n hasPublishedDoc={hasPublishedDoc}\n hasPublishPermission={hasPublishPermission}\n hasSavePermission={hasSavePermission}\n id={id}\n initialData={doc}\n initialState={formState}\n isEditing={isEditing}\n isLocked={isLocked}\n key={locale?.code}\n lastUpdateTime={lastUpdateTime}\n mostRecentVersionIsAutosaved={mostRecentVersionIsAutosaved}\n redirectAfterCreate={redirectAfterCreate}\n redirectAfterDelete={redirectAfterDelete}\n redirectAfterDuplicate={redirectAfterDuplicate}\n unpublishedVersionCount={unpublishedVersionCount}\n versionCount={versionCount}\n >\n {showHeader && !drawerSlug && (\n <DocumentHeader\n collectionConfig={collectionConfig}\n globalConfig={globalConfig}\n i18n={i18n}\n payload={payload}\n permissions={permissions}\n />\n )}\n <HydrateAuthProvider permissions={permissions} />\n <EditDepthProvider>\n {RenderServerComponent({\n clientProps,\n Component: View,\n importMap,\n serverProps: documentViewServerProps,\n })}\n </EditDepthProvider>\n </DocumentInfoProvider>\n ),\n }\n}\n\nexport async function Document(props: AdminViewServerProps) {\n try {\n const { Document: RenderedDocument } = await renderDocument(props)\n return RenderedDocument\n } catch (error) {\n if (error?.message === 'NEXT_REDIRECT') {\n throw error\n }\n\n logError({ err: error, payload: props.initPageResult.req.payload })\n\n if (error.message === 'not-found') {\n notFound()\n }\n }\n}\n"],"mappings":";AAUA,SAASA,oBAAoB,EAAEC,iBAAiB,EAAEC,mBAAmB,QAAQ;AAC7E,SAASC,qBAAqB,QAAQ;AACtC,SAASC,SAAA,IAAaC,YAAY,QAAQ;AAC1C,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,EAAEC,QAAQ,QAAQ;AACnC,SAASC,QAAQ,QAAQ;AACzB,SAASC,cAAc,QAAQ;AAC/B,OAAOC,KAAA,MAAW;AAIlB,SAASC,cAAc,QAAQ;AAC/B,SAASC,YAAY,QAAQ;AAC7B,SAASC,iBAAiB,QAAQ;AAClC,SAASC,eAAe,QAAQ;AAChC,SAASC,sBAAsB,QAAQ;AACvC,SAASC,eAAe,QAAQ;AAChC,SAASC,WAAW,QAAQ;AAC5B,SAASC,gBAAgB,QAAQ;AACjC,SAASC,WAAW,QAAQ;AAC5B,SAASC,mBAAmB,QAAQ;AAEpC,OAAO,MAAMC,gBAAA,GAA6C,MAAOC,IAAA,IAASJ,gBAAA,CAAiBI,IAAA;AAQ3F;;;;;;AAMA,OAAO,MAAMC,cAAA,GAAiB,MAAAA,CAAO;EACnCC,cAAc;EACdC,mBAAmB;EACnBC,UAAU;EACVC,SAAS;EACTC,WAAW;EACXC,cAAc;EACdC,wBAAwB;EACxBC,MAAM;EACNC,mBAAmB;EACnBC,mBAAmB;EACnBC,sBAAsB;EACtBC,YAAY;EACZC;AAAQ,CAOc;EAItB,MAAM;IACJC,gBAAgB;IAChBC,KAAA,EA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UAAA,iBACdkG,IAAA,CAACjH,cAAA;QACC0B,gBAAA,EAAkBA,gBAAA;QAClBG,YAAA,EAAcA,YAAA;QACdI,IAAA,EAAMA,IAAA;QACNC,OAAA,EAASA,OAAA;QACTH,WAAA,EAAaA;uBAGjBkF,IAAA,CAAC3H,mBAAA;QAAoByC,WAAA,EAAaA;uBAClCkF,IAAA,CAAC5H,iBAAA;kBACEE,qBAAA,CAAsB;UACrBsH,WAAA;UACAZ,SAAA,EAAWP,IAAA;UACX1E,SAAA;UACAkG,WAAA,EAAatC;QACf;;OAzBG9C,MAAA,EAAQwC,IAAA;EA6BnB;AACF;AAEA,OAAO,eAAewC,SAASK,KAA2B;EACxD,IAAI;IACF,MAAM;MAAEL,QAAA,EAAUM;IAAgB,CAAE,GAAG,MAAMxG,cAAA,CAAeuG,KAAA;IAC5D,OAAOC,gBAAA;EACT,EAAE,OAAOC,KAAA,EAAO;IACd,IAAIA,KAAA,EAAOC,OAAA,KAAY,iBAAiB;MACtC,MAAMD,KAAA;IACR;IAEAxH,QAAA,CAAS;MAAE0H,GAAA,EAAKF,KAAA;MAAOnF,OAAA,EAASiF,KAAA,CAAMjG,cAAc,CAACc,GAAG,CAACE;IAAQ;IAEjE,IAAImF,KAAA,CAAMC,OAAO,KAAK,aAAa;MACjC3H,QAAA;IACF;EACF;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["DocumentInfoProvider","EditDepthProvider","HydrateAuthProvider","RenderServerComponent","isEditing","getIsEditing","buildFormState","notFound","redirect","logError","formatAdminURL","React","DocumentHeader","NotFoundView","getDocPreferences","getDocumentData","getDocumentPermissions","getIsLocked","getMetaBySegment","getVersions","getViewsFromConfig","renderDocumentSlots","generateMetadata","args","renderDocument","disableActions","documentSubViewType","drawerSlug","importMap","initialData","initPageResult","overrideEntityVisibility","params","redirectAfterCreate","redirectAfterDelete","redirectAfterDuplicate","searchParams","viewType","collectionConfig","docID","idFromArgs","globalConfig","locale","permissions","req","i18n","payload","config","routes","admin","adminRoute","api","apiRoute","serverURL","user","visibleEntities","segments","Array","isArray","collectionSlug","slug","undefined","globalSlug","id","RootViewOverride","CustomView","DefaultView","ErrorView","apiURL","doc","Error","docPreferences","docPermissions","hasPublishPermission","hasSavePermission","currentEditor","isLocked","lastUpdateTime","Promise","all","data","hasPublishedDoc","mostRecentVersionIsAutosaved","unpublishedVersionCount","versionCount","state","formState","code","fallbackLocale","operation","renderAllFields","schemaPath","skipValidation","documentViewServerProps","routeSegments","collections","find","visibleSlug","URLSearchParams","versions","drafts","append","apiQueryParams","toString","components","views","edit","root","Component","collectionViews","globals","globalViews","shouldAutosave","autosave","validateDraftData","validate","create","collection","depth","draft","redirectURL","path","documentSlots","clientProps","Document","_jsxs","initialState","_jsx","ComponentConfig","serverProps","props","RenderedDocument","error","message","err"],"sources":["../../../src/views/Document/index.tsx"],"sourcesContent":["import type {\n AdminViewServerProps,\n Data,\n DocumentViewClientProps,\n DocumentViewServerProps,\n DocumentViewServerPropsOnly,\n PayloadComponent,\n} from 'payload'\n\nimport { DocumentInfoProvider, EditDepthProvider, HydrateAuthProvider } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { isEditing as getIsEditing } from '@payloadcms/ui/shared'\nimport { buildFormState } from '@payloadcms/ui/utilities/buildFormState'\nimport { notFound, redirect } from 'next/navigation.js'\nimport { logError } from 'payload'\nimport { formatAdminURL } from 'payload/shared'\nimport React from 'react'\n\nimport type { GenerateEditViewMetadata } from './getMetaBySegment.js'\nimport type { ViewFromConfig } from './getViewsFromConfig.js'\n\nimport { DocumentHeader } from '../../elements/DocumentHeader/index.js'\nimport { NotFoundView } from '../NotFound/index.js'\nimport { getDocPreferences } from './getDocPreferences.js'\nimport { getDocumentData } from './getDocumentData.js'\nimport { getDocumentPermissions } from './getDocumentPermissions.js'\nimport { getIsLocked } from './getIsLocked.js'\nimport { getMetaBySegment } from './getMetaBySegment.js'\nimport { getVersions } from './getVersions.js'\nimport { getViewsFromConfig } from './getViewsFromConfig.js'\nimport { renderDocumentSlots } from './renderDocumentSlots.js'\n\nexport const generateMetadata: GenerateEditViewMetadata = async (args) => getMetaBySegment(args)\n\n/**\n * This function is responsible for rendering\n * an Edit Document view on the server for both:\n * - default document edit views\n * - on-demand edit views within drawers\n */\nexport const renderDocument = async ({\n disableActions,\n documentSubViewType,\n drawerSlug,\n importMap,\n initialData,\n initPageResult,\n overrideEntityVisibility,\n params,\n redirectAfterCreate,\n redirectAfterDelete,\n redirectAfterDuplicate,\n searchParams,\n viewType,\n}: {\n drawerSlug?: string\n overrideEntityVisibility?: boolean\n readonly redirectAfterCreate?: boolean\n readonly redirectAfterDelete?: boolean\n readonly redirectAfterDuplicate?: boolean\n} & AdminViewServerProps): Promise<{\n data: Data\n Document: React.ReactNode\n}> => {\n const {\n collectionConfig,\n docID: idFromArgs,\n globalConfig,\n locale,\n permissions,\n req,\n req: {\n i18n,\n payload,\n payload: {\n config,\n config: {\n routes: { admin: adminRoute, api: apiRoute },\n serverURL,\n },\n },\n user,\n },\n visibleEntities,\n } = initPageResult\n\n const segments = Array.isArray(params?.segments) ? params.segments : []\n const collectionSlug = collectionConfig?.slug || undefined\n const globalSlug = globalConfig?.slug || undefined\n let isEditing = getIsEditing({ id: idFromArgs, collectionSlug, globalSlug })\n\n let RootViewOverride: PayloadComponent\n let CustomView: ViewFromConfig<DocumentViewServerProps>\n let DefaultView: ViewFromConfig<DocumentViewServerProps>\n let ErrorView: ViewFromConfig<AdminViewServerProps>\n\n let apiURL: string\n\n // Fetch the doc required for the view\n let doc =\n initialData ||\n (await getDocumentData({\n id: idFromArgs,\n collectionSlug,\n globalSlug,\n locale,\n payload,\n req,\n user,\n }))\n\n if (isEditing && !doc) {\n throw new Error('not-found')\n }\n\n const [\n docPreferences,\n { docPermissions, hasPublishPermission, hasSavePermission },\n { currentEditor, isLocked, lastUpdateTime },\n ] = await Promise.all([\n // Get document preferences\n getDocPreferences({\n id: idFromArgs,\n collectionSlug,\n globalSlug,\n payload,\n user,\n }),\n\n // Get permissions\n getDocumentPermissions({\n id: idFromArgs,\n collectionConfig,\n data: doc,\n globalConfig,\n req,\n }),\n\n // Fetch document lock state\n getIsLocked({\n id: idFromArgs,\n collectionConfig,\n globalConfig,\n isEditing,\n req,\n }),\n ])\n\n const [\n { hasPublishedDoc, mostRecentVersionIsAutosaved, unpublishedVersionCount, versionCount },\n { state: formState },\n ] = await Promise.all([\n getVersions({\n id: idFromArgs,\n collectionConfig,\n doc,\n docPermissions,\n globalConfig,\n locale: locale?.code,\n payload,\n user,\n }),\n buildFormState({\n id: idFromArgs,\n collectionSlug,\n data: doc,\n docPermissions,\n docPreferences,\n fallbackLocale: false,\n globalSlug,\n locale: locale?.code,\n operation: (collectionSlug && idFromArgs) || globalSlug ? 'update' : 'create',\n renderAllFields: true,\n req,\n schemaPath: collectionSlug || globalSlug,\n skipValidation: true,\n }),\n ])\n\n const documentViewServerProps: DocumentViewServerPropsOnly = {\n doc,\n i18n,\n initPageResult,\n locale,\n params,\n payload,\n permissions,\n routeSegments: segments,\n searchParams,\n user,\n }\n\n if (collectionConfig) {\n if (\n !visibleEntities?.collections?.find((visibleSlug) => visibleSlug === collectionSlug) &&\n !overrideEntityVisibility\n ) {\n throw new Error('not-found')\n }\n\n const params = new URLSearchParams()\n\n if (collectionConfig.versions?.drafts) {\n params.append('draft', 'true')\n }\n\n if (locale?.code) {\n params.append('locale', locale.code)\n }\n\n const apiQueryParams = `?${params.toString()}`\n\n apiURL = `${serverURL}${apiRoute}/${collectionSlug}/${idFromArgs}${apiQueryParams}`\n\n RootViewOverride =\n collectionConfig?.admin?.components?.views?.edit?.root &&\n 'Component' in collectionConfig.admin.components.views.edit.root\n ? collectionConfig?.admin?.components?.views?.edit?.root?.Component\n : null\n\n if (!RootViewOverride) {\n const collectionViews = getViewsFromConfig({\n collectionConfig,\n config,\n docPermissions,\n routeSegments: segments,\n })\n\n CustomView = collectionViews?.CustomView\n DefaultView = collectionViews?.DefaultView\n ErrorView = collectionViews?.ErrorView\n }\n\n if (!CustomView && !DefaultView && !RootViewOverride && !ErrorView) {\n ErrorView = {\n Component: NotFoundView,\n }\n }\n }\n\n if (globalConfig) {\n if (!visibleEntities?.globals?.find((visibleSlug) => visibleSlug === globalSlug)) {\n throw new Error('not-found')\n }\n\n const params = new URLSearchParams({\n locale: locale?.code,\n })\n\n if (globalConfig.versions?.drafts) {\n params.append('draft', 'true')\n }\n\n if (locale?.code) {\n params.append('locale', locale.code)\n }\n\n const apiQueryParams = `?${params.toString()}`\n\n apiURL = `${serverURL}${apiRoute}/${globalSlug}${apiQueryParams}`\n\n RootViewOverride =\n globalConfig?.admin?.components?.views?.edit?.root &&\n 'Component' in globalConfig.admin.components.views.edit.root\n ? globalConfig?.admin?.components?.views?.edit?.root?.Component\n : null\n\n if (!RootViewOverride) {\n const globalViews = getViewsFromConfig({\n config,\n docPermissions,\n globalConfig,\n routeSegments: segments,\n })\n\n CustomView = globalViews?.CustomView\n DefaultView = globalViews?.DefaultView\n ErrorView = globalViews?.ErrorView\n\n if (!CustomView && !DefaultView && !RootViewOverride && !ErrorView) {\n ErrorView = {\n Component: NotFoundView,\n }\n }\n }\n }\n\n /**\n * Handle case where autoSave is enabled and the document is being created\n * => create document and redirect\n */\n const shouldAutosave =\n hasSavePermission &&\n ((collectionConfig?.versions?.drafts && collectionConfig?.versions?.drafts?.autosave) ||\n (globalConfig?.versions?.drafts && globalConfig?.versions?.drafts?.autosave))\n\n const validateDraftData =\n collectionConfig?.versions?.drafts && collectionConfig?.versions?.drafts?.validate\n\n let id = idFromArgs\n\n if (shouldAutosave && !validateDraftData && !idFromArgs && collectionSlug) {\n doc = await payload.create({\n collection: collectionSlug,\n data: initialData || {},\n depth: 0,\n draft: true,\n fallbackLocale: false,\n locale: locale?.code,\n req,\n user,\n })\n\n if (doc?.id) {\n id = doc.id\n isEditing = getIsEditing({ id: doc.id, collectionSlug, globalSlug })\n\n if (!drawerSlug && redirectAfterCreate !== false) {\n const redirectURL = formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}/${doc.id}`,\n serverURL,\n })\n\n redirect(redirectURL)\n }\n } else {\n throw new Error('not-found')\n }\n }\n\n const documentSlots = renderDocumentSlots({\n collectionConfig,\n globalConfig,\n hasSavePermission,\n permissions: docPermissions,\n req,\n })\n\n const clientProps: DocumentViewClientProps = {\n formState,\n ...documentSlots,\n documentSubViewType,\n viewType,\n }\n\n return {\n data: doc,\n Document: (\n <DocumentInfoProvider\n apiURL={apiURL}\n collectionSlug={collectionConfig?.slug}\n currentEditor={currentEditor}\n disableActions={disableActions ?? false}\n docPermissions={docPermissions}\n globalSlug={globalConfig?.slug}\n hasPublishedDoc={hasPublishedDoc}\n hasPublishPermission={hasPublishPermission}\n hasSavePermission={hasSavePermission}\n id={id}\n initialData={doc}\n initialState={formState}\n isEditing={isEditing}\n isLocked={isLocked}\n key={locale?.code}\n lastUpdateTime={lastUpdateTime}\n mostRecentVersionIsAutosaved={mostRecentVersionIsAutosaved}\n redirectAfterCreate={redirectAfterCreate}\n redirectAfterDelete={redirectAfterDelete}\n redirectAfterDuplicate={redirectAfterDuplicate}\n unpublishedVersionCount={unpublishedVersionCount}\n versionCount={versionCount}\n >\n {!RootViewOverride && !drawerSlug && (\n <DocumentHeader\n collectionConfig={collectionConfig}\n globalConfig={globalConfig}\n i18n={i18n}\n payload={payload}\n permissions={permissions}\n />\n )}\n <HydrateAuthProvider permissions={permissions} />\n <EditDepthProvider>\n {ErrorView\n ? RenderServerComponent({\n clientProps,\n Component: ErrorView.ComponentConfig || ErrorView.Component,\n importMap,\n serverProps: documentViewServerProps,\n })\n : RenderServerComponent({\n clientProps,\n Component: RootViewOverride\n ? RootViewOverride\n : CustomView?.ComponentConfig || CustomView?.Component\n ? CustomView?.ComponentConfig || CustomView?.Component\n : DefaultView?.ComponentConfig || DefaultView?.Component,\n importMap,\n serverProps: documentViewServerProps,\n })}\n </EditDepthProvider>\n </DocumentInfoProvider>\n ),\n }\n}\n\nexport async function Document(props: AdminViewServerProps) {\n try {\n const { Document: RenderedDocument } = await renderDocument(props)\n return RenderedDocument\n } catch (error) {\n if (error?.message === 'NEXT_REDIRECT') {\n throw error\n }\n\n logError({ err: error, payload: props.initPageResult.req.payload })\n\n if (error.message === 'not-found') {\n notFound()\n }\n }\n}\n"],"mappings":";AASA,SAASA,oBAAoB,EAAEC,iBAAiB,EAAEC,mBAAmB,QAAQ;AAC7E,SAASC,qBAAqB,QAAQ;AACtC,SAASC,SAAA,IAAaC,YAAY,QAAQ;AAC1C,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,EAAEC,QAAQ,QAAQ;AACnC,SAASC,QAAQ,QAAQ;AACzB,SAASC,cAAc,QAAQ;AAC/B,OAAOC,KAAA,MAAW;AAKlB,SAASC,cAAc,QAAQ;AAC/B,SAASC,YAAY,QAAQ;AAC7B,SAASC,iBAAiB,QAAQ;AAClC,SAASC,eAAe,QAAQ;AAChC,SAASC,sBAAsB,QAAQ;AACvC,SAASC,WAAW,QAAQ;AAC5B,SAASC,gBAAgB,QAAQ;AACjC,SAASC,WAAW,QAAQ;AAC5B,SAASC,kBAAkB,QAAQ;AACnC,SAASC,mBAAmB,QAAQ;AAEpC,OAAO,MAAMC,gBAAA,GAA6C,MAAOC,IAAA,IAASL,gBAAA,CAAiBK,IAAA;AAE3F;;;;;;AAMA,OAAO,MAAMC,cAAA,GAAiB,MAAAA,CAAO;EACnCC,cAAc;EACdC,mBAAmB;EACnBC,UAAU;EACVC,SAAS;EACTC,WAAW;EACXC,cAAc;EACdC,wBAAwB;EACxBC,MAAM;EACNC,mBAAmB;EACnBC,mBAAmB;EACnBC,sBAAsB;EACtBC,YAAY;EACZC;AAAQ,CAOc;EAItB,MAAM;IACJC,gBAAgB;IAChBC,KAAA,EAAOC,UAAU;IACjBC,YAAY;IACZC,MAAM;IACNC,WAAW;IACXC,GAAG;IACHA,GAAA,EAAK;MACHC,IAAI;MACJC,OAAO;MACPA,OAAA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