@tinacms/search 0.0.0-e0ddb8c-20241004065742 → 0.0.0-e27c017-20250619233313
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.js +18 -18
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -17,20 +17,24 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
23
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
28
|
|
|
25
29
|
// src/index.ts
|
|
26
|
-
var
|
|
27
|
-
__export(
|
|
30
|
+
var index_exports = {};
|
|
31
|
+
__export(index_exports, {
|
|
28
32
|
LocalSearchIndexClient: () => LocalSearchIndexClient,
|
|
29
33
|
SearchIndexer: () => SearchIndexer,
|
|
30
34
|
TinaCMSSearchIndexClient: () => TinaCMSSearchIndexClient,
|
|
31
35
|
si: () => import_search_index2.default
|
|
32
36
|
});
|
|
33
|
-
module.exports = __toCommonJS(
|
|
37
|
+
module.exports = __toCommonJS(index_exports);
|
|
34
38
|
var import_search_index2 = __toESM(require("search-index"));
|
|
35
39
|
|
|
36
40
|
// src/indexer/index.ts
|
|
@@ -61,7 +65,6 @@ var StringBuilder = class {
|
|
|
61
65
|
}
|
|
62
66
|
};
|
|
63
67
|
var extractText = (data, acc, indexableNodeTypes) => {
|
|
64
|
-
var _a, _b;
|
|
65
68
|
if (data) {
|
|
66
69
|
if (indexableNodeTypes.indexOf(data.type) !== -1 && (data.text || data.value)) {
|
|
67
70
|
const tokens = tokenizeString(data.text || data.value);
|
|
@@ -71,8 +74,7 @@ var extractText = (data, acc, indexableNodeTypes) => {
|
|
|
71
74
|
}
|
|
72
75
|
}
|
|
73
76
|
}
|
|
74
|
-
|
|
75
|
-
_a,
|
|
77
|
+
data.children?.forEach?.(
|
|
76
78
|
(child) => extractText(child, acc, indexableNodeTypes)
|
|
77
79
|
);
|
|
78
80
|
}
|
|
@@ -99,7 +101,7 @@ var processDocumentForIndexing = (data, path, collection, textIndexLength, field
|
|
|
99
101
|
data["_id"] = `${collection.name}:${relPath}`;
|
|
100
102
|
data["_relativePath"] = relPath;
|
|
101
103
|
}
|
|
102
|
-
for (const f of
|
|
104
|
+
for (const f of field?.fields || collection.fields || []) {
|
|
103
105
|
if (!f.searchable) {
|
|
104
106
|
delete data[f.name];
|
|
105
107
|
continue;
|
|
@@ -211,7 +213,6 @@ var SearchIndexer = class {
|
|
|
211
213
|
};
|
|
212
214
|
}
|
|
213
215
|
async indexContentByPaths(documentPaths) {
|
|
214
|
-
var _a, _b, _c, _d;
|
|
215
216
|
let batch = [];
|
|
216
217
|
const itemCallback = async (item) => {
|
|
217
218
|
batch.push(item);
|
|
@@ -220,7 +221,7 @@ var SearchIndexer = class {
|
|
|
220
221
|
batch = [];
|
|
221
222
|
}
|
|
222
223
|
};
|
|
223
|
-
await
|
|
224
|
+
await this.client.onStartIndexing?.();
|
|
224
225
|
await (0, import_graphql.scanContentByPaths)(
|
|
225
226
|
this.schema,
|
|
226
227
|
documentPaths,
|
|
@@ -229,11 +230,10 @@ var SearchIndexer = class {
|
|
|
229
230
|
if (batch.length > 0) {
|
|
230
231
|
await this.client.put(batch);
|
|
231
232
|
}
|
|
232
|
-
await
|
|
233
|
+
await this.client.onFinishIndexing?.();
|
|
233
234
|
}
|
|
234
235
|
async indexAllContent() {
|
|
235
|
-
|
|
236
|
-
await ((_b = (_a = this.client).onStartIndexing) == null ? void 0 : _b.call(_a));
|
|
236
|
+
await this.client.onStartIndexing?.();
|
|
237
237
|
let batch = [];
|
|
238
238
|
const itemCallback = async (item) => {
|
|
239
239
|
batch.push(item);
|
|
@@ -250,14 +250,13 @@ var SearchIndexer = class {
|
|
|
250
250
|
if (batch.length > 0) {
|
|
251
251
|
await this.client.put(batch);
|
|
252
252
|
}
|
|
253
|
-
await
|
|
253
|
+
await this.client.onFinishIndexing?.();
|
|
254
254
|
return { warnings };
|
|
255
255
|
}
|
|
256
256
|
async deleteIndexContent(documentPaths) {
|
|
257
|
-
|
|
258
|
-
await ((_b = (_a = this.client).onStartIndexing) == null ? void 0 : _b.call(_a));
|
|
257
|
+
await this.client.onStartIndexing?.();
|
|
259
258
|
await this.client.del(documentPaths);
|
|
260
|
-
await
|
|
259
|
+
await this.client.onFinishIndexing?.();
|
|
261
260
|
}
|
|
262
261
|
};
|
|
263
262
|
|
|
@@ -265,7 +264,7 @@ var SearchIndexer = class {
|
|
|
265
264
|
var import_sqlite_level = require("sqlite-level");
|
|
266
265
|
var import_search_index = __toESM(require("search-index"));
|
|
267
266
|
var import_memory_level = require("memory-level");
|
|
268
|
-
var zlib = __toESM(require("zlib"));
|
|
267
|
+
var zlib = __toESM(require("node:zlib"));
|
|
269
268
|
var DEFAULT_TOKEN_SPLIT_REGEX = /[\p{L}\d_]+/gu;
|
|
270
269
|
var LocalSearchIndexClient = class {
|
|
271
270
|
constructor(options) {
|
|
@@ -275,6 +274,7 @@ var LocalSearchIndexClient = class {
|
|
|
275
274
|
}
|
|
276
275
|
async onStartIndexing() {
|
|
277
276
|
this.searchIndex = await (0, import_search_index.default)({
|
|
277
|
+
// @ts-ignore
|
|
278
278
|
db: this.memoryLevel,
|
|
279
279
|
stopwords: this.stopwords,
|
|
280
280
|
tokenSplitRegex: this.tokenSplitRegex
|
|
@@ -332,7 +332,7 @@ var TinaCMSSearchIndexClient = class extends LocalSearchIndexClient {
|
|
|
332
332
|
console.error("Failed to parse error response", e);
|
|
333
333
|
}
|
|
334
334
|
throw new Error(
|
|
335
|
-
`Failed to get upload url. Status: ${res.status}${
|
|
335
|
+
`Failed to get upload url. Status: ${res.status}${json?.message ? ` - ${json.message}` : ``}`
|
|
336
336
|
);
|
|
337
337
|
}
|
|
338
338
|
const { signedUrl } = await res.json();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/search",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-e27c017-20250619233313",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index-client.mjs",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"memory-level": "^1.0.0",
|
|
33
33
|
"search-index": "4.0.0",
|
|
34
|
-
"sqlite-level": "^1.2.
|
|
35
|
-
"stopword": "^3.1.
|
|
36
|
-
"@tinacms/graphql": "0.0.0-
|
|
37
|
-
"@tinacms/schema-tools": "0.0.0-
|
|
34
|
+
"sqlite-level": "^1.2.1",
|
|
35
|
+
"stopword": "^3.1.4",
|
|
36
|
+
"@tinacms/graphql": "0.0.0-e27c017-20250619233313",
|
|
37
|
+
"@tinacms/schema-tools": "0.0.0-e27c017-20250619233313"
|
|
38
38
|
},
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"registry": "https://registry.npmjs.org"
|
|
@@ -44,16 +44,16 @@
|
|
|
44
44
|
"directory": "packages/@tinacms/search"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@types/jest": "^29.5.
|
|
47
|
+
"@types/jest": "^29.5.14",
|
|
48
48
|
"@types/micromatch": "^4.0.9",
|
|
49
|
-
"@types/node": "^22.
|
|
49
|
+
"@types/node": "^22.13.1",
|
|
50
50
|
"@types/search-index": "^3.2.4",
|
|
51
51
|
"jest": "^29.7.0",
|
|
52
52
|
"jest-diff": "^29.7.0",
|
|
53
53
|
"jest-file-snapshot": "^0.7.0",
|
|
54
54
|
"jest-matcher-utils": "^29.7.0",
|
|
55
|
-
"typescript": "^5.
|
|
56
|
-
"@tinacms/scripts": "1.
|
|
55
|
+
"typescript": "^5.7.3",
|
|
56
|
+
"@tinacms/scripts": "1.3.5"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"types": "pnpm tsc",
|