@payloadcms/next 3.0.0-beta.23 → 3.0.0-beta.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/exports/utilities.d.ts +1 -1
- package/dist/exports/utilities.d.ts.map +1 -1
- package/dist/exports/utilities.js +1 -1
- package/dist/exports/utilities.js.map +1 -1
- package/dist/routes/rest/buildFormState.d.ts.map +1 -1
- package/dist/routes/rest/buildFormState.js +1 -0
- package/dist/routes/rest/buildFormState.js.map +1 -1
- package/dist/utilities/initPage/handleAdminPage.d.ts +13 -0
- package/dist/utilities/initPage/handleAdminPage.d.ts.map +1 -0
- package/dist/utilities/initPage/handleAdminPage.js +35 -0
- package/dist/utilities/initPage/handleAdminPage.js.map +1 -0
- package/dist/utilities/initPage/handleAuthRedirect.d.ts +9 -0
- package/dist/utilities/initPage/handleAuthRedirect.d.ts.map +1 -0
- package/dist/utilities/initPage/handleAuthRedirect.js +26 -0
- package/dist/utilities/initPage/handleAuthRedirect.js.map +1 -0
- package/dist/utilities/initPage/index.d.ts +4 -0
- package/dist/utilities/initPage/index.d.ts.map +1 -0
- package/dist/utilities/initPage/index.js +89 -0
- package/dist/utilities/initPage/index.js.map +1 -0
- package/dist/utilities/initPage/shared.d.ts +4 -0
- package/dist/utilities/initPage/shared.d.ts.map +1 -0
- package/dist/utilities/initPage/shared.js +17 -0
- package/dist/utilities/initPage/shared.js.map +1 -0
- package/dist/utilities/initPage/types.d.ts +24 -0
- package/dist/utilities/initPage/types.d.ts.map +1 -0
- package/dist/utilities/initPage/types.js +3 -0
- package/dist/utilities/initPage/types.js.map +1 -0
- package/dist/views/NotFound/index.js +1 -1
- package/dist/views/NotFound/index.js.map +1 -1
- package/dist/views/Root/getViewFromConfig.d.ts +1 -1
- package/dist/views/Root/getViewFromConfig.d.ts.map +1 -1
- package/dist/views/Root/getViewFromConfig.js.map +1 -1
- package/dist/views/Root/index.js +1 -1
- package/dist/views/Root/index.js.map +1 -1
- package/package.json +7 -7
- package/dist/utilities/initPage.d.ts +0 -12
- package/dist/utilities/initPage.d.ts.map +0 -1
- package/dist/utilities/initPage.js +0 -113
- package/dist/utilities/initPage.js.map +0 -1
|
@@ -5,5 +5,5 @@ export { createPayloadRequest } from '../utilities/createPayloadRequest.js';
|
|
|
5
5
|
export { getNextRequestI18n } from '../utilities/getNextRequestI18n.js';
|
|
6
6
|
export { getPayloadHMR, reload } from '../utilities/getPayloadHMR.js';
|
|
7
7
|
export { headersWithCors } from '../utilities/headersWithCors.js';
|
|
8
|
-
export { initPage } from '../utilities/initPage.js';
|
|
8
|
+
export { initPage } from '../utilities/initPage/index.js';
|
|
9
9
|
//# sourceMappingURL=utilities.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../src/exports/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAA;AACjF,OAAO,EAAE,2BAA2B,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AAClG,OAAO,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAA;AACnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAA;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAA;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAA;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../src/exports/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAA;AACjF,OAAO,EAAE,2BAA2B,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AAClG,OAAO,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAA;AACnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAA;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAA;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAA;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAA"}
|
|
@@ -5,6 +5,6 @@ export { createPayloadRequest } from '../utilities/createPayloadRequest.js';
|
|
|
5
5
|
export { getNextRequestI18n } from '../utilities/getNextRequestI18n.js';
|
|
6
6
|
export { getPayloadHMR, reload } from '../utilities/getPayloadHMR.js';
|
|
7
7
|
export { headersWithCors } from '../utilities/headersWithCors.js';
|
|
8
|
-
export { initPage } from '../utilities/initPage.js';
|
|
8
|
+
export { initPage } from '../utilities/initPage/index.js';
|
|
9
9
|
|
|
10
10
|
//# sourceMappingURL=utilities.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/exports/utilities.ts"],"sourcesContent":["export { addDataAndFileToRequest } from '../utilities/addDataAndFileToRequest.js'\nexport { addLocalesToRequestFromData, sanitizeLocales } from '../utilities/addLocalesToRequest.js'\nexport { traverseFields } from '../utilities/buildFieldSchemaMap/traverseFields.js'\nexport { createPayloadRequest } from '../utilities/createPayloadRequest.js'\nexport { getNextRequestI18n } from '../utilities/getNextRequestI18n.js'\nexport { getPayloadHMR, reload } from '../utilities/getPayloadHMR.js'\nexport { headersWithCors } from '../utilities/headersWithCors.js'\nexport { initPage } from '../utilities/initPage.js'\n"],"names":["addDataAndFileToRequest","addLocalesToRequestFromData","sanitizeLocales","traverseFields","createPayloadRequest","getNextRequestI18n","getPayloadHMR","reload","headersWithCors","initPage"],"rangeMappings":";;;;;;;","mappings":"AAAA,SAASA,uBAAuB,QAAQ,0CAAyC;AACjF,SAASC,2BAA2B,EAAEC,eAAe,QAAQ,sCAAqC;AAClG,SAASC,cAAc,QAAQ,qDAAoD;AACnF,SAASC,oBAAoB,QAAQ,uCAAsC;AAC3E,SAASC,kBAAkB,QAAQ,qCAAoC;AACvE,SAASC,aAAa,EAAEC,MAAM,QAAQ,gCAA+B;AACrE,SAASC,eAAe,QAAQ,kCAAiC;AACjE,SAASC,QAAQ,QAAQ,
|
|
1
|
+
{"version":3,"sources":["../../src/exports/utilities.ts"],"sourcesContent":["export { addDataAndFileToRequest } from '../utilities/addDataAndFileToRequest.js'\nexport { addLocalesToRequestFromData, sanitizeLocales } from '../utilities/addLocalesToRequest.js'\nexport { traverseFields } from '../utilities/buildFieldSchemaMap/traverseFields.js'\nexport { createPayloadRequest } from '../utilities/createPayloadRequest.js'\nexport { getNextRequestI18n } from '../utilities/getNextRequestI18n.js'\nexport { getPayloadHMR, reload } from '../utilities/getPayloadHMR.js'\nexport { headersWithCors } from '../utilities/headersWithCors.js'\nexport { initPage } from '../utilities/initPage/index.js'\n"],"names":["addDataAndFileToRequest","addLocalesToRequestFromData","sanitizeLocales","traverseFields","createPayloadRequest","getNextRequestI18n","getPayloadHMR","reload","headersWithCors","initPage"],"rangeMappings":";;;;;;;","mappings":"AAAA,SAASA,uBAAuB,QAAQ,0CAAyC;AACjF,SAASC,2BAA2B,EAAEC,eAAe,QAAQ,sCAAqC;AAClG,SAASC,cAAc,QAAQ,qDAAoD;AACnF,SAASC,oBAAoB,QAAQ,uCAAsC;AAC3E,SAASC,kBAAkB,QAAQ,qCAAoC;AACvE,SAASC,aAAa,EAAEC,MAAM,QAAQ,gCAA+B;AACrE,SAASC,eAAe,QAAQ,kCAAiC;AACjE,SAASC,QAAQ,QAAQ,iCAAgC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildFormState.d.ts","sourceRoot":"","sources":["../../../src/routes/rest/buildFormState.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA8B,sBAAsB,EAAc,MAAM,eAAe,CAAA;AAMnG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAA;AAalF,eAAO,MAAM,iBAAiB,QAAS,sBAAsB,mBAQ5D,CAAA;AAED,eAAO,MAAM,cAAc,YAAmB;IAAE,GAAG,EAAE,sBAAsB,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"buildFormState.d.ts","sourceRoot":"","sources":["../../../src/routes/rest/buildFormState.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA8B,sBAAsB,EAAc,MAAM,eAAe,CAAA;AAMnG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAA;AAalF,eAAO,MAAM,iBAAiB,QAAS,sBAAsB,mBAQ5D,CAAA;AAED,eAAO,MAAM,cAAc,YAAmB;IAAE,GAAG,EAAE,sBAAsB,CAAA;CAAE,sBAiN5E,CAAA"}
|
|
@@ -171,6 +171,7 @@ export const buildFormState = async ({ req })=>{
|
|
|
171
171
|
}
|
|
172
172
|
if (req.payload.collections[collectionSlug]?.config?.auth && !req.payload.collections[collectionSlug].config.auth.disableLocalStrategy) {
|
|
173
173
|
if (formState.password) result.password = formState.password;
|
|
174
|
+
if (formState['confirm-password']) result['confirm-password'] = formState['confirm-password'];
|
|
174
175
|
if (formState.email) result.email = formState.email;
|
|
175
176
|
}
|
|
176
177
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/routes/rest/buildFormState.ts"],"sourcesContent":["import type { BuildFormStateArgs } from '@payloadcms/ui/forms/buildStateFromSchema'\nimport type { DocumentPreferences, Field, PayloadRequestWithData, TypeWithID } from 'payload/types'\n\nimport { buildStateFromSchema } from '@payloadcms/ui/forms/buildStateFromSchema'\nimport { reduceFieldsToValues } from '@payloadcms/ui/utilities/reduceFieldsToValues'\nimport httpStatus from 'http-status'\n\nimport type { FieldSchemaMap } from '../../utilities/buildFieldSchemaMap/types.js'\n\nimport { buildFieldSchemaMap } from '../../utilities/buildFieldSchemaMap/index.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { routeError } from './routeError.js'\n\nlet cached = global._payload_fieldSchemaMap\n\nif (!cached) {\n // eslint-disable-next-line no-multi-assign\n cached = global._payload_fieldSchemaMap = null\n}\n\nexport const getFieldSchemaMap = (req: PayloadRequestWithData): FieldSchemaMap => {\n if (cached && process.env.NODE_ENV !== 'development') {\n return cached\n }\n\n cached = buildFieldSchemaMap(req)\n\n return cached\n}\n\nexport const buildFormState = async ({ req }: { req: PayloadRequestWithData }) => {\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n try {\n const reqData: BuildFormStateArgs = req.data as BuildFormStateArgs\n const { collectionSlug, formState, globalSlug, locale, operation, schemaPath } = reqData\n\n const incomingUserSlug = req.user?.collection\n const adminUserSlug = req.payload.config.admin.user\n\n // If we have a user slug, test it against the functions\n if (incomingUserSlug) {\n const adminAccessFunction = req.payload.collections[incomingUserSlug].config.access?.admin\n\n // Run the admin access function from the config if it exists\n if (adminAccessFunction) {\n const canAccessAdmin = await adminAccessFunction({ req })\n\n if (!canAccessAdmin) {\n return Response.json(null, {\n headers,\n status: httpStatus.UNAUTHORIZED,\n })\n }\n // Match the user collection to the global admin config\n } else if (adminUserSlug !== incomingUserSlug) {\n return Response.json(null, {\n headers,\n status: httpStatus.UNAUTHORIZED,\n })\n }\n } else {\n const hasUsers = await req.payload.find({\n collection: adminUserSlug,\n depth: 0,\n limit: 1,\n pagination: false,\n })\n // If there are users, we should not allow access because of /create-first-user\n if (hasUsers.docs.length) {\n return Response.json(null, {\n headers,\n status: httpStatus.UNAUTHORIZED,\n })\n }\n }\n\n const fieldSchemaMap = getFieldSchemaMap(req)\n\n const id = collectionSlug ? reqData.id : undefined\n const schemaPathSegments = schemaPath.split('.')\n\n let fieldSchema: Field[]\n\n if (schemaPathSegments.length === 1) {\n if (req.payload.collections[schemaPath]) {\n fieldSchema = req.payload.collections[schemaPath].config.fields\n } else {\n fieldSchema = req.payload.config.globals.find(\n (global) => global.slug === schemaPath,\n )?.fields\n }\n } else if (fieldSchemaMap.has(schemaPath)) {\n fieldSchema = fieldSchemaMap.get(schemaPath)\n }\n\n if (!fieldSchema) {\n return Response.json(\n {\n message: 'Could not find field schema for given path',\n },\n {\n headers,\n status: httpStatus.BAD_REQUEST,\n },\n )\n }\n\n let docPreferences = reqData.docPreferences\n let data = reqData.data\n\n const promises: {\n data?: Promise<void>\n preferences?: Promise<void>\n } = {}\n\n // If the request does not include doc preferences,\n // we should fetch them. This is useful for DocumentInfoProvider\n // as it reduces the amount of client-side fetches necessary\n // when we fetch data for the Edit view\n if (!docPreferences) {\n let preferencesKey\n\n if (collectionSlug && id) {\n preferencesKey = `collection-${collectionSlug}-${id}`\n }\n\n if (globalSlug) {\n preferencesKey = `global-${globalSlug}`\n }\n\n if (preferencesKey) {\n const fetchPreferences = async () => {\n const preferencesResult = (await req.payload.find({\n collection: 'payload-preferences',\n depth: 0,\n limit: 1,\n where: {\n key: {\n equals: preferencesKey,\n },\n },\n })) as unknown as { docs: { value: DocumentPreferences }[] }\n\n if (preferencesResult?.docs?.[0]?.value) docPreferences = preferencesResult.docs[0].value\n }\n\n promises.preferences = fetchPreferences()\n }\n }\n\n // If there is a form state,\n // then we can deduce data from that form state\n if (formState) data = reduceFieldsToValues(formState, true)\n\n // If we do not have data at this point,\n // we can fetch it. This is useful for DocumentInfoProvider\n // to reduce the amount of fetches required\n if (!data) {\n const fetchData = async () => {\n let resolvedData: TypeWithID\n\n if (collectionSlug && id) {\n resolvedData = await req.payload.findByID({\n id,\n collection: collectionSlug,\n depth: 0,\n draft: true,\n fallbackLocale: null,\n locale,\n overrideAccess: false,\n user: req.user,\n })\n }\n\n if (globalSlug && schemaPath === globalSlug) {\n resolvedData = await req.payload.findGlobal({\n slug: globalSlug,\n depth: 0,\n draft: true,\n fallbackLocale: null,\n locale,\n overrideAccess: false,\n user: req.user,\n })\n }\n\n data = resolvedData\n }\n\n promises.data = fetchData()\n }\n\n if (Object.keys(promises).length > 0) {\n await Promise.all(Object.values(promises))\n }\n\n const result = await buildStateFromSchema({\n id,\n data,\n fieldSchema,\n operation,\n preferences: docPreferences || { fields: {} },\n req,\n })\n\n // Maintain form state of auth / upload fields\n if (collectionSlug && formState) {\n if (req.payload.collections[collectionSlug]?.config?.upload && formState.file) {\n result.file = formState.file\n }\n\n if (\n req.payload.collections[collectionSlug]?.config?.auth &&\n !req.payload.collections[collectionSlug].config.auth.disableLocalStrategy\n ) {\n if (formState.password) result.password = formState.password\n if (formState.email) result.email = formState.email\n }\n }\n\n return Response.json(result, {\n headers,\n status: httpStatus.OK,\n })\n } catch (err) {\n req.payload.logger.error({ err, msg: `There was an error building form state` })\n\n return routeError({\n config: req.payload.config,\n err,\n req,\n })\n }\n}\n"],"names":["buildStateFromSchema","reduceFieldsToValues","httpStatus","buildFieldSchemaMap","headersWithCors","routeError","cached","global","_payload_fieldSchemaMap","getFieldSchemaMap","req","process","env","NODE_ENV","buildFormState","headers","Headers","reqData","data","collectionSlug","formState","globalSlug","locale","operation","schemaPath","incomingUserSlug","user","collection","adminUserSlug","payload","config","admin","adminAccessFunction","collections","access","canAccessAdmin","Response","json","status","UNAUTHORIZED","hasUsers","find","depth","limit","pagination","docs","length","fieldSchemaMap","id","undefined","schemaPathSegments","split","fieldSchema","fields","globals","slug","has","get","message","BAD_REQUEST","docPreferences","promises","preferencesKey","fetchPreferences","preferencesResult","where","key","equals","value","preferences","fetchData","resolvedData","findByID","draft","fallbackLocale","overrideAccess","findGlobal","Object","keys","Promise","all","values","result","upload","file","auth","disableLocalStrategy","password","email","OK","err","logger","error","msg"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,oBAAoB,QAAQ,4CAA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oBAChB;gBACF;gBAEAR,OAAOqD;YACT;YAEAV,SAAS3C,IAAI,GAAGoD;QAClB;QAEA,IAAIO,OAAOC,IAAI,CAACjB,UAAUf,MAAM,GAAG,GAAG;YACpC,MAAMiC,QAAQC,GAAG,CAACH,OAAOI,MAAM,CAACpB;QAClC;QAEA,MAAMqB,SAAS,MAAMlF,qBAAqB;YACxCgD;YACA9B;YACAkC;YACA7B;YACA8C,aAAaT,kBAAkB;gBAAEP,QAAQ,CAAC;YAAE;YAC5C3C;QACF;QAEA,8CAA8C;QAC9C,IAAIS,kBAAkBC,WAAW;YAC/B,IAAIV,IAAImB,OAAO,CAACI,WAAW,CAACd,eAAe,EAAEW,QAAQqD,UAAU/D,UAAUgE,IAAI,EAAE;gBAC7EF,OAAOE,IAAI,GAAGhE,UAAUgE,IAAI;YAC9B;YAEA,IACE1E,IAAImB,OAAO,CAACI,WAAW,CAACd,eAAe,EAAEW,QAAQuD,QACjD,CAAC3E,IAAImB,OAAO,CAACI,WAAW,CAACd,eAAe,CAACW,MAAM,CAACuD,IAAI,CAACC,oBAAoB,EACzE;gBACA,IAAIlE,UAAUmE,QAAQ,EAAEL,OAAOK,QAAQ,GAAGnE,UAAUmE,QAAQ;gBAC5D,IAAInE,UAAUoE,KAAK,EAAEN,OAAOM,KAAK,GAAGpE,UAAUoE,KAAK;YACrD;QACF;QAEA,OAAOpD,SAASC,IAAI,CAAC6C,QAAQ;YAC3BnE;YACAuB,QAAQpC,WAAWuF,EAAE;QACvB;IACF,EAAE,OAAOC,KAAK;QACZhF,IAAImB,OAAO,CAAC8D,MAAM,CAACC,KAAK,CAAC;YAAEF;YAAKG,KAAK,CAAC,sCAAsC,CAAC;QAAC;QAE9E,OAAOxF,WAAW;YAChByB,QAAQpB,IAAImB,OAAO,CAACC,MAAM;YAC1B4D;YACAhF;QACF;IACF;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/routes/rest/buildFormState.ts"],"sourcesContent":["import type { BuildFormStateArgs } from '@payloadcms/ui/forms/buildStateFromSchema'\nimport type { DocumentPreferences, Field, PayloadRequestWithData, TypeWithID } from 'payload/types'\n\nimport { buildStateFromSchema } from '@payloadcms/ui/forms/buildStateFromSchema'\nimport { reduceFieldsToValues } from '@payloadcms/ui/utilities/reduceFieldsToValues'\nimport httpStatus from 'http-status'\n\nimport type { FieldSchemaMap } from '../../utilities/buildFieldSchemaMap/types.js'\n\nimport { buildFieldSchemaMap } from '../../utilities/buildFieldSchemaMap/index.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { routeError } from './routeError.js'\n\nlet cached = global._payload_fieldSchemaMap\n\nif (!cached) {\n // eslint-disable-next-line no-multi-assign\n cached = global._payload_fieldSchemaMap = null\n}\n\nexport const getFieldSchemaMap = (req: PayloadRequestWithData): FieldSchemaMap => {\n if (cached && process.env.NODE_ENV !== 'development') {\n return cached\n }\n\n cached = buildFieldSchemaMap(req)\n\n return cached\n}\n\nexport const buildFormState = async ({ req }: { req: PayloadRequestWithData }) => {\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n try {\n const reqData: BuildFormStateArgs = req.data as BuildFormStateArgs\n const { collectionSlug, formState, globalSlug, locale, operation, schemaPath } = reqData\n\n const incomingUserSlug = req.user?.collection\n const adminUserSlug = req.payload.config.admin.user\n\n // If we have a user slug, test it against the functions\n if (incomingUserSlug) {\n const adminAccessFunction = req.payload.collections[incomingUserSlug].config.access?.admin\n\n // Run the admin access function from the config if it exists\n if (adminAccessFunction) {\n const canAccessAdmin = await adminAccessFunction({ req })\n\n if (!canAccessAdmin) {\n return Response.json(null, {\n headers,\n status: httpStatus.UNAUTHORIZED,\n })\n }\n // Match the user collection to the global admin config\n } else if (adminUserSlug !== incomingUserSlug) {\n return Response.json(null, {\n headers,\n status: httpStatus.UNAUTHORIZED,\n })\n }\n } else {\n const hasUsers = await req.payload.find({\n collection: adminUserSlug,\n depth: 0,\n limit: 1,\n pagination: false,\n })\n // If there are users, we should not allow access because of /create-first-user\n if (hasUsers.docs.length) {\n return Response.json(null, {\n headers,\n status: httpStatus.UNAUTHORIZED,\n })\n }\n }\n\n const fieldSchemaMap = getFieldSchemaMap(req)\n\n const id = collectionSlug ? reqData.id : undefined\n const schemaPathSegments = schemaPath.split('.')\n\n let fieldSchema: Field[]\n\n if (schemaPathSegments.length === 1) {\n if (req.payload.collections[schemaPath]) {\n fieldSchema = req.payload.collections[schemaPath].config.fields\n } else {\n fieldSchema = req.payload.config.globals.find(\n (global) => global.slug === schemaPath,\n )?.fields\n }\n } else if (fieldSchemaMap.has(schemaPath)) {\n fieldSchema = fieldSchemaMap.get(schemaPath)\n }\n\n if (!fieldSchema) {\n return Response.json(\n {\n message: 'Could not find field schema for given path',\n },\n {\n headers,\n status: httpStatus.BAD_REQUEST,\n },\n )\n }\n\n let docPreferences = reqData.docPreferences\n let data = reqData.data\n\n const promises: {\n data?: Promise<void>\n preferences?: Promise<void>\n } = {}\n\n // If the request does not include doc preferences,\n // we should fetch them. This is useful for DocumentInfoProvider\n // as it reduces the amount of client-side fetches necessary\n // when we fetch data for the Edit view\n if (!docPreferences) {\n let preferencesKey\n\n if (collectionSlug && id) {\n preferencesKey = `collection-${collectionSlug}-${id}`\n }\n\n if (globalSlug) {\n preferencesKey = `global-${globalSlug}`\n }\n\n if (preferencesKey) {\n const fetchPreferences = async () => {\n const preferencesResult = (await req.payload.find({\n collection: 'payload-preferences',\n depth: 0,\n limit: 1,\n where: {\n key: {\n equals: preferencesKey,\n },\n },\n })) as unknown as { docs: { value: DocumentPreferences }[] }\n\n if (preferencesResult?.docs?.[0]?.value) docPreferences = preferencesResult.docs[0].value\n }\n\n promises.preferences = fetchPreferences()\n }\n }\n\n // If there is a form state,\n // then we can deduce data from that form state\n if (formState) data = reduceFieldsToValues(formState, true)\n\n // If we do not have data at this point,\n // we can fetch it. This is useful for DocumentInfoProvider\n // to reduce the amount of fetches required\n if (!data) {\n const fetchData = async () => {\n let resolvedData: TypeWithID\n\n if (collectionSlug && id) {\n resolvedData = await req.payload.findByID({\n id,\n collection: collectionSlug,\n depth: 0,\n draft: true,\n fallbackLocale: null,\n locale,\n overrideAccess: false,\n user: req.user,\n })\n }\n\n if (globalSlug && schemaPath === globalSlug) {\n resolvedData = await req.payload.findGlobal({\n slug: globalSlug,\n depth: 0,\n draft: true,\n fallbackLocale: null,\n locale,\n overrideAccess: false,\n user: req.user,\n })\n }\n\n data = resolvedData\n }\n\n promises.data = fetchData()\n }\n\n if (Object.keys(promises).length > 0) {\n await Promise.all(Object.values(promises))\n }\n\n const result = await buildStateFromSchema({\n id,\n data,\n fieldSchema,\n operation,\n preferences: docPreferences || { fields: {} },\n req,\n })\n\n // Maintain form state of auth / upload fields\n if (collectionSlug && formState) {\n if (req.payload.collections[collectionSlug]?.config?.upload && formState.file) {\n result.file = formState.file\n }\n\n if (\n req.payload.collections[collectionSlug]?.config?.auth &&\n !req.payload.collections[collectionSlug].config.auth.disableLocalStrategy\n ) {\n if (formState.password) result.password = formState.password\n if (formState['confirm-password'])\n result['confirm-password'] = formState['confirm-password']\n if (formState.email) result.email = formState.email\n }\n }\n\n return Response.json(result, {\n headers,\n status: httpStatus.OK,\n })\n } catch (err) {\n req.payload.logger.error({ err, msg: `There was an error building form state` })\n\n return routeError({\n config: req.payload.config,\n err,\n req,\n })\n }\n}\n"],"names":["buildStateFromSchema","reduceFieldsToValues","httpStatus","buildFieldSchemaMap","headersWithCors","routeError","cached","global","_payload_fieldSchemaMap","getFieldSchemaMap","req","process","env","NODE_ENV","buildFormState","headers","Headers","reqData","data","collectionSlug","formState","globalSlug","locale","operation","schemaPath","incomingUserSlug","user","collection","adminUserSlug","payload","config","admin","adminAccessFunction","collections","access","canAccessAdmin","Response","json","status","UNAUTHORIZED","hasUsers","find","depth","limit","pagination","docs","length","fieldSchemaMap","id","undefined","schemaPathSegments","split","fieldSchema","fields","globals","slug","has","get","message","BAD_REQUEST","docPreferences","promises","preferencesKey","fetchPreferences","preferencesResult","where","key","equals","value","preferences","fetchData","resolvedData","findByID","draft","fallbackLocale","overrideAccess","findGlobal","Object","keys","Promise","all","values","result","upload","file","auth","disableLocalStrategy","password","email","OK","err","logger","error","msg"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,oBAAoB,QAAQ,4CAA2C;AAChF,SAASC,oBAAoB,QAAQ,gDAA+C;AACpF,OAAOC,gBAAgB,cAAa;AAIpC,SAASC,mBAAmB,QAAQ,+CAA8C;AAClF,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,UAAU,QAAQ,kBAAiB;AAE5C,IAAIC,SAASC,OAAOC,uBAAuB;AAE3C,IAAI,CAACF,QAAQ;IACX,2CAA2C;IAC3CA,SAASC,OAAOC,uBAAuB,GAAG;AAC5C;AAEA,OAAO,MAAMC,oBAAoB,CAACC;IAChC,IAAIJ,UAAUK,QAAQC,GAAG,CAACC,QAAQ,KAAK,eAAe;QACpD,OAAOP;IACT;IAEAA,SAASH,oBAAoBO;IAE7B,OAAOJ;AACT,EAAC;AAED,OAAO,MAAMQ,iBAAiB,OAAO,EAAEJ,GAAG,EAAmC;IAC3E,MAAMK,UAAUX,gBAAgB;QAC9BW,SAAS,IAAIC;QACbN;IACF;IAEA,IAAI;QACF,MAAMO,UAA8BP,IAAIQ,IAAI;QAC5C,MAAM,EAAEC,cAAc,EAAEC,SAAS,EAAEC,UAAU,EAAEC,MAAM,EAAEC,SAAS,EAAEC,UAAU,EAAE,GAAGP;QAEjF,MAAMQ,mBAAmBf,IAAIgB,IAAI,EAAEC;QACnC,MAAMC,gBAAgBlB,IAAImB,OAAO,CAACC,MAAM,CAACC,KAAK,CAACL,IAAI;QA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AmB;gBAC5D,IAAIA,UAAUoE,KAAK,EAAEN,OAAOM,KAAK,GAAGpE,UAAUoE,KAAK;YACrD;QACF;QAEA,OAAOpD,SAASC,IAAI,CAAC6C,QAAQ;YAC3BnE;YACAuB,QAAQpC,WAAWuF,EAAE;QACvB;IACF,EAAE,OAAOC,KAAK;QACZhF,IAAImB,OAAO,CAAC8D,MAAM,CAACC,KAAK,CAAC;YAAEF;YAAKG,KAAK,CAAC,sCAAsC,CAAC;QAAC;QAE9E,OAAOxF,WAAW;YAChByB,QAAQpB,IAAImB,OAAO,CAACC,MAAM;YAC1B4D;YACAhF;QACF;IACF;AACF,EAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Permissions } from 'payload/auth';
|
|
2
|
+
import type { SanitizedCollectionConfig, SanitizedConfig, SanitizedGlobalConfig } from 'payload/types';
|
|
3
|
+
export declare const handleAdminPage: ({ adminRoute, config, permissions, route, }: {
|
|
4
|
+
adminRoute: string;
|
|
5
|
+
config: SanitizedConfig;
|
|
6
|
+
permissions: Permissions;
|
|
7
|
+
route: string;
|
|
8
|
+
}) => {
|
|
9
|
+
collectionConfig: SanitizedCollectionConfig;
|
|
10
|
+
docID: string;
|
|
11
|
+
globalConfig: SanitizedGlobalConfig;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=handleAdminPage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleAdminPage.d.ts","sourceRoot":"","sources":["../../../src/utilities/initPage/handleAdminPage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EACV,yBAAyB,EACzB,eAAe,EACf,qBAAqB,EACtB,MAAM,eAAe,CAAA;AAMtB,eAAO,MAAM,eAAe,gDAKzB;IACD,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,eAAe,CAAA;IACvB,WAAW,EAAE,WAAW,CAAA;IACxB,KAAK,EAAE,MAAM,CAAA;CACd;;;;CAqCA,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { notFound } from 'next/navigation.js';
|
|
2
|
+
import { isAdminAuthRoute, isAdminRoute } from './shared.js';
|
|
3
|
+
export const handleAdminPage = ({ adminRoute, config, permissions, route })=>{
|
|
4
|
+
if (isAdminRoute(route, adminRoute)) {
|
|
5
|
+
const routeSegments = route.replace(adminRoute, '').split('/').filter(Boolean);
|
|
6
|
+
const [entityType, entitySlug, createOrID] = routeSegments;
|
|
7
|
+
const collectionSlug = entityType === 'collections' ? entitySlug : undefined;
|
|
8
|
+
const globalSlug = entityType === 'globals' ? entitySlug : undefined;
|
|
9
|
+
const docID = collectionSlug && createOrID !== 'create' ? createOrID : undefined;
|
|
10
|
+
let collectionConfig;
|
|
11
|
+
let globalConfig;
|
|
12
|
+
if (collectionSlug) {
|
|
13
|
+
collectionConfig = config.collections.find((collection)=>collection.slug === collectionSlug);
|
|
14
|
+
if (!collectionConfig) {
|
|
15
|
+
notFound();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if (globalSlug) {
|
|
19
|
+
globalConfig = config.globals.find((global)=>global.slug === globalSlug);
|
|
20
|
+
if (!globalConfig) {
|
|
21
|
+
notFound();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (!permissions.canAccessAdmin && !isAdminAuthRoute(route, adminRoute)) {
|
|
25
|
+
notFound();
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
collectionConfig,
|
|
29
|
+
docID,
|
|
30
|
+
globalConfig
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=handleAdminPage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utilities/initPage/handleAdminPage.ts"],"sourcesContent":["import type { Permissions } from 'payload/auth'\nimport type {\n SanitizedCollectionConfig,\n SanitizedConfig,\n SanitizedGlobalConfig,\n} from 'payload/types'\n\nimport { notFound } from 'next/navigation.js'\n\nimport { isAdminAuthRoute, isAdminRoute } from './shared.js'\n\nexport const handleAdminPage = ({\n adminRoute,\n config,\n permissions,\n route,\n}: {\n adminRoute: string\n config: SanitizedConfig\n permissions: Permissions\n route: string\n}) => {\n if (isAdminRoute(route, adminRoute)) {\n const routeSegments = route.replace(adminRoute, '').split('/').filter(Boolean)\n const [entityType, entitySlug, createOrID] = routeSegments\n const collectionSlug = entityType === 'collections' ? entitySlug : undefined\n const globalSlug = entityType === 'globals' ? entitySlug : undefined\n const docID = collectionSlug && createOrID !== 'create' ? createOrID : undefined\n\n let collectionConfig: SanitizedCollectionConfig | undefined\n let globalConfig: SanitizedGlobalConfig | undefined\n\n if (collectionSlug) {\n collectionConfig = config.collections.find((collection) => collection.slug === collectionSlug)\n\n if (!collectionConfig) {\n notFound()\n }\n }\n\n if (globalSlug) {\n globalConfig = config.globals.find((global) => global.slug === globalSlug)\n\n if (!globalConfig) {\n notFound()\n }\n }\n\n if (!permissions.canAccessAdmin && !isAdminAuthRoute(route, adminRoute)) {\n notFound()\n }\n\n return {\n collectionConfig,\n docID,\n globalConfig,\n }\n }\n}\n"],"names":["notFound","isAdminAuthRoute","isAdminRoute","handleAdminPage","adminRoute","config","permissions","route","routeSegments","replace","split","filter","Boolean","entityType","entitySlug","createOrID","collectionSlug","undefined","globalSlug","docID","collectionConfig","globalConfig","collections","find","collection","slug","globals","global","canAccessAdmin"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAOA,SAASA,QAAQ,QAAQ,qBAAoB;AAE7C,SAASC,gBAAgB,EAAEC,YAAY,QAAQ,cAAa;AAE5D,OAAO,MAAMC,kBAAkB,CAAC,EAC9BC,UAAU,EACVC,MAAM,EACNC,WAAW,EACXC,KAAK,EAMN;IACC,IAAIL,aAAaK,OAAOH,aAAa;QACnC,MAAMI,gBAAgBD,MAAME,OAAO,CAACL,YAAY,IAAIM,KAAK,CAAC,KAAKC,MAAM,CAACC;QACtE,MAAM,CAACC,YAAYC,YAAYC,WAAW,GAAGP;QAC7C,MAAMQ,iBAAiBH,eAAe,gBAAgBC,aAAaG;QACnE,MAAMC,aAAaL,eAAe,YAAYC,aAAaG;QAC3D,MAAME,QAAQH,kBAAkBD,eAAe,WAAWA,aAAaE;QAEvE,IAAIG;QACJ,IAAIC;QAEJ,IAAIL,gBAAgB;YAClBI,mBAAmBf,OAAOiB,WAAW,CAACC,IAAI,CAAC,CAACC,aAAeA,WAAWC,IAAI,KAAKT;YAE/E,IAAI,CAACI,kBAAkB;gBACrBpB;YACF;QACF;QAEA,IAAIkB,YAAY;YACdG,eAAehB,OAAOqB,OAAO,CAACH,IAAI,CAAC,CAACI,SAAWA,OAAOF,IAAI,KAAKP;YAE/D,IAAI,CAACG,cAAc;gBACjBrB;YACF;QACF;QAEA,IAAI,CAACM,YAAYsB,cAAc,IAAI,CAAC3B,iBAAiBM,OAAOH,aAAa;YACvEJ;QACF;QAEA,OAAO;YACLoB;YACAD;YACAE;QACF;IACF;AACF,EAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const handleAuthRedirect: ({ adminRoute, redirectUnauthenticatedUser, route, searchParams, }: {
|
|
2
|
+
adminRoute: string;
|
|
3
|
+
redirectUnauthenticatedUser: boolean | string;
|
|
4
|
+
route: string;
|
|
5
|
+
searchParams: {
|
|
6
|
+
[key: string]: string | string[];
|
|
7
|
+
};
|
|
8
|
+
}) => void;
|
|
9
|
+
//# sourceMappingURL=handleAuthRedirect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleAuthRedirect.d.ts","sourceRoot":"","sources":["../../../src/utilities/initPage/handleAuthRedirect.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,kBAAkB,sEAK5B;IACD,UAAU,EAAE,MAAM,CAAA;IAClB,2BAA2B,EAAE,OAAO,GAAG,MAAM,CAAA;IAC7C,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;KAAE,CAAA;CACnD,SA+BA,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { redirect } from 'next/navigation.js';
|
|
2
|
+
import QueryString from 'qs';
|
|
3
|
+
import { isAdminAuthRoute, isAdminRoute } from './shared.js';
|
|
4
|
+
export const handleAuthRedirect = ({ adminRoute, redirectUnauthenticatedUser, route, searchParams })=>{
|
|
5
|
+
if (!isAdminAuthRoute(route, adminRoute)) {
|
|
6
|
+
if (searchParams && 'redirect' in searchParams) delete searchParams.redirect;
|
|
7
|
+
const redirectRoute = encodeURIComponent(route + Object.keys(searchParams ?? {}).length ? `${QueryString.stringify(searchParams, {
|
|
8
|
+
addQueryPrefix: true
|
|
9
|
+
})}` : undefined);
|
|
10
|
+
const adminLoginRoute = `${adminRoute}/login`;
|
|
11
|
+
const customLoginRoute = typeof redirectUnauthenticatedUser === 'string' ? redirectUnauthenticatedUser : undefined;
|
|
12
|
+
const loginRoute = isAdminRoute(route, adminRoute) ? adminLoginRoute : customLoginRoute || '/login';
|
|
13
|
+
const parsedLoginRouteSearchParams = QueryString.parse(loginRoute.split('?')[1] ?? '');
|
|
14
|
+
const searchParamsWithRedirect = `${QueryString.stringify({
|
|
15
|
+
...parsedLoginRouteSearchParams,
|
|
16
|
+
...redirectRoute ? {
|
|
17
|
+
redirect: redirectRoute
|
|
18
|
+
} : {}
|
|
19
|
+
}, {
|
|
20
|
+
addQueryPrefix: true
|
|
21
|
+
})}`;
|
|
22
|
+
redirect(`${loginRoute.split('?')[0]}${searchParamsWithRedirect}`);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=handleAuthRedirect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utilities/initPage/handleAuthRedirect.ts"],"sourcesContent":["import { redirect } from 'next/navigation.js'\nimport QueryString from 'qs'\n\nimport { isAdminAuthRoute, isAdminRoute } from './shared.js'\n\nexport const handleAuthRedirect = ({\n adminRoute,\n redirectUnauthenticatedUser,\n route,\n searchParams,\n}: {\n adminRoute: string\n redirectUnauthenticatedUser: boolean | string\n route: string\n searchParams: { [key: string]: string | string[] }\n}) => {\n if (!isAdminAuthRoute(route, adminRoute)) {\n if (searchParams && 'redirect' in searchParams) delete searchParams.redirect\n\n const redirectRoute = encodeURIComponent(\n route + Object.keys(searchParams ?? {}).length\n ? `${QueryString.stringify(searchParams, { addQueryPrefix: true })}`\n : undefined,\n )\n\n const adminLoginRoute = `${adminRoute}/login`\n\n const customLoginRoute =\n typeof redirectUnauthenticatedUser === 'string' ? redirectUnauthenticatedUser : undefined\n\n const loginRoute = isAdminRoute(route, adminRoute)\n ? adminLoginRoute\n : customLoginRoute || '/login'\n\n const parsedLoginRouteSearchParams = QueryString.parse(loginRoute.split('?')[1] ?? '')\n\n const searchParamsWithRedirect = `${QueryString.stringify(\n {\n ...parsedLoginRouteSearchParams,\n ...(redirectRoute ? { redirect: redirectRoute } : {}),\n },\n { addQueryPrefix: true },\n )}`\n\n redirect(`${loginRoute.split('?')[0]}${searchParamsWithRedirect}`)\n }\n}\n"],"names":["redirect","QueryString","isAdminAuthRoute","isAdminRoute","handleAuthRedirect","adminRoute","redirectUnauthenticatedUser","route","searchParams","redirectRoute","encodeURIComponent","Object","keys","length","stringify","addQueryPrefix","undefined","adminLoginRoute","customLoginRoute","loginRoute","parsedLoginRouteSearchParams","parse","split","searchParamsWithRedirect"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,QAAQ,QAAQ,qBAAoB;AAC7C,OAAOC,iBAAiB,KAAI;AAE5B,SAASC,gBAAgB,EAAEC,YAAY,QAAQ,cAAa;AAE5D,OAAO,MAAMC,qBAAqB,CAAC,EACjCC,UAAU,EACVC,2BAA2B,EAC3BC,KAAK,EACLC,YAAY,EAMb;IACC,IAAI,CAACN,iBAAiBK,OAAOF,aAAa;QACxC,IAAIG,gBAAgB,cAAcA,cAAc,OAAOA,aAAaR,QAAQ;QAE5E,MAAMS,gBAAgBC,mBACpBH,QAAQI,OAAOC,IAAI,CAACJ,gBAAgB,CAAC,GAAGK,MAAM,GAC1C,CAAC,EAAEZ,YAAYa,SAAS,CAACN,cAAc;YAAEO,gBAAgB;QAAK,GAAG,CAAC,GAClEC;QAGN,MAAMC,kBAAkB,CAAC,EAAEZ,WAAW,MAAM,CAAC;QAE7C,MAAMa,mBACJ,OAAOZ,gCAAgC,WAAWA,8BAA8BU;QAElF,MAAMG,aAAahB,aAAaI,OAAOF,cACnCY,kBACAC,oBAAoB;QAExB,MAAME,+BAA+BnB,YAAYoB,KAAK,CAACF,WAAWG,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI;QAEnF,MAAMC,2BAA2B,CAAC,EAAEtB,YAAYa,SAAS,CACvD;YACE,GAAGM,4BAA4B;YAC/B,GAAIX,gBAAgB;gBAAET,UAAUS;YAAc,IAAI,CAAC,CAAC;QACtD,GACA;YAAEM,gBAAgB;QAAK,GACvB,CAAC;QAEHf,SAAS,CAAC,EAAEmB,WAAWG,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,EAAEC,yBAAyB,CAAC;IACnE;AACF,EAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { InitPageResult } from 'payload/types';
|
|
2
|
+
import type { Args } from './types.js';
|
|
3
|
+
export declare const initPage: ({ config: configPromise, redirectUnauthenticatedUser, route, searchParams, }: Args) => Promise<InitPageResult>;
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utilities/initPage/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAA2C,MAAM,eAAe,CAAA;AAS5F,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAOtC,eAAO,MAAM,QAAQ,iFAKlB,IAAI,KAAG,QAAQ,cAAc,CAmF/B,CAAA"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { initI18n } from '@payloadcms/translations';
|
|
2
|
+
import { findLocaleFromCode } from '@payloadcms/ui/utilities/findLocaleFromCode';
|
|
3
|
+
import { headers as getHeaders } from 'next/headers.js';
|
|
4
|
+
import { parseCookies } from 'payload/auth';
|
|
5
|
+
import { createLocalReq, isEntityHidden } from 'payload/utilities';
|
|
6
|
+
import qs from 'qs';
|
|
7
|
+
import { getPayloadHMR } from '../getPayloadHMR.js';
|
|
8
|
+
import { getRequestLanguage } from '../getRequestLanguage.js';
|
|
9
|
+
import { handleAdminPage } from './handleAdminPage.js';
|
|
10
|
+
import { handleAuthRedirect } from './handleAuthRedirect.js';
|
|
11
|
+
export const initPage = async ({ config: configPromise, redirectUnauthenticatedUser = false, route, searchParams })=>{
|
|
12
|
+
const headers = getHeaders();
|
|
13
|
+
const localeParam = searchParams?.locale;
|
|
14
|
+
const payload = await getPayloadHMR({
|
|
15
|
+
config: configPromise
|
|
16
|
+
});
|
|
17
|
+
const { collections, globals, i18n: i18nConfig, localization, routes: { admin: adminRoute } } = payload.config;
|
|
18
|
+
const queryString = `${qs.stringify(searchParams ?? {}, {
|
|
19
|
+
addQueryPrefix: true
|
|
20
|
+
})}`;
|
|
21
|
+
const defaultLocale = localization && localization.defaultLocale ? localization.defaultLocale : 'en';
|
|
22
|
+
const localeCode = localeParam || defaultLocale;
|
|
23
|
+
const locale = localization && findLocaleFromCode(localization, localeCode);
|
|
24
|
+
const cookies = parseCookies(headers);
|
|
25
|
+
const language = getRequestLanguage({
|
|
26
|
+
config: payload.config,
|
|
27
|
+
cookies,
|
|
28
|
+
headers
|
|
29
|
+
});
|
|
30
|
+
const i18n = await initI18n({
|
|
31
|
+
config: i18nConfig,
|
|
32
|
+
context: 'client',
|
|
33
|
+
language
|
|
34
|
+
});
|
|
35
|
+
const req = await createLocalReq({
|
|
36
|
+
fallbackLocale: null,
|
|
37
|
+
locale: locale.code,
|
|
38
|
+
req: {
|
|
39
|
+
i18n,
|
|
40
|
+
query: qs.parse(queryString, {
|
|
41
|
+
depth: 10,
|
|
42
|
+
ignoreQueryPrefix: true
|
|
43
|
+
}),
|
|
44
|
+
url: `${payload.config.serverURL}${route}${searchParams ? queryString : ''}`
|
|
45
|
+
}
|
|
46
|
+
}, payload);
|
|
47
|
+
const { permissions, user } = await payload.auth({
|
|
48
|
+
headers,
|
|
49
|
+
req
|
|
50
|
+
});
|
|
51
|
+
req.user = user;
|
|
52
|
+
const visibleEntities = {
|
|
53
|
+
collections: collections.map(({ slug, admin: { hidden } })=>!isEntityHidden({
|
|
54
|
+
hidden,
|
|
55
|
+
user
|
|
56
|
+
}) ? slug : null).filter(Boolean),
|
|
57
|
+
globals: globals.map(({ slug, admin: { hidden } })=>!isEntityHidden({
|
|
58
|
+
hidden,
|
|
59
|
+
user
|
|
60
|
+
}) ? slug : null).filter(Boolean)
|
|
61
|
+
};
|
|
62
|
+
if (redirectUnauthenticatedUser && !user) {
|
|
63
|
+
handleAuthRedirect({
|
|
64
|
+
adminRoute,
|
|
65
|
+
redirectUnauthenticatedUser,
|
|
66
|
+
route,
|
|
67
|
+
searchParams
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
const { collectionConfig, docID, globalConfig } = handleAdminPage({
|
|
71
|
+
adminRoute,
|
|
72
|
+
config: payload.config,
|
|
73
|
+
permissions,
|
|
74
|
+
route
|
|
75
|
+
});
|
|
76
|
+
return {
|
|
77
|
+
collectionConfig,
|
|
78
|
+
cookies,
|
|
79
|
+
docID,
|
|
80
|
+
globalConfig,
|
|
81
|
+
locale,
|
|
82
|
+
permissions,
|
|
83
|
+
req,
|
|
84
|
+
translations: i18n.translations,
|
|
85
|
+
visibleEntities
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utilities/initPage/index.ts"],"sourcesContent":["import type { InitPageResult, PayloadRequestWithData, VisibleEntities } from 'payload/types'\n\nimport { initI18n } from '@payloadcms/translations'\nimport { findLocaleFromCode } from '@payloadcms/ui/utilities/findLocaleFromCode'\nimport { headers as getHeaders } from 'next/headers.js'\nimport { parseCookies } from 'payload/auth'\nimport { createLocalReq, isEntityHidden } from 'payload/utilities'\nimport qs from 'qs'\n\nimport type { Args } from './types.js'\n\nimport { getPayloadHMR } from '../getPayloadHMR.js'\nimport { getRequestLanguage } from '../getRequestLanguage.js'\nimport { handleAdminPage } from './handleAdminPage.js'\nimport { handleAuthRedirect } from './handleAuthRedirect.js'\n\nexport const initPage = async ({\n config: configPromise,\n redirectUnauthenticatedUser = false,\n route,\n searchParams,\n}: Args): Promise<InitPageResult> => {\n const headers = getHeaders()\n const localeParam = searchParams?.locale as string\n const payload = await getPayloadHMR({ config: configPromise })\n\n const {\n collections,\n globals,\n i18n: i18nConfig,\n localization,\n routes: { admin: adminRoute },\n } = payload.config\n\n const queryString = `${qs.stringify(searchParams ?? {}, { addQueryPrefix: true })}`\n const defaultLocale =\n localization && localization.defaultLocale ? localization.defaultLocale : 'en'\n const localeCode = localeParam || defaultLocale\n const locale = localization && findLocaleFromCode(localization, localeCode)\n const cookies = parseCookies(headers)\n const language = getRequestLanguage({ config: payload.config, cookies, headers })\n\n const i18n = await initI18n({\n config: i18nConfig,\n context: 'client',\n language,\n })\n\n const req = await createLocalReq(\n {\n fallbackLocale: null,\n locale: locale.code,\n req: {\n i18n,\n query: qs.parse(queryString, {\n depth: 10,\n ignoreQueryPrefix: true,\n }),\n url: `${payload.config.serverURL}${route}${searchParams ? queryString : ''}`,\n } as PayloadRequestWithData,\n },\n payload,\n )\n\n const { permissions, user } = await payload.auth({ headers, req })\n\n req.user = user\n\n const visibleEntities: VisibleEntities = {\n collections: collections\n .map(({ slug, admin: { hidden } }) => (!isEntityHidden({ hidden, user }) ? slug : null))\n .filter(Boolean),\n globals: globals\n .map(({ slug, admin: { hidden } }) => (!isEntityHidden({ hidden, user }) ? slug : null))\n .filter(Boolean),\n }\n\n if (redirectUnauthenticatedUser && !user) {\n handleAuthRedirect({\n adminRoute,\n redirectUnauthenticatedUser,\n route,\n searchParams,\n })\n }\n\n const { collectionConfig, docID, globalConfig } = handleAdminPage({\n adminRoute,\n config: payload.config,\n permissions,\n route,\n })\n\n return {\n collectionConfig,\n cookies,\n docID,\n globalConfig,\n locale,\n permissions,\n req,\n translations: i18n.translations,\n visibleEntities,\n }\n}\n"],"names":["initI18n","findLocaleFromCode","headers","getHeaders","parseCookies","createLocalReq","isEntityHidden","qs","getPayloadHMR","getRequestLanguage","handleAdminPage","handleAuthRedirect","initPage","config","configPromise","redirectUnauthenticatedUser","route","searchParams","localeParam","locale","payload","collections","globals","i18n","i18nConfig","localization","routes","admin","adminRoute","queryString","stringify","addQueryPrefix","defaultLocale","localeCode","cookies","language","context","req","fallbackLocale","code","query","parse","depth","ignoreQueryPrefix","url","serverURL","permissions","user","auth","visibleEntities","map","slug","hidden","filter","Boolean","collectionConfig","docID","globalConfig","translations"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,kBAAkB,QAAQ,8CAA6C;AAChF,SAASC,WAAWC,UAAU,QAAQ,kBAAiB;AACvD,SAASC,YAAY,QAAQ,eAAc;AAC3C,SAASC,cAAc,EAAEC,cAAc,QAAQ,oBAAmB;AAClE,OAAOC,QAAQ,KAAI;AAInB,SAASC,aAAa,QAAQ,sBAAqB;AACnD,SAASC,kBAAkB,QAAQ,2BAA0B;AAC7D,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,kBAAkB,QAAQ,0BAAyB;AAE5D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AmC;QACvC5B,aAAaA,YACV6B,GAAG,CAAC,CAAC,EAAEC,IAAI,EAAExB,OAAO,EAAEyB,MAAM,EAAE,EAAE,GAAM,CAAC9C,eAAe;gBAAE8C;gBAAQL;YAAK,KAAKI,OAAO,MACjFE,MAAM,CAACC;QACVhC,SAASA,QACN4B,GAAG,CAAC,CAAC,EAAEC,IAAI,EAAExB,OAAO,EAAEyB,MAAM,EAAE,EAAE,GAAM,CAAC9C,eAAe;gBAAE8C;gBAAQL;YAAK,KAAKI,OAAO,MACjFE,MAAM,CAACC;IACZ;IAEA,IAAIvC,+BAA+B,CAACgC,MAAM;QACxCpC,mBAAmB;YACjBiB;YACAb;YACAC;YACAC;QACF;IACF;IAEA,MAAM,EAAEsC,gBAAgB,EAAEC,KAAK,EAAEC,YAAY,EAAE,GAAG/C,gBAAgB;QAChEkB;QACAf,QAAQO,QAAQP,MAAM;QACtBiC;QACA9B;IACF;IAEA,OAAO;QACLuC;QACArB;QACAsB;QACAC;QACAtC;QACA2B;QACAT;QACAqB,cAAcnC,KAAKmC,YAAY;QAC/BT;IACF;AACF,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/utilities/initPage/shared.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,UAQtB,CAAA;AAED,eAAO,MAAM,YAAY,UAAW,MAAM,cAAc,MAAM,YAE7D,CAAA;AAED,eAAO,MAAM,gBAAgB,UAAW,MAAM,cAAc,MAAM,YAEjE,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const authRoutes = [
|
|
2
|
+
'/login',
|
|
3
|
+
'/logout',
|
|
4
|
+
'/create-first-user',
|
|
5
|
+
'/forgot',
|
|
6
|
+
'/reset',
|
|
7
|
+
'/verify',
|
|
8
|
+
'/logout-inactivity'
|
|
9
|
+
];
|
|
10
|
+
export const isAdminRoute = (route, adminRoute)=>{
|
|
11
|
+
return route.startsWith(adminRoute);
|
|
12
|
+
};
|
|
13
|
+
export const isAdminAuthRoute = (route, adminRoute)=>{
|
|
14
|
+
return authRoutes.some((r)=>route.replace(adminRoute, '').startsWith(r));
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utilities/initPage/shared.ts"],"sourcesContent":["export const authRoutes = [\n '/login',\n '/logout',\n '/create-first-user',\n '/forgot',\n '/reset',\n '/verify',\n '/logout-inactivity',\n]\n\nexport const isAdminRoute = (route: string, adminRoute: string) => {\n return route.startsWith(adminRoute)\n}\n\nexport const isAdminAuthRoute = (route: string, adminRoute: string) => {\n return authRoutes.some((r) => route.replace(adminRoute, '').startsWith(r))\n}\n"],"names":["authRoutes","isAdminRoute","route","adminRoute","startsWith","isAdminAuthRoute","some","r","replace"],"rangeMappings":";;;;;;;;;;;;;;","mappings":"AAAA,OAAO,MAAMA,aAAa;IACxB;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAA;AAED,OAAO,MAAMC,eAAe,CAACC,OAAeC;IAC1C,OAAOD,MAAME,UAAU,CAACD;AAC1B,EAAC;AAED,OAAO,MAAME,mBAAmB,CAACH,OAAeC;IAC9C,OAAOH,WAAWM,IAAI,CAAC,CAACC,IAAML,MAAMM,OAAO,CAACL,YAAY,IAAIC,UAAU,CAACG;AACzE,EAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { SanitizedConfig } from 'payload/types';
|
|
2
|
+
export type Args = {
|
|
3
|
+
/**
|
|
4
|
+
* Your sanitized Payload config.
|
|
5
|
+
* If unresolved, this function will await the promise.
|
|
6
|
+
*/
|
|
7
|
+
config: Promise<SanitizedConfig> | SanitizedConfig;
|
|
8
|
+
/**
|
|
9
|
+
* If true, redirects unauthenticated users to the admin login page.
|
|
10
|
+
* If a string is provided, the user will be redirected to that specific URL.
|
|
11
|
+
*/
|
|
12
|
+
redirectUnauthenticatedUser?: boolean | string;
|
|
13
|
+
/**
|
|
14
|
+
* The current route, i.e. `/admin/collections/posts`.
|
|
15
|
+
*/
|
|
16
|
+
route: string;
|
|
17
|
+
/**
|
|
18
|
+
* The search parameters of the current route provided to all pages in Next.js.
|
|
19
|
+
*/
|
|
20
|
+
searchParams: {
|
|
21
|
+
[key: string]: string | string[] | undefined;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utilities/initPage/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAEpD,MAAM,MAAM,IAAI,GAAG;IACjB;;;OAGG;IACH,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAA;IAClD;;;OAGG;IACH,2BAA2B,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IAC9C;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,YAAY,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAA;KAAE,CAAA;CAC/D,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utilities/initPage/types.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload/types'\n\nexport type Args = {\n /**\n * Your sanitized Payload config.\n * If unresolved, this function will await the promise.\n */\n config: Promise<SanitizedConfig> | SanitizedConfig\n /**\n * If true, redirects unauthenticated users to the admin login page.\n * If a string is provided, the user will be redirected to that specific URL.\n */\n redirectUnauthenticatedUser?: boolean | string\n /**\n * The current route, i.e. `/admin/collections/posts`.\n */\n route: string\n /**\n * The search parameters of the current route provided to all pages in Next.js.\n */\n searchParams: { [key: string]: string | string[] | undefined }\n}\n"],"names":[],"rangeMappings":"","mappings":"AAEA,WAmBC"}
|
|
@@ -2,7 +2,7 @@ import { HydrateClientUser } from '@payloadcms/ui/elements/HydrateClientUser';
|
|
|
2
2
|
import { DefaultTemplate } from '@payloadcms/ui/templates/Default';
|
|
3
3
|
import React, { Fragment } from 'react';
|
|
4
4
|
import { getNextRequestI18n } from '../../utilities/getNextRequestI18n.js';
|
|
5
|
-
import { initPage } from '../../utilities/initPage.js';
|
|
5
|
+
import { initPage } from '../../utilities/initPage/index.js';
|
|
6
6
|
import { NotFoundClient } from './index.client.js';
|
|
7
7
|
export const generatePageMetadata = async ({ config: configPromise })=>{
|
|
8
8
|
const config = await configPromise;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/views/NotFound/index.tsx"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { Metadata } from 'next'\nimport type { AdminViewComponent, SanitizedConfig } from 'payload/types'\n\nimport { HydrateClientUser } from '@payloadcms/ui/elements/HydrateClientUser'\nimport { DefaultTemplate } from '@payloadcms/ui/templates/Default'\nimport React, { Fragment } from 'react'\n\nimport { getNextRequestI18n } from '../../utilities/getNextRequestI18n.js'\nimport { initPage } from '../../utilities/initPage.js'\nimport { NotFoundClient } from './index.client.js'\n\nexport const generatePageMetadata = async ({\n config: configPromise,\n}: {\n config: Promise<SanitizedConfig> | SanitizedConfig\n params?: { [key: string]: string | string[] }\n //eslint-disable-next-line @typescript-eslint/require-await\n}): Promise<Metadata> => {\n const config = await configPromise\n\n const i18n = await getNextRequestI18n({\n config,\n })\n\n return {\n title: i18n.t('general:notFound'),\n }\n}\n\nexport type GenerateViewMetadata = (args: {\n config: SanitizedConfig\n i18n: I18n\n params?: { [key: string]: string | string[] }\n}) => Promise<Metadata>\n\nexport const NotFoundPage = async ({\n config: configPromise,\n searchParams,\n}: {\n config: Promise<SanitizedConfig>\n params: {\n segments: string[]\n }\n searchParams: {\n [key: string]: string | string[]\n }\n}) => {\n const config = await configPromise\n const { routes: { admin: adminRoute } = {} } = config\n\n const initPageResult = await initPage({\n config,\n redirectUnauthenticatedUser: true,\n route: `${adminRoute}/not-found`,\n searchParams,\n })\n\n return (\n <Fragment>\n <HydrateClientUser permissions={initPageResult.permissions} user={initPageResult.req.user} />\n <DefaultTemplate\n config={initPageResult.req.payload.config}\n visibleEntities={initPageResult.visibleEntities}\n >\n <NotFoundClient />\n </DefaultTemplate>\n </Fragment>\n )\n}\n\nexport const NotFoundView: AdminViewComponent = () => {\n return <NotFoundClient marginTop=\"large\" />\n}\n"],"names":["HydrateClientUser","DefaultTemplate","React","Fragment","getNextRequestI18n","initPage","NotFoundClient","generatePageMetadata","config","configPromise","i18n","title","t","NotFoundPage","searchParams","routes","admin","adminRoute","initPageResult","redirectUnauthenticatedUser","route","permissions","user","req","payload","visibleEntities","NotFoundView","marginTop"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,iBAAiB,QAAQ,4CAA2C;AAC7E,SAASC,eAAe,QAAQ,mCAAkC;AAClE,OAAOC,SAASC,QAAQ,QAAQ,QAAO;AAEvC,SAASC,kBAAkB,QAAQ,wCAAuC;AAC1E,SAASC,QAAQ,QAAQ,
|
|
1
|
+
{"version":3,"sources":["../../../src/views/NotFound/index.tsx"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { Metadata } from 'next'\nimport type { AdminViewComponent, SanitizedConfig } from 'payload/types'\n\nimport { HydrateClientUser } from '@payloadcms/ui/elements/HydrateClientUser'\nimport { DefaultTemplate } from '@payloadcms/ui/templates/Default'\nimport React, { Fragment } from 'react'\n\nimport { getNextRequestI18n } from '../../utilities/getNextRequestI18n.js'\nimport { initPage } from '../../utilities/initPage/index.js'\nimport { NotFoundClient } from './index.client.js'\n\nexport const generatePageMetadata = async ({\n config: configPromise,\n}: {\n config: Promise<SanitizedConfig> | SanitizedConfig\n params?: { [key: string]: string | string[] }\n //eslint-disable-next-line @typescript-eslint/require-await\n}): Promise<Metadata> => {\n const config = await configPromise\n\n const i18n = await getNextRequestI18n({\n config,\n })\n\n return {\n title: i18n.t('general:notFound'),\n }\n}\n\nexport type GenerateViewMetadata = (args: {\n config: SanitizedConfig\n i18n: I18n\n params?: { [key: string]: string | string[] }\n}) => Promise<Metadata>\n\nexport const NotFoundPage = async ({\n config: configPromise,\n searchParams,\n}: {\n config: Promise<SanitizedConfig>\n params: {\n segments: string[]\n }\n searchParams: {\n [key: string]: string | string[]\n }\n}) => {\n const config = await configPromise\n const { routes: { admin: adminRoute } = {} } = config\n\n const initPageResult = await initPage({\n config,\n redirectUnauthenticatedUser: true,\n route: `${adminRoute}/not-found`,\n searchParams,\n })\n\n return (\n <Fragment>\n <HydrateClientUser permissions={initPageResult.permissions} user={initPageResult.req.user} />\n <DefaultTemplate\n config={initPageResult.req.payload.config}\n visibleEntities={initPageResult.visibleEntities}\n >\n <NotFoundClient />\n </DefaultTemplate>\n </Fragment>\n )\n}\n\nexport const NotFoundView: AdminViewComponent = () => {\n return <NotFoundClient marginTop=\"large\" />\n}\n"],"names":["HydrateClientUser","DefaultTemplate","React","Fragment","getNextRequestI18n","initPage","NotFoundClient","generatePageMetadata","config","configPromise","i18n","title","t","NotFoundPage","searchParams","routes","admin","adminRoute","initPageResult","redirectUnauthenticatedUser","route","permissions","user","req","payload","visibleEntities","NotFoundView","marginTop"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,iBAAiB,QAAQ,4CAA2C;AAC7E,SAASC,eAAe,QAAQ,mCAAkC;AAClE,OAAOC,SAASC,QAAQ,QAAQ,QAAO;AAEvC,SAASC,kBAAkB,QAAQ,wCAAuC;AAC1E,SAASC,QAAQ,QAAQ,oCAAmC;AAC5D,SAASC,cAAc,QAAQ,oBAAmB;AAElD,OAAO,MAAMC,uBAAuB,OAAO,EACzCC,QAAQC,aAAa,EAKtB;IACC,MAAMD,SAAS,MAAMC;IAErB,MAAMC,OAAO,MAAMN,mBAAmB;QACpCI;IACF;IAEA,OAAO;QACLG,OAAOD,KAAKE,CAAC,CAAC;IAChB;AACF,EAAC;AAQD,OAAO,MAAMC,eAAe,OAAO,EACjCL,QAAQC,aAAa,EACrBK,YAAY,EASb;IACC,MAAMN,SAAS,MAAMC;IACrB,MAAM,EAAEM,QAAQ,EAAEC,OAAOC,UAAU,EAAE,GAAG,CAAC,CAAC,EAAE,GAAGT;IAE/C,MAAMU,iBAAiB,MAAMb,SAAS;QACpCG;QACAW,6BAA6B;QAC7BC,OAAO,CAAC,EAAEH,WAAW,UAAU,CAAC;QAChCH;IACF;IAEA,qBACE,oBAACX,8BACC,oBAACH;QAAkBqB,aAAaH,eAAeG,WAAW;QAAEC,MAAMJ,eAAeK,GAAG,CAACD,IAAI;sBACzF,oBAACrB;QACCO,QAAQU,eAAeK,GAAG,CAACC,OAAO,CAAChB,MAAM;QACzCiB,iBAAiBP,eAAeO,eAAe;qBAE/C,oBAACnB;AAIT,EAAC;AAED,OAAO,MAAMoB,eAAmC;IAC9C,qBAAO,oBAACpB;QAAeqB,WAAU;;AACnC,EAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SanitizedConfig } from 'payload/config';
|
|
2
2
|
import type { AdminViewComponent } from 'payload/types';
|
|
3
|
-
import type { initPage } from '../../utilities/initPage.js';
|
|
3
|
+
import type { initPage } from '../../utilities/initPage/index.js';
|
|
4
4
|
export declare const getViewFromConfig: ({ adminRoute, config, currentRoute, searchParams, segments, }: {
|
|
5
5
|
adminRoute;
|
|
6
6
|
config: SanitizedConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getViewFromConfig.d.ts","sourceRoot":"","sources":["../../../src/views/Root/getViewFromConfig.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAEvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"getViewFromConfig.d.ts","sourceRoot":"","sources":["../../../src/views/Root/getViewFromConfig.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAEvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAA;AA+BjE,eAAO,MAAM,iBAAiB,kEAM3B;IACD,UAAU,CAAA;IACV,MAAM,EAAE,eAAe,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,EAAE;QACZ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;KACjC,CAAA;IACD,QAAQ,EAAE,MAAM,EAAE,CAAA;CACnB,KAAG;IACF,WAAW,EAAE,kBAAkB,CAAA;IAC/B,eAAe,EAAE,WAAW,eAAe,CAAC,CAAC,CAAC,CAAC,CAAA;IAC/C,iBAAiB,EAAE,MAAM,CAAA;IACzB,YAAY,EAAE,SAAS,GAAG,SAAS,CAAA;CA+GpC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/views/Root/getViewFromConfig.tsx"],"sourcesContent":["import type { SanitizedConfig } from 'payload/config'\nimport type { AdminViewComponent } from 'payload/types'\n\nimport type { initPage } from '../../utilities/initPage.js'\n\nimport { Account } from '../Account/index.js'\nimport { CreateFirstUserView } from '../CreateFirstUser/index.js'\nimport { Dashboard } from '../Dashboard/index.js'\nimport { Document as DocumentView } from '../Document/index.js'\nimport { ForgotPasswordView, forgotPasswordBaseClass } from '../ForgotPassword/index.js'\nimport { ListView } from '../List/index.js'\nimport { LoginView, loginBaseClass } from '../Login/index.js'\nimport { LogoutInactivity, LogoutView } from '../Logout/index.js'\nimport { ResetPassword, resetPasswordBaseClass } from '../ResetPassword/index.js'\nimport { UnauthorizedView } from '../Unauthorized/index.js'\nimport { Verify, verifyBaseClass } from '../Verify/index.js'\nimport { getCustomViewByRoute } from './getCustomViewByRoute.js'\n\nconst baseClasses = {\n forgot: forgotPasswordBaseClass,\n login: loginBaseClass,\n reset: resetPasswordBaseClass,\n verify: verifyBaseClass,\n}\n\nconst oneSegmentViews = {\n 'create-first-user': CreateFirstUserView,\n forgot: ForgotPasswordView,\n login: LoginView,\n logout: LogoutView,\n 'logout-inactivity': LogoutInactivity,\n unauthorized: UnauthorizedView,\n}\n\nexport const getViewFromConfig = ({\n adminRoute,\n config,\n currentRoute,\n searchParams,\n segments,\n}: {\n adminRoute\n config: SanitizedConfig\n currentRoute: string\n searchParams: {\n [key: string]: string | string[]\n }\n segments: string[]\n}): {\n DefaultView: AdminViewComponent\n initPageOptions: Parameters<typeof initPage>[0]\n templateClassName: string\n templateType: 'default' | 'minimal'\n} => {\n let ViewToRender: AdminViewComponent = null\n let templateClassName: string\n let templateType: 'default' | 'minimal' = 'minimal'\n\n const initPageOptions: Parameters<typeof initPage>[0] = {\n config,\n route: currentRoute,\n searchParams,\n }\n\n const [segmentOne, segmentTwo] = segments\n\n const isGlobal = segmentOne === 'globals'\n const isCollection = segmentOne === 'collections'\n\n switch (segments.length) {\n case 0: {\n if (currentRoute === adminRoute) {\n ViewToRender = Dashboard\n templateClassName = 'dashboard'\n templateType = 'default'\n initPageOptions.redirectUnauthenticatedUser = true\n }\n break\n }\n case 1: {\n if (oneSegmentViews[segmentOne] && segmentOne !== 'account') {\n // --> /create-first-user\n // --> /forgot\n // --> /login\n // --> /logout\n // --> /logout-inactivity\n // --> /unauthorized\n ViewToRender = oneSegmentViews[segmentOne]\n templateClassName = baseClasses[segmentOne]\n templateType = 'minimal'\n } else if (segmentOne === 'account') {\n // --> /account\n initPageOptions.redirectUnauthenticatedUser = true\n ViewToRender = Account\n templateClassName = 'account'\n templateType = 'default'\n }\n break\n }\n case 2: {\n if (segmentOne === 'reset') {\n // --> /reset/:token\n ViewToRender = ResetPassword\n templateClassName = baseClasses[segmentTwo]\n templateType = 'minimal'\n }\n\n if (isCollection) {\n // --> /collections/:collectionSlug\n initPageOptions.redirectUnauthenticatedUser = true\n ViewToRender = ListView\n templateClassName = `${segmentTwo}-list`\n templateType = 'default'\n } else if (isGlobal) {\n // --> /globals/:globalSlug\n initPageOptions.redirectUnauthenticatedUser = true\n ViewToRender = DocumentView\n templateClassName = 'global-edit'\n templateType = 'default'\n }\n break\n }\n default:\n if (segmentTwo === 'verify') {\n // --> /:collectionSlug/verify/:token\n ViewToRender = Verify\n templateClassName = 'verify'\n templateType = 'minimal'\n } else if (isCollection) {\n // Custom Views\n // --> /collections/:collectionSlug/:id\n // --> /collections/:collectionSlug/:id/preview\n // --> /collections/:collectionSlug/:id/versions\n // --> /collections/:collectionSlug/:id/versions/:versionId\n // --> /collections/:collectionSlug/:id/api\n initPageOptions.redirectUnauthenticatedUser = true\n ViewToRender = DocumentView\n templateClassName = `collection-default-edit`\n templateType = 'default'\n } else if (isGlobal) {\n // Custom Views\n // --> /globals/:globalSlug/versions\n // --> /globals/:globalSlug/preview\n // --> /globals/:globalSlug/versions/:versionId\n // --> /globals/:globalSlug/api\n initPageOptions.redirectUnauthenticatedUser = true\n ViewToRender = DocumentView\n templateClassName = `global-edit`\n templateType = 'default'\n }\n break\n }\n\n if (!ViewToRender) {\n ViewToRender = getCustomViewByRoute({ config, currentRoute })\n }\n\n return {\n DefaultView: ViewToRender,\n initPageOptions,\n templateClassName,\n templateType,\n }\n}\n"],"names":["Account","CreateFirstUserView","Dashboard","Document","DocumentView","ForgotPasswordView","forgotPasswordBaseClass","ListView","LoginView","loginBaseClass","LogoutInactivity","LogoutView","ResetPassword","resetPasswordBaseClass","UnauthorizedView","Verify","verifyBaseClass","getCustomViewByRoute","baseClasses","forgot","login","reset","verify","oneSegmentViews","logout","unauthorized","getViewFromConfig","adminRoute","config","currentRoute","searchParams","segments","ViewToRender","templateClassName","templateType","initPageOptions","route","segmentOne","segmentTwo","isGlobal","isCollection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f6B,oBAAoB,CAAC,uBAAuB,CAAC;gBAC7CC,eAAe;YACjB,OAAO,IAAIK,UAAU;gBACnB,eAAe;gBACf,oCAAoC;gBACpC,mCAAmC;gBACnC,+CAA+C;gBAC/C,+BAA+B;gBAC/BJ,gBAAgBO,2BAA2B,GAAG;gBAC9CV,eAAe5B;gBACf6B,oBAAoB,CAAC,WAAW,CAAC;gBACjCC,eAAe;YACjB;YACA;IACJ;IAEA,IAAI,CAACF,cAAc;QACjBA,eAAef,qBAAqB;YAAEW;YAAQC;QAAa;IAC7D;IAEA,OAAO;QACLc,aAAaX;QACbG;QACAF;QACAC;IACF;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/views/Root/getViewFromConfig.tsx"],"sourcesContent":["import type { SanitizedConfig } from 'payload/config'\nimport type { AdminViewComponent } from 'payload/types'\n\nimport type { initPage } from '../../utilities/initPage/index.js'\n\nimport { Account } from '../Account/index.js'\nimport { CreateFirstUserView } from '../CreateFirstUser/index.js'\nimport { Dashboard } from '../Dashboard/index.js'\nimport { Document as DocumentView } from '../Document/index.js'\nimport { ForgotPasswordView, forgotPasswordBaseClass } from '../ForgotPassword/index.js'\nimport { ListView } from '../List/index.js'\nimport { LoginView, loginBaseClass } from '../Login/index.js'\nimport { LogoutInactivity, LogoutView } from '../Logout/index.js'\nimport { ResetPassword, resetPasswordBaseClass } from '../ResetPassword/index.js'\nimport { UnauthorizedView } from '../Unauthorized/index.js'\nimport { Verify, verifyBaseClass } from '../Verify/index.js'\nimport { getCustomViewByRoute } from './getCustomViewByRoute.js'\n\nconst baseClasses = {\n forgot: forgotPasswordBaseClass,\n login: loginBaseClass,\n reset: resetPasswordBaseClass,\n verify: verifyBaseClass,\n}\n\nconst oneSegmentViews = {\n 'create-first-user': CreateFirstUserView,\n forgot: ForgotPasswordView,\n login: LoginView,\n logout: LogoutView,\n 'logout-inactivity': LogoutInactivity,\n unauthorized: UnauthorizedView,\n}\n\nexport const getViewFromConfig = ({\n adminRoute,\n config,\n currentRoute,\n searchParams,\n segments,\n}: {\n adminRoute\n config: SanitizedConfig\n currentRoute: string\n searchParams: {\n [key: string]: string | string[]\n }\n segments: string[]\n}): {\n DefaultView: AdminViewComponent\n initPageOptions: Parameters<typeof initPage>[0]\n templateClassName: string\n templateType: 'default' | 'minimal'\n} => {\n let ViewToRender: AdminViewComponent = null\n let templateClassName: string\n let templateType: 'default' | 'minimal' = 'minimal'\n\n const initPageOptions: Parameters<typeof initPage>[0] = {\n config,\n route: currentRoute,\n searchParams,\n }\n\n const [segmentOne, segmentTwo] = segments\n\n const isGlobal = segmentOne === 'globals'\n const isCollection = segmentOne === 'collections'\n\n switch (segments.length) {\n case 0: {\n if (currentRoute === adminRoute) {\n ViewToRender = Dashboard\n templateClassName = 'dashboard'\n templateType = 'default'\n initPageOptions.redirectUnauthenticatedUser = true\n }\n break\n }\n case 1: {\n if (oneSegmentViews[segmentOne] && segmentOne !== 'account') {\n // --> /create-first-user\n // --> /forgot\n // --> /login\n // --> /logout\n // --> /logout-inactivity\n // --> /unauthorized\n ViewToRender = oneSegmentViews[segmentOne]\n templateClassName = baseClasses[segmentOne]\n templateType = 'minimal'\n } else if (segmentOne === 'account') {\n // --> /account\n initPageOptions.redirectUnauthenticatedUser = true\n ViewToRender = Account\n templateClassName = 'account'\n templateType = 'default'\n }\n break\n }\n case 2: {\n if (segmentOne === 'reset') {\n // --> /reset/:token\n ViewToRender = ResetPassword\n templateClassName = baseClasses[segmentTwo]\n templateType = 'minimal'\n }\n\n if (isCollection) {\n // --> /collections/:collectionSlug\n initPageOptions.redirectUnauthenticatedUser = true\n ViewToRender = ListView\n templateClassName = `${segmentTwo}-list`\n templateType = 'default'\n } else if (isGlobal) {\n // --> /globals/:globalSlug\n initPageOptions.redirectUnauthenticatedUser = true\n ViewToRender = DocumentView\n templateClassName = 'global-edit'\n templateType = 'default'\n }\n break\n }\n default:\n if (segmentTwo === 'verify') {\n // --> /:collectionSlug/verify/:token\n ViewToRender = Verify\n templateClassName = 'verify'\n templateType = 'minimal'\n } else if (isCollection) {\n // Custom Views\n // --> /collections/:collectionSlug/:id\n // --> /collections/:collectionSlug/:id/preview\n // --> /collections/:collectionSlug/:id/versions\n // --> /collections/:collectionSlug/:id/versions/:versionId\n // --> /collections/:collectionSlug/:id/api\n initPageOptions.redirectUnauthenticatedUser = true\n ViewToRender = DocumentView\n templateClassName = `collection-default-edit`\n templateType = 'default'\n } else if (isGlobal) {\n // Custom Views\n // --> /globals/:globalSlug/versions\n // --> /globals/:globalSlug/preview\n // --> /globals/:globalSlug/versions/:versionId\n // --> /globals/:globalSlug/api\n initPageOptions.redirectUnauthenticatedUser = true\n ViewToRender = DocumentView\n templateClassName = `global-edit`\n templateType = 'default'\n }\n break\n }\n\n if (!ViewToRender) {\n ViewToRender = getCustomViewByRoute({ config, currentRoute })\n }\n\n return {\n DefaultView: ViewToRender,\n initPageOptions,\n templateClassName,\n templateType,\n }\n}\n"],"names":["Account","CreateFirstUserView","Dashboard","Document","DocumentView","ForgotPasswordView","forgotPasswordBaseClass","ListView","LoginView","loginBaseClass","LogoutInactivity","LogoutView","ResetPassword","resetPasswordBaseClass","UnauthorizedView","Verify","verifyBaseClass","getCustomViewByRoute","baseClasses","forgot","login","reset","verify","oneSegmentViews","logout","unauthorized","getViewFromConfig","adminRoute","config","currentRoute","searchParams","segments","ViewToRender","templateClassName","templateType","initPageOptions","route","segmentOne","segmentTwo","isGlobal","isCollection","length","redirectUnauthenticatedUser","DefaultView"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAKA,SAASA,OAAO,QAAQ,sBAAqB;AAC7C,SAASC,mBAAmB,QAAQ,8BAA6B;AACjE,SAASC,SAAS,QAAQ,wBAAuB;AACjD,SAASC,YAAYC,YAAY,QAA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;IAEA,OAAO;QACLc,aAAaX;QACbG;QACAF;QACAC;IACF;AACF,EAAC"}
|
package/dist/views/Root/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { DefaultTemplate } from '@payloadcms/ui/templates/Default';
|
|
|
2
2
|
import { MinimalTemplate } from '@payloadcms/ui/templates/Minimal';
|
|
3
3
|
import { notFound, redirect } from 'next/navigation.js';
|
|
4
4
|
import React, { Fragment } from 'react';
|
|
5
|
-
import { initPage } from '../../utilities/initPage.js';
|
|
5
|
+
import { initPage } from '../../utilities/initPage/index.js';
|
|
6
6
|
import { getViewFromConfig } from './getViewFromConfig.js';
|
|
7
7
|
export { generatePageMetadata } from './meta.js';
|
|
8
8
|
export const RootPage = async ({ config: configPromise, params, searchParams })=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/views/Root/index.tsx"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { Metadata } from 'next'\nimport type { SanitizedConfig } from 'payload/types'\n\nimport { DefaultTemplate } from '@payloadcms/ui/templates/Default'\nimport { MinimalTemplate } from '@payloadcms/ui/templates/Minimal'\nimport { notFound, redirect } from 'next/navigation.js'\nimport React, { Fragment } from 'react'\n\nimport { initPage } from '../../utilities/initPage.js'\nimport { getViewFromConfig } from './getViewFromConfig.js'\n\nexport { generatePageMetadata } from './meta.js'\n\nexport type GenerateViewMetadata = (args: {\n config: SanitizedConfig\n i18n: I18n\n params?: { [key: string]: string | string[] }\n}) => Promise<Metadata>\n\nexport const RootPage = async ({\n config: configPromise,\n params,\n searchParams,\n}: {\n config: Promise<SanitizedConfig>\n params: {\n segments: string[]\n }\n searchParams: {\n [key: string]: string | string[]\n }\n}) => {\n const config = await configPromise\n\n const {\n admin: { user: userSlug },\n routes: { admin: adminRoute },\n } = config\n\n const currentRoute = `${adminRoute}${Array.isArray(params.segments) ? `/${params.segments.join('/')}` : ''}`\n\n const segments = Array.isArray(params.segments) ? params.segments : []\n\n const { DefaultView, initPageOptions, templateClassName, templateType } = getViewFromConfig({\n adminRoute,\n config,\n currentRoute,\n searchParams,\n segments,\n })\n\n let dbHasUser = false\n\n if (!DefaultView) {\n notFound()\n }\n\n const initPageResult = await initPage(initPageOptions)\n\n if (initPageResult) {\n dbHasUser = await initPageResult?.req.payload.db\n .findOne({\n collection: userSlug,\n req: initPageResult?.req,\n })\n ?.then((doc) => !!doc)\n\n const createFirstUserRoute = `${adminRoute}/create-first-user`\n\n if (!dbHasUser && currentRoute !== createFirstUserRoute) {\n redirect(createFirstUserRoute)\n }\n\n if (dbHasUser && currentRoute === createFirstUserRoute) {\n redirect(adminRoute)\n }\n }\n\n const RenderedView = (\n <DefaultView initPageResult={initPageResult} params={params} searchParams={searchParams} />\n )\n\n return (\n <Fragment>\n {templateType === 'minimal' && (\n <MinimalTemplate className={templateClassName}>{RenderedView}</MinimalTemplate>\n )}\n {templateType === 'default' && (\n <DefaultTemplate config={config} visibleEntities={initPageResult.visibleEntities}>\n {RenderedView}\n </DefaultTemplate>\n )}\n </Fragment>\n )\n}\n"],"names":["DefaultTemplate","MinimalTemplate","notFound","redirect","React","Fragment","initPage","getViewFromConfig","generatePageMetadata","RootPage","config","configPromise","params","searchParams","admin","user","userSlug","routes","adminRoute","currentRoute","Array","isArray","segments","join","DefaultView","initPageOptions","templateClassName","templateType","dbHasUser","initPageResult","req","payload","db","findOne","collection","then","doc","createFirstUserRoute","RenderedView","className","visibleEntities"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,eAAe,QAAQ,mCAAkC;AAClE,SAASC,eAAe,QAAQ,mCAAkC;AAClE,SAASC,QAAQ,EAAEC,QAAQ,QAAQ,qBAAoB;AACvD,OAAOC,SAASC,QAAQ,QAAQ,QAAO;AAEvC,SAASC,QAAQ,QAAQ,
|
|
1
|
+
{"version":3,"sources":["../../../src/views/Root/index.tsx"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { Metadata } from 'next'\nimport type { SanitizedConfig } from 'payload/types'\n\nimport { DefaultTemplate } from '@payloadcms/ui/templates/Default'\nimport { MinimalTemplate } from '@payloadcms/ui/templates/Minimal'\nimport { notFound, redirect } from 'next/navigation.js'\nimport React, { Fragment } from 'react'\n\nimport { initPage } from '../../utilities/initPage/index.js'\nimport { getViewFromConfig } from './getViewFromConfig.js'\n\nexport { generatePageMetadata } from './meta.js'\n\nexport type GenerateViewMetadata = (args: {\n config: SanitizedConfig\n i18n: I18n\n params?: { [key: string]: string | string[] }\n}) => Promise<Metadata>\n\nexport const RootPage = async ({\n config: configPromise,\n params,\n searchParams,\n}: {\n config: Promise<SanitizedConfig>\n params: {\n segments: string[]\n }\n searchParams: {\n [key: string]: string | string[]\n }\n}) => {\n const config = await configPromise\n\n const {\n admin: { user: userSlug },\n routes: { admin: adminRoute },\n } = config\n\n const currentRoute = `${adminRoute}${Array.isArray(params.segments) ? `/${params.segments.join('/')}` : ''}`\n\n const segments = Array.isArray(params.segments) ? params.segments : []\n\n const { DefaultView, initPageOptions, templateClassName, templateType } = getViewFromConfig({\n adminRoute,\n config,\n currentRoute,\n searchParams,\n segments,\n })\n\n let dbHasUser = false\n\n if (!DefaultView) {\n notFound()\n }\n\n const initPageResult = await initPage(initPageOptions)\n\n if (initPageResult) {\n dbHasUser = await initPageResult?.req.payload.db\n .findOne({\n collection: userSlug,\n req: initPageResult?.req,\n })\n ?.then((doc) => !!doc)\n\n const createFirstUserRoute = `${adminRoute}/create-first-user`\n\n if (!dbHasUser && currentRoute !== createFirstUserRoute) {\n redirect(createFirstUserRoute)\n }\n\n if (dbHasUser && currentRoute === createFirstUserRoute) {\n redirect(adminRoute)\n }\n }\n\n const RenderedView = (\n <DefaultView initPageResult={initPageResult} params={params} searchParams={searchParams} />\n )\n\n return (\n <Fragment>\n {templateType === 'minimal' && (\n <MinimalTemplate className={templateClassName}>{RenderedView}</MinimalTemplate>\n )}\n {templateType === 'default' && (\n <DefaultTemplate config={config} visibleEntities={initPageResult.visibleEntities}>\n {RenderedView}\n </DefaultTemplate>\n )}\n </Fragment>\n )\n}\n"],"names":["DefaultTemplate","MinimalTemplate","notFound","redirect","React","Fragment","initPage","getViewFromConfig","generatePageMetadata","RootPage","config","configPromise","params","searchParams","admin","user","userSlug","routes","adminRoute","currentRoute","Array","isArray","segments","join","DefaultView","initPageOptions","templateClassName","templateType","dbHasUser","initPageResult","req","payload","db","findOne","collection","then","doc","createFirstUserRoute","RenderedView","className","visibleEntities"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,eAAe,QAAQ,mCAAkC;AAClE,SAASC,eAAe,QAAQ,mCAAkC;AAClE,SAASC,QAAQ,EAAEC,QAAQ,QAAQ,qBAAoB;AACvD,OAAOC,SAASC,QAAQ,QAAQ,QAAO;AAEvC,SAASC,QAAQ,QAAQ,oCAAmC;AAC5D,SAASC,iBAAiB,QAAQ,yBAAwB;AAE1D,SAASC,oBAAoB,QAAQ,YAAW;AAQhD,OAAO,MAAMC,WAAW,OAAO,EAC7BC,QAAQC,aAAa,EACrBC,MAAM,EACNC,YAAY,EASb;IACC,MAAMH,SAAS,MAAMC;IAErB,MAAM,EACJG,OAAO,EAAEC,MAAMC,QAAQ,EAAE,EACzBC,QAAQ,EAAEH,OAAOI,UAAU,EAAE,EAC9B,GAAGR;IAEJ,MAAMS,eAAe,CAAC,EAAED,WAAW,EAAEE,MAAMC,OAAO,CAACT,OAAOU,QAAQ,IAAI,CAAC,CAAC,EAAEV,OAAOU,QAAQ,CAACC,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC;IAE5G,MAAMD,WAAWF,MAAMC,OAAO,CAACT,OAAOU,QAAQ,IAAIV,OAAOU,QAAQ,GAAG,EAAE;IAEtE,MAAM,EAAEE,WAAW,EAAEC,eAAe,EAAEC,iBAAiB,EAAEC,YAAY,EAAE,GAAGpB,kBAAkB;QAC1FW;QACAR;QACAS;QACAN;QACAS;IACF;IAEA,IAAIM,YAAY;IAEhB,IAAI,CAACJ,aAAa;QAChBtB;IACF;IAEA,MAAM2B,iBAAiB,MAAMvB,SAASmB;IAEtC,IAAII,gBAAgB;QAClBD,YAAY,MAAMC,gBAAgBC,IAAIC,QAAQC,GAC3CC,QAAQ;YACPC,YAAYlB;YACZc,KAAKD,gBAAgBC;QACvB,IACEK,KAAK,CAACC,MAAQ,CAAC,CAACA;QAEpB,MAAMC,uBAAuB,CAAC,EAAEnB,WAAW,kBAAkB,CAAC;QAE9D,IAAI,CAACU,aAAaT,iBAAiBkB,sBAAsB;YACvDlC,SAASkC;QACX;QAEA,IAAIT,aAAaT,iBAAiBkB,sBAAsB;YACtDlC,SAASe;QACX;IACF;IAEA,MAAMoB,6BACJ,oBAACd;QAAYK,gBAAgBA;QAAgBjB,QAAQA;QAAQC,cAAcA;;IAG7E,qBACE,oBAACR,gBACEsB,iBAAiB,2BAChB,oBAAC1B;QAAgBsC,WAAWb;OAAoBY,eAEjDX,iBAAiB,2BAChB,oBAAC3B;QAAgBU,QAAQA;QAAQ8B,iBAAiBX,eAAeW,eAAe;OAC7EF;AAKX,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/next",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.24",
|
|
4
4
|
"homepage": "https://payloadcms.com",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"react-toastify": "8.2.0",
|
|
45
45
|
"sass": "^1.71.1",
|
|
46
46
|
"ws": "^8.16.0",
|
|
47
|
-
"@payloadcms/
|
|
48
|
-
"@payloadcms/
|
|
49
|
-
"@payloadcms/ui": "3.0.0-beta.
|
|
47
|
+
"@payloadcms/translations": "3.0.0-beta.24",
|
|
48
|
+
"@payloadcms/graphql": "3.0.0-beta.24",
|
|
49
|
+
"@payloadcms/ui": "3.0.0-beta.24"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@next/eslint-plugin-next": "^14.1.0",
|
|
@@ -64,13 +64,13 @@
|
|
|
64
64
|
"terser-webpack-plugin": "^5.3.10",
|
|
65
65
|
"webpack": "^5.78.0",
|
|
66
66
|
"webpack-cli": "^5.1.4",
|
|
67
|
-
"
|
|
68
|
-
"
|
|
67
|
+
"payload": "3.0.0-beta.24",
|
|
68
|
+
"@payloadcms/eslint-config": "1.1.1"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
71
|
"graphql": "^16.8.1",
|
|
72
72
|
"next": "^14.3.0-canary.7",
|
|
73
|
-
"payload": "3.0.0-beta.
|
|
73
|
+
"payload": "3.0.0-beta.24"
|
|
74
74
|
},
|
|
75
75
|
"engines": {
|
|
76
76
|
"node": ">=18.20.2"
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { InitPageResult, SanitizedConfig } from 'payload/types';
|
|
2
|
-
type Args = {
|
|
3
|
-
config: Promise<SanitizedConfig> | SanitizedConfig;
|
|
4
|
-
redirectUnauthenticatedUser?: boolean;
|
|
5
|
-
route: string;
|
|
6
|
-
searchParams: {
|
|
7
|
-
[key: string]: string | string[] | undefined;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
export declare const initPage: ({ config: configPromise, redirectUnauthenticatedUser, route, searchParams, }: Args) => Promise<InitPageResult>;
|
|
11
|
-
export {};
|
|
12
|
-
//# sourceMappingURL=initPage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"initPage.d.ts","sourceRoot":"","sources":["../../src/utilities/initPage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EAGd,eAAe,EAGhB,MAAM,eAAe,CAAA;AAatB,KAAK,IAAI,GAAG;IACV,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAA;IAClD,2BAA2B,CAAC,EAAE,OAAO,CAAA;IACrC,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAA;KAAE,CAAA;CAC/D,CAAA;AAYD,eAAO,MAAM,QAAQ,iFAKlB,IAAI,KAAG,QAAQ,cAAc,CA0G/B,CAAA"}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { initI18n } from '@payloadcms/translations';
|
|
2
|
-
import { findLocaleFromCode } from '@payloadcms/ui/utilities/findLocaleFromCode';
|
|
3
|
-
import { headers as getHeaders } from 'next/headers.js';
|
|
4
|
-
import { notFound, redirect } from 'next/navigation.js';
|
|
5
|
-
import { parseCookies } from 'payload/auth';
|
|
6
|
-
import { createLocalReq, isEntityHidden } from 'payload/utilities';
|
|
7
|
-
import qs from 'qs';
|
|
8
|
-
import { getPayloadHMR } from '../utilities/getPayloadHMR.js';
|
|
9
|
-
import { getRequestLanguage } from './getRequestLanguage.js';
|
|
10
|
-
const authRoutes = [
|
|
11
|
-
'/login',
|
|
12
|
-
'/logout',
|
|
13
|
-
'/create-first-user',
|
|
14
|
-
'/forgot',
|
|
15
|
-
'/reset',
|
|
16
|
-
'/verify',
|
|
17
|
-
'/logout-inactivity'
|
|
18
|
-
];
|
|
19
|
-
export const initPage = async ({ config: configPromise, redirectUnauthenticatedUser = false, route, searchParams })=>{
|
|
20
|
-
const headers = getHeaders();
|
|
21
|
-
const localeParam = searchParams?.locale;
|
|
22
|
-
const payload = await getPayloadHMR({
|
|
23
|
-
config: configPromise
|
|
24
|
-
});
|
|
25
|
-
const { collections, globals, localization, routes } = payload.config;
|
|
26
|
-
const queryString = `${qs.stringify(searchParams ?? {}, {
|
|
27
|
-
addQueryPrefix: true
|
|
28
|
-
})}`;
|
|
29
|
-
const defaultLocale = localization && localization.defaultLocale ? localization.defaultLocale : 'en';
|
|
30
|
-
const localeCode = localeParam || defaultLocale;
|
|
31
|
-
const locale = localization && findLocaleFromCode(localization, localeCode);
|
|
32
|
-
const cookies = parseCookies(headers);
|
|
33
|
-
const language = getRequestLanguage({
|
|
34
|
-
config: payload.config,
|
|
35
|
-
cookies,
|
|
36
|
-
headers
|
|
37
|
-
});
|
|
38
|
-
const i18n = await initI18n({
|
|
39
|
-
config: payload.config.i18n,
|
|
40
|
-
context: 'client',
|
|
41
|
-
language
|
|
42
|
-
});
|
|
43
|
-
const req = await createLocalReq({
|
|
44
|
-
fallbackLocale: null,
|
|
45
|
-
locale: locale.code,
|
|
46
|
-
req: {
|
|
47
|
-
i18n,
|
|
48
|
-
query: qs.parse(queryString, {
|
|
49
|
-
depth: 10,
|
|
50
|
-
ignoreQueryPrefix: true
|
|
51
|
-
}),
|
|
52
|
-
url: `${payload.config.serverURL}${route}${searchParams ? queryString : ''}`
|
|
53
|
-
}
|
|
54
|
-
}, payload);
|
|
55
|
-
const { permissions, user } = await payload.auth({
|
|
56
|
-
headers,
|
|
57
|
-
req
|
|
58
|
-
});
|
|
59
|
-
req.user = user;
|
|
60
|
-
const visibleEntities = {
|
|
61
|
-
collections: payload.config.collections.map(({ slug, admin: { hidden } })=>!isEntityHidden({
|
|
62
|
-
hidden,
|
|
63
|
-
user
|
|
64
|
-
}) ? slug : null).filter(Boolean),
|
|
65
|
-
globals: payload.config.globals.map(({ slug, admin: { hidden } })=>!isEntityHidden({
|
|
66
|
-
hidden,
|
|
67
|
-
user
|
|
68
|
-
}) ? slug : null).filter(Boolean)
|
|
69
|
-
};
|
|
70
|
-
const { routes: { admin: adminRoute } } = payload.config;
|
|
71
|
-
const routeSegments = route.replace(adminRoute, '').split('/').filter(Boolean);
|
|
72
|
-
const [entityType, entitySlug, createOrID] = routeSegments;
|
|
73
|
-
const collectionSlug = entityType === 'collections' ? entitySlug : undefined;
|
|
74
|
-
const globalSlug = entityType === 'globals' ? entitySlug : undefined;
|
|
75
|
-
const docID = collectionSlug && createOrID !== 'create' ? createOrID : undefined;
|
|
76
|
-
const isAdminRoute = route.startsWith(adminRoute);
|
|
77
|
-
const isAuthRoute = authRoutes.some((r)=>route.replace(adminRoute, '').startsWith(r));
|
|
78
|
-
if (redirectUnauthenticatedUser && !user && !isAuthRoute) {
|
|
79
|
-
if (searchParams && 'redirect' in searchParams) delete searchParams.redirect;
|
|
80
|
-
const stringifiedSearchParams = Object.keys(searchParams ?? {}).length ? `?${qs.stringify(searchParams)}` : '';
|
|
81
|
-
redirect(`${routes.admin}/login?redirect=${route + stringifiedSearchParams}`);
|
|
82
|
-
}
|
|
83
|
-
if (!permissions.canAccessAdmin && isAdminRoute && !isAuthRoute) {
|
|
84
|
-
notFound();
|
|
85
|
-
}
|
|
86
|
-
let collectionConfig;
|
|
87
|
-
let globalConfig;
|
|
88
|
-
if (collectionSlug) {
|
|
89
|
-
collectionConfig = collections.find((collection)=>collection.slug === collectionSlug);
|
|
90
|
-
if (!collectionConfig) {
|
|
91
|
-
notFound();
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
if (globalSlug) {
|
|
95
|
-
globalConfig = globals.find((global)=>global.slug === globalSlug);
|
|
96
|
-
if (!globalConfig) {
|
|
97
|
-
notFound();
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return {
|
|
101
|
-
collectionConfig,
|
|
102
|
-
cookies,
|
|
103
|
-
docID,
|
|
104
|
-
globalConfig,
|
|
105
|
-
locale,
|
|
106
|
-
permissions,
|
|
107
|
-
req,
|
|
108
|
-
translations: i18n.translations,
|
|
109
|
-
visibleEntities
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
//# sourceMappingURL=initPage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/initPage.ts"],"sourcesContent":["import type {\n InitPageResult,\n PayloadRequestWithData,\n SanitizedCollectionConfig,\n SanitizedConfig,\n SanitizedGlobalConfig,\n VisibleEntities,\n} from 'payload/types'\n\nimport { initI18n } from '@payloadcms/translations'\nimport { findLocaleFromCode } from '@payloadcms/ui/utilities/findLocaleFromCode'\nimport { headers as getHeaders } from 'next/headers.js'\nimport { notFound, redirect } from 'next/navigation.js'\nimport { parseCookies } from 'payload/auth'\nimport { createLocalReq, isEntityHidden } from 'payload/utilities'\nimport qs from 'qs'\n\nimport { getPayloadHMR } from '../utilities/getPayloadHMR.js'\nimport { getRequestLanguage } from './getRequestLanguage.js'\n\ntype Args = {\n config: Promise<SanitizedConfig> | SanitizedConfig\n redirectUnauthenticatedUser?: boolean\n route: string\n searchParams: { [key: string]: string | string[] | undefined }\n}\n\nconst authRoutes = [\n '/login',\n '/logout',\n '/create-first-user',\n '/forgot',\n '/reset',\n '/verify',\n '/logout-inactivity',\n]\n\nexport const initPage = async ({\n config: configPromise,\n redirectUnauthenticatedUser = false,\n route,\n searchParams,\n}: Args): Promise<InitPageResult> => {\n const headers = getHeaders()\n const localeParam = searchParams?.locale as string\n const payload = await getPayloadHMR({ config: configPromise })\n const { collections, globals, localization, routes } = payload.config\n\n const queryString = `${qs.stringify(searchParams ?? {}, { addQueryPrefix: true })}`\n const defaultLocale =\n localization && localization.defaultLocale ? localization.defaultLocale : 'en'\n const localeCode = localeParam || defaultLocale\n const locale = localization && findLocaleFromCode(localization, localeCode)\n const cookies = parseCookies(headers)\n const language = getRequestLanguage({ config: payload.config, cookies, headers })\n\n const i18n = await initI18n({\n config: payload.config.i18n,\n context: 'client',\n language,\n })\n\n const req = await createLocalReq(\n {\n fallbackLocale: null,\n locale: locale.code,\n req: {\n i18n,\n query: qs.parse(queryString, {\n depth: 10,\n ignoreQueryPrefix: true,\n }),\n url: `${payload.config.serverURL}${route}${searchParams ? queryString : ''}`,\n } as PayloadRequestWithData,\n },\n payload,\n )\n\n const { permissions, user } = await payload.auth({ headers, req })\n\n req.user = user\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 {\n routes: { admin: adminRoute },\n } = payload.config\n\n const routeSegments = route.replace(adminRoute, '').split('/').filter(Boolean)\n const [entityType, entitySlug, createOrID] = routeSegments\n const collectionSlug = entityType === 'collections' ? entitySlug : undefined\n const globalSlug = entityType === 'globals' ? entitySlug : undefined\n const docID = collectionSlug && createOrID !== 'create' ? createOrID : undefined\n\n const isAdminRoute = route.startsWith(adminRoute)\n const isAuthRoute = authRoutes.some((r) => route.replace(adminRoute, '').startsWith(r))\n\n if (redirectUnauthenticatedUser && !user && !isAuthRoute) {\n if (searchParams && 'redirect' in searchParams) delete searchParams.redirect\n\n const stringifiedSearchParams = Object.keys(searchParams ?? {}).length\n ? `?${qs.stringify(searchParams)}`\n : ''\n\n redirect(`${routes.admin}/login?redirect=${route + stringifiedSearchParams}`)\n }\n\n if (!permissions.canAccessAdmin && isAdminRoute && !isAuthRoute) {\n notFound()\n }\n\n let collectionConfig: SanitizedCollectionConfig\n let globalConfig: SanitizedGlobalConfig\n\n if (collectionSlug) {\n collectionConfig = collections.find((collection) => collection.slug === collectionSlug)\n\n if (!collectionConfig) {\n notFound()\n }\n }\n\n if (globalSlug) {\n globalConfig = globals.find((global) => global.slug === globalSlug)\n\n if (!globalConfig) {\n notFound()\n }\n }\n\n return {\n collectionConfig,\n cookies,\n docID,\n globalConfig,\n locale,\n permissions,\n req,\n translations: i18n.translations,\n visibleEntities,\n }\n}\n"],"names":["initI18n","findLocaleFromCode","headers","getHeaders","notFound","redirect","parseCookies","createLocalReq","isEntityHidden","qs","getPayloadHMR","getRequestLanguage","authRoutes","initPage","config","configPromise","redirectUnauthenticatedUser","route","searchParams","localeParam","locale","payload","collections","globals","localization","routes","queryString","stringify","addQueryPrefix","defaultLocale","localeCode","cookies","language","i18n","context","req","fallbackLocale","code","query","parse","depth","ignoreQueryPrefix","url","serverURL","permissions","user","auth","visibleEntities","map","slug","admin","hidden","filter","Boolean","adminRoute","routeSegments","replace","split","entityType","entitySlug","createOrID","collectionSlug","undefined","globalSlug","docID","isAdminRoute","startsWith","isAuthRoute","some","r","stringifiedSearchParams","Object","keys","length","canAccessAdmin","collectionConfig","globalConfig","find","collection","global","translations"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AASA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,kBAAkB,QAAQ,8CAA6C;AAChF,SAASC,WAAWC,UAAU,QAAQ,kBAAiB;AACvD,SAASC,QAAQ,EAAEC,QAAQ,QAAQ,qBAAoB;AACvD,SAASC,YAAY,QAAQ,eAAc;AAC3C,SAASC,cAAc,EAAEC,cAAc,QAAQ,oBAAmB;AAClE,OAAOC,QAAQ,KAAI;AAEnB,SAASC,aAAa,QAAQ,gCAA+B;AAC7D,SAASC,kBAAkB,QAAQ,0BAAyB;AAS5D,MAAMC,aAAa;IACjB;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,OAAO,MAAMC,WAAW,OAAO,EAC7BC,QAAQC,aAAa,EACrBC,8BAA8B,KAAK,EACnCC,KAAK,EACLC,YAAY,EACP;IACL,MAAMhB,UAAUC;IAChB,MAAMgB,cAAcD,cAAcE;IAClC,MAAMC,UAAU,MAAMX,cAAc;QAAEI,QAAQC;IAAc;IAC5D,MAAM,EAAEO,WAAW,EAAEC,OAAO,EAAEC,YAAY,EAAEC,MAAM,EAAE,GAAGJ,QAAQP,MAAM;IAErE,MAAMY,cAAc,CAAC,EAAEjB,GAAGkB,SAAS,CAACT,gBAAgB,CAAC,GAAG;QAAEU,gBAAgB;IAAK,GAAG,CAAC;IACnF,MAAMC,gBACJL,gBAAgBA,aAAaK,aAAa,GAAGL,aAAaK,aAAa,GAAG;IAC5E,MAAMC,aAAaX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