@payloadcms/plugin-search 4.0.0-internal.38b7f1d → 4.0.0-internal.40de3ec
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/Search/index.d.ts.map +1 -1
- package/dist/Search/index.js +2 -1
- package/dist/Search/index.js.map +1 -1
- package/dist/Search/ui/LinkToDoc/index.client.js +2 -3
- package/dist/Search/ui/LinkToDoc/index.client.js.map +1 -1
- package/dist/Search/ui/ReindexButton/ReindexButtonLabel/index.js +6 -6
- package/dist/Search/ui/ReindexButton/ReindexButtonLabel/index.js.map +1 -1
- package/dist/Search/ui/ReindexButton/index.client.js +1 -2
- package/dist/Search/ui/ReindexButton/index.client.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -6
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +0 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utilities/generateReindexHandler.d.ts.map +1 -1
- package/dist/utilities/syncDocAsSearchIndex.d.ts.map +1 -1
- package/package.json +5 -5
|
@@ -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,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAM9D,eAAO,MAAM,wBAAwB,
|
|
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,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAM9D,eAAO,MAAM,wBAAwB,GACnC,cAAc,2BAA2B,KACxC,gBA0GF,CAAA"}
|
package/dist/Search/index.js
CHANGED
package/dist/Search/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Search/index.ts"],"sourcesContent":["import type { CollectionConfig, Field } from 'payload'\n\nimport type { SanitizedSearchPluginConfig } from '../types.js'\nimport type { ReindexButtonServerProps } from './ui/ReindexButton/types.js'\n\nimport { generateReindexHandler } from '../utilities/generateReindexHandler.js'\n\n// all settings can be overridden by the config\nexport const generateSearchCollection = (\n pluginConfig: SanitizedSearchPluginConfig,\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 if (!collectionLabels) {\n throw new Error('collectionLabels is required')\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 } satisfies ReindexButtonServerProps,\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","Error","newConfig","access","create","read","views","list","actions","serverProps","defaultColumns","description","enableRichTextRelationship","useAsTitle","endpoints","handler","method","fields","plural","singular"],"mappings":"AAKA,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,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLC,UAAU;YACZ;YACAC,WAAWb,aAAac,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,IAAI,CAACT,kBAAkB;QACrB,MAAM,IAAIiB,MAAM;IAClB;IAEA,MAAMC,YAA8B;QAClC,GAAIxB,cAAcE,mBAAmB,CAAC,CAAC;QACvCC,MAAMF;QACNwB,QAAQ;YACNC,QAAQ,IAAe;YACvBC,MAAM,IAAe;YACrB,GAAI3B,cAAcE,iBAAiBuB,UAAU,CAAC,CAAC;QACjD;QACAd,OAAO;YACLS,YAAY;gBACVQ,OAAO;oBACLC,MAAM;wBACJC,SAAS;4BACP;gCACER,MAAM;gCACNS,aAAa;oCACXzB;oCACAF;oCACAH;gCACF;4BACF;yBACD;oBACH;gBACF;YACF;YACA+B,gBAAgB;gBAAC;aAAQ;YACzBC,aACE;YACFC,4BAA4B;YAC5BC,YAAY;YACZ,GAAInC,cAAcE,iBAAiBS,SAAS,CAAC,CAAC;QAChD;QACAyB,WAAW;eACLpC,cAAcE,iBAAiBkC,aAAa,EAAE;YAClD;gBACEC,SAASvC,uBAAuBE;gBAChCsC,QAAQ;gBACRhB,MAAM;YACR;SACD;QACDiB,QACEvC,cAAcE,iBAAiBqC,UAC/B,OAAOvC,cAAcE,iBAAiBqC,WAAW,aAC7CvC,cAAcE,gBAAgBqC,OAAO;YAAE/B;QAAc,KACrDA;QACND,QAAQ;YACN,GAAIP,cAAcE,iBAAiBK,UAAU;gBAC3CiC,QAAQ;gBACRC,UAAU;YACZ,CAAC;QACH;
|
|
1
|
+
{"version":3,"sources":["../../src/Search/index.ts"],"sourcesContent":["import type { CollectionConfig, Field } from 'payload'\n\nimport type { SanitizedSearchPluginConfig } from '../types.js'\nimport type { ReindexButtonServerProps } from './ui/ReindexButton/types.js'\n\nimport { generateReindexHandler } from '../utilities/generateReindexHandler.js'\n\n// all settings can be overridden by the config\nexport const generateSearchCollection = (\n pluginConfig: SanitizedSearchPluginConfig,\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 if (!collectionLabels) {\n throw new Error('collectionLabels is required')\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 } satisfies ReindexButtonServerProps,\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 versions: pluginConfig?.searchOverrides?.versions ?? false,\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","Error","newConfig","access","create","read","views","list","actions","serverProps","defaultColumns","description","enableRichTextRelationship","useAsTitle","endpoints","handler","method","fields","plural","singular","versions"],"mappings":"AAKA,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,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLC,UAAU;YACZ;YACAC,WAAWb,aAAac,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,IAAI,CAACT,kBAAkB;QACrB,MAAM,IAAIiB,MAAM;IAClB;IAEA,MAAMC,YAA8B;QAClC,GAAIxB,cAAcE,mBAAmB,CAAC,CAAC;QACvCC,MAAMF;QACNwB,QAAQ;YACNC,QAAQ,IAAe;YACvBC,MAAM,IAAe;YACrB,GAAI3B,cAAcE,iBAAiBuB,UAAU,CAAC,CAAC;QACjD;QACAd,OAAO;YACLS,YAAY;gBACVQ,OAAO;oBACLC,MAAM;wBACJC,SAAS;4BACP;gCACER,MAAM;gCACNS,aAAa;oCACXzB;oCACAF;oCACAH;gCACF;4BACF;yBACD;oBACH;gBACF;YACF;YACA+B,gBAAgB;gBAAC;aAAQ;YACzBC,aACE;YACFC,4BAA4B;YAC5BC,YAAY;YACZ,GAAInC,cAAcE,iBAAiBS,SAAS,CAAC,CAAC;QAChD;QACAyB,WAAW;eACLpC,cAAcE,iBAAiBkC,aAAa,EAAE;YAClD;gBACEC,SAASvC,uBAAuBE;gBAChCsC,QAAQ;gBACRhB,MAAM;YACR;SACD;QACDiB,QACEvC,cAAcE,iBAAiBqC,UAC/B,OAAOvC,cAAcE,iBAAiBqC,WAAW,aAC7CvC,cAAcE,gBAAgBqC,OAAO;YAAE/B;QAAc,KACrDA;QACND,QAAQ;YACN,GAAIP,cAAcE,iBAAiBK,UAAU;gBAC3CiC,QAAQ;gBACRC,UAAU;YACZ,CAAC;QACH;QACAC,UAAU1C,cAAcE,iBAAiBwC,YAAY;IACvD;IAEA,OAAOlB;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/Search/ui/LinkToDoc/index.client.tsx"],"sourcesContent":["'use client'\n\nimport { CopyToClipboard, Link, useConfig, useField } from '@payloadcms/ui'\nimport { formatAdminURL } from 'payload/shared'\nimport React from 'react'\n\nexport const LinkToDocClient: React.FC = () => {\n const { config } = useConfig()\n\n const {\n routes: {\n admin: adminRoute, // already includes leading slash\n },\n serverURL,\n } = config\n\n const { value } = useField<{ relationTo?: string; value?: string }>({ path: 'doc' })\n\n if (!value?.relationTo || !value?.value) {\n return null\n }\n\n const href = formatAdminURL({\n adminRoute,\n path: `/collections/${value.relationTo || ''}/${value.value || ''}`,\n serverURL,\n })\n\n return (\n <div style={{ marginBottom: 'var(--spacing-field, 1rem)' }}>\n <div>\n <span\n className=\"label\"\n style={{\n color: '#9A9A9A',\n }}\n >\n Doc URL\n </span>\n <CopyToClipboard value={href} />\n </div>\n <div\n style={{\n fontWeight: '600',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n }}\n >\n <Link href={href}
|
|
1
|
+
{"version":3,"sources":["../../../../src/Search/ui/LinkToDoc/index.client.tsx"],"sourcesContent":["'use client'\n\nimport { CopyToClipboard, Link, useConfig, useField } from '@payloadcms/ui'\nimport { formatAdminURL } from 'payload/shared'\nimport React from 'react'\n\nexport const LinkToDocClient: React.FC = () => {\n const { config } = useConfig()\n\n const {\n routes: {\n admin: adminRoute, // already includes leading slash\n },\n serverURL,\n } = config\n\n const { value } = useField<{ relationTo?: string; value?: string }>({ path: 'doc' })\n\n if (!value?.relationTo || !value?.value) {\n return null\n }\n\n const href = formatAdminURL({\n adminRoute,\n path: `/collections/${value.relationTo || ''}/${value.value || ''}`,\n serverURL,\n })\n\n return (\n <div style={{ marginBottom: 'var(--spacing-field, 1rem)' }}>\n <div>\n <span\n className=\"label\"\n style={{\n color: '#9A9A9A',\n }}\n >\n Doc URL\n </span>\n <CopyToClipboard value={href} />\n </div>\n <div\n style={{\n fontWeight: '600',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n }}\n >\n <Link href={href} rel=\"noopener noreferrer\" target=\"_blank\">\n {href}\n </Link>\n </div>\n </div>\n )\n}\n"],"names":["CopyToClipboard","Link","useConfig","useField","formatAdminURL","React","LinkToDocClient","config","routes","admin","adminRoute","serverURL","value","path","relationTo","href","div","style","marginBottom","span","className","color","fontWeight","overflow","textOverflow","rel","target"],"mappings":"AAAA;;AAEA,SAASA,eAAe,EAAEC,IAAI,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,iBAAgB;AAC3E,SAASC,cAAc,QAAQ,iBAAgB;AAC/C,OAAOC,WAAW,QAAO;AAEzB,OAAO,MAAMC,kBAA4B;IACvC,MAAM,EAAEC,MAAM,EAAE,GAAGL;IAEnB,MAAM,EACJM,QAAQ,EACNC,OAAOC,UAAU,EAClB,EACDC,SAAS,EACV,GAAGJ;IAEJ,MAAM,EAAEK,KAAK,EAAE,GAAGT,SAAkD;QAAEU,MAAM;IAAM;IAElF,IAAI,CAACD,OAAOE,cAAc,CAACF,OAAOA,OAAO;QACvC,OAAO;IACT;IAEA,MAAMG,OAAOX,eAAe;QAC1BM;QACAG,MAAM,CAAC,aAAa,EAAED,MAAME,UAAU,IAAI,GAAG,CAAC,EAAEF,MAAMA,KAAK,IAAI,IAAI;QACnED;IACF;IAEA,qBACE,MAACK;QAAIC,OAAO;YAAEC,cAAc;QAA6B;;0BACvD,MAACF;;kCACC,KAACG;wBACCC,WAAU;wBACVH,OAAO;4BACLI,OAAO;wBACT;kCACD;;kCAGD,KAACrB;wBAAgBY,OAAOG;;;;0BAE1B,KAACC;gBACCC,OAAO;oBACLK,YAAY;oBACZC,UAAU;oBACVC,cAAc;gBAChB;0BAEA,cAAA,KAACvB;oBAAKc,MAAMA;oBAAMU,KAAI;oBAAsBC,QAAO;8BAChDX;;;;;AAKX,EAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { Button, useTranslation } from '@payloadcms/ui';
|
|
3
3
|
export const ReindexButtonLabel = ()=>{
|
|
4
4
|
const { i18n: { t } } = useTranslation();
|
|
5
|
-
return /*#__PURE__*/ _jsx(
|
|
6
|
-
|
|
7
|
-
icon:
|
|
8
|
-
|
|
9
|
-
size: "
|
|
5
|
+
return /*#__PURE__*/ _jsx(Button, {
|
|
6
|
+
buttonStyle: "pill",
|
|
7
|
+
icon: "chevron",
|
|
8
|
+
iconPosition: "right",
|
|
9
|
+
size: "medium",
|
|
10
10
|
children: t('general:reindex')
|
|
11
11
|
});
|
|
12
12
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/Search/ui/ReindexButton/ReindexButtonLabel/index.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../../../src/Search/ui/ReindexButton/ReindexButtonLabel/index.tsx"],"sourcesContent":["import { Button, ChevronIcon, useTranslation } from '@payloadcms/ui'\n\nexport const ReindexButtonLabel = () => {\n const {\n i18n: { t },\n } = useTranslation()\n return (\n <Button buttonStyle=\"pill\" icon=\"chevron\" iconPosition=\"right\" size=\"medium\">\n {t('general:reindex')}\n </Button>\n )\n}\n"],"names":["Button","useTranslation","ReindexButtonLabel","i18n","t","buttonStyle","icon","iconPosition","size"],"mappings":";AAAA,SAASA,MAAM,EAAeC,cAAc,QAAQ,iBAAgB;AAEpE,OAAO,MAAMC,qBAAqB;IAChC,MAAM,EACJC,MAAM,EAAEC,CAAC,EAAE,EACZ,GAAGH;IACJ,qBACE,KAACD;QAAOK,aAAY;QAAOC,MAAK;QAAUC,cAAa;QAAQC,MAAK;kBACjEJ,EAAE;;AAGT,EAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { ConfirmationModal, Popup, PopupList, toast, useConfig, useLocale, useModal, useTranslation } from '@payloadcms/ui';
|
|
4
|
-
import { useRouter } from 'next/navigation.js';
|
|
3
|
+
import { ConfirmationModal, Popup, PopupList, toast, useConfig, useLocale, useModal, useRouter, useTranslation } from '@payloadcms/ui';
|
|
5
4
|
import { formatAdminURL } from 'payload/shared';
|
|
6
5
|
import React, { useCallback, useMemo, useState } from 'react';
|
|
7
6
|
import { ReindexButtonLabel } from './ReindexButtonLabel/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/Search/ui/ReindexButton/index.client.tsx"],"sourcesContent":["'use client'\n\nimport {\n ConfirmationModal,\n Popup,\n PopupList,\n toast,\n useConfig,\n useLocale,\n useModal,\n useTranslation,\n} from '@payloadcms/ui'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/Search/ui/ReindexButton/index.client.tsx"],"sourcesContent":["'use client'\n\nimport {\n ConfirmationModal,\n Popup,\n PopupList,\n toast,\n useConfig,\n useLocale,\n useModal,\n useRouter,\n useTranslation,\n} from '@payloadcms/ui'\nimport { formatAdminURL } from 'payload/shared'\nimport React, { useCallback, useMemo, useState } from 'react'\n\nimport type { ReindexButtonProps } from './types.js'\n\nimport { ReindexButtonLabel } from './ReindexButtonLabel/index.js'\n\nconst confirmReindexModalSlug = 'confirm-reindex-modal'\n\nexport const ReindexButtonClient: React.FC<ReindexButtonProps> = ({\n collectionLabels,\n searchCollections,\n searchSlug,\n}) => {\n const { 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\n const openConfirmModal = useCallback(() => openModal(confirmReindexModalSlug), [openModal])\n\n const handleReindexSubmit = useCallback(async () => {\n if (!reindexCollections.length) {\n return\n }\n\n try {\n const res = await fetch(\n formatAdminURL({\n apiRoute: config.routes.api,\n path: `/${searchSlug}/reindex?locale=${locale.code}`,\n }),\n {\n body: JSON.stringify({\n collections: reindexCollections,\n }),\n method: 'POST',\n },\n )\n\n const { message } = (await res.json()) as { message: string }\n\n if (!res.ok) {\n toast.error(message)\n } else {\n toast.success(message)\n return router.refresh()\n }\n } catch (_err: unknown) {\n // swallow error, toast shown above\n } finally {\n setReindexCollections([])\n }\n }, [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 label && 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 const label = getPluralizedLabel(slug)\n if (label) {\n acc[slug] = label\n }\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\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 <ConfirmationModal\n body={modalDescription}\n heading={modalTitle}\n modalSlug={confirmReindexModalSlug}\n onConfirm={handleReindexSubmit}\n />\n </div>\n )\n}\n"],"names":["ConfirmationModal","Popup","PopupList","toast","useConfig","useLocale","useModal","useRouter","useTranslation","formatAdminURL","React","useCallback","useMemo","useState","ReindexButtonLabel","confirmReindexModalSlug","ReindexButtonClient","collectionLabels","searchCollections","searchSlug","openModal","config","i18n","t","locale","router","reindexCollections","setReindexCollections","openConfirmModal","handleReindexSubmit","length","res","fetch","apiRoute","routes","api","path","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","div","button","render","close","ButtonGroup","collectionSlug","Button","onClick","showScrollbar","size","verticalAlign","heading","modalSlug","onConfirm"],"mappings":"AAAA;;AAEA,SACEA,iBAAiB,EACjBC,KAAK,EACLC,SAAS,EACTC,KAAK,EACLC,SAAS,EACTC,SAAS,EACTC,QAAQ,EACRC,SAAS,EACTC,cAAc,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UqE,WAAW;;4BACnBrD,kBAAkB6C,GAAG,CAAC,CAACS,+BACtB,KAACtE,UAAUuE,MAAM;oCAEfC,SAAS,IAAMvB,uBAAuBmB,OAAOE;8CAE5Cd,gBAAgB,CAACc,eAAe;mCAH5BA;0CAMT,KAACtE,UAAUuE,MAAM;gCAACC,SAAS,IAAMvB,uBAAuBmB;0CACrD/C,EAAE;;;;gBAIToD,aAAa;gBACbC,MAAK;gBACLC,eAAc;;0BAEhB,KAAC7E;gBACCsC,MAAM4B;gBACNY,SAASb;gBACTc,WAAWhE;gBACXiE,WAAWnD;;;;AAInB,EAAC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA6B,MAAM,EAAE,MAAM,SAAS,CAAA;AAEhE,OAAO,KAAK,EAA+B,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAQjF,eAAO,MAAM,YAAY,GACtB,WAAW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA6B,MAAM,EAAE,MAAM,SAAS,CAAA;AAEhE,OAAO,KAAK,EAA+B,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAQjF,eAAO,MAAM,YAAY,GACtB,WAAW,GAAG,OAAO,EAAE,sBAAsB,kBAAkB,CAAC,WAAW,CAAC,MAC5E,QAAQ,MAAM,KAAG,MA2EjB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -8,10 +8,15 @@ export const searchPlugin = (incomingPluginConfig)=>(config)=>{
|
|
|
8
8
|
const shouldLocalize = typeof incomingPluginConfig.localize === 'boolean' ? incomingPluginConfig.localize : Boolean(config.localization);
|
|
9
9
|
incomingPluginConfig.localize = shouldLocalize;
|
|
10
10
|
if (collections) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
// O(1) slug lookup for enabled-collection checks; replaces an Array.indexOf in the
|
|
12
|
+
// hook-attachment pass that was O(M) per collection.
|
|
13
|
+
const enabledSlugSet = new Set(incomingPluginConfig.collections ?? []);
|
|
14
|
+
const labels = {};
|
|
15
|
+
for (const collection of collections){
|
|
16
|
+
if (enabledSlugSet.has(collection.slug)) {
|
|
17
|
+
labels[collection.slug] = collection.labels;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
15
20
|
const pluginConfig = {
|
|
16
21
|
// write any config defaults here
|
|
17
22
|
deleteDrafts: true,
|
|
@@ -23,8 +28,7 @@ export const searchPlugin = (incomingPluginConfig)=>(config)=>{
|
|
|
23
28
|
// add afterChange and afterDelete hooks to every search-enabled collection
|
|
24
29
|
const collectionsWithSearchHooks = config?.collections?.map((collection)=>{
|
|
25
30
|
const { hooks: existingHooks } = collection;
|
|
26
|
-
const
|
|
27
|
-
const isEnabled = enabledCollections.indexOf(collection.slug) > -1;
|
|
31
|
+
const isEnabled = enabledSlugSet.has(collection.slug);
|
|
28
32
|
if (isEnabled) {
|
|
29
33
|
return {
|
|
30
34
|
...collection,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { CollectionAfterChangeHook, Config } from 'payload'\n\nimport type { SanitizedSearchPluginConfig, SearchPluginConfig } 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]\n\nexport const searchPlugin =\n <ConfigTypes = unknown>(incomingPluginConfig: SearchPluginConfig<ConfigTypes>) =>\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
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { CollectionAfterChangeHook, Config } from 'payload'\n\nimport type { SanitizedSearchPluginConfig, SearchPluginConfig } 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]\n\nexport const searchPlugin =\n <ConfigTypes = unknown>(incomingPluginConfig: SearchPluginConfig<ConfigTypes>) =>\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 // O(1) slug lookup for enabled-collection checks; replaces an Array.indexOf in the\n // hook-attachment pass that was O(M) per collection.\n const enabledSlugSet = new Set(incomingPluginConfig.collections ?? [])\n\n const labels: Record<string, (typeof collections)[number]['labels']> = {}\n for (const collection of collections) {\n if (enabledSlugSet.has(collection.slug)) {\n labels[collection.slug] = collection.labels\n }\n }\n\n const pluginConfig: SanitizedSearchPluginConfig<ConfigTypes> = {\n // write any config defaults here\n deleteDrafts: true,\n labels,\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 isEnabled = enabledSlugSet.has(collection.slug)\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 beforeDelete: [\n ...(existingHooks?.beforeDelete || []),\n deleteFromSearch(pluginConfig),\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","enabledSlugSet","Set","labels","collection","has","slug","pluginConfig","deleteDrafts","reindexBatchSize","syncDrafts","collectionsWithSearchHooks","map","hooks","existingHooks","isEnabled","afterChange","args","beforeDelete","filter"],"mappings":"AAIA,SAASA,gBAAgB,QAAQ,qCAAoC;AACrE,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,wBAAwB,QAAQ,oBAAmB;AAI5D,OAAO,MAAMC,eACX,CAAwBC,uBACxB,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,mFAAmF;YACnF,qDAAqD;YACrD,MAAMK,iBAAiB,IAAIC,IAAIR,qBAAqBE,WAAW,IAAI,EAAE;YAErE,MAAMO,SAAiE,CAAC;YACxE,KAAK,MAAMC,cAAcR,YAAa;gBACpC,IAAIK,eAAeI,GAAG,CAACD,WAAWE,IAAI,GAAG;oBACvCH,MAAM,CAACC,WAAWE,IAAI,CAAC,GAAGF,WAAWD,MAAM;gBAC7C;YACF;YAEA,MAAMI,eAAyD;gBAC7D,iCAAiC;gBACjCC,cAAc;gBACdL;gBACAM,kBAAkBf,sBAAsBe,oBAAoB;gBAC5DC,YAAY;gBACZ,GAAGhB,oBAAoB;YACzB;YAEA,2EAA2E;YAC3E,MAAMiB,6BAA6BhB,QAAQC,aACvCgB,IAAI,CAACR;gBACL,MAAM,EAAES,OAAOC,aAAa,EAAE,GAAGV;gBAEjC,MAAMW,YAAYd,eAAeI,GAAG,CAACD,WAAWE,IAAI;gBACpD,IAAIS,WAAW;oBACb,OAAO;wBACL,GAAGX,UAAU;wBACbS,OAAO;4BACL,GAAGT,WAAWS,KAAK;4BACnBG,aAAa;mCACPF,eAAeE,eAAe,EAAE;gCACpC,OAAOC;oCACL,MAAM1B,eAAe;wCACnB,GAAG0B,IAAI;wCACPb,YAAYA,WAAWE,IAAI;wCAC3BC;oCACF;gCACF;6BACD;4BACDW,cAAc;mCACRJ,eAAeI,gBAAgB,EAAE;gCACrC5B,iBAAiBiB;6BAClB;wBACH;oBACF;gBACF;gBAEA,OAAOH;YACT,GACCe,OAAOpB;YAEV,OAAO;gBACL,GAAGJ,MAAM;gBACTC,aAAa;uBACPe,8BAA8B,EAAE;oBACpCnB,yBAAyBe;iBAC1B;YACH;QACF;QAEA,OAAOZ;IACT,EAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -28,13 +28,6 @@ export type SkipSyncFunction<ConfigTypes = unknown> = (args: {
|
|
|
28
28
|
req: PayloadRequest;
|
|
29
29
|
}) => boolean | Promise<boolean>;
|
|
30
30
|
export type SearchPluginConfig<ConfigTypes = unknown> = {
|
|
31
|
-
/**
|
|
32
|
-
* @deprecated
|
|
33
|
-
* This plugin gets the api route from the config directly and does not need to be passed in.
|
|
34
|
-
* As long as you have `routes.api` set in your Payload config, the plugin will use that.
|
|
35
|
-
* This property will be removed in the next major version.
|
|
36
|
-
*/
|
|
37
|
-
apiBasePath?: string;
|
|
38
31
|
beforeSync?: BeforeSync;
|
|
39
32
|
collections?: string[];
|
|
40
33
|
defaultPriorities?: {
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":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AAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,2BAA2B,CAAA;CAC1C,GAAG,IAAI,CAAC,UAAU,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAA;AAEhE,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;IACvB,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,CAAC,IAAI,EAAE,kBAAkB,KAAK,0BAA0B,CAAA"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n CollectionAfterChangeHook,\n CollectionBeforeDeleteHook,\n CollectionConfig,\n Field,\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 collectionSlug: string\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 SkipSyncFunction<ConfigTypes = unknown> = (args: {\n collectionSlug: string\n doc: any\n locale: ConfigTypes extends { locale: unknown } ? ConfigTypes['locale'] : string | undefined\n req: PayloadRequest\n}) => boolean | Promise<boolean>\n\nexport type SearchPluginConfig<ConfigTypes = unknown> = {\n
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n CollectionAfterChangeHook,\n CollectionBeforeDeleteHook,\n CollectionConfig,\n Field,\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 collectionSlug: string\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 SkipSyncFunction<ConfigTypes = unknown> = (args: {\n collectionSlug: string\n doc: any\n locale: ConfigTypes extends { locale: unknown } ? ConfigTypes['locale'] : string | undefined\n req: PayloadRequest\n}) => boolean | Promise<boolean>\n\nexport type SearchPluginConfig<ConfigTypes = unknown> = {\n beforeSync?: BeforeSync\n collections?: string[]\n defaultPriorities?: {\n [collection: string]: ((doc: any) => number | Promise<number>) | number\n }\n /**\n * Controls whether drafts are deleted from the search index\n *\n * @default true\n */\n deleteDrafts?: boolean\n localize?: boolean\n /**\n * We use batching when re-indexing large collections. You can control the amount of items per batch, lower numbers should help with memory.\n *\n * @default 50\n */\n reindexBatchSize?: number\n searchOverrides?: { fields?: FieldsOverride } & Partial<Omit<CollectionConfig, 'fields'>>\n /**\n * Determine whether to skip syncing a document for a specific locale.\n * Useful for multi-tenant applications, conditional indexing, or any scenario where\n * sync behavior should vary by locale, document, or other factors.\n *\n * @default undefined - All configured locales will be synced\n *\n * @example\n * // Skip syncing based on document's tenant settings\n * skipSync: async ({ locale, req, doc, collectionSlug }) => {\n * // For non-localized collections, locale will be undefined\n * if (!locale) return false\n *\n * const tenant = await req.payload.findByID({\n * collection: 'tenants',\n * id: doc.tenant.id\n * })\n * return !tenant.allowedLocales.includes(locale)\n * }\n */\n skipSync?: SkipSyncFunction<ConfigTypes>\n /**\n * Controls whether drafts are synced to the search index\n *\n * @default false\n */\n syncDrafts?: boolean\n}\n\nexport type CollectionLabels = {\n [collection: string]: CollectionConfig['labels']\n}\n\nexport type ResolvedCollectionLabels = {\n [collection: string]: StaticLabel\n}\n\nexport type SearchPluginConfigWithLocales<ConfigTypes = unknown> = {\n labels?: CollectionLabels\n} & SearchPluginConfig<ConfigTypes>\n\nexport type SanitizedSearchPluginConfig<ConfigTypes = unknown> = {\n reindexBatchSize: number\n syncDrafts: boolean\n} & SearchPluginConfigWithLocales<ConfigTypes>\n\nexport type SyncWithSearchArgs = {\n collection: string\n pluginConfig: SanitizedSearchPluginConfig\n} & Omit<Parameters<CollectionAfterChangeHook>[0], 'collection'>\n\nexport type SyncDocArgs = {\n locale?: Locale['code']\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 = (args: SearchPluginConfig) => CollectionBeforeDeleteHook\n"],"names":[],"mappings":"AAuHA,WAAuF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateReindexHandler.d.ts","sourceRoot":"","sources":["../../src/utilities/generateReindexHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAS,MAAM,SAAS,CAAA;AAWpD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAS9D,eAAO,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"generateReindexHandler.d.ts","sourceRoot":"","sources":["../../src/utilities/generateReindexHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAS,MAAM,SAAS,CAAA;AAWpD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAS9D,eAAO,MAAM,sBAAsB,GAChC,cAAc,2BAA2B,KAAG,cAwN5C,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syncDocAsSearchIndex.d.ts","sourceRoot":"","sources":["../../src/utilities/syncDocAsSearchIndex.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzD,eAAO,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"syncDocAsSearchIndex.d.ts","sourceRoot":"","sources":["../../src/utilities/syncDocAsSearchIndex.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzD,eAAO,MAAM,oBAAoB,GAAU,2FASxC,WAAW,iBAgRb,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/plugin-search",
|
|
3
|
-
"version": "4.0.0-internal.
|
|
3
|
+
"version": "4.0.0-internal.40de3ec",
|
|
4
4
|
"description": "Search plugin for Payload",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"payload",
|
|
@@ -50,19 +50,19 @@
|
|
|
50
50
|
"dist"
|
|
51
51
|
],
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@payloadcms/
|
|
54
|
-
"@payloadcms/
|
|
53
|
+
"@payloadcms/next": "4.0.0-internal.40de3ec",
|
|
54
|
+
"@payloadcms/ui": "4.0.0-internal.40de3ec"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/react": "19.2.14",
|
|
58
58
|
"@types/react-dom": "19.2.3",
|
|
59
59
|
"@payloadcms/eslint-config": "3.28.0",
|
|
60
|
-
"payload": "4.0.0-internal.
|
|
60
|
+
"payload": "4.0.0-internal.40de3ec"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"react": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
64
64
|
"react-dom": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
65
|
-
"payload": "4.0.0-internal.
|
|
65
|
+
"payload": "4.0.0-internal.40de3ec"
|
|
66
66
|
},
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"registry": "https://registry.npmjs.org/"
|