@payloadcms/next 3.15.2-canary.36e50dd → 3.15.2-canary.de7619e
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 +65 -5
- package/dist/exports/utilities.d.ts.map +1 -1
- package/dist/exports/utilities.js +49 -5
- package/dist/exports/utilities.js.map +1 -1
- package/dist/layouts/Root/index.d.ts.map +1 -1
- package/dist/layouts/Root/index.js +11 -2
- package/dist/layouts/Root/index.js.map +1 -1
- package/dist/layouts/Root/initJobAutoRun.d.ts +5 -0
- package/dist/layouts/Root/initJobAutoRun.d.ts.map +1 -0
- package/dist/layouts/Root/initJobAutoRun.js +23 -0
- package/dist/layouts/Root/initJobAutoRun.js.map +1 -0
- package/dist/routes/graphql/handler.d.ts.map +1 -1
- package/dist/routes/graphql/handler.js +1 -6
- package/dist/routes/graphql/handler.js.map +1 -1
- package/dist/routes/graphql/playground.d.ts +1 -1
- package/dist/routes/graphql/playground.d.ts.map +1 -1
- package/dist/routes/graphql/playground.js +1 -1
- package/dist/routes/graphql/playground.js.map +1 -1
- package/dist/routes/rest/index.d.ts +6 -26
- package/dist/routes/rest/index.d.ts.map +1 -1
- package/dist/routes/rest/index.js +25 -820
- package/dist/routes/rest/index.js.map +1 -1
- package/dist/routes/rest/og/index.d.ts +2 -8
- package/dist/routes/rest/og/index.d.ts.map +1 -1
- package/dist/routes/rest/og/index.js +3 -6
- package/dist/routes/rest/og/index.js.map +1 -1
- package/dist/utilities/getNextRequestI18n.d.ts +1 -1
- package/dist/utilities/getNextRequestI18n.d.ts.map +1 -1
- package/dist/utilities/getNextRequestI18n.js +1 -1
- package/dist/utilities/getNextRequestI18n.js.map +1 -1
- package/dist/utilities/getPayloadHMR.d.ts +8 -0
- package/dist/utilities/getPayloadHMR.d.ts.map +1 -1
- package/dist/utilities/getPayloadHMR.js +8 -0
- package/dist/utilities/getPayloadHMR.js.map +1 -1
- package/dist/utilities/getPreference.d.ts +3 -0
- package/dist/utilities/getPreference.d.ts.map +1 -0
- package/dist/utilities/getPreference.js +29 -0
- package/dist/utilities/getPreference.js.map +1 -0
- package/dist/utilities/getRequestLocale.d.ts +9 -0
- package/dist/utilities/getRequestLocale.d.ts.map +1 -0
- package/dist/utilities/getRequestLocale.js +13 -0
- package/dist/utilities/getRequestLocale.js.map +1 -0
- package/dist/utilities/initPage/index.d.ts.map +1 -1
- package/dist/utilities/initPage/index.js +7 -38
- package/dist/utilities/initPage/index.js.map +1 -1
- package/dist/utilities/initReq.d.ts.map +1 -1
- package/dist/utilities/initReq.js +1 -2
- package/dist/utilities/initReq.js.map +1 -1
- package/dist/views/List/handleServerFunction.d.ts +1 -2
- package/dist/views/List/handleServerFunction.d.ts.map +1 -1
- package/dist/views/List/handleServerFunction.js.map +1 -1
- package/dist/views/List/index.d.ts.map +1 -1
- package/dist/views/List/index.js.map +1 -1
- package/dist/views/Root/index.d.ts.map +1 -1
- package/dist/views/Root/index.js.map +1 -1
- package/package.json +8 -7
- package/dist/fetchAPI-multipart/fileFactory.d.ts +0 -16
- package/dist/fetchAPI-multipart/fileFactory.d.ts.map +0 -1
- package/dist/fetchAPI-multipart/fileFactory.js +0 -44
- package/dist/fetchAPI-multipart/fileFactory.js.map +0 -1
- package/dist/fetchAPI-multipart/handlers.d.ts +0 -14
- package/dist/fetchAPI-multipart/handlers.d.ts.map +0 -1
- package/dist/fetchAPI-multipart/handlers.js +0 -87
- package/dist/fetchAPI-multipart/handlers.js.map +0 -1
- package/dist/fetchAPI-multipart/index.d.ts +0 -32
- package/dist/fetchAPI-multipart/index.d.ts.map +0 -1
- package/dist/fetchAPI-multipart/index.js +0 -43
- package/dist/fetchAPI-multipart/index.js.map +0 -1
- package/dist/fetchAPI-multipart/isEligibleRequest.d.ts +0 -2
- package/dist/fetchAPI-multipart/isEligibleRequest.d.ts.map +0 -1
- package/dist/fetchAPI-multipart/isEligibleRequest.js +0 -18
- package/dist/fetchAPI-multipart/isEligibleRequest.js.map +0 -1
- package/dist/fetchAPI-multipart/processMultipart.d.ts +0 -9
- package/dist/fetchAPI-multipart/processMultipart.d.ts.map +0 -1
- package/dist/fetchAPI-multipart/processMultipart.js +0 -178
- package/dist/fetchAPI-multipart/processMultipart.js.map +0 -1
- package/dist/fetchAPI-multipart/processNested.d.ts +0 -2
- package/dist/fetchAPI-multipart/processNested.d.ts.map +0 -1
- package/dist/fetchAPI-multipart/processNested.js +0 -31
- package/dist/fetchAPI-multipart/processNested.js.map +0 -1
- package/dist/fetchAPI-multipart/uploadTimer.d.ts +0 -7
- package/dist/fetchAPI-multipart/uploadTimer.d.ts.map +0 -1
- package/dist/fetchAPI-multipart/uploadTimer.js +0 -20
- package/dist/fetchAPI-multipart/uploadTimer.js.map +0 -1
- package/dist/fetchAPI-multipart/utilities.d.ts +0 -65
- package/dist/fetchAPI-multipart/utilities.d.ts.map +0 -1
- package/dist/fetchAPI-multipart/utilities.js +0 -227
- package/dist/fetchAPI-multipart/utilities.js.map +0 -1
- package/dist/fetchAPI-stream-file/index.d.ts +0 -5
- package/dist/fetchAPI-stream-file/index.d.ts.map +0 -1
- package/dist/fetchAPI-stream-file/index.js +0 -27
- package/dist/fetchAPI-stream-file/index.js.map +0 -1
- package/dist/routes/rest/auth/access.d.ts +0 -3
- package/dist/routes/rest/auth/access.d.ts.map +0 -1
- package/dist/routes/rest/auth/access.js +0 -28
- package/dist/routes/rest/auth/access.js.map +0 -1
- package/dist/routes/rest/auth/forgotPassword.d.ts +0 -3
- package/dist/routes/rest/auth/forgotPassword.d.ts.map +0 -1
- package/dist/routes/rest/auth/forgotPassword.js +0 -34
- package/dist/routes/rest/auth/forgotPassword.js.map +0 -1
- package/dist/routes/rest/auth/init.d.ts +0 -3
- package/dist/routes/rest/auth/init.d.ts.map +0 -1
- package/dist/routes/rest/auth/init.js +0 -20
- package/dist/routes/rest/auth/init.js.map +0 -1
- package/dist/routes/rest/auth/login.d.ts +0 -3
- package/dist/routes/rest/auth/login.d.ts.map +0 -1
- package/dist/routes/rest/auth/login.js +0 -49
- package/dist/routes/rest/auth/login.js.map +0 -1
- package/dist/routes/rest/auth/logout.d.ts +0 -3
- package/dist/routes/rest/auth/logout.d.ts.map +0 -1
- package/dist/routes/rest/auth/logout.js +0 -40
- package/dist/routes/rest/auth/logout.js.map +0 -1
- package/dist/routes/rest/auth/me.d.ts +0 -3
- package/dist/routes/rest/auth/me.d.ts.map +0 -1
- package/dist/routes/rest/auth/me.js +0 -28
- package/dist/routes/rest/auth/me.js.map +0 -1
- package/dist/routes/rest/auth/refresh.d.ts +0 -3
- package/dist/routes/rest/auth/refresh.d.ts.map +0 -1
- package/dist/routes/rest/auth/refresh.js +0 -38
- package/dist/routes/rest/auth/refresh.js.map +0 -1
- package/dist/routes/rest/auth/registerFirstUser.d.ts +0 -3
- package/dist/routes/rest/auth/registerFirstUser.d.ts.map +0 -1
- package/dist/routes/rest/auth/registerFirstUser.js +0 -48
- package/dist/routes/rest/auth/registerFirstUser.js.map +0 -1
- package/dist/routes/rest/auth/resetPassword.d.ts +0 -3
- package/dist/routes/rest/auth/resetPassword.d.ts.map +0 -1
- package/dist/routes/rest/auth/resetPassword.js +0 -43
- package/dist/routes/rest/auth/resetPassword.js.map +0 -1
- package/dist/routes/rest/auth/unlock.d.ts +0 -3
- package/dist/routes/rest/auth/unlock.d.ts.map +0 -1
- package/dist/routes/rest/auth/unlock.js +0 -32
- package/dist/routes/rest/auth/unlock.js.map +0 -1
- package/dist/routes/rest/auth/verifyEmail.d.ts +0 -3
- package/dist/routes/rest/auth/verifyEmail.d.ts.map +0 -1
- package/dist/routes/rest/auth/verifyEmail.js +0 -27
- package/dist/routes/rest/auth/verifyEmail.js.map +0 -1
- package/dist/routes/rest/checkEndpoints.d.ts +0 -5
- package/dist/routes/rest/checkEndpoints.d.ts.map +0 -1
- package/dist/routes/rest/checkEndpoints.js +0 -14
- package/dist/routes/rest/checkEndpoints.js.map +0 -1
- package/dist/routes/rest/collections/count.d.ts +0 -3
- package/dist/routes/rest/collections/count.d.ts.map +0 -1
- package/dist/routes/rest/collections/count.js +0 -19
- package/dist/routes/rest/collections/count.js.map +0 -1
- package/dist/routes/rest/collections/create.d.ts +0 -3
- package/dist/routes/rest/collections/create.d.ts.map +0 -1
- package/dist/routes/rest/collections/create.js +0 -39
- package/dist/routes/rest/collections/create.js.map +0 -1
- package/dist/routes/rest/collections/delete.d.ts +0 -3
- package/dist/routes/rest/collections/delete.d.ts.map +0 -1
- package/dist/routes/rest/collections/delete.js +0 -57
- package/dist/routes/rest/collections/delete.js.map +0 -1
- package/dist/routes/rest/collections/deleteByID.d.ts +0 -3
- package/dist/routes/rest/collections/deleteByID.d.ts.map +0 -1
- package/dist/routes/rest/collections/deleteByID.js +0 -50
- package/dist/routes/rest/collections/deleteByID.js.map +0 -1
- package/dist/routes/rest/collections/docAccess.d.ts +0 -3
- package/dist/routes/rest/collections/docAccess.d.ts.map +0 -1
- package/dist/routes/rest/collections/docAccess.js +0 -22
- package/dist/routes/rest/collections/docAccess.js.map +0 -1
- package/dist/routes/rest/collections/duplicate.d.ts +0 -3
- package/dist/routes/rest/collections/duplicate.d.ts.map +0 -1
- package/dist/routes/rest/collections/duplicate.js +0 -47
- package/dist/routes/rest/collections/duplicate.js.map +0 -1
- package/dist/routes/rest/collections/find.d.ts +0 -3
- package/dist/routes/rest/collections/find.d.ts.map +0 -1
- package/dist/routes/rest/collections/find.js +0 -43
- package/dist/routes/rest/collections/find.js.map +0 -1
- package/dist/routes/rest/collections/findByID.d.ts +0 -3
- package/dist/routes/rest/collections/findByID.d.ts.map +0 -1
- package/dist/routes/rest/collections/findByID.js +0 -38
- package/dist/routes/rest/collections/findByID.js.map +0 -1
- package/dist/routes/rest/collections/findVersionByID.d.ts +0 -3
- package/dist/routes/rest/collections/findVersionByID.d.ts.map +0 -1
- package/dist/routes/rest/collections/findVersionByID.js +0 -36
- package/dist/routes/rest/collections/findVersionByID.js.map +0 -1
- package/dist/routes/rest/collections/findVersions.d.ts +0 -3
- package/dist/routes/rest/collections/findVersions.d.ts.map +0 -1
- package/dist/routes/rest/collections/findVersions.js +0 -39
- package/dist/routes/rest/collections/findVersions.js.map +0 -1
- package/dist/routes/rest/collections/preview.d.ts +0 -3
- package/dist/routes/rest/collections/preview.d.ts.map +0 -1
- package/dist/routes/rest/collections/preview.js +0 -49
- package/dist/routes/rest/collections/preview.js.map +0 -1
- package/dist/routes/rest/collections/restoreVersion.d.ts +0 -3
- package/dist/routes/rest/collections/restoreVersion.d.ts.map +0 -1
- package/dist/routes/rest/collections/restoreVersion.js +0 -40
- package/dist/routes/rest/collections/restoreVersion.js.map +0 -1
- package/dist/routes/rest/collections/update.d.ts +0 -3
- package/dist/routes/rest/collections/update.d.ts.map +0 -1
- package/dist/routes/rest/collections/update.js +0 -62
- package/dist/routes/rest/collections/update.js.map +0 -1
- package/dist/routes/rest/collections/updateByID.d.ts +0 -3
- package/dist/routes/rest/collections/updateByID.d.ts.map +0 -1
- package/dist/routes/rest/collections/updateByID.js +0 -55
- package/dist/routes/rest/collections/updateByID.js.map +0 -1
- package/dist/routes/rest/files/checkFileAccess.d.ts +0 -7
- package/dist/routes/rest/files/checkFileAccess.d.ts.map +0 -1
- package/dist/routes/rest/files/checkFileAccess.js +0 -57
- package/dist/routes/rest/files/checkFileAccess.js.map +0 -1
- package/dist/routes/rest/files/getFile.d.ts +0 -9
- package/dist/routes/rest/files/getFile.d.ts.map +0 -1
- package/dist/routes/rest/files/getFile.js +0 -70
- package/dist/routes/rest/files/getFile.js.map +0 -1
- package/dist/routes/rest/files/getFileTypeFallback.d.ts +0 -7
- package/dist/routes/rest/files/getFileTypeFallback.d.ts.map +0 -1
- package/dist/routes/rest/files/getFileTypeFallback.js +0 -20
- package/dist/routes/rest/files/getFileTypeFallback.js.map +0 -1
- package/dist/routes/rest/globals/docAccess.d.ts +0 -3
- package/dist/routes/rest/globals/docAccess.d.ts.map +0 -1
- package/dist/routes/rest/globals/docAccess.js +0 -20
- package/dist/routes/rest/globals/docAccess.js.map +0 -1
- package/dist/routes/rest/globals/findOne.d.ts +0 -3
- package/dist/routes/rest/globals/findOne.d.ts.map +0 -1
- package/dist/routes/rest/globals/findOne.js +0 -30
- package/dist/routes/rest/globals/findOne.js.map +0 -1
- package/dist/routes/rest/globals/findVersionByID.d.ts +0 -3
- package/dist/routes/rest/globals/findVersionByID.d.ts.map +0 -1
- package/dist/routes/rest/globals/findVersionByID.js +0 -30
- package/dist/routes/rest/globals/findVersionByID.js.map +0 -1
- package/dist/routes/rest/globals/findVersions.d.ts +0 -3
- package/dist/routes/rest/globals/findVersions.d.ts.map +0 -1
- package/dist/routes/rest/globals/findVersions.js +0 -39
- package/dist/routes/rest/globals/findVersions.js.map +0 -1
- package/dist/routes/rest/globals/preview.d.ts +0 -3
- package/dist/routes/rest/globals/preview.d.ts.map +0 -1
- package/dist/routes/rest/globals/preview.js +0 -47
- package/dist/routes/rest/globals/preview.js.map +0 -1
- package/dist/routes/rest/globals/restoreVersion.d.ts +0 -3
- package/dist/routes/rest/globals/restoreVersion.d.ts.map +0 -1
- package/dist/routes/rest/globals/restoreVersion.js +0 -34
- package/dist/routes/rest/globals/restoreVersion.js.map +0 -1
- package/dist/routes/rest/globals/update.d.ts +0 -3
- package/dist/routes/rest/globals/update.d.ts.map +0 -1
- package/dist/routes/rest/globals/update.js +0 -46
- package/dist/routes/rest/globals/update.js.map +0 -1
- package/dist/routes/rest/routeError.d.ts +0 -9
- package/dist/routes/rest/routeError.d.ts.map +0 -1
- package/dist/routes/rest/routeError.js +0 -83
- package/dist/routes/rest/routeError.js.map +0 -1
- package/dist/routes/rest/types.d.ts +0 -23
- package/dist/routes/rest/types.d.ts.map +0 -1
- package/dist/routes/rest/types.js +0 -2
- package/dist/routes/rest/types.js.map +0 -1
- package/dist/routes/rest/utilities/sanitizeCollectionID.d.ts +0 -9
- package/dist/routes/rest/utilities/sanitizeCollectionID.d.ts.map +0 -1
- package/dist/routes/rest/utilities/sanitizeCollectionID.js +0 -20
- package/dist/routes/rest/utilities/sanitizeCollectionID.js.map +0 -1
- package/dist/utilities/addDataAndFileToRequest.d.ts +0 -8
- package/dist/utilities/addDataAndFileToRequest.d.ts.map +0 -1
- package/dist/utilities/addDataAndFileToRequest.js +0 -47
- package/dist/utilities/addDataAndFileToRequest.js.map +0 -1
- package/dist/utilities/addLocalesToRequest.d.ts +0 -17
- package/dist/utilities/addLocalesToRequest.d.ts.map +0 -1
- package/dist/utilities/addLocalesToRequest.js +0 -65
- package/dist/utilities/addLocalesToRequest.js.map +0 -1
- package/dist/utilities/createPayloadRequest.d.ts +0 -11
- package/dist/utilities/createPayloadRequest.d.ts.map +0 -1
- package/dist/utilities/createPayloadRequest.js +0 -103
- package/dist/utilities/createPayloadRequest.js.map +0 -1
- package/dist/utilities/getRequestLanguage.d.ts +0 -12
- package/dist/utilities/getRequestLanguage.d.ts.map +0 -1
- package/dist/utilities/getRequestLanguage.js +0 -19
- package/dist/utilities/getRequestLanguage.js.map +0 -1
- package/dist/utilities/getRequestLocales.d.ts +0 -12
- package/dist/utilities/getRequestLocales.d.ts.map +0 -1
- package/dist/utilities/getRequestLocales.js +0 -35
- package/dist/utilities/getRequestLocales.js.map +0 -1
- package/dist/utilities/headersWithCors.d.ts +0 -8
- package/dist/utilities/headersWithCors.d.ts.map +0 -1
- package/dist/utilities/headersWithCors.js +0 -24
- package/dist/utilities/headersWithCors.js.map +0 -1
- package/dist/utilities/mergeHeaders.d.ts +0 -2
- package/dist/utilities/mergeHeaders.d.ts.map +0 -1
- package/dist/utilities/mergeHeaders.js +0 -10
- package/dist/utilities/mergeHeaders.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["DefaultListView","HydrateAuthProvider","ListQueryProvider","RenderServerComponent","renderFilters","renderTable","upsertPreferences","formatAdminURL","mergeListSearchAndWhere","notFound","isNumber","React","Fragment","renderListViewSlots","generateListMetadata","renderListView","args","clientConfig","customCellProps","disableBulkDelete","disableBulkEdit","drawerSlug","enableRowSelections","initPageResult","overrideEntityVisibility","params","query","queryFromArgs","searchParams","collectionConfig","slug","collectionSlug","locale","fullLocale","permissions","req","i18n","payload","config","queryFromReq","user","visibleEntities","collections","read","Error","preferenceKey","listPreferences","key","value","limit","Number","undefined","sort","routes","admin","adminRoute","includes","page","pagination","defaultLimit","defaultSort","where","search","baseListFilter","and","filter","Boolean","data","find","collection","depth","draft","fallbackLocale","includeLockStatus","overrideAccess","clientCollectionConfig","c","columnState","Table","columnPreferences","columns","docs","useAsTitle","renderedFilters","fields","importMap","staticDescription","description","t","sharedClientProps","hasCreatePermission","create","newDocumentURL","path","sharedServerProps","listViewSlots","clientProps","serverProps","isInDrawer","List","_jsxs","_jsx","modifySearchParams","Component","components","views","list","Fallback","listSearchableFields","ListView","RenderedList","error","message","console"],"sources":["../../../src/views/List/index.tsx"],"sourcesContent":["import type {\n ListComponentClientProps,\n ListComponentServerProps,\n ListPreferences,\n ListViewClientProps,\n} from '@payloadcms/ui'\nimport type { AdminViewProps, ListQuery, Where } from 'payload'\n\nimport { DefaultListView, HydrateAuthProvider, ListQueryProvider } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { renderFilters, renderTable, upsertPreferences } from '@payloadcms/ui/rsc'\nimport { formatAdminURL, mergeListSearchAndWhere } from '@payloadcms/ui/shared'\nimport { notFound } from 'next/navigation.js'\nimport { isNumber } from 'payload/shared'\nimport React, { Fragment } from 'react'\n\nimport { renderListViewSlots } from './renderListViewSlots.js'\n\nexport { generateListMetadata } from './meta.js'\n\ntype ListViewArgs = {\n customCellProps?: Record<string, any>\n disableBulkDelete?: boolean\n disableBulkEdit?: boolean\n enableRowSelections: boolean\n overrideEntityVisibility?: boolean\n query: ListQuery\n} & AdminViewProps\n\nexport const renderListView = async (\n args: ListViewArgs,\n): Promise<{\n List: React.ReactNode\n}> => {\n const {\n clientConfig,\n customCellProps,\n disableBulkDelete,\n disableBulkEdit,\n drawerSlug,\n enableRowSelections,\n initPageResult,\n overrideEntityVisibility,\n params,\n query: queryFromArgs,\n searchParams,\n } = args\n\n const {\n collectionConfig,\n collectionConfig: { slug: collectionSlug },\n locale: fullLocale,\n permissions,\n req,\n req: {\n i18n,\n locale,\n payload,\n payload: { config },\n query: queryFromReq,\n user,\n },\n visibleEntities,\n } = initPageResult\n\n if (!permissions?.collections?.[collectionSlug]?.read) {\n throw new Error('not-found')\n }\n\n const query = queryFromArgs || queryFromReq\n\n const preferenceKey = `${collectionSlug}-list`\n\n const listPreferences = await upsertPreferences<ListPreferences>({\n key: `${collectionSlug}-list`,\n req,\n value: { limit: isNumber(query?.limit) ? Number(query.limit) : undefined, sort: query?.sort },\n })\n\n const {\n routes: { admin: adminRoute },\n } = config\n\n if (collectionConfig) {\n if (!visibleEntities.collections.includes(collectionSlug) && !overrideEntityVisibility) {\n throw new Error('not-found')\n }\n\n const page = isNumber(query?.page) ? Number(query.page) : 0\n\n const limit = listPreferences?.limit || collectionConfig.admin.pagination.defaultLimit\n\n const sort =\n listPreferences?.sort ||\n (typeof collectionConfig.defaultSort === 'string' ? collectionConfig.defaultSort : undefined)\n\n let where = mergeListSearchAndWhere({\n collectionConfig,\n search: typeof query?.search === 'string' ? query.search : undefined,\n where: (query?.where as Where) || undefined,\n })\n\n if (typeof collectionConfig.admin?.baseListFilter === 'function') {\n const baseListFilter = await collectionConfig.admin.baseListFilter({\n limit,\n page,\n req,\n sort,\n })\n\n if (baseListFilter) {\n where = {\n and: [where, baseListFilter].filter(Boolean),\n }\n }\n }\n\n const data = await payload.find({\n collection: collectionSlug,\n depth: 0,\n draft: true,\n fallbackLocale: false,\n includeLockStatus: true,\n limit,\n locale,\n overrideAccess: false,\n page,\n req,\n sort,\n user,\n where: where || {},\n })\n\n const clientCollectionConfig = clientConfig.collections.find((c) => c.slug === collectionSlug)\n\n const { columnState, Table } = renderTable({\n clientCollectionConfig,\n collectionConfig,\n columnPreferences: listPreferences?.columns,\n customCellProps,\n docs: data.docs,\n drawerSlug,\n enableRowSelections,\n i18n: req.i18n,\n payload,\n useAsTitle: collectionConfig.admin.useAsTitle,\n })\n\n const renderedFilters = renderFilters(collectionConfig.fields, req.payload.importMap)\n\n const staticDescription =\n typeof collectionConfig.admin.description === 'function'\n ? collectionConfig.admin.description({ t: i18n.t })\n : collectionConfig.admin.description\n\n const sharedClientProps: ListComponentClientProps = {\n collectionSlug,\n hasCreatePermission: permissions?.collections?.[collectionSlug]?.create,\n newDocumentURL: formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}/create`,\n }),\n }\n\n const sharedServerProps: ListComponentServerProps = {\n collectionConfig,\n i18n,\n limit,\n locale: fullLocale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n }\n\n const listViewSlots = renderListViewSlots({\n clientProps: sharedClientProps,\n collectionConfig,\n description: staticDescription,\n payload,\n serverProps: sharedServerProps,\n })\n\n const clientProps: ListViewClientProps = {\n ...listViewSlots,\n ...sharedClientProps,\n columnState,\n disableBulkDelete,\n disableBulkEdit,\n enableRowSelections,\n listPreferences,\n renderedFilters,\n Table,\n }\n\n const isInDrawer = Boolean(drawerSlug)\n\n return {\n List: (\n <Fragment>\n <HydrateAuthProvider permissions={permissions} />\n <ListQueryProvider\n collectionSlug={collectionSlug}\n data={data}\n defaultLimit={limit}\n defaultSort={sort}\n modifySearchParams={!isInDrawer}\n preferenceKey={preferenceKey}\n >\n {RenderServerComponent({\n clientProps,\n Component: collectionConfig?.admin?.components?.views?.list?.Component,\n Fallback: DefaultListView,\n importMap: payload.importMap,\n serverProps: {\n ...sharedServerProps,\n data,\n listPreferences,\n listSearchableFields: collectionConfig.admin.listSearchableFields,\n },\n })}\n </ListQueryProvider>\n </Fragment>\n ),\n }\n }\n\n throw new Error('not-found')\n}\n\nexport const ListView: React.FC<ListViewArgs> = async (args) => {\n try {\n const { List: RenderedList } = await renderListView({ ...args, enableRowSelections: true })\n return RenderedList\n } catch (error) {\n if (error.message === 'not-found') {\n notFound()\n } else {\n console.error(error) //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B,eAAA;cACA8D,oBAAA,EAAsB/E,gBAAA,CAAiByB,KAAK,CAACsD;YAC/C;UACF;;;IAIR;EACF;EAEA,MAAM,IAAIhE,KAAA,CAAM;AAClB;AAEA,OAAO,MAAMiE,QAAA,GAAmC,MAAO7F,IAAA;EACrD,IAAI;IACF,MAAM;MAAEmF,IAAA,EAAMW;IAAY,CAAE,GAAG,MAAM/F,cAAA,CAAe;MAAE,GAAGC,IAAI;MAAEM,mBAAA,EAAqB;IAAK;IACzF,OAAOwF,YAAA;EACT,EAAE,OAAOC,KAAA,EAAO;IACd,IAAIA,KAAA,CAAMC,OAAO,KAAK,aAAa;MACjCvG,QAAA;IACF,OAAO;MACLwG,OAAA,CAAQF,KAAK,CAACA,KAAA,EAAO;MAAA;IACvB;EACF;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["DefaultListView","HydrateAuthProvider","ListQueryProvider","RenderServerComponent","renderFilters","renderTable","upsertPreferences","formatAdminURL","mergeListSearchAndWhere","notFound","isNumber","React","Fragment","renderListViewSlots","generateListMetadata","renderListView","args","clientConfig","customCellProps","disableBulkDelete","disableBulkEdit","drawerSlug","enableRowSelections","initPageResult","overrideEntityVisibility","params","query","queryFromArgs","searchParams","collectionConfig","slug","collectionSlug","locale","fullLocale","permissions","req","i18n","payload","config","queryFromReq","user","visibleEntities","collections","read","Error","preferenceKey","listPreferences","key","value","limit","Number","undefined","sort","routes","admin","adminRoute","includes","page","pagination","defaultLimit","defaultSort","where","search","baseListFilter","and","filter","Boolean","data","find","collection","depth","draft","fallbackLocale","includeLockStatus","overrideAccess","clientCollectionConfig","c","columnState","Table","columnPreferences","columns","docs","useAsTitle","renderedFilters","fields","importMap","staticDescription","description","t","sharedClientProps","hasCreatePermission","create","newDocumentURL","path","sharedServerProps","listViewSlots","clientProps","serverProps","isInDrawer","List","_jsxs","_jsx","modifySearchParams","Component","components","views","list","Fallback","listSearchableFields","ListView","RenderedList","error","message","console"],"sources":["../../../src/views/List/index.tsx"],"sourcesContent":["import type {\n ListComponentClientProps,\n ListComponentServerProps,\n ListPreferences,\n ListViewClientProps,\n} from '@payloadcms/ui'\nimport type { AdminViewProps, ListQuery, Where } from 'payload'\n\nimport { DefaultListView, HydrateAuthProvider, ListQueryProvider } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { renderFilters, renderTable, upsertPreferences } from '@payloadcms/ui/rsc'\nimport { formatAdminURL, mergeListSearchAndWhere } from '@payloadcms/ui/shared'\nimport { notFound } from 'next/navigation.js'\nimport { isNumber } from 'payload/shared'\nimport React, { Fragment } from 'react'\n\nimport { renderListViewSlots } from './renderListViewSlots.js'\n\nexport { generateListMetadata } from './meta.js'\n\ntype ListViewArgs = {\n customCellProps?: Record<string, any>\n disableBulkDelete?: boolean\n disableBulkEdit?: boolean\n enableRowSelections: boolean\n overrideEntityVisibility?: boolean\n query: ListQuery\n} & AdminViewProps\n\nexport const renderListView = async (\n args: ListViewArgs,\n): Promise<{\n List: React.ReactNode\n}> => {\n const {\n clientConfig,\n customCellProps,\n disableBulkDelete,\n disableBulkEdit,\n drawerSlug,\n enableRowSelections,\n initPageResult,\n overrideEntityVisibility,\n params,\n query: queryFromArgs,\n searchParams,\n } = args\n\n const {\n collectionConfig,\n collectionConfig: { slug: collectionSlug },\n locale: fullLocale,\n permissions,\n req,\n req: {\n i18n,\n locale,\n payload,\n payload: { config },\n query: queryFromReq,\n user,\n },\n visibleEntities,\n } = initPageResult\n\n if (!permissions?.collections?.[collectionSlug]?.read) {\n throw new Error('not-found')\n }\n\n const query = queryFromArgs || queryFromReq\n\n const preferenceKey = `${collectionSlug}-list`\n\n const listPreferences = await upsertPreferences<ListPreferences>({\n key: `${collectionSlug}-list`,\n req,\n value: {\n limit: isNumber(query?.limit) ? Number(query.limit) : undefined,\n sort: query?.sort as string,\n },\n })\n\n const {\n routes: { admin: adminRoute },\n } = config\n\n if (collectionConfig) {\n if (!visibleEntities.collections.includes(collectionSlug) && !overrideEntityVisibility) {\n throw new Error('not-found')\n }\n\n const page = isNumber(query?.page) ? Number(query.page) : 0\n\n const limit = listPreferences?.limit || collectionConfig.admin.pagination.defaultLimit\n\n const sort =\n listPreferences?.sort ||\n (typeof collectionConfig.defaultSort === 'string' ? collectionConfig.defaultSort : undefined)\n\n let where = mergeListSearchAndWhere({\n collectionConfig,\n search: typeof query?.search === 'string' ? query.search : undefined,\n where: (query?.where as Where) || undefined,\n })\n\n if (typeof collectionConfig.admin?.baseListFilter === 'function') {\n const baseListFilter = await collectionConfig.admin.baseListFilter({\n limit,\n page,\n req,\n sort,\n })\n\n if (baseListFilter) {\n where = {\n and: [where, baseListFilter].filter(Boolean),\n }\n }\n }\n\n const data = await payload.find({\n collection: collectionSlug,\n depth: 0,\n draft: true,\n fallbackLocale: false,\n includeLockStatus: true,\n limit,\n locale,\n overrideAccess: false,\n page,\n req,\n sort,\n user,\n where: where || {},\n })\n\n const clientCollectionConfig = clientConfig.collections.find((c) => c.slug === collectionSlug)\n\n const { columnState, Table } = renderTable({\n clientCollectionConfig,\n collectionConfig,\n columnPreferences: listPreferences?.columns,\n customCellProps,\n docs: data.docs,\n drawerSlug,\n enableRowSelections,\n i18n: req.i18n,\n payload,\n useAsTitle: collectionConfig.admin.useAsTitle,\n })\n\n const renderedFilters = renderFilters(collectionConfig.fields, req.payload.importMap)\n\n const staticDescription =\n typeof collectionConfig.admin.description === 'function'\n ? collectionConfig.admin.description({ t: i18n.t })\n : collectionConfig.admin.description\n\n const sharedClientProps: ListComponentClientProps = {\n collectionSlug,\n hasCreatePermission: permissions?.collections?.[collectionSlug]?.create,\n newDocumentURL: formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}/create`,\n }),\n }\n\n const sharedServerProps: ListComponentServerProps = {\n collectionConfig,\n i18n,\n limit,\n locale: fullLocale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n }\n\n const listViewSlots = renderListViewSlots({\n clientProps: sharedClientProps,\n collectionConfig,\n description: staticDescription,\n payload,\n serverProps: sharedServerProps,\n })\n\n const clientProps: ListViewClientProps = {\n ...listViewSlots,\n ...sharedClientProps,\n columnState,\n disableBulkDelete,\n disableBulkEdit,\n enableRowSelections,\n listPreferences,\n renderedFilters,\n Table,\n }\n\n const isInDrawer = Boolean(drawerSlug)\n\n return {\n List: (\n <Fragment>\n <HydrateAuthProvider permissions={permissions} />\n <ListQueryProvider\n collectionSlug={collectionSlug}\n data={data}\n defaultLimit={limit}\n defaultSort={sort}\n modifySearchParams={!isInDrawer}\n preferenceKey={preferenceKey}\n >\n {RenderServerComponent({\n clientProps,\n Component: collectionConfig?.admin?.components?.views?.list?.Component,\n Fallback: DefaultListView,\n importMap: payload.importMap,\n serverProps: {\n ...sharedServerProps,\n data,\n listPreferences,\n listSearchableFields: collectionConfig.admin.listSearchableFields,\n },\n })}\n </ListQueryProvider>\n </Fragment>\n ),\n }\n }\n\n throw new Error('not-found')\n}\n\nexport const ListView: React.FC<ListViewArgs> = async (args) => {\n try {\n const { List: RenderedList } = await renderListView({ ...args, enableRowSelections: true })\n return RenderedList\n } catch (error) {\n if (error.message === 'not-found') {\n notFound()\n } else {\n console.error(error) // eslint-disable-line no-console\n }\n }\n}\n"],"mappings":";AAQA,SAASA,eAAe,EAAEC,mBAAmB,EAAEC,iBAAiB,QAAQ;AACxE,SAASC,qBAAqB,QAAQ;AACtC,SAASC,aAAa,EAAEC,WAAW,EAAEC,iBAAiB,QAAQ;AAC9D,SAASC,cAAc,EAAEC,uBAAuB,QAAQ;AACxD,SAASC,QAAQ,QAAQ;AACzB,SAASC,QAAQ,QAAQ;AACzB,OAAOC,KAAA,IAASC,QAAQ,QAAQ;AAEhC,SAASC,mBAAmB,QAAQ;AAEpC,SAASC,oBAAoB,QAAQ;AAWrC,OAAO,MAAMC,cAAA,GAAiB,MAC5BC,IAAA;EAIA,MAAM;IACJC,YAAY;IACZC,eAAe;IACfC,iBAAiB;IACjBC,eAAe;IACfC,UAAU;IACVC,mBAAmB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-1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Root/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;AACpC,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAMzD,OAAO,KAAmB,MAAM,OAAO,CAAA;AAOvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAEhD,MAAM,MAAM,oBAAoB,GAAG,CAAC,IAAI,EAAE;IACxC,MAAM,EAAE,eAAe,CAAA;IACvB,IAAI,EAAE,UAAU,CAAA;IAChB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,MAAM,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;KAAE,CAAA;CAC9C,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEvB,eAAO,MAAM,QAAQ,oGAKlB;IACD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,CAAA;IACzC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;IAC7B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;QACvB,QAAQ,EAAE,MAAM,EAAE,CAAA;KACnB,CAAC,CAAA;IACF,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;QAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;KACjC,CAAC,CAAA;CACH,+
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Root/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;AACpC,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAMzD,OAAO,KAAmB,MAAM,OAAO,CAAA;AAOvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAEhD,MAAM,MAAM,oBAAoB,GAAG,CAAC,IAAI,EAAE;IACxC,MAAM,EAAE,eAAe,CAAA;IACvB,IAAI,EAAE,UAAU,CAAA;IAChB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,MAAM,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;KAAE,CAAA;CAC9C,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEvB,eAAO,MAAM,QAAQ,oGAKlB;IACD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,CAAA;IACzC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;IAC7B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;QACvB,QAAQ,EAAE,MAAM,EAAE,CAAA;KACnB,CAAC,CAAA;IACF,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;QAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;KACjC,CAAC,CAAA;CACH,+BAmIA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["RenderServerComponent","formatAdminURL","getClientConfig","notFound","redirect","React","Fragment","DefaultTemplate","MinimalTemplate","initPage","getViewFromConfig","generatePageMetadata","RootPage","config","configPromise","importMap","params","paramsPromise","searchParams","searchParamsPromise","admin","routes","createFirstUser","_createFirstUserRoute","user","userSlug","adminRoute","currentRoute","path","Array","isArray","segments","join","DefaultView","initPageOptions","serverProps","templateClassName","templateType","initPageResult","dbHasUser","req","payload","db","findOne","collection","then","doc","Component","payloadComponent","redirectTo","createFirstUserRoute","collectionConfig","collections","find","slug","disableLocalStrategy","auth","clientConfig","i18n","RenderedView","clientProps","Fallback","_jsxs","_jsx","className","locale","permissions","viewActions","visibleEntities","globals"],"sources":["../../../src/views/Root/index.tsx"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type { Metadata } from 'next'\nimport type { ImportMap, SanitizedConfig } from 'payload'\n\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { formatAdminURL } from '@payloadcms/ui/shared'\nimport { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig'\nimport { notFound, redirect } from 'next/navigation.js'\nimport React, { Fragment } from 'react'\n\nimport { DefaultTemplate } from '../../templates/Default/index.js'\nimport { MinimalTemplate } from '../../templates/Minimal/index.js'\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: I18nClient\n isEditing?: boolean\n params?: { [key: string]: string | string[] }\n}) => Promise<Metadata>\n\nexport const RootPage = async ({\n config: configPromise,\n importMap,\n params: paramsPromise,\n searchParams: searchParamsPromise,\n}: {\n readonly config: Promise<SanitizedConfig>\n readonly importMap: ImportMap\n readonly params: Promise<{\n segments: string[]\n }>\n readonly searchParams: Promise<{\n [key: string]: string | string[]\n }>\n}) => {\n const config = await configPromise\n\n const {\n admin: {\n routes: { createFirstUser: _createFirstUserRoute },\n user: userSlug,\n },\n routes: { admin: adminRoute },\n } = config\n\n const params = await paramsPromise\n const currentRoute = formatAdminURL({\n adminRoute,\n path: `${Array.isArray(params.segments) ? `/${params.segments.join('/')}` : ''}`,\n })\n\n const segments = Array.isArray(params.segments) ? params.segments : []\n\n const searchParams = await searchParamsPromise\n\n const { DefaultView, initPageOptions, serverProps, templateClassName, templateType } =\n getViewFromConfig({\n adminRoute,\n config,\n currentRoute,\n importMap,\n searchParams,\n segments,\n })\n\n const initPageResult = await initPage(initPageOptions)\n\n const dbHasUser =\n initPageResult.req.user ||\n (await initPageResult?.req.payload.db\n .findOne({\n collection: userSlug,\n req: initPageResult?.req,\n })\n ?.then((doc) => !!doc))\n\n if (!DefaultView?.Component && !DefaultView?.payloadComponent) {\n if (initPageResult?.req?.user) {\n notFound()\n }\n\n if (dbHasUser) {\n redirect(adminRoute)\n }\n }\n\n if (typeof initPageResult?.redirectTo === 'string') {\n redirect(initPageResult.redirectTo)\n }\n\n if (initPageResult) {\n const createFirstUserRoute = formatAdminURL({ adminRoute, path: _createFirstUserRoute })\n\n const collectionConfig = config.collections.find(({ slug }) => slug === userSlug)\n const disableLocalStrategy = collectionConfig?.auth?.disableLocalStrategy\n\n if (disableLocalStrategy && currentRoute === createFirstUserRoute) {\n redirect(adminRoute)\n }\n\n if (!dbHasUser && currentRoute !== createFirstUserRoute && !disableLocalStrategy) {\n redirect(createFirstUserRoute)\n }\n\n if (dbHasUser && currentRoute === createFirstUserRoute) {\n redirect(adminRoute)\n }\n }\n\n if (!DefaultView?.Component && !DefaultView?.payloadComponent && !dbHasUser) {\n redirect(adminRoute)\n }\n\n const clientConfig = getClientConfig({\n config,\n i18n: initPageResult?.req.i18n,\n importMap,\n })\n\n const RenderedView = RenderServerComponent({\n clientProps: { clientConfig },\n Component: DefaultView.payloadComponent,\n Fallback: DefaultView.Component,\n importMap,\n serverProps: {\n ...serverProps,\n clientConfig,\n i18n: initPageResult?.req.i18n,\n importMap,\n initPageResult,\n params,\n payload: initPageResult?.req.payload,\n searchParams,\n },\n })\n\n return (\n <Fragment>\n {!templateType && <Fragment>{RenderedView}</Fragment>}\n {templateType === 'minimal' && (\n <MinimalTemplate className={templateClassName}>{RenderedView}</MinimalTemplate>\n )}\n {templateType === 'default' && (\n <DefaultTemplate\n i18n={initPageResult?.req.i18n}\n locale={initPageResult?.locale}\n params={params}\n payload={initPageResult?.req.payload}\n permissions={initPageResult?.permissions}\n searchParams={searchParams}\n user={initPageResult?.req.user}\n viewActions={serverProps.viewActions}\n visibleEntities={{\n // The reason we are not passing in initPageResult.visibleEntities directly is due to a \"Cannot assign to read only property of object '#<Object>\" error introduced in React 19\n // which this caused as soon as initPageResult.visibleEntities is passed in\n collections: initPageResult?.visibleEntities?.collections,\n globals: initPageResult?.visibleEntities?.globals,\n }}\n >\n {RenderedView}\n </DefaultTemplate>\n )}\n </Fragment>\n )\n}\n"],"mappings":";AAIA,SAASA,qBAAqB,QAAQ;AACtC,SAASC,cAAc,QAAQ;AAC/B,SAASC,eAAe,QAAQ;AAChC,SAASC,QAAQ,EAAEC,QAAQ,QAAQ;AACnC,OAAOC,KAAA,IAASC,QAAQ,QAAQ;AAEhC,SAASC,eAAe,QAAQ;AAChC,SAASC,eAAe,QAAQ;AAChC,SAASC,QAAQ,QAAQ;AACzB,SAASC,iBAAiB,QAAQ;AAElC,SAASC,oBAAoB,QAAQ;AASrC,OAAO,MAAMC,QAAA,GAAW,MAAAA,CAAO;EAC7BC,MAAA,EAAQC,aAAa;EACrBC,SAAS;EACTC,MAAA,EAAQC,aAAa;EACrBC,YAAA,EAAcC;AAAmB,CAUlC;EACC,MAAMN,MAAA,GAAS,MAAMC,aAAA;EAErB,MAAM;IACJM,KAAA,EAAO;MACLC,MAAA,EAAQ;QAAEC,eAAA,EAAiBC;MAAqB,CAAE;MAClDC,IAAA,EAAMC;IAAQ,CACf;IACDJ,MAAA,EAAQ;MAAED,KAAA,EAAOM;IAAU;EAAE,CAC9B,GAAGb,MAAA;EAEJ,MAAMG,MAAA,GAAS,MAAMC,aAAA;
|
|
1
|
+
{"version":3,"file":"index.js","names":["RenderServerComponent","formatAdminURL","getClientConfig","notFound","redirect","React","Fragment","DefaultTemplate","MinimalTemplate","initPage","getViewFromConfig","generatePageMetadata","RootPage","config","configPromise","importMap","params","paramsPromise","searchParams","searchParamsPromise","admin","routes","createFirstUser","_createFirstUserRoute","user","userSlug","adminRoute","currentRoute","path","Array","isArray","segments","join","DefaultView","initPageOptions","serverProps","templateClassName","templateType","initPageResult","dbHasUser","req","payload","db","findOne","collection","then","doc","Component","payloadComponent","redirectTo","createFirstUserRoute","collectionConfig","collections","find","slug","disableLocalStrategy","auth","clientConfig","i18n","RenderedView","clientProps","Fallback","_jsxs","_jsx","className","locale","permissions","viewActions","visibleEntities","globals"],"sources":["../../../src/views/Root/index.tsx"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type { Metadata } from 'next'\nimport type { ImportMap, SanitizedConfig } from 'payload'\n\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { formatAdminURL } from '@payloadcms/ui/shared'\nimport { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig'\nimport { notFound, redirect } from 'next/navigation.js'\nimport React, { Fragment } from 'react'\n\nimport { DefaultTemplate } from '../../templates/Default/index.js'\nimport { MinimalTemplate } from '../../templates/Minimal/index.js'\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: I18nClient\n isEditing?: boolean\n params?: { [key: string]: string | string[] }\n}) => Promise<Metadata>\n\nexport const RootPage = async ({\n config: configPromise,\n importMap,\n params: paramsPromise,\n searchParams: searchParamsPromise,\n}: {\n readonly config: Promise<SanitizedConfig>\n readonly importMap: ImportMap\n readonly params: Promise<{\n segments: string[]\n }>\n readonly searchParams: Promise<{\n [key: string]: string | string[]\n }>\n}) => {\n const config = await configPromise\n\n const {\n admin: {\n routes: { createFirstUser: _createFirstUserRoute },\n user: userSlug,\n },\n routes: { admin: adminRoute },\n } = config\n\n const params = await paramsPromise\n\n const currentRoute = formatAdminURL({\n adminRoute,\n path: `${Array.isArray(params.segments) ? `/${params.segments.join('/')}` : ''}`,\n })\n\n const segments = Array.isArray(params.segments) ? params.segments : []\n\n const searchParams = await searchParamsPromise\n\n const { DefaultView, initPageOptions, serverProps, templateClassName, templateType } =\n getViewFromConfig({\n adminRoute,\n config,\n currentRoute,\n importMap,\n searchParams,\n segments,\n })\n\n const initPageResult = await initPage(initPageOptions)\n\n const dbHasUser =\n initPageResult.req.user ||\n (await initPageResult?.req.payload.db\n .findOne({\n collection: userSlug,\n req: initPageResult?.req,\n })\n ?.then((doc) => !!doc))\n\n if (!DefaultView?.Component && !DefaultView?.payloadComponent) {\n if (initPageResult?.req?.user) {\n notFound()\n }\n\n if (dbHasUser) {\n redirect(adminRoute)\n }\n }\n\n if (typeof initPageResult?.redirectTo === 'string') {\n redirect(initPageResult.redirectTo)\n }\n\n if (initPageResult) {\n const createFirstUserRoute = formatAdminURL({ adminRoute, path: _createFirstUserRoute })\n\n const collectionConfig = config.collections.find(({ slug }) => slug === userSlug)\n const disableLocalStrategy = collectionConfig?.auth?.disableLocalStrategy\n\n if (disableLocalStrategy && currentRoute === createFirstUserRoute) {\n redirect(adminRoute)\n }\n\n if (!dbHasUser && currentRoute !== createFirstUserRoute && !disableLocalStrategy) {\n redirect(createFirstUserRoute)\n }\n\n if (dbHasUser && currentRoute === createFirstUserRoute) {\n redirect(adminRoute)\n }\n }\n\n if (!DefaultView?.Component && !DefaultView?.payloadComponent && !dbHasUser) {\n redirect(adminRoute)\n }\n\n const clientConfig = getClientConfig({\n config,\n i18n: initPageResult?.req.i18n,\n importMap,\n })\n\n const RenderedView = RenderServerComponent({\n clientProps: { clientConfig },\n Component: DefaultView.payloadComponent,\n Fallback: DefaultView.Component,\n importMap,\n serverProps: {\n ...serverProps,\n clientConfig,\n i18n: initPageResult?.req.i18n,\n importMap,\n initPageResult,\n params,\n payload: initPageResult?.req.payload,\n searchParams,\n },\n })\n\n return (\n <Fragment>\n {!templateType && <Fragment>{RenderedView}</Fragment>}\n {templateType === 'minimal' && (\n <MinimalTemplate className={templateClassName}>{RenderedView}</MinimalTemplate>\n )}\n {templateType === 'default' && (\n <DefaultTemplate\n i18n={initPageResult?.req.i18n}\n locale={initPageResult?.locale}\n params={params}\n payload={initPageResult?.req.payload}\n permissions={initPageResult?.permissions}\n searchParams={searchParams}\n user={initPageResult?.req.user}\n viewActions={serverProps.viewActions}\n visibleEntities={{\n // The reason we are not passing in initPageResult.visibleEntities directly is due to a \"Cannot assign to read only property of object '#<Object>\" error introduced in React 19\n // which this caused as soon as initPageResult.visibleEntities is passed in\n collections: initPageResult?.visibleEntities?.collections,\n globals: initPageResult?.visibleEntities?.globals,\n }}\n >\n {RenderedView}\n </DefaultTemplate>\n )}\n </Fragment>\n )\n}\n"],"mappings":";AAIA,SAASA,qBAAqB,QAAQ;AACtC,SAASC,cAAc,QAAQ;AAC/B,SAASC,eAAe,QAAQ;AAChC,SAASC,QAAQ,EAAEC,QAAQ,QAAQ;AACnC,OAAOC,KAAA,IAASC,QAAQ,QAAQ;AAEhC,SAASC,eAAe,QAAQ;AAChC,SAASC,eAAe,QAAQ;AAChC,SAASC,QAAQ,QAAQ;AACzB,SAASC,iBAAiB,QAAQ;AAElC,SAASC,oBAAoB,QAAQ;AASrC,OAAO,MAAMC,QAAA,GAAW,MAAAA,CAAO;EAC7BC,MAAA,EAAQC,aAAa;EACrBC,SAAS;EACTC,MAAA,EAAQC,aAAa;EACrBC,YAAA,EAAcC;AAAmB,CAUlC;EACC,MAAMN,MAAA,GAAS,MAAMC,aAAA;EAErB,MAAM;IACJM,KAAA,EAAO;MACLC,MAAA,EAAQ;QAAEC,eAAA,EAAiBC;MAAqB,CAAE;MAClDC,IAAA,EAAMC;IAAQ,CACf;IACDJ,MAAA,EAAQ;MAAED,KAAA,EAAOM;IAAU;EAAE,CAC9B,GAAGb,MAAA;EAEJ,MAAMG,MAAA,GAAS,MAAMC,aAAA;EAErB,MAAMU,YAAA,GAAe1B,cAAA,CAAe;IAClCyB,UAAA;IACAE,IAAA,EAAM,GAAGC,KAAA,CAAMC,OAAO,CAACd,MAAA,CAAOe,QAAQ,IAAI,IAAIf,MAAA,CAAOe,QAAQ,CAACC,IAAI,CAAC,MAAM,GAAG;EAC9E;EAEA,MAAMD,QAAA,GAAWF,KAAA,CAAMC,OAAO,CAACd,MAAA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AAA,EAAQ3B,cAAA,EAAgB2B,MAAA;MACxBjD,MAAA,EAAQA,MAAA;MACRyB,OAAA,EAASH,cAAA,EAAgBE,GAAA,CAAIC,OAAA;MAC7ByB,WAAA,EAAa5B,cAAA,EAAgB4B,WAAA;MAC7BhD,YAAA,EAAcA,YAAA;MACdM,IAAA,EAAMc,cAAA,EAAgBE,GAAA,CAAIhB,IAAA;MAC1B2C,WAAA,EAAahC,WAAA,CAAYgC,WAAW;MACpCC,eAAA,EAAiB;QACf;QACA;QACAhB,WAAA,EAAad,cAAA,EAAgB8B,eAAA,EAAiBhB,WAAA;QAC9CiB,OAAA,EAAS/B,cAAA,EAAgB8B,eAAA,EAAiBC;MAC5C;gBAECV;;;AAKX","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/next",
|
|
3
|
-
"version": "3.15.2-canary.
|
|
3
|
+
"version": "3.15.2-canary.de7619e",
|
|
4
4
|
"homepage": "https://payloadcms.com",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -69,6 +69,7 @@
|
|
|
69
69
|
"dependencies": {
|
|
70
70
|
"@dnd-kit/core": "6.0.8",
|
|
71
71
|
"busboy": "^1.6.0",
|
|
72
|
+
"croner": "9.0.0",
|
|
72
73
|
"file-type": "19.3.0",
|
|
73
74
|
"graphql-http": "^1.22.0",
|
|
74
75
|
"graphql-playground-html": "1.6.30",
|
|
@@ -79,9 +80,9 @@
|
|
|
79
80
|
"sass": "1.77.4",
|
|
80
81
|
"sonner": "^1.7.0",
|
|
81
82
|
"uuid": "10.0.0",
|
|
82
|
-
"@payloadcms/
|
|
83
|
-
"@payloadcms/
|
|
84
|
-
"@payloadcms/
|
|
83
|
+
"@payloadcms/graphql": "3.15.2-canary.de7619e",
|
|
84
|
+
"@payloadcms/ui": "3.15.2-canary.de7619e",
|
|
85
|
+
"@payloadcms/translations": "3.15.2-canary.de7619e"
|
|
85
86
|
},
|
|
86
87
|
"devDependencies": {
|
|
87
88
|
"@babel/cli": "7.25.9",
|
|
@@ -99,13 +100,13 @@
|
|
|
99
100
|
"esbuild-sass-plugin": "3.3.1",
|
|
100
101
|
"eslint-plugin-react-compiler": "19.0.0-beta-df7b47d-20241124",
|
|
101
102
|
"swc-plugin-transform-remove-imports": "2.0.0",
|
|
102
|
-
"
|
|
103
|
-
"
|
|
103
|
+
"payload": "3.15.2-canary.de7619e",
|
|
104
|
+
"@payloadcms/eslint-config": "3.9.0"
|
|
104
105
|
},
|
|
105
106
|
"peerDependencies": {
|
|
106
107
|
"graphql": "^16.8.1",
|
|
107
108
|
"next": "^15.0.0",
|
|
108
|
-
"payload": "3.15.2-canary.
|
|
109
|
+
"payload": "3.15.2-canary.de7619e"
|
|
109
110
|
},
|
|
110
111
|
"engines": {
|
|
111
112
|
"node": "^18.20.2 || >=20.9.0"
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { FetchAPIFileUploadOptions } from 'payload';
|
|
2
|
-
import type { FileShape } from './index.js';
|
|
3
|
-
type FileFactoryOptions = {
|
|
4
|
-
buffer: Buffer;
|
|
5
|
-
encoding: string;
|
|
6
|
-
hash: Buffer | string;
|
|
7
|
-
mimetype: string;
|
|
8
|
-
name: string;
|
|
9
|
-
size: number;
|
|
10
|
-
tempFilePath: string;
|
|
11
|
-
truncated: boolean;
|
|
12
|
-
};
|
|
13
|
-
type FileFactory = (options: FileFactoryOptions, fileUploadOptions: FetchAPIFileUploadOptions) => FileShape;
|
|
14
|
-
export declare const fileFactory: FileFactory;
|
|
15
|
-
export {};
|
|
16
|
-
//# sourceMappingURL=fileFactory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fileFactory.d.ts","sourceRoot":"","sources":["../../src/fetchAPI-multipart/fileFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAExD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAmC3C,KAAK,kBAAkB,GAAG;IACxB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;IACrB,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE,OAAO,CAAA;CACnB,CAAA;AACD,KAAK,WAAW,GAAG,CACjB,OAAO,EAAE,kBAAkB,EAC3B,iBAAiB,EAAE,yBAAyB,KACzC,SAAS,CAAA;AACd,eAAO,MAAM,WAAW,EAAE,WA4BzB,CAAA"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { checkAndMakeDir, debugLog, isFunc, moveFile, promiseCallback, saveBufferToFile } from './utilities.js';
|
|
2
|
-
/**
|
|
3
|
-
* Returns Local function that moves the file to a different location on the filesystem
|
|
4
|
-
* which takes two function arguments to make it compatible w/ Promise or Callback APIs
|
|
5
|
-
*/
|
|
6
|
-
const moveFromTemp = (filePath, options, fileUploadOptions) => (resolve, reject) => {
|
|
7
|
-
debugLog(fileUploadOptions, `Moving temporary file ${options.tempFilePath} to ${filePath}`);
|
|
8
|
-
moveFile(options.tempFilePath, filePath, promiseCallback(resolve, reject));
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Returns Local function that moves the file from buffer to a different location on the filesystem
|
|
12
|
-
* which takes two function arguments to make it compatible w/ Promise or Callback APIs
|
|
13
|
-
*/
|
|
14
|
-
const moveFromBuffer = (filePath, options, fileUploadOptions) => (resolve, reject) => {
|
|
15
|
-
debugLog(fileUploadOptions, `Moving uploaded buffer to ${filePath}`);
|
|
16
|
-
saveBufferToFile(options.buffer, filePath, promiseCallback(resolve, reject));
|
|
17
|
-
};
|
|
18
|
-
export const fileFactory = (options, fileUploadOptions) => {
|
|
19
|
-
// see: https://github.com/richardgirges/express-fileupload/issues/14
|
|
20
|
-
// firefox uploads empty file in case of cache miss when f5ing page.
|
|
21
|
-
// resulting in unexpected behavior. if there is no file data, the file is invalid.
|
|
22
|
-
// if (!fileUploadOptions.useTempFiles && !options.buffer.length) return;
|
|
23
|
-
// Create and return file object.
|
|
24
|
-
return {
|
|
25
|
-
name: options.name,
|
|
26
|
-
data: options.buffer,
|
|
27
|
-
encoding: options.encoding,
|
|
28
|
-
md5: options.hash,
|
|
29
|
-
mimetype: options.mimetype,
|
|
30
|
-
mv: (filePath, callback) => {
|
|
31
|
-
// Define a proper move function.
|
|
32
|
-
const moveFunc = fileUploadOptions.useTempFiles ? moveFromTemp(filePath, options, fileUploadOptions) : moveFromBuffer(filePath, options, fileUploadOptions);
|
|
33
|
-
// Create a folder for a file.
|
|
34
|
-
checkAndMakeDir(fileUploadOptions, filePath);
|
|
35
|
-
// If callback is passed in, use the callback API, otherwise return a promise.
|
|
36
|
-
const defaultReject = () => undefined;
|
|
37
|
-
return isFunc(callback) ? moveFunc(callback, defaultReject) : new Promise(moveFunc);
|
|
38
|
-
},
|
|
39
|
-
size: options.size,
|
|
40
|
-
tempFilePath: options.tempFilePath,
|
|
41
|
-
truncated: options.truncated
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
//# sourceMappingURL=fileFactory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fileFactory.js","names":["checkAndMakeDir","debugLog","isFunc","moveFile","promiseCallback","saveBufferToFile","moveFromTemp","filePath","options","fileUploadOptions","resolve","reject","tempFilePath","moveFromBuffer","buffer","fileFactory","name","data","encoding","md5","hash","mimetype","mv","callback","moveFunc","useTempFiles","defaultReject","undefined","Promise","size","truncated"],"sources":["../../src/fetchAPI-multipart/fileFactory.ts"],"sourcesContent":["import type { FetchAPIFileUploadOptions } from 'payload'\n\nimport type { FileShape } from './index.js'\n\nimport {\n checkAndMakeDir,\n debugLog,\n isFunc,\n moveFile,\n promiseCallback,\n saveBufferToFile,\n} from './utilities.js'\n\ntype MoveFile = (\n filePath: string,\n options: FileFactoryOptions,\n fileUploadOptions: FetchAPIFileUploadOptions,\n) => (resolve: () => void, reject: () => void) => void\n\n/**\n * Returns Local function that moves the file to a different location on the filesystem\n * which takes two function arguments to make it compatible w/ Promise or Callback APIs\n */\nconst moveFromTemp: MoveFile = (filePath, options, fileUploadOptions) => (resolve, reject) => {\n debugLog(fileUploadOptions, `Moving temporary file ${options.tempFilePath} to ${filePath}`)\n moveFile(options.tempFilePath, filePath, promiseCallback(resolve, reject))\n}\n\n/**\n * Returns Local function that moves the file from buffer to a different location on the filesystem\n * which takes two function arguments to make it compatible w/ Promise or Callback APIs\n */\nconst moveFromBuffer: MoveFile = (filePath, options, fileUploadOptions) => (resolve, reject) => {\n debugLog(fileUploadOptions, `Moving uploaded buffer to ${filePath}`)\n saveBufferToFile(options.buffer, filePath, promiseCallback(resolve, reject))\n}\n\ntype FileFactoryOptions = {\n buffer: Buffer\n encoding: string\n hash: Buffer | string\n mimetype: string\n name: string\n size: number\n tempFilePath: string\n truncated: boolean\n}\ntype FileFactory = (\n options: FileFactoryOptions,\n fileUploadOptions: FetchAPIFileUploadOptions,\n) => FileShape\nexport const fileFactory: FileFactory = (options, fileUploadOptions) => {\n // see: https://github.com/richardgirges/express-fileupload/issues/14\n // firefox uploads empty file in case of cache miss when f5ing page.\n // resulting in unexpected behavior. if there is no file data, the file is invalid.\n // if (!fileUploadOptions.useTempFiles && !options.buffer.length) return;\n\n // Create and return file object.\n return {\n name: options.name,\n data: options.buffer,\n encoding: options.encoding,\n md5: options.hash,\n mimetype: options.mimetype,\n mv: (filePath: string, callback) => {\n // Define a proper move function.\n const moveFunc = fileUploadOptions.useTempFiles\n ? moveFromTemp(filePath, options, fileUploadOptions)\n : moveFromBuffer(filePath, options, fileUploadOptions)\n // Create a folder for a file.\n checkAndMakeDir(fileUploadOptions, filePath)\n // If callback is passed in, use the callback API, otherwise return a promise.\n const defaultReject = () => undefined\n return isFunc(callback) ? moveFunc(callback, defaultReject) : new Promise(moveFunc)\n },\n size: options.size,\n tempFilePath: options.tempFilePath,\n truncated: options.truncated,\n }\n}\n"],"mappings":"AAIA,SACEA,eAAe,EACfC,QAAQ,EACRC,MAAM,EACNC,QAAQ,EACRC,eAAe,EACfC,gBAAgB,QACX;AAQP;;;;AAIA,MAAMC,YAAA,GAAyBA,CAACC,QAAA,EAAUC,OAAA,EAASC,iBAAA,KAAsB,CAACC,OAAA,EAASC,MAAA;EACjFV,QAAA,CAASQ,iBAAA,EAAmB,yBAAyBD,OAAA,CAAQI,YAAY,OAAOL,QAAA,EAAU;EAC1FJ,QAAA,CAASK,OAAA,CAAQI,YAAY,EAAEL,QAAA,EAAUH,eAAA,CAAgBM,OAAA,EAASC,MAAA;AACpE;AAEA;;;;AAIA,MAAME,cAAA,GAA2BA,CAACN,QAAA,EAAUC,OAAA,EAASC,iBAAA,KAAsB,CAACC,OAAA,EAASC,MAAA;EACnFV,QAAA,CAASQ,iBAAA,EAAmB,6BAA6BF,QAAA,EAAU;EACnEF,gBAAA,CAAiBG,OAAA,CAAQM,MAAM,EAAEP,QAAA,EAAUH,eAAA,CAAgBM,OAAA,EAASC,MAAA;AACtE;AAgBA,OAAO,MAAMI,WAAA,GAA2BA,CAACP,OAAA,EAASC,iBAAA;EAChD;EACA;EACA;EACA;EAEA;EACA,OAAO;IACLO,IAAA,EAAMR,OAAA,CAAQQ,IAAI;IAClBC,IAAA,EAAMT,OAAA,CAAQM,MAAM;IACpBI,QAAA,EAAUV,OAAA,CAAQU,QAAQ;IAC1BC,GAAA,EAAKX,OAAA,CAAQY,IAAI;IACjBC,QAAA,EAAUb,OAAA,CAAQa,QAAQ;IAC1BC,EAAA,EAAIA,CAACf,QAAA,EAAkBgB,QAAA;MACrB;MACA,MAAMC,QAAA,GAAWf,iBAAA,CAAkBgB,YAAY,GAC3CnB,YAAA,CAAaC,QAAA,EAAUC,OAAA,EAASC,iBAAA,IAChCI,cAAA,CAAeN,QAAA,EAAUC,OAAA,EAASC,iBAAA;MACtC;MACAT,eAAA,CAAgBS,iBAAA,EAAmBF,QAAA;MACnC;MACA,MAAMmB,aAAA,GAAgBA,CAAA,KAAMC,SAAA;MAC5B,OAAOzB,MAAA,CAAOqB,QAAA,IAAYC,QAAA,CAASD,QAAA,EAAUG,aAAA,IAAiB,IAAIE,OAAA,CAAQJ,QAAA;IAC5E;IACAK,IAAA,EAAMrB,OAAA,CAAQqB,IAAI;IAClBjB,YAAA,EAAcJ,OAAA,CAAQI,YAAY;IAClCkB,SAAA,EAAWtB,OAAA,CAAQsB;EACrB;AACF","ignoreList":[]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { FetchAPIFileUploadOptions } from 'payload';
|
|
2
|
-
type Handler = (options: FetchAPIFileUploadOptions, fieldname: string, filename: string) => {
|
|
3
|
-
cleanup: () => void;
|
|
4
|
-
complete: () => Buffer;
|
|
5
|
-
dataHandler: (data: Buffer) => void;
|
|
6
|
-
getFilePath: () => string;
|
|
7
|
-
getFileSize: () => number;
|
|
8
|
-
getHash: () => string;
|
|
9
|
-
getWritePromise: () => Promise<boolean>;
|
|
10
|
-
};
|
|
11
|
-
export declare const tempFileHandler: Handler;
|
|
12
|
-
export declare const memHandler: Handler;
|
|
13
|
-
export {};
|
|
14
|
-
//# sourceMappingURL=handlers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../src/fetchAPI-multipart/handlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAQxD,KAAK,OAAO,GAAG,CACb,OAAO,EAAE,yBAAyB,EAClC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,KACb;IACH,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,QAAQ,EAAE,MAAM,MAAM,CAAA;IACtB,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACnC,WAAW,EAAE,MAAM,MAAM,CAAA;IACzB,WAAW,EAAE,MAAM,MAAM,CAAA;IACzB,OAAO,EAAE,MAAM,MAAM,CAAA;IACrB,eAAe,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;CACxC,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,OAwD7B,CAAA;AAED,eAAO,MAAM,UAAU,EAAE,OAgCxB,CAAA"}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import crypto from 'crypto';
|
|
2
|
-
import fs, { WriteStream } from 'fs';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import { checkAndMakeDir, debugLog, deleteFile, getTempFilename } from './utilities.js';
|
|
5
|
-
export const tempFileHandler = (options, fieldname, filename) => {
|
|
6
|
-
const dir = path.normalize(options.tempFileDir);
|
|
7
|
-
const tempFilePath = path.join(process.cwd(), dir, getTempFilename());
|
|
8
|
-
checkAndMakeDir({
|
|
9
|
-
createParentPath: true
|
|
10
|
-
}, tempFilePath);
|
|
11
|
-
debugLog(options, `Temporary file path is ${tempFilePath}`);
|
|
12
|
-
const hash = crypto.createHash('md5');
|
|
13
|
-
let fileSize = 0;
|
|
14
|
-
let completed = false;
|
|
15
|
-
debugLog(options, `Opening write stream for ${fieldname}->${filename}...`);
|
|
16
|
-
const writeStream = fs.createWriteStream(tempFilePath);
|
|
17
|
-
const writePromise = new Promise((resolve, reject) => {
|
|
18
|
-
writeStream.on('finish', () => resolve(true));
|
|
19
|
-
writeStream.on('error', err => {
|
|
20
|
-
debugLog(options, `Error write temp file: ${err}`);
|
|
21
|
-
reject(err);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
return {
|
|
25
|
-
cleanup: () => {
|
|
26
|
-
completed = true;
|
|
27
|
-
debugLog(options, `Cleaning up temporary file ${tempFilePath}...`);
|
|
28
|
-
writeStream.end();
|
|
29
|
-
deleteFile(tempFilePath, err => err ? debugLog(options, `Cleaning up temporary file ${tempFilePath} failed: ${err}`) : debugLog(options, `Cleaning up temporary file ${tempFilePath} done.`));
|
|
30
|
-
},
|
|
31
|
-
complete: () => {
|
|
32
|
-
completed = true;
|
|
33
|
-
debugLog(options, `Upload ${fieldname}->${filename} completed, bytes:${fileSize}.`);
|
|
34
|
-
if (writeStream instanceof WriteStream) {
|
|
35
|
-
writeStream.end();
|
|
36
|
-
}
|
|
37
|
-
// Return empty buff since data was uploaded into a temp file.
|
|
38
|
-
return Buffer.concat([]);
|
|
39
|
-
},
|
|
40
|
-
dataHandler: data => {
|
|
41
|
-
if (completed === true) {
|
|
42
|
-
debugLog(options, `Error: got ${fieldname}->${filename} data chunk for completed upload!`);
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
writeStream.write(data);
|
|
46
|
-
hash.update(data);
|
|
47
|
-
fileSize += data.length;
|
|
48
|
-
debugLog(options, `Uploading ${fieldname}->${filename}, bytes:${fileSize}...`);
|
|
49
|
-
},
|
|
50
|
-
getFilePath: () => tempFilePath,
|
|
51
|
-
getFileSize: () => fileSize,
|
|
52
|
-
getHash: () => hash.digest('hex'),
|
|
53
|
-
getWritePromise: () => writePromise
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
export const memHandler = (options, fieldname, filename) => {
|
|
57
|
-
const buffers = [];
|
|
58
|
-
const hash = crypto.createHash('md5');
|
|
59
|
-
let fileSize = 0;
|
|
60
|
-
let completed = false;
|
|
61
|
-
const getBuffer = () => Buffer.concat(buffers, fileSize);
|
|
62
|
-
return {
|
|
63
|
-
cleanup: () => {
|
|
64
|
-
completed = true;
|
|
65
|
-
},
|
|
66
|
-
complete: () => {
|
|
67
|
-
debugLog(options, `Upload ${fieldname}->${filename} completed, bytes:${fileSize}.`);
|
|
68
|
-
completed = true;
|
|
69
|
-
return getBuffer();
|
|
70
|
-
},
|
|
71
|
-
dataHandler: data => {
|
|
72
|
-
if (completed === true) {
|
|
73
|
-
debugLog(options, `Error: got ${fieldname}->${filename} data chunk for completed upload!`);
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
buffers.push(data);
|
|
77
|
-
hash.update(data);
|
|
78
|
-
fileSize += data.length;
|
|
79
|
-
debugLog(options, `Uploading ${fieldname}->${filename}, bytes:${fileSize}...`);
|
|
80
|
-
},
|
|
81
|
-
getFilePath: () => '',
|
|
82
|
-
getFileSize: () => fileSize,
|
|
83
|
-
getHash: () => hash.digest('hex'),
|
|
84
|
-
getWritePromise: () => Promise.resolve(true)
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
|
-
//# sourceMappingURL=handlers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.js","names":["crypto","fs","WriteStream","path","checkAndMakeDir","debugLog","deleteFile","getTempFilename","tempFileHandler","options","fieldname","filename","dir","normalize","tempFileDir","tempFilePath","join","process","cwd","createParentPath","hash","createHash","fileSize","completed","writeStream","createWriteStream","writePromise","Promise","resolve","reject","on","err","cleanup","end","complete","Buffer","concat","dataHandler","data","write","update","length","getFilePath","getFileSize","getHash","digest","getWritePromise","memHandler","buffers","getBuffer","push"],"sources":["../../src/fetchAPI-multipart/handlers.ts"],"sourcesContent":["import type { FetchAPIFileUploadOptions } from 'payload'\n\nimport crypto from 'crypto'\nimport fs, { WriteStream } from 'fs'\nimport path from 'path'\n\nimport { checkAndMakeDir, debugLog, deleteFile, getTempFilename } from './utilities.js'\n\ntype Handler = (\n options: FetchAPIFileUploadOptions,\n fieldname: string,\n filename: string,\n) => {\n cleanup: () => void\n complete: () => Buffer\n dataHandler: (data: Buffer) => void\n getFilePath: () => string\n getFileSize: () => number\n getHash: () => string\n getWritePromise: () => Promise<boolean>\n}\n\nexport const tempFileHandler: Handler = (options, fieldname, filename) => {\n const dir = path.normalize(options.tempFileDir)\n const tempFilePath = path.join(process.cwd(), dir, getTempFilename())\n checkAndMakeDir({ createParentPath: true }, tempFilePath)\n\n debugLog(options, `Temporary file path is ${tempFilePath}`)\n\n const hash = crypto.createHash('md5')\n let fileSize = 0\n let completed = false\n\n debugLog(options, `Opening write stream for ${fieldname}->${filename}...`)\n const writeStream = fs.createWriteStream(tempFilePath)\n const writePromise = new Promise<boolean>((resolve, reject) => {\n writeStream.on('finish', () => resolve(true))\n writeStream.on('error', (err) => {\n debugLog(options, `Error write temp file: ${err}`)\n reject(err)\n })\n })\n\n return {\n cleanup: () => {\n completed = true\n debugLog(options, `Cleaning up temporary file ${tempFilePath}...`)\n writeStream.end()\n deleteFile(tempFilePath, (err) =>\n err\n ? debugLog(options, `Cleaning up temporary file ${tempFilePath} failed: ${err}`)\n : debugLog(options, `Cleaning up temporary file ${tempFilePath} done.`),\n )\n },\n complete: () => {\n completed = true\n debugLog(options, `Upload ${fieldname}->${filename} completed, bytes:${fileSize}.`)\n if (writeStream instanceof WriteStream) {\n writeStream.end()\n }\n // Return empty buff since data was uploaded into a temp file.\n return Buffer.concat([])\n },\n dataHandler: (data) => {\n if (completed === true) {\n debugLog(options, `Error: got ${fieldname}->${filename} data chunk for completed upload!`)\n return\n }\n writeStream.write(data)\n hash.update(data)\n fileSize += data.length\n debugLog(options, `Uploading ${fieldname}->${filename}, bytes:${fileSize}...`)\n },\n getFilePath: () => tempFilePath,\n getFileSize: () => fileSize,\n getHash: () => hash.digest('hex'),\n getWritePromise: () => writePromise,\n }\n}\n\nexport const memHandler: Handler = (options, fieldname, filename) => {\n const buffers: Buffer[] = []\n const hash = crypto.createHash('md5')\n let fileSize = 0\n let completed = false\n\n const getBuffer = () => Buffer.concat(buffers, fileSize)\n\n return {\n cleanup: () => {\n completed = true\n },\n complete: () => {\n debugLog(options, `Upload ${fieldname}->${filename} completed, bytes:${fileSize}.`)\n completed = true\n return getBuffer()\n },\n dataHandler: (data) => {\n if (completed === true) {\n debugLog(options, `Error: got ${fieldname}->${filename} data chunk for completed upload!`)\n return\n }\n buffers.push(data)\n hash.update(data)\n fileSize += data.length\n debugLog(options, `Uploading ${fieldname}->${filename}, bytes:${fileSize}...`)\n },\n getFilePath: () => '',\n getFileSize: () => fileSize,\n getHash: () => hash.digest('hex'),\n getWritePromise: () => Promise.resolve(true),\n }\n}\n"],"mappings":"AAEA,OAAOA,MAAA,MAAY;AACnB,OAAOC,EAAA,IAAMC,WAAW,QAAQ;AAChC,OAAOC,IAAA,MAAU;AAEjB,SAASC,eAAe,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,eAAe,QAAQ;AAgBvE,OAAO,MAAMC,eAAA,GAA2BA,CAACC,OAAA,EAASC,SAAA,EAAWC,QAAA;EAC3D,MAAMC,GAAA,GAAMT,IAAA,CAAKU,SAAS,CAACJ,OAAA,CAAQK,WAAW;EAC9C,MAAMC,YAAA,GAAeZ,IAAA,CAAKa,IAAI,CAACC,OAAA,CAAQC,GAAG,IAAIN,GAAA,EAAKL,eAAA;EACnDH,eAAA,CAAgB;IAAEe,gBAAA,EAAkB;EAAK,GAAGJ,YAAA;EAE5CV,QAAA,CAASI,OAAA,EAAS,0BAA0BM,YAAA,EAAc;EAE1D,MAAMK,IAAA,GAAOpB,MAAA,CAAOqB,UAAU,CAAC;EAC/B,IAAIC,QAAA,GAAW;EACf,IAAIC,SAAA,GAAY;EAEhBlB,QAAA,CAASI,OAAA,EAAS,4BAA4BC,SAAA,KAAcC,QAAA,KAAa;EACzE,MAAMa,WAAA,GAAcvB,EAAA,CAAGwB,iBAAiB,CAACV,YAAA;EACzC,MAAMW,YAAA,GAAe,IAAIC,OAAA,CAAiB,CAACC,OAAA,EAASC,MAAA;IAClDL,WAAA,CAAYM,EAAE,CAAC,UAAU,MAAMF,OAAA,CAAQ;IACvCJ,WAAA,CAAYM,EAAE,CAAC,SAAUC,GAAA;MACvB1B,QAAA,CAASI,OAAA,EAAS,0BAA0BsB,GAAA,EAAK;MACjDF,MAAA,CAAOE,GAAA;IACT;EACF;EAEA,OAAO;IACLC,OAAA,EAASA,CAAA;MACPT,SAAA,GAAY;MACZlB,QAAA,CAASI,OAAA,EAAS,8BAA8BM,YAA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0B,SAAA,GAAYA,CAAA,KAAMd,MAAA,CAAOC,MAAM,CAACY,OAAA,EAAS1B,QAAA;EAE/C,OAAO;IACLU,OAAA,EAASA,CAAA;MACPT,SAAA,GAAY;IACd;IACAW,QAAA,EAAUA,CAAA;MACR7B,QAAA,CAASI,OAAA,EAAS,UAAUC,SAAA,KAAcC,QAAA,qBAA6BW,QAAA,GAAW;MAClFC,SAAA,GAAY;MACZ,OAAO0B,SAAA;IACT;IACAZ,WAAA,EAAcC,IAAA;MACZ,IAAIf,SAAA,KAAc,MAAM;QACtBlB,QAAA,CAASI,OAAA,EAAS,cAAcC,SAAA,KAAcC,QAAA,mCAA2C;QACzF;MACF;MACAqC,OAAA,CAAQE,IAAI,CAACZ,IAAA;MACblB,IAAA,CAAKoB,MAAM,CAACF,IAAA;MACZhB,QAAA,IAAYgB,IAAA,CAAKG,MAAM;MACvBpC,QAAA,CAASI,OAAA,EAAS,aAAaC,SAAA,KAAcC,QAAA,WAAmBW,QAAA,KAAa;IAC/E;IACAoB,WAAA,EAAaA,CAAA,KAAM;IACnBC,WAAA,EAAaA,CAAA,KAAMrB,QAAA;IACnBsB,OAAA,EAASA,CAAA,KAAMxB,IAAA,CAAKyB,MAAM,CAAC;IAC3BC,eAAA,EAAiBA,CAAA,KAAMnB,OAAA,CAAQC,OAAO,CAAC;EACzC;AACF","ignoreList":[]}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { FetchAPIFileUploadOptions } from 'payload';
|
|
2
|
-
import { APIError } from 'payload';
|
|
3
|
-
export type FileShape = {
|
|
4
|
-
data: Buffer;
|
|
5
|
-
encoding: string;
|
|
6
|
-
md5: Buffer | string;
|
|
7
|
-
mimetype: string;
|
|
8
|
-
mv: (filePath: string, callback: () => void) => Promise<void> | void;
|
|
9
|
-
name: string;
|
|
10
|
-
size: number;
|
|
11
|
-
tempFilePath: string;
|
|
12
|
-
truncated: boolean;
|
|
13
|
-
};
|
|
14
|
-
type FetchAPIFileUploadResponseFile = {
|
|
15
|
-
data: Buffer;
|
|
16
|
-
mimetype: string;
|
|
17
|
-
name: string;
|
|
18
|
-
size: number;
|
|
19
|
-
tempFilePath?: string;
|
|
20
|
-
};
|
|
21
|
-
export type FetchAPIFileUploadResponse = {
|
|
22
|
-
error?: APIError;
|
|
23
|
-
fields: Record<string, string>;
|
|
24
|
-
files: Record<string, FetchAPIFileUploadResponseFile>;
|
|
25
|
-
};
|
|
26
|
-
type FetchAPIFileUpload = (args: {
|
|
27
|
-
options?: FetchAPIFileUploadOptions;
|
|
28
|
-
request: Request;
|
|
29
|
-
}) => Promise<FetchAPIFileUploadResponse>;
|
|
30
|
-
export declare const fetchAPIFileUpload: FetchAPIFileUpload;
|
|
31
|
-
export {};
|
|
32
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fetchAPI-multipart/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAGxD,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAsBlC,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,EAAE,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IACpE,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,KAAK,8BAA8B,GAAG;IACpC,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC,KAAK,CAAC,EAAE,QAAQ,CAAA;IAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC9B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,8BAA8B,CAAC,CAAA;CACtD,CAAA;AAED,KAAK,kBAAkB,GAAG,CAAC,IAAI,EAAE;IAC/B,OAAO,CAAC,EAAE,yBAAyB,CAAA;IACnC,OAAO,EAAE,OAAO,CAAA;CACjB,KAAK,OAAO,CAAC,0BAA0B,CAAC,CAAA;AACzC,eAAO,MAAM,kBAAkB,EAAE,kBAYhC,CAAA"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import { APIError } from 'payload';
|
|
3
|
-
import { isEligibleRequest } from './isEligibleRequest.js';
|
|
4
|
-
import { processMultipart } from './processMultipart.js';
|
|
5
|
-
import { debugLog } from './utilities.js';
|
|
6
|
-
const DEFAULT_OPTIONS = {
|
|
7
|
-
abortOnLimit: false,
|
|
8
|
-
createParentPath: false,
|
|
9
|
-
debug: false,
|
|
10
|
-
defParamCharset: 'utf8',
|
|
11
|
-
limitHandler: false,
|
|
12
|
-
parseNested: false,
|
|
13
|
-
preserveExtension: false,
|
|
14
|
-
responseOnLimit: 'File size limit has been reached',
|
|
15
|
-
safeFileNames: false,
|
|
16
|
-
tempFileDir: path.join(process.cwd(), 'tmp'),
|
|
17
|
-
uploadTimeout: 60000,
|
|
18
|
-
uriDecodeFileNames: false,
|
|
19
|
-
useTempFiles: false
|
|
20
|
-
};
|
|
21
|
-
export const fetchAPIFileUpload = async ({
|
|
22
|
-
options,
|
|
23
|
-
request
|
|
24
|
-
}) => {
|
|
25
|
-
const uploadOptions = {
|
|
26
|
-
...DEFAULT_OPTIONS,
|
|
27
|
-
...options
|
|
28
|
-
};
|
|
29
|
-
if (!isEligibleRequest(request)) {
|
|
30
|
-
debugLog(uploadOptions, 'Request is not eligible for file upload!');
|
|
31
|
-
return {
|
|
32
|
-
error: new APIError('Request is not eligible for file upload', 500),
|
|
33
|
-
fields: undefined,
|
|
34
|
-
files: undefined
|
|
35
|
-
};
|
|
36
|
-
} else {
|
|
37
|
-
return processMultipart({
|
|
38
|
-
options: uploadOptions,
|
|
39
|
-
request
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["path","APIError","isEligibleRequest","processMultipart","debugLog","DEFAULT_OPTIONS","abortOnLimit","createParentPath","debug","defParamCharset","limitHandler","parseNested","preserveExtension","responseOnLimit","safeFileNames","tempFileDir","join","process","cwd","uploadTimeout","uriDecodeFileNames","useTempFiles","fetchAPIFileUpload","options","request","uploadOptions","error","fields","undefined","files"],"sources":["../../src/fetchAPI-multipart/index.ts"],"sourcesContent":["import type { FetchAPIFileUploadOptions } from 'payload'\n\nimport path from 'path'\nimport { APIError } from 'payload'\n\nimport { isEligibleRequest } from './isEligibleRequest.js'\nimport { processMultipart } from './processMultipart.js'\nimport { debugLog } from './utilities.js'\n\nconst DEFAULT_OPTIONS: FetchAPIFileUploadOptions = {\n abortOnLimit: false,\n createParentPath: false,\n debug: false,\n defParamCharset: 'utf8',\n limitHandler: false,\n parseNested: false,\n preserveExtension: false,\n responseOnLimit: 'File size limit has been reached',\n safeFileNames: false,\n tempFileDir: path.join(process.cwd(), 'tmp'),\n uploadTimeout: 60000,\n uriDecodeFileNames: false,\n useTempFiles: false,\n}\n\nexport type FileShape = {\n data: Buffer\n encoding: string\n md5: Buffer | string\n mimetype: string\n mv: (filePath: string, callback: () => void) => Promise<void> | void\n name: string\n size: number\n tempFilePath: string\n truncated: boolean\n}\n\ntype FetchAPIFileUploadResponseFile = {\n data: Buffer\n mimetype: string\n name: string\n size: number\n tempFilePath?: string\n}\n\nexport type FetchAPIFileUploadResponse = {\n error?: APIError\n fields: Record<string, string>\n files: Record<string, FetchAPIFileUploadResponseFile>\n}\n\ntype FetchAPIFileUpload = (args: {\n options?: FetchAPIFileUploadOptions\n request: Request\n}) => Promise<FetchAPIFileUploadResponse>\nexport const fetchAPIFileUpload: FetchAPIFileUpload = async ({ options, request }) => {\n const uploadOptions: FetchAPIFileUploadOptions = { ...DEFAULT_OPTIONS, ...options }\n if (!isEligibleRequest(request)) {\n debugLog(uploadOptions, 'Request is not eligible for file upload!')\n return {\n error: new APIError('Request is not eligible for file upload', 500),\n fields: undefined,\n files: undefined,\n }\n } else {\n return processMultipart({ options: uploadOptions, request })\n }\n}\n"],"mappings":"AAEA,OAAOA,IAAA,MAAU;AACjB,SAASC,QAAQ,QAAQ;AAEzB,SAASC,iBAAiB,QAAQ;AAClC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,QAAQ,QAAQ;AAEzB,MAAMC,eAAA,GAA6C;EACjDC,YAAA,EAAc;EACdC,gBAAA,EAAkB;EAClBC,KAAA,EAAO;EACPC,eAAA,EAAiB;EACjBC,YAAA,EAAc;EACdC,WAAA,EAAa;EACbC,iBAAA,EAAmB;EACnBC,eAAA,EAAiB;EACjBC,aAAA,EAAe;EACfC,WAAA,EAAaf,IAAA,CAAKgB,IAAI,CAACC,OAAA,CAAQC,GAAG,IAAI;EACtCC,aAAA,EAAe;EACfC,kBAAA,EAAoB;EACpBC,YAAA,EAAc;AAChB;AAgCA,OAAO,MAAMC,kBAAA,GAAyC,MAAAA,CAAO;EAAEC,OAAO;EAAEC;AAAO,CAAE;EAC/E,MAAMC,aAAA,GAA2C;IAAE,GAAGpB,eAAe;IAAE,GAAGkB;EAAQ;EAClF,IAAI,CAACrB,iBAAA,CAAkBsB,OAAA,GAAU;IAC/BpB,QAAA,CAASqB,aAAA,EAAe;IACxB,OAAO;MACLC,KAAA,EAAO,IAAIzB,QAAA,CAAS,2CAA2C;MAC/D0B,MAAA,EAAQC,SAAA;MACRC,KAAA,EAAOD;IACT;EACF,OAAO;IACL,OAAOzB,gBAAA,CAAiB;MAAEoB,OAAA,EAASE,aAAA;MAAeD;IAAQ;EAC5D;AACF","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isEligibleRequest.d.ts","sourceRoot":"","sources":["../../src/fetchAPI-multipart/isEligibleRequest.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,iBAAiB,QAAS,OAAO,KAAG,OAMhD,CAAA"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
const ACCEPTABLE_CONTENT_TYPE = /multipart\/['"()+-_]+(?:; ?['"()+-_]*)+$/i;
|
|
2
|
-
const UNACCEPTABLE_METHODS = new Set(['CONNECT', 'DELETE', 'GET', 'HEAD', 'OPTIONS', 'TRACE']);
|
|
3
|
-
const hasBody = req => {
|
|
4
|
-
return Boolean(req.headers.get('transfer-encoding') || req.headers.get('content-length') && req.headers.get('content-length') !== '0');
|
|
5
|
-
};
|
|
6
|
-
const hasAcceptableMethod = req => !UNACCEPTABLE_METHODS.has(req.method);
|
|
7
|
-
const hasAcceptableContentType = req => {
|
|
8
|
-
const contType = req.headers.get('content-type');
|
|
9
|
-
return contType.includes('boundary=') && ACCEPTABLE_CONTENT_TYPE.test(contType);
|
|
10
|
-
};
|
|
11
|
-
export const isEligibleRequest = req => {
|
|
12
|
-
try {
|
|
13
|
-
return hasBody(req) && hasAcceptableMethod(req) && hasAcceptableContentType(req);
|
|
14
|
-
} catch (e) {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=isEligibleRequest.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isEligibleRequest.js","names":["ACCEPTABLE_CONTENT_TYPE","UNACCEPTABLE_METHODS","Set","hasBody","req","Boolean","headers","get","hasAcceptableMethod","has","method","hasAcceptableContentType","contType","includes","test","isEligibleRequest","e"],"sources":["../../src/fetchAPI-multipart/isEligibleRequest.ts"],"sourcesContent":["const ACCEPTABLE_CONTENT_TYPE = /multipart\\/['\"()+-_]+(?:; ?['\"()+-_]*)+$/i\nconst UNACCEPTABLE_METHODS = new Set(['CONNECT', 'DELETE', 'GET', 'HEAD', 'OPTIONS', 'TRACE'])\n\nconst hasBody = (req: Request): boolean => {\n return Boolean(\n req.headers.get('transfer-encoding') ||\n (req.headers.get('content-length') && req.headers.get('content-length') !== '0'),\n )\n}\n\nconst hasAcceptableMethod = (req: Request): boolean => !UNACCEPTABLE_METHODS.has(req.method)\n\nconst hasAcceptableContentType = (req: Request): boolean => {\n const contType = req.headers.get('content-type')\n return contType.includes('boundary=') && ACCEPTABLE_CONTENT_TYPE.test(contType)\n}\n\nexport const isEligibleRequest = (req: Request): boolean => {\n try {\n return hasBody(req) && hasAcceptableMethod(req) && hasAcceptableContentType(req)\n } catch (e) {\n return false\n }\n}\n"],"mappings":"AAAA,MAAMA,uBAAA,GAA0B;AAChC,MAAMC,oBAAA,GAAuB,IAAIC,GAAA,CAAI,CAAC,WAAW,UAAU,OAAO,QAAQ,WAAW,QAAQ;AAE7F,MAAMC,OAAA,GAAWC,GAAA;EACf,OAAOC,OAAA,CACLD,GAAA,CAAIE,OAAO,CAACC,GAAG,CAAC,wBACbH,GAAA,CAAIE,OAAO,CAACC,GAAG,CAAC,qBAAqBH,GAAA,CAAIE,OAAO,CAACC,GAAG,CAAC,sBAAsB;AAElF;AAEA,MAAMC,mBAAA,GAAuBJ,GAAA,IAA0B,CAACH,oBAAA,CAAqBQ,GAAG,CAACL,GAAA,CAAIM,MAAM;AAE3F,MAAMC,wBAAA,GAA4BP,GAAA;EAChC,MAAMQ,QAAA,GAAWR,GAAA,CAAIE,OAAO,CAACC,GAAG,CAAC;EACjC,OAAOK,QAAA,CAASC,QAAQ,CAAC,gBAAgBb,uBAAA,CAAwBc,IAAI,CAACF,QAAA;AACxE;AAEA,OAAO,MAAMG,iBAAA,GAAqBX,GAAA;EAChC,IAAI;IACF,OAAOD,OAAA,CAAQC,GAAA,KAAQI,mBAAA,CAAoBJ,GAAA,KAAQO,wBAAA,CAAyBP,GAAA;EAC9E,EAAE,OAAOY,CAAA,EAAG;IACV,OAAO;EACT;AACF","ignoreList":[]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { FetchAPIFileUploadOptions } from 'payload';
|
|
2
|
-
import type { FetchAPIFileUploadResponse } from './index.js';
|
|
3
|
-
type ProcessMultipart = (args: {
|
|
4
|
-
options: FetchAPIFileUploadOptions;
|
|
5
|
-
request: Request;
|
|
6
|
-
}) => Promise<FetchAPIFileUploadResponse>;
|
|
7
|
-
export declare const processMultipart: ProcessMultipart;
|
|
8
|
-
export {};
|
|
9
|
-
//# sourceMappingURL=processMultipart.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"processMultipart.d.ts","sourceRoot":"","sources":["../../src/fetchAPI-multipart/processMultipart.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAOxD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAA;AAU5D,KAAK,gBAAgB,GAAG,CAAC,IAAI,EAAE;IAC7B,OAAO,EAAE,yBAAyB,CAAA;IAClC,OAAO,EAAE,OAAO,CAAA;CACjB,KAAK,OAAO,CAAC,0BAA0B,CAAC,CAAA;AACzC,eAAO,MAAM,gBAAgB,EAAE,gBAmM9B,CAAA"}
|