@rubixstudios/payload-typesense 1.1.1 → 1.1.3

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.
Files changed (103) hide show
  1. package/README.md +2 -19
  2. package/dist/components/HeadlessSearchInput.d.ts +2 -92
  3. package/dist/components/HeadlessSearchInput.d.ts.map +1 -1
  4. package/dist/components/HeadlessSearchInput.js +23 -140
  5. package/dist/components/ThemeProvider.d.ts +3 -2
  6. package/dist/components/ThemeProvider.d.ts.map +1 -1
  7. package/dist/components/ThemeProvider.js +1 -1
  8. package/dist/components/index.d.ts +5 -5
  9. package/dist/components/index.d.ts.map +1 -1
  10. package/dist/components/index.js +3 -3
  11. package/dist/components/themes/hooks.d.ts +5 -5
  12. package/dist/components/themes/hooks.d.ts.map +1 -1
  13. package/dist/components/themes/hooks.js +16 -16
  14. package/dist/components/themes/index.d.ts +4 -4
  15. package/dist/components/themes/index.js +4 -4
  16. package/dist/components/themes/themes.d.ts +1 -1
  17. package/dist/components/themes/themes.d.ts.map +1 -1
  18. package/dist/components/themes/themes.js +109 -109
  19. package/dist/components/themes/types.d.ts.map +1 -1
  20. package/dist/components/themes/utils.d.ts +1 -1
  21. package/dist/components/themes/utils.d.ts.map +1 -1
  22. package/dist/components/themes/utils.js +140 -140
  23. package/dist/endpoints/handler/createAdvancedSearch.d.ts +5 -0
  24. package/dist/endpoints/handler/createAdvancedSearch.d.ts.map +1 -0
  25. package/dist/endpoints/handler/createAdvancedSearch.js +40 -0
  26. package/dist/endpoints/handler/createCollections.d.ts +4 -0
  27. package/dist/endpoints/handler/createCollections.d.ts.map +1 -0
  28. package/dist/endpoints/handler/createCollections.js +23 -0
  29. package/dist/endpoints/handler/createSearch.d.ts +5 -0
  30. package/dist/endpoints/handler/createSearch.d.ts.map +1 -0
  31. package/dist/endpoints/handler/createSearch.js +119 -0
  32. package/dist/endpoints/handler/createSuggest.d.ts +5 -0
  33. package/dist/endpoints/handler/createSuggest.d.ts.map +1 -0
  34. package/dist/endpoints/handler/createSuggest.js +50 -0
  35. package/dist/endpoints/health.d.ts +4 -10
  36. package/dist/endpoints/health.d.ts.map +1 -1
  37. package/dist/endpoints/health.js +45 -103
  38. package/dist/endpoints/search.d.ts +5 -6
  39. package/dist/endpoints/search.d.ts.map +1 -1
  40. package/dist/endpoints/search.js +26 -355
  41. package/dist/index.d.ts +5 -14
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +6 -105
  44. package/dist/lib/cache.d.ts +6 -27
  45. package/dist/lib/cache.d.ts.map +1 -1
  46. package/dist/lib/cache.js +11 -29
  47. package/dist/lib/client.d.ts +4 -0
  48. package/dist/lib/client.d.ts.map +1 -0
  49. package/dist/lib/{typesense-client.js → client.js} +10 -18
  50. package/dist/lib/headlessSearch.d.ts +89 -0
  51. package/dist/lib/headlessSearch.d.ts.map +1 -0
  52. package/dist/lib/headlessSearch.js +2 -0
  53. package/dist/lib/hooks.d.ts +12 -3
  54. package/dist/lib/hooks.d.ts.map +1 -1
  55. package/dist/lib/hooks.js +37 -37
  56. package/dist/lib/initialization.d.ts +4 -4
  57. package/dist/lib/initialization.d.ts.map +1 -1
  58. package/dist/lib/initialization.js +36 -49
  59. package/dist/lib/schema-mapper.d.ts +17 -7
  60. package/dist/lib/schema-mapper.d.ts.map +1 -1
  61. package/dist/lib/schema-mapper.js +55 -91
  62. package/dist/lib/{config-validation.d.ts → validation.d.ts} +17 -23
  63. package/dist/lib/validation.d.ts.map +1 -0
  64. package/dist/lib/validation.js +103 -0
  65. package/dist/{lib/types.d.ts → types.d.ts} +22 -5
  66. package/dist/types.d.ts.map +1 -0
  67. package/dist/utils/buildError.d.ts +2 -0
  68. package/dist/utils/buildError.d.ts.map +1 -0
  69. package/dist/utils/buildError.js +10 -0
  70. package/dist/utils/ensureCollection.d.ts +3 -0
  71. package/dist/utils/ensureCollection.d.ts.map +1 -0
  72. package/dist/utils/ensureCollection.js +13 -0
  73. package/dist/utils/extractText.d.ts +2 -0
  74. package/dist/utils/extractText.d.ts.map +1 -0
  75. package/dist/utils/extractText.js +20 -0
  76. package/dist/utils/getAllCollections.d.ts +9 -0
  77. package/dist/utils/getAllCollections.d.ts.map +1 -0
  78. package/dist/utils/getAllCollections.js +84 -0
  79. package/dist/utils/getCacheStats.d.ts +6 -0
  80. package/dist/utils/getCacheStats.d.ts.map +1 -0
  81. package/dist/utils/getCacheStats.js +9 -0
  82. package/dist/utils/getCollectionInfo.d.ts +3 -0
  83. package/dist/utils/getCollectionInfo.d.ts.map +1 -0
  84. package/dist/utils/getCollectionInfo.js +8 -0
  85. package/dist/utils/keyboard.d.ts +8 -0
  86. package/dist/utils/keyboard.d.ts.map +1 -0
  87. package/dist/utils/keyboard.js +41 -0
  88. package/dist/utils/testConnection.d.ts +3 -0
  89. package/dist/utils/testConnection.d.ts.map +1 -0
  90. package/dist/utils/testConnection.js +8 -0
  91. package/dist/utils/useDebounce.d.ts +2 -0
  92. package/dist/utils/useDebounce.d.ts.map +1 -0
  93. package/dist/utils/useDebounce.js +15 -0
  94. package/dist/utils/useSearch.d.ts +17 -0
  95. package/dist/utils/useSearch.d.ts.map +1 -0
  96. package/dist/utils/useSearch.js +78 -0
  97. package/package.json +13 -10
  98. package/dist/lib/config-validation.d.ts.map +0 -1
  99. package/dist/lib/config-validation.js +0 -174
  100. package/dist/lib/types.d.ts.map +0 -1
  101. package/dist/lib/typesense-client.d.ts +0 -5
  102. package/dist/lib/typesense-client.d.ts.map +0 -1
  103. /package/dist/{lib/types.js → types.js} +0 -0
@@ -1,4 +1,4 @@
1
- import { defaultTheme, themes } from "./themes.js";
1
+ import { defaultTheme, themes } from './themes.js';
2
2
  /**
3
3
  * Get a theme by name or return the default theme
4
4
  */ export function getTheme(themeName) {
@@ -7,7 +7,7 @@ import { defaultTheme, themes } from "./themes.js";
7
7
  /**
8
8
  * Merge theme configurations with custom overrides
9
9
  */ export function mergeThemeConfig(config) {
10
- const baseTheme = typeof config.theme === "string" ? getTheme(config.theme) : config.theme;
10
+ const baseTheme = typeof config.theme === 'string' ? getTheme(config.theme) : config.theme;
11
11
  return {
12
12
  ...baseTheme,
13
13
  animations: {
@@ -40,114 +40,114 @@ import { defaultTheme, themes } from "./themes.js";
40
40
  const enableRoundedCorners = config.enableRoundedCorners !== false;
41
41
  const css = (styles)=>{
42
42
  return Object.entries(styles).map(([key, value])=>{
43
- if (typeof value === "object" && value !== null) {
44
- const nested = Object.entries(value).map(([nestedKey, nestedValue])=>`${nestedKey.replace(/([A-Z])/g, "-$1").toLowerCase()}: ${nestedValue}`).join("; ");
45
- return `${key.replace(/([A-Z])/g, "-$1").toLowerCase()}: { ${nested} }`;
43
+ if (typeof value === 'object' && value !== null) {
44
+ const nested = Object.entries(value).map(([nestedKey, nestedValue])=>`${nestedKey.replace(/([A-Z])/g, '-$1').toLowerCase()}: ${nestedValue}`).join('; ');
45
+ return `${key.replace(/([A-Z])/g, '-$1').toLowerCase()}: { ${nested} }`;
46
46
  }
47
- return `${key.replace(/([A-Z])/g, "-$1").toLowerCase()}: ${value}`;
48
- }).join("; ");
47
+ return `${key.replace(/([A-Z])/g, '-$1').toLowerCase()}: ${value}`;
48
+ }).join('; ');
49
49
  };
50
50
  const containerStyles = css({
51
- margin: "0 auto",
52
- maxWidth: "600px",
53
- position: "relative",
54
- width: "100%"
51
+ margin: '0 auto',
52
+ maxWidth: '600px',
53
+ position: 'relative',
54
+ width: '100%'
55
55
  });
56
56
  const inputContainerStyles = css({
57
- position: "relative",
58
- width: "100%"
57
+ position: 'relative',
58
+ width: '100%'
59
59
  });
60
60
  const resultsContainerStyles = css({
61
61
  backgroundColor: theme.colors.resultsBackground,
62
62
  border: `1px solid ${theme.colors.resultsBorder}`,
63
- borderRadius: enableRoundedCorners ? theme.spacing.resultsBorderRadius : "0",
64
- boxShadow: enableShadows ? theme.shadows.shadowLg : "none",
65
- left: "0",
66
- marginBottom: "2px",
67
- marginTop: "2px",
63
+ borderRadius: enableRoundedCorners ? theme.spacing.resultsBorderRadius : '0',
64
+ boxShadow: enableShadows ? theme.shadows.shadowLg : 'none',
65
+ left: '0',
66
+ marginBottom: '2px',
67
+ marginTop: '2px',
68
68
  maxHeight: theme.spacing.resultsMaxHeight,
69
- overflowY: "auto",
70
- position: "absolute",
71
- right: "0",
72
- top: "100%",
73
- zIndex: "1000",
69
+ overflowY: 'auto',
70
+ position: 'absolute',
71
+ right: '0',
72
+ top: '100%',
73
+ zIndex: '1000',
74
74
  ...enableAnimations && {
75
- animation: "slideDown 0.2s ease-out"
75
+ animation: 'slideDown 0.2s ease-out'
76
76
  }
77
77
  });
78
78
  const inputStyles = css({
79
- "::placeholder": {
79
+ '::placeholder': {
80
80
  color: theme.colors.inputPlaceholder
81
81
  },
82
- ":disabled": {
82
+ ':disabled': {
83
83
  backgroundColor: theme.colors.inputBackground,
84
- cursor: "not-allowed",
85
- opacity: "0.6"
84
+ cursor: 'not-allowed',
85
+ opacity: '0.6'
86
86
  },
87
- ":focus": {
87
+ ':focus': {
88
88
  borderColor: theme.colors.inputBorderFocus,
89
- boxShadow: enableShadows ? `${theme.shadows.focusShadow} ${theme.shadows.focusShadowColor}` : "none"
89
+ boxShadow: enableShadows ? `${theme.shadows.focusShadow} ${theme.shadows.focusShadowColor}` : 'none'
90
90
  },
91
91
  backgroundColor: theme.colors.inputBackground,
92
92
  border: `2px solid ${theme.colors.inputBorder}`,
93
- borderRadius: enableRoundedCorners ? theme.spacing.inputBorderRadius : "0",
94
- boxShadow: "none",
93
+ borderRadius: enableRoundedCorners ? theme.spacing.inputBorderRadius : '0',
94
+ boxShadow: 'none',
95
95
  color: theme.colors.inputText,
96
96
  fontFamily: theme.typography.fontFamily,
97
97
  fontSize: theme.spacing.inputFontSize,
98
98
  fontWeight: theme.typography.fontWeightNormal,
99
99
  lineHeight: theme.typography.lineHeightNormal,
100
- outline: "none",
100
+ outline: 'none',
101
101
  padding: theme.spacing.inputPadding,
102
- transition: enableAnimations ? `all ${theme.animations.transitionNormal} ${theme.animations.easeInOut}` : "none",
103
- width: "100%"
102
+ transition: enableAnimations ? `all ${theme.animations.transitionNormal} ${theme.animations.easeInOut}` : 'none',
103
+ width: '100%'
104
104
  });
105
105
  const resultsStyles = css({
106
106
  backgroundColor: theme.colors.resultsBackground,
107
107
  border: `1px solid ${theme.colors.resultsBorder}`,
108
- borderRadius: enableRoundedCorners ? theme.spacing.resultsBorderRadius : "0",
109
- boxShadow: enableShadows ? theme.shadows.shadowLg : "none",
110
- left: "0",
108
+ borderRadius: enableRoundedCorners ? theme.spacing.resultsBorderRadius : '0',
109
+ boxShadow: enableShadows ? theme.shadows.shadowLg : 'none',
110
+ left: '0',
111
111
  maxHeight: theme.spacing.resultsMaxHeight,
112
- overflowY: "auto",
113
- position: "absolute",
114
- right: "0",
115
- top: "100%",
116
- zIndex: "1000"
112
+ overflowY: 'auto',
113
+ position: 'absolute',
114
+ right: '0',
115
+ top: '100%',
116
+ zIndex: '1000'
117
117
  });
118
118
  const resultsHeaderStyles = css({
119
- alignItems: "center",
119
+ alignItems: 'center',
120
120
  backgroundColor: theme.colors.headerBackground,
121
121
  borderBottom: `1px solid ${theme.colors.headerBorder}`,
122
122
  color: theme.colors.headerText,
123
- display: "flex",
123
+ display: 'flex',
124
124
  fontFamily: theme.typography.fontFamily,
125
125
  fontSize: theme.spacing.headerFontSize,
126
126
  fontWeight: theme.typography.fontWeightMedium,
127
- justifyContent: "space-between",
127
+ justifyContent: 'space-between',
128
128
  padding: theme.spacing.headerPadding
129
129
  });
130
130
  const resultsListStyles = css({
131
- padding: "4px"
131
+ padding: '4px'
132
132
  });
133
133
  const resultItemStyles = css({
134
- ":focus": {
134
+ ':focus': {
135
135
  backgroundColor: theme.colors.resultBackgroundFocus,
136
- boxShadow: enableShadows ? `inset 0 0 0 2px ${theme.colors.inputBorderFocus}` : "none"
136
+ boxShadow: enableShadows ? `inset 0 0 0 2px ${theme.colors.inputBorderFocus}` : 'none'
137
137
  },
138
- ":hover": {
138
+ ':hover': {
139
139
  backgroundColor: theme.colors.resultBackgroundHover,
140
- transform: enableAnimations ? "translateX(2px)" : "none"
140
+ transform: enableAnimations ? 'translateX(2px)' : 'none'
141
141
  },
142
- ":last-child": {
143
- borderBottom: "none"
142
+ ':last-child': {
143
+ borderBottom: 'none'
144
144
  },
145
145
  backgroundColor: theme.colors.resultBackground,
146
146
  borderBottom: `1px solid ${theme.colors.resultBorder}`,
147
- cursor: "pointer",
148
- outline: "none",
147
+ cursor: 'pointer',
148
+ outline: 'none',
149
149
  padding: theme.spacing.itemPadding,
150
- transition: enableAnimations ? `all ${theme.animations.transitionFast} ${theme.animations.easeInOut}` : "none"
150
+ transition: enableAnimations ? `all ${theme.animations.transitionFast} ${theme.animations.easeInOut}` : 'none'
151
151
  });
152
152
  const resultTitleStyles = css({
153
153
  color: theme.colors.titleText,
@@ -155,122 +155,122 @@ import { defaultTheme, themes } from "./themes.js";
155
155
  fontSize: theme.typography.fontSizeLg,
156
156
  fontWeight: theme.typography.fontWeightSemibold,
157
157
  lineHeight: theme.typography.lineHeightTight,
158
- marginBottom: "8px"
158
+ marginBottom: '8px'
159
159
  });
160
160
  const resultDescriptionStyles = css({
161
161
  color: theme.colors.descriptionText,
162
162
  fontFamily: theme.typography.fontFamily,
163
163
  fontSize: theme.typography.fontSizeSm,
164
164
  lineHeight: theme.typography.lineHeightNormal,
165
- marginBottom: "8px"
165
+ marginBottom: '8px'
166
166
  });
167
167
  const resultHighlightStyles = css({
168
168
  backgroundColor: theme.colors.highlightBackground,
169
- borderRadius: enableRoundedCorners ? "6px" : "0",
169
+ borderRadius: enableRoundedCorners ? '6px' : '0',
170
170
  color: theme.colors.descriptionText,
171
171
  fontFamily: theme.typography.fontFamily,
172
172
  fontSize: theme.typography.fontSizeSm,
173
173
  lineHeight: theme.typography.lineHeightNormal,
174
- marginBottom: "8px",
174
+ marginBottom: '8px',
175
175
  mark: {
176
176
  backgroundColor: theme.colors.highlightBackground,
177
- borderRadius: enableRoundedCorners ? "3px" : "0",
177
+ borderRadius: enableRoundedCorners ? '3px' : '0',
178
178
  color: theme.colors.highlightText,
179
179
  fontWeight: theme.typography.fontWeightMedium,
180
- padding: "2px 4px"
180
+ padding: '2px 4px'
181
181
  },
182
- padding: "8px 12px"
182
+ padding: '8px 12px'
183
183
  });
184
184
  const resultMetaStyles = css({
185
- alignItems: "center",
185
+ alignItems: 'center',
186
186
  color: theme.colors.metaText,
187
- display: "flex",
187
+ display: 'flex',
188
188
  fontFamily: theme.typography.fontFamily,
189
189
  fontSize: theme.typography.fontSizeXs,
190
- justifyContent: "space-between",
191
- marginTop: "8px"
190
+ justifyContent: 'space-between',
191
+ marginTop: '8px'
192
192
  });
193
193
  const collectionBadgeStyles = css({
194
194
  backgroundColor: theme.colors.collectionBadge,
195
- borderRadius: enableRoundedCorners ? "12px" : "0",
195
+ borderRadius: enableRoundedCorners ? '12px' : '0',
196
196
  color: theme.colors.collectionBadgeText,
197
- display: "inline-block",
197
+ display: 'inline-block',
198
198
  fontFamily: theme.typography.fontFamily,
199
199
  fontSize: theme.typography.fontSizeXs,
200
200
  fontWeight: theme.typography.fontWeightSemibold,
201
- letterSpacing: "0.5px",
202
- padding: "4px 8px",
203
- textTransform: "uppercase"
201
+ letterSpacing: '0.5px',
202
+ padding: '4px 8px',
203
+ textTransform: 'uppercase'
204
204
  });
205
205
  const scoreBadgeStyles = css({
206
206
  backgroundColor: theme.colors.scoreBadge,
207
- borderRadius: enableRoundedCorners ? "4px" : "0",
207
+ borderRadius: enableRoundedCorners ? '4px' : '0',
208
208
  color: theme.colors.scoreBadgeText,
209
- display: "inline-block",
209
+ display: 'inline-block',
210
210
  fontFamily: theme.typography.fontFamily,
211
211
  fontSize: theme.typography.fontSizeXs,
212
212
  fontWeight: theme.typography.fontWeightMedium,
213
- padding: "2px 6px"
213
+ padding: '2px 6px'
214
214
  });
215
215
  const loadingStyles = css({
216
- alignItems: "center",
216
+ alignItems: 'center',
217
217
  color: theme.colors.loadingText,
218
- display: "flex",
218
+ display: 'flex',
219
219
  fontFamily: theme.typography.fontFamily,
220
220
  fontSize: theme.typography.fontSizeSm,
221
- gap: "12px",
222
- justifyContent: "center",
223
- padding: "24px"
221
+ gap: '12px',
222
+ justifyContent: 'center',
223
+ padding: '24px'
224
224
  });
225
225
  const loadingSpinnerStyles = css({
226
- animation: enableAnimations ? `spin 1s linear infinite` : "none",
226
+ animation: enableAnimations ? `spin 1s linear infinite` : 'none',
227
227
  border: `2px solid ${theme.colors.inputBorder}`,
228
- borderRadius: "50%",
228
+ borderRadius: '50%',
229
229
  borderTop: `2px solid ${theme.colors.inputBorderFocus}`,
230
- height: "20px",
231
- width: "20px"
230
+ height: '20px',
231
+ width: '20px'
232
232
  });
233
233
  const errorStyles = css({
234
- alignItems: "center",
234
+ alignItems: 'center',
235
235
  backgroundColor: theme.colors.errorBackground,
236
236
  borderBottom: `1px solid ${theme.colors.resultBorder}`,
237
237
  color: theme.colors.errorText,
238
- display: "flex",
238
+ display: 'flex',
239
239
  fontFamily: theme.typography.fontFamily,
240
240
  fontSize: theme.typography.fontSizeSm,
241
- gap: "8px",
242
- padding: "16px"
241
+ gap: '8px',
242
+ padding: '16px'
243
243
  });
244
244
  const noResultsStyles = css({
245
245
  color: theme.colors.noResultsText,
246
246
  fontFamily: theme.typography.fontFamily,
247
247
  fontSize: theme.typography.fontSizeSm,
248
- padding: "40px 20px",
249
- textAlign: "center"
248
+ padding: '40px 20px',
249
+ textAlign: 'center'
250
250
  });
251
251
  const facetContainerStyles = css({
252
252
  backgroundColor: theme.colors.headerBackground,
253
253
  borderBottom: `1px solid ${theme.colors.headerBorder}`,
254
- padding: "16px"
254
+ padding: '16px'
255
255
  });
256
256
  const facetItemStyles = css({
257
- ":hover": {
257
+ ':hover': {
258
258
  backgroundColor: theme.colors.facetActiveBackground,
259
259
  borderColor: theme.colors.facetActiveBackground,
260
260
  color: theme.colors.facetActiveText
261
261
  },
262
262
  backgroundColor: theme.colors.facetBackground,
263
263
  border: `1px solid ${theme.colors.facetBorder}`,
264
- borderRadius: enableRoundedCorners ? "16px" : "0",
264
+ borderRadius: enableRoundedCorners ? '16px' : '0',
265
265
  color: theme.colors.facetText,
266
- cursor: "pointer",
267
- display: "inline-block",
266
+ cursor: 'pointer',
267
+ display: 'inline-block',
268
268
  fontFamily: theme.typography.fontFamily,
269
269
  fontSize: theme.typography.fontSizeXs,
270
270
  fontWeight: theme.typography.fontWeightMedium,
271
- margin: "4px",
272
- padding: "6px 12px",
273
- transition: enableAnimations ? `all ${theme.animations.transitionFast} ${theme.animations.easeInOut}` : "none"
271
+ margin: '4px',
272
+ padding: '6px 12px',
273
+ transition: enableAnimations ? `all ${theme.animations.transitionFast} ${theme.animations.easeInOut}` : 'none'
274
274
  });
275
275
  const facetItemActiveStyles = css({
276
276
  backgroundColor: theme.colors.facetActiveBackground,
@@ -278,16 +278,16 @@ import { defaultTheme, themes } from "./themes.js";
278
278
  color: theme.colors.facetActiveText
279
279
  });
280
280
  const hiddenStyles = css({
281
- display: "none"
281
+ display: 'none'
282
282
  });
283
283
  const visibleStyles = css({
284
- display: "block"
284
+ display: 'block'
285
285
  });
286
286
  const focusableStyles = css({
287
- ":focus": {
288
- boxShadow: enableShadows ? `0 0 0 2px ${theme.colors.inputBorderFocus}` : "none"
287
+ ':focus': {
288
+ boxShadow: enableShadows ? `0 0 0 2px ${theme.colors.inputBorderFocus}` : 'none'
289
289
  },
290
- outline: "none"
290
+ outline: 'none'
291
291
  });
292
292
  return {
293
293
  // Container classes
@@ -296,17 +296,17 @@ import { defaultTheme, themes } from "./themes.js";
296
296
  resultsContainer: resultsContainerStyles,
297
297
  // Input classes
298
298
  input: inputStyles,
299
- inputDisabled: "",
300
- inputFocus: "",
299
+ inputDisabled: '',
300
+ inputFocus: '',
301
301
  // Results classes
302
302
  results: resultsStyles,
303
303
  resultsHeader: resultsHeaderStyles,
304
304
  resultsList: resultsListStyles,
305
305
  // Item classes
306
306
  resultItem: resultItemStyles,
307
- resultItemActive: "",
308
- resultItemFocus: "",
309
- resultItemHover: "",
307
+ resultItemActive: '',
308
+ resultItemFocus: '',
309
+ resultItemHover: '',
310
310
  // Content classes
311
311
  resultDescription: resultDescriptionStyles,
312
312
  resultHighlight: resultHighlightStyles,
@@ -336,14 +336,14 @@ import { defaultTheme, themes } from "./themes.js";
336
336
  const classes = generateThemeClasses(theme);
337
337
  if (variant) {
338
338
  const variantKey = `${element}${variant.charAt(0).toUpperCase() + variant.slice(1)}`;
339
- return `${classes[element] || ""} ${classes[variantKey] || ""}`;
339
+ return `${classes[element] || ''} ${classes[variantKey] || ''}`;
340
340
  }
341
- return classes[element] || "";
341
+ return classes[element] || '';
342
342
  }
343
343
  /**
344
344
  * Check if theme is dark mode
345
345
  */ export function isDarkTheme(theme) {
346
- return theme.name === "dark" || theme.colors.inputBackground.includes("#1f") || theme.colors.inputBackground.includes("#0f");
346
+ return theme.name === 'dark' || theme.colors.inputBackground.includes('#1f') || theme.colors.inputBackground.includes('#0f');
347
347
  }
348
348
  /**
349
349
  * Check if theme is light mode
@@ -354,34 +354,34 @@ import { defaultTheme, themes } from "./themes.js";
354
354
  * Get theme-specific CSS variables
355
355
  */ export function getThemeVariables(theme) {
356
356
  return {
357
- "--search-collection-badge": theme.colors.collectionBadge,
358
- "--search-collection-badge-text": theme.colors.collectionBadgeText,
359
- "--search-description-text": theme.colors.descriptionText,
360
- "--search-error-bg": theme.colors.errorBackground,
361
- "--search-error-text": theme.colors.errorText,
362
- "--search-facet-active-bg": theme.colors.facetActiveBackground,
363
- "--search-facet-active-text": theme.colors.facetActiveText,
364
- "--search-facet-bg": theme.colors.facetBackground,
365
- "--search-facet-border": theme.colors.facetBorder,
366
- "--search-facet-text": theme.colors.facetText,
367
- "--search-header-bg": theme.colors.headerBackground,
368
- "--search-header-text": theme.colors.headerText,
369
- "--search-highlight-bg": theme.colors.highlightBackground,
370
- "--search-highlight-text": theme.colors.highlightText,
371
- "--search-input-bg": theme.colors.inputBackground,
372
- "--search-input-border": theme.colors.inputBorder,
373
- "--search-input-border-focus": theme.colors.inputBorderFocus,
374
- "--search-input-placeholder": theme.colors.inputPlaceholder,
375
- "--search-input-text": theme.colors.inputText,
376
- "--search-loading-text": theme.colors.loadingText,
377
- "--search-meta-text": theme.colors.metaText,
378
- "--search-no-results-text": theme.colors.noResultsText,
379
- "--search-result-bg": theme.colors.resultBackground,
380
- "--search-result-bg-hover": theme.colors.resultBackgroundHover,
381
- "--search-results-bg": theme.colors.resultsBackground,
382
- "--search-results-border": theme.colors.resultsBorder,
383
- "--search-score-badge": theme.colors.scoreBadge,
384
- "--search-score-badge-text": theme.colors.scoreBadgeText,
385
- "--search-title-text": theme.colors.titleText
357
+ '--search-collection-badge': theme.colors.collectionBadge,
358
+ '--search-collection-badge-text': theme.colors.collectionBadgeText,
359
+ '--search-description-text': theme.colors.descriptionText,
360
+ '--search-error-bg': theme.colors.errorBackground,
361
+ '--search-error-text': theme.colors.errorText,
362
+ '--search-facet-active-bg': theme.colors.facetActiveBackground,
363
+ '--search-facet-active-text': theme.colors.facetActiveText,
364
+ '--search-facet-bg': theme.colors.facetBackground,
365
+ '--search-facet-border': theme.colors.facetBorder,
366
+ '--search-facet-text': theme.colors.facetText,
367
+ '--search-header-bg': theme.colors.headerBackground,
368
+ '--search-header-text': theme.colors.headerText,
369
+ '--search-highlight-bg': theme.colors.highlightBackground,
370
+ '--search-highlight-text': theme.colors.highlightText,
371
+ '--search-input-bg': theme.colors.inputBackground,
372
+ '--search-input-border': theme.colors.inputBorder,
373
+ '--search-input-border-focus': theme.colors.inputBorderFocus,
374
+ '--search-input-placeholder': theme.colors.inputPlaceholder,
375
+ '--search-input-text': theme.colors.inputText,
376
+ '--search-loading-text': theme.colors.loadingText,
377
+ '--search-meta-text': theme.colors.metaText,
378
+ '--search-no-results-text': theme.colors.noResultsText,
379
+ '--search-result-bg': theme.colors.resultBackground,
380
+ '--search-result-bg-hover': theme.colors.resultBackgroundHover,
381
+ '--search-results-bg': theme.colors.resultsBackground,
382
+ '--search-results-border': theme.colors.resultsBorder,
383
+ '--search-score-badge': theme.colors.scoreBadge,
384
+ '--search-score-badge-text': theme.colors.scoreBadgeText,
385
+ '--search-title-text': theme.colors.titleText
386
386
  };
387
387
  }
@@ -0,0 +1,5 @@
1
+ import type Typesense from 'typesense';
2
+ import { type PayloadHandler } from 'payload';
3
+ import { type TypesenseConfig } from '../../index.js';
4
+ export declare const createAdvancedSearch: (typesenseClient: Typesense.Client, pluginOptions: TypesenseConfig) => PayloadHandler;
5
+ //# sourceMappingURL=createAdvancedSearch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createAdvancedSearch.d.ts","sourceRoot":"","sources":["../../../src/endpoints/handler/createAdvancedSearch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,WAAW,CAAA;AAEtC,OAAO,EAAE,KAAK,cAAc,EAAuB,MAAM,SAAS,CAAA;AAElE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAErD,eAAO,MAAM,oBAAoB,GAC/B,iBAAiB,SAAS,CAAC,MAAM,EACjC,eAAe,eAAe,KAC7B,cA+BF,CAAA"}
@@ -0,0 +1,40 @@
1
+ export const createAdvancedSearch = (typesenseClient, pluginOptions)=>{
2
+ return async (request)=>{
3
+ if (!request.url) {
4
+ return Response.json({
5
+ error: 'Missing request URL'
6
+ }, {
7
+ status: 400
8
+ });
9
+ }
10
+ const url = new URL(request.url);
11
+ const parts = url.pathname.split('/');
12
+ const searchIndex = parts.indexOf('search');
13
+ const collection = searchIndex >= 0 && parts[searchIndex + 1] ? String(parts[searchIndex + 1]) : '';
14
+ if (!pluginOptions.collections?.[collection]?.enabled) {
15
+ return Response.json({
16
+ error: 'Collection not enabled for search'
17
+ }, {
18
+ status: 400
19
+ });
20
+ }
21
+ if (!request.data) {
22
+ return Response.json({
23
+ error: 'Missing search parameters in request body'
24
+ }, {
25
+ status: 400
26
+ });
27
+ }
28
+ const body = request.data;
29
+ try {
30
+ const results = await typesenseClient.collections(collection).documents().search(body);
31
+ return Response.json(results);
32
+ } catch {
33
+ return Response.json({
34
+ error: 'Advanced search failed'
35
+ }, {
36
+ status: 500
37
+ });
38
+ }
39
+ };
40
+ };
@@ -0,0 +1,4 @@
1
+ import { type PayloadHandler } from 'payload';
2
+ import { type TypesenseConfig } from '../../index.js';
3
+ export declare const createCollections: (pluginOptions: TypesenseConfig) => PayloadHandler;
4
+ //# sourceMappingURL=createCollections.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createCollections.d.ts","sourceRoot":"","sources":["../../../src/endpoints/handler/createCollections.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAErD,eAAO,MAAM,iBAAiB,GAAI,eAAe,eAAe,KAAG,cAqBlE,CAAA"}
@@ -0,0 +1,23 @@
1
+ export const createCollections = (pluginOptions)=>{
2
+ return ()=>{
3
+ try {
4
+ const enabledCollections = Object.entries(pluginOptions.collections || {}).filter(([, config])=>config?.enabled).map(([slug, config])=>({
5
+ slug,
6
+ displayName: config?.displayName || slug.charAt(0).toUpperCase() + slug.slice(1),
7
+ facetFields: config?.facetFields ?? [],
8
+ icon: config?.icon ?? '📄',
9
+ searchFields: config?.searchFields ?? []
10
+ }));
11
+ return Response.json({
12
+ categorized: Boolean(pluginOptions.settings?.categorized),
13
+ collections: enabledCollections
14
+ });
15
+ } catch {
16
+ return Response.json({
17
+ error: 'Failed to get collections'
18
+ }, {
19
+ status: 500
20
+ });
21
+ }
22
+ };
23
+ };
@@ -0,0 +1,5 @@
1
+ import type Typesense from 'typesense';
2
+ import { type PayloadHandler } from 'payload';
3
+ import { type TypesenseConfig } from '../../index.js';
4
+ export declare const createSearch: (typesenseClient: Typesense.Client, pluginOptions: TypesenseConfig) => PayloadHandler;
5
+ //# sourceMappingURL=createSearch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createSearch.d.ts","sourceRoot":"","sources":["../../../src/endpoints/handler/createSearch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,WAAW,CAAA;AAEtC,OAAO,EAAE,KAAK,cAAc,EAAuB,MAAM,SAAS,CAAA;AAElE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAKrD,eAAO,MAAM,YAAY,GACvB,iBAAiB,SAAS,CAAC,MAAM,EACjC,eAAe,eAAe,KAC7B,cAoGF,CAAA"}