@blocklet/search-kit-js 0.2.13 → 0.2.14
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/index.cjs +18 -1
- package/dist/index.mjs +17 -1
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
const meilisearch = require('meilisearch');
|
|
4
4
|
const component = require('@blocklet/sdk/lib/component');
|
|
5
|
+
const verifySign = require('@blocklet/sdk/lib/util/verify-sign');
|
|
6
|
+
const axios = require('axios');
|
|
5
7
|
const config = require('@blocklet/sdk/lib/config');
|
|
6
8
|
const zod = require('zod');
|
|
7
9
|
const getWallet = require('@blocklet/sdk/lib/wallet');
|
|
@@ -11,6 +13,7 @@ const crypto = require('crypto');
|
|
|
11
13
|
|
|
12
14
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
13
15
|
|
|
16
|
+
const axios__default = /*#__PURE__*/_interopDefaultCompat(axios);
|
|
14
17
|
const config__default = /*#__PURE__*/_interopDefaultCompat(config);
|
|
15
18
|
const getWallet__default = /*#__PURE__*/_interopDefaultCompat(getWallet);
|
|
16
19
|
const env__default = /*#__PURE__*/_interopDefaultCompat(env);
|
|
@@ -85,7 +88,21 @@ class SearchKitClient extends meilisearch.MeiliSearch {
|
|
|
85
88
|
const endpoint = component.getComponentWebEndpoint(SEARCH_KIT_DID);
|
|
86
89
|
if (!endpoint)
|
|
87
90
|
throw new Error("SearchKit Kit not found");
|
|
88
|
-
super({
|
|
91
|
+
super({
|
|
92
|
+
host: `${endpoint}/api/meilisearch`,
|
|
93
|
+
httpClient: async (url, opts) => {
|
|
94
|
+
const body = typeof opts?.body === "string" ? JSON.parse(opts.body) : opts?.body ?? {};
|
|
95
|
+
const headers = typeof opts?.headers === "string" ? JSON.parse(opts.headers) : opts?.headers ?? {};
|
|
96
|
+
const response = await axios__default.request({
|
|
97
|
+
url,
|
|
98
|
+
data: body,
|
|
99
|
+
headers: { "x-component-sig": verifySign.sign(body), ...headers },
|
|
100
|
+
method: opts?.method?.toLocaleUpperCase() ?? "GET"
|
|
101
|
+
});
|
|
102
|
+
return response.data;
|
|
103
|
+
},
|
|
104
|
+
...config
|
|
105
|
+
});
|
|
89
106
|
}
|
|
90
107
|
get serpIndex() {
|
|
91
108
|
return new SerpIndex(this.index(SERP_INDEX));
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { MeiliSearch } from 'meilisearch';
|
|
2
2
|
export * from 'meilisearch';
|
|
3
3
|
import { getComponentWebEndpoint, getComponentMountPoint } from '@blocklet/sdk/lib/component';
|
|
4
|
+
import { sign } from '@blocklet/sdk/lib/util/verify-sign';
|
|
5
|
+
import axios from 'axios';
|
|
4
6
|
import config from '@blocklet/sdk/lib/config';
|
|
5
7
|
import { z } from 'zod';
|
|
6
8
|
import getWallet from '@blocklet/sdk/lib/wallet';
|
|
@@ -77,7 +79,21 @@ class SearchKitClient extends MeiliSearch {
|
|
|
77
79
|
const endpoint = getComponentWebEndpoint(SEARCH_KIT_DID);
|
|
78
80
|
if (!endpoint)
|
|
79
81
|
throw new Error("SearchKit Kit not found");
|
|
80
|
-
super({
|
|
82
|
+
super({
|
|
83
|
+
host: `${endpoint}/api/meilisearch`,
|
|
84
|
+
httpClient: async (url, opts) => {
|
|
85
|
+
const body = typeof opts?.body === "string" ? JSON.parse(opts.body) : opts?.body ?? {};
|
|
86
|
+
const headers = typeof opts?.headers === "string" ? JSON.parse(opts.headers) : opts?.headers ?? {};
|
|
87
|
+
const response = await axios.request({
|
|
88
|
+
url,
|
|
89
|
+
data: body,
|
|
90
|
+
headers: { "x-component-sig": sign(body), ...headers },
|
|
91
|
+
method: opts?.method?.toLocaleUpperCase() ?? "GET"
|
|
92
|
+
});
|
|
93
|
+
return response.data;
|
|
94
|
+
},
|
|
95
|
+
...config
|
|
96
|
+
});
|
|
81
97
|
}
|
|
82
98
|
get serpIndex() {
|
|
83
99
|
return new SerpIndex(this.index(SERP_INDEX));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/search-kit-js",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.14",
|
|
4
4
|
"author": "Arcblock <blocklet@arcblock.io> https://github.com/blocklet",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -19,12 +19,13 @@
|
|
|
19
19
|
"README.md"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
+
"axios": "^1.7.7",
|
|
22
23
|
"meilisearch": "^0.42.0",
|
|
23
24
|
"ufo": "^1.5.4",
|
|
24
25
|
"zod": "^3.23.8"
|
|
25
26
|
},
|
|
26
27
|
"peerDependencies": {
|
|
27
|
-
"@blocklet/sdk": "^1.16.
|
|
28
|
+
"@blocklet/sdk": "^1.16.32"
|
|
28
29
|
},
|
|
29
30
|
"scripts": {
|
|
30
31
|
"build": "unbuild",
|