@payloadcms/plugin-search 3.0.0-beta.59 → 3.0.0-beta.60
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 +55 -44
- package/dist/Search/index.js.map +1 -1
- package/dist/types.d.ts +9 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.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,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Search/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAS,MAAM,SAAS,CAAA;AAItD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAKrD,eAAO,MAAM,wBAAwB,iBAAkB,kBAAkB,KAAG,gBAuE3E,CAAA"}
|
package/dist/Search/index.js
CHANGED
|
@@ -1,11 +1,51 @@
|
|
|
1
|
-
import deepMerge from 'deepmerge';
|
|
2
1
|
import { LinkToDoc } from './ui/index.js';
|
|
3
2
|
// all settings can be overridden by the config
|
|
4
|
-
export const generateSearchCollection = (pluginConfig)=>
|
|
5
|
-
|
|
3
|
+
export const generateSearchCollection = (pluginConfig)=>{
|
|
4
|
+
const defaultFields = [
|
|
5
|
+
{
|
|
6
|
+
name: 'title',
|
|
7
|
+
type: 'text',
|
|
8
|
+
admin: {
|
|
9
|
+
readOnly: true
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
name: 'priority',
|
|
14
|
+
type: 'number',
|
|
15
|
+
admin: {
|
|
16
|
+
position: 'sidebar'
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'doc',
|
|
21
|
+
type: 'relationship',
|
|
22
|
+
admin: {
|
|
23
|
+
position: 'sidebar',
|
|
24
|
+
readOnly: true
|
|
25
|
+
},
|
|
26
|
+
index: true,
|
|
27
|
+
maxDepth: 0,
|
|
28
|
+
relationTo: pluginConfig?.collections || [],
|
|
29
|
+
required: true
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'docUrl',
|
|
33
|
+
type: 'ui',
|
|
34
|
+
admin: {
|
|
35
|
+
components: {
|
|
36
|
+
Field: LinkToDoc
|
|
37
|
+
},
|
|
38
|
+
position: 'sidebar'
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
];
|
|
42
|
+
const newConfig = {
|
|
43
|
+
...pluginConfig?.searchOverrides || {},
|
|
44
|
+
slug: pluginConfig?.searchOverrides?.slug || 'search',
|
|
6
45
|
access: {
|
|
7
46
|
create: ()=>false,
|
|
8
|
-
read: ()=>true
|
|
47
|
+
read: ()=>true,
|
|
48
|
+
...pluginConfig?.searchOverrides?.access || {}
|
|
9
49
|
},
|
|
10
50
|
admin: {
|
|
11
51
|
defaultColumns: [
|
|
@@ -13,50 +53,21 @@ export const generateSearchCollection = (pluginConfig)=>deepMerge({
|
|
|
13
53
|
],
|
|
14
54
|
description: '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.',
|
|
15
55
|
enableRichTextRelationship: false,
|
|
16
|
-
useAsTitle: 'title'
|
|
56
|
+
useAsTitle: 'title',
|
|
57
|
+
...pluginConfig?.searchOverrides?.admin || {}
|
|
58
|
+
},
|
|
59
|
+
fields: pluginConfig?.searchOverrides?.fields && typeof pluginConfig?.searchOverrides?.fields === 'function' ? pluginConfig?.searchOverrides.fields({
|
|
60
|
+
defaultFields
|
|
61
|
+
}) : defaultFields,
|
|
62
|
+
hooks: {
|
|
63
|
+
...pluginConfig?.searchOverrides?.hooks || {}
|
|
17
64
|
},
|
|
18
|
-
fields: [
|
|
19
|
-
{
|
|
20
|
-
name: 'title',
|
|
21
|
-
type: 'text',
|
|
22
|
-
admin: {
|
|
23
|
-
readOnly: true
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
name: 'priority',
|
|
28
|
-
type: 'number',
|
|
29
|
-
admin: {
|
|
30
|
-
position: 'sidebar'
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
name: 'doc',
|
|
35
|
-
type: 'relationship',
|
|
36
|
-
admin: {
|
|
37
|
-
position: 'sidebar',
|
|
38
|
-
readOnly: true
|
|
39
|
-
},
|
|
40
|
-
index: true,
|
|
41
|
-
maxDepth: 0,
|
|
42
|
-
relationTo: pluginConfig?.collections || [],
|
|
43
|
-
required: true
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
name: 'docUrl',
|
|
47
|
-
type: 'ui',
|
|
48
|
-
admin: {
|
|
49
|
-
components: {
|
|
50
|
-
Field: LinkToDoc
|
|
51
|
-
},
|
|
52
|
-
position: 'sidebar'
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
],
|
|
56
65
|
labels: {
|
|
57
66
|
plural: 'Search Results',
|
|
58
67
|
singular: 'Search Result'
|
|
59
68
|
}
|
|
60
|
-
}
|
|
69
|
+
};
|
|
70
|
+
return newConfig;
|
|
71
|
+
};
|
|
61
72
|
|
|
62
73
|
//# sourceMappingURL=index.js.map
|
package/dist/Search/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Search/index.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload'\n\nimport deepMerge from 'deepmerge'\n\nimport type { SearchPluginConfig } from '../types.js'\n\nimport { LinkToDoc } from './ui/index.js'\n\n// all settings can be overridden by the config\nexport const generateSearchCollection = (pluginConfig: SearchPluginConfig): CollectionConfig
|
|
1
|
+
{"version":3,"sources":["../../src/Search/index.ts"],"sourcesContent":["import type { CollectionConfig, Field } from 'payload'\n\nimport deepMerge from 'deepmerge'\n\nimport type { SearchPluginConfig } from '../types.js'\n\nimport { LinkToDoc } from './ui/index.js'\n\n// all settings can be overridden by the config\nexport const generateSearchCollection = (pluginConfig: SearchPluginConfig): CollectionConfig => {\n const defaultFields: Field[] = [\n {\n name: 'title',\n type: 'text',\n admin: {\n readOnly: true,\n },\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: pluginConfig?.collections || [],\n required: true,\n },\n {\n name: 'docUrl',\n type: 'ui',\n admin: {\n components: {\n Field: LinkToDoc,\n },\n position: 'sidebar',\n },\n },\n ]\n\n const newConfig: CollectionConfig = {\n ...(pluginConfig?.searchOverrides || {}),\n slug: pluginConfig?.searchOverrides?.slug || 'search',\n access: {\n create: (): boolean => false,\n read: (): boolean => true,\n ...(pluginConfig?.searchOverrides?.access || {}),\n },\n admin: {\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 fields:\n pluginConfig?.searchOverrides?.fields &&\n typeof pluginConfig?.searchOverrides?.fields === 'function'\n ? pluginConfig?.searchOverrides.fields({ defaultFields })\n : defaultFields,\n hooks: {\n ...(pluginConfig?.searchOverrides?.hooks || {}),\n },\n labels: {\n plural: 'Search Results',\n singular: 'Search Result',\n },\n }\n\n return newConfig\n}\n"],"names":["LinkToDoc","generateSearchCollection","pluginConfig","defaultFields","name","type","admin","readOnly","position","index","maxDepth","relationTo","collections","required","components","Field","newConfig","searchOverrides","slug","access","create","read","defaultColumns","description","enableRichTextRelationship","useAsTitle","fields","hooks","labels","plural","singular"],"mappings":"AAMA,SAASA,SAAS,QAAQ,gBAAe;AAEzC,+CAA+C;AAC/C,OAAO,MAAMC,2BAA2B,CAACC;IACvC,MAAMC,gBAAyB;QAC7B;YACEC,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLC,UAAU;YACZ;QACF;QACA;YACEH,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLE,UAAU;YACZ;QACF;QACA;YACEJ,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLE,UAAU;gBACVD,UAAU;YACZ;YACAE,OAAO;YACPC,UAAU;YACVC,YAAYT,cAAcU,eAAe,EAAE;YAC3CC,UAAU;QACZ;QACA;YACET,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLQ,YAAY;oBACVC,OAAOf;gBACT;gBACAQ,UAAU;YACZ;QACF;KACD;IAED,MAAMQ,YAA8B;QAClC,GAAId,cAAce,mBAAmB,CAAC,CAAC;QACvCC,MAAMhB,cAAce,iBAAiBC,QAAQ;QAC7CC,QAAQ;YACNC,QAAQ,IAAe;YACvBC,MAAM,IAAe;YACrB,GAAInB,cAAce,iBAAiBE,UAAU,CAAC,CAAC;QACjD;QACAb,OAAO;YACLgB,gBAAgB;gBAAC;aAAQ;YACzBC,aACE;YACFC,4BAA4B;YAC5BC,YAAY;YACZ,GAAIvB,cAAce,iBAAiBX,SAAS,CAAC,CAAC;QAChD;QACAoB,QACExB,cAAce,iBAAiBS,UAC/B,OAAOxB,cAAce,iBAAiBS,WAAW,aAC7CxB,cAAce,gBAAgBS,OAAO;YAAEvB;QAAc,KACrDA;QACNwB,OAAO;YACL,GAAIzB,cAAce,iBAAiBU,SAAS,CAAC,CAAC;QAChD;QACAC,QAAQ;YACNC,QAAQ;YACRC,UAAU;QACZ;IACF;IAEA,OAAOd;AACT,EAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CollectionAfterChangeHook, CollectionConfig, Payload, PayloadRequest } from 'payload';
|
|
1
|
+
import type { CollectionAfterChangeHook, CollectionConfig, Field, Payload, PayloadRequest } from 'payload';
|
|
2
2
|
export type DocToSync = {
|
|
3
3
|
[key: string]: any;
|
|
4
4
|
doc: {
|
|
@@ -15,6 +15,9 @@ export type BeforeSync = (args: {
|
|
|
15
15
|
req: PayloadRequest;
|
|
16
16
|
searchDoc: DocToSync;
|
|
17
17
|
}) => DocToSync | Promise<DocToSync>;
|
|
18
|
+
export type FieldsOverride = (args: {
|
|
19
|
+
defaultFields: Field[];
|
|
20
|
+
}) => Field[];
|
|
18
21
|
export type SearchPluginConfig = {
|
|
19
22
|
beforeSync?: BeforeSync;
|
|
20
23
|
collections?: string[];
|
|
@@ -22,11 +25,13 @@ export type SearchPluginConfig = {
|
|
|
22
25
|
[collection: string]: ((doc: any) => Promise<number> | number) | number;
|
|
23
26
|
};
|
|
24
27
|
deleteDrafts?: boolean;
|
|
25
|
-
searchOverrides?:
|
|
28
|
+
searchOverrides?: {
|
|
29
|
+
fields?: FieldsOverride;
|
|
30
|
+
} & Partial<Omit<CollectionConfig, 'fields'>>;
|
|
26
31
|
syncDrafts?: boolean;
|
|
27
32
|
};
|
|
28
|
-
export type SyncWithSearch = (Args:
|
|
33
|
+
export type SyncWithSearch = (Args: {
|
|
29
34
|
collection: string;
|
|
30
35
|
pluginConfig: SearchPluginConfig;
|
|
31
|
-
}) => ReturnType<CollectionAfterChangeHook>;
|
|
36
|
+
} & Omit<Parameters<CollectionAfterChangeHook>[0], 'collection'>) => ReturnType<CollectionAfterChangeHook>;
|
|
32
37
|
//# sourceMappingURL=types.d.ts.map
|
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,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,gBAAgB,EAChB,KAAK,EACL,OAAO,EACP,cAAc,EACf,MAAM,SAAS,CAAA;AAEhB,MAAM,MAAM,SAAS,GAAG;IACtB,CAAC,GAAG,EAAE,MAAM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AC7D,UAAU,CAAC,yBAAyB,CAAC,CAAA"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n CollectionAfterChangeHook,\n CollectionConfig,\n Field,\n Payload,\n PayloadRequest,\n} from 'payload'\n\nexport type DocToSync = {\n [key: string]: any\n doc: {\n relationTo: string\n value: string\n }\n title: string\n}\n\nexport type BeforeSync = (args: {\n originalDoc: {\n [key: string]: any\n }\n payload: Payload\n req: PayloadRequest\n searchDoc: DocToSync\n}) => DocToSync | Promise<DocToSync>\n\nexport type FieldsOverride = (args: { defaultFields: Field[] }) => Field[]\n\nexport type SearchPluginConfig = {\n beforeSync?: BeforeSync\n collections?: string[]\n defaultPriorities?: {\n [collection: string]: ((doc: any) => Promise<number> | number) | number\n }\n deleteDrafts?: boolean\n searchOverrides?: { fields?: FieldsOverride } & Partial<Omit<CollectionConfig, 'fields'>>\n syncDrafts?: boolean\n}\n\n// Extend the `CollectionAfterChangeHook` with more function args\n// Convert the `collection` arg from `SanitizedCollectionConfig` to a string\nexport type SyncWithSearch = (\n Args: {\n collection: string\n pluginConfig: SearchPluginConfig\n } & Omit<Parameters<CollectionAfterChangeHook>[0], 'collection'>,\n) => ReturnType<CollectionAfterChangeHook>\n"],"names":[],"mappings":"AAuCA,iEAAiE;AACjE,4EAA4E;AAC5E,WAK0C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/plugin-search",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.60",
|
|
4
4
|
"description": "Search plugin for Payload",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"payload",
|
|
@@ -38,19 +38,19 @@
|
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"deepmerge": "4.3.1",
|
|
41
|
-
"@payloadcms/ui": "3.0.0-beta.
|
|
41
|
+
"@payloadcms/ui": "3.0.0-beta.60"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/express": "^4.17.9",
|
|
45
45
|
"@types/react": "npm:types-react@19.0.0-beta.2",
|
|
46
46
|
"@types/react-dom": "npm:types-react-dom@19.0.0-beta.2",
|
|
47
|
-
"
|
|
48
|
-
"
|
|
47
|
+
"payload": "3.0.0-beta.60",
|
|
48
|
+
"@payloadcms/eslint-config": "3.0.0-beta.59"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"react": "^19.0.0 || ^19.0.0-rc-f994737d14-20240522",
|
|
52
52
|
"react-dom": "^19.0.0 || ^19.0.0-rc-f994737d14-20240522",
|
|
53
|
-
"payload": "3.0.0-beta.
|
|
53
|
+
"payload": "3.0.0-beta.60"
|
|
54
54
|
},
|
|
55
55
|
"publishConfig": {
|
|
56
56
|
"registry": "https://registry.npmjs.org/"
|