@blocklet/search-kit-js 0.2.8 → 0.2.9
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 +3 -6
- package/dist/index.mjs +3 -5
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3,15 +3,12 @@
|
|
|
3
3
|
const meilisearch = require('meilisearch');
|
|
4
4
|
const component = require('@blocklet/sdk/lib/component');
|
|
5
5
|
const getWallet = require('@blocklet/sdk/lib/wallet');
|
|
6
|
-
const env = require('@blocklet/sdk/lib/env');
|
|
7
6
|
const ufo = require('ufo');
|
|
8
|
-
const sdk = require('@blocklet/sdk');
|
|
9
7
|
const crypto = require('crypto');
|
|
10
8
|
|
|
11
9
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
12
10
|
|
|
13
11
|
const getWallet__default = /*#__PURE__*/_interopDefaultCompat(getWallet);
|
|
14
|
-
const env__default = /*#__PURE__*/_interopDefaultCompat(env);
|
|
15
12
|
const crypto__default = /*#__PURE__*/_interopDefaultCompat(crypto);
|
|
16
13
|
|
|
17
14
|
const SEARCH_KIT_DID = "z8iZorY6mvb5tZrxXTqhBmwu89xjEEazrgT3t";
|
|
@@ -28,14 +25,14 @@ const hash = (str, salt) => crypto__default.createHash("sha256").update(str + sa
|
|
|
28
25
|
|
|
29
26
|
const wallet = getWallet__default();
|
|
30
27
|
const resolveRestEmbedders = ({ documentTemplate, ...rest }) => {
|
|
31
|
-
const
|
|
32
|
-
if (!wallet.secretKey || !
|
|
28
|
+
const endpoint = component.getComponentWebEndpoint("ai-kit");
|
|
29
|
+
if (!wallet.secretKey || !endpoint) {
|
|
33
30
|
throw new Error("wallet.secretKey or ai-kit blocklet is not found");
|
|
34
31
|
}
|
|
35
32
|
return {
|
|
36
33
|
default: {
|
|
37
34
|
source: "rest",
|
|
38
|
-
url: ufo.joinURL(
|
|
35
|
+
url: ufo.joinURL(endpoint, "/api/meilisearch/embeddings"),
|
|
39
36
|
dimensions: 1536,
|
|
40
37
|
apiKey: hash(wallet.secretKey, ":/ai-kit/api/meilisearch/embeddings"),
|
|
41
38
|
request: { data: { text: "{{text}}" } },
|
package/dist/index.mjs
CHANGED
|
@@ -2,9 +2,7 @@ import { MeiliSearch } from 'meilisearch';
|
|
|
2
2
|
export * from 'meilisearch';
|
|
3
3
|
import { getComponentWebEndpoint } from '@blocklet/sdk/lib/component';
|
|
4
4
|
import getWallet from '@blocklet/sdk/lib/wallet';
|
|
5
|
-
import env from '@blocklet/sdk/lib/env';
|
|
6
5
|
import { joinURL } from 'ufo';
|
|
7
|
-
import { getComponentMountPoint } from '@blocklet/sdk';
|
|
8
6
|
import crypto from 'crypto';
|
|
9
7
|
|
|
10
8
|
const SEARCH_KIT_DID = "z8iZorY6mvb5tZrxXTqhBmwu89xjEEazrgT3t";
|
|
@@ -21,14 +19,14 @@ const hash = (str, salt) => crypto.createHash("sha256").update(str + salt).diges
|
|
|
21
19
|
|
|
22
20
|
const wallet = getWallet();
|
|
23
21
|
const resolveRestEmbedders = ({ documentTemplate, ...rest }) => {
|
|
24
|
-
const
|
|
25
|
-
if (!wallet.secretKey || !
|
|
22
|
+
const endpoint = getComponentWebEndpoint("ai-kit");
|
|
23
|
+
if (!wallet.secretKey || !endpoint) {
|
|
26
24
|
throw new Error("wallet.secretKey or ai-kit blocklet is not found");
|
|
27
25
|
}
|
|
28
26
|
return {
|
|
29
27
|
default: {
|
|
30
28
|
source: "rest",
|
|
31
|
-
url: joinURL(
|
|
29
|
+
url: joinURL(endpoint, "/api/meilisearch/embeddings"),
|
|
32
30
|
dimensions: 1536,
|
|
33
31
|
apiKey: hash(wallet.secretKey, ":/ai-kit/api/meilisearch/embeddings"),
|
|
34
32
|
request: { data: { text: "{{text}}" } },
|