@rubixstudios/payload-typesense 1.0.9 → 1.0.11
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/components/HeadlessSearchInput.d.ts +9 -1
- package/dist/components/HeadlessSearchInput.d.ts.map +1 -1
- package/dist/components/HeadlessSearchInput.js +18 -31
- package/dist/components/themes/themes.js +2 -2
- package/dist/components/themes/utils.d.ts.map +1 -1
- package/dist/components/themes/utils.js +3 -2
- package/dist/lib/hooks.js +0 -2
- package/dist/lib/initialization.d.ts.map +1 -1
- package/dist/lib/initialization.js +0 -13
- package/package.json +3 -3
|
@@ -18,6 +18,10 @@ export interface HeadlessSearchInputProps<T = Record<string, unknown>> extends B
|
|
|
18
18
|
* Number of results to show per page
|
|
19
19
|
*/
|
|
20
20
|
perPage?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Show date in search results
|
|
23
|
+
*/
|
|
24
|
+
renderDate?: boolean;
|
|
21
25
|
/**
|
|
22
26
|
* Custom render function for error state
|
|
23
27
|
*/
|
|
@@ -39,6 +43,10 @@ export interface HeadlessSearchInputProps<T = Record<string, unknown>> extends B
|
|
|
39
43
|
* Custom render function for loading state
|
|
40
44
|
*/
|
|
41
45
|
renderLoading?: () => React.ReactNode;
|
|
46
|
+
/**
|
|
47
|
+
* Show match percentage in search results
|
|
48
|
+
*/
|
|
49
|
+
renderMatchPercentage?: boolean;
|
|
42
50
|
/**
|
|
43
51
|
* Custom render function for no results
|
|
44
52
|
*/
|
|
@@ -82,7 +90,7 @@ export interface HeadlessSearchInputProps<T = Record<string, unknown>> extends B
|
|
|
82
90
|
*/
|
|
83
91
|
theme?: string | ThemeConfig;
|
|
84
92
|
}
|
|
85
|
-
declare const HeadlessSearchInput: <T = Record<string, unknown>>({ baseUrl, className, collection, collections, debounceMs, enableSuggestions: _enableSuggestions, errorClassName, inputClassName, inputWrapperClassName, minQueryLength, noResultsClassName, onResultClick, onResults, onSearch, perPage, placeholder, renderError, renderInput, renderNoResults, renderResult, renderResultsHeader, resultItemClassName, resultsClassName, resultsContainerClassName, resultsHeaderClassName, resultsListClassName, showLoading, showResultCount, showSearchTime, theme, }: HeadlessSearchInputProps<T>) => React.ReactElement;
|
|
93
|
+
declare const HeadlessSearchInput: <T = Record<string, unknown>>({ baseUrl, className, collection, collections, debounceMs, enableSuggestions: _enableSuggestions, errorClassName, inputClassName, inputWrapperClassName, minQueryLength, noResultsClassName, onResultClick, onResults, onSearch, perPage, placeholder, renderDate, renderError, renderInput, renderMatchPercentage, renderNoResults, renderResult, renderResultsHeader, resultItemClassName, resultsClassName, resultsContainerClassName, resultsHeaderClassName, resultsListClassName, showLoading, showResultCount, showSearchTime, theme, }: HeadlessSearchInputProps<T>) => React.ReactElement;
|
|
86
94
|
export default HeadlessSearchInput;
|
|
87
95
|
export { HeadlessSearchInput };
|
|
88
96
|
//# sourceMappingURL=HeadlessSearchInput.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeadlessSearchInput.d.ts","sourceRoot":"","sources":["../../src/components/HeadlessSearchInput.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmD,MAAM,OAAO,CAAA;AAEvE,OAAO,KAAK,EAAE,oBAAoB,EAAkB,YAAY,EAAE,MAAM,iBAAiB,CAAA;AACzF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAIpD,MAAM,WAAW,wBAAwB,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CACnE,SAAQ,oBAAoB,CAAC,CAAC,CAAC;IAC/B;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,WAAW,CAAC,EAAE,CAAC,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,MAAM,GAAG,WAAW,CAAA;CAC7B;AAED,QAAA,MAAM,mBAAmB,GAAI,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAG,ghBAiCxD,wBAAwB,CAAC,CAAC,CAAC,KAAG,KAAK,CAAC,YAgtBtC,CAAA;AAED,eAAe,mBAAmB,CAAA;AAClC,OAAO,EAAE,mBAAmB,EAAE,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { useThemeConfig } from './themes/hooks.js';
|
|
4
|
-
const HeadlessSearchInput = ({ baseUrl, className = '', collection, collections, debounceMs = 300, enableSuggestions: _enableSuggestions = true, errorClassName = '', inputClassName = '', inputWrapperClassName = '', minQueryLength = 2, noResultsClassName = '', onResultClick, onResults, onSearch, perPage = 10, placeholder = 'Search...', renderError, renderInput, renderNoResults, renderResult, renderResultsHeader, resultItemClassName = '', resultsClassName = '', resultsContainerClassName = '', resultsHeaderClassName = '', resultsListClassName = '', showLoading = true, showResultCount = true, showSearchTime = true, theme = 'modern' })=>{
|
|
4
|
+
const HeadlessSearchInput = ({ baseUrl, className = '', collection, collections, debounceMs = 300, enableSuggestions: _enableSuggestions = true, errorClassName = '', inputClassName = '', inputWrapperClassName = '', minQueryLength = 2, noResultsClassName = '', onResultClick, onResults, onSearch, perPage = 10, placeholder = 'Search...', renderDate = true, renderError, renderInput, renderMatchPercentage = true, renderNoResults, renderResult, renderResultsHeader, resultItemClassName = '', resultsClassName = '', resultsContainerClassName = '', resultsHeaderClassName = '', resultsListClassName = '', showLoading = true, showResultCount = true, showSearchTime = true, theme = 'modern' })=>{
|
|
5
5
|
const [query, setQuery] = useState('');
|
|
6
6
|
const [results, setResults] = useState(null);
|
|
7
7
|
const [isLoading, setIsLoading] = useState(false);
|
|
@@ -225,12 +225,12 @@ const HeadlessSearchInput = ({ baseUrl, className = '', collection, collections,
|
|
|
225
225
|
style: {
|
|
226
226
|
alignItems: 'flex-start',
|
|
227
227
|
display: 'flex',
|
|
228
|
-
gap: '12px'
|
|
228
|
+
gap: '12px',
|
|
229
|
+
padding: '6px'
|
|
229
230
|
}
|
|
230
231
|
}, /*#__PURE__*/ React.createElement("div", {
|
|
231
232
|
style: {
|
|
232
|
-
flexShrink: 0
|
|
233
|
-
marginTop: '4px'
|
|
233
|
+
flexShrink: 0
|
|
234
234
|
}
|
|
235
235
|
}, /*#__PURE__*/ React.createElement("div", {
|
|
236
236
|
style: {
|
|
@@ -261,7 +261,7 @@ const HeadlessSearchInput = ({ baseUrl, className = '', collection, collections,
|
|
|
261
261
|
style: {
|
|
262
262
|
color: themeConfig.theme.colors.titleText,
|
|
263
263
|
fontFamily: themeConfig.theme.typography.fontFamily,
|
|
264
|
-
fontSize: themeConfig.theme.typography.
|
|
264
|
+
fontSize: themeConfig.theme.typography.fontSizeBase,
|
|
265
265
|
fontWeight: themeConfig.theme.typography.fontWeightSemibold,
|
|
266
266
|
lineHeight: themeConfig.theme.typography.lineHeightTight,
|
|
267
267
|
margin: 0,
|
|
@@ -269,7 +269,7 @@ const HeadlessSearchInput = ({ baseUrl, className = '', collection, collections,
|
|
|
269
269
|
textOverflow: 'ellipsis',
|
|
270
270
|
whiteSpace: 'nowrap'
|
|
271
271
|
}
|
|
272
|
-
}, result.document?.title || result.document?.name || result.title || 'Untitled'), typeof result.text_match === 'number' && !isNaN(result.text_match) && /*#__PURE__*/ React.createElement("span", {
|
|
272
|
+
}, result.document?.title || result.document?.name || result.title || 'Untitled'), renderMatchPercentage && typeof result.text_match === 'number' && !isNaN(result.text_match) && /*#__PURE__*/ React.createElement("span", {
|
|
273
273
|
style: {
|
|
274
274
|
alignItems: 'center',
|
|
275
275
|
backgroundColor: themeConfig.theme.colors.scoreBadge,
|
|
@@ -289,6 +289,7 @@ const HeadlessSearchInput = ({ baseUrl, className = '', collection, collections,
|
|
|
289
289
|
color: themeConfig.theme.colors.descriptionText,
|
|
290
290
|
display: '-webkit-box',
|
|
291
291
|
fontSize: themeConfig.theme.typography.fontSizeSm,
|
|
292
|
+
fontWeight: themeConfig.theme.typography.fontWeightNormal,
|
|
292
293
|
lineHeight: themeConfig.theme.typography.lineHeightNormal,
|
|
293
294
|
marginTop: '4px',
|
|
294
295
|
overflow: 'hidden',
|
|
@@ -304,7 +305,7 @@ const HeadlessSearchInput = ({ baseUrl, className = '', collection, collections,
|
|
|
304
305
|
gap: '12px',
|
|
305
306
|
marginTop: '8px'
|
|
306
307
|
}
|
|
307
|
-
}, /*#__PURE__*/ React.createElement("span", {
|
|
308
|
+
}, result.collection && /*#__PURE__*/ React.createElement("span", {
|
|
308
309
|
style: {
|
|
309
310
|
alignItems: 'center',
|
|
310
311
|
display: 'inline-flex'
|
|
@@ -321,7 +322,7 @@ const HeadlessSearchInput = ({ baseUrl, className = '', collection, collections,
|
|
|
321
322
|
clipRule: "evenodd",
|
|
322
323
|
d: "M3 4a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm0 4a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm0 4a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm0 4a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1z",
|
|
323
324
|
fillRule: "evenodd"
|
|
324
|
-
})), result.collection), (result.document?.updatedAt || result.updatedAt) && /*#__PURE__*/ React.createElement("span", {
|
|
325
|
+
})), result.collection), renderDate && (result.document?.updatedAt || result.updatedAt) && /*#__PURE__*/ React.createElement("span", {
|
|
325
326
|
style: {
|
|
326
327
|
alignItems: 'center',
|
|
327
328
|
display: 'inline-flex'
|
|
@@ -338,27 +339,7 @@ const HeadlessSearchInput = ({ baseUrl, className = '', collection, collections,
|
|
|
338
339
|
clipRule: "evenodd",
|
|
339
340
|
d: "M10 18a8 8 0 100-16 8 8 0 000 16zm1-12a1 1 0 10-2 0v4a1 1 0 00.293.707l2.828 2.829a1 1 0 101.415-1.415L11 9.586V6z",
|
|
340
341
|
fillRule: "evenodd"
|
|
341
|
-
})), new Date(result.document?.updatedAt || result.updatedAt).toLocaleDateString())))
|
|
342
|
-
style: {
|
|
343
|
-
flexShrink: 0,
|
|
344
|
-
opacity: 0,
|
|
345
|
-
transition: `opacity ${themeConfig.theme.animations.transitionNormal} ${themeConfig.theme.animations.easeInOut}`
|
|
346
|
-
}
|
|
347
|
-
}, /*#__PURE__*/ React.createElement("svg", {
|
|
348
|
-
fill: "none",
|
|
349
|
-
stroke: "currentColor",
|
|
350
|
-
style: {
|
|
351
|
-
color: themeConfig.theme.colors.metaText,
|
|
352
|
-
height: '16px',
|
|
353
|
-
width: '16px'
|
|
354
|
-
},
|
|
355
|
-
viewBox: "0 0 24 24"
|
|
356
|
-
}, /*#__PURE__*/ React.createElement("path", {
|
|
357
|
-
d: "M9 5l7 7-7 7",
|
|
358
|
-
strokeLinecap: "round",
|
|
359
|
-
strokeLinejoin: "round",
|
|
360
|
-
strokeWidth: 2
|
|
361
|
-
}))))));
|
|
342
|
+
})), new Date(result.document?.updatedAt || result.updatedAt).toLocaleDateString()))))));
|
|
362
343
|
};
|
|
363
344
|
const defaultRenderNoResults = (_query)=>/*#__PURE__*/ React.createElement("div", {
|
|
364
345
|
className: `${noResultsClassName}`,
|
|
@@ -556,7 +537,12 @@ const HeadlessSearchInput = ({ baseUrl, className = '', collection, collections,
|
|
|
556
537
|
top: '50%',
|
|
557
538
|
transform: 'translateY(-50%)'
|
|
558
539
|
}
|
|
559
|
-
}, /*#__PURE__*/ React.createElement("
|
|
540
|
+
}, /*#__PURE__*/ React.createElement("style", null, `
|
|
541
|
+
@keyframes spin {
|
|
542
|
+
0% { transform: rotate(0deg); }
|
|
543
|
+
100% { transform: rotate(360deg); }
|
|
544
|
+
}
|
|
545
|
+
`), /*#__PURE__*/ React.createElement("div", {
|
|
560
546
|
"data-testid": "loading-spinner",
|
|
561
547
|
style: {
|
|
562
548
|
animation: `spin 1s linear infinite`,
|
|
@@ -566,7 +552,7 @@ const HeadlessSearchInput = ({ baseUrl, className = '', collection, collections,
|
|
|
566
552
|
height: '16px',
|
|
567
553
|
width: '16px'
|
|
568
554
|
}
|
|
569
|
-
}))), isOpen && /*#__PURE__*/ React.createElement("div", {
|
|
555
|
+
}))), isOpen && results && /*#__PURE__*/ React.createElement("div", {
|
|
570
556
|
className: `${resultsContainerClassName}`,
|
|
571
557
|
ref: resultsRef,
|
|
572
558
|
style: {
|
|
@@ -580,6 +566,7 @@ const HeadlessSearchInput = ({ baseUrl, className = '', collection, collections,
|
|
|
580
566
|
marginTop: '10px',
|
|
581
567
|
maxHeight: themeConfig.theme.spacing.resultsMaxHeight,
|
|
582
568
|
overflow: 'hidden',
|
|
569
|
+
padding: '1px',
|
|
583
570
|
position: 'absolute',
|
|
584
571
|
right: '0',
|
|
585
572
|
top: '100%',
|
|
@@ -26,10 +26,10 @@ const baseTheme = {
|
|
|
26
26
|
inputPadding: "0.5rem 0.75rem",
|
|
27
27
|
itemBorderRadius: "0",
|
|
28
28
|
itemMargin: "0",
|
|
29
|
-
itemPadding: "0.
|
|
29
|
+
itemPadding: "0.5rem",
|
|
30
30
|
metaFontSize: "0.75rem",
|
|
31
31
|
metaPadding: "0.5rem 0",
|
|
32
|
-
resultsBorderRadius: "0
|
|
32
|
+
resultsBorderRadius: "0.5rem",
|
|
33
33
|
resultsMaxHeight: "24rem",
|
|
34
34
|
resultsPadding: "0"
|
|
35
35
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/themes/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAIlE;;GAEG;AACH,wBAAgB,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,KAAK,CAEjD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,GAAG,KAAK,CA2B3D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CACnC,KAAK,EAAE,KAAK,EACZ,MAAM,GAAE,OAAO,CAAC,WAAW,CAAM,GAC/B,YAAY,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/themes/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAIlE;;GAEG;AACH,wBAAgB,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,KAAK,CAEjD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,GAAG,KAAK,CA2B3D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CACnC,KAAK,EAAE,KAAK,EACZ,MAAM,GAAE,OAAO,CAAC,WAAW,CAAM,GAC/B,YAAY,CAiXd;AAED;;GAEG;AACH,wBAAgB,UAAU,CACzB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,GACd,MAAM,CAaR;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAMjD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAElD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAgCtE"}
|
|
@@ -66,7 +66,8 @@ import { defaultTheme, themes } from "./themes.js";
|
|
|
66
66
|
borderRadius: enableRoundedCorners ? theme.spacing.resultsBorderRadius : "0",
|
|
67
67
|
boxShadow: enableShadows ? theme.shadows.shadowLg : "none",
|
|
68
68
|
left: "0",
|
|
69
|
-
|
|
69
|
+
marginBottom: "2px",
|
|
70
|
+
marginTop: "2px",
|
|
70
71
|
maxHeight: theme.spacing.resultsMaxHeight,
|
|
71
72
|
overflowY: "auto",
|
|
72
73
|
position: "absolute",
|
|
@@ -132,7 +133,7 @@ import { defaultTheme, themes } from "./themes.js";
|
|
|
132
133
|
padding: theme.spacing.headerPadding
|
|
133
134
|
});
|
|
134
135
|
const resultsListStyles = css({
|
|
135
|
-
padding: "
|
|
136
|
+
padding: "4px"
|
|
136
137
|
});
|
|
137
138
|
// Result item styles
|
|
138
139
|
const resultItemStyles = css({
|
package/dist/lib/hooks.js
CHANGED
|
@@ -37,7 +37,6 @@ const syncDocumentToTypesense = async (typesenseClient, collectionSlug, doc, ope
|
|
|
37
37
|
await typesenseClient.collections(collectionSlug).documents().upsert(typesenseDoc);
|
|
38
38
|
// Document synced successfully
|
|
39
39
|
} catch (error) {
|
|
40
|
-
// Handle document sync error
|
|
41
40
|
// Log the problematic document for debugging
|
|
42
41
|
if (error.message.includes("validation")) {
|
|
43
42
|
// Log problematic document details
|
|
@@ -47,7 +46,6 @@ const syncDocumentToTypesense = async (typesenseClient, collectionSlug, doc, ope
|
|
|
47
46
|
const deleteDocumentFromTypesense = async (typesenseClient, collectionSlug, docId)=>{
|
|
48
47
|
try {
|
|
49
48
|
await typesenseClient.collections(collectionSlug).documents(docId).delete();
|
|
50
|
-
// Document deleted successfully
|
|
51
49
|
} catch (_error) {
|
|
52
50
|
// Handle document deletion error
|
|
53
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialization.d.ts","sourceRoot":"","sources":["../../src/lib/initialization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,KAAK,SAAS,MAAM,WAAW,CAAA;AAEtC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AASxD,eAAO,MAAM,8BAA8B,GAC1C,SAAS,OAAO,EAChB,iBAAiB,SAAS,CAAC,MAAM,EACjC,eAAe,qBAAqB,
|
|
1
|
+
{"version":3,"file":"initialization.d.ts","sourceRoot":"","sources":["../../src/lib/initialization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,KAAK,SAAS,MAAM,WAAW,CAAA;AAEtC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AASxD,eAAO,MAAM,8BAA8B,GAC1C,SAAS,OAAO,EAChB,iBAAiB,SAAS,CAAC,MAAM,EACjC,eAAe,qBAAqB,kBAiCpC,CAAA"}
|
|
@@ -5,14 +5,11 @@ export const initializeTypesenseCollections = async (payload, typesenseClient, p
|
|
|
5
5
|
// Validate configuration first
|
|
6
6
|
const validation = validateConfig(pluginOptions);
|
|
7
7
|
if (!validation.success) {
|
|
8
|
-
// Handle configuration validation error
|
|
9
8
|
throw new Error("Invalid plugin configuration");
|
|
10
9
|
}
|
|
11
|
-
// Configuration validated successfully
|
|
12
10
|
// Test Typesense connection first
|
|
13
11
|
const isConnected = await testTypesenseConnection(typesenseClient);
|
|
14
12
|
if (!isConnected) {
|
|
15
|
-
// Typesense connection failed
|
|
16
13
|
return;
|
|
17
14
|
}
|
|
18
15
|
// Initialize Typesense collections
|
|
@@ -27,29 +24,23 @@ export const initializeTypesenseCollections = async (payload, typesenseClient, p
|
|
|
27
24
|
}
|
|
28
25
|
}
|
|
29
26
|
}
|
|
30
|
-
// Collections initialized successfully
|
|
31
27
|
};
|
|
32
28
|
const initializeCollection = async (payload, typesenseClient, collectionSlug, config)=>{
|
|
33
29
|
// Get the collection config from Payload
|
|
34
30
|
const collection = payload.collections[collectionSlug];
|
|
35
31
|
if (!collection) {
|
|
36
|
-
// Collection not found in Payload
|
|
37
32
|
return;
|
|
38
33
|
}
|
|
39
34
|
// Create Typesense schema
|
|
40
35
|
const schema = mapCollectionToTypesenseSchema(collection, collectionSlug, config);
|
|
41
|
-
// Create schema for collection
|
|
42
36
|
try {
|
|
43
37
|
// Check if collection exists
|
|
44
38
|
await typesenseClient.collections(collectionSlug).retrieve();
|
|
45
|
-
// Collection already exists
|
|
46
39
|
} catch (_error) {
|
|
47
40
|
// Collection doesn't exist, create it
|
|
48
41
|
try {
|
|
49
42
|
await typesenseClient.collections().create(schema);
|
|
50
|
-
// Collection created successfully
|
|
51
43
|
} catch (_createError) {
|
|
52
|
-
// Handle collection creation error
|
|
53
44
|
return;
|
|
54
45
|
}
|
|
55
46
|
}
|
|
@@ -64,7 +55,6 @@ const syncExistingDocuments = async (payload, typesenseClient, collectionSlug, c
|
|
|
64
55
|
limit: 1000
|
|
65
56
|
});
|
|
66
57
|
if (docs.length === 0) {
|
|
67
|
-
// No documents to sync
|
|
68
58
|
return;
|
|
69
59
|
}
|
|
70
60
|
// Batch sync documents
|
|
@@ -76,12 +66,9 @@ const syncExistingDocuments = async (payload, typesenseClient, collectionSlug, c
|
|
|
76
66
|
const _importResult = await typesenseClient.collections(collectionSlug).documents().import(typesenseDocs, {
|
|
77
67
|
action: "upsert"
|
|
78
68
|
});
|
|
79
|
-
// Documents synced successfully
|
|
80
69
|
} catch (batchError) {
|
|
81
|
-
// Handle batch sync error
|
|
82
70
|
// Log detailed import results if available
|
|
83
71
|
if (batchError.importResults) {
|
|
84
|
-
// Handle import results error
|
|
85
72
|
// Try to sync documents individually to identify problematic ones
|
|
86
73
|
// Attempt individual document sync
|
|
87
74
|
for(let j = 0; j < typesenseDocs.length; j++){
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rubixstudios/payload-typesense",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"description": "A production-ready search plugin that integrates Typesense with Payload CMS, offering fast, typo-tolerant search with real-time synchronization. This fork by Rubix Studios reduces bloat and introduces targeted changes for improved performance, maintainability, and flexibility.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Rubix Studios <hello@rubixstudios.com.au> (https://rubixstudios.com.au)",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"@semantic-release/npm": "^12.0.2",
|
|
64
64
|
"@swc/cli": "^0.7.8",
|
|
65
65
|
"@swc/core": "^1.13.5",
|
|
66
|
-
"@types/react": "19.
|
|
67
|
-
"eslint": "^9.
|
|
66
|
+
"@types/react": "19.2.0",
|
|
67
|
+
"eslint": "^9.37.0",
|
|
68
68
|
"payload": "3.58.0",
|
|
69
69
|
"rimraf": "6.0.1",
|
|
70
70
|
"semantic-release": "^24.2.9",
|