@payloadcms/ui 4.0.0-canary.6 → 4.0.0-canary.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/dist/elements/AddNewRelation/index.css +28 -28
- package/dist/elements/AppHeader/index.d.ts +2 -1
- package/dist/elements/AppHeader/index.d.ts.map +1 -1
- package/dist/elements/AppHeader/index.js +2 -0
- package/dist/elements/AppHeader/index.js.map +1 -1
- package/dist/elements/BulkUpload/FormsManager/index.d.ts.map +1 -1
- package/dist/elements/BulkUpload/FormsManager/index.js +13 -0
- package/dist/elements/BulkUpload/FormsManager/index.js.map +1 -1
- package/dist/elements/DocumentFields/index.css +8 -0
- package/dist/elements/Hierarchy/Tree/TreeNode/index.css +38 -13
- package/dist/elements/Hierarchy/Tree/TreeNode/index.d.ts.map +1 -1
- package/dist/elements/Hierarchy/Tree/TreeNode/index.js +37 -31
- package/dist/elements/Hierarchy/Tree/TreeNode/index.js.map +1 -1
- package/dist/elements/Hierarchy/Tree/index.css +1 -1
- package/dist/elements/Hierarchy/Tree/index.d.ts.map +1 -1
- package/dist/elements/Hierarchy/Tree/index.js +18 -5
- package/dist/elements/Hierarchy/Tree/index.js.map +1 -1
- package/dist/elements/RelationshipTable/index.css +1 -2
- package/dist/elements/RenderServerComponent/clientOnly.d.ts +8 -0
- package/dist/elements/RenderServerComponent/clientOnly.d.ts.map +1 -0
- package/dist/elements/RenderServerComponent/clientOnly.js +56 -0
- package/dist/elements/RenderServerComponent/clientOnly.js.map +1 -0
- package/dist/elements/SidebarRow/index.css +0 -2
- package/dist/elements/Table/index.css +7 -2
- package/dist/elements/UserMenu/index.d.ts +1 -0
- package/dist/elements/UserMenu/index.d.ts.map +1 -1
- package/dist/elements/UserMenu/index.js +2 -1
- package/dist/elements/UserMenu/index.js.map +1 -1
- package/dist/exports/client/index.d.ts +1 -0
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +1 -86
- package/dist/exports/client/index.js.map +4 -4
- package/dist/exports/rsc/index.d.ts +2 -0
- package/dist/exports/rsc/index.d.ts.map +1 -1
- package/dist/exports/rsc/index.js +2 -0
- package/dist/exports/rsc/index.js.map +1 -1
- package/dist/exports/server.d.ts +3 -0
- package/dist/exports/server.d.ts.map +1 -0
- package/dist/exports/server.js +2 -0
- package/dist/exports/server.js.map +1 -0
- package/dist/exports/shared/index.js.map +2 -2
- package/dist/fields/Group/index.css +1 -7
- package/dist/forms/Form/types.d.ts +2 -2
- package/dist/forms/Form/types.d.ts.map +1 -1
- package/dist/forms/Form/types.js.map +1 -1
- package/dist/forms/RenderFields/index.css +4 -4
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.d.ts +1 -0
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.js +9 -1
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/index.d.ts +2 -2
- package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/index.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/index.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/iterateFields.d.ts +2 -2
- package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/iterateFields.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/iterateFields.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/promise.d.ts +2 -2
- package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/promise.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/promise.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/index.d.ts +2 -1
- package/dist/forms/fieldSchemasToFormState/index.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/index.js +2 -0
- package/dist/forms/fieldSchemasToFormState/index.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/iterateFields.d.ts +2 -1
- package/dist/forms/fieldSchemasToFormState/iterateFields.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/iterateFields.js +2 -0
- package/dist/forms/fieldSchemasToFormState/iterateFields.js.map +1 -1
- package/dist/providers/Auth/index.d.ts +2 -2
- package/dist/providers/Auth/index.d.ts.map +1 -1
- package/dist/providers/Auth/index.js.map +1 -1
- package/dist/providers/DocumentInfo/types.d.ts +2 -2
- package/dist/providers/DocumentInfo/types.d.ts.map +1 -1
- package/dist/providers/DocumentInfo/types.js.map +1 -1
- package/dist/providers/Root/index.d.ts +2 -2
- package/dist/providers/Root/index.d.ts.map +1 -1
- package/dist/providers/Root/index.js.map +1 -1
- package/dist/styles.css +1369 -1
- package/dist/templates/Default/index.d.ts.map +1 -1
- package/dist/templates/Default/index.js +6 -0
- package/dist/templates/Default/index.js.map +1 -1
- package/dist/utilities/buildFormState.d.ts.map +1 -1
- package/dist/utilities/buildFormState.js +1 -0
- package/dist/utilities/buildFormState.js.map +1 -1
- package/dist/utilities/formatRelativeDate.d.ts +15 -0
- package/dist/utilities/formatRelativeDate.d.ts.map +1 -0
- package/dist/utilities/formatRelativeDate.js +62 -0
- package/dist/utilities/formatRelativeDate.js.map +1 -0
- package/dist/utilities/getDocPreferences.d.ts +2 -2
- package/dist/utilities/getDocPreferences.d.ts.map +1 -1
- package/dist/utilities/getDocPreferences.js.map +1 -1
- package/dist/utilities/getDocumentData.d.ts +2 -2
- package/dist/utilities/getDocumentData.d.ts.map +1 -1
- package/dist/utilities/getDocumentData.js.map +1 -1
- package/dist/utilities/getGlobalData.d.ts.map +1 -1
- package/dist/utilities/getGlobalData.js.map +1 -1
- package/dist/utilities/getHasScheduledPublish.d.ts +2 -2
- package/dist/utilities/getHasScheduledPublish.d.ts.map +1 -1
- package/dist/utilities/getHasScheduledPublish.js.map +1 -1
- package/dist/utilities/getIsLocked.d.ts +2 -2
- package/dist/utilities/getIsLocked.d.ts.map +1 -1
- package/dist/utilities/getIsLocked.js.map +1 -1
- package/dist/utilities/getVersions.d.ts +2 -2
- package/dist/utilities/getVersions.d.ts.map +1 -1
- package/dist/utilities/getVersions.js.map +1 -1
- package/dist/utilities/handleAuthRedirect.d.ts +2 -2
- package/dist/utilities/handleAuthRedirect.d.ts.map +1 -1
- package/dist/utilities/handleAuthRedirect.js.map +1 -1
- package/dist/utilities/handleFormStateLocking.d.ts +2 -2
- package/dist/utilities/handleFormStateLocking.d.ts.map +1 -1
- package/dist/utilities/handleFormStateLocking.js.map +1 -1
- package/dist/utilities/handleLivePreview.d.ts.map +1 -1
- package/dist/utilities/recentlyViewed.d.ts +16 -0
- package/dist/utilities/recentlyViewed.d.ts.map +1 -0
- package/dist/utilities/recentlyViewed.js +21 -0
- package/dist/utilities/recentlyViewed.js.map +1 -0
- package/dist/utilities/recentlyViewed.spec.js +92 -0
- package/dist/utilities/recentlyViewed.spec.js.map +1 -0
- package/dist/utilities/serverFunctionRegistry.d.ts +13 -0
- package/dist/utilities/serverFunctionRegistry.d.ts.map +1 -0
- package/dist/utilities/serverFunctionRegistry.js +25 -0
- package/dist/utilities/serverFunctionRegistry.js.map +1 -0
- package/dist/views/Account/ResetPreferences/index.d.ts +2 -2
- package/dist/views/Account/ResetPreferences/index.d.ts.map +1 -1
- package/dist/views/Account/ResetPreferences/index.js.map +1 -1
- package/dist/views/Account/Settings/index.d.ts +2 -2
- package/dist/views/Account/Settings/index.d.ts.map +1 -1
- package/dist/views/Account/Settings/index.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/utils/getItemsFromPreferences.d.ts +2 -2
- package/dist/views/Dashboard/Default/ModularDashboard/utils/getItemsFromPreferences.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/utils/getItemsFromPreferences.js.map +1 -1
- package/dist/views/Document/index.d.ts.map +1 -1
- package/dist/views/Document/index.js +16 -0
- package/dist/views/Document/index.js.map +1 -1
- package/dist/views/Document/recordRecentlyViewed.d.ts +12 -0
- package/dist/views/Document/recordRecentlyViewed.d.ts.map +1 -0
- package/dist/views/Document/recordRecentlyViewed.js +40 -0
- package/dist/views/Document/recordRecentlyViewed.js.map +1 -0
- package/dist/views/Logout/LogoutClient.d.ts +14 -0
- package/dist/views/Logout/LogoutClient.d.ts.map +1 -1
- package/dist/views/Logout/LogoutClient.js +6 -4
- package/dist/views/Logout/LogoutClient.js.map +1 -1
- package/dist/views/Logout/index.d.ts.map +1 -1
- package/dist/views/Logout/index.js +7 -2
- package/dist/views/Logout/index.js.map +1 -1
- package/dist/views/Versions/fetchVersions.d.ts +4 -4
- package/dist/views/Versions/fetchVersions.d.ts.map +1 -1
- package/dist/views/Versions/fetchVersions.js.map +1 -1
- package/dist/views/Versions/types.d.ts +2 -2
- package/dist/views/Versions/types.d.ts.map +1 -1
- package/dist/views/Versions/types.js.map +1 -1
- package/dist/widgets/CollectionCards/getCollectionCardsData.d.ts +20 -0
- package/dist/widgets/CollectionCards/getCollectionCardsData.d.ts.map +1 -0
- package/dist/widgets/CollectionCards/getCollectionCardsData.js +29 -0
- package/dist/widgets/CollectionCards/getCollectionCardsData.js.map +1 -0
- package/dist/widgets/CollectionCards/index.client.d.ts +5 -0
- package/dist/widgets/CollectionCards/index.client.d.ts.map +1 -0
- package/dist/widgets/CollectionCards/index.client.js +139 -0
- package/dist/widgets/CollectionCards/index.client.js.map +1 -0
- package/dist/widgets/CollectionQuery/index.css +10 -152
- package/dist/widgets/CollectionQuery/index.d.ts +0 -1
- package/dist/widgets/CollectionQuery/index.d.ts.map +1 -1
- package/dist/widgets/CollectionQuery/index.js +40 -111
- package/dist/widgets/CollectionQuery/index.js.map +1 -1
- package/dist/widgets/RecentlyViewed/CollectionsField/index.css +14 -0
- package/dist/widgets/RecentlyViewed/CollectionsField/index.d.ts +10 -0
- package/dist/widgets/RecentlyViewed/CollectionsField/index.d.ts.map +1 -0
- package/dist/widgets/RecentlyViewed/CollectionsField/index.js +76 -0
- package/dist/widgets/RecentlyViewed/CollectionsField/index.js.map +1 -0
- package/dist/widgets/RecentlyViewed/index.d.ts +10 -0
- package/dist/widgets/RecentlyViewed/index.d.ts.map +1 -0
- package/dist/widgets/RecentlyViewed/index.js +148 -0
- package/dist/widgets/RecentlyViewed/index.js.map +1 -0
- package/dist/widgets/WidgetCard/index.css +155 -0
- package/dist/widgets/WidgetCard/index.d.ts +19 -0
- package/dist/widgets/WidgetCard/index.d.ts.map +1 -0
- package/dist/widgets/WidgetCard/index.js +49 -0
- package/dist/widgets/WidgetCard/index.js.map +1 -0
- package/package.json +57 -7
- package/dist/exports/client/CodeEditor-T3624SG3.js +0 -14
- package/dist/exports/client/CodeEditor-T3624SG3.js.map +0 -7
- package/dist/exports/client/DatePicker-6KF52Z3G.js +0 -14
- package/dist/exports/client/DatePicker-6KF52Z3G.js.map +0 -7
- package/dist/exports/client/chunk-5LKBKI4T.js +0 -14
- package/dist/exports/client/chunk-5LKBKI4T.js.map +0 -7
- package/dist/exports/client/chunk-7T64ULOM.js +0 -29
- package/dist/exports/client/chunk-7T64ULOM.js.map +0 -7
- package/dist/exports/client/chunk-DMFYTMX6.js +0 -27
- package/dist/exports/client/chunk-DMFYTMX6.js.map +0 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleAuthRedirect.js","names":["formatAdminURL","qs","handleAuthRedirect","config","route","searchParams","user","admin","routes","login","loginRouteFromConfig","unauthorized","unauthorizedRoute","adminRoute","redirect","redirectRoute","Object","keys","length","stringify","addQueryPrefix","redirectTo","path","parsedLoginRouteSearchParams","parse","split","searchParamsWithRedirect"],"sources":["../../src/utilities/handleAuthRedirect.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"handleAuthRedirect.js","names":["formatAdminURL","qs","handleAuthRedirect","config","route","searchParams","user","admin","routes","login","loginRouteFromConfig","unauthorized","unauthorizedRoute","adminRoute","redirect","redirectRoute","Object","keys","length","stringify","addQueryPrefix","redirectTo","path","parsedLoginRouteSearchParams","parse","split","searchParamsWithRedirect"],"sources":["../../src/utilities/handleAuthRedirect.ts"],"sourcesContent":["import type { User } from 'payload'\n\nimport { formatAdminURL } from 'payload/shared'\nimport * as qs from 'qs-esm'\n\ntype Args = {\n config: {\n admin: {\n routes: {\n login: string\n unauthorized: string\n }\n }\n routes: {\n admin: string\n }\n }\n route: string\n searchParams: { [key: string]: string | string[] }\n user?: User\n}\n\n/** Builds the redirect URL for unauthenticated or unauthorized admin access. */\nexport const handleAuthRedirect = ({ config, route, searchParams, user }: Args): string => {\n const {\n admin: {\n routes: { login: loginRouteFromConfig, unauthorized: unauthorizedRoute },\n },\n routes: { admin: adminRoute },\n } = config\n\n if (searchParams && 'redirect' in searchParams) {\n delete searchParams.redirect\n }\n\n const redirectRoute =\n (route !== adminRoute ? route : '') +\n (Object.keys(searchParams ?? {}).length > 0\n ? `${qs.stringify(searchParams, { addQueryPrefix: true })}`\n : '')\n\n const redirectTo = formatAdminURL({\n adminRoute,\n path: (user ? unauthorizedRoute : loginRouteFromConfig) as `/${string}`,\n })\n\n const parsedLoginRouteSearchParams = qs.parse(redirectTo.split('?')[1] ?? '')\n\n const searchParamsWithRedirect = `${qs.stringify(\n {\n ...parsedLoginRouteSearchParams,\n ...(redirectRoute ? { redirect: redirectRoute } : {}),\n },\n { addQueryPrefix: true },\n )}`\n\n return `${redirectTo.split('?', 1)[0]}${searchParamsWithRedirect}`\n}\n"],"mappings":"AAEA,SAASA,cAAc,QAAQ;AAC/B,YAAYC,EAAA,MAAQ;AAmBpB;AACA,OAAO,MAAMC,kBAAA,GAAqBA,CAAC;EAAEC,MAAM;EAAEC,KAAK;EAAEC,YAAY;EAAEC;AAAI,CAAQ;EAC5E,MAAM;IACJC,KAAA,EAAO;MACLC,MAAA,EAAQ;QAAEC,KAAA,EAAOC,oBAAoB;QAAEC,YAAA,EAAcC;MAAiB;IAAE,CACzE;IACDJ,MAAA,EAAQ;MAAED,KAAA,EAAOM;IAAU;EAAE,CAC9B,GAAGV,MAAA;EAEJ,IAAIE,YAAA,IAAgB,cAAcA,YAAA,EAAc;IAC9C,OAAOA,YAAA,CAAaS,QAAQ;EAC9B;EAEA,MAAMC,aAAA,GACJ,CAACX,KAAA,KAAUS,UAAA,GAAaT,KAAA,GAAQ,EAAC,KAChCY,MAAA,CAAOC,IAAI,CAACZ,YAAA,IAAgB,CAAC,GAAGa,MAAM,GAAG,IACtC,GAAGjB,EAAA,CAAGkB,SAAS,CAACd,YAAA,EAAc;IAAEe,cAAA,EAAgB;EAAK,IAAI,GACzD,EAAC;EAEP,MAAMC,UAAA,GAAarB,cAAA,CAAe;IAChCa,UAAA;IACAS,IAAA,EAAOhB,IAAA,GAAOM,iBAAA,GAAoBF;EACpC;EAEA,MAAMa,4BAAA,GAA+BtB,EAAA,CAAGuB,KAAK,CAACH,UAAA,CAAWI,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI;EAE1E,MAAMC,wBAAA,GAA2B,GAAGzB,EAAA,CAAGkB,SAAS,CAC9C;IACE,GAAGI,4BAA4B;IAC/B,IAAIR,aAAA,GAAgB;MAAED,QAAA,EAAUC;IAAc,IAAI,CAAC,CAAC;EACtD,GACA;IAAEK,cAAA,EAAgB;EAAK,IACtB;EAEH,OAAO,GAAGC,UAAA,CAAWI,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE,GAAGC,wBAAA,EAA0B;AACpE","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PayloadRequest,
|
|
1
|
+
import type { PayloadRequest, User } from 'payload';
|
|
2
2
|
type Args = {
|
|
3
3
|
collectionSlug?: string;
|
|
4
4
|
globalSlug?: string;
|
|
@@ -9,7 +9,7 @@ type Args = {
|
|
|
9
9
|
type Result = {
|
|
10
10
|
isLocked: boolean;
|
|
11
11
|
lastEditedAt: string;
|
|
12
|
-
user:
|
|
12
|
+
user: User;
|
|
13
13
|
};
|
|
14
14
|
export declare const handleFormStateLocking: ({ id, collectionSlug, globalSlug, req, updateLastEdited, }: Args) => Promise<Result>;
|
|
15
15
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleFormStateLocking.d.ts","sourceRoot":"","sources":["../../src/utilities/handleFormStateLocking.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"handleFormStateLocking.d.ts","sourceRoot":"","sources":["../../src/utilities/handleFormStateLocking.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAEnD,KAAK,IAAI,GAAG;IACV,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,GAAG,EAAE,cAAc,CAAA;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,CAAA;AAED,KAAK,MAAM,GAAG;IACZ,QAAQ,EAAE,OAAO,CAAA;IACjB,YAAY,EAAE,MAAM,CAAA;IACpB,IAAI,EAAE,IAAI,CAAA;CACX,CAAA;AAID,eAAO,MAAM,sBAAsB,GAAU,4DAM1C,IAAI,KAAG,OAAO,CAAC,MAAM,CAsIvB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleFormStateLocking.js","names":["lockDurationDefault","handleFormStateLocking","id","collectionSlug","globalSlug","req","updateLastEdited","result","payload","collections","lockedDocumentQuery","and","equals","lockDocumentsProp","config","lockDocuments","globals","find","g","slug","lockDuration","duration","lockDurationInMilliseconds","now","Date","getTime","push","updatedAt","greater_than","toISOString","lockedDocument","collection","depth","limit","overrideAccess","pagination","user","where","docs","length","isLocked","lastEditedAt","value","lockOwnerID","db","updateOne","data","returning","deleteExpiredLocksQuery","less_than","deleteMany","create","document","relationTo","undefined"],"sources":["../../src/utilities/handleFormStateLocking.ts"],"sourcesContent":["import type { PayloadRequest,
|
|
1
|
+
{"version":3,"file":"handleFormStateLocking.js","names":["lockDurationDefault","handleFormStateLocking","id","collectionSlug","globalSlug","req","updateLastEdited","result","payload","collections","lockedDocumentQuery","and","equals","lockDocumentsProp","config","lockDocuments","globals","find","g","slug","lockDuration","duration","lockDurationInMilliseconds","now","Date","getTime","push","updatedAt","greater_than","toISOString","lockedDocument","collection","depth","limit","overrideAccess","pagination","user","where","docs","length","isLocked","lastEditedAt","value","lockOwnerID","db","updateOne","data","returning","deleteExpiredLocksQuery","less_than","deleteMany","create","document","relationTo","undefined"],"sources":["../../src/utilities/handleFormStateLocking.ts"],"sourcesContent":["import type { PayloadRequest, User } from 'payload'\n\ntype Args = {\n collectionSlug?: string\n globalSlug?: string\n id?: number | string\n req: PayloadRequest\n updateLastEdited?: boolean\n}\n\ntype Result = {\n isLocked: boolean\n lastEditedAt: string\n user: User\n}\n\nconst lockDurationDefault = 300 // Default 5 minutes in seconds\n\nexport const handleFormStateLocking = async ({\n id,\n collectionSlug,\n globalSlug,\n req,\n updateLastEdited,\n}: Args): Promise<Result> => {\n let result: Result\n\n // Check if the locked-documents collection exists\n if (!req.payload.collections?.['payload-locked-documents']) {\n // If the collection doesn't exist, locking is not available\n return result\n }\n\n if (id || globalSlug) {\n let lockedDocumentQuery\n\n if (collectionSlug) {\n lockedDocumentQuery = {\n and: [\n { 'document.relationTo': { equals: collectionSlug } },\n { 'document.value': { equals: id } },\n ],\n }\n } else if (globalSlug) {\n lockedDocumentQuery = {\n and: [{ globalSlug: { equals: globalSlug } }],\n }\n }\n\n const lockDocumentsProp = collectionSlug\n ? req.payload.collections?.[collectionSlug]?.config.lockDocuments\n : req.payload.config.globals.find((g) => g.slug === globalSlug)?.lockDocuments\n\n const lockDuration =\n typeof lockDocumentsProp === 'object' ? lockDocumentsProp.duration : lockDurationDefault\n const lockDurationInMilliseconds = lockDuration * 1000\n const now = new Date().getTime()\n\n if (lockedDocumentQuery) {\n // Query where the lock is newer than the current time minus the lock duration\n lockedDocumentQuery.and.push({\n updatedAt: {\n greater_than: new Date(now - lockDurationInMilliseconds).toISOString(),\n },\n })\n\n const lockedDocument = await req.payload.find({\n collection: 'payload-locked-documents',\n depth: 1,\n limit: 1,\n overrideAccess: false,\n pagination: false,\n user: req.user,\n where: lockedDocumentQuery,\n })\n\n if (lockedDocument.docs && lockedDocument.docs.length > 0) {\n result = {\n isLocked: true,\n lastEditedAt: lockedDocument.docs[0]?.updatedAt,\n user: lockedDocument.docs[0]?.user?.value,\n }\n\n const lockOwnerID =\n typeof lockedDocument.docs[0]?.user?.value === 'object'\n ? lockedDocument.docs[0]?.user?.value?.id\n : lockedDocument.docs[0]?.user?.value\n // Should only update doc if the incoming / current user is also the owner of the locked doc\n if (updateLastEdited && req.user && lockOwnerID === req.user.id) {\n await req.payload.db.updateOne({\n id: lockedDocument.docs[0].id,\n collection: 'payload-locked-documents',\n data: {},\n returning: false,\n })\n }\n } else {\n // If NO ACTIVE lock document exists, first delete any expired locks and then create a fresh lock\n // Where updatedAt is older than the duration that is specified in the config\n let deleteExpiredLocksQuery\n\n if (collectionSlug) {\n deleteExpiredLocksQuery = {\n and: [\n { 'document.relationTo': { equals: collectionSlug } },\n {\n updatedAt: {\n less_than: new Date(now - lockDurationInMilliseconds).toISOString(),\n },\n },\n ],\n }\n } else if (globalSlug) {\n deleteExpiredLocksQuery = {\n and: [\n { globalSlug: { equals: globalSlug } },\n {\n updatedAt: {\n less_than: new Date(now - lockDurationInMilliseconds).toISOString(),\n },\n },\n ],\n }\n }\n\n await req.payload.db.deleteMany({\n collection: 'payload-locked-documents',\n where: deleteExpiredLocksQuery,\n })\n\n await req.payload.db.create({\n collection: 'payload-locked-documents',\n data: {\n document: collectionSlug\n ? {\n relationTo: collectionSlug,\n value: id,\n }\n : undefined,\n globalSlug: globalSlug ? globalSlug : undefined,\n user: {\n relationTo: req.user.collection,\n value: req.user.id,\n },\n },\n returning: false,\n })\n\n result = {\n isLocked: true,\n lastEditedAt: new Date().toISOString(),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":3,"file":"handleLivePreview.d.ts","sourceRoot":"","sources":["../../src/utilities/handleLivePreview.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,SAAS,EACT,cAAc,EACd,eAAe,EAChB,MAAM,SAAS,CAAA;AAEhB,eAAO,MAAM,oBAAoB,GAAI,mEAKlC;IACD,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;IACnC,MAAM,EAAE,eAAe,CAAA;IACvB,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B,oBAAoB,EAAE,OAAO,CAAA;CAC9B;;;;;;;;
|
|
1
|
+
{"version":3,"file":"handleLivePreview.d.ts","sourceRoot":"","sources":["../../src/utilities/handleLivePreview.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,SAAS,EACT,cAAc,EACd,eAAe,EAChB,MAAM,SAAS,CAAA;AAEhB,eAAO,MAAM,oBAAoB,GAAI,mEAKlC;IACD,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;IACnC,MAAM,EAAE,eAAe,CAAA;IACvB,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B,oBAAoB,EAAE,OAAO,CAAA;CAC9B;;;;;;;;wBAsH6sI,CAAC;;oBAAoF,CAAC;;;;;;;CAlHlyI,CAAA;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,6CAIlC;IACD,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;IACnC,MAAM,EAAE,eAAe,CAAA;IACvB,YAAY,CAAC,EAAE,YAAY,CAAA;CAC5B,KAAG,OAcH,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,GAAU,+DAOrC;IACD,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,eAAe,CAAA;IACvB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,GAAG,EAAE,cAAc,CAAA;CACpB,KAAG,OAAO,CAAC;IACV,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,iBAAiB,CAAC,EAAE,iBAAiB,CAAA;IACrC,cAAc,CAAC,EAAE,kBAAkB,CAAA;CACpC,CAqDA,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { RecentlyViewedItem, RecentlyViewedPreferences } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Maximum number of documents retained in the `recently-viewed` preference. The dashboard widget
|
|
4
|
+
* typically shows fewer; the extra entries act as a buffer once excluded collections are filtered.
|
|
5
|
+
*/
|
|
6
|
+
export declare const recentlyViewedMaxItems = 20;
|
|
7
|
+
/**
|
|
8
|
+
* Returns a new preference value with `item` moved to the front, deduped by collection + id, and
|
|
9
|
+
* capped at `max`. Pure so it can be unit tested and reused as `upsertPreferences`' customMerge.
|
|
10
|
+
*/
|
|
11
|
+
export declare const addRecentlyViewedItem: ({ existing, item, max, }: {
|
|
12
|
+
existing: RecentlyViewedPreferences | undefined;
|
|
13
|
+
item: RecentlyViewedItem;
|
|
14
|
+
max?: number;
|
|
15
|
+
}) => RecentlyViewedPreferences;
|
|
16
|
+
//# sourceMappingURL=recentlyViewed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recentlyViewed.d.ts","sourceRoot":"","sources":["../../src/utilities/recentlyViewed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAE5E;;;GAGG;AACH,eAAO,MAAM,sBAAsB,KAAK,CAAA;AAKxC;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAAI,0BAInC;IACD,QAAQ,EAAE,yBAAyB,GAAG,SAAS,CAAA;IAC/C,IAAI,EAAE,kBAAkB,CAAA;IACxB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,KAAG,yBASH,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maximum number of documents retained in the `recently-viewed` preference. The dashboard widget
|
|
3
|
+
* typically shows fewer; the extra entries act as a buffer once excluded collections are filtered.
|
|
4
|
+
*/export const recentlyViewedMaxItems = 20;
|
|
5
|
+
const isSameDocument = (a, b) => a.collectionSlug === b.collectionSlug && String(a.id) === String(b.id);
|
|
6
|
+
/**
|
|
7
|
+
* Returns a new preference value with `item` moved to the front, deduped by collection + id, and
|
|
8
|
+
* capped at `max`. Pure so it can be unit tested and reused as `upsertPreferences`' customMerge.
|
|
9
|
+
*/
|
|
10
|
+
export const addRecentlyViewedItem = ({
|
|
11
|
+
existing,
|
|
12
|
+
item,
|
|
13
|
+
max = recentlyViewedMaxItems
|
|
14
|
+
}) => {
|
|
15
|
+
const previousItems = Array.isArray(existing?.items) ? existing.items : [];
|
|
16
|
+
const withoutDuplicate = previousItems.filter(existingItem => !isSameDocument(existingItem, item));
|
|
17
|
+
return {
|
|
18
|
+
items: [item, ...withoutDuplicate].slice(0, max)
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=recentlyViewed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recentlyViewed.js","names":["recentlyViewedMaxItems","isSameDocument","a","b","collectionSlug","String","id","addRecentlyViewedItem","existing","item","max","previousItems","Array","isArray","items","withoutDuplicate","filter","existingItem","slice"],"sources":["../../src/utilities/recentlyViewed.ts"],"sourcesContent":["import type { RecentlyViewedItem, RecentlyViewedPreferences } from 'payload'\n\n/**\n * Maximum number of documents retained in the `recently-viewed` preference. The dashboard widget\n * typically shows fewer; the extra entries act as a buffer once excluded collections are filtered.\n */\nexport const recentlyViewedMaxItems = 20\n\nconst isSameDocument = (a: RecentlyViewedItem, b: RecentlyViewedItem) =>\n a.collectionSlug === b.collectionSlug && String(a.id) === String(b.id)\n\n/**\n * Returns a new preference value with `item` moved to the front, deduped by collection + id, and\n * capped at `max`. Pure so it can be unit tested and reused as `upsertPreferences`' customMerge.\n */\nexport const addRecentlyViewedItem = ({\n existing,\n item,\n max = recentlyViewedMaxItems,\n}: {\n existing: RecentlyViewedPreferences | undefined\n item: RecentlyViewedItem\n max?: number\n}): RecentlyViewedPreferences => {\n const previousItems = Array.isArray(existing?.items) ? existing.items : []\n const withoutDuplicate = previousItems.filter(\n (existingItem) => !isSameDocument(existingItem, item),\n )\n\n return {\n items: [item, ...withoutDuplicate].slice(0, max),\n }\n}\n"],"mappings":"AAEA;;;GAIA,OAAO,MAAMA,sBAAA,GAAyB;AAEtC,MAAMC,cAAA,GAAiBA,CAACC,CAAA,EAAuBC,CAAA,KAC7CD,CAAA,CAAEE,cAAc,KAAKD,CAAA,CAAEC,cAAc,IAAIC,MAAA,CAAOH,CAAA,CAAEI,EAAE,MAAMD,MAAA,CAAOF,CAAA,CAAEG,EAAE;AAEvE;;;;AAIA,OAAO,MAAMC,qBAAA,GAAwBA,CAAC;EACpCC,QAAQ;EACRC,IAAI;EACJC,GAAA,GAAMV;AAAsB,CAK7B;EACC,MAAMW,aAAA,GAAgBC,KAAA,CAAMC,OAAO,CAACL,QAAA,EAAUM,KAAA,IAASN,QAAA,CAASM,KAAK,GAAG,EAAE;EAC1E,MAAMC,gBAAA,GAAmBJ,aAAA,CAAcK,MAAM,CAC1CC,YAAA,IAAiB,CAAChB,cAAA,CAAegB,YAAA,EAAcR,IAAA;EAGlD,OAAO;IACLK,KAAA,EAAO,CAACL,IAAA,E,GAASM,gBAAA,CAAiB,CAACG,KAAK,CAAC,GAAGR,GAAA;EAC9C;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { addRecentlyViewedItem, recentlyViewedMaxItems } from './recentlyViewed.js';
|
|
3
|
+
const item = (collectionSlug, id, viewedAt) => ({
|
|
4
|
+
collectionSlug,
|
|
5
|
+
id,
|
|
6
|
+
viewedAt
|
|
7
|
+
});
|
|
8
|
+
describe('addRecentlyViewedItem', () => {
|
|
9
|
+
it('should create the list when there are no existing preferences', () => {
|
|
10
|
+
const next = item('posts', 1, '2026-01-01T00:00:00.000Z');
|
|
11
|
+
const result = addRecentlyViewedItem({
|
|
12
|
+
existing: undefined,
|
|
13
|
+
item: next
|
|
14
|
+
});
|
|
15
|
+
expect(result.items).toEqual([next]);
|
|
16
|
+
});
|
|
17
|
+
it('should prepend the newly viewed document', () => {
|
|
18
|
+
const existing = {
|
|
19
|
+
items: [item('posts', 1, '2026-01-01T00:00:00.000Z')]
|
|
20
|
+
};
|
|
21
|
+
const next = item('pages', 2, '2026-01-02T00:00:00.000Z');
|
|
22
|
+
const result = addRecentlyViewedItem({
|
|
23
|
+
existing,
|
|
24
|
+
item: next
|
|
25
|
+
});
|
|
26
|
+
expect(result.items.map(i => i.id)).toEqual([2, 1]);
|
|
27
|
+
});
|
|
28
|
+
it('should move an already-viewed document to the front and refresh its timestamp', () => {
|
|
29
|
+
const existing = {
|
|
30
|
+
items: [item('pages', 2, '2026-01-02T00:00:00.000Z'), item('posts', 1, '2026-01-01T00:00:00.000Z')]
|
|
31
|
+
};
|
|
32
|
+
const next = item('posts', 1, '2026-01-03T00:00:00.000Z');
|
|
33
|
+
const result = addRecentlyViewedItem({
|
|
34
|
+
existing,
|
|
35
|
+
item: next
|
|
36
|
+
});
|
|
37
|
+
expect(result.items).toEqual([next, item('pages', 2, '2026-01-02T00:00:00.000Z')]);
|
|
38
|
+
});
|
|
39
|
+
it('should treat numeric and string ids consistently when deduping', () => {
|
|
40
|
+
const existing = {
|
|
41
|
+
items: [item('posts', 1, '2026-01-01T00:00:00.000Z')]
|
|
42
|
+
};
|
|
43
|
+
const next = item('posts', '1', '2026-01-02T00:00:00.000Z');
|
|
44
|
+
const result = addRecentlyViewedItem({
|
|
45
|
+
existing,
|
|
46
|
+
item: next
|
|
47
|
+
});
|
|
48
|
+
expect(result.items).toHaveLength(1);
|
|
49
|
+
expect(result.items[0]).toEqual(next);
|
|
50
|
+
});
|
|
51
|
+
it('should not dedupe documents with the same id across different collections', () => {
|
|
52
|
+
const existing = {
|
|
53
|
+
items: [item('posts', 1, '2026-01-01T00:00:00.000Z')]
|
|
54
|
+
};
|
|
55
|
+
const next = item('pages', 1, '2026-01-02T00:00:00.000Z');
|
|
56
|
+
const result = addRecentlyViewedItem({
|
|
57
|
+
existing,
|
|
58
|
+
item: next
|
|
59
|
+
});
|
|
60
|
+
expect(result.items).toHaveLength(2);
|
|
61
|
+
});
|
|
62
|
+
it('should cap the list at the provided max', () => {
|
|
63
|
+
const existing = {
|
|
64
|
+
items: Array.from({
|
|
65
|
+
length: 5
|
|
66
|
+
}, (_, index) => item('posts', index, `2026-01-0${index + 1}T00:00:00.000Z`))
|
|
67
|
+
};
|
|
68
|
+
const next = item('pages', 99, '2026-02-01T00:00:00.000Z');
|
|
69
|
+
const result = addRecentlyViewedItem({
|
|
70
|
+
existing,
|
|
71
|
+
item: next,
|
|
72
|
+
max: 3
|
|
73
|
+
});
|
|
74
|
+
expect(result.items).toHaveLength(3);
|
|
75
|
+
expect(result.items[0]).toEqual(next);
|
|
76
|
+
});
|
|
77
|
+
it('should default the cap to recentlyViewedMaxItems', () => {
|
|
78
|
+
const existing = {
|
|
79
|
+
items: Array.from({
|
|
80
|
+
length: recentlyViewedMaxItems
|
|
81
|
+
}, (_, index) => item('posts', index, '2026-01-01T00:00:00.000Z'))
|
|
82
|
+
};
|
|
83
|
+
const next = item('pages', 99, '2026-02-01T00:00:00.000Z');
|
|
84
|
+
const result = addRecentlyViewedItem({
|
|
85
|
+
existing,
|
|
86
|
+
item: next
|
|
87
|
+
});
|
|
88
|
+
expect(result.items).toHaveLength(recentlyViewedMaxItems);
|
|
89
|
+
expect(result.items[0]).toEqual(next);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
//# sourceMappingURL=recentlyViewed.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recentlyViewed.spec.js","names":["describe","expect","it","addRecentlyViewedItem","recentlyViewedMaxItems","item","collectionSlug","id","viewedAt","next","result","existing","undefined","items","toEqual","map","i","toHaveLength","Array","from","length","_","index","max"],"sources":["../../src/utilities/recentlyViewed.spec.ts"],"sourcesContent":["import type { RecentlyViewedItem } from 'payload'\n\nimport { describe, expect, it } from 'vitest'\n\nimport { addRecentlyViewedItem, recentlyViewedMaxItems } from './recentlyViewed.js'\n\nconst item = (\n collectionSlug: string,\n id: number | string,\n viewedAt: string,\n): RecentlyViewedItem => ({\n collectionSlug,\n id,\n viewedAt,\n})\n\ndescribe('addRecentlyViewedItem', () => {\n it('should create the list when there are no existing preferences', () => {\n const next = item('posts', 1, '2026-01-01T00:00:00.000Z')\n\n const result = addRecentlyViewedItem({ existing: undefined, item: next })\n\n expect(result.items).toEqual([next])\n })\n\n it('should prepend the newly viewed document', () => {\n const existing = { items: [item('posts', 1, '2026-01-01T00:00:00.000Z')] }\n const next = item('pages', 2, '2026-01-02T00:00:00.000Z')\n\n const result = addRecentlyViewedItem({ existing, item: next })\n\n expect(result.items.map((i) => i.id)).toEqual([2, 1])\n })\n\n it('should move an already-viewed document to the front and refresh its timestamp', () => {\n const existing = {\n items: [\n item('pages', 2, '2026-01-02T00:00:00.000Z'),\n item('posts', 1, '2026-01-01T00:00:00.000Z'),\n ],\n }\n const next = item('posts', 1, '2026-01-03T00:00:00.000Z')\n\n const result = addRecentlyViewedItem({ existing, item: next })\n\n expect(result.items).toEqual([next, item('pages', 2, '2026-01-02T00:00:00.000Z')])\n })\n\n it('should treat numeric and string ids consistently when deduping', () => {\n const existing = { items: [item('posts', 1, '2026-01-01T00:00:00.000Z')] }\n const next = item('posts', '1', '2026-01-02T00:00:00.000Z')\n\n const result = addRecentlyViewedItem({ existing, item: next })\n\n expect(result.items).toHaveLength(1)\n expect(result.items[0]).toEqual(next)\n })\n\n it('should not dedupe documents with the same id across different collections', () => {\n const existing = { items: [item('posts', 1, '2026-01-01T00:00:00.000Z')] }\n const next = item('pages', 1, '2026-01-02T00:00:00.000Z')\n\n const result = addRecentlyViewedItem({ existing, item: next })\n\n expect(result.items).toHaveLength(2)\n })\n\n it('should cap the list at the provided max', () => {\n const existing = {\n items: Array.from({ length: 5 }, (_, index) =>\n item('posts', index, `2026-01-0${index + 1}T00:00:00.000Z`),\n ),\n }\n const next = item('pages', 99, '2026-02-01T00:00:00.000Z')\n\n const result = addRecentlyViewedItem({ existing, item: next, max: 3 })\n\n expect(result.items).toHaveLength(3)\n expect(result.items[0]).toEqual(next)\n })\n\n it('should default the cap to recentlyViewedMaxItems', () => {\n const existing = {\n items: Array.from({ length: recentlyViewedMaxItems }, (_, index) =>\n item('posts', index, '2026-01-01T00:00:00.000Z'),\n ),\n }\n const next = item('pages', 99, '2026-02-01T00:00:00.000Z')\n\n const result = addRecentlyViewedItem({ existing, item: next })\n\n expect(result.items).toHaveLength(recentlyViewedMaxItems)\n expect(result.items[0]).toEqual(next)\n })\n})\n"],"mappings":"AAEA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ;AAErC,SAASC,qBAAqB,EAAEC,sBAAsB,QAAQ;AAE9D,MAAMC,IAAA,GAAOA,CACXC,cAAA,EACAC,EAAA,EACAC,QAAA,MACwB;EACxBF,cAAA;EACAC,EAAA;EACAC;AACF;AAEAR,QAAA,CAAS,yBAAyB;EAChCE,EAAA,CAAG,iEAAiE;IAClE,MAAMO,IAAA,GAAOJ,IAAA,CAAK,SAAS,GAAG;IAE9B,MAAMK,MAAA,GAASP,qBAAA,CAAsB;MAAEQ,QAAA,EAAUC,SAAA;MAAWP,IAAA,EAAMI;IAAK;IAEvER,MAAA,CAAOS,MAAA,CAAOG,KAAK,EAAEC,OAAO,CAAC,CAACL,IAAA,CAAK;EACrC;EAEAP,EAAA,CAAG,4CAA4C;IAC7C,MAA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[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ServerFunction } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Framework-agnostic server function handlers shared across all adapters.
|
|
4
|
+
*
|
|
5
|
+
* Each handler returns a value that may contain React elements (e.g.
|
|
6
|
+
* `customComponents` inside form state, the `Document` / `List` nodes returned
|
|
7
|
+
* by render-document / render-list). Adapters are expected to ship those over
|
|
8
|
+
* the wire as RSC payloads — Next.js's runtime does this natively, while the
|
|
9
|
+
* TanStack Start adapter pipes the result through `serializeForRsc` to convert
|
|
10
|
+
* elements into `renderServerComponent` handles.
|
|
11
|
+
*/
|
|
12
|
+
export declare const sharedServerFunctions: Record<string, ServerFunction<any, any>>;
|
|
13
|
+
//# sourceMappingURL=serverFunctionRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serverFunctionRegistry.d.ts","sourceRoot":"","sources":["../../src/utilities/serverFunctionRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAS7C;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,EAAE,GAAG,CAAC,CAO1E,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { renderDocumentHandler } from '../views/Document/handleServerFunction.js';
|
|
2
|
+
import { renderListHandler } from '../views/List/handleServerFunction.js';
|
|
3
|
+
import { buildFormStateHandler } from './buildFormState.js';
|
|
4
|
+
import { buildTableStateHandler } from './buildTableState.js';
|
|
5
|
+
import { copyDataFromLocaleHandler } from './copyDataFromLocale.js';
|
|
6
|
+
import { schedulePublishHandler } from './schedulePublishHandler.js';
|
|
7
|
+
/**
|
|
8
|
+
* Framework-agnostic server function handlers shared across all adapters.
|
|
9
|
+
*
|
|
10
|
+
* Each handler returns a value that may contain React elements (e.g.
|
|
11
|
+
* `customComponents` inside form state, the `Document` / `List` nodes returned
|
|
12
|
+
* by render-document / render-list). Adapters are expected to ship those over
|
|
13
|
+
* the wire as RSC payloads — Next.js's runtime does this natively, while the
|
|
14
|
+
* TanStack Start adapter pipes the result through `serializeForRsc` to convert
|
|
15
|
+
* elements into `renderServerComponent` handles.
|
|
16
|
+
*/
|
|
17
|
+
export const sharedServerFunctions = {
|
|
18
|
+
'copy-data-from-locale': copyDataFromLocaleHandler,
|
|
19
|
+
'form-state': buildFormStateHandler,
|
|
20
|
+
'render-document': renderDocumentHandler,
|
|
21
|
+
'render-list': renderListHandler,
|
|
22
|
+
'schedule-publish': schedulePublishHandler,
|
|
23
|
+
'table-state': buildTableStateHandler
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=serverFunctionRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serverFunctionRegistry.js","names":["renderDocumentHandler","renderListHandler","buildFormStateHandler","buildTableStateHandler","copyDataFromLocaleHandler","schedulePublishHandler","sharedServerFunctions"],"sources":["../../src/utilities/serverFunctionRegistry.ts"],"sourcesContent":["import type { ServerFunction } from 'payload'\n\nimport { renderDocumentHandler } from '../views/Document/handleServerFunction.js'\nimport { renderListHandler } from '../views/List/handleServerFunction.js'\nimport { buildFormStateHandler } from './buildFormState.js'\nimport { buildTableStateHandler } from './buildTableState.js'\nimport { copyDataFromLocaleHandler } from './copyDataFromLocale.js'\nimport { schedulePublishHandler } from './schedulePublishHandler.js'\n\n/**\n * Framework-agnostic server function handlers shared across all adapters.\n *\n * Each handler returns a value that may contain React elements (e.g.\n * `customComponents` inside form state, the `Document` / `List` nodes returned\n * by render-document / render-list). Adapters are expected to ship those over\n * the wire as RSC payloads — Next.js's runtime does this natively, while the\n * TanStack Start adapter pipes the result through `serializeForRsc` to convert\n * elements into `renderServerComponent` handles.\n */\nexport const sharedServerFunctions: Record<string, ServerFunction<any, any>> = {\n 'copy-data-from-locale': copyDataFromLocaleHandler,\n 'form-state': buildFormStateHandler,\n 'render-document': renderDocumentHandler,\n 'render-list': renderListHandler,\n 'schedule-publish': schedulePublishHandler,\n 'table-state': buildTableStateHandler,\n}\n"],"mappings":"AAEA,SAASA,qBAAqB,QAAQ;AACtC,SAASC,iBAAiB,QAAQ;AAClC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,sBAAsB,QAAQ;AACvC,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,sBAAsB,QAAQ;AAEvC;;;;;;;;;;AAUA,OAAO,MAAMC,qBAAA,GAAkE;EAC7E,yBAAyBF,yBAAA;EACzB,cAAcF,qBAAA;EACd,mBAAmBF,qBAAA;EACnB,eAAeC,iBAAA;EACf,oBAAoBI,sBAAA;EACpB,eAAeF;AACjB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/Account/ResetPreferences/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/Account/ResetPreferences/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAenC,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC;IACtC,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAA;CACrB,CAsEA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","formatAdminURL","qs","Fragment","useCallback","toast","Button","ConfirmationModal","useModal","useConfig","useTranslation","confirmResetModalSlug","ResetPreferences","t0","$","user","openModal","t","config","t1","routes","t2","api","apiRoute","t3","stringifiedQuery","stringify","depth","where","equals","id","addQueryPrefix","res","fetch","path","credentials","headers","method","json","message","ok","success","error","t4","_err","handleResetPreferences","t5","_jsxs","children","_jsx","className","buttonStyle","onClick","body","confirmingLabel","heading","modalSlug","onConfirm"],"sources":["../../../../src/views/Account/ResetPreferences/index.tsx"],"sourcesContent":["'use client'\nimport type {
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","formatAdminURL","qs","Fragment","useCallback","toast","Button","ConfirmationModal","useModal","useConfig","useTranslation","confirmResetModalSlug","ResetPreferences","t0","$","user","openModal","t","config","t1","routes","t2","api","apiRoute","t3","stringifiedQuery","stringify","depth","where","equals","id","addQueryPrefix","res","fetch","path","credentials","headers","method","json","message","ok","success","error","t4","_err","handleResetPreferences","t5","_jsxs","children","_jsx","className","buttonStyle","onClick","body","confirmingLabel","heading","modalSlug","onConfirm"],"sources":["../../../../src/views/Account/ResetPreferences/index.tsx"],"sourcesContent":["'use client'\nimport type { User } from 'payload'\n\nimport { formatAdminURL } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport { Fragment, useCallback } from 'react'\nimport { toast } from 'sonner'\n\nimport { Button } from '../../../elements/Button/index.js'\nimport { ConfirmationModal } from '../../../elements/ConfirmationModal/index.js'\nimport { useModal } from '../../../elements/Modal/index.js'\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\n\nconst confirmResetModalSlug = 'confirm-reset-modal'\n\nexport const ResetPreferences: React.FC<{\n readonly user?: User\n}> = ({ user }) => {\n const { openModal } = useModal()\n const { t } = useTranslation()\n const {\n config: {\n routes: { api: apiRoute },\n },\n } = useConfig()\n\n const handleResetPreferences = useCallback(async () => {\n if (!user) {\n return\n }\n\n const stringifiedQuery = qs.stringify(\n {\n depth: 0,\n where: {\n 'user.value': {\n equals: user.id,\n },\n },\n },\n { addQueryPrefix: true },\n )\n\n try {\n const res = await fetch(\n formatAdminURL({\n apiRoute,\n path: `/payload-preferences${stringifiedQuery}`,\n }),\n {\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'DELETE',\n },\n )\n\n const json = await res.json()\n const message = json.message\n\n if (res.ok) {\n toast.success(message)\n } else {\n toast.error(message)\n }\n } catch (_err) {\n // swallow error\n }\n }, [apiRoute, user])\n\n return (\n <Fragment>\n <div className=\"payload-reset-preferences\">\n <Button buttonStyle=\"secondary\" onClick={() => openModal(confirmResetModalSlug)}>\n {t('general:resetPreferences')}\n </Button>\n </div>\n <ConfirmationModal\n body={t('general:resetPreferencesDescription')}\n confirmingLabel={t('general:resettingPreferences')}\n heading={t('general:resetPreferences')}\n modalSlug={confirmResetModalSlug}\n onConfirm={handleResetPreferences}\n />\n </Fragment>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,cAAc,QAAQ;AAC/B,YAAYC,EAAA,MAAQ;AACpB,SAASC,QAAQ,EAAEC,WAAW,QAAQ;AACtC,SAASC,KAAK,QAAQ;AAEtB,SAASC,MAAM,QAAQ;AACvB,SAASC,iBAAiB,QAAQ;AAClC,SAASC,QAAQ,QAAQ;AACzB,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAE/B,MAAMC,qBAAA,GAAwB;AAE9B,OAAO,MAAMC,gBAAA,GAERC,EAAA;EAAA,MAAAC,CAAA,GAAAd,EAAA;EAAC;IAAAe;EAAA,IAAAF,EAAQ;EACZ;IAAAG;EAAA,IAAsBR,QAAA;EACtB;IAAAS;EAAA,IAAcP,cAAA;EACd;IAAAQ,MAAA,EAAAC;EAAA,IAIIV,SAAA;EAHM;IAAAW,MAAA,EAAAC;EAAA,IAAAF,EAEP;EADS;IAAAG,GAAA,EAAAC;EAAA,IAAAF,EAAiB;EAAA,IAAAG,EAAA;EAAA,IAAAV,CAAA,QAAAS,QAAA,IAAAT,CAAA,QAAAC,IAAA;IAIcS,EAAA,SAAAA,CAAA;MAAA,KACpCT,IAAA;QAAA;MAAA;MAIL,MAAAU,gBAAA,GAAyBvB,EAAA,CAAAwB,SAAA;QAAAC,KAAA;QAAAC,KAAA;UAAA;YAAAC,MAAA,EAKTd,IAAA,CAAAe;UAAA;QAAA;MAAA;QAAAC,cAAA;MAAA,CAIS;MAAA;MAA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,iBAAA;QAAA8C,IAAA,EACQpC,CAAA,CAAE;QAAAqC,eAAA,EACSrC,CAAA,CAAE;QAAAsC,OAAA,EACVtC,CAAA,CAAE;QAAAuC,SAAA,EAAA7C,qBAAA;QAAA8C,SAAA,EAEAZ;MAAA,C;;;;;;;;;SAXfC,E;CAeJ","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { I18n } from '@payloadcms/translations';
|
|
2
|
-
import type { BasePayload, Config, LanguageOptions,
|
|
2
|
+
import type { BasePayload, Config, LanguageOptions, User } from 'payload';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import './index.css';
|
|
5
5
|
export declare const Settings: React.FC<{
|
|
@@ -8,6 +8,6 @@ export declare const Settings: React.FC<{
|
|
|
8
8
|
readonly languageOptions: LanguageOptions;
|
|
9
9
|
readonly payload: BasePayload;
|
|
10
10
|
readonly theme: Config['admin']['theme'];
|
|
11
|
-
readonly user?:
|
|
11
|
+
readonly user?: User;
|
|
12
12
|
}>;
|
|
13
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/Account/Settings/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/Account/Settings/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAEzE,OAAO,KAAK,MAAM,OAAO,CAAA;AAWzB,OAAO,aAAa,CAAA;AAIpB,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;IACnB,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAA;IACzC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAA;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAA;IACxC,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAA;CACrB,CAeA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","FieldLabel","AccountLanguageSelector","LanguageSelector","AccountResetPreferences","ResetPreferences","AccountToggleHighContrast","ToggleHighContrast","AccountToggleTheme","ToggleTheme","baseClass","Settings","props","className","i18n","languageOptions","theme","user","_jsxs","filter","Boolean","join","_jsx","t","htmlFor","label"],"sources":["../../../../src/views/Account/Settings/index.tsx"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { BasePayload, Config, LanguageOptions,
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","FieldLabel","AccountLanguageSelector","LanguageSelector","AccountResetPreferences","ResetPreferences","AccountToggleHighContrast","ToggleHighContrast","AccountToggleTheme","ToggleTheme","baseClass","Settings","props","className","i18n","languageOptions","theme","user","_jsxs","filter","Boolean","join","_jsx","t","htmlFor","label"],"sources":["../../../../src/views/Account/Settings/index.tsx"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { BasePayload, Config, LanguageOptions, User } from 'payload'\n\nimport React from 'react'\n\n/* eslint-disable payload/no-imports-from-exports-dir -- Server component must reference exports/client bundle for proper client boundary in prod builds */\nimport {\n FieldLabel,\n AccountLanguageSelector as LanguageSelector,\n AccountResetPreferences as ResetPreferences,\n AccountToggleHighContrast as ToggleHighContrast,\n AccountToggleTheme as ToggleTheme,\n} from '../../../exports/client/index.js'\n/* eslint-enable payload/no-imports-from-exports-dir */\nimport './index.css'\n\nconst baseClass = 'payload-settings'\n\nexport const Settings: React.FC<{\n readonly className?: string\n readonly i18n: I18n\n readonly languageOptions: LanguageOptions\n readonly payload: BasePayload\n readonly theme: Config['admin']['theme']\n readonly user?: User\n}> = (props) => {\n const { className, i18n, languageOptions, theme, user } = props\n\n return (\n <div className={[baseClass, className].filter(Boolean).join(' ')}>\n <h3>{i18n.t('general:payloadSettings')}</h3>\n <div className={`${baseClass}__language`}>\n <FieldLabel htmlFor=\"language-select\" label={i18n.t('general:language')} />\n <LanguageSelector languageOptions={languageOptions} />\n </div>\n {theme === 'all' && <ToggleTheme />}\n <ToggleHighContrast />\n <ResetPreferences user={user} />\n </div>\n )\n}\n"],"mappings":";AAGA,OAAOA,KAAA,MAAW;AAElB;AACA,SACEC,UAAU,EACVC,uBAAA,IAA2BC,gBAAgB,EAC3CC,uBAAA,IAA2BC,gBAAgB,EAC3CC,yBAAA,IAA6BC,kBAAkB,EAC/CC,kBAAA,IAAsBC,WAAW,QAC5B;AACP;AACA,OAAO;AAEP,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,QAAA,GAOPC,KAAA;EACJ,MAAM;IAAEC,SAAS;IAAEC,IAAI;IAAEC,eAAe;IAAEC,KAAK;IAAEC;EAAI,CAAE,GAAGL,KAAA;EAE1D,oBACEM,KAAA,CAAC;IAAIL,SAAA,EAAW,CAACH,SAAA,EAAWG,SAAA,CAAU,CAACM,MAAM,CAACC,OAAA,EAASC,IAAI,CAAC;4BAC1DC,IAAA,CAAC;gBAAIR,IAAA,CAAKS,CAAC,CAAC;qBACZL,KAAA,CAAC;MAAIL,SAAA,EAAW,GAAGH,SAAA,YAAqB;8BACtCY,IAAA,CAACrB,UAAA;QAAWuB,OAAA,EAAQ;QAAkBC,KAAA,EAAOX,IAAA,CAAKS,CAAC,CAAC;uBACpDD,IAAA,CAACnB,gBAAA;QAAiBY,eAAA,EAAiBA;;QAEpCC,KAAA,KAAU,sBAASM,IAAA,CAACb,WAAA,O,aACrBa,IAAA,CAACf,kBAAA,O,aACDe,IAAA,CAACjB,gBAAA;MAAiBY,IAAA,EAAMA;;;AAG9B","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BasePayload,
|
|
1
|
+
import type { BasePayload, User } from 'payload';
|
|
2
2
|
import type { WidgetItem } from '../index.client.js';
|
|
3
|
-
export declare function getItemsFromPreferences(payload: BasePayload, user:
|
|
3
|
+
export declare function getItemsFromPreferences(payload: BasePayload, user: User): Promise<null | WidgetItem[]>;
|
|
4
4
|
//# sourceMappingURL=getItemsFromPreferences.d.ts.map
|
package/dist/views/Dashboard/Default/ModularDashboard/utils/getItemsFromPreferences.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getItemsFromPreferences.d.ts","sourceRoot":"","sources":["../../../../../../src/views/Dashboard/Default/ModularDashboard/utils/getItemsFromPreferences.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"getItemsFromPreferences.d.ts","sourceRoot":"","sources":["../../../../../../src/views/Dashboard/Default/ModularDashboard/utils/getItemsFromPreferences.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAIhD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAIpD,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,WAAW,EACpB,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,IAAI,GAAG,UAAU,EAAE,CAAC,CAe9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getItemsFromPreferences.js","names":["PREFERENCE_KEYS","getPreferences","getItemsFromPreferences","payload","user","savedPreferences","DASHBOARD_LAYOUT","id","collection","value","layouts"],"sources":["../../../../../../src/views/Dashboard/Default/ModularDashboard/utils/getItemsFromPreferences.ts"],"sourcesContent":["import type { BasePayload,
|
|
1
|
+
{"version":3,"file":"getItemsFromPreferences.js","names":["PREFERENCE_KEYS","getPreferences","getItemsFromPreferences","payload","user","savedPreferences","DASHBOARD_LAYOUT","id","collection","value","layouts"],"sources":["../../../../../../src/views/Dashboard/Default/ModularDashboard/utils/getItemsFromPreferences.ts"],"sourcesContent":["import type { BasePayload, User } from 'payload'\n\nimport { PREFERENCE_KEYS } from 'payload/shared'\n\nimport type { WidgetItem } from '../index.client.js'\n\nimport { getPreferences } from '../../../../../utilities/upsertPreferences.js'\n\nexport async function getItemsFromPreferences(\n payload: BasePayload,\n user: User,\n): Promise<null | WidgetItem[]> {\n const savedPreferences = await getPreferences(\n PREFERENCE_KEYS.DASHBOARD_LAYOUT,\n payload,\n user.id,\n user.collection,\n )\n if (\n !savedPreferences?.value ||\n typeof savedPreferences.value !== 'object' ||\n !('layouts' in savedPreferences.value)\n ) {\n return null\n }\n return savedPreferences.value.layouts as null | WidgetItem[]\n}\n"],"mappings":"AAEA,SAASA,eAAe,QAAQ;AAIhC,SAASC,cAAc,QAAQ;AAE/B,OAAO,eAAeC,wBACpBC,OAAoB,EACpBC,IAAU;EAEV,MAAMC,gBAAA,GAAmB,MAAMJ,cAAA,CAC7BD,eAAA,CAAgBM,gBAAgB,EAChCH,OAAA,EACAC,IAAA,CAAKG,EAAE,EACPH,IAAA,CAAKI,UAAU;EAEjB,IACE,CAACH,gBAAA,EAAkBI,KAAA,IACnB,OAAOJ,gBAAA,CAAiBI,KAAK,KAAK,YAClC,EAAE,aAAaJ,gBAAA,CAAiBI,KAAK,CAAD,EACpC;IACA,OAAO;EACT;EACA,OAAOJ,gBAAA,CAAiBI,KAAK,CAACC,OAAO;AACvC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Document/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EAEpB,IAAI,EACJ,uBAAuB,EACvB,uBAAuB,EAEvB,iBAAiB,EACjB,gBAAgB,EAChB,gCAAgC,EACjC,MAAM,SAAS,CAAA;AAIhB,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Document/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EAEpB,IAAI,EACJ,uBAAuB,EACvB,uBAAuB,EAEvB,iBAAiB,EACjB,gBAAgB,EAChB,gCAAgC,EACjC,MAAM,SAAS,CAAA;AAIhB,OAAO,KAAK,MAAM,OAAO,CAAA;AA6BzB,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEtD,MAAM,MAAM,YAAY,GACpB,iBAAiB,GACjB,gBAAgB,CAAC,uBAAuB,CAAC,GACzC,KAAK,CAAC,EAAE,GACR,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAAC,CAAA;AAErC;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAU,0PAgBlC;IACD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAA;IACtC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAA;IACtC,QAAQ,CAAC,sBAAsB,CAAC,EAAE,OAAO,CAAA;IACzC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,OAAO,CAAA;IACvC,QAAQ,CAAC,EAAE,gCAAgC,CAAA;CAC5C,GAAG,oBAAoB,KAAG,OAAO,CAAC;IACjC,IAAI,EAAE,IAAI,CAAA;IACV,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,CAoZA,CAAA;AAED,wBAAsB,YAAY,CAAC,KAAK,EAAE,oBAAoB,+QAuB7D"}
|
|
@@ -21,6 +21,7 @@ import { getPreferences } from '../../utilities/upsertPreferences.js';
|
|
|
21
21
|
import { NotFoundView } from '../NotFound/index.js';
|
|
22
22
|
import { UnauthorizedViewWithGutter } from '../Unauthorized/index.js';
|
|
23
23
|
import { getDocumentView } from './getDocumentView.js';
|
|
24
|
+
import { recordRecentlyViewed } from './recordRecentlyViewed.js';
|
|
24
25
|
import { renderDocumentSlots } from './renderDocumentSlots.js';
|
|
25
26
|
export { getDocumentView } from './getDocumentView.js';
|
|
26
27
|
/**
|
|
@@ -160,6 +161,13 @@ export const renderDocument = async ({
|
|
|
160
161
|
// get entity preferences
|
|
161
162
|
getPreferences(collectionSlug ? `collection-${collectionSlug}` : `global-${globalSlug}`, payload, req.user.id, req.user.collection)]);
|
|
162
163
|
const operation = collectionSlug && idFromArgs || globalSlug ? 'update' : 'create';
|
|
164
|
+
// Record the document as recently viewed (collections only, never on the create route or for
|
|
165
|
+
// trashed docs). Runs concurrently with the work below and never throws.
|
|
166
|
+
const recentlyViewedPromise = collectionSlug && idFromArgs && doc && !isTrashedDoc ? recordRecentlyViewed({
|
|
167
|
+
id: idFromArgs,
|
|
168
|
+
collectionSlug,
|
|
169
|
+
req
|
|
170
|
+
}) : undefined;
|
|
163
171
|
const [{
|
|
164
172
|
hasPublishedDoc,
|
|
165
173
|
mostRecentVersionIsAutosaved,
|
|
@@ -199,6 +207,7 @@ export const renderDocument = async ({
|
|
|
199
207
|
payload,
|
|
200
208
|
user
|
|
201
209
|
})]);
|
|
210
|
+
await recentlyViewedPromise;
|
|
202
211
|
const documentViewServerProps = {
|
|
203
212
|
doc,
|
|
204
213
|
hasPublishedDoc,
|
|
@@ -399,6 +408,13 @@ export async function DocumentView(props) {
|
|
|
399
408
|
if (error?.message === 'NEXT_REDIRECT') {
|
|
400
409
|
throw error;
|
|
401
410
|
}
|
|
411
|
+
// The TanStack adapter's `req.server.redirect()` throws `redirect:<url>` as a
|
|
412
|
+
// control-flow signal — the target is already recorded on `req.server` and
|
|
413
|
+
// honored upstream in `loadAdminPage`. It isn't a real error, so swallow it
|
|
414
|
+
// without logging, mirroring the `NEXT_REDIRECT` guard above.
|
|
415
|
+
if (error?.message?.startsWith('redirect:')) {
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
402
418
|
logError({
|
|
403
419
|
err: error,
|
|
404
420
|
payload: props.initPageResult.req.payload
|