bonsai-search 3.0.8
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/README.md +84 -0
- package/dist/bonsai-sdk-3.0.8.css +861 -0
- package/dist/bonsai-sdk-3.0.8.js +1698 -0
- package/dist/bonsai-searchbar-3.0.8.js +486 -0
- package/dist/index.cjs +1695 -0
- package/dist/index.d.cts +312 -0
- package/dist/index.d.ts +312 -0
- package/dist/index.js +1693 -0
- package/package.json +55 -0
package/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Bonsai SDK
|
|
2
|
+
|
|
3
|
+
The build and CDN publish system for the Bonsai Search SDK.
|
|
4
|
+
|
|
5
|
+
## Development
|
|
6
|
+
|
|
7
|
+
- Install dependencies:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
- Run the unit tests:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm run test
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
- Build the library:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm run build
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## I just want to test the SDK with a tenant
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
cd sdk
|
|
29
|
+
npm install
|
|
30
|
+
npm run build
|
|
31
|
+
npx serve
|
|
32
|
+
#edit index.html to suit your test (apikey mostly)
|
|
33
|
+
open http://localhost:3000
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Unhandled case right now
|
|
37
|
+
|
|
38
|
+
```javascript
|
|
39
|
+
renderResults(data, results) {
|
|
40
|
+
if (!this.resultsContainer)
|
|
41
|
+
return;
|
|
42
|
+
|
|
43
|
+
//This was to remove all faw content for bathhouse and just let the recommendation stand alone as "THE answer"
|
|
44
|
+
for (let i = results.length - 1; i >= 0; i--) {
|
|
45
|
+
if (!results[i].productType === "faq") {
|
|
46
|
+
results.splice(i, 1);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Aurora Integration
|
|
52
|
+
|
|
53
|
+
inside a `<script>` tag:
|
|
54
|
+
|
|
55
|
+
```javascript
|
|
56
|
+
function waitForWindowObject(objectName, interval = 100) {
|
|
57
|
+
return new Promise((resolve) => {
|
|
58
|
+
const intervalId = setInterval(() => {
|
|
59
|
+
if (window[objectName]) {
|
|
60
|
+
clearInterval(intervalId);
|
|
61
|
+
resolve(window[objectName]);
|
|
62
|
+
}
|
|
63
|
+
}, interval);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
waitForWindowObject("BonsaiSearch").then(() => {
|
|
67
|
+
const search = new BonsaiSearch({
|
|
68
|
+
container: document.getElementsByClassName("framer-ys3trd-container")[0],
|
|
69
|
+
apiKey: "FA3s_HgeI-oc1zogV8qRnT06s4NJJwaRgmDlo7eL0DiEo7ZTpZoqc9bwcLDb8Z4_", // Replace with your API key
|
|
70
|
+
baseUrl: "https://api.hibonsai.com/rest/search/v2/", // Replace with your API URL
|
|
71
|
+
placeholder: "Ask us any question here...",
|
|
72
|
+
suggestions: ["suggestion 1", "suggestion 2", "suggestion 3"],
|
|
73
|
+
onSearch: (query) => {
|
|
74
|
+
console.log("Searching for:", query);
|
|
75
|
+
},
|
|
76
|
+
onResults: (results) => {
|
|
77
|
+
console.log("Found results:", results);
|
|
78
|
+
},
|
|
79
|
+
onError: (error) => {
|
|
80
|
+
console.error("Search error:", error);
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
```
|