Files
klz-cables.com/.pnpm-store/v10/files/62/d660ae6905bec84f7465290a8f01b2aafafd14d5e30b07de098f93357b11da4e81415a0375452b613cdc1047d731ce4392aca55f5702f21d845fa823d0f2e9
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

1 line
14 KiB
Plaintext

{"version":3,"file":"index.js","names":["React","createContext","useCallback","ServerFunctionsContext","undefined","useServerFunctions","context","use","Error","ServerFunctionsProvider","children","serverFunction","getDocumentSlots","args","name","schedulePublish","signal","remoteSignal","rest","aborted","result","_err","console","error","type","doc","value","relationTo","getFormState","fallbackLocale","state","getTableState","renderDocument","copyDataFromLocale","data","getFolderResultsComponentAndData","_internal_renderField","slugify","_jsx"],"sources":["../../../src/providers/ServerFunctions/index.tsx"],"sourcesContent":["import type {\n AdminViewServerPropsOnly,\n BuildFormStateArgs,\n BuildTableStateArgs,\n Data,\n DocumentPreferences,\n DocumentSlots,\n FormState,\n GetFolderResultsComponentAndDataArgs,\n Params,\n RenderDocumentVersionsProperties,\n ServerFunction,\n ServerFunctionClient,\n SlugifyServerFunctionArgs,\n} from 'payload'\nimport type { Slugify } from 'payload/shared'\n\nimport React, { createContext, useCallback } from 'react'\n\nimport type {\n RenderFieldServerFnArgs,\n RenderFieldServerFnReturnType,\n} from '../../forms/fieldSchemasToFormState/serverFunctions/renderFieldServerFn.js'\nimport type { buildFormStateHandler } from '../../utilities/buildFormState.js'\nimport type { buildTableStateHandler } from '../../utilities/buildTableState.js'\nimport type { CopyDataFromLocaleArgs } from '../../utilities/copyDataFromLocale.js'\nimport type { getFolderResultsComponentAndDataHandler } from '../../utilities/getFolderResultsComponentAndData.js'\nimport type {\n schedulePublishHandler,\n SchedulePublishHandlerArgs,\n} from '../../utilities/schedulePublishHandler.js'\n\ntype GetFormStateClient = (\n args: {\n signal?: AbortSignal\n } & Omit<BuildFormStateArgs, 'clientConfig' | 'req'>,\n) => ReturnType<typeof buildFormStateHandler>\n\ntype SchedulePublishClient = (\n args: {\n signal?: AbortSignal\n } & Omit<SchedulePublishHandlerArgs, 'clientConfig' | 'req'>,\n) => ReturnType<typeof schedulePublishHandler>\n\ntype GetTableStateClient = (\n args: {\n signal?: AbortSignal\n } & Omit<BuildTableStateArgs, 'clientConfig' | 'req'>,\n) => ReturnType<typeof buildTableStateHandler>\n\ntype SlugifyClient = (\n args: {\n signal?: AbortSignal\n } & Omit<SlugifyServerFunctionArgs, 'clientConfig' | 'req'>,\n) => ReturnType<Slugify>\n\nexport type RenderDocumentResult = {\n data: any\n Document: React.ReactNode\n preferences: DocumentPreferences\n}\n\ntype RenderDocumentBaseArgs = {\n collectionSlug: string\n disableActions?: boolean\n docID: number | string\n drawerSlug?: string\n initialData?: Data\n initialState?: FormState\n overrideEntityVisibility?: boolean\n paramsOverride?: AdminViewServerPropsOnly['params']\n redirectAfterCreate?: boolean\n redirectAfterDelete: boolean\n redirectAfterDuplicate: boolean\n redirectAfterRestore?: boolean\n searchParams?: Params\n /**\n * Properties specific to the versions view\n */\n versions?: RenderDocumentVersionsProperties\n}\n\nexport type RenderDocumentServerFunction = ServerFunction<\n RenderDocumentBaseArgs,\n Promise<RenderDocumentResult>\n>\n\ntype RenderDocumentServerFunctionHookFn = (\n // No req or importMap - those are augmented by handleServerFunctions\n args: {\n signal?: AbortSignal\n } & RenderDocumentBaseArgs,\n) => Promise<RenderDocumentResult>\n\ntype CopyDataFromLocaleClient = (\n args: {\n signal?: AbortSignal\n } & Omit<CopyDataFromLocaleArgs, 'req'>,\n) => Promise<{ data: Data }>\n\ntype GetDocumentSlots = (args: {\n collectionSlug: string\n id?: number | string\n signal?: AbortSignal\n}) => Promise<DocumentSlots>\n\ntype GetFolderResultsComponentAndDataClient = (\n args: {\n signal?: AbortSignal\n } & Omit<GetFolderResultsComponentAndDataArgs, 'req'>,\n) => ReturnType<typeof getFolderResultsComponentAndDataHandler>\n\ntype RenderFieldClient = (args: RenderFieldServerFnArgs) => Promise<RenderFieldServerFnReturnType>\n\nexport type ServerFunctionsContextType = {\n _internal_renderField: RenderFieldClient\n copyDataFromLocale: CopyDataFromLocaleClient\n getDocumentSlots: GetDocumentSlots\n getFolderResultsComponentAndData: GetFolderResultsComponentAndDataClient\n getFormState: GetFormStateClient\n getTableState: GetTableStateClient\n renderDocument: RenderDocumentServerFunctionHookFn\n schedulePublish: SchedulePublishClient\n serverFunction: ServerFunctionClient\n slugify: SlugifyClient\n}\n\nexport const ServerFunctionsContext = createContext<ServerFunctionsContextType | undefined>(\n undefined,\n)\n\nexport const useServerFunctions = () => {\n const context = React.use(ServerFunctionsContext)\n if (context === undefined) {\n throw new Error('useServerFunctions must be used within a ServerFunctionsProvider')\n }\n return context\n}\n\nexport const ServerFunctionsProvider: React.FC<{\n children: React.ReactNode\n serverFunction: ServerFunctionClient\n}> = ({ children, serverFunction }) => {\n if (!serverFunction) {\n throw new Error('ServerFunctionsProvider requires a serverFunction prop')\n }\n\n const getDocumentSlots = useCallback<GetDocumentSlots>(\n async (args) =>\n await serverFunction({\n name: 'render-document-slots',\n args,\n }),\n [serverFunction],\n )\n\n const schedulePublish = useCallback<SchedulePublishClient>(\n async (args) => {\n const { signal: remoteSignal, ...rest } = args\n\n try {\n if (!remoteSignal?.aborted) {\n const result = await serverFunction({\n name: 'schedule-publish',\n args: { ...rest },\n })\n\n if (!remoteSignal?.aborted) {\n return result\n }\n }\n } catch (_err) {\n console.error(_err) // eslint-disable-line no-console\n }\n\n let error = `Error scheduling ${rest.type}`\n\n if (rest.doc) {\n error += ` for document with ID ${rest.doc.value} in collection ${rest.doc.relationTo}`\n }\n\n return { error }\n },\n [serverFunction],\n )\n\n const getFormState = useCallback<GetFormStateClient>(\n async (args) => {\n const { signal: remoteSignal, ...rest } = args || {}\n\n try {\n if (!remoteSignal?.aborted) {\n const result = (await serverFunction({\n name: 'form-state',\n args: { fallbackLocale: false, ...rest },\n })) as Awaited<ReturnType<typeof buildFormStateHandler>> // TODO: infer this type when `strictNullChecks` is enabled\n\n if (!remoteSignal?.aborted) {\n return result\n }\n }\n } catch (_err) {\n console.error(_err) // eslint-disable-line no-console\n }\n\n return { state: null }\n },\n [serverFunction],\n )\n\n const getTableState = useCallback<GetTableStateClient>(\n async (args) => {\n const { signal: remoteSignal, ...rest } = args || {}\n\n try {\n if (!remoteSignal?.aborted) {\n const result = (await serverFunction({\n name: 'table-state',\n args: { fallbackLocale: false, ...rest },\n })) as Awaited<ReturnType<typeof buildTableStateHandler>> // TODO: infer this type when `strictNullChecks` is enabled\n\n if (!remoteSignal?.aborted) {\n return result\n }\n }\n } catch (_err) {\n console.error(_err) // eslint-disable-line no-console\n }\n\n // return { state: args.formState }\n },\n [serverFunction],\n )\n\n const renderDocument = useCallback<RenderDocumentServerFunctionHookFn>(\n async (args) => {\n const { signal: remoteSignal, ...rest } = args || {}\n try {\n const result = (await serverFunction({\n name: 'render-document',\n args: {\n fallbackLocale: false,\n ...rest,\n } as Parameters<RenderDocumentServerFunctionHookFn>[0],\n })) as Awaited<ReturnType<RenderDocumentServerFunctionHookFn>> // TODO: infer this type when `strictNullChecks` is enabled\n\n return result\n } catch (_err) {\n console.error(_err) // eslint-disable-line no-console\n }\n },\n [serverFunction],\n )\n\n const copyDataFromLocale = useCallback<CopyDataFromLocaleClient>(\n async (args) => {\n const { signal: remoteSignal, ...rest } = args || {}\n\n const result = (await serverFunction({\n name: 'copy-data-from-locale',\n args: rest,\n })) as Data\n\n if (!remoteSignal?.aborted) {\n return { data: result }\n }\n },\n [serverFunction],\n )\n\n const getFolderResultsComponentAndData = useCallback<GetFolderResultsComponentAndDataClient>(\n async (args) => {\n const { signal: remoteSignal, ...rest } = args || {}\n\n try {\n const result = (await serverFunction({\n name: 'get-folder-results-component-and-data',\n args: rest,\n })) as Awaited<ReturnType<typeof getFolderResultsComponentAndDataHandler>>\n\n if (!remoteSignal?.aborted) {\n return result\n }\n } catch (_err) {\n console.error(_err) // eslint-disable-line no-console\n }\n },\n [serverFunction],\n )\n\n const _internal_renderField = useCallback<RenderFieldClient>(\n async (args) => {\n try {\n const result = (await serverFunction({\n name: 'render-field',\n args,\n })) as RenderFieldServerFnReturnType\n\n return result\n } catch (_err) {\n console.error(_err) // eslint-disable-line no-console\n }\n },\n [serverFunction],\n )\n\n const slugify = useCallback<SlugifyClient>(\n async (args) => {\n const { signal: remoteSignal, ...rest } = args || {}\n\n try {\n const result = (await serverFunction({\n name: 'slugify',\n args: { ...rest },\n })) as Awaited<ReturnType<Slugify>> // TODO: infer this type when `strictNullChecks` is enabled\n\n return result\n } catch (_err) {\n console.error(_err) // eslint-disable-line no-console\n }\n },\n [serverFunction],\n )\n\n return (\n <ServerFunctionsContext\n value={{\n _internal_renderField,\n copyDataFromLocale,\n getDocumentSlots,\n getFolderResultsComponentAndData,\n getFormState,\n getTableState,\n renderDocument,\n schedulePublish,\n serverFunction,\n slugify,\n }}\n >\n {children}\n </ServerFunctionsContext>\n )\n}\n"],"mappings":";AAiBA,OAAOA,KAAA,IAASC,aAAa,EAAEC,WAAW,QAAQ;AA8GlD,OAAO,MAAMC,sBAAA,gBAAyBF,aAAA,CACpCG,SAAA;AAGF,OAAO,MAAMC,kBAAA,GAAqBA,CAAA;EAChC,MAAMC,OAAA,GAAUN,KAAA,CAAMO,GAAG,CAACJ,sBAAA;EAC1B,IAAIG,OAAA,KAAYF,SAAA,EAAW;IACzB,MAAM,IAAII,KAAA,CAAM;EAClB;EACA,OAAOF,OAAA;AACT;AAEA,OAAO,MAAMG,uBAAA,GAGRA,CAAC;EAAEC,QAAQ;EAAEC;AAAc,CAAE;EAChC,IAAI,CAACA,cAAA,EAAgB;IACn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