@payloadcms/plugin-search 4.0.0-internal.2fddfc0 → 4.0.0-internal.31ba7ee
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/LICENSE.md +1 -1
- package/dist/Search/hooks/deleteFromSearch.d.ts.map +1 -1
- package/dist/Search/hooks/deleteFromSearch.js +1 -0
- package/dist/Search/hooks/deleteFromSearch.js.map +1 -1
- package/dist/Search/index.d.ts.map +1 -1
- package/dist/Search/index.js +2 -0
- package/dist/Search/index.js.map +1 -1
- package/dist/Search/ui/LinkToDoc/index.client.d.ts +1 -0
- package/dist/Search/ui/LinkToDoc/index.client.d.ts.map +1 -1
- package/dist/Search/ui/LinkToDoc/index.client.js +9 -15
- package/dist/Search/ui/LinkToDoc/index.client.js.map +1 -1
- package/dist/Search/ui/LinkToDoc/index.css +26 -0
- package/dist/Search/ui/ReindexButton/ReindexButtonLabel/index.d.ts +12 -1
- package/dist/Search/ui/ReindexButton/ReindexButtonLabel/index.d.ts.map +1 -1
- package/dist/Search/ui/ReindexButton/ReindexButtonLabel/index.js +14 -4
- package/dist/Search/ui/ReindexButton/ReindexButtonLabel/index.js.map +1 -1
- package/dist/Search/ui/ReindexButton/index.client.d.ts.map +1 -1
- package/dist/Search/ui/ReindexButton/index.client.js +9 -5
- package/dist/Search/ui/ReindexButton/index.client.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +9 -11
- 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/dist/utilities/syncDocAsSearchIndex.js +9 -0
- package/dist/utilities/syncDocAsSearchIndex.js.map +1 -1
- package/package.json +6 -6
package/LICENSE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2018-
|
|
3
|
+
Copyright (c) 2018-2026 Payload CMS, LLC <info@payloadcms.com>
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
6
|
a copy of this software and associated documentation files (the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deleteFromSearch.d.ts","sourceRoot":"","sources":["../../../src/Search/hooks/deleteFromSearch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAEtD,eAAO,MAAM,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"deleteFromSearch.d.ts","sourceRoot":"","sources":["../../../src/Search/hooks/deleteFromSearch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAEtD,eAAO,MAAM,gBAAgB,EAAE,gBA0B5B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/Search/hooks/deleteFromSearch.ts"],"sourcesContent":["import type { DeleteFromSearch } from '../../types.js'\n\nexport const deleteFromSearch: DeleteFromSearch =\n (pluginConfig) =>\n async ({ id, collection, req: { payload }, req }) => {\n const searchSlug = pluginConfig?.searchOverrides?.slug || 'search'\n\n try {\n await payload.delete({\n collection: searchSlug,\n depth: 0,\n req,\n where: {\n 'doc.relationTo': {\n equals: collection.slug,\n },\n 'doc.value': {\n equals: id,\n },\n },\n })\n } catch (err: unknown) {\n payload.logger.error({\n err,\n msg: `Error deleting ${searchSlug} doc.`,\n })\n }\n }\n"],"names":["deleteFromSearch","pluginConfig","id","collection","req","payload","searchSlug","searchOverrides","slug","delete","depth","where","equals","err","logger","error","msg"],"mappings":"AAEA,OAAO,MAAMA,mBACX,CAACC,eACD,OAAO,EAAEC,EAAE,EAAEC,UAAU,EAAEC,KAAK,EAAEC,OAAO,EAAE,EAAED,GAAG,EAAE;QAC9C,MAAME,aAAaL,cAAcM,iBAAiBC,QAAQ;QAE1D,IAAI;YACF,MAAMH,QAAQI,MAAM,CAAC;gBACnBN,YAAYG;gBACZI,OAAO;
|
|
1
|
+
{"version":3,"sources":["../../../src/Search/hooks/deleteFromSearch.ts"],"sourcesContent":["import type { DeleteFromSearch } from '../../types.js'\n\nexport const deleteFromSearch: DeleteFromSearch =\n (pluginConfig) =>\n async ({ id, collection, req: { payload }, req }) => {\n const searchSlug = pluginConfig?.searchOverrides?.slug || 'search'\n\n try {\n await payload.delete({\n collection: searchSlug,\n depth: 0,\n overrideAccess: true,\n req,\n where: {\n 'doc.relationTo': {\n equals: collection.slug,\n },\n 'doc.value': {\n equals: id,\n },\n },\n })\n } catch (err: unknown) {\n payload.logger.error({\n err,\n msg: `Error deleting ${searchSlug} doc.`,\n })\n }\n }\n"],"names":["deleteFromSearch","pluginConfig","id","collection","req","payload","searchSlug","searchOverrides","slug","delete","depth","overrideAccess","where","equals","err","logger","error","msg"],"mappings":"AAEA,OAAO,MAAMA,mBACX,CAACC,eACD,OAAO,EAAEC,EAAE,EAAEC,UAAU,EAAEC,KAAK,EAAEC,OAAO,EAAE,EAAED,GAAG,EAAE;QAC9C,MAAME,aAAaL,cAAcM,iBAAiBC,QAAQ;QAE1D,IAAI;YACF,MAAMH,QAAQI,MAAM,CAAC;gBACnBN,YAAYG;gBACZI,OAAO;gBACPC,gBAAgB;gBAChBP;gBACAQ,OAAO;oBACL,kBAAkB;wBAChBC,QAAQV,WAAWK,IAAI;oBACzB;oBACA,aAAa;wBACXK,QAAQX;oBACV;gBACF;YACF;QACF,EAAE,OAAOY,KAAc;YACrBT,QAAQU,MAAM,CAACC,KAAK,CAAC;gBACnBF;gBACAG,KAAK,CAAC,eAAe,EAAEX,WAAW,KAAK,CAAC;YAC1C;QACF;IACF,EAAC"}
|
|
@@ -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,iBACrB,2BAA2B,KACxC,gBA4GF,CAAA"}
|
package/dist/Search/index.js
CHANGED
|
@@ -98,6 +98,8 @@ export const generateSearchCollection = (pluginConfig)=>{
|
|
|
98
98
|
singular: 'Search Result'
|
|
99
99
|
}
|
|
100
100
|
},
|
|
101
|
+
// Internal search index; opt out of authorship (a searchOverride can re-enable it).
|
|
102
|
+
authorship: pluginConfig?.searchOverrides?.authorship ?? false,
|
|
101
103
|
versions: pluginConfig?.searchOverrides?.versions ?? false
|
|
102
104
|
};
|
|
103
105
|
return newConfig;
|
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 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;
|
|
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 // Internal search index; opt out of authorship (a searchOverride can re-enable it).\n authorship: pluginConfig?.searchOverrides?.authorship ?? false,\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","authorship","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,MAA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YACZ,CAAC;QACH;QACA,oFAAoF;QACpFC,YAAY1C,cAAcE,iBAAiBwC,cAAc;QACzDC,UAAU3C,cAAcE,iBAAiByC,YAAY;IACvD;IAEA,OAAOnB;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.client.d.ts","sourceRoot":"","sources":["../../../../src/Search/ui/LinkToDoc/index.client.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"index.client.d.ts","sourceRoot":"","sources":["../../../../src/Search/ui/LinkToDoc/index.client.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,aAAa,CAAA;AAIpB,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAmCnC,CAAA"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { CopyToClipboard, Link, useConfig, useField } from '@payloadcms/ui';
|
|
3
|
+
import { CopyToClipboard, FieldLabel, Link, useConfig, useField } from '@payloadcms/ui';
|
|
4
4
|
import { formatAdminURL } from 'payload/shared';
|
|
5
5
|
import React from 'react';
|
|
6
|
+
import './index.css';
|
|
7
|
+
const baseClass = 'link-to-doc';
|
|
6
8
|
export const LinkToDocClient = ()=>{
|
|
7
9
|
const { config } = useConfig();
|
|
8
10
|
const { routes: { admin: adminRoute }, serverURL } = config;
|
|
@@ -18,18 +20,14 @@ export const LinkToDocClient = ()=>{
|
|
|
18
20
|
serverURL
|
|
19
21
|
});
|
|
20
22
|
return /*#__PURE__*/ _jsxs("div", {
|
|
21
|
-
|
|
22
|
-
marginBottom: 'var(--spacing-field, 1rem)'
|
|
23
|
-
},
|
|
23
|
+
className: baseClass,
|
|
24
24
|
children: [
|
|
25
25
|
/*#__PURE__*/ _jsxs("div", {
|
|
26
|
+
className: `${baseClass}__header`,
|
|
26
27
|
children: [
|
|
27
|
-
/*#__PURE__*/ _jsx(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
color: '#9A9A9A'
|
|
31
|
-
},
|
|
32
|
-
children: "Doc URL"
|
|
28
|
+
/*#__PURE__*/ _jsx(FieldLabel, {
|
|
29
|
+
htmlFor: baseClass,
|
|
30
|
+
label: "Doc URL"
|
|
33
31
|
}),
|
|
34
32
|
/*#__PURE__*/ _jsx(CopyToClipboard, {
|
|
35
33
|
value: href
|
|
@@ -37,11 +35,7 @@ export const LinkToDocClient = ()=>{
|
|
|
37
35
|
]
|
|
38
36
|
}),
|
|
39
37
|
/*#__PURE__*/ _jsx("div", {
|
|
40
|
-
|
|
41
|
-
fontWeight: '600',
|
|
42
|
-
overflow: 'hidden',
|
|
43
|
-
textOverflow: 'ellipsis'
|
|
44
|
-
},
|
|
38
|
+
className: `${baseClass}__url`,
|
|
45
39
|
children: /*#__PURE__*/ _jsx(Link, {
|
|
46
40
|
href: href,
|
|
47
41
|
rel: "noopener noreferrer",
|
|
@@ -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
|
|
1
|
+
{"version":3,"sources":["../../../../src/Search/ui/LinkToDoc/index.client.tsx"],"sourcesContent":["'use client'\n\nimport { CopyToClipboard, FieldLabel, Link, useConfig, useField } from '@payloadcms/ui'\nimport { formatAdminURL } from 'payload/shared'\nimport React from 'react'\n\nimport './index.css'\n\nconst baseClass = 'link-to-doc'\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 className={baseClass}>\n <div className={`${baseClass}__header`}>\n <FieldLabel htmlFor={baseClass} label=\"Doc URL\" />\n <CopyToClipboard value={href} />\n </div>\n <div className={`${baseClass}__url`}>\n <Link href={href} rel=\"noopener noreferrer\" target=\"_blank\">\n {href}\n </Link>\n </div>\n </div>\n )\n}\n"],"names":["CopyToClipboard","FieldLabel","Link","useConfig","useField","formatAdminURL","React","baseClass","LinkToDocClient","config","routes","admin","adminRoute","serverURL","value","path","relationTo","href","div","className","htmlFor","label","rel","target"],"mappings":"AAAA;;AAEA,SAASA,eAAe,EAAEC,UAAU,EAAEC,IAAI,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,iBAAgB;AACvF,SAASC,cAAc,QAAQ,iBAAgB;AAC/C,OAAOC,WAAW,QAAO;AAEzB,OAAO,cAAa;AAEpB,MAAMC,YAAY;AAElB,OAAO,MAAMC,kBAA4B;IACvC,MAAM,EAAEC,MAAM,EAAE,GAAGN;IAEnB,MAAM,EACJO,QAAQ,EACNC,OAAOC,UAAU,EAClB,EACDC,SAAS,EACV,GAAGJ;IAEJ,MAAM,EAAEK,KAAK,EAAE,GAAGV,SAAkD;QAAEW,MAAM;IAAM;IAElF,IAAI,CAACD,OAAOE,cAAc,CAACF,OAAOA,OAAO;QACvC,OAAO;IACT;IAEA,MAAMG,OAAOZ,eAAe;QAC1BO;QACAG,MAAM,CAAC,aAAa,EAAED,MAAME,UAAU,IAAI,GAAG,CAAC,EAAEF,MAAMA,KAAK,IAAI,IAAI;QACnED;IACF;IAEA,qBACE,MAACK;QAAIC,WAAWZ;;0BACd,MAACW;gBAAIC,WAAW,GAAGZ,UAAU,QAAQ,CAAC;;kCACpC,KAACN;wBAAWmB,SAASb;wBAAWc,OAAM;;kCACtC,KAACrB;wBAAgBc,OAAOG;;;;0BAE1B,KAACC;gBAAIC,WAAW,GAAGZ,UAAU,KAAK,CAAC;0BACjC,cAAA,KAACL;oBAAKe,MAAMA;oBAAMK,KAAI;oBAAsBC,QAAO;8BAChDN;;;;;AAKX,EAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
@layer payload-default {
|
|
2
|
+
.link-to-doc {
|
|
3
|
+
margin-bottom: var(--spacing-field);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.link-to-doc__header {
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
width: fit-content;
|
|
10
|
+
gap: var(--spacer-1);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.link-to-doc__url {
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
font-weight: 600;
|
|
16
|
+
text-overflow: ellipsis;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.link-to-doc__url a {
|
|
20
|
+
color: var(--color-text-secondary);
|
|
21
|
+
|
|
22
|
+
&:hover {
|
|
23
|
+
color: var(--color-text);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import type { AriaAttributes } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
type ReindexButtonLabelProps = {
|
|
4
|
+
readonly active?: boolean;
|
|
5
|
+
readonly 'aria-controls'?: AriaAttributes['aria-controls'];
|
|
6
|
+
readonly 'aria-expanded'?: AriaAttributes['aria-expanded'];
|
|
7
|
+
readonly 'aria-haspopup'?: AriaAttributes['aria-haspopup'];
|
|
8
|
+
readonly onClick?: React.MouseEventHandler;
|
|
9
|
+
readonly onKeyDown?: React.KeyboardEventHandler;
|
|
10
|
+
};
|
|
11
|
+
export declare const ReindexButtonLabel: React.FC<ReindexButtonLabelProps>;
|
|
12
|
+
export {};
|
|
2
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/Search/ui/ReindexButton/ReindexButtonLabel/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/Search/ui/ReindexButton/ReindexButtonLabel/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAG3C,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,KAAK,uBAAuB,GAAG;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,eAAe,CAAC,EAAE,cAAc,CAAC,eAAe,CAAC,CAAA;IAC1D,QAAQ,CAAC,eAAe,CAAC,EAAE,cAAc,CAAC,eAAe,CAAC,CAAA;IAC1D,QAAQ,CAAC,eAAe,CAAC,EAAE,cAAc,CAAC,eAAe,CAAC,CAAA;IAC1D,QAAQ,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAA;IAC1C,QAAQ,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,oBAAoB,CAAA;CAChD,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAuBhE,CAAA"}
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Button, useTranslation } from '@payloadcms/ui';
|
|
3
|
-
|
|
2
|
+
import { Button, ChevronIcon, useTranslation } from '@payloadcms/ui';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
export const ReindexButtonLabel = ({ active, onClick, onKeyDown, ...ariaProps })=>{
|
|
4
5
|
const { i18n: { t } } = useTranslation();
|
|
5
6
|
return /*#__PURE__*/ _jsx(Button, {
|
|
6
|
-
buttonStyle: "
|
|
7
|
-
|
|
7
|
+
buttonStyle: "secondary",
|
|
8
|
+
extraButtonProps: {
|
|
9
|
+
onKeyDown
|
|
10
|
+
},
|
|
11
|
+
icon: /*#__PURE__*/ _jsx(ChevronIcon, {
|
|
12
|
+
direction: active ? 'up' : 'down',
|
|
13
|
+
size: 16
|
|
14
|
+
}),
|
|
8
15
|
iconPosition: "right",
|
|
16
|
+
onClick: onClick,
|
|
17
|
+
selected: active,
|
|
9
18
|
size: "medium",
|
|
19
|
+
...ariaProps,
|
|
10
20
|
children: t('general:reindex')
|
|
11
21
|
});
|
|
12
22
|
};
|
|
@@ -1 +1 @@
|
|
|
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
|
|
1
|
+
{"version":3,"sources":["../../../../../src/Search/ui/ReindexButton/ReindexButtonLabel/index.tsx"],"sourcesContent":["import type { AriaAttributes } from 'react'\n\nimport { Button, ChevronIcon, useTranslation } from '@payloadcms/ui'\nimport React from 'react'\n\ntype ReindexButtonLabelProps = {\n readonly active?: boolean\n readonly 'aria-controls'?: AriaAttributes['aria-controls']\n readonly 'aria-expanded'?: AriaAttributes['aria-expanded']\n readonly 'aria-haspopup'?: AriaAttributes['aria-haspopup']\n readonly onClick?: React.MouseEventHandler\n readonly onKeyDown?: React.KeyboardEventHandler\n}\n\nexport const ReindexButtonLabel: React.FC<ReindexButtonLabelProps> = ({\n active,\n onClick,\n onKeyDown,\n ...ariaProps\n}) => {\n const {\n i18n: { t },\n } = useTranslation()\n return (\n <Button\n buttonStyle=\"secondary\"\n extraButtonProps={{ onKeyDown }}\n icon={<ChevronIcon direction={active ? 'up' : 'down'} size={16} />}\n iconPosition=\"right\"\n onClick={onClick}\n selected={active}\n size=\"medium\"\n {...ariaProps}\n >\n {t('general:reindex')}\n </Button>\n )\n}\n"],"names":["Button","ChevronIcon","useTranslation","React","ReindexButtonLabel","active","onClick","onKeyDown","ariaProps","i18n","t","buttonStyle","extraButtonProps","icon","direction","size","iconPosition","selected"],"mappings":";AAEA,SAASA,MAAM,EAAEC,WAAW,EAAEC,cAAc,QAAQ,iBAAgB;AACpE,OAAOC,WAAW,QAAO;AAWzB,OAAO,MAAMC,qBAAwD,CAAC,EACpEC,MAAM,EACNC,OAAO,EACPC,SAAS,EACT,GAAGC,WACJ;IACC,MAAM,EACJC,MAAM,EAAEC,CAAC,EAAE,EACZ,GAAGR;IACJ,qBACE,KAACF;QACCW,aAAY;QACZC,kBAAkB;YAAEL;QAAU;QAC9BM,oBAAM,KAACZ;YAAYa,WAAWT,SAAS,OAAO;YAAQU,MAAM;;QAC5DC,cAAa;QACbV,SAASA;QACTW,UAAUZ;QACVU,MAAK;QACJ,GAAGP,SAAS;kBAEZE,EAAE;;AAGT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.client.d.ts","sourceRoot":"","sources":["../../../../src/Search/ui/ReindexButton/index.client.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAyC,MAAM,OAAO,CAAA;AAE7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAMpD,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.client.d.ts","sourceRoot":"","sources":["../../../../src/Search/ui/ReindexButton/index.client.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAyC,MAAM,OAAO,CAAA;AAE7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAMpD,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAuI5D,CAAA"}
|
|
@@ -10,6 +10,7 @@ export const ReindexButtonClient = ({ collectionLabels, searchCollections, searc
|
|
|
10
10
|
const { config } = useConfig();
|
|
11
11
|
const { i18n: { t } } = useTranslation();
|
|
12
12
|
const locale = useLocale();
|
|
13
|
+
const localeCode = locale?.code;
|
|
13
14
|
const router = useRouter();
|
|
14
15
|
const [reindexCollections, setReindexCollections] = useState([]);
|
|
15
16
|
const openConfirmModal = useCallback(()=>openModal(confirmReindexModalSlug), [
|
|
@@ -22,7 +23,7 @@ export const ReindexButtonClient = ({ collectionLabels, searchCollections, searc
|
|
|
22
23
|
try {
|
|
23
24
|
const res = await fetch(formatAdminURL({
|
|
24
25
|
apiRoute: config.routes.api,
|
|
25
|
-
path: `/${searchSlug}/reindex?locale=${
|
|
26
|
+
path: `/${searchSlug}/reindex${localeCode ? `?locale=${localeCode}` : ''}`
|
|
26
27
|
}), {
|
|
27
28
|
body: JSON.stringify({
|
|
28
29
|
collections: reindexCollections
|
|
@@ -45,7 +46,7 @@ export const ReindexButtonClient = ({ collectionLabels, searchCollections, searc
|
|
|
45
46
|
reindexCollections,
|
|
46
47
|
router,
|
|
47
48
|
searchSlug,
|
|
48
|
-
|
|
49
|
+
localeCode,
|
|
49
50
|
config
|
|
50
51
|
]);
|
|
51
52
|
const handleShowConfirmModal = useCallback((collections = searchCollections)=>{
|
|
@@ -68,11 +69,11 @@ export const ReindexButtonClient = ({ collectionLabels, searchCollections, searc
|
|
|
68
69
|
if (typeof label === 'string') {
|
|
69
70
|
return label;
|
|
70
71
|
} else {
|
|
71
|
-
return label && Object.hasOwn(label,
|
|
72
|
+
return label && localeCode && Object.hasOwn(label, localeCode) ? label[localeCode] : slug;
|
|
72
73
|
}
|
|
73
74
|
}, [
|
|
74
75
|
collectionLabels,
|
|
75
|
-
|
|
76
|
+
localeCode
|
|
76
77
|
]);
|
|
77
78
|
const pluralizedLabels = useMemo(()=>{
|
|
78
79
|
return searchCollections.reduce((acc, slug)=>{
|
|
@@ -97,7 +98,7 @@ export const ReindexButtonClient = ({ collectionLabels, searchCollections, searc
|
|
|
97
98
|
return /*#__PURE__*/ _jsxs("div", {
|
|
98
99
|
children: [
|
|
99
100
|
/*#__PURE__*/ _jsx(Popup, {
|
|
100
|
-
|
|
101
|
+
popupType: "menu",
|
|
101
102
|
render: ({ close })=>/*#__PURE__*/ _jsxs(PopupList.ButtonGroup, {
|
|
102
103
|
children: [
|
|
103
104
|
searchCollections.map((collectionSlug)=>/*#__PURE__*/ _jsx(PopupList.Button, {
|
|
@@ -110,6 +111,9 @@ export const ReindexButtonClient = ({ collectionLabels, searchCollections, searc
|
|
|
110
111
|
})
|
|
111
112
|
]
|
|
112
113
|
}),
|
|
114
|
+
renderButton: (buttonProps)=>/*#__PURE__*/ _jsx(ReindexButtonLabel, {
|
|
115
|
+
...buttonProps
|
|
116
|
+
}),
|
|
113
117
|
showScrollbar: true,
|
|
114
118
|
size: "large",
|
|
115
119
|
verticalAlign: "bottom"
|
|
@@ -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 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=${
|
|
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 localeCode = locale?.code\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${localeCode ? `?locale=${localeCode}` : ''}`,\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, localeCode, 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 && localeCode && Object.hasOwn(label, localeCode) ? label[localeCode] : slug\n }\n },\n [collectionLabels, localeCode],\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 popupType=\"menu\"\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 renderButton={(buttonProps) => <ReindexButtonLabel {...buttonProps} />}\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","localeCode","code","router","reindexCollections","setReindexCollections","openConfirmModal","handleReindexSubmit","length","res","fetch","apiRoute","routes","api","path","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","popupType","render","close","ButtonGroup","collectionSlug","Button","onClick","renderButton","buttonProps","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,QACT,iBAAgB;AACvB,SAASC,cAAc,QAAQ,iBAAgB;AAC/C,OAAOC,SAASC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AAI7D,SAASC,kBAAkB,QAAQ,gCAA+B;AAElE,MAAMC,0BAA0B;AAEhC,OAAO,MAAMC,sBAAoD,CAAC,EAChEC,gBAAgB,EAChBC,iBAAiB,EACjBC,UAAU,EACX;IACC,MAAM,EAAEC,SAAS,EAAE,GAAGd;IAEtB,MAAM,EAAEe,MAAM,EAAE,GAAGjB;IAEnB,MAAM,EACJkB,MAAM,EAAEC,CAAC,EAAE,EACZ,GAAGf;IAEJ,MAAMgB,SAASnB;IACf,MAAMoB,aAAaD,QAAQE;IAC3B,MAAMC,SAASpB;IAEf,MAAM,CAACqB,oBAAoBC,sBAAsB,GAAGhB,SAAmB,EAAE;IAEzE,MAAMiB,mBAAmBnB,YAAY,IAAMS,UAAUL,0BAA0B;QAACK;KAAU;IAE1F,MAAMW,sBAAsBpB,YAAY;QACt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AOM,kBAAkB0C,MAAM,CAAyB,CAACC,KAAKP;YAC5D,MAAME,QAAQD,mBAAmBD;YACjC,IAAIE,OAAO;gBACTK,GAAG,CAACP,KAAK,GAAGE;YACd;YACA,OAAOK;QACT,GAAG,CAAC;IACN,GAAG;QAAC3C;QAAmBqC;KAAmB;IAE1C,MAAMO,cAAclC,mBAAmBI,MAAM,KAAKd,kBAAkBc,MAAM;IAC1E,MAAM+B,iBAAiBnC,mBAAmBoC,GAAG,CAAC,CAACV,OAASK,gBAAgB,CAACL,KAAK,EAAEW,IAAI,CAAC;IAErF,MAAMC,aAAaJ,cACfvC,EAAE,+BACFA,EAAE,0BAA0B;QAAEmB,aAAaqB;IAAe;IAC9D,MAAMI,mBAAmBL,cACrBvC,EAAE,0CACFA,EAAE,qCAAqC;QAAEmB,aAAaqB;IAAe;IAEzE,qBACE,MAACK;;0BACC,KAACnE;gBACCoE,WAAU;gBACVC,QAAQ,CAAC,EAAEC,KAAK,EAAE,iBAChB,MAACrE,UAAUsE,WAAW;;4BACnBtD,kBAAkB8C,GAAG,CAAC,CAACS,+BACtB,KAACvE,UAAUwE,MAAM;oCAEfC,SAAS,IAAMvB,uBAAuBmB,OAAOE;8CAE5Cd,gBAAgB,CAACc,eAAe;mCAH5BA;0CAMT,KAACvE,UAAUwE,MAAM;gCAACC,SAAS,IAAMvB,uBAAuBmB;0CACrDhD,EAAE;;;;gBAITqD,cAAc,CAACC,4BAAgB,KAAC/D;wBAAoB,GAAG+D,WAAW;;gBAClEC,aAAa;gBACbC,MAAK;gBACLC,eAAc;;0BAEhB,KAAChF;gBACCuC,MAAM4B;gBACNc,SAASf;gBACTgB,WAAWnE;gBACXoE,WAAWpD;;;;AAInB,EAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Config } from 'payload';
|
|
2
1
|
import type { SearchPluginConfig } from './types.js';
|
|
3
|
-
export declare const searchPlugin:
|
|
2
|
+
export declare const searchPlugin: (options: SearchPluginConfig) => import("payload").Plugin;
|
|
4
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAA+B,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAQjF,eAAO,MAAM,YAAY,2DA8EvB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { definePlugin } from 'payload';
|
|
1
2
|
import { deleteFromSearch } from './Search/hooks/deleteFromSearch.js';
|
|
2
3
|
import { syncWithSearch } from './Search/hooks/syncWithSearch.js';
|
|
3
4
|
import { generateSearchCollection } from './Search/index.js';
|
|
4
|
-
export const searchPlugin = (
|
|
5
|
+
export const searchPlugin = definePlugin({
|
|
6
|
+
slug: '@payloadcms/plugin-search',
|
|
7
|
+
plugin: ({ config, options: incomingPluginConfig })=>{
|
|
5
8
|
const { collections } = config;
|
|
6
9
|
// If the user defines `localize` to either true or false, use that
|
|
7
10
|
// Otherwise, set it based on if their config has localization enabled or disabled
|
|
@@ -62,6 +65,7 @@ export const searchPlugin = (incomingPluginConfig)=>(config)=>{
|
|
|
62
65
|
};
|
|
63
66
|
}
|
|
64
67
|
return config;
|
|
65
|
-
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
66
70
|
|
|
67
71
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { CollectionAfterChangeHook
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { CollectionAfterChangeHook } from 'payload'\n\nimport { definePlugin } 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 = definePlugin<SearchPluginConfig>({\n slug: '@payloadcms/plugin-search',\n plugin: ({ config, options: incomingPluginConfig }) => {\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 = {\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})\n"],"names":["definePlugin","deleteFromSearch","syncWithSearch","generateSearchCollection","searchPlugin","slug","plugin","config","options","incomingPluginConfig","collections","shouldLocalize","localize","Boolean","localization","enabledSlugSet","Set","labels","collection","has","pluginConfig","deleteDrafts","reindexBatchSize","syncDrafts","collectionsWithSearchHooks","map","hooks","existingHooks","isEnabled","afterChange","args","beforeDelete","filter"],"mappings":"AAEA,SAASA,YAAY,QAAQ,UAAS;AAItC,SAASC,gBAAgB,QAAQ,qCAAoC;AACrE,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,wBAAwB,QAAQ,oBAAmB;AAI5D,OAAO,MAAMC,eAAeJ,aAAiC;IAC3DK,MAAM;IACNC,QAAQ,CAAC,EAAEC,MAAM,EAAEC,SAASC,oBAAoB,EAAE;QAChD,MAAM,EAAEC,WAAW,EAAE,GAAGH;QAExB,mEAAmE;QACnE,kFAAkF;QAClF,MAAMI,iBACJ,OAAOF,qBAAqBG,QAAQ,KAAK,YACrCH,qBAAqBG,QAAQ,GAC7BC,QAAQN,OAAOO,YAAY;QACjCL,qBAAqBG,QAAQ,GAAGD;QAEhC,IAAID,aAAa;YACf,mFAAmF;YACnF,qDAAqD;YACrD,MAAMK,iBAAiB,IAAIC,IAAIP,qBAAqBC,WAAW,IAAI,EAAE;YAErE,MAAMO,SAAiE,CAAC;YACxE,KAAK,MAAMC,cAAcR,YAAa;gBACpC,IAAIK,eAAeI,GAAG,CAACD,WAAWb,IAAI,GAAG;oBACvCY,MAAM,CAACC,WAAWb,IAAI,CAAC,GAAGa,WAAWD,MAAM;gBAC7C;YACF;YAEA,MAAMG,eAA4C;gBAChD,iCAAiC;gBACjCC,cAAc;gBACdJ;gBACAK,kBAAkBb,sBAAsBa,oBAAoB;gBAC5DC,YAAY;gBACZ,GAAGd,oBAAoB;YACzB;YAEA,2EAA2E;YAC3E,MAAMe,6BAA6BjB,QAAQG,aACvCe,IAAI,CAACP;gBACL,MAAM,EAAEQ,OAAOC,aAAa,EAAE,GAAGT;gBAEjC,MAAMU,YAAYb,eAAeI,GAAG,CAACD,WAAWb,IAAI;gBACpD,IAAIuB,WAAW;oBACb,OAAO;wBACL,GAAGV,UAAU;wBACbQ,OAAO;4BACL,GAAGR,WAAWQ,KAAK;4BACnBG,aAAa;mCACPF,eAAeE,eAAe,EAAE;gCACpC,OAAOC;oCACL,MAAM5B,eAAe;wCACnB,GAAG4B,IAAI;wCACPZ,YAAYA,WAAWb,IAAI;wCAC3Be;oCACF;gCACF;6BACD;4BACDW,cAAc;mCACRJ,eAAeI,gBAAgB,EAAE;gCACrC9B,iBAAiBmB;6BAClB;wBACH;oBACF;gBACF;gBAEA,OAAOF;YACT,GACCc,OAAOnB;YAEV,OAAO;gBACL,GAAGN,MAAM;gBACTG,aAAa;uBACPc,8BAA8B,EAAE;oBACpCrB,yBAAyBiB;iBAC1B;YACH;QACF;QAEA,OAAOb;IACT;AACF,GAAE"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CollectionAfterChangeHook, CollectionBeforeDeleteHook, CollectionConfig, Field, Locale, Payload, PayloadRequest, StaticLabel } from 'payload';
|
|
1
|
+
import type { CollectionAfterChangeHook, CollectionBeforeDeleteHook, CollectionConfig, Field, Locale, Payload, PayloadRequest, StaticLabel, TypedLocale } from 'payload';
|
|
2
2
|
export type DocToSync = {
|
|
3
3
|
[key: string]: any;
|
|
4
4
|
doc: {
|
|
@@ -19,15 +19,13 @@ export type BeforeSync = (args: {
|
|
|
19
19
|
export type FieldsOverride = (args: {
|
|
20
20
|
defaultFields: Field[];
|
|
21
21
|
}) => Field[];
|
|
22
|
-
export type SkipSyncFunction
|
|
22
|
+
export type SkipSyncFunction = (args: {
|
|
23
23
|
collectionSlug: string;
|
|
24
24
|
doc: any;
|
|
25
|
-
locale:
|
|
26
|
-
locale: unknown;
|
|
27
|
-
} ? ConfigTypes['locale'] : string | undefined;
|
|
25
|
+
locale: TypedLocale | undefined;
|
|
28
26
|
req: PayloadRequest;
|
|
29
27
|
}) => boolean | Promise<boolean>;
|
|
30
|
-
export type SearchPluginConfig
|
|
28
|
+
export type SearchPluginConfig = {
|
|
31
29
|
beforeSync?: BeforeSync;
|
|
32
30
|
collections?: string[];
|
|
33
31
|
defaultPriorities?: {
|
|
@@ -69,7 +67,7 @@ export type SearchPluginConfig<ConfigTypes = unknown> = {
|
|
|
69
67
|
* return !tenant.allowedLocales.includes(locale)
|
|
70
68
|
* }
|
|
71
69
|
*/
|
|
72
|
-
skipSync?: SkipSyncFunction
|
|
70
|
+
skipSync?: SkipSyncFunction;
|
|
73
71
|
/**
|
|
74
72
|
* Controls whether drafts are synced to the search index
|
|
75
73
|
*
|
|
@@ -83,13 +81,13 @@ export type CollectionLabels = {
|
|
|
83
81
|
export type ResolvedCollectionLabels = {
|
|
84
82
|
[collection: string]: StaticLabel;
|
|
85
83
|
};
|
|
86
|
-
export type SearchPluginConfigWithLocales
|
|
84
|
+
export type SearchPluginConfigWithLocales = {
|
|
87
85
|
labels?: CollectionLabels;
|
|
88
|
-
} & SearchPluginConfig
|
|
89
|
-
export type SanitizedSearchPluginConfig
|
|
86
|
+
} & SearchPluginConfig;
|
|
87
|
+
export type SanitizedSearchPluginConfig = {
|
|
90
88
|
reindexBatchSize: number;
|
|
91
89
|
syncDrafts: boolean;
|
|
92
|
-
} & SearchPluginConfigWithLocales
|
|
90
|
+
} & SearchPluginConfigWithLocales;
|
|
93
91
|
export type SyncWithSearchArgs = {
|
|
94
92
|
collection: string;
|
|
95
93
|
pluginConfig: SanitizedSearchPluginConfig;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,0BAA0B,EAC1B,gBAAgB,EAChB,KAAK,EACL,MAAM,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AO,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,CAAC,UAAU,EAAE,MAAM,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAA;CACjD,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,CAAC,UAAU,EAAE,MAAM,GAAG,WAAW,CAAA;CAClC,CAAA;AAED,MAAM,MAAM,6BAA6B,GAAG;IAC1C,MAAM,CAAC,EAAE,gBAAgB,CAAA;CAC1B,GAAG,kBAAkB,CAAA;AAEtB,MAAM,MAAM,2BAA2B,GAAG;IACxC,gBAAgB,EAAE,MAAM,CAAA;IACxB,UAAU,EAAE,OAAO,CAAA;CACpB,GAAG,6BAA6B,CAAA;AAEjC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,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
|
|
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 TypedLocale,\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 = (args: {\n collectionSlug: string\n doc: any\n locale: TypedLocale | undefined\n req: PayloadRequest\n}) => boolean | Promise<boolean>\n\nexport type SearchPluginConfig = {\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\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 = {\n labels?: CollectionLabels\n} & SearchPluginConfig\n\nexport type SanitizedSearchPluginConfig = {\n reindexBatchSize: number\n syncDrafts: boolean\n} & SearchPluginConfigWithLocales\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":"AAwHA,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,iBAClB,2BAA2B,KAAG,cAyN5C,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,8FAS9B,WAAW,iBAyRb,CAAA"}
|
|
@@ -51,6 +51,7 @@ export const syncDocAsSearchIndex = async ({ collection, doc, locale, onSyncErro
|
|
|
51
51
|
id,
|
|
52
52
|
collection,
|
|
53
53
|
locale: syncLocale,
|
|
54
|
+
overrideAccess: true,
|
|
54
55
|
req,
|
|
55
56
|
// Include trashed documents when the document being synced is trashed
|
|
56
57
|
trash: isTrashDocument
|
|
@@ -89,6 +90,7 @@ export const syncDocAsSearchIndex = async ({ collection, doc, locale, onSyncErro
|
|
|
89
90
|
},
|
|
90
91
|
depth: 0,
|
|
91
92
|
locale: syncLocale,
|
|
93
|
+
overrideAccess: true,
|
|
92
94
|
req
|
|
93
95
|
});
|
|
94
96
|
}
|
|
@@ -99,6 +101,7 @@ export const syncDocAsSearchIndex = async ({ collection, doc, locale, onSyncErro
|
|
|
99
101
|
collection: searchSlug,
|
|
100
102
|
depth: 0,
|
|
101
103
|
locale: syncLocale,
|
|
104
|
+
overrideAccess: true,
|
|
102
105
|
req,
|
|
103
106
|
where: {
|
|
104
107
|
'doc.relationTo': {
|
|
@@ -119,6 +122,7 @@ export const syncDocAsSearchIndex = async ({ collection, doc, locale, onSyncErro
|
|
|
119
122
|
await payload.delete({
|
|
120
123
|
collection: searchSlug,
|
|
121
124
|
depth: 0,
|
|
125
|
+
overrideAccess: true,
|
|
122
126
|
req,
|
|
123
127
|
where: {
|
|
124
128
|
id: {
|
|
@@ -143,6 +147,7 @@ export const syncDocAsSearchIndex = async ({ collection, doc, locale, onSyncErro
|
|
|
143
147
|
id: searchDocID,
|
|
144
148
|
collection: searchSlug,
|
|
145
149
|
depth: 0,
|
|
150
|
+
overrideAccess: true,
|
|
146
151
|
req
|
|
147
152
|
});
|
|
148
153
|
} catch (err) {
|
|
@@ -164,6 +169,7 @@ export const syncDocAsSearchIndex = async ({ collection, doc, locale, onSyncErro
|
|
|
164
169
|
},
|
|
165
170
|
depth: 0,
|
|
166
171
|
locale: syncLocale,
|
|
172
|
+
overrideAccess: true,
|
|
167
173
|
req
|
|
168
174
|
});
|
|
169
175
|
} catch (err) {
|
|
@@ -182,6 +188,7 @@ export const syncDocAsSearchIndex = async ({ collection, doc, locale, onSyncErro
|
|
|
182
188
|
draft: false,
|
|
183
189
|
limit: 1,
|
|
184
190
|
locale: syncLocale,
|
|
191
|
+
overrideAccess: true,
|
|
185
192
|
pagination: false,
|
|
186
193
|
req,
|
|
187
194
|
where: {
|
|
@@ -206,6 +213,7 @@ export const syncDocAsSearchIndex = async ({ collection, doc, locale, onSyncErro
|
|
|
206
213
|
id: searchDocID,
|
|
207
214
|
collection: searchSlug,
|
|
208
215
|
depth: 0,
|
|
216
|
+
overrideAccess: true,
|
|
209
217
|
req
|
|
210
218
|
});
|
|
211
219
|
} catch (err) {
|
|
@@ -227,6 +235,7 @@ export const syncDocAsSearchIndex = async ({ collection, doc, locale, onSyncErro
|
|
|
227
235
|
},
|
|
228
236
|
depth: 0,
|
|
229
237
|
locale: syncLocale,
|
|
238
|
+
overrideAccess: true,
|
|
230
239
|
req
|
|
231
240
|
});
|
|
232
241
|
} catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/syncDocAsSearchIndex.ts"],"sourcesContent":["import type { DocToSync, SyncDocArgs } from '../types.js'\n\nexport const syncDocAsSearchIndex = async ({\n collection,\n doc,\n locale,\n onSyncError,\n operation,\n pluginConfig,\n req: { payload },\n req,\n}: SyncDocArgs) => {\n const { id, _status: status, title } = doc || {}\n\n const { beforeSync, defaultPriorities, deleteDrafts, searchOverrides, syncDrafts } = pluginConfig\n\n const searchSlug = searchOverrides?.slug || 'search'\n\n // Determine sync locale\n const syncLocale = locale || req.locale || undefined\n\n if (typeof pluginConfig.skipSync === 'function') {\n try {\n const skipSync = await pluginConfig.skipSync({\n collectionSlug: collection,\n doc,\n locale: syncLocale,\n req,\n })\n\n if (skipSync) {\n return doc\n }\n } catch (err) {\n req.payload.logger.error({\n err,\n msg: 'Search plugin: Error executing skipSync. Proceeding with sync.',\n })\n }\n }\n\n let dataToSave: DocToSync = {\n doc: {\n relationTo: collection,\n value: id,\n },\n title,\n }\n const docKeyPrefix = `${collection}:${id}`\n const docKey = req.payload.config.localization ? `${docKeyPrefix}:${syncLocale}` : docKeyPrefix\n const syncedDocsSet = (req.context?.syncedDocsSet as Set<string>) || new Set<string>()\n\n if (syncedDocsSet.has(docKey)) {\n /*\n * prevents duplicate syncing of documents in the same request\n * this can happen when hooks call `payload.update` within the create lifecycle\n * like the nested-docs plugin does\n */\n return doc\n } else {\n syncedDocsSet.add(docKey)\n }\n\n req.context.syncedDocsSet = syncedDocsSet\n\n if (typeof beforeSync === 'function') {\n let docToSyncWith = doc\n if (payload.config?.localization) {\n // Check if document is trashed (has deletedAt field)\n const isTrashDocument = doc && 'deletedAt' in doc && doc.deletedAt\n\n docToSyncWith = await payload.findByID({\n id,\n collection,\n locale: syncLocale,\n req,\n // Include trashed documents when the document being synced is trashed\n trash: isTrashDocument,\n })\n }\n dataToSave = await beforeSync({\n collectionSlug: collection,\n originalDoc: docToSyncWith,\n payload,\n req,\n searchDoc: dataToSave,\n })\n }\n\n let defaultPriority = 0\n if (defaultPriorities) {\n const { [collection]: priority } = defaultPriorities\n\n if (typeof priority === 'function') {\n try {\n defaultPriority = await priority(doc)\n } catch (err: unknown) {\n payload.logger.error(err)\n payload.logger.error(\n `Error gathering default priority for ${searchSlug} documents related to ${collection}`,\n )\n }\n } else if (priority !== undefined) {\n defaultPriority = priority\n }\n }\n\n const doSync = syncDrafts || (!syncDrafts && status !== 'draft')\n\n try {\n if (operation === 'create' && doSync) {\n await payload.create({\n collection: searchSlug,\n data: {\n ...dataToSave,\n priority: defaultPriority,\n },\n depth: 0,\n locale: syncLocale,\n req,\n })\n }\n\n if (operation === 'update') {\n try {\n // find the correct doc to sync with\n const searchDocQuery = await payload.find({\n collection: searchSlug,\n depth: 0,\n locale: syncLocale,\n req,\n where: {\n 'doc.relationTo': {\n equals: collection,\n },\n 'doc.value': {\n equals: id,\n },\n },\n })\n\n const docs: Array<{\n id: number | string\n priority?: number\n }> = searchDocQuery?.docs || []\n\n const [foundDoc, ...duplicativeDocs] = docs\n\n // delete all duplicative search docs (docs that reference the same page)\n // to ensure the same, out-of-date result does not appear twice (where only syncing the first found doc)\n if (duplicativeDocs.length > 0) {\n try {\n const duplicativeDocIDs = duplicativeDocs.map(({ id }) => id)\n await payload.delete({\n collection: searchSlug,\n depth: 0,\n req,\n where: { id: { in: duplicativeDocIDs } },\n })\n } catch (err: unknown) {\n payload.logger.error({\n err,\n msg: `Error deleting duplicative ${searchSlug} documents.`,\n })\n }\n }\n\n if (foundDoc) {\n const { id: searchDocID } = foundDoc\n\n // Check if document is trashed and delete from search\n const isTrashDocument = doc && 'deletedAt' in doc && doc.deletedAt\n\n if (isTrashDocument) {\n try {\n await payload.delete({\n id: searchDocID,\n collection: searchSlug,\n depth: 0,\n req,\n })\n } catch (err: unknown) {\n payload.logger.error({\n err,\n msg: `Error deleting ${searchSlug} document for trashed doc.`,\n })\n }\n } else {\n if (doSync) {\n // update the doc normally\n try {\n await payload.update({\n id: searchDocID,\n collection: searchSlug,\n data: {\n ...dataToSave,\n priority: foundDoc.priority || defaultPriority,\n },\n depth: 0,\n locale: syncLocale,\n req,\n })\n } catch (err: unknown) {\n payload.logger.error({ err, msg: `Error updating ${searchSlug} document.` })\n }\n }\n\n if (deleteDrafts && status === 'draft') {\n // Check to see if there's a published version of the doc\n // We don't want to remove the search doc if there is a published version but a new draft has been created\n const {\n docs: [docWithPublish],\n } = await payload.find({\n collection,\n depth: 0,\n draft: false,\n limit: 1,\n locale: syncLocale,\n pagination: false,\n req,\n where: {\n and: [\n {\n _status: {\n equals: 'published',\n },\n },\n {\n id: {\n equals: id,\n },\n },\n ],\n },\n })\n\n if (!docWithPublish) {\n // do not include draft docs in search results, so delete the record\n try {\n await payload.delete({\n id: searchDocID,\n collection: searchSlug,\n depth: 0,\n req,\n })\n } catch (err: unknown) {\n payload.logger.error({ err, msg: `Error deleting ${searchSlug} document.` })\n }\n }\n }\n }\n } else if (doSync) {\n try {\n await payload.create({\n collection: searchSlug,\n data: {\n ...dataToSave,\n priority: defaultPriority,\n },\n depth: 0,\n locale: syncLocale,\n req,\n })\n } catch (err: unknown) {\n payload.logger.error({ err, msg: `Error creating ${searchSlug} document.` })\n }\n }\n } catch (err: unknown) {\n payload.logger.error({ err, msg: `Error finding ${searchSlug} document.` })\n }\n }\n } catch (err: unknown) {\n payload.logger.error({\n err,\n msg: `Error syncing ${searchSlug} document related to ${collection} with id: '${id}'.`,\n })\n\n if (onSyncError) {\n onSyncError()\n }\n }\n\n return doc\n}\n"],"names":["syncDocAsSearchIndex","collection","doc","locale","onSyncError","operation","pluginConfig","req","payload","id","_status","status","title","beforeSync","defaultPriorities","deleteDrafts","searchOverrides","syncDrafts","searchSlug","slug","syncLocale","undefined","skipSync","collectionSlug","err","logger","error","msg","dataToSave","relationTo","value","docKeyPrefix","docKey","config","localization","syncedDocsSet","context","Set","has","add","docToSyncWith","isTrashDocument","deletedAt","findByID","trash","originalDoc","searchDoc","defaultPriority","priority","doSync","create","data","depth","searchDocQuery","find","where","equals","docs","foundDoc","duplicativeDocs","length","duplicativeDocIDs","map","delete","in","searchDocID","update","docWithPublish","draft","limit","pagination","and"],"mappings":"AAEA,OAAO,MAAMA,uBAAuB,OAAO,EACzCC,UAAU,EACVC,GAAG,EACHC,MAAM,EACNC,WAAW,EACXC,SAAS,EACTC,YAAY,EACZC,KAAK,EAAEC,OAAO,EAAE,EAChBD,GAAG,EACS;IACZ,MAAM,EAAEE,EAAE,EAAEC,SAASC,MAAM,EAAEC,KAAK,EAAE,GAAGV,OAAO,CAAC;IAE/C,MAAM,EAAEW,UAAU,EAAEC,iBAAiB,EAAEC,YAAY,EAAEC,eAAe,EAAEC,UAAU,EAAE,GAAGX;IAErF,MAAMY,aAAaF,iBAAiBG,QAAQ;IAE5C,wBAAwB;IACxB,MAAMC,aAAajB,UAAUI,IAAIJ,MAAM,IAAIkB;IAE3C,IAAI,OAAOf,aAAagB,QAAQ,KAAK,YAAY;QAC/C,IAAI;YACF,MAAMA,WAAW,MAAMhB,aAAagB,QAAQ,CAAC;gBAC3CC,gBAAgBtB;gBAChBC;gBACAC,QAAQiB;gBACRb;YACF;YAEA,IAAIe,UAAU;gBACZ,OAAOpB;YACT;QACF,EAAE,OAAOsB,KAAK;YACZjB,IAAIC,OAAO,CAACiB,MAAM,CAACC,KAAK,CAAC;gBACvBF;gBACAG,KAAK;YACP;QACF;IACF;IAEA,IAAIC,aAAwB;QAC1B1B,KAAK;YACH2B,YAAY5B;YACZ6B,OAAOrB;QACT;QACAG;IACF;IACA,MAAMmB,eAAe,GAAG9B,WAAW,CAAC,EAAEQ,IAAI;IAC1C,MAAMuB,SAASzB,IAAIC,OAAO,CAACyB,MAAM,CAACC,YAAY,GAAG,GAAGH,aAAa,CAAC,EAAEX,YAAY,GAAGW;IACnF,MAAMI,gBAAgB,AAAC5B,IAAI6B,OAAO,EAAED,iBAAiC,IAAIE;IAEzE,IAAIF,cAAcG,GAAG,CAACN,SAAS;QAC7B;;;;K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QAAQiB;4BACRb;wBACF;oBACF,EAAE,OAAOiB,KAAc;wBACrBhB,QAAQiB,MAAM,CAACC,KAAK,CAAC;4BAAEF;4BAAKG,KAAK,CAAC,eAAe,EAAET,WAAW,UAAU,CAAC;wBAAC;oBAC5E;gBACF;YACF,EAAE,OAAOM,KAAc;gBACrBhB,QAAQiB,MAAM,CAACC,KAAK,CAAC;oBAAEF;oBAAKG,KAAK,CAAC,cAAc,EAAET,WAAW,UAAU,CAAC;gBAAC;YAC3E;QACF;IACF,EAAE,OAAOM,KAAc;QACrBhB,QAAQiB,MAAM,CAACC,KAAK,CAAC;YACnBF;YACAG,KAAK,CAAC,cAAc,EAAET,WAAW,qBAAqB,EAAEjB,WAAW,WAAW,EAAEQ,GAAG,EAAE,CAAC;QACxF;QAEA,IAAIL,aAAa;YACfA;QACF;IACF;IAEA,OAAOF;AACT,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/syncDocAsSearchIndex.ts"],"sourcesContent":["import type { DocToSync, SyncDocArgs } from '../types.js'\n\nexport const syncDocAsSearchIndex = async ({\n collection,\n doc,\n locale,\n onSyncError,\n operation,\n pluginConfig,\n req: { payload },\n req,\n}: SyncDocArgs) => {\n const { id, _status: status, title } = doc || {}\n\n const { beforeSync, defaultPriorities, deleteDrafts, searchOverrides, syncDrafts } = pluginConfig\n\n const searchSlug = searchOverrides?.slug || 'search'\n\n // Determine sync locale\n const syncLocale = locale || req.locale || undefined\n\n if (typeof pluginConfig.skipSync === 'function') {\n try {\n const skipSync = await pluginConfig.skipSync({\n collectionSlug: collection,\n doc,\n locale: syncLocale,\n req,\n })\n\n if (skipSync) {\n return doc\n }\n } catch (err) {\n req.payload.logger.error({\n err,\n msg: 'Search plugin: Error executing skipSync. Proceeding with sync.',\n })\n }\n }\n\n let dataToSave: DocToSync = {\n doc: {\n relationTo: collection,\n value: id,\n },\n title,\n }\n const docKeyPrefix = `${collection}:${id}`\n const docKey = req.payload.config.localization ? `${docKeyPrefix}:${syncLocale}` : docKeyPrefix\n const syncedDocsSet = (req.context?.syncedDocsSet as Set<string>) || new Set<string>()\n\n if (syncedDocsSet.has(docKey)) {\n /*\n * prevents duplicate syncing of documents in the same request\n * this can happen when hooks call `payload.update` within the create lifecycle\n * like the nested-docs plugin does\n */\n return doc\n } else {\n syncedDocsSet.add(docKey)\n }\n\n req.context.syncedDocsSet = syncedDocsSet\n\n if (typeof beforeSync === 'function') {\n let docToSyncWith = doc\n if (payload.config?.localization) {\n // Check if document is trashed (has deletedAt field)\n const isTrashDocument = doc && 'deletedAt' in doc && doc.deletedAt\n\n docToSyncWith = await payload.findByID({\n id,\n collection,\n locale: syncLocale,\n overrideAccess: true,\n req,\n // Include trashed documents when the document being synced is trashed\n trash: isTrashDocument,\n })\n }\n dataToSave = await beforeSync({\n collectionSlug: collection,\n originalDoc: docToSyncWith,\n payload,\n req,\n searchDoc: dataToSave,\n })\n }\n\n let defaultPriority = 0\n if (defaultPriorities) {\n const { [collection]: priority } = defaultPriorities\n\n if (typeof priority === 'function') {\n try {\n defaultPriority = await priority(doc)\n } catch (err: unknown) {\n payload.logger.error(err)\n payload.logger.error(\n `Error gathering default priority for ${searchSlug} documents related to ${collection}`,\n )\n }\n } else if (priority !== undefined) {\n defaultPriority = priority\n }\n }\n\n const doSync = syncDrafts || (!syncDrafts && status !== 'draft')\n\n try {\n if (operation === 'create' && doSync) {\n await payload.create({\n collection: searchSlug,\n data: {\n ...dataToSave,\n priority: defaultPriority,\n },\n depth: 0,\n locale: syncLocale,\n overrideAccess: true,\n req,\n })\n }\n\n if (operation === 'update') {\n try {\n // find the correct doc to sync with\n const searchDocQuery = await payload.find({\n collection: searchSlug,\n depth: 0,\n locale: syncLocale,\n overrideAccess: true,\n req,\n where: {\n 'doc.relationTo': {\n equals: collection,\n },\n 'doc.value': {\n equals: id,\n },\n },\n })\n\n const docs: Array<{\n id: number | string\n priority?: number\n }> = searchDocQuery?.docs || []\n\n const [foundDoc, ...duplicativeDocs] = docs\n\n // delete all duplicative search docs (docs that reference the same page)\n // to ensure the same, out-of-date result does not appear twice (where only syncing the first found doc)\n if (duplicativeDocs.length > 0) {\n try {\n const duplicativeDocIDs = duplicativeDocs.map(({ id }) => id)\n await payload.delete({\n collection: searchSlug,\n depth: 0,\n overrideAccess: true,\n req,\n where: { id: { in: duplicativeDocIDs } },\n })\n } catch (err: unknown) {\n payload.logger.error({\n err,\n msg: `Error deleting duplicative ${searchSlug} documents.`,\n })\n }\n }\n\n if (foundDoc) {\n const { id: searchDocID } = foundDoc\n\n // Check if document is trashed and delete from search\n const isTrashDocument = doc && 'deletedAt' in doc && doc.deletedAt\n\n if (isTrashDocument) {\n try {\n await payload.delete({\n id: searchDocID,\n collection: searchSlug,\n depth: 0,\n overrideAccess: true,\n req,\n })\n } catch (err: unknown) {\n payload.logger.error({\n err,\n msg: `Error deleting ${searchSlug} document for trashed doc.`,\n })\n }\n } else {\n if (doSync) {\n // update the doc normally\n try {\n await payload.update({\n id: searchDocID,\n collection: searchSlug,\n data: {\n ...dataToSave,\n priority: foundDoc.priority || defaultPriority,\n },\n depth: 0,\n locale: syncLocale,\n overrideAccess: true,\n req,\n })\n } catch (err: unknown) {\n payload.logger.error({ err, msg: `Error updating ${searchSlug} document.` })\n }\n }\n\n if (deleteDrafts && status === 'draft') {\n // Check to see if there's a published version of the doc\n // We don't want to remove the search doc if there is a published version but a new draft has been created\n const {\n docs: [docWithPublish],\n } = await payload.find({\n collection,\n depth: 0,\n draft: false,\n limit: 1,\n locale: syncLocale,\n overrideAccess: true,\n pagination: false,\n req,\n where: {\n and: [\n {\n _status: {\n equals: 'published',\n },\n },\n {\n id: {\n equals: id,\n },\n },\n ],\n },\n })\n\n if (!docWithPublish) {\n // do not include draft docs in search results, so delete the record\n try {\n await payload.delete({\n id: searchDocID,\n collection: searchSlug,\n depth: 0,\n overrideAccess: true,\n req,\n })\n } catch (err: unknown) {\n payload.logger.error({ err, msg: `Error deleting ${searchSlug} document.` })\n }\n }\n }\n }\n } else if (doSync) {\n try {\n await payload.create({\n collection: searchSlug,\n data: {\n ...dataToSave,\n priority: defaultPriority,\n },\n depth: 0,\n locale: syncLocale,\n overrideAccess: true,\n req,\n })\n } catch (err: unknown) {\n payload.logger.error({ err, msg: `Error creating ${searchSlug} document.` })\n }\n }\n } catch (err: unknown) {\n payload.logger.error({ err, msg: `Error finding ${searchSlug} document.` })\n }\n }\n } catch (err: unknown) {\n payload.logger.error({\n err,\n msg: `Error syncing ${searchSlug} document related to ${collection} with id: '${id}'.`,\n })\n\n if (onSyncError) {\n onSyncError()\n }\n }\n\n return doc\n}\n"],"names":["syncDocAsSearchIndex","collection","doc","locale","onSyncError","operation","pluginConfig","req","payload","id","_status","status","title","beforeSync","defaultPriorities","deleteDrafts","searchOverrides","syncDrafts","searchSlug","slug","syncLocale","undefined","skipSync","collectionSlug","err","logger","error","msg","dataToSave","relationTo","value","docKeyPrefix","docKey","config","localization","syncedDocsSet","context","Set","has","add","docToSyncWith","isTrashDocument","deletedAt","findByID","overrideAccess","trash","originalDoc","searchDoc","defaultPriority","priority","doSync","create","data","depth","searchDocQuery","find","where","equals","docs","foundDoc","duplicativeDocs","length","duplicativeDocIDs","map","delete","in","searchDocID","update","docWithPublish","draft","limit","pagination","and"],"mappings":"AAEA,OAAO,MAAMA,uBAAuB,OAAO,EACzCC,UAAU,EACVC,GAAG,EACHC,MAAM,EACNC,WAAW,EACXC,SAAS,EACTC,YAAY,EACZC,KAAK,EAAEC,OAAO,EAAE,EAChBD,GAAG,EACS;IACZ,MAAM,EAAEE,EAAE,EAAEC,SAASC,MAAM,EAAEC,KAAK,EAAE,GAAGV,OAAO,CAAC;IAE/C,MAAM,EAAEW,UAAU,EAAEC,iBAAiB,EAAEC,YAAY,EAAEC,eAAe,EAAEC,UAAU,EAAE,GAAGX;IAErF,MAAMY,aAAaF,iBAAiBG,QAAQ;IAE5C,wBAAwB;IACxB,MAAMC,aAAajB,UAAUI,IAAIJ,MAAM,IAAIkB;IAE3C,IAAI,OA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AAC,cAAc,EAAET,WAAW,qBAAqB,EAAEjB,WAAW,WAAW,EAAEQ,GAAG,EAAE,CAAC;QACxF;QAEA,IAAIL,aAAa;YACfA;QACF;IACF;IAEA,OAAOF;AACT,EAAC"}
|
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.31ba7ee",
|
|
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/next": "4.0.0-internal.
|
|
54
|
-
"@payloadcms/ui": "4.0.0-internal.
|
|
53
|
+
"@payloadcms/next": "4.0.0-internal.31ba7ee",
|
|
54
|
+
"@payloadcms/ui": "4.0.0-internal.31ba7ee"
|
|
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.31ba7ee"
|
|
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.31ba7ee"
|
|
66
66
|
},
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
|
|
75
75
|
"build:types": "tsc --emitDeclarationOnly --outDir dist",
|
|
76
76
|
"clean": "rimraf -g {dist,*.tsbuildinfo}",
|
|
77
|
-
"copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/",
|
|
77
|
+
"copyfiles": "copyfiles -u 1 -e \"**/*.spec.*\" \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/",
|
|
78
78
|
"lint": "eslint .",
|
|
79
79
|
"lint:fix": "eslint . --fix",
|
|
80
80
|
"test": "echo \"Error: no tests specified\""
|