@tinacms/search 0.0.0-cef656e-20250119001929 → 0.0.0-d1bd1a1-20251124051649

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.
Files changed (2) hide show
  1. package/dist/index.js +18 -24
  2. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -27,14 +27,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
28
 
29
29
  // src/index.ts
30
- var src_exports = {};
31
- __export(src_exports, {
30
+ var index_exports = {};
31
+ __export(index_exports, {
32
32
  LocalSearchIndexClient: () => LocalSearchIndexClient,
33
33
  SearchIndexer: () => SearchIndexer,
34
34
  TinaCMSSearchIndexClient: () => TinaCMSSearchIndexClient,
35
35
  si: () => import_search_index2.default
36
36
  });
37
- module.exports = __toCommonJS(src_exports);
37
+ module.exports = __toCommonJS(index_exports);
38
38
  var import_search_index2 = __toESM(require("search-index"));
39
39
 
40
40
  // src/indexer/index.ts
@@ -65,7 +65,6 @@ var StringBuilder = class {
65
65
  }
66
66
  };
67
67
  var extractText = (data, acc, indexableNodeTypes) => {
68
- var _a, _b;
69
68
  if (data) {
70
69
  if (indexableNodeTypes.indexOf(data.type) !== -1 && (data.text || data.value)) {
71
70
  const tokens = tokenizeString(data.text || data.value);
@@ -75,8 +74,7 @@ var extractText = (data, acc, indexableNodeTypes) => {
75
74
  }
76
75
  }
77
76
  }
78
- (_b = (_a = data.children) == null ? void 0 : _a.forEach) == null ? void 0 : _b.call(
79
- _a,
77
+ data.children?.forEach?.(
80
78
  (child) => extractText(child, acc, indexableNodeTypes)
81
79
  );
82
80
  }
@@ -103,7 +101,7 @@ var processDocumentForIndexing = (data, path, collection, textIndexLength, field
103
101
  data["_id"] = `${collection.name}:${relPath}`;
104
102
  data["_relativePath"] = relPath;
105
103
  }
106
- for (const f of (field == null ? void 0 : field.fields) || collection.fields || []) {
104
+ for (const f of field?.fields || collection.fields || []) {
107
105
  if (!f.searchable) {
108
106
  delete data[f.name];
109
107
  continue;
@@ -189,9 +187,9 @@ var SearchIndexer = class {
189
187
  return async (collection, contentPaths) => {
190
188
  const templateInfo = this.schema.getTemplatesForCollectable(collection);
191
189
  await (0, import_graphql.sequential)(contentPaths, async (path) => {
192
- const data = await (0, import_graphql.transformDocumentIntoPayload)({
193
- fullPath: `${collection.path}/${path}`,
194
- rawData: (0, import_graphql.transformDocument)(
190
+ const data = await (0, import_graphql.transformDocumentIntoPayload)(
191
+ `${collection.path}/${path}`,
192
+ (0, import_graphql.transformDocument)(
195
193
  path,
196
194
  await (0, import_graphql.loadAndParseWithAliases)(
197
195
  this.bridge,
@@ -201,9 +199,8 @@ var SearchIndexer = class {
201
199
  ),
202
200
  this.schema
203
201
  ),
204
- tinaSchema: this.schema,
205
- context: {}
206
- });
202
+ this.schema
203
+ );
207
204
  await itemCallback(
208
205
  processDocumentForIndexing(
209
206
  data["_values"],
@@ -216,7 +213,6 @@ var SearchIndexer = class {
216
213
  };
217
214
  }
218
215
  async indexContentByPaths(documentPaths) {
219
- var _a, _b, _c, _d;
220
216
  let batch = [];
221
217
  const itemCallback = async (item) => {
222
218
  batch.push(item);
@@ -225,7 +221,7 @@ var SearchIndexer = class {
225
221
  batch = [];
226
222
  }
227
223
  };
228
- await ((_b = (_a = this.client).onStartIndexing) == null ? void 0 : _b.call(_a));
224
+ await this.client.onStartIndexing?.();
229
225
  await (0, import_graphql.scanContentByPaths)(
230
226
  this.schema,
231
227
  documentPaths,
@@ -234,11 +230,10 @@ var SearchIndexer = class {
234
230
  if (batch.length > 0) {
235
231
  await this.client.put(batch);
236
232
  }
237
- await ((_d = (_c = this.client).onFinishIndexing) == null ? void 0 : _d.call(_c));
233
+ await this.client.onFinishIndexing?.();
238
234
  }
239
235
  async indexAllContent() {
240
- var _a, _b, _c, _d;
241
- await ((_b = (_a = this.client).onStartIndexing) == null ? void 0 : _b.call(_a));
236
+ await this.client.onStartIndexing?.();
242
237
  let batch = [];
243
238
  const itemCallback = async (item) => {
244
239
  batch.push(item);
@@ -255,14 +250,13 @@ var SearchIndexer = class {
255
250
  if (batch.length > 0) {
256
251
  await this.client.put(batch);
257
252
  }
258
- await ((_d = (_c = this.client).onFinishIndexing) == null ? void 0 : _d.call(_c));
253
+ await this.client.onFinishIndexing?.();
259
254
  return { warnings };
260
255
  }
261
256
  async deleteIndexContent(documentPaths) {
262
- var _a, _b, _c, _d;
263
- await ((_b = (_a = this.client).onStartIndexing) == null ? void 0 : _b.call(_a));
257
+ await this.client.onStartIndexing?.();
264
258
  await this.client.del(documentPaths);
265
- await ((_d = (_c = this.client).onFinishIndexing) == null ? void 0 : _d.call(_c));
259
+ await this.client.onFinishIndexing?.();
266
260
  }
267
261
  };
268
262
 
@@ -270,7 +264,7 @@ var SearchIndexer = class {
270
264
  var import_sqlite_level = require("sqlite-level");
271
265
  var import_search_index = __toESM(require("search-index"));
272
266
  var import_memory_level = require("memory-level");
273
- var zlib = __toESM(require("zlib"));
267
+ var zlib = __toESM(require("node:zlib"));
274
268
  var DEFAULT_TOKEN_SPLIT_REGEX = /[\p{L}\d_]+/gu;
275
269
  var LocalSearchIndexClient = class {
276
270
  constructor(options) {
@@ -338,7 +332,7 @@ var TinaCMSSearchIndexClient = class extends LocalSearchIndexClient {
338
332
  console.error("Failed to parse error response", e);
339
333
  }
340
334
  throw new Error(
341
- `Failed to get upload url. Status: ${res.status}${(json == null ? void 0 : json.message) ? ` - ${json.message}` : ``}`
335
+ `Failed to get upload url. Status: ${res.status}${json?.message ? ` - ${json.message}` : ``}`
342
336
  );
343
337
  }
344
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-cef656e-20250119001929",
3
+ "version": "0.0.0-d1bd1a1-20251124051649",
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.0",
35
- "stopword": "^3.1.1",
36
- "@tinacms/graphql": "0.0.0-cef656e-20250119001929",
37
- "@tinacms/schema-tools": "1.7.0"
34
+ "sqlite-level": "^1.2.1",
35
+ "stopword": "^3.1.4",
36
+ "@tinacms/graphql": "0.0.0-d1bd1a1-20251124051649",
37
+ "@tinacms/schema-tools": "0.0.0-d1bd1a1-20251124051649"
38
38
  },
39
39
  "publishConfig": {
40
40
  "registry": "https://registry.npmjs.org"
@@ -46,14 +46,14 @@
46
46
  "devDependencies": {
47
47
  "@types/jest": "^29.5.14",
48
48
  "@types/micromatch": "^4.0.9",
49
- "@types/node": "^22.9.0",
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.6.3",
56
- "@tinacms/scripts": "1.3.1"
55
+ "typescript": "^5.7.3",
56
+ "@tinacms/scripts": "0.0.0-d1bd1a1-20251124051649"
57
57
  },
58
58
  "scripts": {
59
59
  "types": "pnpm tsc",