@payloadcms/plugin-search 3.20.0 → 3.21.0-canary.0a1cc6a

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Search/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAS,MAAM,SAAS,CAAA;AAEtD,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAA;AAKhE,eAAO,MAAM,wBAAwB,iBACrB,6BAA6B,KAC1C,gBAuGF,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Search/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAS,MAAM,SAAS,CAAA;AAEtD,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAA;AAKhE,eAAO,MAAM,wBAAwB,iBACrB,6BAA6B,KAC1C,gBAqGF,CAAA"}
@@ -1,7 +1,6 @@
1
1
  import { generateReindexHandler } from '../utilities/generateReindexHandler.js';
2
2
  // all settings can be overridden by the config
3
3
  export const generateSearchCollection = (pluginConfig)=>{
4
- const apiBasePath = pluginConfig?.apiBasePath || '/api';
5
4
  const searchSlug = pluginConfig?.searchOverrides?.slug || 'search';
6
5
  const searchCollections = pluginConfig?.collections || [];
7
6
  const collectionLabels = pluginConfig?.labels;
@@ -62,7 +61,6 @@ export const generateSearchCollection = (pluginConfig)=>{
62
61
  {
63
62
  path: '@payloadcms/plugin-search/client#ReindexButton',
64
63
  serverProps: {
65
- apiBasePath,
66
64
  collectionLabels,
67
65
  searchCollections,
68
66
  searchSlug
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Search/index.ts"],"sourcesContent":["import type { CollectionConfig, Field } from 'payload'\n\nimport type { SearchPluginConfigWithLocales } from '../types.js'\n\nimport { generateReindexHandler } from '../utilities/generateReindexHandler.js'\n\n// all settings can be overridden by the config\nexport const generateSearchCollection = (\n pluginConfig: SearchPluginConfigWithLocales,\n): CollectionConfig => {\n const apiBasePath = pluginConfig?.apiBasePath || '/api'\n const searchSlug = pluginConfig?.searchOverrides?.slug || 'search'\n const searchCollections = pluginConfig?.collections || []\n const collectionLabels = pluginConfig?.labels\n\n const defaultFields: Field[] = [\n {\n name: 'title',\n type: 'text',\n admin: {\n readOnly: true,\n },\n localized: pluginConfig.localize,\n },\n {\n name: 'priority',\n type: 'number',\n admin: {\n position: 'sidebar',\n },\n },\n {\n name: 'doc',\n type: 'relationship',\n admin: {\n position: 'sidebar',\n readOnly: true,\n },\n index: true,\n maxDepth: 0,\n relationTo: searchCollections,\n required: true,\n },\n {\n name: 'docUrl',\n type: 'ui',\n admin: {\n components: {\n Field: {\n path: '@payloadcms/plugin-search/client#LinkToDoc',\n },\n },\n position: 'sidebar',\n },\n },\n ]\n\n const newConfig: CollectionConfig = {\n ...(pluginConfig?.searchOverrides || {}),\n slug: searchSlug,\n access: {\n create: (): boolean => false,\n read: (): boolean => true,\n ...(pluginConfig?.searchOverrides?.access || {}),\n },\n admin: {\n components: {\n views: {\n list: {\n actions: [\n {\n path: '@payloadcms/plugin-search/client#ReindexButton',\n serverProps: {\n apiBasePath,\n collectionLabels,\n searchCollections,\n searchSlug,\n },\n },\n ],\n },\n },\n },\n defaultColumns: ['title'],\n description:\n 'This is a collection of automatically created search results. These results are used by the global site search and will be updated automatically as documents in the CMS are created or updated.',\n enableRichTextRelationship: false,\n useAsTitle: 'title',\n ...(pluginConfig?.searchOverrides?.admin || {}),\n },\n endpoints: [\n ...(pluginConfig?.searchOverrides?.endpoints || []),\n {\n handler: generateReindexHandler(pluginConfig),\n method: 'post',\n path: '/reindex',\n },\n ],\n fields:\n pluginConfig?.searchOverrides?.fields &&\n typeof pluginConfig?.searchOverrides?.fields === 'function'\n ? pluginConfig?.searchOverrides.fields({ defaultFields })\n : defaultFields,\n labels: {\n ...(pluginConfig?.searchOverrides?.labels || {\n plural: 'Search Results',\n singular: 'Search Result',\n }),\n },\n }\n\n return newConfig\n}\n"],"names":["generateReindexHandler","generateSearchCollection","pluginConfig","apiBasePath","searchSlug","searchOverrides","slug","searchCollections","collections","collectionLabels","labels","defaultFields","name","type","admin","readOnly","localized","localize","position","index","maxDepth","relationTo","required","components","Field","path","newConfig","access","create","read","views","list","actions","serverProps","defaultColumns","description","enableRichTextRelationship","useAsTitle","endpoints","handler","method","fields","plural","singular"],"mappings":"AAIA,SAASA,sBAAsB,QAAQ,yCAAwC;AAE/E,+CAA+C;AAC/C,OAAO,MAAMC,2BAA2B,CACtCC;IAEA,MAAMC,cAAcD,cAAcC,eAAe;IACjD,MAAMC,aAAaF,cAAcG,iBAAiBC,QAAQ;IAC1D,MAAMC,oBAAoBL,cAAcM,eAAe,EAAE;IACzD,MAAMC,mBAAmBP,cAAcQ;IAEvC,MAAMC,gBAAyB;QAC7B;YACEC,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLC,UAAU;YACZ;YACAC,WAAWd,aAAae,QAAQ;QAClC;QACA;YACEL,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLI,UAAU;YACZ;QACF;QACA;YACEN,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLI,UAAU;gBACVH,UAAU;YACZ;YACAI,OAAO;YACPC,UAAU;YACVC,YAAYd;YACZe,UAAU;QACZ;QACA;YACEV,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLS,YAAY;oBACVC,OAAO;wBACLC,MAAM;oBACR;gBACF;gBACAP,UAAU;YACZ;QACF;KACD;IAED,MAAMQ,YAA8B;QAClC,GAAIxB,cAAcG,mBAAmB,CAAC,CAAC;QACvCC,MAAMF;QACNuB,QAAQ;YACNC,QAAQ,IAAe;YACvBC,MAAM,IAAe;YACrB,GAAI3B,cAAcG,iBAAiBsB,UAAU,CAAC,CAAC;QACjD;QACAb,OAAO;YACLS,YAAY;gBACVO,OAAO;oBACLC,MAAM;wBACJC,SAAS;4BACP;gCACEP,MAAM;gCACNQ,aAAa;oCACX9B;oCACAM;oCACAF;oCACAH;gCACF;4BACF;yBACD;oBACH;gBACF;YACF;YACA8B,gBAAgB;gBAAC;aAAQ;YACzBC,aACE;YACFC,4BAA4B;YAC5BC,YAAY;YACZ,GAAInC,cAAcG,iBAAiBS,SAAS,CAAC,CAAC;QAChD;QACAwB,WAAW;eACLpC,cAAcG,iBAAiBiC,aAAa,EAAE;YAClD;gBACEC,SAASvC,uBAAuBE;gBAChCsC,QAAQ;gBACRf,MAAM;YACR;SACD;QACDgB,QACEvC,cAAcG,iBAAiBoC,UAC/B,OAAOvC,cAAcG,iBAAiBoC,WAAW,aAC7CvC,cAAcG,gBAAgBoC,OAAO;YAAE9B;QAAc,KACrDA;QACND,QAAQ;YACN,GAAIR,cAAcG,iBAAiBK,UAAU;gBAC3CgC,QAAQ;gBACRC,UAAU;YACZ,CAAC;QACH;IACF;IAEA,OAAOjB;AACT,EAAC"}
1
+ {"version":3,"sources":["../../src/Search/index.ts"],"sourcesContent":["import type { CollectionConfig, Field } from 'payload'\n\nimport type { SearchPluginConfigWithLocales } from '../types.js'\n\nimport { generateReindexHandler } from '../utilities/generateReindexHandler.js'\n\n// all settings can be overridden by the config\nexport const generateSearchCollection = (\n pluginConfig: SearchPluginConfigWithLocales,\n): CollectionConfig => {\n const searchSlug = pluginConfig?.searchOverrides?.slug || 'search'\n const searchCollections = pluginConfig?.collections || []\n const collectionLabels = pluginConfig?.labels\n\n const defaultFields: Field[] = [\n {\n name: 'title',\n type: 'text',\n admin: {\n readOnly: true,\n },\n localized: pluginConfig.localize,\n },\n {\n name: 'priority',\n type: 'number',\n admin: {\n position: 'sidebar',\n },\n },\n {\n name: 'doc',\n type: 'relationship',\n admin: {\n position: 'sidebar',\n readOnly: true,\n },\n index: true,\n maxDepth: 0,\n relationTo: searchCollections,\n required: true,\n },\n {\n name: 'docUrl',\n type: 'ui',\n admin: {\n components: {\n Field: {\n path: '@payloadcms/plugin-search/client#LinkToDoc',\n },\n },\n position: 'sidebar',\n },\n },\n ]\n\n const newConfig: CollectionConfig = {\n ...(pluginConfig?.searchOverrides || {}),\n slug: searchSlug,\n access: {\n create: (): boolean => false,\n read: (): boolean => true,\n ...(pluginConfig?.searchOverrides?.access || {}),\n },\n admin: {\n components: {\n views: {\n list: {\n actions: [\n {\n path: '@payloadcms/plugin-search/client#ReindexButton',\n serverProps: {\n collectionLabels,\n searchCollections,\n searchSlug,\n },\n },\n ],\n },\n },\n },\n defaultColumns: ['title'],\n description:\n 'This is a collection of automatically created search results. These results are used by the global site search and will be updated automatically as documents in the CMS are created or updated.',\n enableRichTextRelationship: false,\n useAsTitle: 'title',\n ...(pluginConfig?.searchOverrides?.admin || {}),\n },\n endpoints: [\n ...(pluginConfig?.searchOverrides?.endpoints || []),\n {\n handler: generateReindexHandler(pluginConfig),\n method: 'post',\n path: '/reindex',\n },\n ],\n fields:\n pluginConfig?.searchOverrides?.fields &&\n typeof pluginConfig?.searchOverrides?.fields === 'function'\n ? pluginConfig?.searchOverrides.fields({ defaultFields })\n : defaultFields,\n labels: {\n ...(pluginConfig?.searchOverrides?.labels || {\n plural: 'Search Results',\n singular: 'Search Result',\n }),\n },\n }\n\n return newConfig\n}\n"],"names":["generateReindexHandler","generateSearchCollection","pluginConfig","searchSlug","searchOverrides","slug","searchCollections","collections","collectionLabels","labels","defaultFields","name","type","admin","readOnly","localized","localize","position","index","maxDepth","relationTo","required","components","Field","path","newConfig","access","create","read","views","list","actions","serverProps","defaultColumns","description","enableRichTextRelationship","useAsTitle","endpoints","handler","method","fields","plural","singular"],"mappings":"AAIA,SAASA,sBAAsB,QAAQ,yCAAwC;AAE/E,+CAA+C;AAC/C,OAAO,MAAMC,2BAA2B,CACtCC;IAEA,MAAMC,aAAaD,cAAcE,iBAAiBC,QAAQ;IAC1D,MAAMC,oBAAoBJ,cAAcK,eAAe,EAAE;IACzD,MAAMC,mBAAmBN,cAAcO;IAEvC,MAAMC,gBAAyB;QAC7B;YACEC,MAA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C"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.client.d.ts","sourceRoot":"","sources":["../../../../src/Search/ui/ReindexButton/index.client.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAyC,MAAM,OAAO,CAAA;AAE7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAOpD,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAsI5D,CAAA"}
1
+ {"version":3,"file":"index.client.d.ts","sourceRoot":"","sources":["../../../../src/Search/ui/ReindexButton/index.client.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAyC,MAAM,OAAO,CAAA;AAE7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAOpD,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA0I5D,CAAA"}
@@ -1,13 +1,14 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { LoadingOverlay, Popup, PopupList, toast, useLocale, useModal, useTranslation } from '@payloadcms/ui';
3
+ import { LoadingOverlay, Popup, PopupList, toast, useConfig, useLocale, useModal, useTranslation } from '@payloadcms/ui';
4
4
  import { useRouter } from 'next/navigation.js';
5
5
  import React, { useCallback, useMemo, useState } from 'react';
6
6
  import { ReindexButtonLabel } from './ReindexButtonLabel/index.js';
7
7
  import { ReindexConfirmModal } from './ReindexConfirmModal/index.js';
8
8
  const confirmReindexModalSlug = 'confirm-reindex-modal';
9
- export const ReindexButtonClient = ({ apiBasePath, collectionLabels, searchCollections, searchSlug })=>{
9
+ export const ReindexButtonClient = ({ collectionLabels, searchCollections, searchSlug })=>{
10
10
  const { closeModal, openModal } = useModal();
11
+ const { config } = useConfig();
11
12
  const { i18n: { t } } = useTranslation();
12
13
  const locale = useLocale();
13
14
  const router = useRouter();
@@ -25,9 +26,8 @@ export const ReindexButtonClient = ({ apiBasePath, collectionLabels, searchColle
25
26
  }
26
27
  closeConfirmModal();
27
28
  setLoading(true);
28
- const basePath = apiBasePath.endsWith('/') ? apiBasePath.slice(0, -1) : apiBasePath;
29
29
  try {
30
- const endpointRes = await fetch(`${basePath}/${searchSlug}/reindex?locale=${locale.code}`, {
30
+ const endpointRes = await fetch(`${config.routes.api}/${searchSlug}/reindex?locale=${locale.code}`, {
31
31
  body: JSON.stringify({
32
32
  collections: reindexCollections
33
33
  }),
@@ -40,7 +40,7 @@ export const ReindexButtonClient = ({ apiBasePath, collectionLabels, searchColle
40
40
  toast.success(message);
41
41
  router.refresh();
42
42
  }
43
- } catch (err) {
43
+ } catch (_err) {
44
44
  // swallow error, toast shown above
45
45
  } finally{
46
46
  setReindexCollections([]);
@@ -53,7 +53,7 @@ export const ReindexButtonClient = ({ apiBasePath, collectionLabels, searchColle
53
53
  router,
54
54
  searchSlug,
55
55
  locale,
56
- apiBasePath
56
+ config
57
57
  ]);
58
58
  const handleShowConfirmModal = useCallback((collections = searchCollections)=>{
59
59
  setReindexCollections(typeof collections === 'string' ? [
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/Search/ui/ReindexButton/index.client.tsx"],"sourcesContent":["'use client'\n\nimport {\n LoadingOverlay,\n Popup,\n PopupList,\n toast,\n useLocale,\n useModal,\n useTranslation,\n} from '@payloadcms/ui'\nimport { useRouter } from 'next/navigation.js'\nimport React, { useCallback, useMemo, useState } from 'react'\n\nimport type { ReindexButtonProps } from './types.js'\n\nimport { ReindexButtonLabel } from './ReindexButtonLabel/index.js'\nimport { ReindexConfirmModal } from './ReindexConfirmModal/index.js'\n\nconst confirmReindexModalSlug = 'confirm-reindex-modal'\n\nexport const ReindexButtonClient: React.FC<ReindexButtonProps> = ({\n apiBasePath,\n collectionLabels,\n searchCollections,\n searchSlug,\n}) => {\n const { closeModal, openModal } = useModal()\n const {\n i18n: { t },\n } = useTranslation()\n const locale = useLocale()\n const router = useRouter()\n\n const [reindexCollections, setReindexCollections] = useState<string[]>([])\n const [isLoading, setLoading] = useState<boolean>(false)\n\n const openConfirmModal = useCallback(() => openModal(confirmReindexModalSlug), [openModal])\n const closeConfirmModal = useCallback(() => closeModal(confirmReindexModalSlug), [closeModal])\n\n const handleReindexSubmit = useCallback(async () => {\n if (isLoading || !reindexCollections.length) {\n return\n }\n\n closeConfirmModal()\n setLoading(true)\n\n const basePath = apiBasePath.endsWith('/') ? apiBasePath.slice(0, -1) : apiBasePath\n\n try {\n const endpointRes = await fetch(`${basePath}/${searchSlug}/reindex?locale=${locale.code}`, {\n body: JSON.stringify({\n collections: reindexCollections,\n }),\n method: 'POST',\n })\n\n const { message } = (await endpointRes.json()) as { message: string }\n\n if (!endpointRes.ok) {\n toast.error(message)\n } else {\n toast.success(message)\n router.refresh()\n }\n } catch (err: unknown) {\n // swallow error, toast shown above\n } finally {\n setReindexCollections([])\n setLoading(false)\n }\n }, [closeConfirmModal, isLoading, reindexCollections, router, searchSlug, locale, apiBasePath])\n\n const handleShowConfirmModal = useCallback(\n (collections: string | string[] = searchCollections) => {\n setReindexCollections(typeof collections === 'string' ? [collections] : collections)\n openConfirmModal()\n },\n [openConfirmModal, searchCollections],\n )\n\n const handlePopupButtonClick = useCallback(\n (closePopup: () => void, slug?: string) => {\n closePopup()\n handleShowConfirmModal(slug)\n },\n [handleShowConfirmModal],\n )\n\n const getPluralizedLabel = useCallback(\n (slug: string) => {\n const label = collectionLabels[slug]\n if (typeof label === 'string') {\n return label\n } else {\n return Object.hasOwn(label, locale.code) ? label[locale.code] : slug\n }\n },\n [collectionLabels, locale.code],\n )\n\n const pluralizedLabels = useMemo(() => {\n return searchCollections.reduce<Record<string, string>>((acc, slug) => {\n acc[slug] = getPluralizedLabel(slug)\n return acc\n }, {})\n }, [searchCollections, getPluralizedLabel])\n\n const selectedAll = reindexCollections.length === searchCollections.length\n const selectedLabels = reindexCollections.map((slug) => pluralizedLabels[slug]).join(', ')\n\n const modalTitle = selectedAll\n ? t('general:confirmReindexAll')\n : t('general:confirmReindex', { collections: selectedLabels })\n const modalDescription = selectedAll\n ? t('general:confirmReindexDescriptionAll')\n : t('general:confirmReindexDescription', { collections: selectedLabels })\n const loadingText = selectedAll\n ? t('general:reindexingAll', { collections: t('general:collections') })\n : t('general:reindexingAll', { collections: selectedLabels })\n\n return (\n <div>\n <Popup\n button={<ReindexButtonLabel />}\n render={({ close }) => (\n <PopupList.ButtonGroup>\n {searchCollections.map((collectionSlug) => (\n <PopupList.Button\n key={collectionSlug}\n onClick={() => handlePopupButtonClick(close, collectionSlug)}\n >\n {pluralizedLabels[collectionSlug]}\n </PopupList.Button>\n ))}\n <PopupList.Button onClick={() => handlePopupButtonClick(close)}>\n {t('general:allCollections')}\n </PopupList.Button>\n </PopupList.ButtonGroup>\n )}\n showScrollbar\n size=\"large\"\n verticalAlign=\"bottom\"\n />\n <ReindexConfirmModal\n description={modalDescription}\n onCancel={closeConfirmModal}\n onConfirm={handleReindexSubmit}\n slug={confirmReindexModalSlug}\n title={modalTitle}\n />\n {isLoading && <LoadingOverlay loadingText={loadingText} />}\n </div>\n )\n}\n"],"names":["LoadingOverlay","Popup","PopupList","toast","useLocale","useModal","useTranslation","useRouter","React","useCallback","useMemo","useState","ReindexButtonLabel","ReindexConfirmModal","confirmReindexModalSlug","ReindexButtonClient","apiBasePath","collectionLabels","searchCollections","searchSlug","closeModal","openModal","i18n","t","locale","router","reindexCollections","setReindexCollections","isLoading","setLoading","openConfirmModal","closeConfirmModal","handleReindexSubmit","length","basePath","endsWith","slice","endpointRes","fetch","code","body","JSON","stringify","collections","method","message","json","ok","error","success","refresh","err","handleShowConfirmModal","handlePopupButtonClick","closePopup","slug","getPluralizedLabel","label","Object","hasOwn","pluralizedLabels","reduce","acc","selectedAll","selectedLabels","map","join","modalTitle","modalDescription","loadingText","div","button","render","close","ButtonGroup","collectionSlug","Button","onClick","showScrollbar","size","verticalAlign","description","onCancel","onConfirm","title"],"mappings":"AAAA;;AAEA,SACEA,cAAc,EACdC,KAAK,EACLC,SAAS,EACT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B,aAAaqB;IAAe;IAC9D,MAAMI,mBAAmBL,cACrBxC,EAAE,0CACFA,EAAE,qCAAqC;QAAEoB,aAAaqB;IAAe;IACzE,MAAMK,cAAcN,cAChBxC,EAAE,yBAAyB;QAAEoB,aAAapB,EAAE;IAAuB,KACnEA,EAAE,yBAAyB;QAAEoB,aAAaqB;IAAe;IAE7D,qBACE,MAACM;;0BACC,KAACrE;gBACCsE,sBAAQ,KAAC3D;gBACT4D,QAAQ,CAAC,EAAEC,KAAK,EAAE,iBAChB,MAACvE,UAAUwE,WAAW;;4BACnBxD,kBAAkB+C,GAAG,CAAC,CAACU,+BACtB,KAACzE,UAAU0E,MAAM;oCAEfC,SAAS,IAAMxB,uBAAuBoB,OAAOE;8CAE5Cf,gBAAgB,CAACe,eAAe;mCAH5BA;0CAMT,KAACzE,UAAU0E,MAAM;gCAACC,SAAS,IAAMxB,uBAAuBoB;0CACrDlD,EAAE;;;;gBAITuD,aAAa;gBACbC,MAAK;gBACLC,eAAc;;0BAEhB,KAACnE;gBACCoE,aAAab;gBACbc,UAAUnD;gBACVoD,WAAWnD;gBACXuB,MAAMzC;gBACNsE,OAAOjB;;YAERvC,2BAAa,KAAC5B;gBAAeqE,aAAaA;;;;AAGjD,EAAC"}
1
+ {"version":3,"sources":["../../../../src/Search/ui/ReindexButton/index.client.tsx"],"sourcesContent":["'use client'\n\nimport {\n LoadingOverlay,\n Popup,\n PopupList,\n toast,\n useConfig,\n useLocale,\n useModal,\n useTranslation,\n} from '@payloadcms/ui'\nimport { useRouter } from 'next/navigation.js'\nimport React, { useCallback, useMemo, useState } from 'react'\n\nimport type { ReindexButtonProps } from './types.js'\n\nimport { ReindexButtonLabel } from './ReindexButtonLabel/index.js'\nimport { ReindexConfirmModal } from './ReindexConfirmModal/index.js'\n\nconst confirmReindexModalSlug = 'confirm-reindex-modal'\n\nexport const ReindexButtonClient: React.FC<ReindexButtonProps> = ({\n collectionLabels,\n searchCollections,\n searchSlug,\n}) => {\n const { closeModal, openModal } = useModal()\n\n const { config } = useConfig()\n\n const {\n i18n: { t },\n } = useTranslation()\n\n const locale = useLocale()\n const router = useRouter()\n\n const [reindexCollections, setReindexCollections] = useState<string[]>([])\n const [isLoading, setLoading] = useState<boolean>(false)\n\n const openConfirmModal = useCallback(() => openModal(confirmReindexModalSlug), [openModal])\n const closeConfirmModal = useCallback(() => closeModal(confirmReindexModalSlug), [closeModal])\n\n const handleReindexSubmit = useCallback(async () => {\n if (isLoading || !reindexCollections.length) {\n return\n }\n\n closeConfirmModal()\n setLoading(true)\n\n try {\n const endpointRes = await fetch(\n `${config.routes.api}/${searchSlug}/reindex?locale=${locale.code}`,\n {\n body: JSON.stringify({\n collections: reindexCollections,\n }),\n method: 'POST',\n },\n )\n\n const { message } = (await endpointRes.json()) as { message: string }\n\n if (!endpointRes.ok) {\n toast.error(message)\n } else {\n toast.success(message)\n router.refresh()\n }\n } catch (_err: unknown) {\n // swallow error, toast shown above\n } finally {\n setReindexCollections([])\n setLoading(false)\n }\n }, [closeConfirmModal, isLoading, reindexCollections, router, searchSlug, locale, config])\n\n const handleShowConfirmModal = useCallback(\n (collections: string | string[] = searchCollections) => {\n setReindexCollections(typeof collections === 'string' ? [collections] : collections)\n openConfirmModal()\n },\n [openConfirmModal, searchCollections],\n )\n\n const handlePopupButtonClick = useCallback(\n (closePopup: () => void, slug?: string) => {\n closePopup()\n handleShowConfirmModal(slug)\n },\n [handleShowConfirmModal],\n )\n\n const getPluralizedLabel = useCallback(\n (slug: string) => {\n const label = collectionLabels[slug]\n if (typeof label === 'string') {\n return label\n } else {\n return Object.hasOwn(label, locale.code) ? label[locale.code] : slug\n }\n },\n [collectionLabels, locale.code],\n )\n\n const pluralizedLabels = useMemo(() => {\n return searchCollections.reduce<Record<string, string>>((acc, slug) => {\n acc[slug] = getPluralizedLabel(slug)\n return acc\n }, {})\n }, [searchCollections, getPluralizedLabel])\n\n const selectedAll = reindexCollections.length === searchCollections.length\n const selectedLabels = reindexCollections.map((slug) => pluralizedLabels[slug]).join(', ')\n\n const modalTitle = selectedAll\n ? t('general:confirmReindexAll')\n : t('general:confirmReindex', { collections: selectedLabels })\n const modalDescription = selectedAll\n ? t('general:confirmReindexDescriptionAll')\n : t('general:confirmReindexDescription', { collections: selectedLabels })\n const loadingText = selectedAll\n ? t('general:reindexingAll', { collections: t('general:collections') })\n : t('general:reindexingAll', { collections: selectedLabels })\n\n return (\n <div>\n <Popup\n button={<ReindexButtonLabel />}\n render={({ close }) => (\n <PopupList.ButtonGroup>\n {searchCollections.map((collectionSlug) => (\n <PopupList.Button\n key={collectionSlug}\n onClick={() => handlePopupButtonClick(close, collectionSlug)}\n >\n {pluralizedLabels[collectionSlug]}\n </PopupList.Button>\n ))}\n <PopupList.Button onClick={() => handlePopupButtonClick(close)}>\n {t('general:allCollections')}\n </PopupList.Button>\n </PopupList.ButtonGroup>\n )}\n showScrollbar\n size=\"large\"\n verticalAlign=\"bottom\"\n />\n <ReindexConfirmModal\n description={modalDescription}\n onCancel={closeConfirmModal}\n onConfirm={handleReindexSubmit}\n slug={confirmReindexModalSlug}\n title={modalTitle}\n />\n {isLoading && <LoadingOverlay loadingText={loadingText} />}\n </div>\n )\n}\n"],"names":["LoadingOverlay","Popup","PopupList","toast","useConfig","useLocale","useModal","useTranslation","useRouter","React","useCallback","useMemo","useState","ReindexButtonLabel","ReindexConfirmModal","confirmReindexModalSlug","ReindexButtonClient","collectionLabels","searchCollections","searchSlug","closeModal","openModal","config","i18n","t","locale","router","reindexCollections","setReindexCollections","isLoading","setLoading","openConfirmModal","closeConfirmModal","handleReindexSubmit","length","endpointRes","fetch","routes","api","code","body","JSON","stringify","collections","method","message","json","ok","error","success","refresh","_err","handleShowConfirmModal","handlePopupButtonClick","closePopup","slug","getPluralizedLabel","label","Object","hasOwn","pluralizedLabels","reduce","acc","selectedAll","selectedLabels","map","join","modalTitle","modalDescription","loadingText","div","button","render","close","ButtonGroup","collectionSlug","Button","onClick","showScrollbar","size","verticalAlign","description","onCancel","onCon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,cACfvC,EAAE,+BACFA,EAAE,0BAA0B;QAAEmB,aAAaqB;IAAe;IAC9D,MAAMI,mBAAmBL,cACrBvC,EAAE,0CACFA,EAAE,qCAAqC;QAAEmB,aAAaqB;IAAe;IACzE,MAAMK,cAAcN,cAChBvC,EAAE,yBAAyB;QAAEmB,aAAanB,EAAE;IAAuB,KACnEA,EAAE,yBAAyB;QAAEmB,aAAaqB;IAAe;IAE7D,qBACE,MAACM;;0BACC,KAACrE;gBACCsE,sBAAQ,KAAC1D;gBACT2D,QAAQ,CAAC,EAAEC,KAAK,EAAE,iBAChB,MAACvE,UAAUwE,WAAW;;4BACnBxD,kBAAkB+C,GAAG,CAAC,CAACU,+BACtB,KAACzE,UAAU0E,MAAM;oCAEfC,SAAS,IAAMxB,uBAAuBoB,OAAOE;8CAE5Cf,gBAAgB,CAACe,eAAe;mCAH5BA;0CAMT,KAACzE,UAAU0E,MAAM;gCAACC,SAAS,IAAMxB,uBAAuBoB;0CACrDjD,EAAE;;;;gBAITsD,aAAa;gBACbC,MAAK;gBACLC,eAAc;;0BAEhB,KAAClE;gBACCmE,aAAab;gBACbc,UAAUlD;gBACVmD,WAAWlD;gBACXsB,MAAMxC;gBACNqE,OAAOjB;;YAERtC,2BAAa,KAAC7B;gBAAeqE,aAAaA;;;;AAGjD,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Search/ui/ReindexButton/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,YAAY,CAAA;AAIpE,eAAO,MAAM,aAAa,EAAE,kCA8B3B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Search/ui/ReindexButton/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,YAAY,CAAA;AAIpE,eAAO,MAAM,aAAa,EAAE,kCA6B3B,CAAA"}
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { ReindexButtonClient } from './index.client.js';
3
3
  export const ReindexButton = (props)=>{
4
- const { apiBasePath, collectionLabels, i18n, searchCollections, searchSlug } = props;
4
+ const { collectionLabels, i18n, searchCollections, searchSlug } = props;
5
5
  const getStaticLocalizedPluralLabels = ()=>{
6
6
  return Object.fromEntries(searchCollections.map((collection)=>{
7
7
  const labels = collectionLabels[collection];
@@ -27,7 +27,6 @@ export const ReindexButton = (props)=>{
27
27
  }));
28
28
  };
29
29
  return /*#__PURE__*/ _jsx(ReindexButtonClient, {
30
- apiBasePath: apiBasePath,
31
30
  collectionLabels: getStaticLocalizedPluralLabels(),
32
31
  searchCollections: searchCollections,
33
32
  searchSlug: searchSlug
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/Search/ui/ReindexButton/index.tsx"],"sourcesContent":["import type { SearchReindexButtonServerComponent } from './types.js'\n\nimport { ReindexButtonClient } from './index.client.js'\n\nexport const ReindexButton: SearchReindexButtonServerComponent = (props) => {\n const { apiBasePath, collectionLabels, i18n, searchCollections, searchSlug } = props\n\n const getStaticLocalizedPluralLabels = () => {\n return Object.fromEntries(\n searchCollections.map((collection) => {\n const labels = collectionLabels[collection]\n const pluralLabel = labels?.plural\n\n if (typeof pluralLabel === 'function') {\n return [collection, pluralLabel({ t: i18n.t })]\n }\n\n if (pluralLabel) {\n return [collection, pluralLabel]\n }\n\n return [collection, collection]\n }),\n )\n }\n\n return (\n <ReindexButtonClient\n apiBasePath={apiBasePath}\n collectionLabels={getStaticLocalizedPluralLabels()}\n searchCollections={searchCollections}\n searchSlug={searchSlug}\n />\n )\n}\n"],"names":["ReindexButtonClient","ReindexButton","props","apiBasePath","collectionLabels","i18n","searchCollections","searchSlug","getStaticLocalizedPluralLabels","Object","fromEntries","map","collection","labels","pluralLabel","plural","t"],"mappings":";AAEA,SAASA,mBAAmB,QAAQ,oBAAmB;AAEvD,OAAO,MAAMC,gBAAoD,CAACC;IAChE,MAAM,EAAEC,WAAW,EAAEC,gBAAgB,EAAEC,IAAI,EAAEC,iBAAiB,EAAEC,UAAU,EAAE,GAAGL;IAE/E,MAAMM,iCAAiC;QACrC,OAAOC,OAAOC,WAAW,CACvBJ,kBAAkBK,GAAG,CAAC,CAACC;YACrB,MAAMC,SAAST,gBAAgB,CAACQ,WAAW;YAC3C,MAAME,cAAcD,QAAQE;YAE5B,IAAI,OAAOD,gBAAgB,YAAY;gBACrC,OAAO;oBAACF;oBAAYE,YAAY;wBAAEE,GAAGX,KAAKW,CAAC;oBAAC;iBAAG;YACjD;YAEA,IAAIF,aAAa;gBACf,OAAO;oBAACF;oBAAYE;iBAAY;YAClC;YAEA,OAAO;gBAACF;gBAAYA;aAAW;QACjC;IAEJ;IAEA,qBACE,KAACZ;QACCG,aAAaA;QACbC,kBAAkBI;QAClBF,mBAAmBA;QACnBC,YAAYA;;AAGlB,EAAC"}
1
+ {"version":3,"sources":["../../../../src/Search/ui/ReindexButton/index.tsx"],"sourcesContent":["import type { SearchReindexButtonServerComponent } from './types.js'\n\nimport { ReindexButtonClient } from './index.client.js'\n\nexport const ReindexButton: SearchReindexButtonServerComponent = (props) => {\n const { collectionLabels, i18n, searchCollections, searchSlug } = props\n\n const getStaticLocalizedPluralLabels = () => {\n return Object.fromEntries(\n searchCollections.map((collection) => {\n const labels = collectionLabels[collection]\n const pluralLabel = labels?.plural\n\n if (typeof pluralLabel === 'function') {\n return [collection, pluralLabel({ t: i18n.t })]\n }\n\n if (pluralLabel) {\n return [collection, pluralLabel]\n }\n\n return [collection, collection]\n }),\n )\n }\n\n return (\n <ReindexButtonClient\n collectionLabels={getStaticLocalizedPluralLabels()}\n searchCollections={searchCollections}\n searchSlug={searchSlug}\n />\n )\n}\n"],"names":["ReindexButtonClient","ReindexButton","props","collectionLabels","i18n","searchCollections","searchSlug","getStaticLocalizedPluralLabels","Object","fromEntries","map","collection","labels","pluralLabel","plural","t"],"mappings":";AAEA,SAASA,mBAAmB,QAAQ,oBAAmB;AAEvD,OAAO,MAAMC,gBAAoD,CAACC;IAChE,MAAM,EAAEC,gBAAgB,EAAEC,IAAI,EAAEC,iBAAiB,EAAEC,UAAU,EAAE,GAAGJ;IAElE,MAAMK,iCAAiC;QACrC,OAAOC,OAAOC,WAAW,CACvBJ,kBAAkBK,GAAG,CAAC,CAACC;YACrB,MAAMC,SAAST,gBAAgB,CAACQ,WAAW;YAC3C,MAAME,cAAcD,QAAQE;YAE5B,IAAI,OAAOD,gBAAgB,YAAY;gBACrC,OAAO;oBAACF;oBAAYE,YAAY;wBAAEE,GAAGX,KAAKW,CAAC;oBAAC;iBAAG;YACjD;YAEA,IAAIF,aAAa;gBACf,OAAO;oBAACF;oBAAYE;iBAAY;YAClC;YAEA,OAAO;gBAACF;gBAAYA;aAAW;QACjC;IAEJ;IAEA,qBACE,KAACX;QACCG,kBAAkBI;QAClBF,mBAAmBA;QACnBC,YAAYA;;AAGlB,EAAC"}
@@ -1,7 +1,6 @@
1
1
  import type { CustomComponent, PayloadServerReactComponent, StaticLabel } from 'payload';
2
2
  import type { CollectionLabels } from '../../../types.js';
3
3
  export type ReindexButtonProps = {
4
- apiBasePath: string;
5
4
  collectionLabels: Record<string, StaticLabel>;
6
5
  searchCollections: string[];
7
6
  searchSlug: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/Search/ui/ReindexButton/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,2BAA2B,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAExF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAEzD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,WAAW,EAAE,MAAM,CAAA;IACnB,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;IAC7C,iBAAiB,EAAE,MAAM,EAAE,CAAA;IAC3B,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,KAAK,wBAAwB,GAAG;IAC9B,gBAAgB,EAAE,gBAAgB,CAAA;CACnC,GAAG,kBAAkB,CAAA;AAEtB,MAAM,MAAM,kCAAkC,GAAG,kBAAkB,CAAA;AACnE,MAAM,MAAM,kCAAkC,GAAG,2BAA2B,CAC1E,eAAe,CAAC,wBAAwB,CAAC,CAC1C,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/Search/ui/ReindexButton/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,2BAA2B,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAExF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAEzD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;IAC7C,iBAAiB,EAAE,MAAM,EAAE,CAAA;IAC3B,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,KAAK,wBAAwB,GAAG;IAC9B,gBAAgB,EAAE,gBAAgB,CAAA;CACnC,GAAG,kBAAkB,CAAA;AAEtB,MAAM,MAAM,kCAAkC,GAAG,kBAAkB,CAAA;AACnE,MAAM,MAAM,kCAAkC,GAAG,2BAA2B,CAC1E,eAAe,CAAC,wBAAwB,CAAC,CAC1C,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/Search/ui/ReindexButton/types.ts"],"sourcesContent":["import type { CustomComponent, PayloadServerReactComponent, StaticLabel } from 'payload'\n\nimport type { CollectionLabels } from '../../../types.js'\n\nexport type ReindexButtonProps = {\n apiBasePath: string\n collectionLabels: Record<string, StaticLabel>\n searchCollections: string[]\n searchSlug: string\n}\n\ntype ReindexButtonServerProps = {\n collectionLabels: CollectionLabels\n} & ReindexButtonProps\n\nexport type SearchReindexButtonClientComponent = ReindexButtonProps\nexport type SearchReindexButtonServerComponent = PayloadServerReactComponent<\n CustomComponent<ReindexButtonServerProps>\n>\n"],"names":[],"mappings":"AAgBA,WAEC"}
1
+ {"version":3,"sources":["../../../../src/Search/ui/ReindexButton/types.ts"],"sourcesContent":["import type { CustomComponent, PayloadServerReactComponent, StaticLabel } from 'payload'\n\nimport type { CollectionLabels } from '../../../types.js'\n\nexport type ReindexButtonProps = {\n collectionLabels: Record<string, StaticLabel>\n searchCollections: string[]\n searchSlug: string\n}\n\ntype ReindexButtonServerProps = {\n collectionLabels: CollectionLabels\n} & ReindexButtonProps\n\nexport type SearchReindexButtonClientComponent = ReindexButtonProps\nexport type SearchReindexButtonServerComponent = PayloadServerReactComponent<\n CustomComponent<ReindexButtonServerProps>\n>\n"],"names":[],"mappings":"AAeA,WAEC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAwD,MAAM,EAAE,MAAM,SAAS,CAAA;AAE3F,OAAO,KAAK,EAAE,kBAAkB,EAAiC,MAAM,YAAY,CAAA;AASnF,eAAO,MAAM,YAAY,yBACA,kBAAkB,cAChC,MAAM,KAAG,MAoFjB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAwD,MAAM,EAAE,MAAM,SAAS,CAAA;AAE3F,OAAO,KAAK,EAAE,kBAAkB,EAAiC,MAAM,YAAY,CAAA;AASnF,eAAO,MAAM,YAAY,yBACA,kBAAkB,cAChC,MAAM,KAAG,MAmFjB,CAAA"}
package/dist/index.js CHANGED
@@ -15,7 +15,6 @@ export const searchPlugin = (incomingPluginConfig)=>(config)=>{
15
15
  ]));
16
16
  const pluginConfig = {
17
17
  // write any config defaults here
18
- apiBasePath: config.routes?.api,
19
18
  deleteDrafts: true,
20
19
  labels,
21
20
  locales,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { CollectionAfterChangeHook, CollectionAfterDeleteHook, Config } from 'payload'\n\nimport type { SearchPluginConfig, SearchPluginConfigWithLocales } from './types.js'\n\nimport { deleteFromSearch } from './Search/hooks/deleteFromSearch.js'\nimport { syncWithSearch } from './Search/hooks/syncWithSearch.js'\nimport { generateSearchCollection } from './Search/index.js'\n\ntype CollectionAfterChangeHookArgs = Parameters<CollectionAfterChangeHook>[0]\ntype CollectionAfterDeleteHookArgs = Parameters<CollectionAfterDeleteHook>[0]\n\nexport const searchPlugin =\n (incomingPluginConfig: SearchPluginConfig) =>\n (config: Config): Config => {\n const { collections } = config\n\n // If the user defines `localize` to either true or false, use that\n // Otherwise, set it based on if their config has localization enabled or disabled\n const shouldLocalize =\n typeof incomingPluginConfig.localize === 'boolean'\n ? incomingPluginConfig.localize\n : Boolean(config.localization)\n incomingPluginConfig.localize = shouldLocalize\n\n if (collections) {\n const locales = config.localization\n ? config.localization.locales.map((localeConfig) =>\n typeof localeConfig === 'string' ? localeConfig : localeConfig.code,\n )\n : []\n\n const labels = Object.fromEntries(\n collections\n .filter(({ slug }) => incomingPluginConfig.collections?.includes(slug))\n .map((collection) => [collection.slug, collection.labels]),\n )\n\n const pluginConfig: SearchPluginConfigWithLocales = {\n // write any config defaults here\n apiBasePath: config.routes?.api,\n deleteDrafts: true,\n labels,\n locales,\n reindexBatchSize: incomingPluginConfig?.reindexBatchSize || 50,\n syncDrafts: false,\n ...incomingPluginConfig,\n }\n\n // add afterChange and afterDelete hooks to every search-enabled collection\n const collectionsWithSearchHooks = config?.collections\n ?.map((collection) => {\n const { hooks: existingHooks } = collection\n\n const enabledCollections = pluginConfig.collections || []\n const isEnabled = enabledCollections.indexOf(collection.slug) > -1\n if (isEnabled) {\n return {\n ...collection,\n hooks: {\n ...collection.hooks,\n afterChange: [\n ...(existingHooks?.afterChange || []),\n async (args: CollectionAfterChangeHookArgs) => {\n await syncWithSearch({\n ...args,\n collection: collection.slug,\n pluginConfig,\n })\n },\n ],\n afterDelete: [\n ...(existingHooks?.afterDelete || []),\n async (args: CollectionAfterDeleteHookArgs) => {\n await deleteFromSearch({\n ...args,\n pluginConfig,\n })\n },\n ],\n },\n }\n }\n\n return collection\n })\n .filter(Boolean)\n\n return {\n ...config,\n collections: [\n ...(collectionsWithSearchHooks || []),\n generateSearchCollection(pluginConfig),\n ],\n }\n }\n\n return config\n }\n"],"names":["deleteFromSearch","syncWithSearch","generateSearchCollection","searchPlugin","incomingPluginConfig","config","collections","shouldLocalize","localize","Boolean","localization","locales","map","localeConfig","code","labels","Object","fromEntries","filter","slug","includes","collection","pluginConfig","apiBasePath","routes","api","deleteDrafts","reindexBatchSize","syncDrafts","collectionsWithSearchHooks","hooks","existingHooks","enabledCollections","isEnabled","indexOf","afterChange","args","afterDelete"],"mappings":"AAIA,SAASA,gBAAgB,QAAQ,qCAAoC;AACrE,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,wBAAwB,QAAQ,oBAAmB;AAK5D,OAAO,MAAMC,eACX,CAACC,uBACD,CAACC;QACC,MAAM,EAAEC,WAAW,EAAE,GAAGD;QAExB,mEAAmE;QACnE,kFAAkF;QAClF,MAAME,iBACJ,OAAOH,qBAAqBI,QAAQ,KAAK,YACrCJ,qBAAqBI,QAAQ,GAC7BC,QAAQJ,OAAOK,YAAY;QACjCN,qBAAqBI,QAAQ,GAAGD;QAEhC,IAAID,aAAa;YACf,MAAMK,UAAUN,OAAOK,YAAY,GAC/BL,OAAOK,YAAY,CAACC,OAAO,CAACC,GAAG,CAAC,CAACC,eAC/B,OAAOA,iBAAiB,WAAWA,eAAeA,aAAaC,IAAI,IAErE,EAAE;YAEN,MAAMC,SAASC,OAAOC,WAAW,CAC/BX,YACGY,MAAM,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKf,qBAAqBE,WAAW,EAAEc,SAASD,OAChEP,GAAG,CAAC,CAACS,aAAe;oBAACA,WAAWF,IAAI;oBAAEE,WAAWN,MAAM;iBAAC;YAG7D,MAAMO,eAA8C;gBAClD,iCAAiC;gBACjCC,aAAalB,OAAOmB,MAAM,EAAEC;gBAC5BC,cAAc;gBACdX;gBACAJ;gBACAgB,kBAAkBvB,sBAAsBuB,oBAAoB;gBAC5DC,YAAY;gBACZ,GAAGxB,oBAAoB;YACzB;YAEA,2EAA2E;YAC3E,MAAMyB,6BAA6BxB,QAAQC,aACvCM,IAAI,CAACS;gBACL,MAAM,EAAES,OAAOC,aAAa,EAAE,GAAGV;gBAEjC,MAAMW,qBAAqBV,aAAahB,WAAW,IAAI,EAAE;gBACzD,MAAM2B,YAAYD,mBAAmBE,OAAO,CAACb,WAAWF,IAAI,IAAI,CAAC;gBACjE,IAAIc,WAAW;oBACb,OAAO;wBACL,GAAGZ,UAAU;wBACbS,OAAO;4BACL,GAAGT,WAAWS,KAAK;4BACnBK,aAAa;mCACPJ,eAAeI,eAAe,EAAE;gCACpC,OAAOC;oCACL,MAAMnC,eAAe;wCACnB,GAAGmC,IAAI;wCACPf,YAAYA,WAAWF,IAAI;wCAC3BG;oCACF;gCACF;6BACD;4BACDe,aAAa;mCACPN,eAAeM,eAAe,EAAE;gCACpC,OAAOD;oCACL,MAAMpC,iBAAiB;wCACrB,GAAGoC,IAAI;wCACPd;oCACF;gCACF;6BACD;wBACH;oBACF;gBACF;gBAEA,OAAOD;YACT,GACCH,OAAOT;YAEV,OAAO;gBACL,GAAGJ,MAAM;gBACTC,aAAa;uBACPuB,8BAA8B,EAAE;oBACpC3B,yBAAyBoB;iBAC1B;YACH;QACF;QAEA,OAAOjB;IACT,EAAC"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { CollectionAfterChangeHook, CollectionAfterDeleteHook, Config } from 'payload'\n\nimport type { SearchPluginConfig, SearchPluginConfigWithLocales } from './types.js'\n\nimport { deleteFromSearch } from './Search/hooks/deleteFromSearch.js'\nimport { syncWithSearch } from './Search/hooks/syncWithSearch.js'\nimport { generateSearchCollection } from './Search/index.js'\n\ntype CollectionAfterChangeHookArgs = Parameters<CollectionAfterChangeHook>[0]\ntype CollectionAfterDeleteHookArgs = Parameters<CollectionAfterDeleteHook>[0]\n\nexport const searchPlugin =\n (incomingPluginConfig: SearchPluginConfig) =>\n (config: Config): Config => {\n const { collections } = config\n\n // If the user defines `localize` to either true or false, use that\n // Otherwise, set it based on if their config has localization enabled or disabled\n const shouldLocalize =\n typeof incomingPluginConfig.localize === 'boolean'\n ? incomingPluginConfig.localize\n : Boolean(config.localization)\n incomingPluginConfig.localize = shouldLocalize\n\n if (collections) {\n const locales = config.localization\n ? config.localization.locales.map((localeConfig) =>\n typeof localeConfig === 'string' ? localeConfig : localeConfig.code,\n )\n : []\n\n const labels = Object.fromEntries(\n collections\n .filter(({ slug }) => incomingPluginConfig.collections?.includes(slug))\n .map((collection) => [collection.slug, collection.labels]),\n )\n\n const pluginConfig: SearchPluginConfigWithLocales = {\n // write any config defaults here\n deleteDrafts: true,\n labels,\n locales,\n reindexBatchSize: incomingPluginConfig?.reindexBatchSize || 50,\n syncDrafts: false,\n ...incomingPluginConfig,\n }\n\n // add afterChange and afterDelete hooks to every search-enabled collection\n const collectionsWithSearchHooks = config?.collections\n ?.map((collection) => {\n const { hooks: existingHooks } = collection\n\n const enabledCollections = pluginConfig.collections || []\n const isEnabled = enabledCollections.indexOf(collection.slug) > -1\n if (isEnabled) {\n return {\n ...collection,\n hooks: {\n ...collection.hooks,\n afterChange: [\n ...(existingHooks?.afterChange || []),\n async (args: CollectionAfterChangeHookArgs) => {\n await syncWithSearch({\n ...args,\n collection: collection.slug,\n pluginConfig,\n })\n },\n ],\n afterDelete: [\n ...(existingHooks?.afterDelete || []),\n async (args: CollectionAfterDeleteHookArgs) => {\n await deleteFromSearch({\n ...args,\n pluginConfig,\n })\n },\n ],\n },\n }\n }\n\n return collection\n })\n .filter(Boolean)\n\n return {\n ...config,\n collections: [\n ...(collectionsWithSearchHooks || []),\n generateSearchCollection(pluginConfig),\n ],\n }\n }\n\n return config\n }\n"],"names":["deleteFromSearch","syncWithSearch","generateSearchCollection","searchPlugin","incomingPluginConfig","config","collections","shouldLocalize","localize","Boolean","localization","locales","map","localeConfig","code","labels","Object","fromEntries","filter","slug","includes","collection","pluginConfig","deleteDrafts","reindexBatchSize","syncDrafts","collectionsWithSearchHooks","hooks","existingHooks","enabledCollections","isEnabled","indexOf","afterChange","args","afterDelete"],"mappings":"AAIA,SAASA,gBAAgB,QAAQ,qCAAoC;AACrE,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,wBAAwB,QAAQ,oBAAmB;AAK5D,OAAO,MAAMC,eACX,CAACC,uBACD,CAACC;QACC,MAAM,EAAEC,WAAW,EAAE,GAAGD;QAExB,mEAAmE;QACnE,kFAAkF;QAClF,MAAME,iBACJ,OAAOH,qBAAqBI,QAAQ,KAAK,YACrCJ,qBAAqBI,QAAQ,GAC7BC,QAAQJ,OAAOK,YAAY;QACjCN,qBAAqBI,QAAQ,GAAGD;QAEhC,IAAID,aAAa;YACf,MAAMK,UAAUN,OAAOK,YAAY,GAC/BL,OAAOK,YAAY,CAACC,OAAO,CAACC,GAAG,CAAC,CAACC,eAC/B,OAAOA,iBAAiB,WAAWA,eAAeA,aAAaC,IAAI,IAErE,EAAE;YAEN,MAAMC,SAASC,OAAOC,WAAW,CAC/BX,YACGY,MAAM,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKf,qBAAqBE,WAAW,EAAEc,SAASD,OAChEP,GAAG,CAAC,CAACS,aAAe;oBAACA,WAAWF,IAAI;oBAAEE,WAAWN,MAAM;iBAAC;YAG7D,MAAMO,eAA8C;gBAClD,iCAAiC;gBACjCC,cAAc;gBACdR;gBACAJ;gBACAa,kBAAkBpB,sBAAsBoB,oBAAoB;gBAC5DC,YAAY;gBACZ,GAAGrB,oBAAoB;YACzB;YAEA,2EAA2E;YAC3E,MAAMsB,6BAA6BrB,QAAQC,aACvCM,IAAI,CAACS;gBACL,MAAM,EAAEM,OAAOC,aAAa,EAAE,GAAGP;gBAEjC,MAAMQ,qBAAqBP,aAAahB,WAAW,IAAI,EAAE;gBACzD,MAAMwB,YAAYD,mBAAmBE,OAAO,CAACV,WAAWF,IAAI,IAAI,CAAC;gBACjE,IAAIW,WAAW;oBACb,OAAO;wBACL,GAAGT,UAAU;wBACbM,OAAO;4BACL,GAAGN,WAAWM,KAAK;4BACnBK,aAAa;mCACPJ,eAAeI,eAAe,EAAE;gCACpC,OAAOC;oCACL,MAAMhC,eAAe;wCACnB,GAAGgC,IAAI;wCACPZ,YAAYA,WAAWF,IAAI;wCAC3BG;oCACF;gCACF;6BACD;4BACDY,aAAa;mCACPN,eAAeM,eAAe,EAAE;gCACpC,OAAOD;oCACL,MAAMjC,iBAAiB;wCACrB,GAAGiC,IAAI;wCACPX;oCACF;gCACF;6BACD;wBACH;oBACF;gBACF;gBAEA,OAAOD;YACT,GACCH,OAAOT;YAEV,OAAO;gBACL,GAAGJ,MAAM;gBACTC,aAAa;uBACPoB,8BAA8B,EAAE;oBACpCxB,yBAAyBoB;iBAC1B;YACH;QACF;QAEA,OAAOjB;IACT,EAAC"}
package/dist/types.d.ts CHANGED
@@ -19,6 +19,12 @@ export type FieldsOverride = (args: {
19
19
  defaultFields: Field[];
20
20
  }) => Field[];
21
21
  export type SearchPluginConfig = {
22
+ /**
23
+ * @deprecated
24
+ * This plugin gets the api route from the config directly and does not need to be passed in.
25
+ * As long as you have `routes.api` set in your Payload config, the plugin will use that.
26
+ * This property will be removed in the next major version.
27
+ */
22
28
  apiBasePath?: string;
23
29
  beforeSync?: BeforeSync;
24
30
  collections?: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,yBAAyB,EACzB,gBAAgB,EAChB,KAAK,EACL,aAAa,EAEb,OAAO,EACP,cAAc,EACd,WAAW,EACZ,MAAM,SAAS,CAAA;AAEhB,MAAM,MAAM,SAAS,GAAG;IACtB,CAAC,GAAG,EAAE,MAAM,G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G,WAAW,CAAA;KACvC,CAAA;CACF,CAAA;AAED,MAAM,MAAM,6BAA6B,GAAG;IAC1C,MAAM,CAAC,EAAE,gBAAgB,CAAA;IACzB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACnB,GAAG,kBAAkB,CAAA;AAEtB,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,kBAAkB,CAAA;CACjC,GAAG,IAAI,CAAC,UAAU,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAA;AAEhE,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,IAAI,CAAA;CACzB,GAAG,IAAI,CAAC,kBAAkB,EAAE,SAAS,GAAG,aAAa,CAAC,CAAA;AAIvD,MAAM,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,kBAAkB,KAAK,UAAU,CAAC,yBAAyB,CAAC,CAAA;AAEhG,MAAM,MAAM,gBAAgB,GAAG,CAC7B,IAAI,EAAE;IACJ,YAAY,EAAE,kBAAkB,CAAA;CACjC,GAAG,UAAU,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,KACzC,UAAU,CAAC,yBAAyB,CAAC,CAAA"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n CollectionAfterChangeHook,\n CollectionAfterDeleteHook,\n CollectionConfig,\n Field,\n LabelFunction,\n Locale,\n Payload,\n PayloadRequest,\n StaticLabel,\n} from 'payload'\n\nexport type DocToSync = {\n [key: string]: any\n doc: {\n relationTo: string\n value: string\n }\n title: string\n}\n\nexport type BeforeSync = (args: {\n originalDoc: {\n [key: string]: any\n }\n payload: Payload\n req: PayloadRequest\n searchDoc: DocToSync\n}) => DocToSync | Promise<DocToSync>\n\nexport type FieldsOverride = (args: { defaultFields: Field[] }) => Field[]\n\nexport type SearchPluginConfig = {\n apiBasePath?: string\n beforeSync?: BeforeSync\n collections?: string[]\n defaultPriorities?: {\n [collection: string]: ((doc: any) => number | Promise<number>) | number\n }\n deleteDrafts?: boolean\n localize?: boolean\n reindexBatchSize?: number\n searchOverrides?: { fields?: FieldsOverride } & Partial<Omit<CollectionConfig, 'fields'>>\n syncDrafts?: boolean\n}\n\nexport type CollectionLabels = {\n [collection: string]: {\n plural?: LabelFunction | StaticLabel\n singular?: LabelFunction | StaticLabel\n }\n}\n\nexport type SearchPluginConfigWithLocales = {\n labels?: CollectionLabels\n locales?: string[]\n} & SearchPluginConfig\n\nexport type SyncWithSearchArgs = {\n collection: string\n pluginConfig: SearchPluginConfig\n} & Omit<Parameters<CollectionAfterChangeHook>[0], 'collection'>\n\nexport type SyncDocArgs = {\n locale?: string\n onSyncError?: () => void\n} & Omit<SyncWithSearchArgs, 'context' | 'previousDoc'>\n\n// Extend the `CollectionAfterChangeHook` with more function args\n// Convert the `collection` arg from `SanitizedCollectionConfig` to a string\nexport type SyncWithSearch = (Args: SyncWithSearchArgs) => ReturnType<CollectionAfterChangeHook>\n\nexport type DeleteFromSearch = (\n Args: {\n pluginConfig: SearchPluginConfig\n } & Parameters<CollectionAfterDeleteHook>[0],\n) => ReturnType<CollectionAfterDeleteHook>\n"],"names":[],"mappings":"AAwEA,WAI0C"}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n CollectionAfterChangeHook,\n CollectionAfterDeleteHook,\n CollectionConfig,\n Field,\n LabelFunction,\n Locale,\n Payload,\n PayloadRequest,\n StaticLabel,\n} from 'payload'\n\nexport type DocToSync = {\n [key: string]: any\n doc: {\n relationTo: string\n value: string\n }\n title: string\n}\n\nexport type BeforeSync = (args: {\n originalDoc: {\n [key: string]: any\n }\n payload: Payload\n req: PayloadRequest\n searchDoc: DocToSync\n}) => DocToSync | Promise<DocToSync>\n\nexport type FieldsOverride = (args: { defaultFields: Field[] }) => Field[]\n\nexport type SearchPluginConfig = {\n /**\n * @deprecated\n * This plugin gets the api route from the config directly and does not need to be passed in.\n * As long as you have `routes.api` set in your Payload config, the plugin will use that.\n * This property will be removed in the next major version.\n */\n apiBasePath?: string\n beforeSync?: BeforeSync\n collections?: string[]\n defaultPriorities?: {\n [collection: string]: ((doc: any) => number | Promise<number>) | number\n }\n deleteDrafts?: boolean\n localize?: boolean\n reindexBatchSize?: number\n searchOverrides?: { fields?: FieldsOverride } & Partial<Omit<CollectionConfig, 'fields'>>\n syncDrafts?: boolean\n}\n\nexport type CollectionLabels = {\n [collection: string]: {\n plural?: LabelFunction | StaticLabel\n singular?: LabelFunction | StaticLabel\n }\n}\n\nexport type SearchPluginConfigWithLocales = {\n labels?: CollectionLabels\n locales?: string[]\n} & SearchPluginConfig\n\nexport type SyncWithSearchArgs = {\n collection: string\n pluginConfig: SearchPluginConfig\n} & Omit<Parameters<CollectionAfterChangeHook>[0], 'collection'>\n\nexport type SyncDocArgs = {\n locale?: string\n onSyncError?: () => void\n} & Omit<SyncWithSearchArgs, 'context' | 'previousDoc'>\n\n// Extend the `CollectionAfterChangeHook` with more function args\n// Convert the `collection` arg from `SanitizedCollectionConfig` to a string\nexport type SyncWithSearch = (Args: SyncWithSearchArgs) => ReturnType<CollectionAfterChangeHook>\n\nexport type DeleteFromSearch = (\n Args: {\n pluginConfig: SearchPluginConfig\n } & Parameters<CollectionAfterDeleteHook>[0],\n) => ReturnType<CollectionAfterDeleteHook>\n"],"names":[],"mappings":"AA8EA,WAI0C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/plugin-search",
3
- "version": "3.20.0",
3
+ "version": "3.21.0-canary.0a1cc6a",
4
4
  "description": "Search plugin for Payload",
5
5
  "keywords": [
6
6
  "payload",
@@ -49,19 +49,19 @@
49
49
  "dist"
50
50
  ],
51
51
  "dependencies": {
52
- "@payloadcms/next": "3.20.0",
53
- "@payloadcms/ui": "3.20.0"
52
+ "@payloadcms/next": "3.21.0-canary.0a1cc6a",
53
+ "@payloadcms/ui": "3.21.0-canary.0a1cc6a"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@types/react": "19.0.1",
57
57
  "@types/react-dom": "19.0.1",
58
58
  "@payloadcms/eslint-config": "3.9.0",
59
- "payload": "3.20.0"
59
+ "payload": "3.21.0-canary.0a1cc6a"
60
60
  },
61
61
  "peerDependencies": {
62
62
  "react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
63
63
  "react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
64
- "payload": "3.20.0"
64
+ "payload": "3.21.0-canary.0a1cc6a"
65
65
  },
66
66
  "publishConfig": {
67
67
  "registry": "https://registry.npmjs.org/"