@payloadcms/next 3.74.0 → 3.75.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/auth/login.d.ts +9 -12
  2. package/dist/auth/login.d.ts.map +1 -1
  3. package/dist/auth/login.js.map +1 -1
  4. package/dist/auth/logout.d.ts +2 -2
  5. package/dist/auth/logout.d.ts.map +1 -1
  6. package/dist/auth/logout.js.map +1 -1
  7. package/dist/auth/refresh.d.ts +2 -1
  8. package/dist/auth/refresh.d.ts.map +1 -1
  9. package/dist/auth/refresh.js.map +1 -1
  10. package/dist/cjs/withPayload.cjs +1 -1
  11. package/dist/cjs/withPayload.cjs.map +1 -1
  12. package/dist/elements/Nav/getNavPrefs.d.ts.map +1 -1
  13. package/dist/elements/Nav/getNavPrefs.js +2 -1
  14. package/dist/elements/Nav/getNavPrefs.js.map +1 -1
  15. package/dist/elements/Nav/index.d.ts.map +1 -1
  16. package/dist/elements/Nav/index.js +76 -38
  17. package/dist/elements/Nav/index.js.map +1 -1
  18. package/dist/exports/client.d.ts +1 -1
  19. package/dist/exports/client.d.ts.map +1 -1
  20. package/dist/exports/client.js +1 -1
  21. package/dist/exports/client.js.map +1 -1
  22. package/dist/exports/rsc.d.ts +1 -1
  23. package/dist/exports/rsc.d.ts.map +1 -1
  24. package/dist/exports/rsc.js +1 -1
  25. package/dist/exports/rsc.js.map +1 -1
  26. package/dist/utilities/handleServerFunctions.d.ts.map +1 -1
  27. package/dist/utilities/handleServerFunctions.js +7 -5
  28. package/dist/utilities/handleServerFunctions.js.map +1 -1
  29. package/dist/utilities/initReq.d.ts +2 -13
  30. package/dist/utilities/initReq.d.ts.map +1 -1
  31. package/dist/utilities/initReq.js.map +1 -1
  32. package/dist/views/BrowseByFolder/buildView.d.ts.map +1 -1
  33. package/dist/views/BrowseByFolder/buildView.js +2 -1
  34. package/dist/views/BrowseByFolder/buildView.js.map +1 -1
  35. package/dist/views/Dashboard/Default/ModularDashboard/index.d.ts.map +1 -1
  36. package/dist/views/Dashboard/Default/ModularDashboard/index.js +8 -1
  37. package/dist/views/Dashboard/Default/ModularDashboard/index.js.map +1 -1
  38. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.d.ts.map +1 -1
  39. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js +6 -0
  40. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js.map +1 -1
  41. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.d.ts.map +1 -1
  42. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js +7 -1
  43. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js.map +1 -1
  44. package/dist/views/Dashboard/Default/ModularDashboard/useDashboardLayout.d.ts.map +1 -1
  45. package/dist/views/Dashboard/Default/ModularDashboard/useDashboardLayout.js +9 -2
  46. package/dist/views/Dashboard/Default/ModularDashboard/useDashboardLayout.js.map +1 -1
  47. package/dist/views/Document/handleServerFunction.d.ts.map +1 -1
  48. package/dist/views/Document/handleServerFunction.js +5 -7
  49. package/dist/views/Document/handleServerFunction.js.map +1 -1
  50. package/dist/views/Document/index.js +3 -3
  51. package/dist/views/Document/index.js.map +1 -1
  52. package/dist/views/Document/renderDocumentSlots.d.ts +3 -2
  53. package/dist/views/Document/renderDocumentSlots.d.ts.map +1 -1
  54. package/dist/views/Document/renderDocumentSlots.js +9 -2
  55. package/dist/views/Document/renderDocumentSlots.js.map +1 -1
  56. package/dist/views/List/handleServerFunction.d.ts.map +1 -1
  57. package/dist/views/List/handleServerFunction.js +7 -7
  58. package/dist/views/List/handleServerFunction.js.map +1 -1
  59. package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.d.ts.map +1 -1
  60. package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.js +3 -1
  61. package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.js.map +1 -1
  62. package/dist/withPayload/withPayload.js +1 -1
  63. package/dist/withPayload/withPayload.js.map +1 -1
  64. package/package.json +8 -8
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["DocumentInfoProvider","EditDepthProvider","HydrateAuthProvider","LivePreviewProvider","RenderServerComponent","handleLivePreview","handlePreview","isEditing","getIsEditing","buildFormState","notFound","redirect","isolateObjectProperty","logError","formatAdminURL","hasAutosaveEnabled","hasDraftsEnabled","React","DocumentHeader","getPreferences","NotFoundView","getDocPreferences","getDocumentData","getDocumentPermissions","getDocumentView","getIsLocked","getMetaBySegment","getVersions","renderDocumentSlots","generateMetadata","args","renderDocument","disableActions","documentSubViewType","drawerSlug","importMap","initialData","initPageResult","overrideEntityVisibility","params","redirectAfterCreate","redirectAfterDelete","redirectAfterDuplicate","redirectAfterRestore","searchParams","versions","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","redirectURL","path","encodeURIComponent","Error","isTrashedDoc","Boolean","deletedAt","reqForPermissions","transactionID","reqForLockCheck","docPreferences","docPermissions","hasPublishPermission","hasSavePermission","currentEditor","isLocked","lastUpdateTime","entityPreferences","Promise","all","data","collection","operation","hasPublishedDoc","mostRecentVersionIsAutosaved","unpublishedVersionCount","versionCount","state","formState","code","fallbackLocale","readOnly","renderAllFields","schemaPath","skipValidation","documentViewServerProps","routeSegments","collections","find","visibleSlug","globals","formattedParams","URLSearchParams","append","apiQueryParams","toString","apiURL","View","showHeader","RootViewOverride","components","views","edit","root","Component","shouldAutosave","validateDraftData","drafts","validate","create","depth","draft","documentSlots","Description","clientProps","isLivePreviewEnabled","livePreviewConfig","livePreviewURL","isPreviewEnabled","previewURL","Document","_jsx","initialState","isTrashed","_jsxs","breakpoints","isLivePreviewing","value","editViewType","typeofLivePreviewURL","url","AfterHeader","serverProps","DocumentView","props","RenderedDocument","error","message","err"],"sources":["../../../src/views/Document/index.tsx"],"sourcesContent":["import type {\n AdminViewServerProps,\n CollectionPreferences,\n Data,\n DocumentViewClientProps,\n DocumentViewServerProps,\n DocumentViewServerPropsOnly,\n EditViewComponent,\n PayloadComponent,\n RenderDocumentVersionsProperties,\n} from 'payload'\n\nimport {\n DocumentInfoProvider,\n EditDepthProvider,\n HydrateAuthProvider,\n LivePreviewProvider,\n} from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { handleLivePreview, handlePreview } from '@payloadcms/ui/rsc'\nimport { isEditing as getIsEditing } from '@payloadcms/ui/shared'\nimport { buildFormState } from '@payloadcms/ui/utilities/buildFormState'\nimport { notFound, redirect } from 'next/navigation.js'\nimport { isolateObjectProperty, logError } from 'payload'\nimport { formatAdminURL, hasAutosaveEnabled, hasDraftsEnabled } from 'payload/shared'\nimport React from 'react'\n\nimport type { GenerateEditViewMetadata } from './getMetaBySegment.js'\n\nimport { DocumentHeader } from '../../elements/DocumentHeader/index.js'\nimport { getPreferences } from '../../utilities/getPreferences.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 redirectAfterRestore,\n searchParams,\n versions,\n viewType,\n}: {\n drawerSlug?: string\n overrideEntityVisibility?: boolean\n readonly redirectAfterCreate?: boolean\n readonly redirectAfterDelete?: boolean\n readonly redirectAfterDuplicate?: boolean\n readonly redirectAfterRestore?: boolean\n versions?: RenderDocumentVersionsProperties\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 !idFromArgs && !globalSlug\n ? initialData || null\n : await getDocumentData({\n id: idFromArgs,\n collectionSlug,\n globalSlug,\n locale,\n payload,\n req,\n segments,\n user,\n })\n\n if (isEditing && !doc) {\n // If it's a collection document that doesn't exist, redirect to collection list\n if (collectionSlug) {\n const redirectURL = formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}?notFound=${encodeURIComponent(idFromArgs)}`,\n })\n redirect(redirectURL)\n } else {\n // For globals or other cases, keep the 404 behavior\n throw new Error('not-found')\n }\n }\n\n const isTrashedDoc = Boolean(doc && 'deletedAt' in doc && typeof doc?.deletedAt === 'string')\n\n // CRITICAL FIX FOR TRANSACTION RACE CONDITION:\n // When running parallel operations with Promise.all, if they share the same req object\n // and one operation calls initTransaction() which MUTATES req.transactionID, that mutation\n // is visible to all parallel operations. This causes:\n // 1. Operation A (e.g., getDocumentPermissions → docAccessOperation) calls initTransaction()\n // which sets req.transactionID = Promise, then resolves it to a UUID\n // 2. Operation B (e.g., getIsLocked) running in parallel receives the SAME req with the mutated transactionID\n // 3. Operation A (does not even know that Operation B even exists and is stil using the transactionID) commits/ends its transaction\n // 4. Operation B tries to use the now-expired session → MongoExpiredSessionError!\n //\n // Solution: Use isolateObjectProperty to create a Proxy that isolates the 'transactionID' property.\n // This allows each operation to have its own transactionID without affecting the parent req.\n // If parent req already has a transaction, preserve it (don't isolate), since this\n // issue only arises when one of the operations calls initTransaction() themselves -\n // because then, that operation will also try to commit/end the transaction itself.\n\n // If the transactionID is already set, the parallel operations will not try to\n // commit/end the transaction themselves, so we don't need to isolate the\n // transactionID property.\n const reqForPermissions = req.transactionID ? req : isolateObjectProperty(req, 'transactionID')\n const reqForLockCheck = req.transactionID ? req : isolateObjectProperty(req, 'transactionID')\n\n const [\n docPreferences,\n { docPermissions, hasPublishPermission, hasSavePermission },\n { currentEditor, isLocked, lastUpdateTime },\n entityPreferences,\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 - isolated transactionID prevents cross-contamination\n getDocumentPermissions({\n id: idFromArgs,\n collectionConfig,\n data: doc,\n globalConfig,\n req: reqForPermissions,\n }),\n\n // Fetch document lock state - isolated transactionID prevents cross-contamination\n getIsLocked({\n id: idFromArgs,\n collectionConfig,\n globalConfig,\n isEditing,\n req: reqForLockCheck,\n }),\n\n // get entity preferences\n getPreferences<CollectionPreferences>(\n collectionSlug ? `collection-${collectionSlug}` : `global-${globalSlug}`,\n payload,\n req.user.id,\n req.user.collection,\n ),\n ])\n\n const operation = (collectionSlug && idFromArgs) || globalSlug ? 'update' : 'create'\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,\n readOnly: isTrashedDoc || isLocked,\n renderAllFields: true,\n req,\n schemaPath: collectionSlug || globalSlug,\n skipValidation: true,\n }),\n ])\n\n const documentViewServerProps: DocumentViewServerPropsOnly = {\n doc,\n hasPublishedDoc,\n i18n,\n initPageResult,\n locale,\n params,\n payload,\n permissions,\n routeSegments: segments,\n searchParams,\n user,\n versions,\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 (hasDraftsEnabled(collectionConfig || globalConfig)) {\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 = formatAdminURL({\n apiRoute,\n path: collectionSlug\n ? `/${collectionSlug}/${idFromArgs}${apiQueryParams}`\n : globalSlug\n ? `/${globalSlug}${apiQueryParams}`\n : '',\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 = hasSavePermission && hasAutosaveEnabled(collectionConfig || globalConfig)\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 })\n\n redirect(redirectURL)\n }\n } else {\n throw new Error('not-found')\n }\n }\n\n const documentSlots = renderDocumentSlots({\n id,\n collectionConfig,\n globalConfig,\n hasSavePermission,\n permissions: docPermissions,\n req,\n })\n\n // Extract Description from documentSlots to pass to DocumentHeader\n const { Description } = documentSlots\n\n const clientProps: DocumentViewClientProps = {\n formState,\n ...documentSlots,\n documentSubViewType,\n viewType,\n }\n\n const { isLivePreviewEnabled, livePreviewConfig, livePreviewURL } = await handleLivePreview({\n collectionSlug,\n config,\n data: doc,\n globalSlug,\n operation,\n req,\n })\n\n const { isPreviewEnabled, previewURL } = await handlePreview({\n collectionSlug,\n config,\n data: doc,\n globalSlug,\n operation,\n req,\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 isTrashed={isTrashedDoc}\n key={locale?.code}\n lastUpdateTime={lastUpdateTime}\n mostRecentVersionIsAutosaved={mostRecentVersionIsAutosaved}\n redirectAfterCreate={redirectAfterCreate}\n redirectAfterDelete={redirectAfterDelete}\n redirectAfterDuplicate={redirectAfterDuplicate}\n redirectAfterRestore={redirectAfterRestore}\n unpublishedVersionCount={unpublishedVersionCount}\n versionCount={versionCount}\n >\n <LivePreviewProvider\n breakpoints={livePreviewConfig?.breakpoints}\n isLivePreviewEnabled={isLivePreviewEnabled && operation !== 'create'}\n isLivePreviewing={Boolean(\n entityPreferences?.value?.editViewType === 'live-preview' && livePreviewURL,\n )}\n isPreviewEnabled={Boolean(isPreviewEnabled)}\n previewURL={previewURL}\n typeofLivePreviewURL={typeof livePreviewConfig?.url as 'function' | 'string' | undefined}\n url={livePreviewURL}\n >\n {showHeader && !drawerSlug && (\n <DocumentHeader\n AfterHeader={Description}\n collectionConfig={collectionConfig}\n globalConfig={globalConfig}\n permissions={permissions}\n req={req}\n />\n )}\n <HydrateAuthProvider permissions={permissions} />\n <EditDepthProvider>\n {RenderServerComponent({\n clientProps,\n Component: View,\n importMap,\n serverProps: documentViewServerProps,\n })}\n </EditDepthProvider>\n </LivePreviewProvider>\n </DocumentInfoProvider>\n ),\n }\n}\n\nexport async function DocumentView(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":";AAYA,SACEA,oBAAoB,EACpBC,iBAAiB,EACjBC,mBAAmB,EACnBC,mBAAmB,QACd;AACP,SAASC,qBAAqB,QAAQ;AACtC,SAASC,iBAAiB,EAAEC,aAAa,QAAQ;AACjD,SAASC,SAAA,IAAaC,YAAY,QAAQ;AAC1C,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,EAAEC,QAAQ,QAAQ;AACnC,SAASC,qBAAqB,EAAEC,QAAQ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AalB,WAAA;UACb1F,gBAAA,EAAkBA,gBAAA;UAClBG,YAAA,EAAcA,YAAA;UACdE,WAAA,EAAaA,WAAA;UACbC,GAAA,EAAKA;yBAGT4F,IAAA,CAAC/I,mBAAA;UAAoBkD,WAAA,EAAaA;yBAClC6F,IAAA,CAAChJ,iBAAA;oBACEG,qBAAA,CAAsB;YACrBsI,WAAA;YACAV,SAAA,EAAWP,IAAA;YACXtF,SAAA;YACAyH,WAAA,EAAa/C;UACf;;;OArCC1D,MAAA,EAAQoD,IAAA;EA0CnB;AACF;AAEA,OAAO,eAAesD,aAAaC,KAA2B;EAC5D,IAAI;IACF,MAAM;MAAEd,QAAA,EAAUe;IAAgB,CAAE,GAAG,MAAMhI,cAAA,CAAe+H,KAAA;IAC5D,OAAOC,gBAAA;EACT,EAAE,OAAOC,KAAA,EAAO;IACd,IAAIA,KAAA,EAAOC,OAAA,KAAY,iBAAiB;MACtC,MAAMD,KAAA;IACR;IAEAnJ,QAAA,CAAS;MAAEqJ,GAAA,EAAKF,KAAA;MAAOzG,OAAA,EAASuG,KAAA,CAAMzH,cAAc,CAACgB,GAAG,CAACE;IAAQ;IAEjE,IAAIyG,KAAA,CAAMC,OAAO,KAAK,aAAa;MACjCvJ,QAAA;IACF;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["DocumentInfoProvider","EditDepthProvider","HydrateAuthProvider","LivePreviewProvider","RenderServerComponent","handleLivePreview","handlePreview","isEditing","getIsEditing","buildFormState","notFound","redirect","isolateObjectProperty","logError","formatAdminURL","hasAutosaveEnabled","hasDraftsEnabled","React","DocumentHeader","getPreferences","NotFoundView","getDocPreferences","getDocumentData","getDocumentPermissions","getDocumentView","getIsLocked","getMetaBySegment","getVersions","renderDocumentSlots","generateMetadata","args","renderDocument","disableActions","documentSubViewType","drawerSlug","importMap","initialData","initPageResult","overrideEntityVisibility","params","redirectAfterCreate","redirectAfterDelete","redirectAfterDuplicate","redirectAfterRestore","searchParams","versions","viewType","collectionConfig","docID","idFromArgs","globalConfig","locale","permissions","req","i18n","payload","config","routes","admin","adminRoute","api","apiRoute","user","visibleEntities","segments","Array","isArray","collectionSlug","slug","undefined","globalSlug","id","doc","redirectURL","path","encodeURIComponent","Error","isTrashedDoc","Boolean","deletedAt","reqForPermissions","transactionID","reqForLockCheck","docPreferences","docPermissions","hasPublishPermission","hasSavePermission","currentEditor","isLocked","lastUpdateTime","entityPreferences","Promise","all","data","collection","operation","hasPublishedDoc","mostRecentVersionIsAutosaved","unpublishedVersionCount","versionCount","state","formState","code","fallbackLocale","readOnly","renderAllFields","schemaPath","skipValidation","documentViewServerProps","routeSegments","collections","find","visibleSlug","globals","formattedParams","URLSearchParams","append","apiQueryParams","toString","apiURL","View","showHeader","RootViewOverride","components","views","edit","root","Component","shouldAutosave","validateDraftData","drafts","validate","create","depth","draft","documentSlots","Description","clientProps","isLivePreviewEnabled","livePreviewConfig","livePreviewURL","isPreviewEnabled","previewURL","Document","_jsx","initialState","isTrashed","_jsxs","breakpoints","isLivePreviewing","value","editViewType","typeofLivePreviewURL","url","AfterHeader","serverProps","DocumentView","props","RenderedDocument","error","message","err"],"sources":["../../../src/views/Document/index.tsx"],"sourcesContent":["import type {\n AdminViewServerProps,\n CollectionPreferences,\n Data,\n DocumentViewClientProps,\n DocumentViewServerProps,\n DocumentViewServerPropsOnly,\n EditViewComponent,\n PayloadComponent,\n RenderDocumentVersionsProperties,\n} from 'payload'\n\nimport {\n DocumentInfoProvider,\n EditDepthProvider,\n HydrateAuthProvider,\n LivePreviewProvider,\n} from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { handleLivePreview, handlePreview } from '@payloadcms/ui/rsc'\nimport { isEditing as getIsEditing } from '@payloadcms/ui/shared'\nimport { buildFormState } from '@payloadcms/ui/utilities/buildFormState'\nimport { notFound, redirect } from 'next/navigation.js'\nimport { isolateObjectProperty, logError } from 'payload'\nimport { formatAdminURL, hasAutosaveEnabled, hasDraftsEnabled } from 'payload/shared'\nimport React from 'react'\n\nimport type { GenerateEditViewMetadata } from './getMetaBySegment.js'\n\nimport { DocumentHeader } from '../../elements/DocumentHeader/index.js'\nimport { getPreferences } from '../../utilities/getPreferences.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 redirectAfterRestore,\n searchParams,\n versions,\n viewType,\n}: {\n drawerSlug?: string\n overrideEntityVisibility?: boolean\n readonly redirectAfterCreate?: boolean\n readonly redirectAfterDelete?: boolean\n readonly redirectAfterDuplicate?: boolean\n readonly redirectAfterRestore?: boolean\n versions?: RenderDocumentVersionsProperties\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 },\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 !idFromArgs && !globalSlug\n ? initialData || null\n : await getDocumentData({\n id: idFromArgs,\n collectionSlug,\n globalSlug,\n locale,\n payload,\n req,\n segments,\n user,\n })\n\n if (isEditing && !doc) {\n // If it's a collection document that doesn't exist, redirect to collection list\n if (collectionSlug) {\n const redirectURL = formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}?notFound=${encodeURIComponent(idFromArgs)}`,\n })\n redirect(redirectURL)\n } else {\n // For globals or other cases, keep the 404 behavior\n throw new Error('not-found')\n }\n }\n\n const isTrashedDoc = Boolean(doc && 'deletedAt' in doc && typeof doc?.deletedAt === 'string')\n\n // CRITICAL FIX FOR TRANSACTION RACE CONDITION:\n // When running parallel operations with Promise.all, if they share the same req object\n // and one operation calls initTransaction() which MUTATES req.transactionID, that mutation\n // is visible to all parallel operations. This causes:\n // 1. Operation A (e.g., getDocumentPermissions → docAccessOperation) calls initTransaction()\n // which sets req.transactionID = Promise, then resolves it to a UUID\n // 2. Operation B (e.g., getIsLocked) running in parallel receives the SAME req with the mutated transactionID\n // 3. Operation A (does not even know that Operation B even exists and is stil using the transactionID) commits/ends its transaction\n // 4. Operation B tries to use the now-expired session → MongoExpiredSessionError!\n //\n // Solution: Use isolateObjectProperty to create a Proxy that isolates the 'transactionID' property.\n // This allows each operation to have its own transactionID without affecting the parent req.\n // If parent req already has a transaction, preserve it (don't isolate), since this\n // issue only arises when one of the operations calls initTransaction() themselves -\n // because then, that operation will also try to commit/end the transaction itself.\n\n // If the transactionID is already set, the parallel operations will not try to\n // commit/end the transaction themselves, so we don't need to isolate the\n // transactionID property.\n const reqForPermissions = req.transactionID ? req : isolateObjectProperty(req, 'transactionID')\n const reqForLockCheck = req.transactionID ? req : isolateObjectProperty(req, 'transactionID')\n\n const [\n docPreferences,\n { docPermissions, hasPublishPermission, hasSavePermission },\n { currentEditor, isLocked, lastUpdateTime },\n entityPreferences,\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 - isolated transactionID prevents cross-contamination\n getDocumentPermissions({\n id: idFromArgs,\n collectionConfig,\n data: doc,\n globalConfig,\n req: reqForPermissions,\n }),\n\n // Fetch document lock state - isolated transactionID prevents cross-contamination\n getIsLocked({\n id: idFromArgs,\n collectionConfig,\n globalConfig,\n isEditing,\n req: reqForLockCheck,\n }),\n\n // get entity preferences\n getPreferences<CollectionPreferences>(\n collectionSlug ? `collection-${collectionSlug}` : `global-${globalSlug}`,\n payload,\n req.user.id,\n req.user.collection,\n ),\n ])\n\n const operation = (collectionSlug && idFromArgs) || globalSlug ? 'update' : 'create'\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,\n readOnly: isTrashedDoc || isLocked,\n renderAllFields: true,\n req,\n schemaPath: collectionSlug || globalSlug,\n skipValidation: true,\n }),\n ])\n\n const documentViewServerProps: DocumentViewServerPropsOnly = {\n doc,\n hasPublishedDoc,\n i18n,\n initPageResult,\n locale,\n params,\n payload,\n permissions,\n routeSegments: segments,\n searchParams,\n user,\n versions,\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 (hasDraftsEnabled(collectionConfig || globalConfig)) {\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 = formatAdminURL({\n apiRoute,\n path: collectionSlug\n ? `/${collectionSlug}/${idFromArgs}${apiQueryParams}`\n : globalSlug\n ? `/${globalSlug}${apiQueryParams}`\n : '',\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 = hasSavePermission && hasAutosaveEnabled(collectionConfig || globalConfig)\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 })\n\n redirect(redirectURL)\n }\n } else {\n throw new Error('not-found')\n }\n }\n\n const documentSlots = renderDocumentSlots({\n id,\n collectionConfig,\n globalConfig,\n hasSavePermission,\n locale,\n permissions,\n req,\n })\n\n // Extract Description from documentSlots to pass to DocumentHeader\n const { Description } = documentSlots\n\n const clientProps: DocumentViewClientProps = {\n formState,\n ...documentSlots,\n documentSubViewType,\n viewType,\n }\n\n const { isLivePreviewEnabled, livePreviewConfig, livePreviewURL } = await handleLivePreview({\n collectionSlug,\n config,\n data: doc,\n globalSlug,\n operation,\n req,\n })\n\n const { isPreviewEnabled, previewURL } = await handlePreview({\n collectionSlug,\n config,\n data: doc,\n globalSlug,\n operation,\n req,\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 isTrashed={isTrashedDoc}\n key={locale?.code}\n lastUpdateTime={lastUpdateTime}\n mostRecentVersionIsAutosaved={mostRecentVersionIsAutosaved}\n redirectAfterCreate={redirectAfterCreate}\n redirectAfterDelete={redirectAfterDelete}\n redirectAfterDuplicate={redirectAfterDuplicate}\n redirectAfterRestore={redirectAfterRestore}\n unpublishedVersionCount={unpublishedVersionCount}\n versionCount={versionCount}\n >\n <LivePreviewProvider\n breakpoints={livePreviewConfig?.breakpoints}\n isLivePreviewEnabled={isLivePreviewEnabled && operation !== 'create'}\n isLivePreviewing={Boolean(\n entityPreferences?.value?.editViewType === 'live-preview' && livePreviewURL,\n )}\n isPreviewEnabled={Boolean(isPreviewEnabled)}\n previewURL={previewURL}\n typeofLivePreviewURL={typeof livePreviewConfig?.url as 'function' | 'string' | undefined}\n url={livePreviewURL}\n >\n {showHeader && !drawerSlug && (\n <DocumentHeader\n AfterHeader={Description}\n collectionConfig={collectionConfig}\n globalConfig={globalConfig}\n permissions={permissions}\n req={req}\n />\n )}\n <HydrateAuthProvider permissions={permissions} />\n <EditDepthProvider>\n {RenderServerComponent({\n clientProps,\n Component: View,\n importMap,\n serverProps: documentViewServerProps,\n })}\n </EditDepthProvider>\n </LivePreviewProvider>\n </DocumentInfoProvider>\n ),\n }\n}\n\nexport async function DocumentView(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":";AAYA,SACEA,oBAAoB,EACpBC,iBAAiB,EACjBC,mBAAmB,EACnBC,mBAAmB,QACd;AACP,SAASC,qBAAqB,QAAQ;AACtC,SAASC,iBAAiB,EAAEC,aAAa,QAAQ;AACjD,SAASC,SAAA,IAAaC,YAAY,QAAQ;AAC1C,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,EAAEC,QAAQ,QAAQ;AACnC,SAASC,qBAAqB,EAAEC,QAAQ,QAAQ;AAChD,SAASC,cAAc,EAAEC,kBAAkB,EAAEC,gBAAgB,QAAQ;AACrE,OAAOC,KAAA,MAAW;AAIlB,SAASC,cAAc,QAAQ;AAC/B,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,SAA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;MAAEoJ,GAAA,EAAKF,KAAA;MAAOxG,OAAA,EAASsG,KAAA,CAAMxH,cAAc,CAACgB,GAAG,CAACE;IAAQ;IAEjE,IAAIwG,KAAA,CAAMC,OAAO,KAAK,aAAa;MACjCtJ,QAAA;IACF;EACF;AACF","ignoreList":[]}
@@ -1,10 +1,11 @@
1
- import type { DocumentSlots, PayloadRequest, SanitizedCollectionConfig, SanitizedDocumentPermissions, SanitizedGlobalConfig, ServerFunction } from 'payload';
1
+ import type { DocumentSlots, Locale, PayloadRequest, SanitizedCollectionConfig, SanitizedGlobalConfig, SanitizedPermissions, ServerFunction } from 'payload';
2
2
  export declare const renderDocumentSlots: (args: {
3
3
  collectionConfig?: SanitizedCollectionConfig;
4
4
  globalConfig?: SanitizedGlobalConfig;
5
5
  hasSavePermission: boolean;
6
6
  id?: number | string;
7
- permissions: SanitizedDocumentPermissions;
7
+ locale: Locale;
8
+ permissions: SanitizedPermissions;
8
9
  req: PayloadRequest;
9
10
  }) => DocumentSlots;
10
11
  export declare const renderDocumentSlotsHandler: ServerFunction<{
@@ -1 +1 @@
1
- {"version":3,"file":"renderDocumentSlots.d.ts","sourceRoot":"","sources":["../../../src/views/Document/renderDocumentSlots.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,aAAa,EAEb,cAAc,EAGd,yBAAyB,EACzB,4BAA4B,EAC5B,qBAAqB,EAGrB,cAAc,EAMf,MAAM,SAAS,CAAA;AAQhB,eAAO,MAAM,mBAAmB,EAAE,CAAC,IAAI,EAAE;IACvC,gBAAgB,CAAC,EAAE,yBAAyB,CAAA;IAC5C,YAAY,CAAC,EAAE,qBAAqB,CAAA;IACpC,iBAAiB,EAAE,OAAO,CAAA;IAC1B,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,WAAW,EAAE,4BAA4B,CAAA;IACzC,GAAG,EAAE,cAAc,CAAA;CACpB,KAAK,aA+KL,CAAA;AAED,eAAO,MAAM,0BAA0B,EAAE,cAAc,CAAC;IACtD,cAAc,EAAE,MAAM,CAAA;IACtB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACrB,CAsBA,CAAA"}
1
+ {"version":3,"file":"renderDocumentSlots.d.ts","sourceRoot":"","sources":["../../../src/views/Document/renderDocumentSlots.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,aAAa,EAEb,MAAM,EACN,cAAc,EAGd,yBAAyB,EACzB,qBAAqB,EACrB,oBAAoB,EAGpB,cAAc,EAMf,MAAM,SAAS,CAAA;AAQhB,eAAO,MAAM,mBAAmB,EAAE,CAAC,IAAI,EAAE;IACvC,gBAAgB,CAAC,EAAE,yBAAyB,CAAA;IAC5C,YAAY,CAAC,EAAE,qBAAqB,CAAA;IACpC,iBAAiB,EAAE,OAAO,CAAA;IAC1B,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,oBAAoB,CAAA;IACjC,GAAG,EAAE,cAAc,CAAA;CACpB,KAAK,aAiLL,CAAA;AAED,eAAO,MAAM,0BAA0B,EAAE,cAAc,CAAC;IACtD,cAAc,EAAE,MAAM,CAAA;IACtB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACrB,CAwBA,CAAA"}
@@ -8,6 +8,8 @@ export const renderDocumentSlots = args => {
8
8
  collectionConfig,
9
9
  globalConfig,
10
10
  hasSavePermission,
11
+ locale,
12
+ permissions,
11
13
  req
12
14
  } = args;
13
15
  const components = {};
@@ -16,7 +18,9 @@ export const renderDocumentSlots = args => {
16
18
  const serverProps = {
17
19
  id,
18
20
  i18n: req.i18n,
21
+ locale,
19
22
  payload: req.payload,
23
+ permissions,
20
24
  user: req.user
21
25
  };
22
26
  const BeforeDocumentControls = collectionConfig?.admin?.components?.edit?.beforeDocumentControls || globalConfig?.admin?.components?.elements?.beforeDocumentControls;
@@ -137,6 +141,8 @@ export const renderDocumentSlotsHandler = async args => {
137
141
  const {
138
142
  id,
139
143
  collectionSlug,
144
+ locale,
145
+ permissions,
140
146
  req
141
147
  } = args;
142
148
  const collectionConfig = req.payload.collections[collectionSlug]?.config;
@@ -144,9 +150,9 @@ export const renderDocumentSlotsHandler = async args => {
144
150
  throw new Error(req.t('error:incorrectCollection'));
145
151
  }
146
152
  const {
147
- docPermissions,
148
153
  hasSavePermission
149
154
  } = await getDocumentPermissions({
155
+ id,
150
156
  collectionConfig,
151
157
  data: {},
152
158
  req
@@ -155,7 +161,8 @@ export const renderDocumentSlotsHandler = async args => {
155
161
  id,
156
162
  collectionConfig,
157
163
  hasSavePermission,
158
- permissions: docPermissions,
164
+ locale,
165
+ permissions,
159
166
  req
160
167
  });
161
168
  };
@@ -1 +1 @@
1
- {"version":3,"file":"renderDocumentSlots.js","names":["ViewDescription","RenderServerComponent","hasDraftsEnabled","getDocumentPermissions","renderDocumentSlots","args","id","collectionConfig","globalConfig","hasSavePermission","req","components","unsavedDraftWithValidations","undefined","isPreviewEnabled","admin","preview","serverProps","i18n","payload","user","BeforeDocumentControls","edit","beforeDocumentControls","elements","Component","importMap","EditMenuItems","editMenuItems","CustomPreviewButton","PreviewButton","LivePreview","views","livePreview","descriptionFromConfig","description","staticDescription","t","CustomDescription","Description","hasDescription","clientProps","collectionSlug","slug","Fallback","versions","drafts","CustomStatus","Status","CustomPublishButton","PublishButton","CustomUnpublishButton","UnpublishButton","CustomSaveDraftButton","SaveDraftButton","draftsEnabled","CustomSaveButton","SaveButton","upload","Upload","controls","UploadControls","renderDocumentSlotsHandler","collections","config","Error","docPermissions","data","permissions"],"sources":["../../../src/views/Document/renderDocumentSlots.tsx"],"sourcesContent":["import type {\n BeforeDocumentControlsServerPropsOnly,\n DocumentSlots,\n EditMenuItemsServerPropsOnly,\n PayloadRequest,\n PreviewButtonServerPropsOnly,\n PublishButtonServerPropsOnly,\n SanitizedCollectionConfig,\n SanitizedDocumentPermissions,\n SanitizedGlobalConfig,\n SaveButtonServerPropsOnly,\n SaveDraftButtonServerPropsOnly,\n ServerFunction,\n ServerProps,\n StaticDescription,\n UnpublishButtonServerPropsOnly,\n ViewDescriptionClientProps,\n ViewDescriptionServerPropsOnly,\n} from 'payload'\n\nimport { ViewDescription } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { hasDraftsEnabled } from 'payload/shared'\n\nimport { getDocumentPermissions } from './getDocumentPermissions.js'\n\nexport const renderDocumentSlots: (args: {\n collectionConfig?: SanitizedCollectionConfig\n globalConfig?: SanitizedGlobalConfig\n hasSavePermission: boolean\n id?: number | string\n permissions: SanitizedDocumentPermissions\n req: PayloadRequest\n}) => DocumentSlots = (args) => {\n const { id, collectionConfig, globalConfig, hasSavePermission, req } = args\n\n const components: DocumentSlots = {} as DocumentSlots\n\n const unsavedDraftWithValidations = undefined\n\n const isPreviewEnabled = collectionConfig?.admin?.preview || globalConfig?.admin?.preview\n\n const serverProps: ServerProps = {\n id,\n i18n: req.i18n,\n payload: req.payload,\n user: req.user,\n // TODO: Add remaining serverProps\n }\n\n const BeforeDocumentControls =\n collectionConfig?.admin?.components?.edit?.beforeDocumentControls ||\n globalConfig?.admin?.components?.elements?.beforeDocumentControls\n\n if (BeforeDocumentControls) {\n components.BeforeDocumentControls = RenderServerComponent({\n Component: BeforeDocumentControls,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies BeforeDocumentControlsServerPropsOnly,\n })\n }\n\n const EditMenuItems = collectionConfig?.admin?.components?.edit?.editMenuItems\n\n if (EditMenuItems) {\n components.EditMenuItems = RenderServerComponent({\n Component: EditMenuItems,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies EditMenuItemsServerPropsOnly,\n })\n }\n\n const CustomPreviewButton =\n collectionConfig?.admin?.components?.edit?.PreviewButton ||\n globalConfig?.admin?.components?.elements?.PreviewButton\n\n if (isPreviewEnabled && CustomPreviewButton) {\n components.PreviewButton = RenderServerComponent({\n Component: CustomPreviewButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies PreviewButtonServerPropsOnly,\n })\n }\n\n const LivePreview =\n collectionConfig?.admin?.components?.views?.edit?.livePreview ||\n globalConfig?.admin?.components?.views?.edit?.livePreview\n\n if (LivePreview?.Component) {\n components.LivePreview = RenderServerComponent({\n Component: LivePreview.Component,\n importMap: req.payload.importMap,\n serverProps,\n })\n }\n\n const descriptionFromConfig =\n collectionConfig?.admin?.description || globalConfig?.admin?.description\n\n const staticDescription: StaticDescription =\n typeof descriptionFromConfig === 'function'\n ? descriptionFromConfig({ t: req.i18n.t })\n : descriptionFromConfig\n\n const CustomDescription =\n collectionConfig?.admin?.components?.Description ||\n globalConfig?.admin?.components?.elements?.Description\n\n const hasDescription = CustomDescription || staticDescription\n\n if (hasDescription) {\n components.Description = RenderServerComponent({\n clientProps: {\n collectionSlug: collectionConfig?.slug,\n description: staticDescription,\n } satisfies ViewDescriptionClientProps,\n Component: CustomDescription,\n Fallback: ViewDescription,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies ViewDescriptionServerPropsOnly,\n })\n }\n\n if (collectionConfig?.versions?.drafts || globalConfig?.versions?.drafts) {\n const CustomStatus =\n collectionConfig?.admin?.components?.edit?.Status ||\n globalConfig?.admin?.components?.elements?.Status\n\n if (CustomStatus) {\n components.Status = RenderServerComponent({\n Component: CustomStatus,\n importMap: req.payload.importMap,\n serverProps,\n })\n }\n }\n\n if (hasSavePermission) {\n if (hasDraftsEnabled(collectionConfig || globalConfig)) {\n const CustomPublishButton =\n collectionConfig?.admin?.components?.edit?.PublishButton ||\n globalConfig?.admin?.components?.elements?.PublishButton\n\n if (CustomPublishButton) {\n components.PublishButton = RenderServerComponent({\n Component: CustomPublishButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies PublishButtonServerPropsOnly,\n })\n }\n\n const CustomUnpublishButton =\n collectionConfig?.admin?.components?.edit?.UnpublishButton ||\n globalConfig?.admin?.components?.elements?.UnpublishButton\n\n if (CustomUnpublishButton) {\n components.UnpublishButton = RenderServerComponent({\n Component: CustomUnpublishButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies UnpublishButtonServerPropsOnly,\n })\n }\n\n const CustomSaveDraftButton =\n collectionConfig?.admin?.components?.edit?.SaveDraftButton ||\n globalConfig?.admin?.components?.elements?.SaveDraftButton\n\n const draftsEnabled = hasDraftsEnabled(collectionConfig || globalConfig)\n\n if ((draftsEnabled || unsavedDraftWithValidations) && CustomSaveDraftButton) {\n components.SaveDraftButton = RenderServerComponent({\n Component: CustomSaveDraftButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies SaveDraftButtonServerPropsOnly,\n })\n }\n } else {\n const CustomSaveButton =\n collectionConfig?.admin?.components?.edit?.SaveButton ||\n globalConfig?.admin?.components?.elements?.SaveButton\n\n if (CustomSaveButton) {\n components.SaveButton = RenderServerComponent({\n Component: CustomSaveButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies SaveButtonServerPropsOnly,\n })\n }\n }\n }\n\n if (collectionConfig?.upload && collectionConfig?.admin?.components?.edit?.Upload) {\n components.Upload = RenderServerComponent({\n Component: collectionConfig.admin.components.edit.Upload,\n importMap: req.payload.importMap,\n serverProps,\n })\n }\n\n if (collectionConfig?.upload && collectionConfig.upload.admin?.components?.controls) {\n components.UploadControls = RenderServerComponent({\n Component: collectionConfig.upload.admin.components.controls,\n importMap: req.payload.importMap,\n serverProps,\n })\n }\n\n return components\n}\n\nexport const renderDocumentSlotsHandler: ServerFunction<{\n collectionSlug: string\n id?: number | string\n}> = async (args) => {\n const { id, collectionSlug, req } = args\n\n const collectionConfig = req.payload.collections[collectionSlug]?.config\n\n if (!collectionConfig) {\n throw new Error(req.t('error:incorrectCollection'))\n }\n\n const { docPermissions, hasSavePermission } = await getDocumentPermissions({\n collectionConfig,\n data: {},\n req,\n })\n\n return renderDocumentSlots({\n id,\n collectionConfig,\n hasSavePermission,\n permissions: docPermissions,\n req,\n })\n}\n"],"mappings":"AAoBA,SAASA,eAAe,QAAQ;AAChC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hD,UAAA,CAAWgD,MAAM,GAAG1D,qBAAA,CAAsB;MACxCwB,SAAA,EAAWlB,gBAAA,CAAiBQ,KAAK,CAACJ,UAAU,CAACW,IAAI,CAACqC,MAAM;MACxDjC,SAAA,EAAWhB,GAAA,CAAIS,OAAO,CAACO,SAAS;MAChCT;IACF;EACF;EAEA,IAAIV,gBAAA,EAAkBmD,MAAA,IAAUnD,gBAAA,CAAiBmD,MAAM,CAAC3C,KAAK,EAAEJ,UAAA,EAAYiD,QAAA,EAAU;IACnFjD,UAAA,CAAWkD,cAAc,GAAG5D,qBAAA,CAAsB;MAChDwB,SAAA,EAAWlB,gBAAA,CAAiBmD,MAAM,CAAC3C,KAAK,CAACJ,UAAU,CAACiD,QAAQ;MAC5DlC,SAAA,EAAWhB,GAAA,CAAIS,OAAO,CAACO,SAAS;MAChCT;IACF;EACF;EAEA,OAAON,UAAA;AACT;AAEA,OAAO,MAAMmD,0BAAA,GAGR,MAAOzD,IAAA;EACV,MAAM;IAAEC,EAAE;IAAEoC,cAAc;IAAEhC;EAAG,CAAE,GAAGL,IAAA;EAEpC,MAAME,gBAAA,GAAmBG,GAAA,CAAIS,OAAO,CAAC4C,WAAW,CAACrB,cAAA,CAAe,EAAEsB,MAAA;EAElE,IAAI,CAACzD,gBAAA,EAAkB;IACrB,MAAM,IAAI0D,KAAA,CAAMvD,GAAA,CAAI2B,CAAC,CAAC;EACxB;EAEA,MAAM;IAAE6B,cAAc;IAAEzD;EAAiB,CAAE,GAAG,MAAMN,sBAAA,CAAuB;IACzEI,gBAAA;IACA4D,IAAA,EAAM,CAAC;IACPzD;EACF;EAEA,OAAON,mBAAA,CAAoB;IACzBE,EAAA;IACAC,gBAAA;IACAE,iBAAA;IACA2D,WAAA,EAAaF,cAAA;IACbxD;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"renderDocumentSlots.js","names":["ViewDescription","RenderServerComponent","hasDraftsEnabled","getDocumentPermissions","renderDocumentSlots","args","id","collectionConfig","globalConfig","hasSavePermission","locale","permissions","req","components","unsavedDraftWithValidations","undefined","isPreviewEnabled","admin","preview","serverProps","i18n","payload","user","BeforeDocumentControls","edit","beforeDocumentControls","elements","Component","importMap","EditMenuItems","editMenuItems","CustomPreviewButton","PreviewButton","LivePreview","views","livePreview","descriptionFromConfig","description","staticDescription","t","CustomDescription","Description","hasDescription","clientProps","collectionSlug","slug","Fallback","versions","drafts","CustomStatus","Status","CustomPublishButton","PublishButton","CustomUnpublishButton","UnpublishButton","CustomSaveDraftButton","SaveDraftButton","draftsEnabled","CustomSaveButton","SaveButton","upload","Upload","controls","UploadControls","renderDocumentSlotsHandler","collections","config","Error","data"],"sources":["../../../src/views/Document/renderDocumentSlots.tsx"],"sourcesContent":["import type {\n BeforeDocumentControlsServerPropsOnly,\n DocumentSlots,\n EditMenuItemsServerPropsOnly,\n Locale,\n PayloadRequest,\n PreviewButtonServerPropsOnly,\n PublishButtonServerPropsOnly,\n SanitizedCollectionConfig,\n SanitizedGlobalConfig,\n SanitizedPermissions,\n SaveButtonServerPropsOnly,\n SaveDraftButtonServerPropsOnly,\n ServerFunction,\n ServerProps,\n StaticDescription,\n UnpublishButtonServerPropsOnly,\n ViewDescriptionClientProps,\n ViewDescriptionServerPropsOnly,\n} from 'payload'\n\nimport { ViewDescription } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { hasDraftsEnabled } from 'payload/shared'\n\nimport { getDocumentPermissions } from './getDocumentPermissions.js'\n\nexport const renderDocumentSlots: (args: {\n collectionConfig?: SanitizedCollectionConfig\n globalConfig?: SanitizedGlobalConfig\n hasSavePermission: boolean\n id?: number | string\n locale: Locale\n permissions: SanitizedPermissions\n req: PayloadRequest\n}) => DocumentSlots = (args) => {\n const { id, collectionConfig, globalConfig, hasSavePermission, locale, permissions, req } = args\n\n const components: DocumentSlots = {} as DocumentSlots\n\n const unsavedDraftWithValidations = undefined\n\n const isPreviewEnabled = collectionConfig?.admin?.preview || globalConfig?.admin?.preview\n\n const serverProps: ServerProps = {\n id,\n i18n: req.i18n,\n locale,\n payload: req.payload,\n permissions,\n user: req.user,\n // TODO: Add remaining serverProps\n }\n\n const BeforeDocumentControls =\n collectionConfig?.admin?.components?.edit?.beforeDocumentControls ||\n globalConfig?.admin?.components?.elements?.beforeDocumentControls\n\n if (BeforeDocumentControls) {\n components.BeforeDocumentControls = RenderServerComponent({\n Component: BeforeDocumentControls,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies BeforeDocumentControlsServerPropsOnly,\n })\n }\n\n const EditMenuItems = collectionConfig?.admin?.components?.edit?.editMenuItems\n\n if (EditMenuItems) {\n components.EditMenuItems = RenderServerComponent({\n Component: EditMenuItems,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies EditMenuItemsServerPropsOnly,\n })\n }\n\n const CustomPreviewButton =\n collectionConfig?.admin?.components?.edit?.PreviewButton ||\n globalConfig?.admin?.components?.elements?.PreviewButton\n\n if (isPreviewEnabled && CustomPreviewButton) {\n components.PreviewButton = RenderServerComponent({\n Component: CustomPreviewButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies PreviewButtonServerPropsOnly,\n })\n }\n\n const LivePreview =\n collectionConfig?.admin?.components?.views?.edit?.livePreview ||\n globalConfig?.admin?.components?.views?.edit?.livePreview\n\n if (LivePreview?.Component) {\n components.LivePreview = RenderServerComponent({\n Component: LivePreview.Component,\n importMap: req.payload.importMap,\n serverProps,\n })\n }\n\n const descriptionFromConfig =\n collectionConfig?.admin?.description || globalConfig?.admin?.description\n\n const staticDescription: StaticDescription =\n typeof descriptionFromConfig === 'function'\n ? descriptionFromConfig({ t: req.i18n.t })\n : descriptionFromConfig\n\n const CustomDescription =\n collectionConfig?.admin?.components?.Description ||\n globalConfig?.admin?.components?.elements?.Description\n\n const hasDescription = CustomDescription || staticDescription\n\n if (hasDescription) {\n components.Description = RenderServerComponent({\n clientProps: {\n collectionSlug: collectionConfig?.slug,\n description: staticDescription,\n } satisfies ViewDescriptionClientProps,\n Component: CustomDescription,\n Fallback: ViewDescription,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies ViewDescriptionServerPropsOnly,\n })\n }\n\n if (collectionConfig?.versions?.drafts || globalConfig?.versions?.drafts) {\n const CustomStatus =\n collectionConfig?.admin?.components?.edit?.Status ||\n globalConfig?.admin?.components?.elements?.Status\n\n if (CustomStatus) {\n components.Status = RenderServerComponent({\n Component: CustomStatus,\n importMap: req.payload.importMap,\n serverProps,\n })\n }\n }\n\n if (hasSavePermission) {\n if (hasDraftsEnabled(collectionConfig || globalConfig)) {\n const CustomPublishButton =\n collectionConfig?.admin?.components?.edit?.PublishButton ||\n globalConfig?.admin?.components?.elements?.PublishButton\n\n if (CustomPublishButton) {\n components.PublishButton = RenderServerComponent({\n Component: CustomPublishButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies PublishButtonServerPropsOnly,\n })\n }\n\n const CustomUnpublishButton =\n collectionConfig?.admin?.components?.edit?.UnpublishButton ||\n globalConfig?.admin?.components?.elements?.UnpublishButton\n\n if (CustomUnpublishButton) {\n components.UnpublishButton = RenderServerComponent({\n Component: CustomUnpublishButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies UnpublishButtonServerPropsOnly,\n })\n }\n\n const CustomSaveDraftButton =\n collectionConfig?.admin?.components?.edit?.SaveDraftButton ||\n globalConfig?.admin?.components?.elements?.SaveDraftButton\n\n const draftsEnabled = hasDraftsEnabled(collectionConfig || globalConfig)\n\n if ((draftsEnabled || unsavedDraftWithValidations) && CustomSaveDraftButton) {\n components.SaveDraftButton = RenderServerComponent({\n Component: CustomSaveDraftButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies SaveDraftButtonServerPropsOnly,\n })\n }\n } else {\n const CustomSaveButton =\n collectionConfig?.admin?.components?.edit?.SaveButton ||\n globalConfig?.admin?.components?.elements?.SaveButton\n\n if (CustomSaveButton) {\n components.SaveButton = RenderServerComponent({\n Component: CustomSaveButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies SaveButtonServerPropsOnly,\n })\n }\n }\n }\n\n if (collectionConfig?.upload && collectionConfig?.admin?.components?.edit?.Upload) {\n components.Upload = RenderServerComponent({\n Component: collectionConfig.admin.components.edit.Upload,\n importMap: req.payload.importMap,\n serverProps,\n })\n }\n\n if (collectionConfig?.upload && collectionConfig.upload.admin?.components?.controls) {\n components.UploadControls = RenderServerComponent({\n Component: collectionConfig.upload.admin.components.controls,\n importMap: req.payload.importMap,\n serverProps,\n })\n }\n\n return components\n}\n\nexport const renderDocumentSlotsHandler: ServerFunction<{\n collectionSlug: string\n id?: number | string\n}> = async (args) => {\n const { id, collectionSlug, locale, permissions, req } = args\n\n const collectionConfig = req.payload.collections[collectionSlug]?.config\n\n if (!collectionConfig) {\n throw new Error(req.t('error:incorrectCollection'))\n }\n\n const { hasSavePermission } = await getDocumentPermissions({\n id,\n collectionConfig,\n data: {},\n req,\n })\n\n return renderDocumentSlots({\n id,\n collectionConfig,\n hasSavePermission,\n locale,\n permissions,\n req,\n })\n}\n"],"mappings":"AAqBA,SAASA,eAAe,QAAQ;AAChC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,gBAAgB,QAAQ;AAEjC,SAASC,sBAAsB,QAAQ;AAEvC,OAAO,MAAMC,mBAAA,GAQUC,IAAA;EACrB,MAAM;IAAEC,EAAE;IAAEC,gBAAgB;IAAEC,YAAY;IAAEC,iBAAiB;IAAEC,MAAM;IAAEC,WAAW;IAAEC;EAAG,CAAE,GAAGP,IAAA;EAE5F,MAAMQ,UAAA,GAA4B,CAAC;EAEnC,MAAMC,2BAAA,GAA8BC,SAAA;EAEpC,MAAMC,gBAAA,GAAmBT,gBAAA,EAAkBU,KAAA,EAAOC,OAAA,IAAWV,YAAA,EAAcS,KAAA,EAAOC,OAAA;EAElF,MAAMC,WAAA,GAA2B;IAC/Bb,EAAA;IACAc,IAAA,EAAMR,GAAA,CAAIQ,IAAI;IACdV,MAAA;IACAW,OAAA,EAAST,GAAA,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AACO,SAAS;MAChCT;IACF;EACF;EAEA,OAAON,UAAA;AACT;AAEA,OAAO,MAAMmD,0BAAA,GAGR,MAAO3D,IAAA;EACV,MAAM;IAAEC,EAAE;IAAEsC,cAAc;IAAElC,MAAM;IAAEC,WAAW;IAAEC;EAAG,CAAE,GAAGP,IAAA;EAEzD,MAAME,gBAAA,GAAmBK,GAAA,CAAIS,OAAO,CAAC4C,WAAW,CAACrB,cAAA,CAAe,EAAEsB,MAAA;EAElE,IAAI,CAAC3D,gBAAA,EAAkB;IACrB,MAAM,IAAI4D,KAAA,CAAMvD,GAAA,CAAI2B,CAAC,CAAC;EACxB;EAEA,MAAM;IAAE9B;EAAiB,CAAE,GAAG,MAAMN,sBAAA,CAAuB;IACzDG,EAAA;IACAC,gBAAA;IACA6D,IAAA,EAAM,CAAC;IACPxD;EACF;EAEA,OAAOR,mBAAA,CAAoB;IACzBE,EAAA;IACAC,gBAAA;IACAE,iBAAA;IACAC,MAAA;IACAC,WAAA;IACAC;EACF;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"handleServerFunction.d.ts","sourceRoot":"","sources":["../../../src/views/List/handleServerFunction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAA;AAC1F,OAAO,KAAK,EAAyB,cAAc,EAAmB,MAAM,SAAS,CAAA;AAerF,eAAO,MAAM,iBAAiB,EAAE,cAAc,CAC5C,sBAAsB,EACtB,OAAO,CAAC,4BAA4B,CAAC,CAuHtC,CAAA"}
1
+ {"version":3,"file":"handleServerFunction.d.ts","sourceRoot":"","sources":["../../../src/views/List/handleServerFunction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAA;AAC1F,OAAO,KAAK,EAAyB,cAAc,EAAmB,MAAM,SAAS,CAAA;AAQrF,eAAO,MAAM,iBAAiB,EAAE,cAAc,CAC5C,sBAAsB,EACtB,OAAO,CAAC,4BAA4B,CAAC,CAqHtC,CAAA"}
@@ -1,18 +1,20 @@
1
1
  import { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig';
2
- import { headers as getHeaders } from 'next/headers.js';
3
- import { canAccessAdmin, getAccessResults, isEntityHidden, parseCookies, UnauthorizedError } from 'payload';
2
+ import { canAccessAdmin, isEntityHidden, UnauthorizedError } from 'payload';
4
3
  import { applyLocaleFiltering } from 'payload/shared';
5
4
  import { renderListView } from './index.js';
6
5
  export const renderListHandler = async args => {
7
6
  const {
8
7
  collectionSlug,
8
+ cookies,
9
9
  disableActions,
10
10
  disableBulkDelete,
11
11
  disableBulkEdit,
12
12
  disableQueryPresets,
13
13
  drawerSlug,
14
14
  enableRowSelections,
15
+ locale,
15
16
  overrideEntityVisibility,
17
+ permissions,
16
18
  query,
17
19
  redirectAfterDelete,
18
20
  redirectAfterDuplicate,
@@ -29,8 +31,6 @@ export const renderListHandler = async args => {
29
31
  if (!req.user) {
30
32
  throw new UnauthorizedError();
31
33
  }
32
- const headers = await getHeaders();
33
- const cookies = parseCookies(headers);
34
34
  await canAccessAdmin({
35
35
  req
36
36
  });
@@ -86,9 +86,6 @@ export const renderListHandler = async args => {
86
86
  user
87
87
  }) ? slug : null).filter(Boolean)
88
88
  };
89
- const permissions = await getAccessResults({
90
- req
91
- });
92
89
  const {
93
90
  List
94
91
  } = await renderListView({
@@ -106,16 +103,19 @@ export const renderListHandler = async args => {
106
103
  cookies,
107
104
  globalConfig: payload.config.globals.find(global => global.slug === collectionSlug),
108
105
  languageOptions: undefined,
106
+ locale,
109
107
  permissions,
110
108
  req,
111
109
  translations: undefined,
112
110
  visibleEntities
113
111
  },
112
+ locale,
114
113
  overrideEntityVisibility,
115
114
  params: {
116
115
  segments: ['collections', collectionSlug]
117
116
  },
118
117
  payload,
118
+ permissions,
119
119
  query,
120
120
  redirectAfterDelete,
121
121
  redirectAfterDuplicate,
@@ -1 +1 @@
1
- {"version":3,"file":"handleServerFunction.js","names":["getClientConfig","headers","getHeaders","canAccessAdmin","getAccessResults","isEntityHidden","parseCookies","UnauthorizedError","applyLocaleFiltering","renderListView","renderListHandler","args","collectionSlug","disableActions","disableBulkDelete","disableBulkEdit","disableQueryPresets","drawerSlug","enableRowSelections","overrideEntityVisibility","query","redirectAfterDelete","redirectAfterDuplicate","req","i18n","payload","config","user","cookies","clientConfig","importMap","preferencesKey","preferences","find","collection","depth","limit","where","and","key","equals","id","then","res","docs","value","visibleEntities","collections","map","slug","admin","hidden","filter","Boolean","globals","permissions","List","initPageResult","collectionConfig","globalConfig","global","languageOptions","undefined","translations","params","segments","searchParams","viewType"],"sources":["../../../src/views/List/handleServerFunction.tsx"],"sourcesContent":["import type { RenderListServerFnArgs, RenderListServerFnReturnType } from '@payloadcms/ui'\nimport type { CollectionPreferences, ServerFunction, VisibleEntities } from 'payload'\n\nimport { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig'\nimport { headers as getHeaders } from 'next/headers.js'\nimport {\n canAccessAdmin,\n getAccessResults,\n isEntityHidden,\n parseCookies,\n UnauthorizedError,\n} from 'payload'\nimport { applyLocaleFiltering } from 'payload/shared'\n\nimport { renderListView } from './index.js'\n\nexport const renderListHandler: ServerFunction<\n RenderListServerFnArgs,\n Promise<RenderListServerFnReturnType>\n> = async (args) => {\n const {\n collectionSlug,\n disableActions,\n disableBulkDelete,\n disableBulkEdit,\n disableQueryPresets,\n drawerSlug,\n enableRowSelections,\n overrideEntityVisibility,\n query,\n redirectAfterDelete,\n redirectAfterDuplicate,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n user,\n },\n } = args\n\n if (!req.user) {\n throw new UnauthorizedError()\n }\n\n const headers = await getHeaders()\n\n const cookies = parseCookies(headers)\n\n await canAccessAdmin({ req })\n\n const clientConfig = getClientConfig({\n config,\n i18n,\n importMap: payload.importMap,\n user,\n })\n await applyLocaleFiltering({ clientConfig, config, req })\n\n const preferencesKey = `collection-${collectionSlug}`\n\n const preferences = await payload\n .find({\n collection: 'payload-preferences',\n depth: 0,\n limit: 1,\n where: {\n and: [\n {\n key: {\n equals: preferencesKey,\n },\n },\n {\n 'user.relationTo': {\n equals: user.collection,\n },\n },\n {\n 'user.value': {\n equals: user.id,\n },\n },\n ],\n },\n })\n .then((res) => res.docs[0]?.value as CollectionPreferences)\n\n const visibleEntities: VisibleEntities = {\n collections: payload.config.collections\n .map(({ slug, admin: { hidden } }) => (!isEntityHidden({ hidden, user }) ? slug : null))\n .filter(Boolean),\n globals: payload.config.globals\n .map(({ slug, admin: { hidden } }) => (!isEntityHidden({ hidden, user }) ? slug : null))\n .filter(Boolean),\n }\n\n const permissions = await getAccessResults({\n req,\n })\n\n const { List } = await renderListView({\n clientConfig,\n disableActions,\n disableBulkDelete,\n disableBulkEdit,\n disableQueryPresets,\n drawerSlug,\n enableRowSelections,\n i18n,\n importMap: payload.importMap,\n initPageResult: {\n collectionConfig: payload?.collections?.[collectionSlug]?.config,\n cookies,\n globalConfig: payload.config.globals.find((global) => global.slug === collectionSlug),\n languageOptions: undefined, // TODO\n permissions,\n req,\n translations: undefined, // TODO\n visibleEntities,\n },\n overrideEntityVisibility,\n params: {\n segments: ['collections', collectionSlug],\n },\n payload,\n query,\n redirectAfterDelete,\n redirectAfterDuplicate,\n searchParams: {},\n viewType: 'list',\n })\n\n return {\n List,\n preferences,\n }\n}\n"],"mappings":"AAGA,SAASA,eAAe,QAAQ;AAChC,SAASC,OAAA,IAAWC,UAAU,QAAQ;AACtC,SACEC,cAAc,EACdC,gBAAgB,EAChBC,cAAc,EACdC,YAAY,EACZC,iBAAiB,QACZ;AACP,SAASC,oBAAoB,QAAQ;AAErC,SAASC,cAAc,QAAQ;AAE/B,OAAO,MAAMC,iBAAA,GAGT,MAAOC,IAAA;EACT,MAAM;IACJC,cAAc;IACdC,cAAc;IACdC,iBAAiB;IACjBC,eAAe;IACfC,mBAAmB;IACnBC,UAAU;IACVC,mBAAmB;IACnBC,wBAAwB;IACxBC,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IAAK,KAAKsB,IAAA,GAAO,MACjFG,MAAM,CAACC,OAAA;IACVC,OAAA,EAAS7B,OAAA,CAAQC,MAAM,CAAC4B,OAAO,CAC5BN,GAAG,CAAC,CAAC;MAAEC,IAAI;MAAEC,KAAA,EAAO;QAAEC;MAAM;IAAE,CAAE,KAAM,CAAC9C,cAAA,CAAe;MAAE8C,MAAA;MAAQxB;IAAK,KAAKsB,IAAA,GAAO,MACjFG,MAAM,CAACC,OAAA;EACZ;EAEA,MAAME,WAAA,GAAc,MAAMnD,gBAAA,CAAiB;IACzCmB;EACF;EAEA,MAAM;IAAEiC;EAAI,CAAE,GAAG,MAAM/C,cAAA,CAAe;IACpCoB,YAAA;IACAhB,cAAA;IACAC,iBAAA;IACAC,eAAA;IACAC,mBAAA;IACAC,UAAA;IACAC,mBAAA;IACAM,IAAA;IACAM,SAAA,EAAWL,OAAA,CAAQK,SAAS;IAC5B2B,cAAA,EAAgB;MACdC,gBAAA,EAAkBjC,OAAA,EAASsB,WAAA,GAAcnC,cAAA,CAAe,EAAEc,MAAA;MAC1DE,OAAA;MACA+B,YAAA,EAAclC,OAAA,CAAQC,MAAM,CAAC4B,OAAO,CAACrB,IAAI,CAAE2B,MAAA,IAAWA,MAAA,CAAOX,IAAI,KAAKrC,cAAA;MACtEiD,eAAA,EAAiBC,SAAA;MACjBP,WAAA;MACAhC,GAAA;MACAwC,YAAA,EAAcD,SAAA;MACdhB;IACF;IACA3B,wBAAA;IACA6C,MAAA,EAAQ;MACNC,QAAA,EAAU,CAAC,eAAerD,cAAA;IAC5B;IACAa,OAAA;IACAL,KAAA;IACAC,mBAAA;IACAC,sBAAA;IACA4C,YAAA,EAAc,CAAC;IACfC,QAAA,EAAU;EACZ;EAEA,OAAO;IACLX,IAAA;IACAxB;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"handleServerFunction.js","names":["getClientConfig","canAccessAdmin","isEntityHidden","UnauthorizedError","applyLocaleFiltering","renderListView","renderListHandler","args","collectionSlug","cookies","disableActions","disableBulkDelete","disableBulkEdit","disableQueryPresets","drawerSlug","enableRowSelections","locale","overrideEntityVisibility","permissions","query","redirectAfterDelete","redirectAfterDuplicate","req","i18n","payload","config","user","clientConfig","importMap","preferencesKey","preferences","find","collection","depth","limit","where","and","key","equals","id","then","res","docs","value","visibleEntities","collections","map","slug","admin","hidden","filter","Boolean","globals","List","initPageResult","collectionConfig","globalConfig","global","languageOptions","undefined","translations","params","segments","searchParams","viewType"],"sources":["../../../src/views/List/handleServerFunction.tsx"],"sourcesContent":["import type { RenderListServerFnArgs, RenderListServerFnReturnType } from '@payloadcms/ui'\nimport type { CollectionPreferences, ServerFunction, VisibleEntities } from 'payload'\n\nimport { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig'\nimport { canAccessAdmin, isEntityHidden, UnauthorizedError } from 'payload'\nimport { applyLocaleFiltering } from 'payload/shared'\n\nimport { renderListView } from './index.js'\n\nexport const renderListHandler: ServerFunction<\n RenderListServerFnArgs,\n Promise<RenderListServerFnReturnType>\n> = async (args) => {\n const {\n collectionSlug,\n cookies,\n disableActions,\n disableBulkDelete,\n disableBulkEdit,\n disableQueryPresets,\n drawerSlug,\n enableRowSelections,\n locale,\n overrideEntityVisibility,\n permissions,\n query,\n redirectAfterDelete,\n redirectAfterDuplicate,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n user,\n },\n } = args\n\n if (!req.user) {\n throw new UnauthorizedError()\n }\n\n await canAccessAdmin({ req })\n\n const clientConfig = getClientConfig({\n config,\n i18n,\n importMap: payload.importMap,\n user,\n })\n await applyLocaleFiltering({ clientConfig, config, req })\n\n const preferencesKey = `collection-${collectionSlug}`\n\n const preferences = await payload\n .find({\n collection: 'payload-preferences',\n depth: 0,\n limit: 1,\n where: {\n and: [\n {\n key: {\n equals: preferencesKey,\n },\n },\n {\n 'user.relationTo': {\n equals: user.collection,\n },\n },\n {\n 'user.value': {\n equals: user.id,\n },\n },\n ],\n },\n })\n .then((res) => res.docs[0]?.value as CollectionPreferences)\n\n const visibleEntities: VisibleEntities = {\n collections: payload.config.collections\n .map(({ slug, admin: { hidden } }) => (!isEntityHidden({ hidden, user }) ? slug : null))\n .filter(Boolean),\n globals: payload.config.globals\n .map(({ slug, admin: { hidden } }) => (!isEntityHidden({ hidden, user }) ? slug : null))\n .filter(Boolean),\n }\n\n const { List } = await renderListView({\n clientConfig,\n disableActions,\n disableBulkDelete,\n disableBulkEdit,\n disableQueryPresets,\n drawerSlug,\n enableRowSelections,\n i18n,\n importMap: payload.importMap,\n initPageResult: {\n collectionConfig: payload?.collections?.[collectionSlug]?.config,\n cookies,\n globalConfig: payload.config.globals.find((global) => global.slug === collectionSlug),\n languageOptions: undefined, // TODO\n locale,\n permissions,\n req,\n translations: undefined, // TODO\n visibleEntities,\n },\n locale,\n overrideEntityVisibility,\n params: {\n segments: ['collections', collectionSlug],\n },\n payload,\n permissions,\n query,\n redirectAfterDelete,\n redirectAfterDuplicate,\n searchParams: {},\n viewType: 'list',\n })\n\n return {\n List,\n preferences,\n }\n}\n"],"mappings":"AAGA,SAASA,eAAe,QAAQ;AAChC,SAASC,cAAc,EAAEC,cAAc,EAAEC,iBAAiB,QAAQ;AAClE,SAASC,oBAAoB,QAAQ;AAErC,SAASC,cAAc,QAAQ;AAE/B,OAAO,MAAMC,iBAAA,GAGT,MAAOC,IAAA;EACT,MAAM;IACJC,cAAc;IACdC,OAAO;IACPC,cAAc;IACdC,iBAAiB;IACjBC,eAAe;IACfC,mBAAmB;IACnBC,UAAU;IACVC,mBAAmB;IACnBC,MAAM;IACNC,wBAAwB;IACxBC,WAAW;IACXC,KAAK;IACLC,mBAAmB;IACnBC,sBAAsB;IACtBC,GAAG;IACHA,GAAA,EAAK;MACHC,IAAI;MACJC,OAAO;MACPA,OAAA,EAAS;QAAEC;MAAM,CAAE;MACnBC;IAAI;EACL,CACF,GAAGnB,IAAA;EAEJ,IAAI,CAACe,GAAA,CAAII,IAAI,EAAE;IACb,MAAM,IAAIvB,iBAAA;EACZ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,GAAG,MAAMhD,cAAA,CAAe;IACpCsB,YAAA;IACAjB,cAAA;IACAC,iBAAA;IACAC,eAAA;IACAC,mBAAA;IACAC,UAAA;IACAC,mBAAA;IACAQ,IAAA;IACAK,SAAA,EAAWJ,OAAA,CAAQI,SAAS;IAC5B0B,cAAA,EAAgB;MACdC,gBAAA,EAAkB/B,OAAA,EAASqB,WAAA,GAAcrC,cAAA,CAAe,EAAEiB,MAAA;MAC1DhB,OAAA;MACA+C,YAAA,EAAchC,OAAA,CAAQC,MAAM,CAAC2B,OAAO,CAACrB,IAAI,CAAE0B,MAAA,IAAWA,MAAA,CAAOV,IAAI,KAAKvC,cAAA;MACtEkD,eAAA,EAAiBC,SAAA;MACjB3C,MAAA;MACAE,WAAA;MACAI,GAAA;MACAsC,YAAA,EAAcD,SAAA;MACdf;IACF;IACA5B,MAAA;IACAC,wBAAA;IACA4C,MAAA,EAAQ;MACNC,QAAA,EAAU,CAAC,eAAetD,cAAA;IAC5B;IACAgB,OAAA;IACAN,WAAA;IACAC,KAAA;IACAC,mBAAA;IACAC,sBAAA;IACA0C,YAAA,EAAc,CAAC;IACfC,QAAA,EAAU;EACZ;EAEA,OAAO;IACLX,IAAA;IACAvB;EACF;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/views/Version/RenderFieldsToDiff/fields/Relationship/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EACjB,oCAAoC,EACpC,UAAU,EACX,MAAM,SAAS,CAAA;AAEhB,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAG1E,OAAO,cAAc,CAAA;AAErB,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB,MAAM,MAAM,iBAAiB,GACzB;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,CAAA;CAAE,GAC3D,CAAC,MAAM,GAAG,MAAM,GAAG,UAAU,CAAC,CAAA;AAElC,eAAO,MAAM,YAAY,EAAE,oCA0C1B,CAAA;AAED,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC;IAC5C,KAAK,EAAE,iBAAiB,CAAA;IACxB,IAAI,EAAE,UAAU,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,iBAAiB,EAAE,OAAO,CAAA;IAC1B,WAAW,EAAE,OAAO,CAAA;IACpB,GAAG,EAAE,cAAc,CAAA;IACnB,SAAS,EAAE,iBAAiB,CAAA;IAC5B,OAAO,EAAE,iBAAiB,CAAA;CAC3B,CAkGA,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/views/Version/RenderFieldsToDiff/fields/Relationship/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EACjB,oCAAoC,EACpC,UAAU,EACX,MAAM,SAAS,CAAA;AAEhB,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAG1E,OAAO,cAAc,CAAA;AAErB,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB,MAAM,MAAM,iBAAiB,GACzB;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,CAAA;CAAE,GAC3D,CAAC,MAAM,GAAG,MAAM,GAAG,UAAU,CAAC,CAAA;AAElC,eAAO,MAAM,YAAY,EAAE,oCA8C1B,CAAA;AAED,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC;IAC5C,KAAK,EAAE,iBAAiB,CAAA;IACxB,IAAI,EAAE,UAAU,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,iBAAiB,EAAE,OAAO,CAAA;IAC1B,WAAW,EAAE,OAAO,CAAA;IACpB,GAAG,EAAE,cAAc,CAAA;IACnB,SAAS,EAAE,iBAAiB,CAAA;IAC5B,OAAO,EAAE,iBAAiB,CAAA;CAC3B,CAkGA,CAAA"}
@@ -14,7 +14,9 @@ export const Relationship = ({
14
14
  req,
15
15
  versionValue: valueTo
16
16
  }) => {
17
- const hasMany = 'hasMany' in field && field.hasMany;
17
+ const hasMany = 'hasMany' in field && field.hasMany ||
18
+ // Check data structure (handles block swaps where schema may not match data)
19
+ Array.isArray(valueFrom) || Array.isArray(valueTo);
18
20
  const polymorphic = Array.isArray(field.relationTo);
19
21
  if (hasMany) {
20
22
  return /*#__PURE__*/_jsx(ManyRelationshipDiff, {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["getTranslation","FieldDiffContainer","getHTMLDiffComponents","React","generateLabelFromValue","baseClass","Relationship","comparisonValue","valueFrom","field","i18n","locale","nestingLevel","parentIsLocalized","req","versionValue","valueTo","hasMany","polymorphic","Array","isArray","relationTo","_jsx","ManyRelationshipDiff","SingleRelationshipDiff","args","ReactDOMServer","default","localeToUse","payload","config","localization","defaultLocale","titleFrom","titleTo","Promise","all","value","resolve","FromComponent","RelationshipDocumentDiff","showPill","title","ToComponent","fromHTML","renderToStaticMarkup","toHTML","diff","tokenizeByCharacter","className","From","label","To","fromArr","toArr","titlesFrom","titlesTo","map","val","makeNodes","list","titles","idx","fromNodes","length","toNodes","pillLabel","collectionConfig","collections","labels","singular","slug","_jsxs","id"],"sources":["../../../../../../src/views/Version/RenderFieldsToDiff/fields/Relationship/index.tsx"],"sourcesContent":["import type {\n PayloadRequest,\n RelationshipField,\n RelationshipFieldDiffServerComponent,\n TypeWithID,\n} from 'payload'\n\nimport { getTranslation, type I18nClient } from '@payloadcms/translations'\nimport { FieldDiffContainer, getHTMLDiffComponents } from '@payloadcms/ui/rsc'\n\nimport './index.scss'\n\nimport React from 'react'\n\nimport { generateLabelFromValue } from './generateLabelFromValue.js'\n\nconst baseClass = 'relationship-diff'\n\nexport type RelationshipValue =\n | { relationTo: string; value: number | string | TypeWithID }\n | (number | string | TypeWithID)\n\nexport const Relationship: RelationshipFieldDiffServerComponent = ({\n comparisonValue: valueFrom,\n field,\n i18n,\n locale,\n nestingLevel,\n parentIsLocalized,\n req,\n versionValue: valueTo,\n}) => {\n const hasMany = 'hasMany' in field && field.hasMany\n const polymorphic = Array.isArray(field.relationTo)\n\n if (hasMany) {\n return (\n <ManyRelationshipDiff\n field={field}\n i18n={i18n}\n locale={locale}\n nestingLevel={nestingLevel}\n parentIsLocalized={parentIsLocalized}\n polymorphic={polymorphic}\n req={req}\n valueFrom={valueFrom as RelationshipValue[] | undefined}\n valueTo={valueTo as RelationshipValue[] | undefined}\n />\n )\n }\n\n return (\n <SingleRelationshipDiff\n field={field}\n i18n={i18n}\n locale={locale}\n nestingLevel={nestingLevel}\n parentIsLocalized={parentIsLocalized}\n polymorphic={polymorphic}\n req={req}\n valueFrom={valueFrom as RelationshipValue}\n valueTo={valueTo as RelationshipValue}\n />\n )\n}\n\nexport const SingleRelationshipDiff: React.FC<{\n field: RelationshipField\n i18n: I18nClient\n locale: string\n nestingLevel?: number\n parentIsLocalized: boolean\n polymorphic: boolean\n req: PayloadRequest\n valueFrom: RelationshipValue\n valueTo: RelationshipValue\n}> = async (args) => {\n const {\n field,\n i18n,\n locale,\n nestingLevel,\n parentIsLocalized,\n polymorphic,\n req,\n valueFrom,\n valueTo,\n } = args\n\n const ReactDOMServer = (await import('react-dom/server')).default\n\n const localeToUse =\n locale ??\n (req.payload.config?.localization && req.payload.config?.localization?.defaultLocale) ??\n 'en'\n\n // Generate titles asynchronously before creating components\n const [titleFrom, titleTo] = await Promise.all([\n valueFrom\n ? generateLabelFromValue({\n field,\n locale: localeToUse,\n parentIsLocalized,\n req,\n value: valueFrom,\n })\n : Promise.resolve(null),\n valueTo\n ? generateLabelFromValue({\n field,\n locale: localeToUse,\n parentIsLocalized,\n req,\n value: valueTo,\n })\n : Promise.resolve(null),\n ])\n\n const FromComponent = valueFrom ? (\n <RelationshipDocumentDiff\n field={field}\n i18n={i18n}\n locale={locale}\n parentIsLocalized={parentIsLocalized}\n polymorphic={polymorphic}\n relationTo={\n polymorphic\n ? (valueFrom as { relationTo: string; value: TypeWithID }).relationTo\n : (field.relationTo as string)\n }\n req={req}\n showPill={true}\n title={titleFrom}\n value={valueFrom}\n />\n ) : null\n const ToComponent = valueTo ? (\n <RelationshipDocumentDiff\n field={field}\n i18n={i18n}\n locale={locale}\n parentIsLocalized={parentIsLocalized}\n polymorphic={polymorphic}\n relationTo={\n polymorphic\n ? (valueTo as { relationTo: string; value: TypeWithID }).relationTo\n : (field.relationTo as string)\n }\n req={req}\n showPill={true}\n title={titleTo}\n value={valueTo}\n />\n ) : null\n\n const fromHTML = FromComponent ? ReactDOMServer.renderToStaticMarkup(FromComponent) : `<p></p>`\n const toHTML = ToComponent ? ReactDOMServer.renderToStaticMarkup(ToComponent) : `<p></p>`\n\n const diff = getHTMLDiffComponents({\n fromHTML,\n toHTML,\n tokenizeByCharacter: false,\n })\n\n return (\n <FieldDiffContainer\n className={`${baseClass}-container ${baseClass}-container--hasOne`}\n From={diff.From}\n i18n={i18n}\n label={{ label: field.label, locale }}\n nestingLevel={nestingLevel}\n To={diff.To}\n />\n )\n}\n\nconst ManyRelationshipDiff: React.FC<{\n field: RelationshipField\n i18n: I18nClient\n locale: string\n nestingLevel?: number\n parentIsLocalized: boolean\n polymorphic: boolean\n req: PayloadRequest\n valueFrom: RelationshipValue[] | undefined\n valueTo: RelationshipValue[] | undefined\n}> = async ({\n field,\n i18n,\n locale,\n nestingLevel,\n parentIsLocalized,\n polymorphic,\n req,\n valueFrom,\n valueTo,\n}) => {\n const ReactDOMServer = (await import('react-dom/server')).default\n\n const fromArr = Array.isArray(valueFrom) ? valueFrom : []\n const toArr = Array.isArray(valueTo) ? valueTo : []\n\n const localeToUse =\n locale ??\n (req.payload.config?.localization && req.payload.config?.localization?.defaultLocale) ??\n 'en'\n\n // Generate all titles asynchronously before creating components\n const [titlesFrom, titlesTo] = await Promise.all([\n Promise.all(\n fromArr.map((val) =>\n generateLabelFromValue({\n field,\n locale: localeToUse,\n parentIsLocalized,\n req,\n value: val,\n }),\n ),\n ),\n Promise.all(\n toArr.map((val) =>\n generateLabelFromValue({\n field,\n locale: localeToUse,\n parentIsLocalized,\n req,\n value: val,\n }),\n ),\n ),\n ])\n\n const makeNodes = (list: RelationshipValue[], titles: string[]) =>\n list.map((val, idx) => (\n <RelationshipDocumentDiff\n field={field}\n i18n={i18n}\n key={idx}\n locale={locale}\n parentIsLocalized={parentIsLocalized}\n polymorphic={polymorphic}\n relationTo={\n polymorphic\n ? (val as { relationTo: string; value: TypeWithID }).relationTo\n : (field.relationTo as string)\n }\n req={req}\n showPill={polymorphic}\n title={titles[idx]}\n value={val}\n />\n ))\n\n const fromNodes =\n fromArr.length > 0 ? makeNodes(fromArr, titlesFrom) : <p className={`${baseClass}__empty`}></p>\n\n const toNodes =\n toArr.length > 0 ? makeNodes(toArr, titlesTo) : <p className={`${baseClass}__empty`}></p>\n\n const fromHTML = ReactDOMServer.renderToStaticMarkup(fromNodes)\n const toHTML = ReactDOMServer.renderToStaticMarkup(toNodes)\n\n const diff = getHTMLDiffComponents({\n fromHTML,\n toHTML,\n tokenizeByCharacter: false,\n })\n\n return (\n <FieldDiffContainer\n className={`${baseClass}-container ${baseClass}-container--hasMany`}\n From={diff.From}\n i18n={i18n}\n label={{ label: field.label, locale }}\n nestingLevel={nestingLevel}\n To={diff.To}\n />\n )\n}\n\nconst RelationshipDocumentDiff = ({\n field,\n i18n,\n locale,\n parentIsLocalized,\n polymorphic,\n relationTo,\n req,\n showPill = false,\n title,\n value,\n}: {\n field: RelationshipField\n i18n: I18nClient\n locale: string\n parentIsLocalized: boolean\n polymorphic: boolean\n relationTo: string\n req: PayloadRequest\n showPill?: boolean\n title: null | string\n value: RelationshipValue\n}) => {\n let pillLabel: null | string = null\n if (showPill) {\n const collectionConfig = req.payload.collections[relationTo].config\n pillLabel = collectionConfig.labels?.singular\n ? getTranslation(collectionConfig.labels.singular, i18n)\n : collectionConfig.slug\n }\n\n return (\n <div\n className={`${baseClass}`}\n data-enable-match=\"true\"\n data-id={\n polymorphic\n ? (value as { relationTo: string; value: TypeWithID }).value.id\n : (value as TypeWithID).id\n }\n data-relation-to={relationTo}\n >\n {pillLabel && (\n <span className={`${baseClass}__pill`} data-enable-match=\"false\">\n {pillLabel}\n </span>\n )}\n <strong className={`${baseClass}__info`} data-enable-match=\"false\">\n {title}\n </strong>\n </div>\n )\n}\n"],"mappings":";AAOA,SAASA,cAAc,QAAyB;AAChD,SAASC,kBAAkB,EAAEC,qBAAqB,QAAQ;AAI1D,OAAOC,KAAA,MAAW;AAElB,SAASC,sBAAsB,QAAQ;AAEvC,MAAMC,SAAA,GAAY;AAMlB,OAAO,MAAMC,YAAA,GAAqDA,CAAC;EACjEC,eAAA,EAAiBC,SAAS;EAC1BC,KAAK;EACLC,IAAI;EACJC,MAAM;EACNC,YAAY;EACZC,iBAAiB;EACjBC,GAAG;EACHC,YAAA,EAAcC;AAAO,CACtB;EACC,MAAMC,OAAA,GAAU,aAAaR,KAAA,IAASA,KAAA,CAAMQ,OAAO;EACnD,MAAMC,WAAA,GAAcC,KAAA,CAAMC,OAAO,CAACX,KAAA,CAAMY,UAAU;EAElD,IAAIJ,OAAA,EAAS;IACX,oBACEK,IAAA,CAACC,oBAAA;MACCd,KAAA,EAAOA,KAAA;MACPC,IAAA,EAAMA,IAAA;MACNC,MAAA,EAAQA,MAAA;MACRC,YAAA,EAAcA,YAAA;MACdC,iBAAA,EAAmBA,iBAAA;MACnBK,WAAA,EAAaA,WAAA;MACbJ,GAAA,EAAKA,GAAA;MACLN,SAAA,EAAWA,SAAA;MACXQ,OAAA,EAASA;;EAGf;EAEA,oBACEM,IAAA,CAACE,sBAAA;IACCf,KAAA,EAAOA,KAAA;IACPC,IAAA,EAAMA,IAAA;IACNC,MAAA,EAAQA,MAAA;IACRC,YAAA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ACuC,WAAW,CAAC/C,UAAA,CAAW,CAACS,MAAM;IACnEoC,SAAA,GAAYC,gBAAA,CAAiBE,MAAM,EAAEC,QAAA,GACjCtE,cAAA,CAAemE,gBAAA,CAAiBE,MAAM,CAACC,QAAQ,EAAE5D,IAAA,IACjDyD,gBAAA,CAAiBI,IAAI;EAC3B;EAEA,oBACEC,KAAA,CAAC;IACCvB,SAAA,EAAW,GAAG5C,SAAA,EAAW;IACzB,qBAAkB;IAClB,WACEa,WAAA,GACImB,KAAC,CAAoDA,KAAK,CAACoC,EAAE,GAC7DpC,KAAC,CAAqBoC,EAAE;IAE9B,oBAAkBpD,UAAA;eAEjB6C,SAAA,iBACC5C,IAAA,CAAC;MAAK2B,SAAA,EAAW,GAAG5C,SAAA,QAAiB;MAAE,qBAAkB;gBACtD6D;qBAGL5C,IAAA,CAAC;MAAO2B,SAAA,EAAW,GAAG5C,SAAA,QAAiB;MAAE,qBAAkB;gBACxDqC;;;AAIT","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["getTranslation","FieldDiffContainer","getHTMLDiffComponents","React","generateLabelFromValue","baseClass","Relationship","comparisonValue","valueFrom","field","i18n","locale","nestingLevel","parentIsLocalized","req","versionValue","valueTo","hasMany","Array","isArray","polymorphic","relationTo","_jsx","ManyRelationshipDiff","SingleRelationshipDiff","args","ReactDOMServer","default","localeToUse","payload","config","localization","defaultLocale","titleFrom","titleTo","Promise","all","value","resolve","FromComponent","RelationshipDocumentDiff","showPill","title","ToComponent","fromHTML","renderToStaticMarkup","toHTML","diff","tokenizeByCharacter","className","From","label","To","fromArr","toArr","titlesFrom","titlesTo","map","val","makeNodes","list","titles","idx","fromNodes","length","toNodes","pillLabel","collectionConfig","collections","labels","singular","slug","_jsxs","id"],"sources":["../../../../../../src/views/Version/RenderFieldsToDiff/fields/Relationship/index.tsx"],"sourcesContent":["import type {\n PayloadRequest,\n RelationshipField,\n RelationshipFieldDiffServerComponent,\n TypeWithID,\n} from 'payload'\n\nimport { getTranslation, type I18nClient } from '@payloadcms/translations'\nimport { FieldDiffContainer, getHTMLDiffComponents } from '@payloadcms/ui/rsc'\n\nimport './index.scss'\n\nimport React from 'react'\n\nimport { generateLabelFromValue } from './generateLabelFromValue.js'\n\nconst baseClass = 'relationship-diff'\n\nexport type RelationshipValue =\n | { relationTo: string; value: number | string | TypeWithID }\n | (number | string | TypeWithID)\n\nexport const Relationship: RelationshipFieldDiffServerComponent = ({\n comparisonValue: valueFrom,\n field,\n i18n,\n locale,\n nestingLevel,\n parentIsLocalized,\n req,\n versionValue: valueTo,\n}) => {\n const hasMany =\n ('hasMany' in field && field.hasMany) ||\n // Check data structure (handles block swaps where schema may not match data)\n Array.isArray(valueFrom) ||\n Array.isArray(valueTo)\n const polymorphic = Array.isArray(field.relationTo)\n\n if (hasMany) {\n return (\n <ManyRelationshipDiff\n field={field}\n i18n={i18n}\n locale={locale}\n nestingLevel={nestingLevel}\n parentIsLocalized={parentIsLocalized}\n polymorphic={polymorphic}\n req={req}\n valueFrom={valueFrom as RelationshipValue[] | undefined}\n valueTo={valueTo as RelationshipValue[] | undefined}\n />\n )\n }\n\n return (\n <SingleRelationshipDiff\n field={field}\n i18n={i18n}\n locale={locale}\n nestingLevel={nestingLevel}\n parentIsLocalized={parentIsLocalized}\n polymorphic={polymorphic}\n req={req}\n valueFrom={valueFrom as RelationshipValue}\n valueTo={valueTo as RelationshipValue}\n />\n )\n}\n\nexport const SingleRelationshipDiff: React.FC<{\n field: RelationshipField\n i18n: I18nClient\n locale: string\n nestingLevel?: number\n parentIsLocalized: boolean\n polymorphic: boolean\n req: PayloadRequest\n valueFrom: RelationshipValue\n valueTo: RelationshipValue\n}> = async (args) => {\n const {\n field,\n i18n,\n locale,\n nestingLevel,\n parentIsLocalized,\n polymorphic,\n req,\n valueFrom,\n valueTo,\n } = args\n\n const ReactDOMServer = (await import('react-dom/server')).default\n\n const localeToUse =\n locale ??\n (req.payload.config?.localization && req.payload.config?.localization?.defaultLocale) ??\n 'en'\n\n // Generate titles asynchronously before creating components\n const [titleFrom, titleTo] = await Promise.all([\n valueFrom\n ? generateLabelFromValue({\n field,\n locale: localeToUse,\n parentIsLocalized,\n req,\n value: valueFrom,\n })\n : Promise.resolve(null),\n valueTo\n ? generateLabelFromValue({\n field,\n locale: localeToUse,\n parentIsLocalized,\n req,\n value: valueTo,\n })\n : Promise.resolve(null),\n ])\n\n const FromComponent = valueFrom ? (\n <RelationshipDocumentDiff\n field={field}\n i18n={i18n}\n locale={locale}\n parentIsLocalized={parentIsLocalized}\n polymorphic={polymorphic}\n relationTo={\n polymorphic\n ? (valueFrom as { relationTo: string; value: TypeWithID }).relationTo\n : (field.relationTo as string)\n }\n req={req}\n showPill={true}\n title={titleFrom}\n value={valueFrom}\n />\n ) : null\n const ToComponent = valueTo ? (\n <RelationshipDocumentDiff\n field={field}\n i18n={i18n}\n locale={locale}\n parentIsLocalized={parentIsLocalized}\n polymorphic={polymorphic}\n relationTo={\n polymorphic\n ? (valueTo as { relationTo: string; value: TypeWithID }).relationTo\n : (field.relationTo as string)\n }\n req={req}\n showPill={true}\n title={titleTo}\n value={valueTo}\n />\n ) : null\n\n const fromHTML = FromComponent ? ReactDOMServer.renderToStaticMarkup(FromComponent) : `<p></p>`\n const toHTML = ToComponent ? ReactDOMServer.renderToStaticMarkup(ToComponent) : `<p></p>`\n\n const diff = getHTMLDiffComponents({\n fromHTML,\n toHTML,\n tokenizeByCharacter: false,\n })\n\n return (\n <FieldDiffContainer\n className={`${baseClass}-container ${baseClass}-container--hasOne`}\n From={diff.From}\n i18n={i18n}\n label={{ label: field.label, locale }}\n nestingLevel={nestingLevel}\n To={diff.To}\n />\n )\n}\n\nconst ManyRelationshipDiff: React.FC<{\n field: RelationshipField\n i18n: I18nClient\n locale: string\n nestingLevel?: number\n parentIsLocalized: boolean\n polymorphic: boolean\n req: PayloadRequest\n valueFrom: RelationshipValue[] | undefined\n valueTo: RelationshipValue[] | undefined\n}> = async ({\n field,\n i18n,\n locale,\n nestingLevel,\n parentIsLocalized,\n polymorphic,\n req,\n valueFrom,\n valueTo,\n}) => {\n const ReactDOMServer = (await import('react-dom/server')).default\n\n const fromArr = Array.isArray(valueFrom) ? valueFrom : []\n const toArr = Array.isArray(valueTo) ? valueTo : []\n\n const localeToUse =\n locale ??\n (req.payload.config?.localization && req.payload.config?.localization?.defaultLocale) ??\n 'en'\n\n // Generate all titles asynchronously before creating components\n const [titlesFrom, titlesTo] = await Promise.all([\n Promise.all(\n fromArr.map((val) =>\n generateLabelFromValue({\n field,\n locale: localeToUse,\n parentIsLocalized,\n req,\n value: val,\n }),\n ),\n ),\n Promise.all(\n toArr.map((val) =>\n generateLabelFromValue({\n field,\n locale: localeToUse,\n parentIsLocalized,\n req,\n value: val,\n }),\n ),\n ),\n ])\n\n const makeNodes = (list: RelationshipValue[], titles: string[]) =>\n list.map((val, idx) => (\n <RelationshipDocumentDiff\n field={field}\n i18n={i18n}\n key={idx}\n locale={locale}\n parentIsLocalized={parentIsLocalized}\n polymorphic={polymorphic}\n relationTo={\n polymorphic\n ? (val as { relationTo: string; value: TypeWithID }).relationTo\n : (field.relationTo as string)\n }\n req={req}\n showPill={polymorphic}\n title={titles[idx]}\n value={val}\n />\n ))\n\n const fromNodes =\n fromArr.length > 0 ? makeNodes(fromArr, titlesFrom) : <p className={`${baseClass}__empty`}></p>\n\n const toNodes =\n toArr.length > 0 ? makeNodes(toArr, titlesTo) : <p className={`${baseClass}__empty`}></p>\n\n const fromHTML = ReactDOMServer.renderToStaticMarkup(fromNodes)\n const toHTML = ReactDOMServer.renderToStaticMarkup(toNodes)\n\n const diff = getHTMLDiffComponents({\n fromHTML,\n toHTML,\n tokenizeByCharacter: false,\n })\n\n return (\n <FieldDiffContainer\n className={`${baseClass}-container ${baseClass}-container--hasMany`}\n From={diff.From}\n i18n={i18n}\n label={{ label: field.label, locale }}\n nestingLevel={nestingLevel}\n To={diff.To}\n />\n )\n}\n\nconst RelationshipDocumentDiff = ({\n field,\n i18n,\n locale,\n parentIsLocalized,\n polymorphic,\n relationTo,\n req,\n showPill = false,\n title,\n value,\n}: {\n field: RelationshipField\n i18n: I18nClient\n locale: string\n parentIsLocalized: boolean\n polymorphic: boolean\n relationTo: string\n req: PayloadRequest\n showPill?: boolean\n title: null | string\n value: RelationshipValue\n}) => {\n let pillLabel: null | string = null\n if (showPill) {\n const collectionConfig = req.payload.collections[relationTo].config\n pillLabel = collectionConfig.labels?.singular\n ? getTranslation(collectionConfig.labels.singular, i18n)\n : collectionConfig.slug\n }\n\n return (\n <div\n className={`${baseClass}`}\n data-enable-match=\"true\"\n data-id={\n polymorphic\n ? (value as { relationTo: string; value: TypeWithID }).value.id\n : (value as TypeWithID).id\n }\n data-relation-to={relationTo}\n >\n {pillLabel && (\n <span className={`${baseClass}__pill`} data-enable-match=\"false\">\n {pillLabel}\n </span>\n )}\n <strong className={`${baseClass}__info`} data-enable-match=\"false\">\n {title}\n </strong>\n </div>\n )\n}\n"],"mappings":";AAOA,SAASA,cAAc,QAAyB;AAChD,SAASC,kBAAkB,EAAEC,qBAAqB,QAAQ;AAI1D,OAAOC,KAAA,MAAW;AAElB,SAASC,sBAAsB,QAAQ;AAEvC,MAAMC,SAAA,GAAY;AAMlB,OAAO,MAAMC,YAAA,GAAqDA,CAAC;EACjEC,eAAA,EAAiBC,SAAS;EAC1BC,KAAK;EACLC,IAAI;EACJC,MAAM;EACNC,YAAY;EACZC,iBAAiB;EACjBC,GAAG;EACHC,YAAA,EAAcC;AAAO,CACtB;EACC,MAAMC,OAAA,GACJ,SAAC,IAAaR,KAAA,IAASA,KAAA,CAAMQ,OAAO;EACpC;EACAC,KAAA,CAAMC,OAAO,CAACX,SAAA,KACdU,KAAA,CAAMC,OAAO,CAACH,OAAA;EAChB,MAAMI,WAAA,GAAcF,KAAA,CAAMC,OAAO,CAACV,KAAA,CAAMY,UAAU;EAElD,IAAIJ,OAAA,EAAS;IACX,oBACEK,IAAA,CAACC,oBAAA;MACCd,KAAA,EAAOA,KAAA;MACPC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AIL,IAAA,CAAKK;;AAGf;AAEA,MAAMZ,wBAAA,GAA2BA,CAAC;EAChC/B,KAAK;EACLC,IAAI;EACJC,MAAM;EACNE,iBAAiB;EACjBO,WAAW;EACXC,UAAU;EACVP,GAAG;EACH2B,QAAA,GAAW,KAAK;EAChBC,KAAK;EACLL;AAAK,CAYN;EACC,IAAI6B,SAAA,GAA2B;EAC/B,IAAIzB,QAAA,EAAU;IACZ,MAAM0B,gBAAA,GAAmBrD,GAAA,CAAIe,OAAO,CAACuC,WAAW,CAAC/C,UAAA,CAAW,CAACS,MAAM;IACnEoC,SAAA,GAAYC,gBAAA,CAAiBE,MAAM,EAAEC,QAAA,GACjCtE,cAAA,CAAemE,gBAAA,CAAiBE,MAAM,CAACC,QAAQ,EAAE5D,IAAA,IACjDyD,gBAAA,CAAiBI,IAAI;EAC3B;EAEA,oBACEC,KAAA,CAAC;IACCvB,SAAA,EAAW,GAAG5C,SAAA,EAAW;IACzB,qBAAkB;IAClB,WACEe,WAAA,GACIiB,KAAC,CAAoDA,KAAK,CAACoC,EAAE,GAC7DpC,KAAC,CAAqBoC,EAAE;IAE9B,oBAAkBpD,UAAA;eAEjB6C,SAAA,iBACC5C,IAAA,CAAC;MAAK2B,SAAA,EAAW,GAAG5C,SAAA,QAAiB;MAAE,qBAAkB;gBACtD6D;qBAGL5C,IAAA,CAAC;MAAO2B,SAAA,EAAW,GAAG5C,SAAA,QAAiB;MAAE,qBAAkB;gBACxDqC;;;AAIT","ignoreList":[]}
@@ -23,7 +23,7 @@ export const withPayload = (nextConfig = {}, options = {}) => {
23
23
  env.NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH = 'true';
24
24
  }
25
25
  const consoleWarn = console.warn;
26
- const sassWarningText = 'SassWarning: Future import deprecation is not yet active, so silencing it is unnecessary';
26
+ const sassWarningText = 'Future import deprecation is not yet active, so silencing it is unnecessary';
27
27
  console.warn = (...args) => {
28
28
  if (typeof args[1] === 'string' && args[1].includes(sassWarningText) || typeof args[0] === 'string' && args[0].includes(sassWarningText)) {
29
29
  // This warning is a lie - without silencing import deprecation warnings, sass will spam the console with deprecation warnings
@@ -1 +1 @@
1
- {"version":3,"file":"withPayload.js","names":["getNextjsVersion","supportsTurbopackExternalizeTransitiveDependencies","withPayloadLegacy","poweredByHeader","key","value","withPayload","nextConfig","options","nextjsVersion","supportsTurbopackBuild","env","experimental","staleTimes","dynamic","console","warn","NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH","consoleWarn","sassWarningText","args","includes","baseConfig","sassOptions","silenceDeprecations","outputFileTracingExcludes","outputFileTracingIncludes","turbopack","headers","headersFromConfig","source","serverExternalPackages","process","NODE_ENV","devBundleServerPackages","webpack","webpackConfig","webpackOptions","incomingWebpackConfig","externals","plugins","IgnorePlugin","resourceRegExp","resolve","alias","fallback","aws4","basePath","NEXT_BASE_PATH"],"sources":["../../src/withPayload/withPayload.js"],"sourcesContent":["/**\n * These files must remain as plain JavaScript (.js) rather than TypeScript (.ts) because they are\n * imported directly in next.config.mjs files. Since next.config files run before the build process,\n * TypeScript compilation is not available. This ensures compatibility with all templates and\n * user projects regardless of their TypeScript setup.\n */\nimport {\n getNextjsVersion,\n supportsTurbopackExternalizeTransitiveDependencies,\n} from './withPayload.utils.js'\nimport { withPayloadLegacy } from './withPayloadLegacy.js'\n\nconst poweredByHeader = {\n key: 'X-Powered-By',\n value: 'Next.js, Payload',\n}\n\n/**\n * @param {import('next').NextConfig} nextConfig\n * @param {Object} [options] - Optional configuration options\n * @param {boolean} [options.devBundleServerPackages] - Whether to bundle server packages in development mode. @default false\n * */\nexport const withPayload = (nextConfig = {}, options = {}) => {\n const nextjsVersion = getNextjsVersion()\n\n const supportsTurbopackBuild = supportsTurbopackExternalizeTransitiveDependencies(nextjsVersion)\n\n const env = nextConfig.env || {}\n\n if (nextConfig.experimental?.staleTimes?.dynamic) {\n console.warn(\n 'Payload detected a non-zero value for the `staleTimes.dynamic` option in your Next.js config. This will slow down page transitions and may cause stale data to load within the Admin panel. To clear this warning, remove the `staleTimes.dynamic` option from your Next.js config or set it to 0. In the future, Next.js may support scoping this option to specific routes.',\n )\n env.NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH = 'true'\n }\n\n const consoleWarn = console.warn\n const sassWarningText =\n 'SassWarning: Future import deprecation is not yet active, so silencing it is unnecessary'\n console.warn = (...args) => {\n if (\n (typeof args[1] === 'string' && args[1].includes(sassWarningText)) ||\n (typeof args[0] === 'string' && args[0].includes(sassWarningText))\n ) {\n // This warning is a lie - without silencing import deprecation warnings, sass will spam the console with deprecation warnings\n return\n }\n\n consoleWarn(...args)\n }\n\n /** @type {import('next').NextConfig} */\n const baseConfig = {\n ...nextConfig,\n env,\n sassOptions: {\n ...(nextConfig.sassOptions || {}),\n /**\n * This prevents scss warning spam during pnpm dev that looks like this:\n * ⚠ ./test/admin/components/views/CustomMinimal/index.scss\n * Issue while running loader\n * SassWarning: Deprecation Warning on line 8, column 8 of file:///Users/alessio/Documents/GitHub/ payload/packages/ui/src/scss/styles.scss:8:8:\n * Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.\n *\n * More info and automated migrator: https://sass-lang.com/d/import\n *\n * 8 | @import 'queries';\n *\n *\n * packages/ui/src/scss/styles.scss 9:9 @import\n * test/admin/components/views/CustomMinimal/index.scss 1:9 root stylesheet\n *\n * @todo: update all outdated scss imports to use @use instead of @import. Then, we can remove this.\n */\n silenceDeprecations: [...(nextConfig.sassOptions?.silenceDeprecations || []), 'import'],\n },\n outputFileTracingExcludes: {\n ...(nextConfig.outputFileTracingExcludes || {}),\n '**/*': [\n ...(nextConfig.outputFileTracingExcludes?.['**/*'] || []),\n 'drizzle-kit',\n 'drizzle-kit/api',\n ],\n },\n outputFileTracingIncludes: {\n ...(nextConfig.outputFileTracingIncludes || {}),\n '**/*': [...(nextConfig.outputFileTracingIncludes?.['**/*'] || []), '@libsql/client'],\n },\n turbopack: {\n ...(nextConfig.turbopack || {}),\n },\n // We disable the poweredByHeader here because we add it manually in the headers function below\n ...(nextConfig.poweredByHeader !== false ? { poweredByHeader: false } : {}),\n headers: async () => {\n const headersFromConfig = 'headers' in nextConfig ? await nextConfig.headers() : []\n\n return [\n ...(headersFromConfig || []),\n {\n headers: [\n {\n key: 'Accept-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Vary',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Critical-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n ...(nextConfig.poweredByHeader !== false ? [poweredByHeader] : []),\n ],\n source: '/:path*',\n },\n ]\n },\n serverExternalPackages: [\n ...(nextConfig.serverExternalPackages || []),\n // WHY: without externalizing graphql, a graphql version error will be thrown\n // during runtime (\"Ensure that there is only one instance of \\\"graphql\\\" in the node_modules\\ndirectory.\")\n 'graphql',\n ...(process.env.NODE_ENV === 'development' && options.devBundleServerPackages !== true\n ? /**\n * Unless explicitly disabled by the user, by passing `devBundleServerPackages: true` to withPayload, we\n * do not bundle server-only packages during dev for two reasons:\n *\n * 1. Performance: Fewer files to compile means faster compilation speeds.\n * 2. Turbopack support: Webpack's externals are not supported by Turbopack.\n *\n * Regarding Turbopack support: Unlike webpack.externals, we cannot use serverExternalPackages to\n * externalized packages that are not resolvable from the project root. So including a package like\n * \"drizzle-kit\" in here would do nothing - Next.js will ignore the rule and still bundle the package -\n * because it detects that the package is not resolvable from the project root (= not directly installed\n * by the user in their own package.json).\n *\n * Instead, we can use serverExternalPackages for the entry-point packages that *are* installed directly\n * by the user (e.g. db-postgres, which then installs drizzle-kit as a dependency).\n *\n *\n *\n * We should only do this during development, not build, because externalizing these packages can hurt\n * the bundle size. Not only does it disable tree-shaking, it also risks installing duplicate copies of the\n * same package.\n *\n * Example:\n * - @payloadcms/richtext-lexical (in bundle) -> installs qs-esm (bundled because of importer)\n * - payload (not in bundle, external) -> installs qs-esm (external because of importer)\n * Result: we have two copies of qs-esm installed - one in the bundle, and one in node_modules.\n *\n * During development, these bundle size difference do not matter much, and development speed /\n * turbopack support are more important.\n */\n [\n 'payload',\n '@payloadcms/db-mongodb',\n '@payloadcms/db-postgres',\n '@payloadcms/db-sqlite',\n '@payloadcms/db-vercel-postgres',\n '@payloadcms/db-d1-sqlite',\n '@payloadcms/drizzle',\n '@payloadcms/email-nodemailer',\n '@payloadcms/email-resend',\n '@payloadcms/graphql',\n '@payloadcms/payload-cloud',\n '@payloadcms/plugin-redirects',\n // TODO: Add the following packages, excluding their /client subpath exports, once Next.js supports it\n // see: https://github.com/vercel/next.js/discussions/76991\n //'@payloadcms/plugin-cloud-storage',\n //'@payloadcms/plugin-sentry',\n //'@payloadcms/plugin-stripe',\n // @payloadcms/richtext-lexical\n //'@payloadcms/storage-azure',\n //'@payloadcms/storage-gcs',\n //'@payloadcms/storage-s3',\n //'@payloadcms/storage-uploadthing',\n //'@payloadcms/storage-vercel-blob',\n ]\n : []),\n ],\n webpack: (webpackConfig, webpackOptions) => {\n const incomingWebpackConfig =\n typeof nextConfig.webpack === 'function'\n ? nextConfig.webpack(webpackConfig, webpackOptions)\n : webpackConfig\n\n return {\n ...incomingWebpackConfig,\n externals: [\n ...(incomingWebpackConfig?.externals || []),\n /**\n * See the explanation in the serverExternalPackages section above.\n * We need to force Webpack to emit require() calls for these packages, even though they are not\n * resolvable from the project root. You would expect this to error during runtime, but Next.js seems to be able to require these just fine.\n *\n * This is the only way to get Webpack Build to work, without the bundle size caveats of externalizing the\n * entry point packages, as explained in the serverExternalPackages section above.\n */\n 'drizzle-kit',\n 'drizzle-kit/api',\n 'sharp',\n 'libsql',\n 'require-in-the-middle',\n 'json-schema-to-typescript',\n ],\n plugins: [\n ...(incomingWebpackConfig?.plugins || []),\n // Fix cloudflare:sockets error: https://github.com/vercel/next.js/discussions/50177\n new webpackOptions.webpack.IgnorePlugin({\n resourceRegExp: /^pg-native$|^cloudflare:sockets$/,\n }),\n ],\n resolve: {\n ...(incomingWebpackConfig?.resolve || {}),\n alias: {\n ...(incomingWebpackConfig?.resolve?.alias || {}),\n },\n fallback: {\n ...(incomingWebpackConfig?.resolve?.fallback || {}),\n /*\n * This fixes the following warning when running next build with webpack (tested on Next.js 16.0.3 with Payload 3.64.0):\n *\n * ⚠ Compiled with warnings in 8.7s\n *\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/deps.js\n * Module not found: Can't resolve 'aws4' in '/Users/alessio/Documents/temp/next16p/node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib'\n *\n * Import trace for requested module:\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/deps.js\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/client-side-encryption/client_encryption.js\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/index.js\n * ./node_modules/.pnpm/mongoose@8.15.1/node_modules/mongoose/lib/index.js\n * ./node_modules/.pnpm/mongoose@8.15.1/node_modules/mongoose/index.js\n * ./node_modules/.pnpm/@payloadcms+db-mongodb@3.64.0_payload@3.64.0_graphql@16.12.0_typescript@5.7.3_/node_modules/@payloadcms/db-mongodb/dist/index.js\n * ./src/payload.config.ts\n * ./src/app/my-route/route.ts\n *\n **/\n aws4: false,\n },\n },\n }\n },\n }\n\n if (nextConfig.basePath) {\n process.env.NEXT_BASE_PATH = nextConfig.basePath\n baseConfig.env.NEXT_BASE_PATH = nextConfig.basePath\n }\n\n if (!supportsTurbopackBuild) {\n return withPayloadLegacy(baseConfig)\n } else {\n return {\n ...baseConfig,\n serverExternalPackages: [\n ...(baseConfig.serverExternalPackages || []),\n 'drizzle-kit',\n 'drizzle-kit/api',\n 'sharp',\n 'libsql',\n 'require-in-the-middle',\n 'json-schema-to-typescript',\n // Prevents turbopack build errors by the thread-stream package which is installed by pino\n 'pino',\n ],\n }\n }\n}\n\nexport default withPayload\n"],"mappings":"AAAA;;;;;GAMA,SACEA,gBAAgB,EAChBC,kDAAkD,QAC7C;AACP,SAASC,iBAAiB,QAAQ;A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AAA,IAClCD,aAAA;MAEN,OAAO;QACL,GAAGE,qBAAqB;QACxBC,SAAA,EAAW,C,IACLD,qBAAA,EAAuBC,SAAA,IAAa,EAAE;QAC1C;;;;;;;;QAQA,eACA,mBACA,SACA,UACA,yBACA,4BACD;QACDC,OAAA,EAAS,C,IACHF,qBAAA,EAAuBE,OAAA,IAAW,EAAE;QACxC;QACA,IAAIH,cAAA,CAAeF,OAAO,CAACM,YAAY,CAAC;UACtCC,cAAA,EAAgB;QAClB,GACD;QACDC,OAAA,EAAS;UACP,IAAIL,qBAAA,EAAuBK,OAAA,IAAW,CAAC,CAAC;UACxCC,KAAA,EAAO;YACL,IAAIN,qBAAA,EAAuBK,OAAA,EAASC,KAAA,IAAS,CAAC,CAAC;UACjD;UACAC,QAAA,EAAU;YACR,IAAIP,qBAAA,EAAuBK,OAAA,EAASE,QAAA,IAAY,CAAC,CAAC;YAClD;;;;;;;;;;;;;;;;;;;YAmBAC,IAAA,EAAM;UACR;QACF;MACF;IACF;EACF;EAEA,IAAIvC,UAAA,CAAWwC,QAAQ,EAAE;IACvBf,OAAA,CAAQrB,GAAG,CAACqC,cAAc,GAAGzC,UAAA,CAAWwC,QAAQ;IAChDzB,UAAA,CAAWX,GAAG,CAACqC,cAAc,GAAGzC,UAAA,CAAWwC,QAAQ;EACrD;EAEA,IAAI,CAACrC,sBAAA,EAAwB;IAC3B,OAAOR,iBAAA,CAAkBoB,UAAA;EAC3B,OAAO;IACL,OAAO;MACL,GAAGA,UAAU;MACbS,sBAAA,EAAwB,C,IAClBT,UAAA,CAAWS,sBAAsB,IAAI,EAAE,GAC3C,eACA,mBACA,SACA,UACA,yBACA;MACA;MACA;IAEJ;EACF;AACF;AAEA,eAAezB,WAAA","ignoreList":[]}
1
+ {"version":3,"file":"withPayload.js","names":["getNextjsVersion","supportsTurbopackExternalizeTransitiveDependencies","withPayloadLegacy","poweredByHeader","key","value","withPayload","nextConfig","options","nextjsVersion","supportsTurbopackBuild","env","experimental","staleTimes","dynamic","console","warn","NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH","consoleWarn","sassWarningText","args","includes","baseConfig","sassOptions","silenceDeprecations","outputFileTracingExcludes","outputFileTracingIncludes","turbopack","headers","headersFromConfig","source","serverExternalPackages","process","NODE_ENV","devBundleServerPackages","webpack","webpackConfig","webpackOptions","incomingWebpackConfig","externals","plugins","IgnorePlugin","resourceRegExp","resolve","alias","fallback","aws4","basePath","NEXT_BASE_PATH"],"sources":["../../src/withPayload/withPayload.js"],"sourcesContent":["/**\n * These files must remain as plain JavaScript (.js) rather than TypeScript (.ts) because they are\n * imported directly in next.config.mjs files. Since next.config files run before the build process,\n * TypeScript compilation is not available. This ensures compatibility with all templates and\n * user projects regardless of their TypeScript setup.\n */\nimport {\n getNextjsVersion,\n supportsTurbopackExternalizeTransitiveDependencies,\n} from './withPayload.utils.js'\nimport { withPayloadLegacy } from './withPayloadLegacy.js'\n\nconst poweredByHeader = {\n key: 'X-Powered-By',\n value: 'Next.js, Payload',\n}\n\n/**\n * @param {import('next').NextConfig} nextConfig\n * @param {Object} [options] - Optional configuration options\n * @param {boolean} [options.devBundleServerPackages] - Whether to bundle server packages in development mode. @default false\n * */\nexport const withPayload = (nextConfig = {}, options = {}) => {\n const nextjsVersion = getNextjsVersion()\n\n const supportsTurbopackBuild = supportsTurbopackExternalizeTransitiveDependencies(nextjsVersion)\n\n const env = nextConfig.env || {}\n\n if (nextConfig.experimental?.staleTimes?.dynamic) {\n console.warn(\n 'Payload detected a non-zero value for the `staleTimes.dynamic` option in your Next.js config. This will slow down page transitions and may cause stale data to load within the Admin panel. To clear this warning, remove the `staleTimes.dynamic` option from your Next.js config or set it to 0. In the future, Next.js may support scoping this option to specific routes.',\n )\n env.NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH = 'true'\n }\n\n const consoleWarn = console.warn\n const sassWarningText =\n 'Future import deprecation is not yet active, so silencing it is unnecessary'\n console.warn = (...args) => {\n if (\n (typeof args[1] === 'string' && args[1].includes(sassWarningText)) ||\n (typeof args[0] === 'string' && args[0].includes(sassWarningText))\n ) {\n // This warning is a lie - without silencing import deprecation warnings, sass will spam the console with deprecation warnings\n return\n }\n\n consoleWarn(...args)\n }\n\n /** @type {import('next').NextConfig} */\n const baseConfig = {\n ...nextConfig,\n env,\n sassOptions: {\n ...(nextConfig.sassOptions || {}),\n /**\n * This prevents scss warning spam during pnpm dev that looks like this:\n * ⚠ ./test/admin/components/views/CustomMinimal/index.scss\n * Issue while running loader\n * SassWarning: Deprecation Warning on line 8, column 8 of file:///Users/alessio/Documents/GitHub/ payload/packages/ui/src/scss/styles.scss:8:8:\n * Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.\n *\n * More info and automated migrator: https://sass-lang.com/d/import\n *\n * 8 | @import 'queries';\n *\n *\n * packages/ui/src/scss/styles.scss 9:9 @import\n * test/admin/components/views/CustomMinimal/index.scss 1:9 root stylesheet\n *\n * @todo: update all outdated scss imports to use @use instead of @import. Then, we can remove this.\n */\n silenceDeprecations: [...(nextConfig.sassOptions?.silenceDeprecations || []), 'import'],\n },\n outputFileTracingExcludes: {\n ...(nextConfig.outputFileTracingExcludes || {}),\n '**/*': [\n ...(nextConfig.outputFileTracingExcludes?.['**/*'] || []),\n 'drizzle-kit',\n 'drizzle-kit/api',\n ],\n },\n outputFileTracingIncludes: {\n ...(nextConfig.outputFileTracingIncludes || {}),\n '**/*': [...(nextConfig.outputFileTracingIncludes?.['**/*'] || []), '@libsql/client'],\n },\n turbopack: {\n ...(nextConfig.turbopack || {}),\n },\n // We disable the poweredByHeader here because we add it manually in the headers function below\n ...(nextConfig.poweredByHeader !== false ? { poweredByHeader: false } : {}),\n headers: async () => {\n const headersFromConfig = 'headers' in nextConfig ? await nextConfig.headers() : []\n\n return [\n ...(headersFromConfig || []),\n {\n headers: [\n {\n key: 'Accept-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Vary',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Critical-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n ...(nextConfig.poweredByHeader !== false ? [poweredByHeader] : []),\n ],\n source: '/:path*',\n },\n ]\n },\n serverExternalPackages: [\n ...(nextConfig.serverExternalPackages || []),\n // WHY: without externalizing graphql, a graphql version error will be thrown\n // during runtime (\"Ensure that there is only one instance of \\\"graphql\\\" in the node_modules\\ndirectory.\")\n 'graphql',\n ...(process.env.NODE_ENV === 'development' && options.devBundleServerPackages !== true\n ? /**\n * Unless explicitly disabled by the user, by passing `devBundleServerPackages: true` to withPayload, we\n * do not bundle server-only packages during dev for two reasons:\n *\n * 1. Performance: Fewer files to compile means faster compilation speeds.\n * 2. Turbopack support: Webpack's externals are not supported by Turbopack.\n *\n * Regarding Turbopack support: Unlike webpack.externals, we cannot use serverExternalPackages to\n * externalized packages that are not resolvable from the project root. So including a package like\n * \"drizzle-kit\" in here would do nothing - Next.js will ignore the rule and still bundle the package -\n * because it detects that the package is not resolvable from the project root (= not directly installed\n * by the user in their own package.json).\n *\n * Instead, we can use serverExternalPackages for the entry-point packages that *are* installed directly\n * by the user (e.g. db-postgres, which then installs drizzle-kit as a dependency).\n *\n *\n *\n * We should only do this during development, not build, because externalizing these packages can hurt\n * the bundle size. Not only does it disable tree-shaking, it also risks installing duplicate copies of the\n * same package.\n *\n * Example:\n * - @payloadcms/richtext-lexical (in bundle) -> installs qs-esm (bundled because of importer)\n * - payload (not in bundle, external) -> installs qs-esm (external because of importer)\n * Result: we have two copies of qs-esm installed - one in the bundle, and one in node_modules.\n *\n * During development, these bundle size difference do not matter much, and development speed /\n * turbopack support are more important.\n */\n [\n 'payload',\n '@payloadcms/db-mongodb',\n '@payloadcms/db-postgres',\n '@payloadcms/db-sqlite',\n '@payloadcms/db-vercel-postgres',\n '@payloadcms/db-d1-sqlite',\n '@payloadcms/drizzle',\n '@payloadcms/email-nodemailer',\n '@payloadcms/email-resend',\n '@payloadcms/graphql',\n '@payloadcms/payload-cloud',\n '@payloadcms/plugin-redirects',\n // TODO: Add the following packages, excluding their /client subpath exports, once Next.js supports it\n // see: https://github.com/vercel/next.js/discussions/76991\n //'@payloadcms/plugin-cloud-storage',\n //'@payloadcms/plugin-sentry',\n //'@payloadcms/plugin-stripe',\n // @payloadcms/richtext-lexical\n //'@payloadcms/storage-azure',\n //'@payloadcms/storage-gcs',\n //'@payloadcms/storage-s3',\n //'@payloadcms/storage-uploadthing',\n //'@payloadcms/storage-vercel-blob',\n ]\n : []),\n ],\n webpack: (webpackConfig, webpackOptions) => {\n const incomingWebpackConfig =\n typeof nextConfig.webpack === 'function'\n ? nextConfig.webpack(webpackConfig, webpackOptions)\n : webpackConfig\n\n return {\n ...incomingWebpackConfig,\n externals: [\n ...(incomingWebpackConfig?.externals || []),\n /**\n * See the explanation in the serverExternalPackages section above.\n * We need to force Webpack to emit require() calls for these packages, even though they are not\n * resolvable from the project root. You would expect this to error during runtime, but Next.js seems to be able to require these just fine.\n *\n * This is the only way to get Webpack Build to work, without the bundle size caveats of externalizing the\n * entry point packages, as explained in the serverExternalPackages section above.\n */\n 'drizzle-kit',\n 'drizzle-kit/api',\n 'sharp',\n 'libsql',\n 'require-in-the-middle',\n 'json-schema-to-typescript',\n ],\n plugins: [\n ...(incomingWebpackConfig?.plugins || []),\n // Fix cloudflare:sockets error: https://github.com/vercel/next.js/discussions/50177\n new webpackOptions.webpack.IgnorePlugin({\n resourceRegExp: /^pg-native$|^cloudflare:sockets$/,\n }),\n ],\n resolve: {\n ...(incomingWebpackConfig?.resolve || {}),\n alias: {\n ...(incomingWebpackConfig?.resolve?.alias || {}),\n },\n fallback: {\n ...(incomingWebpackConfig?.resolve?.fallback || {}),\n /*\n * This fixes the following warning when running next build with webpack (tested on Next.js 16.0.3 with Payload 3.64.0):\n *\n * ⚠ Compiled with warnings in 8.7s\n *\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/deps.js\n * Module not found: Can't resolve 'aws4' in '/Users/alessio/Documents/temp/next16p/node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib'\n *\n * Import trace for requested module:\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/deps.js\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/client-side-encryption/client_encryption.js\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/index.js\n * ./node_modules/.pnpm/mongoose@8.15.1/node_modules/mongoose/lib/index.js\n * ./node_modules/.pnpm/mongoose@8.15.1/node_modules/mongoose/index.js\n * ./node_modules/.pnpm/@payloadcms+db-mongodb@3.64.0_payload@3.64.0_graphql@16.12.0_typescript@5.7.3_/node_modules/@payloadcms/db-mongodb/dist/index.js\n * ./src/payload.config.ts\n * ./src/app/my-route/route.ts\n *\n **/\n aws4: false,\n },\n },\n }\n },\n }\n\n if (nextConfig.basePath) {\n process.env.NEXT_BASE_PATH = nextConfig.basePath\n baseConfig.env.NEXT_BASE_PATH = nextConfig.basePath\n }\n\n if (!supportsTurbopackBuild) {\n return withPayloadLegacy(baseConfig)\n } else {\n return {\n ...baseConfig,\n serverExternalPackages: [\n ...(baseConfig.serverExternalPackages || []),\n 'drizzle-kit',\n 'drizzle-kit/api',\n 'sharp',\n 'libsql',\n 'require-in-the-middle',\n 'json-schema-to-typescript',\n // Prevents turbopack build errors by the thread-stream package which is installed by pino\n 'pino',\n ],\n }\n }\n}\n\nexport default withPayload\n"],"mappings":"AAAA;;;;;GAMA,SACEA,gBAAgB,EAChBC,kDAAkD,QAC7C;AACP,SAASC,iBAAiB,QAAQ;AAElC,MAAMC,eAAA,GAAkB;EACtBC,GAAA,EAAK;EACLC,KAAA,EAAO;AACT;AAEA;;;;;AAKA,OAAO,MAAMC,WAAA,GAAcA,CAACC,UAAA,GAAa,CAAC,CAAC,EAAEC,OAAA,GAAU,CAAC,CAAC;EACvD,MAAMC,aAAA,GAAgBT,gBAAA;EAEtB,MAAMU,sBAAA,GAAyBT,kDAAA,CAAmDQ,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