@blocklet/search-kit-js 0.2.19 → 0.2.21

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 CHANGED
@@ -5,8 +5,6 @@ const component = require('@blocklet/sdk/lib/component');
5
5
  const verifySign = require('@blocklet/sdk/lib/util/verify-sign');
6
6
  const axios = require('axios');
7
7
  const ufo = require('ufo');
8
- const config = require('@blocklet/sdk/lib/config');
9
- const zod = require('zod');
10
8
  const getWallet = require('@blocklet/sdk/lib/wallet');
11
9
  const env = require('@blocklet/sdk/lib/env');
12
10
  const crypto = require('crypto');
@@ -14,75 +12,11 @@ const crypto = require('crypto');
14
12
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
15
13
 
16
14
  const axios__default = /*#__PURE__*/_interopDefaultCompat(axios);
17
- const config__default = /*#__PURE__*/_interopDefaultCompat(config);
18
15
  const getWallet__default = /*#__PURE__*/_interopDefaultCompat(getWallet);
19
16
  const env__default = /*#__PURE__*/_interopDefaultCompat(env);
20
17
  const crypto__default = /*#__PURE__*/_interopDefaultCompat(crypto);
21
18
 
22
- const SerpDocSchema = zod.z.object({
23
- id: zod.z.string(),
24
- appId: zod.z.string().optional(),
25
- type: zod.z.string().optional(),
26
- title: zod.z.string().optional().nullable(),
27
- content: zod.z.string().optional().nullable(),
28
- author: zod.z.string().optional(),
29
- url: zod.z.string().optional(),
30
- passports: zod.z.array(zod.z.string()).optional(),
31
- createdAt: zod.z.number().optional(),
32
- updatedAt: zod.z.number().optional(),
33
- image: zod.z.string().optional(),
34
- labels: zod.z.array(zod.z.object({ id: zod.z.string() })).optional(),
35
- translations: zod.z.array(
36
- zod.z.object({
37
- locale: zod.z.string(),
38
- title: zod.z.string().optional().nullable(),
39
- content: zod.z.string().optional().nullable(),
40
- url: zod.z.string().optional()
41
- })
42
- ).optional()
43
- }).passthrough();
44
- const SerpDocsSchema = zod.z.array(SerpDocSchema);
45
-
46
- var __defProp = Object.defineProperty;
47
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
48
- var __publicField = (obj, key, value) => {
49
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
50
- return value;
51
- };
52
- const resolveSerpDocId = (id) => `${config__default.env.appId}--${id}`;
53
- const resolveSerpDoc = (doc) => ({ ...doc, id: resolveSerpDocId(doc.id), appId: config__default.env.appId });
54
- class SerpIndex {
55
- constructor(index) {
56
- __publicField(this, "index");
57
- this.index = index;
58
- }
59
- search(query, options) {
60
- return this.index.search(query, options);
61
- }
62
- addDocuments(documents, options) {
63
- const valid = SerpDocsSchema.safeParse(documents);
64
- if (!valid.success) {
65
- throw new Error(`Invalid documents: ${valid.error}`);
66
- }
67
- const data = valid.data.map((doc) => resolveSerpDoc(doc));
68
- return this.index.addDocuments(data, options);
69
- }
70
- updateDocuments(documents, options) {
71
- const valid = SerpDocsSchema.safeParse(documents);
72
- if (!valid.success) {
73
- throw new Error(`Invalid documents: ${valid.error}`);
74
- }
75
- const data = valid.data.map((doc) => resolveSerpDoc(doc));
76
- return this.index.updateDocuments(data, options);
77
- }
78
- deleteDocuments(documentIds) {
79
- const ids = documentIds.map((id) => resolveSerpDocId(id));
80
- return this.index.deleteDocuments(ids);
81
- }
82
- }
83
-
84
19
  const SEARCH_KIT_DID = "z8iZorY6mvb5tZrxXTqhBmwu89xjEEazrgT3t";
85
- const SERP_INDEX = `${SEARCH_KIT_DID}-search-kit-serp`;
86
20
  class SearchKitClient extends meilisearch.MeiliSearch {
87
21
  constructor(config) {
88
22
  const endpoint = component.getComponentWebEndpoint(SEARCH_KIT_DID);
@@ -104,9 +38,6 @@ class SearchKitClient extends meilisearch.MeiliSearch {
104
38
  ...config
105
39
  });
106
40
  }
107
- get serpIndex() {
108
- return new SerpIndex(this.index(SERP_INDEX));
109
- }
110
41
  }
111
42
 
112
43
  const hash = (str, salt) => crypto__default.createHash("sha256").update(str + salt).digest("hex");
@@ -133,10 +64,7 @@ const resolveRestEmbedders = ({ documentTemplate, ...rest }) => {
133
64
  };
134
65
  };
135
66
 
136
- exports.SERP_INDEX = SERP_INDEX;
137
67
  exports.SearchKitClient = SearchKitClient;
138
- exports.SerpDocSchema = SerpDocSchema;
139
- exports.SerpDocsSchema = SerpDocsSchema;
140
68
  exports.resolveRestEmbedders = resolveRestEmbedders;
141
69
  Object.keys(meilisearch).forEach(function (k) {
142
70
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = meilisearch[k];
package/dist/index.d.cts CHANGED
@@ -1,272 +1,8 @@
1
- import * as meilisearch from 'meilisearch';
2
- import { Index, SearchParams, DocumentOptions, MeiliSearch, Config, Embedders, RestEmbedder } from 'meilisearch';
1
+ import { MeiliSearch, Config, Embedders, RestEmbedder } from 'meilisearch';
3
2
  export * from 'meilisearch';
4
- import * as zod from 'zod';
5
- import { z } from 'zod';
6
3
 
7
- declare const SerpDocSchema: z.ZodObject<{
8
- id: z.ZodString;
9
- appId: z.ZodOptional<z.ZodString>;
10
- type: z.ZodOptional<z.ZodString>;
11
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
12
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
13
- author: z.ZodOptional<z.ZodString>;
14
- url: z.ZodOptional<z.ZodString>;
15
- passports: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
16
- createdAt: z.ZodOptional<z.ZodNumber>;
17
- updatedAt: z.ZodOptional<z.ZodNumber>;
18
- image: z.ZodOptional<z.ZodString>;
19
- labels: z.ZodOptional<z.ZodArray<z.ZodObject<{
20
- id: z.ZodString;
21
- }, "strip", z.ZodTypeAny, {
22
- id?: string;
23
- }, {
24
- id?: string;
25
- }>, "many">>;
26
- translations: z.ZodOptional<z.ZodArray<z.ZodObject<{
27
- locale: z.ZodString;
28
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
29
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
30
- url: z.ZodOptional<z.ZodString>;
31
- }, "strip", z.ZodTypeAny, {
32
- title?: string;
33
- content?: string;
34
- url?: string;
35
- locale?: string;
36
- }, {
37
- title?: string;
38
- content?: string;
39
- url?: string;
40
- locale?: string;
41
- }>, "many">>;
42
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
43
- id: z.ZodString;
44
- appId: z.ZodOptional<z.ZodString>;
45
- type: z.ZodOptional<z.ZodString>;
46
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
47
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
48
- author: z.ZodOptional<z.ZodString>;
49
- url: z.ZodOptional<z.ZodString>;
50
- passports: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
51
- createdAt: z.ZodOptional<z.ZodNumber>;
52
- updatedAt: z.ZodOptional<z.ZodNumber>;
53
- image: z.ZodOptional<z.ZodString>;
54
- labels: z.ZodOptional<z.ZodArray<z.ZodObject<{
55
- id: z.ZodString;
56
- }, "strip", z.ZodTypeAny, {
57
- id?: string;
58
- }, {
59
- id?: string;
60
- }>, "many">>;
61
- translations: z.ZodOptional<z.ZodArray<z.ZodObject<{
62
- locale: z.ZodString;
63
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
64
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
65
- url: z.ZodOptional<z.ZodString>;
66
- }, "strip", z.ZodTypeAny, {
67
- title?: string;
68
- content?: string;
69
- url?: string;
70
- locale?: string;
71
- }, {
72
- title?: string;
73
- content?: string;
74
- url?: string;
75
- locale?: string;
76
- }>, "many">>;
77
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
78
- id: z.ZodString;
79
- appId: z.ZodOptional<z.ZodString>;
80
- type: z.ZodOptional<z.ZodString>;
81
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
82
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
83
- author: z.ZodOptional<z.ZodString>;
84
- url: z.ZodOptional<z.ZodString>;
85
- passports: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
86
- createdAt: z.ZodOptional<z.ZodNumber>;
87
- updatedAt: z.ZodOptional<z.ZodNumber>;
88
- image: z.ZodOptional<z.ZodString>;
89
- labels: z.ZodOptional<z.ZodArray<z.ZodObject<{
90
- id: z.ZodString;
91
- }, "strip", z.ZodTypeAny, {
92
- id?: string;
93
- }, {
94
- id?: string;
95
- }>, "many">>;
96
- translations: z.ZodOptional<z.ZodArray<z.ZodObject<{
97
- locale: z.ZodString;
98
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
99
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
100
- url: z.ZodOptional<z.ZodString>;
101
- }, "strip", z.ZodTypeAny, {
102
- title?: string;
103
- content?: string;
104
- url?: string;
105
- locale?: string;
106
- }, {
107
- title?: string;
108
- content?: string;
109
- url?: string;
110
- locale?: string;
111
- }>, "many">>;
112
- }, z.ZodTypeAny, "passthrough">>;
113
- declare const SerpDocsSchema: z.ZodArray<z.ZodObject<{
114
- id: z.ZodString;
115
- appId: z.ZodOptional<z.ZodString>;
116
- type: z.ZodOptional<z.ZodString>;
117
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
118
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
119
- author: z.ZodOptional<z.ZodString>;
120
- url: z.ZodOptional<z.ZodString>;
121
- passports: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
122
- createdAt: z.ZodOptional<z.ZodNumber>;
123
- updatedAt: z.ZodOptional<z.ZodNumber>;
124
- image: z.ZodOptional<z.ZodString>;
125
- labels: z.ZodOptional<z.ZodArray<z.ZodObject<{
126
- id: z.ZodString;
127
- }, "strip", z.ZodTypeAny, {
128
- id?: string;
129
- }, {
130
- id?: string;
131
- }>, "many">>;
132
- translations: z.ZodOptional<z.ZodArray<z.ZodObject<{
133
- locale: z.ZodString;
134
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
135
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
136
- url: z.ZodOptional<z.ZodString>;
137
- }, "strip", z.ZodTypeAny, {
138
- title?: string;
139
- content?: string;
140
- url?: string;
141
- locale?: string;
142
- }, {
143
- title?: string;
144
- content?: string;
145
- url?: string;
146
- locale?: string;
147
- }>, "many">>;
148
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
149
- id: z.ZodString;
150
- appId: z.ZodOptional<z.ZodString>;
151
- type: z.ZodOptional<z.ZodString>;
152
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
153
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
154
- author: z.ZodOptional<z.ZodString>;
155
- url: z.ZodOptional<z.ZodString>;
156
- passports: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
157
- createdAt: z.ZodOptional<z.ZodNumber>;
158
- updatedAt: z.ZodOptional<z.ZodNumber>;
159
- image: z.ZodOptional<z.ZodString>;
160
- labels: z.ZodOptional<z.ZodArray<z.ZodObject<{
161
- id: z.ZodString;
162
- }, "strip", z.ZodTypeAny, {
163
- id?: string;
164
- }, {
165
- id?: string;
166
- }>, "many">>;
167
- translations: z.ZodOptional<z.ZodArray<z.ZodObject<{
168
- locale: z.ZodString;
169
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
170
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
171
- url: z.ZodOptional<z.ZodString>;
172
- }, "strip", z.ZodTypeAny, {
173
- title?: string;
174
- content?: string;
175
- url?: string;
176
- locale?: string;
177
- }, {
178
- title?: string;
179
- content?: string;
180
- url?: string;
181
- locale?: string;
182
- }>, "many">>;
183
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
184
- id: z.ZodString;
185
- appId: z.ZodOptional<z.ZodString>;
186
- type: z.ZodOptional<z.ZodString>;
187
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
188
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
189
- author: z.ZodOptional<z.ZodString>;
190
- url: z.ZodOptional<z.ZodString>;
191
- passports: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
192
- createdAt: z.ZodOptional<z.ZodNumber>;
193
- updatedAt: z.ZodOptional<z.ZodNumber>;
194
- image: z.ZodOptional<z.ZodString>;
195
- labels: z.ZodOptional<z.ZodArray<z.ZodObject<{
196
- id: z.ZodString;
197
- }, "strip", z.ZodTypeAny, {
198
- id?: string;
199
- }, {
200
- id?: string;
201
- }>, "many">>;
202
- translations: z.ZodOptional<z.ZodArray<z.ZodObject<{
203
- locale: z.ZodString;
204
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
205
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
206
- url: z.ZodOptional<z.ZodString>;
207
- }, "strip", z.ZodTypeAny, {
208
- title?: string;
209
- content?: string;
210
- url?: string;
211
- locale?: string;
212
- }, {
213
- title?: string;
214
- content?: string;
215
- url?: string;
216
- locale?: string;
217
- }>, "many">>;
218
- }, z.ZodTypeAny, "passthrough">>, "many">;
219
- type SerpDoc = z.infer<typeof SerpDocSchema>;
220
- type SerpDocs = z.infer<typeof SerpDocsSchema>;
221
-
222
- declare class SerpIndex {
223
- private index;
224
- constructor(index: Index<SerpDoc>);
225
- search(query: string, options?: SearchParams): Promise<meilisearch.SearchResponse<zod.objectOutputType<{
226
- id: zod.ZodString;
227
- appId: zod.ZodOptional<zod.ZodString>;
228
- type: zod.ZodOptional<zod.ZodString>;
229
- title: zod.ZodNullable<zod.ZodOptional<zod.ZodString>>;
230
- content: zod.ZodNullable<zod.ZodOptional<zod.ZodString>>;
231
- author: zod.ZodOptional<zod.ZodString>;
232
- url: zod.ZodOptional<zod.ZodString>;
233
- passports: zod.ZodOptional<zod.ZodArray<zod.ZodString, "many">>;
234
- createdAt: zod.ZodOptional<zod.ZodNumber>;
235
- updatedAt: zod.ZodOptional<zod.ZodNumber>;
236
- image: zod.ZodOptional<zod.ZodString>;
237
- labels: zod.ZodOptional<zod.ZodArray<zod.ZodObject<{
238
- id: zod.ZodString;
239
- }, "strip", zod.ZodTypeAny, {
240
- id?: string;
241
- }, {
242
- id?: string;
243
- }>, "many">>;
244
- translations: zod.ZodOptional<zod.ZodArray<zod.ZodObject<{
245
- locale: zod.ZodString;
246
- title: zod.ZodNullable<zod.ZodOptional<zod.ZodString>>;
247
- content: zod.ZodNullable<zod.ZodOptional<zod.ZodString>>;
248
- url: zod.ZodOptional<zod.ZodString>;
249
- }, "strip", zod.ZodTypeAny, {
250
- title?: string;
251
- content?: string;
252
- url?: string;
253
- locale?: string;
254
- }, {
255
- title?: string;
256
- content?: string;
257
- url?: string;
258
- locale?: string;
259
- }>, "many">>;
260
- }, zod.ZodTypeAny, "passthrough">, SearchParams>>;
261
- addDocuments(documents: SerpDocs, options?: DocumentOptions): Promise<meilisearch.EnqueuedTask>;
262
- updateDocuments(documents: SerpDocs, options?: DocumentOptions): Promise<meilisearch.EnqueuedTask>;
263
- deleteDocuments(documentIds: string[]): Promise<meilisearch.EnqueuedTask>;
264
- }
265
-
266
- declare const SERP_INDEX = "z8iZorY6mvb5tZrxXTqhBmwu89xjEEazrgT3t-search-kit-serp";
267
4
  declare class SearchKitClient extends MeiliSearch {
268
5
  constructor(config?: Omit<Config, 'host' | 'apiKey'>);
269
- get serpIndex(): SerpIndex;
270
6
  }
271
7
 
272
8
  type PartialRestEmbedder = Partial<RestEmbedder> & {
@@ -274,4 +10,4 @@ type PartialRestEmbedder = Partial<RestEmbedder> & {
274
10
  };
275
11
  declare const resolveRestEmbedders: ({ documentTemplate, ...rest }: PartialRestEmbedder) => Embedders;
276
12
 
277
- export { SERP_INDEX, SearchKitClient, type SerpDoc, SerpDocSchema, type SerpDocs, SerpDocsSchema, resolveRestEmbedders };
13
+ export { SearchKitClient, resolveRestEmbedders };
package/dist/index.d.mts CHANGED
@@ -1,272 +1,8 @@
1
- import * as meilisearch from 'meilisearch';
2
- import { Index, SearchParams, DocumentOptions, MeiliSearch, Config, Embedders, RestEmbedder } from 'meilisearch';
1
+ import { MeiliSearch, Config, Embedders, RestEmbedder } from 'meilisearch';
3
2
  export * from 'meilisearch';
4
- import * as zod from 'zod';
5
- import { z } from 'zod';
6
3
 
7
- declare const SerpDocSchema: z.ZodObject<{
8
- id: z.ZodString;
9
- appId: z.ZodOptional<z.ZodString>;
10
- type: z.ZodOptional<z.ZodString>;
11
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
12
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
13
- author: z.ZodOptional<z.ZodString>;
14
- url: z.ZodOptional<z.ZodString>;
15
- passports: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
16
- createdAt: z.ZodOptional<z.ZodNumber>;
17
- updatedAt: z.ZodOptional<z.ZodNumber>;
18
- image: z.ZodOptional<z.ZodString>;
19
- labels: z.ZodOptional<z.ZodArray<z.ZodObject<{
20
- id: z.ZodString;
21
- }, "strip", z.ZodTypeAny, {
22
- id?: string;
23
- }, {
24
- id?: string;
25
- }>, "many">>;
26
- translations: z.ZodOptional<z.ZodArray<z.ZodObject<{
27
- locale: z.ZodString;
28
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
29
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
30
- url: z.ZodOptional<z.ZodString>;
31
- }, "strip", z.ZodTypeAny, {
32
- title?: string;
33
- content?: string;
34
- url?: string;
35
- locale?: string;
36
- }, {
37
- title?: string;
38
- content?: string;
39
- url?: string;
40
- locale?: string;
41
- }>, "many">>;
42
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
43
- id: z.ZodString;
44
- appId: z.ZodOptional<z.ZodString>;
45
- type: z.ZodOptional<z.ZodString>;
46
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
47
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
48
- author: z.ZodOptional<z.ZodString>;
49
- url: z.ZodOptional<z.ZodString>;
50
- passports: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
51
- createdAt: z.ZodOptional<z.ZodNumber>;
52
- updatedAt: z.ZodOptional<z.ZodNumber>;
53
- image: z.ZodOptional<z.ZodString>;
54
- labels: z.ZodOptional<z.ZodArray<z.ZodObject<{
55
- id: z.ZodString;
56
- }, "strip", z.ZodTypeAny, {
57
- id?: string;
58
- }, {
59
- id?: string;
60
- }>, "many">>;
61
- translations: z.ZodOptional<z.ZodArray<z.ZodObject<{
62
- locale: z.ZodString;
63
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
64
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
65
- url: z.ZodOptional<z.ZodString>;
66
- }, "strip", z.ZodTypeAny, {
67
- title?: string;
68
- content?: string;
69
- url?: string;
70
- locale?: string;
71
- }, {
72
- title?: string;
73
- content?: string;
74
- url?: string;
75
- locale?: string;
76
- }>, "many">>;
77
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
78
- id: z.ZodString;
79
- appId: z.ZodOptional<z.ZodString>;
80
- type: z.ZodOptional<z.ZodString>;
81
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
82
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
83
- author: z.ZodOptional<z.ZodString>;
84
- url: z.ZodOptional<z.ZodString>;
85
- passports: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
86
- createdAt: z.ZodOptional<z.ZodNumber>;
87
- updatedAt: z.ZodOptional<z.ZodNumber>;
88
- image: z.ZodOptional<z.ZodString>;
89
- labels: z.ZodOptional<z.ZodArray<z.ZodObject<{
90
- id: z.ZodString;
91
- }, "strip", z.ZodTypeAny, {
92
- id?: string;
93
- }, {
94
- id?: string;
95
- }>, "many">>;
96
- translations: z.ZodOptional<z.ZodArray<z.ZodObject<{
97
- locale: z.ZodString;
98
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
99
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
100
- url: z.ZodOptional<z.ZodString>;
101
- }, "strip", z.ZodTypeAny, {
102
- title?: string;
103
- content?: string;
104
- url?: string;
105
- locale?: string;
106
- }, {
107
- title?: string;
108
- content?: string;
109
- url?: string;
110
- locale?: string;
111
- }>, "many">>;
112
- }, z.ZodTypeAny, "passthrough">>;
113
- declare const SerpDocsSchema: z.ZodArray<z.ZodObject<{
114
- id: z.ZodString;
115
- appId: z.ZodOptional<z.ZodString>;
116
- type: z.ZodOptional<z.ZodString>;
117
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
118
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
119
- author: z.ZodOptional<z.ZodString>;
120
- url: z.ZodOptional<z.ZodString>;
121
- passports: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
122
- createdAt: z.ZodOptional<z.ZodNumber>;
123
- updatedAt: z.ZodOptional<z.ZodNumber>;
124
- image: z.ZodOptional<z.ZodString>;
125
- labels: z.ZodOptional<z.ZodArray<z.ZodObject<{
126
- id: z.ZodString;
127
- }, "strip", z.ZodTypeAny, {
128
- id?: string;
129
- }, {
130
- id?: string;
131
- }>, "many">>;
132
- translations: z.ZodOptional<z.ZodArray<z.ZodObject<{
133
- locale: z.ZodString;
134
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
135
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
136
- url: z.ZodOptional<z.ZodString>;
137
- }, "strip", z.ZodTypeAny, {
138
- title?: string;
139
- content?: string;
140
- url?: string;
141
- locale?: string;
142
- }, {
143
- title?: string;
144
- content?: string;
145
- url?: string;
146
- locale?: string;
147
- }>, "many">>;
148
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
149
- id: z.ZodString;
150
- appId: z.ZodOptional<z.ZodString>;
151
- type: z.ZodOptional<z.ZodString>;
152
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
153
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
154
- author: z.ZodOptional<z.ZodString>;
155
- url: z.ZodOptional<z.ZodString>;
156
- passports: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
157
- createdAt: z.ZodOptional<z.ZodNumber>;
158
- updatedAt: z.ZodOptional<z.ZodNumber>;
159
- image: z.ZodOptional<z.ZodString>;
160
- labels: z.ZodOptional<z.ZodArray<z.ZodObject<{
161
- id: z.ZodString;
162
- }, "strip", z.ZodTypeAny, {
163
- id?: string;
164
- }, {
165
- id?: string;
166
- }>, "many">>;
167
- translations: z.ZodOptional<z.ZodArray<z.ZodObject<{
168
- locale: z.ZodString;
169
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
170
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
171
- url: z.ZodOptional<z.ZodString>;
172
- }, "strip", z.ZodTypeAny, {
173
- title?: string;
174
- content?: string;
175
- url?: string;
176
- locale?: string;
177
- }, {
178
- title?: string;
179
- content?: string;
180
- url?: string;
181
- locale?: string;
182
- }>, "many">>;
183
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
184
- id: z.ZodString;
185
- appId: z.ZodOptional<z.ZodString>;
186
- type: z.ZodOptional<z.ZodString>;
187
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
188
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
189
- author: z.ZodOptional<z.ZodString>;
190
- url: z.ZodOptional<z.ZodString>;
191
- passports: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
192
- createdAt: z.ZodOptional<z.ZodNumber>;
193
- updatedAt: z.ZodOptional<z.ZodNumber>;
194
- image: z.ZodOptional<z.ZodString>;
195
- labels: z.ZodOptional<z.ZodArray<z.ZodObject<{
196
- id: z.ZodString;
197
- }, "strip", z.ZodTypeAny, {
198
- id?: string;
199
- }, {
200
- id?: string;
201
- }>, "many">>;
202
- translations: z.ZodOptional<z.ZodArray<z.ZodObject<{
203
- locale: z.ZodString;
204
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
205
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
206
- url: z.ZodOptional<z.ZodString>;
207
- }, "strip", z.ZodTypeAny, {
208
- title?: string;
209
- content?: string;
210
- url?: string;
211
- locale?: string;
212
- }, {
213
- title?: string;
214
- content?: string;
215
- url?: string;
216
- locale?: string;
217
- }>, "many">>;
218
- }, z.ZodTypeAny, "passthrough">>, "many">;
219
- type SerpDoc = z.infer<typeof SerpDocSchema>;
220
- type SerpDocs = z.infer<typeof SerpDocsSchema>;
221
-
222
- declare class SerpIndex {
223
- private index;
224
- constructor(index: Index<SerpDoc>);
225
- search(query: string, options?: SearchParams): Promise<meilisearch.SearchResponse<zod.objectOutputType<{
226
- id: zod.ZodString;
227
- appId: zod.ZodOptional<zod.ZodString>;
228
- type: zod.ZodOptional<zod.ZodString>;
229
- title: zod.ZodNullable<zod.ZodOptional<zod.ZodString>>;
230
- content: zod.ZodNullable<zod.ZodOptional<zod.ZodString>>;
231
- author: zod.ZodOptional<zod.ZodString>;
232
- url: zod.ZodOptional<zod.ZodString>;
233
- passports: zod.ZodOptional<zod.ZodArray<zod.ZodString, "many">>;
234
- createdAt: zod.ZodOptional<zod.ZodNumber>;
235
- updatedAt: zod.ZodOptional<zod.ZodNumber>;
236
- image: zod.ZodOptional<zod.ZodString>;
237
- labels: zod.ZodOptional<zod.ZodArray<zod.ZodObject<{
238
- id: zod.ZodString;
239
- }, "strip", zod.ZodTypeAny, {
240
- id?: string;
241
- }, {
242
- id?: string;
243
- }>, "many">>;
244
- translations: zod.ZodOptional<zod.ZodArray<zod.ZodObject<{
245
- locale: zod.ZodString;
246
- title: zod.ZodNullable<zod.ZodOptional<zod.ZodString>>;
247
- content: zod.ZodNullable<zod.ZodOptional<zod.ZodString>>;
248
- url: zod.ZodOptional<zod.ZodString>;
249
- }, "strip", zod.ZodTypeAny, {
250
- title?: string;
251
- content?: string;
252
- url?: string;
253
- locale?: string;
254
- }, {
255
- title?: string;
256
- content?: string;
257
- url?: string;
258
- locale?: string;
259
- }>, "many">>;
260
- }, zod.ZodTypeAny, "passthrough">, SearchParams>>;
261
- addDocuments(documents: SerpDocs, options?: DocumentOptions): Promise<meilisearch.EnqueuedTask>;
262
- updateDocuments(documents: SerpDocs, options?: DocumentOptions): Promise<meilisearch.EnqueuedTask>;
263
- deleteDocuments(documentIds: string[]): Promise<meilisearch.EnqueuedTask>;
264
- }
265
-
266
- declare const SERP_INDEX = "z8iZorY6mvb5tZrxXTqhBmwu89xjEEazrgT3t-search-kit-serp";
267
4
  declare class SearchKitClient extends MeiliSearch {
268
5
  constructor(config?: Omit<Config, 'host' | 'apiKey'>);
269
- get serpIndex(): SerpIndex;
270
6
  }
271
7
 
272
8
  type PartialRestEmbedder = Partial<RestEmbedder> & {
@@ -274,4 +10,4 @@ type PartialRestEmbedder = Partial<RestEmbedder> & {
274
10
  };
275
11
  declare const resolveRestEmbedders: ({ documentTemplate, ...rest }: PartialRestEmbedder) => Embedders;
276
12
 
277
- export { SERP_INDEX, SearchKitClient, type SerpDoc, SerpDocSchema, type SerpDocs, SerpDocsSchema, resolveRestEmbedders };
13
+ export { SearchKitClient, resolveRestEmbedders };
package/dist/index.d.ts CHANGED
@@ -1,272 +1,8 @@
1
- import * as meilisearch from 'meilisearch';
2
- import { Index, SearchParams, DocumentOptions, MeiliSearch, Config, Embedders, RestEmbedder } from 'meilisearch';
1
+ import { MeiliSearch, Config, Embedders, RestEmbedder } from 'meilisearch';
3
2
  export * from 'meilisearch';
4
- import * as zod from 'zod';
5
- import { z } from 'zod';
6
3
 
7
- declare const SerpDocSchema: z.ZodObject<{
8
- id: z.ZodString;
9
- appId: z.ZodOptional<z.ZodString>;
10
- type: z.ZodOptional<z.ZodString>;
11
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
12
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
13
- author: z.ZodOptional<z.ZodString>;
14
- url: z.ZodOptional<z.ZodString>;
15
- passports: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
16
- createdAt: z.ZodOptional<z.ZodNumber>;
17
- updatedAt: z.ZodOptional<z.ZodNumber>;
18
- image: z.ZodOptional<z.ZodString>;
19
- labels: z.ZodOptional<z.ZodArray<z.ZodObject<{
20
- id: z.ZodString;
21
- }, "strip", z.ZodTypeAny, {
22
- id?: string;
23
- }, {
24
- id?: string;
25
- }>, "many">>;
26
- translations: z.ZodOptional<z.ZodArray<z.ZodObject<{
27
- locale: z.ZodString;
28
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
29
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
30
- url: z.ZodOptional<z.ZodString>;
31
- }, "strip", z.ZodTypeAny, {
32
- title?: string;
33
- content?: string;
34
- url?: string;
35
- locale?: string;
36
- }, {
37
- title?: string;
38
- content?: string;
39
- url?: string;
40
- locale?: string;
41
- }>, "many">>;
42
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
43
- id: z.ZodString;
44
- appId: z.ZodOptional<z.ZodString>;
45
- type: z.ZodOptional<z.ZodString>;
46
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
47
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
48
- author: z.ZodOptional<z.ZodString>;
49
- url: z.ZodOptional<z.ZodString>;
50
- passports: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
51
- createdAt: z.ZodOptional<z.ZodNumber>;
52
- updatedAt: z.ZodOptional<z.ZodNumber>;
53
- image: z.ZodOptional<z.ZodString>;
54
- labels: z.ZodOptional<z.ZodArray<z.ZodObject<{
55
- id: z.ZodString;
56
- }, "strip", z.ZodTypeAny, {
57
- id?: string;
58
- }, {
59
- id?: string;
60
- }>, "many">>;
61
- translations: z.ZodOptional<z.ZodArray<z.ZodObject<{
62
- locale: z.ZodString;
63
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
64
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
65
- url: z.ZodOptional<z.ZodString>;
66
- }, "strip", z.ZodTypeAny, {
67
- title?: string;
68
- content?: string;
69
- url?: string;
70
- locale?: string;
71
- }, {
72
- title?: string;
73
- content?: string;
74
- url?: string;
75
- locale?: string;
76
- }>, "many">>;
77
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
78
- id: z.ZodString;
79
- appId: z.ZodOptional<z.ZodString>;
80
- type: z.ZodOptional<z.ZodString>;
81
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
82
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
83
- author: z.ZodOptional<z.ZodString>;
84
- url: z.ZodOptional<z.ZodString>;
85
- passports: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
86
- createdAt: z.ZodOptional<z.ZodNumber>;
87
- updatedAt: z.ZodOptional<z.ZodNumber>;
88
- image: z.ZodOptional<z.ZodString>;
89
- labels: z.ZodOptional<z.ZodArray<z.ZodObject<{
90
- id: z.ZodString;
91
- }, "strip", z.ZodTypeAny, {
92
- id?: string;
93
- }, {
94
- id?: string;
95
- }>, "many">>;
96
- translations: z.ZodOptional<z.ZodArray<z.ZodObject<{
97
- locale: z.ZodString;
98
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
99
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
100
- url: z.ZodOptional<z.ZodString>;
101
- }, "strip", z.ZodTypeAny, {
102
- title?: string;
103
- content?: string;
104
- url?: string;
105
- locale?: string;
106
- }, {
107
- title?: string;
108
- content?: string;
109
- url?: string;
110
- locale?: string;
111
- }>, "many">>;
112
- }, z.ZodTypeAny, "passthrough">>;
113
- declare const SerpDocsSchema: z.ZodArray<z.ZodObject<{
114
- id: z.ZodString;
115
- appId: z.ZodOptional<z.ZodString>;
116
- type: z.ZodOptional<z.ZodString>;
117
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
118
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
119
- author: z.ZodOptional<z.ZodString>;
120
- url: z.ZodOptional<z.ZodString>;
121
- passports: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
122
- createdAt: z.ZodOptional<z.ZodNumber>;
123
- updatedAt: z.ZodOptional<z.ZodNumber>;
124
- image: z.ZodOptional<z.ZodString>;
125
- labels: z.ZodOptional<z.ZodArray<z.ZodObject<{
126
- id: z.ZodString;
127
- }, "strip", z.ZodTypeAny, {
128
- id?: string;
129
- }, {
130
- id?: string;
131
- }>, "many">>;
132
- translations: z.ZodOptional<z.ZodArray<z.ZodObject<{
133
- locale: z.ZodString;
134
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
135
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
136
- url: z.ZodOptional<z.ZodString>;
137
- }, "strip", z.ZodTypeAny, {
138
- title?: string;
139
- content?: string;
140
- url?: string;
141
- locale?: string;
142
- }, {
143
- title?: string;
144
- content?: string;
145
- url?: string;
146
- locale?: string;
147
- }>, "many">>;
148
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
149
- id: z.ZodString;
150
- appId: z.ZodOptional<z.ZodString>;
151
- type: z.ZodOptional<z.ZodString>;
152
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
153
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
154
- author: z.ZodOptional<z.ZodString>;
155
- url: z.ZodOptional<z.ZodString>;
156
- passports: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
157
- createdAt: z.ZodOptional<z.ZodNumber>;
158
- updatedAt: z.ZodOptional<z.ZodNumber>;
159
- image: z.ZodOptional<z.ZodString>;
160
- labels: z.ZodOptional<z.ZodArray<z.ZodObject<{
161
- id: z.ZodString;
162
- }, "strip", z.ZodTypeAny, {
163
- id?: string;
164
- }, {
165
- id?: string;
166
- }>, "many">>;
167
- translations: z.ZodOptional<z.ZodArray<z.ZodObject<{
168
- locale: z.ZodString;
169
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
170
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
171
- url: z.ZodOptional<z.ZodString>;
172
- }, "strip", z.ZodTypeAny, {
173
- title?: string;
174
- content?: string;
175
- url?: string;
176
- locale?: string;
177
- }, {
178
- title?: string;
179
- content?: string;
180
- url?: string;
181
- locale?: string;
182
- }>, "many">>;
183
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
184
- id: z.ZodString;
185
- appId: z.ZodOptional<z.ZodString>;
186
- type: z.ZodOptional<z.ZodString>;
187
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
188
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
189
- author: z.ZodOptional<z.ZodString>;
190
- url: z.ZodOptional<z.ZodString>;
191
- passports: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
192
- createdAt: z.ZodOptional<z.ZodNumber>;
193
- updatedAt: z.ZodOptional<z.ZodNumber>;
194
- image: z.ZodOptional<z.ZodString>;
195
- labels: z.ZodOptional<z.ZodArray<z.ZodObject<{
196
- id: z.ZodString;
197
- }, "strip", z.ZodTypeAny, {
198
- id?: string;
199
- }, {
200
- id?: string;
201
- }>, "many">>;
202
- translations: z.ZodOptional<z.ZodArray<z.ZodObject<{
203
- locale: z.ZodString;
204
- title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
205
- content: z.ZodNullable<z.ZodOptional<z.ZodString>>;
206
- url: z.ZodOptional<z.ZodString>;
207
- }, "strip", z.ZodTypeAny, {
208
- title?: string;
209
- content?: string;
210
- url?: string;
211
- locale?: string;
212
- }, {
213
- title?: string;
214
- content?: string;
215
- url?: string;
216
- locale?: string;
217
- }>, "many">>;
218
- }, z.ZodTypeAny, "passthrough">>, "many">;
219
- type SerpDoc = z.infer<typeof SerpDocSchema>;
220
- type SerpDocs = z.infer<typeof SerpDocsSchema>;
221
-
222
- declare class SerpIndex {
223
- private index;
224
- constructor(index: Index<SerpDoc>);
225
- search(query: string, options?: SearchParams): Promise<meilisearch.SearchResponse<zod.objectOutputType<{
226
- id: zod.ZodString;
227
- appId: zod.ZodOptional<zod.ZodString>;
228
- type: zod.ZodOptional<zod.ZodString>;
229
- title: zod.ZodNullable<zod.ZodOptional<zod.ZodString>>;
230
- content: zod.ZodNullable<zod.ZodOptional<zod.ZodString>>;
231
- author: zod.ZodOptional<zod.ZodString>;
232
- url: zod.ZodOptional<zod.ZodString>;
233
- passports: zod.ZodOptional<zod.ZodArray<zod.ZodString, "many">>;
234
- createdAt: zod.ZodOptional<zod.ZodNumber>;
235
- updatedAt: zod.ZodOptional<zod.ZodNumber>;
236
- image: zod.ZodOptional<zod.ZodString>;
237
- labels: zod.ZodOptional<zod.ZodArray<zod.ZodObject<{
238
- id: zod.ZodString;
239
- }, "strip", zod.ZodTypeAny, {
240
- id?: string;
241
- }, {
242
- id?: string;
243
- }>, "many">>;
244
- translations: zod.ZodOptional<zod.ZodArray<zod.ZodObject<{
245
- locale: zod.ZodString;
246
- title: zod.ZodNullable<zod.ZodOptional<zod.ZodString>>;
247
- content: zod.ZodNullable<zod.ZodOptional<zod.ZodString>>;
248
- url: zod.ZodOptional<zod.ZodString>;
249
- }, "strip", zod.ZodTypeAny, {
250
- title?: string;
251
- content?: string;
252
- url?: string;
253
- locale?: string;
254
- }, {
255
- title?: string;
256
- content?: string;
257
- url?: string;
258
- locale?: string;
259
- }>, "many">>;
260
- }, zod.ZodTypeAny, "passthrough">, SearchParams>>;
261
- addDocuments(documents: SerpDocs, options?: DocumentOptions): Promise<meilisearch.EnqueuedTask>;
262
- updateDocuments(documents: SerpDocs, options?: DocumentOptions): Promise<meilisearch.EnqueuedTask>;
263
- deleteDocuments(documentIds: string[]): Promise<meilisearch.EnqueuedTask>;
264
- }
265
-
266
- declare const SERP_INDEX = "z8iZorY6mvb5tZrxXTqhBmwu89xjEEazrgT3t-search-kit-serp";
267
4
  declare class SearchKitClient extends MeiliSearch {
268
5
  constructor(config?: Omit<Config, 'host' | 'apiKey'>);
269
- get serpIndex(): SerpIndex;
270
6
  }
271
7
 
272
8
  type PartialRestEmbedder = Partial<RestEmbedder> & {
@@ -274,4 +10,4 @@ type PartialRestEmbedder = Partial<RestEmbedder> & {
274
10
  };
275
11
  declare const resolveRestEmbedders: ({ documentTemplate, ...rest }: PartialRestEmbedder) => Embedders;
276
12
 
277
- export { SERP_INDEX, SearchKitClient, type SerpDoc, SerpDocSchema, type SerpDocs, SerpDocsSchema, resolveRestEmbedders };
13
+ export { SearchKitClient, resolveRestEmbedders };
package/dist/index.mjs CHANGED
@@ -4,76 +4,11 @@ import { getComponentWebEndpoint, getComponentMountPoint } from '@blocklet/sdk/l
4
4
  import { sign } from '@blocklet/sdk/lib/util/verify-sign';
5
5
  import axios from 'axios';
6
6
  import { joinURL } from 'ufo';
7
- import config from '@blocklet/sdk/lib/config';
8
- import { z } from 'zod';
9
7
  import getWallet from '@blocklet/sdk/lib/wallet';
10
8
  import env from '@blocklet/sdk/lib/env';
11
9
  import crypto from 'crypto';
12
10
 
13
- const SerpDocSchema = z.object({
14
- id: z.string(),
15
- appId: z.string().optional(),
16
- type: z.string().optional(),
17
- title: z.string().optional().nullable(),
18
- content: z.string().optional().nullable(),
19
- author: z.string().optional(),
20
- url: z.string().optional(),
21
- passports: z.array(z.string()).optional(),
22
- createdAt: z.number().optional(),
23
- updatedAt: z.number().optional(),
24
- image: z.string().optional(),
25
- labels: z.array(z.object({ id: z.string() })).optional(),
26
- translations: z.array(
27
- z.object({
28
- locale: z.string(),
29
- title: z.string().optional().nullable(),
30
- content: z.string().optional().nullable(),
31
- url: z.string().optional()
32
- })
33
- ).optional()
34
- }).passthrough();
35
- const SerpDocsSchema = z.array(SerpDocSchema);
36
-
37
- var __defProp = Object.defineProperty;
38
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
39
- var __publicField = (obj, key, value) => {
40
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
41
- return value;
42
- };
43
- const resolveSerpDocId = (id) => `${config.env.appId}--${id}`;
44
- const resolveSerpDoc = (doc) => ({ ...doc, id: resolveSerpDocId(doc.id), appId: config.env.appId });
45
- class SerpIndex {
46
- constructor(index) {
47
- __publicField(this, "index");
48
- this.index = index;
49
- }
50
- search(query, options) {
51
- return this.index.search(query, options);
52
- }
53
- addDocuments(documents, options) {
54
- const valid = SerpDocsSchema.safeParse(documents);
55
- if (!valid.success) {
56
- throw new Error(`Invalid documents: ${valid.error}`);
57
- }
58
- const data = valid.data.map((doc) => resolveSerpDoc(doc));
59
- return this.index.addDocuments(data, options);
60
- }
61
- updateDocuments(documents, options) {
62
- const valid = SerpDocsSchema.safeParse(documents);
63
- if (!valid.success) {
64
- throw new Error(`Invalid documents: ${valid.error}`);
65
- }
66
- const data = valid.data.map((doc) => resolveSerpDoc(doc));
67
- return this.index.updateDocuments(data, options);
68
- }
69
- deleteDocuments(documentIds) {
70
- const ids = documentIds.map((id) => resolveSerpDocId(id));
71
- return this.index.deleteDocuments(ids);
72
- }
73
- }
74
-
75
11
  const SEARCH_KIT_DID = "z8iZorY6mvb5tZrxXTqhBmwu89xjEEazrgT3t";
76
- const SERP_INDEX = `${SEARCH_KIT_DID}-search-kit-serp`;
77
12
  class SearchKitClient extends MeiliSearch {
78
13
  constructor(config) {
79
14
  const endpoint = getComponentWebEndpoint(SEARCH_KIT_DID);
@@ -95,9 +30,6 @@ class SearchKitClient extends MeiliSearch {
95
30
  ...config
96
31
  });
97
32
  }
98
- get serpIndex() {
99
- return new SerpIndex(this.index(SERP_INDEX));
100
- }
101
33
  }
102
34
 
103
35
  const hash = (str, salt) => crypto.createHash("sha256").update(str + salt).digest("hex");
@@ -124,4 +56,4 @@ const resolveRestEmbedders = ({ documentTemplate, ...rest }) => {
124
56
  };
125
57
  };
126
58
 
127
- export { SERP_INDEX, SearchKitClient, SerpDocSchema, SerpDocsSchema, resolveRestEmbedders };
59
+ export { SearchKitClient, resolveRestEmbedders };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/search-kit-js",
3
- "version": "0.2.19",
3
+ "version": "0.2.21",
4
4
  "author": "Arcblock <blocklet@arcblock.io> https://github.com/blocklet",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",